/**
  * Set a Plugin setting. Use {@link dbupdate()} to write it to the database.
  *
  * @param string The settings name.
  * @param string The settings value.
  * @param integer User ID (by default $current_User->ID will be used - make sure that it is available already in your event!)
  * @return boolean true, if the value has been set, false if it has not changed.
  */
 function set($setting, $value, $user_ID = NULL)
 {
     if (!isset($user_ID)) {
         global $current_User;
         if (!isset($current_User)) {
             global $Debuglog;
             $Debuglog->add('No $current_User available in PluginUserSettings::set()/[ID' . $this->plugin_ID . ']!', array('errors', 'plugins'));
             return false;
         }
         $user_ID = $current_User->ID;
     }
     return parent::set($this->plugin_ID, $user_ID, $setting, $value);
 }
Ejemplo n.º 2
0
 /**
  * Set a Plugin setting. Use {@link dbupdate()} to write it to the database.
  *
  * @param string The settings name.
  * @param string The settings value.
  * @return boolean true, if the value has been set, false if it has not changed.
  */
 function set($setting, $value)
 {
     return parent::set($this->plugin_ID, $setting, $value);
 }
Ejemplo n.º 3
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_dirty_cache_when_deleting_deep()
 {
     // query() should return 1 always; it does not get called when dbupdate() does not consider the cache to be dirty.
     $this->MockDB->returns('query', 1);
     $s = new AbstractSettings('T_test', array('key1', 'key2', 'key3'), 'val', 0);
     $this->assertTrue($s->set(1, 2, 3, 'value'));
     $this->assertEqual($s->get(1, 2, 3), 'value');
     $this->assertTrue($s->dbupdate());
     $this->assertFalse($s->dbupdate());
     $this->assertTrue($s->delete(1, 2, 3));
     $this->MockDB->expect('query', array("DELETE FROM T_test WHERE (`key1` = '1' AND `key2` = '2' AND `key3` = '3')"));
     $this->assertTrue($s->dbupdate());
 }
Ejemplo n.º 5
0
 /**
  * Temporarily sets a group permission ({@link dbupdate()} writes it to DB)
  *
  * @param string name of permission
  * @param mixed new value
  * @param integer Group ID
  */
 function set($permission, $value, $grp_ID)
 {
     if ($grp_ID != 0) {
         // We can set permission, because the current group is already in database
         $this->permission_values[$permission] = $value;
         return parent::set($grp_ID, $permission, $value);
     }
     $this->_permissions[$permission] = $value;
     return true;
 }
Ejemplo n.º 6
0
 /**
  * Temporarily sets a user setting ({@link dbupdate()} writes it to DB)
  *
  * @param string name of setting
  * @param mixed new value
  * @param integer User ID (by default $current_User->ID will be used)
  */
 function set($setting, $value, $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::set($user_ID, $setting, $value);
 }