You are here

function tinybrowser_update_profiles in TinyBrowser 7

Add, update or delete a profile

2 calls to tinybrowser_update_profiles()
tinybrowser_profile_delete_submit in ./tinybrowser.module
Profile delete form submit
tinybrowser_profile_submit in ./tinybrowser.module
Profile form submit

File

./tinybrowser.module, line 988

Code

function tinybrowser_update_profiles($pid, $profile = NULL) {
  $profiles = variable_get('tinybrowser_profiles', array());

  // add or update
  if (isset($profile)) {
    $pid = isset($profiles[$pid]) ? $pid : count($profiles) + 1;
    $profiles[$pid] = $profile;
  }
  else {
    if (isset($profiles[$pid]) && $pid > 1) {
      unset($profiles[$pid]);
      for ($i = $pid + 1; isset($profiles[$i]); $i++) {
        $profiles[$i - 1] = $profiles[$i];
        unset($profiles[$i]);
      }
      tinybrowser_update_roles($pid);
    }
  }
  variable_set('tinybrowser_profiles', $profiles);
  return $pid;
}