本文整理汇总了PHP中SelectQuery::addWhereEqual方法的典型用法代码示例。如果您正苦于以下问题:PHP SelectQuery::addWhereEqual方法的具体用法?PHP SelectQuery::addWhereEqual怎么用?PHP SelectQuery::addWhereEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectQuery
的用法示例。
在下文中一共展示了SelectQuery::addWhereEqual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getThemes
/**
* Answer an array of all of the themes known to this source
*
* @return array of Harmoni_Gui2_ThemeInterface
* @access public
* @since 5/6/08
*/
public function getThemes()
{
$themes = array();
$query = new SelectQuery();
$query->addTable('segue_site_theme');
$query->addColumn('id');
$query->addWhereEqual('fk_site', $this->getSiteId());
$dbMgr = Services::getService("DatabaseManager");
$result = $dbMgr->query($query, $this->databaseIndex);
while ($result->hasNext()) {
$row = $result->next();
$themes[] = new Segue_Gui2_SiteTheme($this->databaseIndex, $row['id']);
}
$result->free();
return $themes;
}
示例2: getExplicitAZ
/**
* Answer the explicit authorization for this implicit authorization
*
* @return object Authorization
* @access public
* @since 4/22/08
*/
public function getExplicitAZ()
{
if ($this->isExplicit()) {
throw new OperationFailedException("Can not get explicit AZs for an explicit AZ");
}
if (isset($this->explicitAZId)) {
return $this->_cache->getExplicitAZById($this->explicitAZId);
}
if (isset($this->_cache->harmoni_db)) {
if (!isset($this->_cache->_getExplicitAZ_stmt)) {
$query = $this->_cache->harmoni_db->select();
$query->addColumn("fk_explicit_az");
$query->addTable("az2_implicit_az");
$query->addWhereEqual("id", '?');
$this->_cache->_getExplicitAZ_stmt = $query->prepare();
}
$this->_cache->_getExplicitAZ_stmt->bindValue(1, $this->getIdString());
$this->_cache->_getExplicitAZ_stmt->execute();
$result = $this->_cache->_getExplicitAZ_stmt->getResult();
} else {
$dbHandler = Services::getService("DatabaseManager");
$query = new SelectQuery();
$query->addColumn("fk_explicit_az");
$query->addTable("az2_implicit_az");
$query->addWhereEqual("id", $this->getIdString());
// printpre($query->asString());
$result = $dbHandler->query($query, $this->_cache->_dbIndex);
}
$this->explicitAZId = $result->field("fk_explicit_az");
$result->free();
return $this->_cache->getExplicitAZById($this->explicitAZId);
}
示例3: addWhereClauses
/**
* Add where clauses to the query
*
* @param object SelectQuery $query
* @return void
* @access public
* @since 3/9/06
*/
function addWhereClauses($query)
{
$query->addWhere("log_name = '" . addslashes($this->_logName) . "'");
$subQuery = new SelectQuery();
$subQuery->addTable("log_type");
$subQuery->addColumn("id");
$subQuery->addWhereEqual("domain", $this->_formatType->getDomain());
$subQuery->addWhereEqual("authority", $this->_formatType->getAuthority());
$subQuery->addWhereEqual("keyword", $this->_formatType->getKeyword());
$query->addWhere("log_entry.fk_format_type = \n(\n" . $subQuery->asString() . ")");
if ($this->_priorityType && !$this->_priorityType->isEqual(new Type('logging', 'edu.middlebury', 'All'))) {
$subQuery = new SelectQuery();
$subQuery->addTable("log_type");
$subQuery->addColumn("id");
$subQuery->addWhereEqual("domain", $this->_priorityType->getDomain());
$subQuery->addWhereEqual("authority", $this->_priorityType->getAuthority());
$subQuery->addWhereEqual("keyword", $this->_priorityType->getKeyword());
$query->addWhere("log_entry.fk_priority_type = \n(\n" . $subQuery->asString() . ")");
}
}
示例4: getImages
/**
* Answer the images for this theme
*
* @return array of Harmoni_Filing_FileInterface objects
* @access public
* @since 5/15/08
*/
public function getImages()
{
$query = new SelectQuery();
$query->addTable('segue_site_theme_image');
$query->addColumn('path');
$query->addWhereEqual('fk_theme', $this->id);
$dbMgr = Services::getService("DatabaseManager");
$result = $dbMgr->query($query, $this->databaseIndex);
$images = array();
while ($result->hasNext()) {
$row = $result->next();
$images[] = new Segue_Gui2_ThemeImage($this->databaseIndex, $this->id, $row['path']);
}
$result->free();
return $images;
}
示例5: runUpdate
//.........这里部分代码省略.........
*********************************************************/
$hierarchyMgr1 = Services::getService("Hierarchy");
if (get_class($hierarchyMgr1) == "AuthZ2_HierarchyManager") {
throw new OperationFailedException("Original HierarchyManager not configured.");
}
$hierarchyMgr2 = new AuthZ2_HierarchyManager();
$azMgr2 = new AuthZ2_AuthorizationManager();
$azMgr2->setHierarchyManager($hierarchyMgr2);
$hierarchyMgr2->assignConfiguration($hierarchyMgr1->_configuration);
/*********************************************************
* Authorization
*********************************************************/
$azMgr1 = Services::getService("AuthZ");
if (get_class($hierarchyMgr1) == "AuthZ2_AuthorizationManager") {
throw new OperationFailedException("Original HierarchyManager not configured.");
}
$azMgr2->assignConfiguration($azMgr1->_configuration);
$prepStatus->updateStatistics();
/*********************************************************
* Hierarchies
*********************************************************/
$hierarchies = $hierarchyMgr1->getHierarchies();
$prepStatus->updateStatistics();
while ($hierarchies->hasNext()) {
$hierarchy = $hierarchies->next();
try {
$newHierarchy = $hierarchyMgr2->getHierarchy($hierarchy->getId());
} catch (UnknownIdException $e) {
$newHierarchy = $hierarchyMgr2->createHierarchy($hierarchy->getDisplayName(), array(), $hierarchy->getDescription(), $hierarchy->allowsMultipleParents(), $hierarchy->allowsRecursion(), $hierarchy->getId());
}
$query = new SelectQuery();
$query->addTable("node");
$query->addColumn("COUNT(*)", "num");
$query->addWhereEqual("fk_hierarchy", $hierarchy->getId()->getIdString());
$dbc = Services::getService("DatabaseManager");
$result = $dbc->query($query);
$this->nodeStatus = new StatusStars("Migrating nodes in the '" . $hierarchy->getDisplayName() . "' Hierarchy.");
$this->nodeStatus->initializeStatistics($result->field("num"));
// Add all of the nodes
$nodes = $hierarchy->getRootNodes();
while ($nodes->hasNext()) {
$this->addNode($newHierarchy, $nodes->next());
}
}
/*********************************************************
* Authorizations
*********************************************************/
$azMgr1 = Services::getService("AuthZ");
if (get_class($hierarchyMgr1) == "AuthZ2_AuthorizationManager") {
throw new OperationFailedException("Original HierarchyManager not configured.");
}
// Add all of the Authorization functions
$functionTypes = $azMgr1->getFunctionTypes();
while ($functionTypes->hasNext()) {
$oldFunctions = $azMgr1->getFunctions($functionTypes->next());
while ($oldFunctions->hasNext()) {
$oldFunction = $oldFunctions->next();
// Get or create the function
try {
$newFunction = $azMgr2->getFunction($oldFunction->getId());
} catch (UnknownIdException $e) {
$newFunction = $azMgr2->createFunction($oldFunction->getId(), $oldFunction->getReferenceName(), $oldFunction->getDescription(), $oldFunction->getFunctionType(), $oldFunction->getQualifierHierarchyId());
}
// Get all authorizations for this function.
$oldAZs = $azMgr1->getExplicitAZs(null, $oldFunction->getId(), null, false);
$status = new StatusStars("Migrating '" . $newFunction->getReferenceName() . "' Authorizations (" . $oldAZs->count() . ")");
示例6: getCachedXmlString
/**
* Answer the cached version of the feed Xml
*
* @param string $url
* @return string The feed XML
* @access protected
* @since 7/8/08
*/
protected function getCachedXmlString($url)
{
$dbc = Services::getService("DatabaseManager");
$query = new SelectQuery();
$query->addTable('segue_plugins_rssfeed_cache');
$query->addColumn('feed_data');
$query->addWhereEqual('url', $url);
$result = $dbc->query($query, IMPORTER_CONNECTION);
$data = $result->field('feed_data');
$result->free();
return $data;
}
示例7: runUpdate
/**
* Run the update
*
* @return boolean
* @access public
* @since 3/24/08
*/
function runUpdate()
{
$prepStatus = new StatusStars("Preparing Migration");
$prepStatus->initializeStatistics(3);
$prepStatus->updateStatistics();
$dbc = Services::getService("DatabaseManager");
try {
/*********************************************************
* Check for the old tables. They must exist for us to run
*********************************************************/
$azTables = array('az_authorization', 'az_function', 'hierarchy', 'j_node_node', 'node', 'node_ancestry');
// Check for old tables
$tables = $dbc->getTableList(IMPORTER_CONNECTION);
foreach ($azTables as $table) {
if (!in_array($table, $tables)) {
throw new Exception("Old AZ table, {$table}, is missing. Can not run Update.");
}
}
/*********************************************************
* Create the new tables
*********************************************************/
$type = $dbc->getDatabaseType(IMPORTER_CONNECTION);
switch ($type) {
case MYSQL:
SQLUtils::runSQLfile(HARMONI_BASE . "/SQL/MySQL/AuthZ2.sql", IMPORTER_CONNECTION);
break;
case POSTGRESQL:
SQLUtils::runSQLfile(HARMONI_BASE . "/SQL/PostgreSQL/AuthZ2.sql", IMPORTER_CONNECTION);
break;
case ORACLE:
SQLUtils::runSQLfile(HARMONI_BASE . "/SQL/PostgreSQL/AuthZ2.sql", IMPORTER_CONNECTION);
break;
default:
throw new Exception("Database schemas are not defined for specified database type.");
}
/*********************************************************
* Hierarchy
*********************************************************/
$hierarchyMgr1 = Services::getService("Hierarchy");
if (get_class($hierarchyMgr1) == "AuthZ2_HierarchyManager") {
throw new OperationFailedException("Original HierarchyManager not configured.");
}
$hierarchyMgr2 = new AuthZ2_HierarchyManager();
$azMgr2 = new AuthZ2_AuthorizationManager();
$azMgr2->setHierarchyManager($hierarchyMgr2);
$hierarchyMgr2->assignConfiguration($hierarchyMgr1->_configuration);
/*********************************************************
* Authorization
*********************************************************/
$azMgr1 = Services::getService("AuthZ");
if (get_class($hierarchyMgr1) == "AuthZ2_AuthorizationManager") {
throw new OperationFailedException("Original HierarchyManager not configured.");
}
$azMgr2->assignConfiguration($azMgr1->_configuration);
$prepStatus->updateStatistics();
/*********************************************************
* Hierarchies
*********************************************************/
$hierarchies = $hierarchyMgr1->getHierarchies();
$prepStatus->updateStatistics();
while ($hierarchies->hasNext()) {
$hierarchy = $hierarchies->next();
try {
$newHierarchy = $hierarchyMgr2->getHierarchy($hierarchy->getId());
} catch (UnknownIdException $e) {
$newHierarchy = $hierarchyMgr2->createHierarchy($hierarchy->getDisplayName(), array(), $hierarchy->getDescription(), $hierarchy->allowsMultipleParents(), $hierarchy->allowsRecursion(), $hierarchy->getId());
}
$query = new SelectQuery();
$query->addTable("node");
$query->addColumn("COUNT(*)", "num");
$query->addWhereEqual("fk_hierarchy", $hierarchy->getId()->getIdString());
$dbc = Services::getService("DatabaseManager");
$result = $dbc->query($query);
$this->nodeStatus = new StatusStars("Migrating nodes in the '" . $hierarchy->getDisplayName() . "' Hierarchy.");
$this->nodeStatus->initializeStatistics($result->field("num"));
// Add all of the nodes
$nodes = $hierarchy->getRootNodes();
while ($nodes->hasNext()) {
$this->addNode($newHierarchy, $nodes->next());
}
}
/*********************************************************
* Authorizations
*********************************************************/
$azMgr1 = Services::getService("AuthZ");
if (get_class($hierarchyMgr1) == "AuthZ2_AuthorizationManager") {
throw new OperationFailedException("Original HierarchyManager not configured.");
}
// Add all of the Authorization functions
$functionTypes = $azMgr1->getFunctionTypes();
while ($functionTypes->hasNext()) {
$oldFunctions = $azMgr1->getFunctions($functionTypes->next());
while ($oldFunctions->hasNext()) {
//.........这里部分代码省略.........
示例8: deleteNode
/**
* Attempts to delete the specified node in the database. Only leaf nodes can
* be deleted.
* @access public
* @param mixed idValue The string id of the node to delete.
* @return void
**/
function deleteNode($idValue)
{
// ** parameter validation
ArgumentValidator::validate($idValue, OrValidatorRule::getRule(NonzeroLengthStringValidatorRule::getRule(), IntegerValidatorRule::getRule()), true);
// ** end of parameter validation
// get the node
$node = $this->getNode($idValue);
// if not a leaf, cannot delete
if (!$node->isLeaf()) {
// "Can not delete non-leaf nodes.";
throw new OperationFailedException("Cannont delete non-leaf nodes.");
}
// clear the cache and update the _tree structure
// detach the node from each of its parents and update the join table
$parents = $node->getParents();
while ($parents->hasNext()) {
$parent = $parents->next();
$node->removeParent($parent->getId());
}
// now delete the tree node
$treeNode = $this->_tree->getNode($idValue);
$this->_tree->deleteNode($treeNode);
// -----------------
// remove from cache
unset($this->_cache[$idValue]);
$node = null;
// now remove from database
$dbHandler = Services::getService("DatabaseManager");
// 1. Get the id of the type associated with the node
$query = new SelectQuery();
$query->addTable("az2_node");
$query->addColumn("fk_type", "type_id", "az2_node");
$query->addWhereEqual("id", $idValue);
$queryResult = $dbHandler->query($query, $this->_dbIndex);
if (!$queryResult->hasNext()) {
$queryResult->free();
throw new OperationFailedException("No type found for node, '{$idValue}'.");
}
$typeIdValue = $queryResult->field("type_id");
$queryResult->free();
// 2. Now delete the node
$query = new DeleteQuery();
$query->setTable("az2_node");
$query->addWhereEqual("id", $idValue);
$queryResult = $dbHandler->query($query, $this->_dbIndex);
// 3. Now see if any other nodes have the same type
$query = new SelectQuery();
$query->addTable("az2_node");
// count the number of nodes using the same type
$query->addColumn("COUNT(fk_type)", "num");
$query->addWhereEqual("fk_type", $typeIdValue);
$queryResult = $dbHandler->query($query, $this->_dbIndex);
$num = $queryResult->field("num");
$queryResult->free();
if ($num == 0) {
// if no other nodes use this type, then delete the type
$query = new DeleteQuery();
$query->setTable("az2_node_type");
$query->addWhereEqual("id", $typeIdValue);
$queryResult = $dbHandler->query($query, $this->_dbIndex);
}
// Delete the node's ancestory from the Ancestory table
$this->clearNodeAncestory($idValue);
}
示例9: runUpdate
/**
* Run the update
*
* @return boolean
* @access public
* @since 6/12/08
*/
function runUpdate()
{
set_time_limit(600);
$hierarchyMgr = Services::getService("HierarchyManager");
$idMgr = Services::getService("IdManager");
$hierarchyId = $idMgr->getId("edu.middlebury.authorization.hierarchy");
$hierarchy = $hierarchyMgr->getHierarchy($hierarchyId);
$view = $idMgr->getId("edu.middlebury.authorization.view");
$authZ = Services::getService("AuthZ");
$query = new SelectQuery();
$query->addColumn('az2_explicit_az.id', 'explicit_az_id');
$query->addTable('az2_explicit_az');
$query->addTable('az2_j_node_node', INNER_JOIN, 'az2_j_node_node.fk_child = az2_explicit_az.fk_qualifier');
$query->addTable('az2_implicit_az', LEFT_JOIN, '(az2_implicit_az.fk_explicit_az = az2_explicit_az.id AND az2_j_node_node.fk_parent = az2_implicit_az.fk_qualifier)');
$query->addWhereEqual('az2_explicit_az.fk_function', 'edu.middlebury.authorization.view');
$query->addWhereNull('az2_implicit_az.fk_explicit_az');
$dbc = Services::getService('DatabaseManager');
$result = $dbc->query($query, IMPORTER_CONNECTION);
$status = new StatusStars(str_replace('%1', $result->getNumberOfRows(), _("Rebuilding cascading-up implicit 'view' AZs on %1 nodes.")));
$status->initializeStatistics($result->getNumberOfRows());
$azCache = $authZ->getAuthorizationCache();
while ($result->hasNext()) {
$row = $result->next();
$azCache->createImplicitAZsUpForAZ($azCache->getExplicitAZById($row['explicit_az_id']));
$status->updateStatistics();
}
return true;
}
示例10: getRecentSlots
/**
* Answer a list of most recently seen slot-names ordered recent-first.
*
* @return array
* @access public
* @since 9/22/08
*/
public function getRecentSlots()
{
$slots = array();
$dbc = Services::getService('DatabaseManager');
$query = new SelectQuery();
$query->addTable('segue_accesslog');
$query->addColumn('fk_slotname');
$query->addColumn('tstamp');
$query->addWhereEqual('agent_id', $this->_getCurrentAgentId());
$query->addOrderBy('tstamp', DESCENDING);
$query->limitNumberOfRows(50);
$result = $dbc->query($query, IMPORTER_CONNECTION);
while ($result->hasNext()) {
$row = $result->next();
$slots[$row['fk_slotname']] = DateAndTime::fromString($row['tstamp'])->asString();
}
// Add session-stored slots
if (isset($_SESSION['segue_access_log'])) {
foreach ($_SESSION['segue_access_log'] as $slotname => $tstamp) {
$slots[$slotname] = $tstamp;
}
arsort($slots);
}
return array_keys($slots);
}
示例11: getAZs
/**
* Auxilliary private function that returns Authorizations according to a
* criteria. Null values are interpreted as wildmarks. Warning: $returnExplicitOnly = false
* will increase the running time significantly - USE SPARINGLY!
* @access public
* @param string aId The string id of an agent.
* @param string fId The string id of a function.
* @param string qId The string id of a qualifier. This parameter can not be null
* and used as a wildmark.
* @param object fType The type of a function.
* @param boolean returnExplicitOnly If True, only explicit Authorizations
* will be returned.
* @param boolean searchUp If true, the ancester nodes of the qualifier will
* be checked as well
* @param boolean isActiveNow If True, only active Authorizations will be returned.
* @return ref object An AuthorizationIterator.
**/
function getAZs($aId, $fId, $qId, $fType, $returnExplicitOnly, $searchUp, $isActiveNow, $groupIds = array())
{
// printpre (func_get_args());
// ** parameter validation
$rule = StringValidatorRule::getRule();
ArgumentValidator::validate($groupIds, ArrayValidatorRuleWithRule::getRule(OptionalRule::getRule($rule)), true);
ArgumentValidator::validate($aId, OptionalRule::getRule($rule), true);
ArgumentValidator::validate($fId, OptionalRule::getRule($rule), true);
ArgumentValidator::validate($qId, OptionalRule::getRule($rule), true);
ArgumentValidator::validate($fType, OptionalRule::getRule(ExtendsValidatorRule::getRule("Type")), true);
ArgumentValidator::validate($returnExplicitOnly, BooleanValidatorRule::getRule(), true);
ArgumentValidator::validate($isActiveNow, BooleanValidatorRule::getRule(), true);
// ** end of parameter validation
$idManager = Services::getService("Id");
// the parameter that influences the result most is $returnExplicitOnly
// 1) If $returnExplicitOnly is TRUE, then we only need to check for Authorizations
// that have been explicitly created, i.e. no need to look for inherited
// authorizations
// 2) If $returnExplicitOnly is FALSE, then we need to include inherited Authorizations
// as well.
// this array will store the ids of all qualifiers to be checked for authorizations
$qualifiers = array();
// check all ancestors of given qualifier
$hierarchyManager = Services::getService("Hierarchy");
if (isset($qId)) {
$qualifierId = $idManager->getId($qId);
$node = $hierarchyManager->getNode($qualifierId);
$hierarchy = $hierarchyManager->getHierarchyForNode($node);
if ($searchUp) {
// these are the ancestor nodes
$nodes = $hierarchy->traverse($qualifierId, Hierarchy::TRAVERSE_MODE_DEPTH_FIRST, Hierarchy::TRAVERSE_DIRECTION_UP, Hierarchy::TRAVERSE_LEVELS_ALL);
// now get the id of each node and store in array
while ($nodes->hasNext()) {
$info = $nodes->next();
$id = $info->getNodeId();
$qualifiers[] = $id->getIdString();
}
} else {
$qualifiers = array($qId);
}
}
// print_r($qualifiers);
// setup the query
$dbHandler = Services::getService("DatabaseManager");
$query = new SelectQuery();
$query->addColumn("authorization_id", "id");
$query->addColumn("fk_agent", "aid");
$query->addColumn("fk_function", "fid");
$query->addColumn("fk_qualifier", "qid");
$query->addColumn("authorization_effective_date", "eff_date");
$query->addColumn("authorization_expiration_date", "exp_date");
$query->addTable("az_authorization");
// now include criteria
// the qualifiers criteria
if (isset($qualifiers) && count($qualifiers)) {
$query->addWhereIn('az_authorization.fk_qualifier', $qualifiers);
}
// Agents/Groups
if (isset($aId)) {
$agentIds = array($aId);
} else {
$agentIds = array();
}
$allAgentIds = array_merge($agentIds, $groupIds);
// the agent criteria
if (count($allAgentIds)) {
$query->addWhereIn('az_authorization.fk_agent', $allAgentIds);
}
// the function criteria
if (isset($fId)) {
$joinc = "az_authorization.fk_function = az_function.function_id";
$query->addTable("az_function", INNER_JOIN, $joinc);
$query->addWhereEqual("az_authorization.fk_function", $fId);
}
// the function type criteria
if (isset($fType)) {
// do not join with az_function if we did already
if (!isset($fId)) {
$joinc = "az_authorization.fk_function = az_function.function_id";
$query->addTable("az_function", INNER_JOIN, $joinc);
}
// now join with type
$joinc = "az_function.fk_type = type.type_id";
//.........这里部分代码省略.........
示例12: getSegue2IdForOld
/**
* Answer a new Segue 2 id for a segue1 id
*
* @param string $idType 'site', 'section', 'page', 'story', or 'comment'
* @param string $id
* @return string or throw an UnknownIdException
* @access private
* @since 3/20/08
*/
private function getSegue2IdForOld($idType, $id)
{
$segue1Identifiers = array('story', 'page', 'section', 'site');
if (!in_array($idType, $segue1Identifiers)) {
throw new InvalidArgumentException("{$idType} is not one of (" . implode(', ', $segue1Identifiers) . ").");
}
$query = new SelectQuery();
$query->addTable('segue1_id_map');
$query->addColumn('segue2_slot_name', 'slotName');
$query->addColumn('segue2_id', 'id');
$query->addWhereEqual('segue1_id', $idType . "_" . $id);
$dbc = Services::getService('DatabaseManager');
$result = $dbc->query($query, IMPORTER_CONNECTION);
if (!$result->getNumberOfRows()) {
throw new UnknownIdException("No map matches for Segue 1 {$idType} {$id}.");
}
$slotName = $result->field('slotName');
$newId = $result->field('id');
// check to see if the new Id is valid.
try {
$repositoryMgr = Services::getService('Repository');
$idMgr = Services::getService('Id');
$repository = $repositoryMgr->getRepository($idMgr->getId('edu.middlebury.segue.sites_repository'));
$asset = $repository->getAsset($idMgr->getId($newId));
return $newId;
} catch (UnknownIdException $e) {
$slotMgr = SlotManager::instance();
$slot = $slotMgr->getSlotByShortname($slotName);
if ($slot->siteExists()) {
return $slot->getSiteId()->getIdString();
}
}
// If we still couldn't resolve throw an exception.
throw new UnknownIdException("A match was found for Segue 1 {$idType} {$id}, but it was not valid.");
}
示例13: _loadUserPrefs
/**
* Load all user preferences for the current user
*
* @return void
* @access protected
* @since 9/16/08
*/
protected function _loadUserPrefs()
{
if (!isset($_SESSION['harmoni_user_prefs_persistant']) || $_SESSION['harmoni_user_prefs_user'] != $this->_getCurrentAgentId()) {
unset($_SESSION['harmoni_user_prefs_user']);
unset($_SESSION['harmoni_user_prefs_persistant']);
// Do not load preferences for anonymous.
if ($this->_getCurrentAgentId() == 'edu.middlebury.agents.anonymous') {
return;
}
$query = new SelectQuery();
$query->addTable('user_prefs');
$query->addColumn('pref_key');
$query->addColumn('pref_val');
$query->addWhereEqual('agent_id', $this->_getCurrentAgentId());
$dbc = Services::getService('DatabaseManager');
$result = $dbc->query($query);
$_SESSION['harmoni_user_prefs_user'] = $this->_getCurrentAgentId();
$_SESSION['harmoni_user_prefs_persistant'] = array();
while ($result->hasNext()) {
$row = $result->next();
$_SESSION['harmoni_user_prefs_persistant'][$row['pref_key']] = $row['pref_val'];
}
}
}
示例14: isCurrent
/**
* Answer true if this version is the current version.
*
* @return boolean
* @access public
* @since 1/8/08
*/
public function isCurrent()
{
$query = new SelectQuery();
$query->addTable('segue_plugin_version');
$query->addColumn('version_id');
$query->addWhereEqual('node_id', $this->pluginInstance->getId());
$query->addOrderBy('tstamp', SORT_DESC);
$query->limitNumberOfRows(1);
$dbc = Services::getService('DBHandler');
$result = $dbc->query($query, IMPORTER_CONNECTION);
if ($result->field('version_id') == $this->getVersionId()) {
return true;
} else {
return false;
}
}
示例15: getVersions
/**
* Answer an array of the versions for this plugin instance with the most
* recent version first.
*
* @return array of SeguePluginVersion objects
* @access public
* @since 1/7/08
*/
public function getVersions()
{
if (!isset($this->versions)) {
$this->versions = array();
$query = new SelectQuery();
$query->addTable('segue_plugin_version');
$query->addColumn('version_id');
$query->addColumn('tstamp');
$query->addColumn('comment');
$query->addColumn('agent_id');
$query->addWhereEqual('node_id', $this->getId());
$query->addOrderBy('tstamp', SORT_DESC);
$dbc = Services::getService('DBHandler');
$result = $dbc->query($query, IMPORTER_CONNECTION);
$idMgr = Services::getService("Id");
$number = $result->getNumberOfRows();
while ($result->hasNext()) {
$row = $result->next();
$this->versions[] = new SeguePluginVersion($this, $row['version_id'], DateAndTime::fromString($row['tstamp']), $idMgr->getId($row['agent_id']), $number, $row['comment']);
$number--;
}
}
return $this->versions;
}