Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


Migration from old to new API - user realms

 
Post new topic   Reply to topic    Cacti Forum Index -> Plugin Development
Author Message
Howie
Cacti Guru User


Joined: 16 Sep 2004
Posts: 2252
Location: United Kingdom

PostPosted: Tue Nov 18, 2008 7:38 am    Post subject: Migration from old to new API - user realms Reply with quote

Is there anything in the API to make it nicer to move from the old, fixed realm numbers to dynamically allocated ones?

I can't see how I can migrate old permissions with confidence that I'm not just rewriting some other plugins permissions - I know that weathermap used to use 42 and 43.

If I get allocated a dynamic realm number, how do I know that the 42 and 43 in the user's system are old weathermap permissions and not some other plugin's dynamic realm?

The alternative is not to migrate them at all, which makes the user suffer for something that's not their fault.
Back to top
gthe
Cacti User


Joined: 29 Jul 2006
Posts: 113
Location: RU

PostPosted: Tue Nov 18, 2008 8:34 am    Post subject: Reply with quote

In snmptt plugin I use this to check snmptt admin realms status :
Code:

function is_snmptt_admin () {
global $user_auth_realm_filenames;
$rezult = 0;
//get snmptt Plugin -> SNMPTT: Manage Realm ID
$snmptt_admin_realm_id = db_fetch_cell("SELECT `id`+100 FROM `plugin_realms` where `display` like 'plugin%snmptt%manage%'");

if (isset($snmptt_admin_realm_id)) {
   //Check this user - for snmptt admin realms
   if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm
      where user_auth_realm.user_id='" . $_SESSION["sess_user_id"] . "'
      and user_auth_realm.realm_id='$snmptt_admin_realm_id'")) && (!empty($snmptt_admin_realm_id))) {
         $rezult = 1;
      }   
}

return $rezult;

}
Back to top
Howie
Cacti Guru User


Joined: 16 Sep 2004
Posts: 2252
Location: United Kingdom

PostPosted: Tue Nov 18, 2008 8:37 am    Post subject: Reply with quote

But that also doesn't check that it isn't already in use by another plugin.
Back to top
gthe
Cacti User


Joined: 29 Jul 2006
Posts: 113
Location: RU

PostPosted: Tue Nov 18, 2008 8:53 am    Post subject: Reply with quote

1. I think is made specially for this purpose what not to be crossed with old realms
Code:
`id`+100

2. Why You need to know who uses old realmID ? After installing new version of Weathermap with PA 2.x admin must recheck users permission and new realmID will be added.
Back to top
Howie
Cacti Guru User


Joined: 16 Sep 2004
Posts: 2252
Location: United Kingdom

PostPosted: Tue Nov 18, 2008 8:57 am    Post subject: Reply with quote

gthe wrote:
1. I think is made specially for this purpose what not to be crossed with old realms
Code:
`id`+100



No, that only finds a realm 100 above the other one. You don't check if it's already in use. Some plugins use large fixed numbers to try and avoid clashes too. Most of the time you will be lucky, but it's not right.

Quote:

2. Why You need to know who uses old realmID ? After installing new version of Weathermap with PA 2.x admin must recheck users permission and new realmID will be added.


I see that as a failure. Suppose the user has set up hundreds of users... why should they be forced to repeat that work?
Back to top
gthe
Cacti User


Joined: 29 Jul 2006
Posts: 113
Location: RU

PostPosted: Thu Nov 27, 2008 8:49 am    Post subject: Reply with quote

Howie wrote:
gthe wrote:
1. I think is made specially for this purpose what not to be crossed with old realms
Code:
`id`+100



No, that only finds a realm 100 above the other one. You don't check if it's already in use. Some plugins use large fixed numbers to try and avoid clashes too. Most of the time you will be lucky, but it's not right.

But even if you find unused realmID for install pia2.x plugin - there are no guarantees that then in future user don't install old plugin with you new realmID.
Howie wrote:

Quote:

2. Why You need to know who uses old realmID ? After installing new version of Weathermap with PA 2.x admin must recheck users permission and new realmID will be added.


I see that as a failure. Suppose the user has set up hundreds of users... why should they be forced to repeat that work?

I think it is a way go away from using realmID.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Plugin Development All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group