Esempio n. 1
0
 /**
  * Get the user options. This function returns the option value for $name. If $name is not set,
  * it returns the array containing all the user options
  *
  * @param string $name The option name, formatted like '<plugin>.<key>'
  *
  * @return mixed The value for the option $name, or the array contaning all the user options
  */
 public function getOptions($name = '')
 {
     if (!isset($this->options)) {
         $example = $this->isLogged() ? array('userId' => $this->id) : array('userIp' => App::request()->clientIp());
         $options = UserOption::getListByExample(new DBExample($example));
         $this->options = array();
         foreach ($options as $option) {
             $this->options[$option->plugin . '.' . $option->key] = $option->value;
         }
     }
     if ($name) {
         return isset($this->options[$name]) ? $this->options[$name] : null;
     } else {
         return $this->options;
     }
 }