/**
  * Loads the settings. Not meant to be called directly, but gets called
  * when needed.
  *
  * @access protected
  * @param string First column key
  * @param string Second column key
  * @return boolean
  */
 function _load($coll_ID, $arg)
 {
     if (empty($coll_ID)) {
         return false;
     }
     return parent::_load($coll_ID, $arg);
 }
Esempio n. 2
0
 function __construct($apiKey = false)
 {
     parent::__construct();
     if (!$apiKey) {
         throw new \Exception("Missing API Key", 1);
     }
     $this->apiKey = $apiKey;
 }
Esempio n. 3
0
 /**
  * Constructor.
  *
  * This loads the general settings and checks db_version.
  *
  * It will also turn off error-reporting/halting of the {@link $DB DB object}
  * temporarily to present a more decent error message if tables do not exist yet.
  *
  * Because the {@link $DB DB object} itself creates a connection when it gets
  * created "Error selecting database" occurs before we can check for it here.
  */
 function GeneralSettings()
 {
     global $new_db_version, $DB;
     $save_DB_show_errors = $DB->show_errors;
     $save_DB_halt_on_error = $DB->halt_on_error;
     $DB->halt_on_error = false;
     $DB->show_errors = false;
     // Init through the abstract constructor. This should be the first DB connection.
     parent::AbstractSettings('T_settings', array('set_name'), 'set_value', 0);
     // check DB version:
     if ($this->get('db_version') != $new_db_version) {
         // Database is not up to date:
         if ($DB->last_error) {
             $error_message = '<p>MySQL error:</p>' . $DB->last_error;
         } else {
             $error_message = '<p>Database schema is not up to date!</p>' . '<p>You have schema version &laquo;' . (int) $this->get('db_version') . '&raquo;, ' . 'but we would need &laquo;' . (int) $new_db_version . '&raquo;.</p>';
         }
         global $adminskins_path;
         require $adminskins_path . 'conf_error.main.php';
         // error & exit
     }
     $DB->halt_on_error = $save_DB_halt_on_error;
     $DB->show_errors = $save_DB_show_errors;
 }
 /**
  * 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);
     }
 }
 /**
  * Delete a setting.
  *
  * Use {@link dbupdate()} to commit it to the database.
  *
  * @param string name of setting
  */
 function delete($setting)
 {
     return parent::delete($this->plugin_ID, $setting);
 }
Esempio n. 6
0
 /**
  * Delete a setting.
  *
  * Use {@link dbupdate()} to commit it to the database.
  *
  * @param string name of setting
  * @param integer User ID (by default $current_User->ID will be used - make sure that it is available already in your event!)
  */
 function delete($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::delete()/[ID' . $this->plugin_ID . ']!', array('errors', 'plugins'));
             return false;
         }
         $user_ID = $current_User->ID;
     }
     return parent::delete($this->plugin_ID, $user_ID, $setting);
 }
Esempio n. 7
0
/**
 * 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");
 }
 /**
  * Delete all of the group permissions
  *
  * @param @param integer Group ID
  */
 function delete($grp_ID)
 {
     foreach ($this->permission_values as $name => $value) {
         parent::delete($grp_ID, $name);
     }
 }
Esempio n. 10
0
 /**
  * Mark a setting for deletion ({@link dbupdate()} writes it to DB).
  *
  * @param string name of setting
  * @param integer User ID (by default $current_User->ID will be used)
  */
 function delete($setting, $user_ID = NULL)
 {
     if (!isset($user_ID)) {
         global $current_User;
         if (!isset($current_User)) {
             // no current/logged in user:
             return false;
         }
         $user_ID = $current_User->ID;
     }
     return parent::delete($user_ID, $setting);
 }