/** * Answer agentIds that have stored tags * * @return object IdIterator * @access public * @since 11/1/06 */ function getAgentIds() { $query = new SelectQuery(); $query->addColumn('user_id'); $query->addColumn('COUNT(user_id)', 'occurances'); $query->addTable('tag'); $query->setGroupBy(array('user_id')); $query->addOrderBy('occurances', DESCENDING); $dbc = Services::getService("DatabaseManager"); $result = $dbc->query($query, $this->getDatabaseIndex()); // Add tag objects to an array, still sorted by frequency of usage $agentIds = array(); $idManager = Services::getService('Id'); while ($result->hasNext()) { $row = $result->next(); $agentIds[] = $idManager->getId($row['user_id']); } $iterator = new HarmoniIterator($agentIds); return $iterator; }
/** * Return the priority types available with this implementation. * * @return object TypeIterator * * @throws object LoggingException An exception with one of the * following messages defined in org.osid.logging.LoggingException * may be thrown: {@link * org.osid.logging.LoggingException#UNIMPLEMENTED UNIMPLEMENTED}, * {@link org.osid.logging.LoggingException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.logging.LoggingException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.logging.LoggingException#PERMISSION_DENIED * PERMISSION_DENIED} * * @access public */ function getPriorityTypes() { $dbc = Services::getService("DatabaseManager"); $query = new SelectQuery(); $query->addColumn("domain", "domain", "log_type"); $query->addColumn("authority", "authority", "log_type"); $query->addColumn("keyword", "keyword", "log_type"); $query->addColumn("description", "description", "log_type"); $query->addTable("log_entry"); $query->addTable("log_type", INNER_JOIN, "log_entry.fk_priority_type = log_type.id"); $query->setGroupBy(array("log_type.id")); $query->addOrderBy("keyword"); $results = $dbc->query($query, $this->_dbIndex); $types = array(); // Add a custom type to encompass all priority types $types[] = new Type('logging', 'edu.middlebury', 'All', _('All priority types.')); while ($results->hasNext()) { $types[] = new Type($results->field("domain"), $results->field("authority"), $results->field("keyword"), $results->field("description")); $results->advanceRow(); } $results->free(); $iterator = new HarmoniIterator($types); return $iterator; }
/** * Answer all items with this tag in a particular system * * @return object ItemsIterator * @access public * @since 11/2/06 */ function getItemsInSystem($system) { $dbc = Services::getService("DatabaseManager"); $subQuery = new SelectQuery(); $subQuery->addColumn('tag_item.db_id'); $subQuery->addColumn('tag_item.id'); $subQuery->addColumn('tag_item.system'); $subQuery->addColumn('tag.tstamp'); $subQuery->addTable('tag'); $subQuery->addTable('tag_item', INNER_JOIN, "tag.fk_item = tag_item.db_id"); $subQuery->addWhere("tag.value='" . addslashes($this->getValue()) . "'"); $subQuery->addWhere("tag_item.system='" . addslashes($system) . "'"); $subQuery->addOrderBy('tag.tstamp', DESCENDING); $query = new SelectQuery(); $query->addColumn('*'); $query->addTable("(" . $dbc->generateSQL($subQuery, $this->getDatabaseIndex()) . ") AS tag_results"); $query->setGroupBy(array('db_id')); $result = $dbc->query($query, $this->getDatabaseIndex()); $iterator = new TaggedItemIterator($result); return $iterator; }
/** * Get all the Function of the specified Type. * @param ref object functionType the Type of the Functions to return * @return ref object FunctionIterator */ function getFunctionTypes() { if (!isset($this->_functionTypes)) { $dbHandler = Services::getService("DatabaseManager"); $query = new SelectQuery(); $query->addColumn("type_domain", "domain", "type"); $query->addColumn("type_authority", "authority", "type"); $query->addColumn("type_keyword", "keyword", "type"); $query->addColumn("type_description", "type_description", "type"); $query->addTable("az_function"); $joinc = "fk_type = " . "type.type_id"; $query->addTable("type", INNER_JOIN, $joinc); $query->setGroupBy(array("type_domain", "type_authority", "type_keyword", "type_description")); $queryResult = $dbHandler->query($query, $this->_dbIndex); $this->_functionTypes = array(); while ($queryResult->hasMoreRows()) { $row = $queryResult->getCurrentRow(); // echo "<pre>"; // print_r($row); // echo "</pre>"; $this->_functionTypes[] = new HarmoniType($row['domain'], $row['authority'], $row['keyword'], $row['type_description']); $queryResult->advanceRow(); } $queryResult->free(); } $obj = new HarmoniTypeIterator($this->_functionTypes); return $obj; }