|
|
| Author |
Message |
Howie Cacti Guru User
Joined: 16 Sep 2004 Posts: 2252 Location: United Kingdom
|
Posted: Tue Nov 18, 2008 7:38 am Post subject: Migration from old to new API - user realms |
|
|
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
|
Posted: Tue Nov 18, 2008 8:34 am Post subject: |
|
|
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
|
Posted: Tue Nov 18, 2008 8:37 am Post subject: |
|
|
| 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
|
Posted: Tue Nov 18, 2008 8:53 am Post subject: |
|
|
1. I think is made specially for this purpose what not to be crossed with old realms
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
|
Posted: Tue Nov 18, 2008 8:57 am Post subject: |
|
|
| gthe wrote: | 1. I think is made specially for this purpose what not to be crossed with old realms
|
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
|
Posted: Thu Nov 27, 2008 8:49 am Post subject: |
|
|
| Howie wrote: | | gthe wrote: | 1. I think is made specially for this purpose what not to be crossed with old realms
|
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 |
|
 |
|