/** * This function will return paginated result. Result is an array where first element is * array of returned object and second populated pagination object that can be used for * obtaining and rendering pagination data using various helpers. * * Items and pagination array vars are indexed with 0 for items and 1 for pagination * because you can't use associative indexing with list() construct * * @access public * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! * @param integer $items_per_page Number of items per page * @param integer $current_page Current page number * @return array */ function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if (isset($this) && instance_of($this, 'UserWsConfigOptionValues')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return UserWsConfigOptionValues::instance()->paginate($arguments, $items_per_page, $current_page); //$instance =& ConfigOptions::instance(); //return $instance->paginate($arguments, $items_per_page, $current_page); } // if }
/** * Set value * */ function setUserValue($new_value, $user_id = 0, $workspace_id = 0) { $val = null; if (GlobalCache::isAvailable()) { $val = GlobalCache::get('user_copt_val_' . $user_id . "_" . $this->getId(), $success); } if (!$val) { $val = UserWsConfigOptionValues::findById(array('option_id' => $this->getId(), 'user_id' => $user_id, 'workspace_id' => $workspace_id)); } if (!$val) { // if value was not found, create it $val = new UserWsConfigOptionValue(); $val->setOptionId($this->getId()); $val->setUserId($user_id); $val->setWorkspaceId($workspace_id); } $val->setValue($new_value); $val->save(); $this->updateUserValueCache($user_id, $workspace_id, $val->getValue()); if (GlobalCache::isAvailable()) { GlobalCache::update('user_copt_val_' . $user_id . "_" . $this->getId(), $val); } }
function user_has_config_option($option_name, $user_id = 0, $workspace_id = 0) { //FIXME return; if (!$user_id && logged_user() instanceof User) { $user_id = logged_user()->getId(); } else { return false; } $option = UserWsConfigOptions::getByName($option_name); if (!$option instanceof UserWsConfigOption) return false; $value = UserWsConfigOptionValues::findById(array( 'option_id' => $option->getId(), 'user_id' => $user_id, 'workspace_id' => $workspace_id)); return $value instanceof UserWsConfigOptionValue; }
/** * Return manager instance * * @access protected * @param void * @return UserWsConfigOptionValues */ function manager() { if (!$this->manager instanceof UserWsConfigOptionValues) { $this->manager = UserWsConfigOptionValues::instance(); } return $this->manager; }
/** * Returns true if user info is updated by the user since user is created. * * @access public * @param void * @return boolean */ function hasPreferencesUpdated() { return UserWsConfigOptionValues::hasOptionValues($this); }