/** * @covers ConfigVariable::getComment * @todo Implement testGetComment(). */ public function testGetComment() { $variable_name = 'some_variable'; $variable_value = 'some_value'; $variable_comment = 'some_comment'; $config_variable = new ConfigVariable($variable_name, $variable_value, $variable_comment); $this->assertEquals($config_variable->getComment(), $variable_comment); }
function testConfigVar() { // setup ConfigVariable::remove("test_config_var"); $this->assertEquals(ConfigVariable::get("test_config_var", "1234"), "1234"); // see if we can save a new value and serialize an array ConfigVariable::set("test_config_var", array(1, 2, 3)); $this->assertEquals(ConfigVariable::get("test_config_var", "1234"), array(1, 2, 3)); // see if we can change an existing value, and store a nasty // string full of punctuation $ridiculous_punctuation = "'&@^%\$*(&^@%#\"\$&*^%@#\$+_)}{}{{?><,./,"; ConfigVariable::set("test_config_var", $ridiculous_punctuation); $this->assertEquals(ConfigVariable::get("test_config_var", "1234"), $ridiculous_punctuation); // make sure we can remove the value ConfigVariable::remove("test_config_var"); $this->assertEquals(ConfigVariable::get("test_config_var", "1234"), "1234"); }
public function read($input) { $xfer = 0; $fname = null; $ftype = 0; $fid = 0; $xfer += $input->readStructBegin($fname); while (true) { $xfer += $input->readFieldBegin($fname, $ftype, $fid); if ($ftype == TType::STOP) { break; } switch ($fid) { case 0: if ($ftype == TType::LST) { $this->success = array(); $_size21 = 0; $_etype24 = 0; $xfer += $input->readListBegin($_etype24, $_size21); for ($_i25 = 0; $_i25 < $_size21; ++$_i25) { $elem26 = null; $elem26 = new \ConfigVariable(); $xfer += $elem26->read($input); $this->success[] = $elem26; } $xfer += $input->readListEnd(); } else { $xfer += $input->skip($ftype); } break; default: $xfer += $input->skip($ftype); break; } $xfer += $input->readFieldEnd(); } $xfer += $input->readStructEnd(); return $xfer; }
private function addSomeVariablesToSection(\ConfigVariable $variable, $amount = 0, $mutable = false) { for ($i = 0; $i < $amount; $i++) { if ($mutable) { $name = $variable->getVariable() . '_' . $i; $variable = new \ConfigVariable($name, $variable->getValue(), $variable->getComment()); } $this->object->addVariable($variable); } }
/** * Appends config variable to section variables container * * @param ConfigVariable $config_variable Config variable */ public function addVariable(ConfigVariable $config_variable) { $this->section_variables[$config_variable->getVariable()] = $config_variable; }
/** * Get array of all users who login after latest updates of ranking. * */ public function recent_login_users() { Logger::log("Enter: Ranking::recent_login_users()"); $last_cron_timestamp = ConfigVariable::get('last_cron_timestamp', 0); //ConfigVariable::set('last_cron_timestamp',time()); $sql = "SELECT \n u.user_id, \n u.login_name, \n u.picture, \n (select count(*) from {contentcollections} cc where cc.author_id = u.user_id AND cc.type =1 AND is_active=1) as group_created, \n (select count(*) from {contents} c where c.author_id = u.user_id AND c.type = 4 AND is_active=1) as image_uploaded,\n (select count(*) from {relations} r where r.user_id = u.user_id AND r.status = 'approved') as buddies\n FROM {users} u\n WHERE u.is_active = 1 AND u.last_login >= ?"; $users = array(); $res = Dal::query($sql, array($last_cron_timestamp)); while ($user = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $users[$user->user_id]["user_id"] = $user->user_id; $users[$user->user_id]["login_name"] = $user->login_name; $users[$user->user_id]["picture"] = $user->picture; $users[$user->user_id]["group_created"] = $user->group_created; $users[$user->user_id]["image_uploaded"] = $user->image_uploaded; $users[$user->user_id]["buddies"] = $user->buddies; $sql = "SELECT field_name, field_value FROM {user_profile_data} WHERE user_id = ? AND field_name IN('time_spent', 'profile_visitor_count')"; $result = Dal::query($sql, array($user->user_id)); while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { $users[$user->user_id][$row->field_name] = $row->field_value; } } Logger::log("Exit: Ranking::recent_login_users()"); return $users; }
public function __construct($vals = null) { if (!isset(self::$_TSPEC)) { self::$_TSPEC = array(1 => array('var' => 'key', 'type' => TType::STRING), 2 => array('var' => 'value', 'type' => TType::STRING), 3 => array('var' => 'description', 'type' => TType::STRING)); } if (is_array($vals)) { if (isset($vals['key'])) { $this->key = $vals['key']; } if (isset($vals['value'])) { $this->value = $vals['value']; } if (isset($vals['description'])) { $this->description = $vals['description']; } } }
/** This function keeps track of online registered user * @param user_id of logged in user * make an entry in users_online table * @return true, if entry succeeded else return false */ public static function track_status($user_id) { // TODO: we can fetch recent entries as well by specifying time stamp $timeout = ConfigVariable::get('session_timeout', 1800); $time = strtotime('-' . $timeout . ' seconds'); $sql = "DELETE FROM {users_online} WHERE timestamp < " . $time; Dal::query($sql); $sql = 'SELECT * FROM {users_online} WHERE user_id = ?'; $data = array($user_id); $res = Dal::query($sql, $data); //if session for user exists then update that entry if ($res->numRows()) { $sql = 'UPDATE {users_online} SET timestamp = ? WHERE user_id = ?'; $data = array(time(), $user_id); } else { $sql = 'INSERT INTO {users_online}(timestamp, user_id) VALUES(?, ?)'; $data = array(time(), $user_id); } $res = Dal::query($sql, $data); }