/** * Get a setting from the DB user settings table * * @param string name of setting * @param integer User ID (by default $current_User->ID will be used) */ function get($setting, $user_ID = NULL) { if (!isset($user_ID)) { global $current_User; if (!isset($current_User)) { // no current/logged in user: return $this->get_default($setting); } $user_ID = $current_User->ID; } return parent::get($user_ID, $setting); }
/** * Get a setting by name for the Plugin. * * @param string The settings name. * @param integer User ID (by default $current_User->ID will be used - make sure that it is available already in your event!) * @return mixed|NULL|false False in case of error, NULL if not found, the value otherwise. */ function get($setting, $user_ID = NULL) { if (!isset($user_ID)) { global $current_User; if (!isset($current_User)) { global $Debuglog; $Debuglog->add('No $current_User available in PluginUserSettings::get()/[ID' . $this->plugin_ID . ']!', array('errors', 'plugins')); return false; } $user_ID = $current_User->ID; } return parent::get($this->plugin_ID, $user_ID, $setting); }
/** * Get a setting from the DB user settings table * * @param string name of setting * @param integer User ID (by default $current_User->ID will be used) */ function get($setting, $user_ID = NULL) { global $Settings; if (!isset($user_ID)) { global $current_User; if (!isset($current_User)) { // no current/logged in user: $result = $this->get_default($setting); if ($result == NULL) { $result = $Settings->get('def_' . $setting); } return $result; } $user_ID = $current_User->ID; } $result = parent::get($user_ID, $setting); if ($result == NULL) { $result = $Settings->get('def_' . $setting); } return $result; }
/** * Get a member param by its name * * @param mixed Name of parameter * @param boolean true to return param's real value * @return mixed Value of parameter */ function get($parname, $real_value = false) { if ($real_value) { return parent::get($parname); } switch ($parname) { case 'allow_avatars': return parent::get($parname) && isset($GLOBALS['files_Module']); break; case 'upload_enabled': return parent::get($parname) && isset($GLOBALS['files_Module']); break; default: return parent::get($parname); } }
/** * Get a setting by name for the Plugin. * * @param string The settings name. * @return mixed|NULL|false False in case of error, NULL if not found, the value otherwise. */ function get($setting) { return parent::get($this->plugin_ID, $setting); }
/** * Log a creating of new item (Increase counter in global cache) * * @param string Source of item creation ( 'through_admin', 'through_xmlrpc', 'through_email' ) */ function log_new_item_create($created_through) { /** * @var AbstractSettings */ global $global_Cache; if (empty($global_Cache)) { // Init global cache if it is not defined (for example, during on install process) $global_Cache = new AbstractSettings('T_global__cache', array('cach_name'), 'cach_cache', 0); } if (!in_array($created_through, array('through_admin', 'through_xmlrpc', 'through_email'))) { // Set default value if source is wrong $created_through = 'through_admin'; } // Set variable name for current post counter $cache_var_name = 'post_' . $created_through; // Get previuos counter value $counter = (int) $global_Cache->get($cache_var_name); // Increase counter $global_Cache->set($cache_var_name, $counter + 1); // Update the changed data in global cache $global_Cache->dbupdate(); }
function test_cache_only_once() { $this->MockDB->expectAt(0, 'get_results', array(new PatternExpectation("/SELECT cset_coll_ID, cset_name, cset_value\\s+FROM T_coll_settings\$/"), ARRAY_A, 'Settings::load'), 'DB SELECT ok.'); $this->MockDB->expectOnce('get_results'); $s = new AbstractSettings('T_coll_settings', array('cset_coll_ID', 'cset_name'), 'cset_value', 0); $s->get("1", "cache_enabled"); $s->get("17", "title_link_type"); }
/** * Get a permission from the DB group settings table * * @param string name of permission * @param integer Group */ function get($permission, $grp_ID) { if ($grp_ID != 0) { // We can get permission from database, because the current group setting are available in database $this->permission_values[$permission] = parent::get($grp_ID, $permission); } return $this->permission_values[$permission]; }