Example #1
0
 /**
  * Set option bit field for user options.
  *
  * @param int $key Option key, as defined in $keyoptions property.
  * @param bool $value True to set the option, false to clear the option.
  * @param int $data Current bit field value, or false to use $this->data['user_options']
  * @return int|bool If $data is false, the bit field is modified and
  *                  written back to $this->data['user_options'], and
  *                  return value is true if the bit field changed and
  *                  false otherwise. If $data is not false, the new
  *                  bitfield value is returned.
  */
 function optionset($key, $value, $data = false)
 {
     $var = $data !== false ? $data : $this->data['user_options'];
     $new_var = src_optionset($this->keyoptions[$key], $value, $var);
     if ($data === false) {
         if ($new_var != $var) {
             $this->data['user_options'] = $new_var;
             return true;
         } else {
             return false;
         }
     } else {
         return $new_var;
     }
 }
Example #2
0
 /**
  * Set option bit field for user options in a user row array.
  *
  * Optionset replacement for this module based on $user->optionset.
  *
  * @param array $user_row Row from the users table.
  * @param int $key Option key, as defined in $user->keyoptions property.
  * @param bool $value True to set the option, false to clear the option.
  * @param int $data Current bit field value, or false to use $user_row['user_options']
  * @return int|bool If $data is false, the bit field is modified and
  *                  written back to $user_row['user_options'], and
  *                  return value is true if the bit field changed and
  *                  false otherwise. If $data is not false, the new
  *                  bitfield value is returned.
  */
 function optionset(&$user_row, $key, $value, $data = false)
 {
     global $user;
     $var = $data !== false ? $data : $user_row['user_options'];
     $new_var = src_optionset($user->keyoptions[$key], $value, $var);
     if ($data === false) {
         if ($new_var != $var) {
             $user_row['user_options'] = $new_var;
             return true;
         } else {
             return false;
         }
     } else {
         return $new_var;
     }
 }