/**
 * Set a there preference $string to $value.
 */
function setPref($data_dir, $username, $string, $value)
{
    global $prefs_cache;
    cachePrefValues($data_dir, $username);
    if (isset($prefs_cache[$string]) && $prefs_cache[$string] == $value) {
        return;
    }
    if ($value === '') {
        removePref($data_dir, $username, $string);
        return;
    }
    $prefs_cache[$string] = $value;
    savePrefValues($data_dir, $username);
}
Exemple #2
0
 function getKey($user, $key, $default = '')
 {
     global $prefs_cache;
     $result = do_hook_function('get_pref_override', array($user, $key));
     //FIXME: testing below for !$result means that a plugin cannot fetch its own pref value of 0, '0', '', FALSE, or anything else that evaluates to boolean FALSE.
     if (!$result) {
         cachePrefValues($user);
         if (isset($prefs_cache[$key])) {
             $result = $prefs_cache[$key];
         } else {
             //FIXME: is there justification for having these TWO hooks so close together?  who uses these?
             $result = do_hook_function('get_pref', array($user, $key));
             //FIXME: testing below for !$result means that a plugin cannot fetch its own pref value of 0, '0', '', FALSE, or anything else that evaluates to boolean FALSE.
             if (!$result) {
                 if (isset($this->default[$key])) {
                     $result = $this->default[$key];
                 } else {
                     $result = $default;
                 }
             }
         }
     }
     return $result;
 }
 function getKey($user, $key, $default = '')
 {
     global $prefs_cache;
     cachePrefValues($user);
     if (isset($prefs_cache[$key])) {
         return $prefs_cache[$key];
     } else {
         if (isset($this->default[$key])) {
             return $this->default[$key];
         } else {
             return $default;
         }
     }
 }
Exemple #4
0
 /**
  * Get user's prefs setting
  *
  * @param string $user user name
  * @param string $key preference name
  * @param mixed $default (since 1.2.5) default value
  *
  * @return mixed preference value
  *
  */
 function getKey($user, $key, $default = '')
 {
     global $prefs_cache;
     $temp = array(&$user, &$key);
     $result = do_hook('get_pref_override', $temp);
     if (is_null($result)) {
         cachePrefValues($user);
         if (isset($prefs_cache[$key])) {
             $result = $prefs_cache[$key];
         } else {
             //FIXME: is there a justification for having two prefs hooks so close?  who uses them?
             $temp = array(&$user, &$key);
             $result = do_hook('get_pref', $temp);
             if (is_null($result)) {
                 if (isset($this->default[$key])) {
                     $result = $this->default[$key];
                 } else {
                     $result = $default;
                 }
             }
         }
     }
     return $result;
 }