You are here

function smart_ip_update_6005 in Smart IP 6.2

Update the admin debug mode to role based debug mode

File

./smart_ip.install, line 227
Installation callback for Smart IP.

Code

function smart_ip_update_6005() {
  if (variable_get('smart_ip_debug', FALSE)) {
    $debug_ip = variable_get('smart_ip_test_ip_address', ip_address());
    $roles = user_roles();
    $roles_debug = array();
    $roles_debug_ip = array();
    $query = db_query('SELECT rid, perm FROM {permission} ORDER BY rid');
    foreach ($roles as $rid => $rolename) {
      while ($role = db_fetch_object($query)) {
        if ($role->rid == $rid && strpos($role->perm, 'administer smart_ip') !== FALSE) {
          $roles_debug[$rid] = $rid;
        }
        $roles_debug_ip[$rid] = $debug_ip;
      }
    }
    variable_set('smart_ip_roles_in_debug_mode', $roles_debug);
    variable_set('smart_ip_roles_in_debug_mode_ip', $roles_debug_ip);
  }
  variable_del('smart_ip_debug');
  variable_del('smart_ip_test_ip_address');
}