/**
  * Answer true if a comment should be added to the history to indicate a change in
  * author/time.
  * 
  * @param object Id $origAgentId
  * @param object Id $newAgentId
  * @return boolean
  * @access protected
  * @since 1/25/08
  */
 protected function addChangedAgentComment(Id $origAgentId, Id $newAgentId)
 {
     if ($origAgentId->isEqual($newAgentId)) {
         return false;
     } else {
         return true;
     }
 }
Пример #2
0
 /**
  * @param IdReference $model
  * @return string
  */
 public function encodeIdReference($model)
 {
     if (Id::isEmpty($model)) {
         return null;
     }
     $mongoId = MongoMapper::mongoID($model->id);
     return $mongoId;
 }
 /**
  * Delete a Part and all its Parts.
  * 
  * @param object Id $partId
  * 
  * @throws object RepositoryException An exception with one of
  *		   the following messages defined in
  *		   org.osid.repository.RepositoryException may be thrown: {@link
  *		   org.osid.repository.RepositoryException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.repository.RepositoryException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.repository.RepositoryException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.repository.RepositoryException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  * 
  * @access public
  */
 function deletePart(Id $partId)
 {
     $string = $partId->getIdString();
     if (preg_match("/(.*)-(FILE_SIZE|FILE_NAME|FILE_DATA|MIME_TYPE|THUMBNAIL_DATA|THUMBNAIL_MIME_TYPE)/", $string, $r)) {
         $recordId = $r[1];
         $field = $r[2];
         if ($this->_isLastPart($field)) {
             $dbHandler = Services::getService("DatabaseManager");
             // Delete the data
             $file = $this->_parts['FILE_DATA']->_getFilePath();
             if (!unlink($file)) {
                 throwError(new Error(RepositoryException::OPERATION_FAILED() . ": '{$file}' could not be deleted.", "FileSystemFileRecord", true));
             }
             // Delete the thumbnail
             $query = new DeleteQuery();
             $query->setTable("dr_thumbnail");
             $query->setWhere("fk_file = '" . $this->_id->getIdString() . "'");
             $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
             // Delete the data row in case we were switching from another type
             // that used it.
             $query = new DeleteQuery();
             $query->setTable("dr_file_data");
             $query->setWhere("fk_file = '" . $this->_id->getIdString() . "'");
             $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
             // delete the file row.
             $query = new DeleteQuery();
             $query->setTable("dr_file");
             $query->setWhere("id = '" . $this->_id->getIdString() . "'");
             $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
         } else {
             if ($field != "FILE_SIZE") {
                 $this->_parts[$field]->updateValue("NULL");
             }
         }
     } else {
         throwError(new Error(RepositoryException::UNKNOWN_ID() . ": {$string}", "FileSystemFileRecord", true));
     }
 }
Пример #4
0
 public function vote($arguments)
 {
     if (!CheckAcl::can('voteOnNews')) {
         return Error::set('You can not vote on news posts.');
     }
     if (empty($arguments[0]) || empty($arguments[1])) {
         return Error::set('Vote or news id not found.');
     }
     $news = new news(ConnectionFactory::get('mongo'));
     $result = $news->castVote($arguments[0], $arguments[1]);
     $post = $news->get($arguments[0], false, true);
     if (is_string($result)) {
         return Error::set($result, false, array('Back' => Url::format('/news/view/' . Id::create($post, 'news'))));
     }
     Error::set('Vote cast!', true, array('Back' => Url::format('/news/view/' . Id::create($post, 'news'))));
 }
Пример #5
0
 /**
  * Get a user by id.
  * 
  * @param string $id The user id.
  * @param bool $idlib If the id library should be used.
  * @param bool $justOne If only one entry should be returned.
  * 
  * @return array The user found as an array.
  */
 protected function get($id, $idlib = true, $justOne = true)
 {
     if ($idlib) {
         $keys = Id::dissectKeys($id, 'user');
         $query = array('username' => $this->clean($keys['username']));
     } else {
         $query = array('_id' => $this->_toMongoId($id));
     }
     if ($justOne) {
         return $this->resolveDeps($this->db->findOne($query));
     }
     $users = iterator_to_array($this->db->find($query));
     foreach ($users as $key => $user) {
         $users[$key] = $this->resolveCerts($user);
     }
     return $users;
 }
Пример #6
0
 /**
  * Get an article(s).
  * 
  * @param string $id Article id.
  * @param bool $idlib True if the Id library should be used (False for MongoIds)
  * @param bool $justOne True if only one entry should be returned.
  * @param bool $fixUTF8 True if UTF8 should be decoded.
  * 
  * @return mixed The article/articles as an array, or an error string.
  */
 protected function get($id, $idlib = true, $justOne = false, $fixUTF8 = true, $page = 1, $limit = self::PER_PAGE)
 {
     $query = array('published' => true, 'ghosted' => false);
     if ($idlib) {
         $keys = Id::dissectKeys($id, 'article');
         $query['date'] = array('$gte' => $keys['date'], '$lte' => $keys['date'] + $keys['ambiguity']);
     } else {
         $query['_id'] = $this->_toMongoId($id);
     }
     $results = $this->db->find($query)->skip(($page - 1) * self::PER_PAGE)->sort(array('date' => -1));
     $total = $results->count();
     $valid = array();
     if ($limit != null) {
         $results->limit($limit);
     }
     if ($idlib) {
         foreach ($results as $result) {
             if (!Id::validateHash($id, array('ambiguity' => $keys['ambiguity'], 'reportedDate' => $keys['date'], 'date' => $result['date'], 'title' => $result['title']), 'news')) {
                 continue;
             }
             array_push($valid, $result);
         }
     } else {
         $valid = iterator_to_array($results);
     }
     if ($justOne) {
         $valid = array(reset($valid));
     }
     if (empty($valid)) {
         return array('Invalid id.', 0);
     }
     $comments = new comments(ConnectionFactory::get('mongo'));
     foreach ($valid as $key => $entry) {
         $this->resolveUser($valid[$key]['user']);
         if ($fixUTF8) {
             $this->resolveUTF8($valid[$key]);
         }
         $valid[$key]['rating'] = $this->getScore($entry['_id']);
         $valid[$key]['comments'] = $comments->getCount($entry['_id']);
     }
     if ($justOne) {
         return reset($valid);
     }
     return array($valid, $total);
 }
Пример #7
0
 /**
  * Gets a bug.
  * 
  * @param string $id Bug id.
  * @param bool $idlib True if the Id library should be used (False for MongoIds)
  * @param bool $justOne True if only one entry should be returned.
  * @param bool $fixUTF8 True if UTF8 should be decoded.
  * 
  * @return mixed The bug/bugs as an array, or an error string.
  */
 protected function get($id, $idlib = true, $justOne = false, $fixUTF8 = true, $page = 1, $limit = self::PER_PAGE)
 {
     $query = array('ghosted' => false);
     if ($idlib) {
         $keys = Id::dissectKeys($id, 'bugs');
         $query['created'] = (int) $keys['time'];
     } else {
         $query['_id'] = $this->_toMongoId($id);
     }
     $results = $this->db->find($query)->skip(($page - 1) * self::PER_PAGE);
     $total = $results->count();
     $valid = array();
     if ($limit != null) {
         $results->limit($limit);
     }
     if ($idlib) {
         foreach ($results as $result) {
             if (!Id::validateHash($id, array('_id' => $result['_id'], 'created' => $result['created']), 'bugs')) {
                 continue;
             }
             array_push($valid, $result);
         }
     } else {
         $valid = iterator_to_array($results);
     }
     if ($justOne) {
         $valid = array(reset($valid));
     }
     if (empty($valid) || $total == 0) {
         return array('Invalid id.', 0);
     }
     foreach ($valid as $key => $entry) {
         $this->resolveUser($valid[$key]['reporter']);
         if ($fixUTF8) {
             $this->resolveUTF8($valid[$key]);
         }
     }
     if ($justOne) {
         return reset($valid);
     }
     return array($valid, $total);
 }
Пример #8
0
 /**
  * Add this tag to an Item for a particular agent
  * 
  * @param object TaggedItem $item
  * @param object Id $agentId
  * @param optional object DateAndTime $date An optional timestamp, used for importing historical tags.
  * @return object The item
  * @access public
  * @since 11/6/06
  */
 function tagItemForAgent(TaggedItem $item, Id $agentId, DateAndTime $date = null)
 {
     // Make sure the item is not already tagged
     if ($this->isItemTagged($item)) {
         return $item;
     }
     // Make sure the tag has a non-zero length
     if (!$this->getValue()) {
         return $item;
     }
     $query = new InsertQuery();
     $query->setTable('tag');
     $query->addValue('value', $this->getValue());
     $query->addValue('user_id', $agentId->getIdString());
     $query->addValue('fk_item', $item->getDatabaseId());
     //printpre("'".addslashes($item->getDatabaseId())."'"))
     if (!is_null($date)) {
         $query->addValue('tstamp', $date->asString());
     }
     $dbc = Services::getService("DatabaseManager");
     $result = $dbc->query($query, $this->getDatabaseIndex());
     return $item;
 }
Пример #9
0
 public function clearCache($id, $idlib = false)
 {
     $entry = $this->get($id, $idlib, true);
     if (empty($entry)) {
         return;
     }
     self::ApcPurge('get', $entry['_id']);
     self::ApcPurge('get', Id::create($this->type, $entry));
 }
Пример #10
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Id the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Id::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #11
0
 /**
  * Get the Parts of the Records for this Asset that are based on this
  * RecordStructure PartStructure's unique Id.
  *
  * WARNING: NOT IN OSID (as of July 2005)
  * 
  * @param object Id $partStructureId
  *  
  * @return object PartIterator
  * 
  * @throws object RepositoryException An exception with one of
  *         the following messages defined in
  *         org.osid.repository.RepositoryException may be thrown: {@link
  *         org.osid.repository.RepositoryException#OPERATION_FAILED
  *         OPERATION_FAILED}, {@link
  *         org.osid.repository.RepositoryException#PERMISSION_DENIED
  *         PERMISSION_DENIED}, {@link
  *         org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *         CONFIGURATION_ERROR}, {@link
  *         org.osid.repository.RepositoryException#UNIMPLEMENTED
  *         UNIMPLEMENTED}, {@link
  *         org.osid.repository.RepositoryException#NULL_ARGUMENT
  *         NULL_ARGUMENT}, {@link
  *         org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  * 
  * @access public
  */
 function getPartsByPartStructure(Id $partStructureId)
 {
     $this->_loadParts();
     $partArray = array();
     if (isset($this->_parts[$partStructureId->getIdString()])) {
         $partArray[] = $this->_parts[$partStructureId->getIdString()];
     }
     $partsIterator = new HarmoniIterator($partArray);
     return $partsIterator;
 }
 /**
  * Get the Asset with the specified unique Id.
  * 
  * @param object Id $assetId
  *  
  * @return object Asset
  * 
  * @throws object RepositoryException An exception with one of
  *         the following messages defined in
  *         org.osid.repository.RepositoryException may be thrown: {@link
  *         org.osid.repository.RepositoryException#OPERATION_FAILED
  *         OPERATION_FAILED}, {@link
  *         org.osid.repository.RepositoryException#PERMISSION_DENIED
  *         PERMISSION_DENIED}, {@link
  *         org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *         CONFIGURATION_ERROR}, {@link
  *         org.osid.repository.RepositoryException#UNIMPLEMENTED
  *         UNIMPLEMENTED}, {@link
  *         org.osid.repository.RepositoryException#NULL_ARGUMENT
  *         NULL_ARGUMENT}, {@link
  *         org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  * 
  * @access public
  */
 function getAsset(Id $assetId)
 {
     $query = new SelectQuery();
     $query->addTable($this->config['table']);
     $query->addColumn($this->config['id_column']);
     foreach ($this->config['columns'] as $column) {
         $query->addColumn($column);
     }
     $query->addWhereEqual($this->config['id_column'], substr($assetId->getIdString(), strlen($this->getId()->getIdString() . ".")));
     $assets = new SimpleTableAssetIterator($this, $this->config, $this->dbc->query($query, $this->dbIndex));
     if (!$assets->hasNext()) {
         throw new UnknownIdException();
     }
     return $assets->next();
 }
 /**
  * Get all the PartStructures in the RecordStructure.  Iterators return a
  * set, one at a time.
  *	
  * @return object PartStructureIterator
  * 
  * @throws object RepositoryException An exception with one of
  *		   the following messages defined in
  *		   org.osid.repository.RepositoryException may be thrown: {@link
  *		   org.osid.repository.RepositoryException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.repository.RepositoryException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.repository.RepositoryException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}
  * 
  * @access public
  */
 function getPartStructure(Id $partStructureId)
 {
     if ($this->_partStructures[$partStructureId->getIdString()]) {
         return $this->_partStructures[$partStructureId->getIdString()];
     } else {
         throwError(new Error(RepositoryException::UNKNOWN_ID(), "Repository :: FileRecordStructure", TRUE));
     }
 }
Пример #14
0
 /**
  * Get the Parts of the Records for this Asset that are based on this
  * RecordStructure PartStructure's unique Id.
  *
  * WARNING: NOT IN OSID (as of July 2005)
  * 
  * @param object Id $partStructureId
  *  
  * @return object PartIterator
  * 
  * @throws object RepositoryException An exception with one of
  *         the following messages defined in
  *         org.osid.repository.RepositoryException may be thrown: {@link
  *         org.osid.repository.RepositoryException#OPERATION_FAILED
  *         OPERATION_FAILED}, {@link
  *         org.osid.repository.RepositoryException#PERMISSION_DENIED
  *         PERMISSION_DENIED}, {@link
  *         org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *         CONFIGURATION_ERROR}, {@link
  *         org.osid.repository.RepositoryException#UNIMPLEMENTED
  *         UNIMPLEMENTED}, {@link
  *         org.osid.repository.RepositoryException#NULL_ARGUMENT
  *         NULL_ARGUMENT}, {@link
  *         org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  * 
  * @access public
  */
 function getPartsByPartStructure(Id $partStructureId)
 {
     if (!isset($this->partsByPartStructure[$partStructureId->getIdString()])) {
         return new HarmoniIterator(array());
     }
     return new HarmoniIterator($this->partsByPartStructure[$partStructureId->getIdString()]);
 }
 /**
  * Return true if a mapping between AuthNTokens and an AgentId exists for this auth
  * Type.
  * 
  * @param object Id $agentId
  * @param object AuthNTokens $authNTokens
  * @param object Type $authenticationType
  * @return boolean
  * @access public
  * @since 3/1/05
  */
 function mappingExists(Id $agentId, AuthNTokens $authNTokens, Type $authenticationType)
 {
     $this->_checkConfig();
     $dbc = Services::getService("DatabaseManager");
     $query = new SelectQuery();
     $query->addTable($this->_mappingTable);
     $query->addTable($this->_typeTable, LEFT_JOIN, $this->_mappingTable . '.fk_type=' . $this->_typeTable . '.id');
     $query->addColumn('agent_id');
     $query->addColumn('token_identifier');
     $query->addWhere("agent_id='" . addslashes($agentId->getIdString()) . "'");
     $query->addWhere("token_identifier='" . addslashes($authNTokens->getIdentifier()) . "'", _AND);
     $query->addWhere("domain='" . addslashes($authenticationType->getDomain()) . "'", _AND);
     $query->addWhere("authority='" . addslashes($authenticationType->getAuthority()) . "'", _AND);
     $query->addWhere("keyword='" . addslashes($authenticationType->getKeyword()) . "'", _AND);
     $result = $dbc->query($query, $this->_dbId);
     if ($result->getNumberOfRows() == 1) {
         $result->free();
         return TRUE;
     }
     if ($result->getNumberOfRows() == 0) {
         $result->free();
         return FALSE;
     } else {
         throwError(new Error("Invalid number of results: " . $result->getNumberOfRows(), "AgentTokenMappingManager", true));
     }
 }
Пример #16
0
 /**
  * Determines if this Qualifier is a descendant of the given qualifierId.
  * 
  * @param object Id $ancestorId
  *	
  * @return boolean
  * 
  * @throws object AuthorizationException An exception with
  *		   one of the following messages defined in
  *		   org.osid.authorization.AuthorizationException may be thrown:
  *		   {@link
  *		   org.osid.authorization.AuthorizationException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.authorization.AuthorizationException#UNKNOWN_ID
  *		   UNKNOWN_ID}
  * 
  * @access public
  */
 function isDescendantOf(Id $ancestorId)
 {
     // Alright, I realize this could be written much more efficiently (for
     // example by using Hierarchy->traverse()) but it is too much pain to do so.
     // The code below uses the methods in this class and is clearer, albeit slower.
     // Are we going to use this method a lot anyway?
     // base case
     if ($ancestorId->isEqual($this->getId())) {
         return true;
     }
     // recurse up
     $parents = $this->getParents();
     while ($parents->hasNext()) {
         $parent = $parents->next();
         if ($parent->isDescendantOf($ancestorId)) {
             return true;
         }
     }
     return false;
 }
Пример #17
0
 /**
  * Delete a Node by Id.	 Only leaf Nodes can be deleted.
  * 
  * @param object Id $nodeId
  * 
  * @throws object HierarchyException An exception with one of
  *		   the following messages defined in
  *		   org.osid.hierarchy.HierarchyException may be thrown:	 {@link
  *		   org.osid.hierarchy.HierarchyException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.hierarchy.HierarchyException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.hierarchy.HierarchyException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.hierarchy.HierarchyException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.hierarchy.HierarchyException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.hierarchy.HierarchyException#NODE_TYPE_NOT_FOUND
  *		   NODE_TYPE_NOT_FOUND}, {@link
  *		   org.osid.hierarchy.HierarchyException#INCONSISTENT_STATE
  *		   INCONSISTENT_STATE}
  * 
  * @access public
  */
 function deleteNode(Id $nodeId)
 {
     $this->_cache->deleteNode($nodeId->getIdString());
     // Database foreign key constraints should take care of deleting implicit AZs.
 }
 /**
  * Get the PartStructure in the RecordStructure with the specified Id.
  * @param object $infoPartId
  * @return object PartStructure
  * @throws osid.dr.DigitalRepositoryException An exception with one of the following messages defined in osid.dr.DigitalRepositoryException may be thrown: {@link DigitalRepositoryException#OPERATION_FAILED OPERATION_FAILED}, {@link DigitalRepositoryException#PERMISSION_DENIED PERMISSION_DENIED}, {@link DigitalRepositoryException#CONFIGURATION_ERROR CONFIGURATION_ERROR}, {@link DigitalRepositoryException#UNIMPLEMENTED UNIMPLEMENTED}
  */
 function getPartStructure(Id $partStructureId)
 {
     if (!isset($this->partStructures[$partStructureId->getIdString()])) {
         throw new UnknownIdException("<strong>" . $partStructureId->getIdString() . "</strong> was not found in <strong>" . implode(", ", array_keys($this->partStructures)) . "</strong>.");
     }
     return $this->partStructures[$partStructureId->getIdString()];
 }
Пример #19
0
    echo '<a style="font-size: 11px;" title="' . $fullTitle . '" href="' . $link . '">' . $shortTitle . '</a><br />';
}
?>
    </div></div>
    <div class="span6"><div class="well">
        <h4>IRC Lines</h4>
        <em>Not implemented yet.</em>
    </div></div>
</div>

<div class="row">
    <div class="span3"><div class="well">
        <h4>Latest Articles</h4>
<?php 
foreach ($newArticles['articles'] as $entry) {
    $link = Url::format('/article/view/' . Id::create($entry, 'news'));
    $fullTitle = $entry['title'];
    $shortTitle = html_entity_decode($fullTitle, ENT_QUOTES);
    $longer = strlen($shortTitle) > 30;
    $shortTitle = substr($shortTitle, 0, 30);
    $shortTitle = htmlentities($shortTitle, ENT_QUOTES) . ($longer ? '&hellip;' : '');
    echo '<a style="font-size: 11px;" title="' . $fullTitle . '" href="' . $link . '">' . $shortTitle . '</a><br />';
}
?>
    </div></div>
    <div class="span6"><div class="well">
        <h4>Active Forum Posts</h4>
<?php 
if (!empty($fPosts)) {
    foreach ($fPosts as $post) {
        echo '<a href="' . Url::format($post['url']) . '">' . $post['topic'] . '</a><br />';
Пример #20
0
 /**
  * Build the ancestory rows for a given node
  * 
  * @param object Id $id
  * @return void
  * @access protected
  * @since 4/23/08
  */
 protected function rebuildNodeAncestory_Harmoni_Db(Id $id)
 {
     $idString = $id->getIdString();
     // Delete the old ancestory rows
     $this->clearNodeAncestory($idString);
     // Make sure we have traversed the authoratative parent/child hierarchy
     // To determine the new ancestory of the nodes
     if (!$this->_isCachedUp($idString, -1)) {
         $this->_traverseUp($idString, -1);
     }
     // now that all nodes are cached, add their ids to the ancestor table for
     // easy future searching.
     if (!isset($this->rebuildNodeAncestory_stmt)) {
         $query = $this->harmoni_db->insert();
         $query->setTable("az2_node_ancestry");
         $query->addRawValue("fk_hierarchy", "?");
         $query->addRawValue("fk_node", "?");
         $query->addRawValue("fk_ancestor", "?");
         $query->addRawValue("level", "?");
         $query->addRawValue("fk_ancestors_child", "?");
         $this->rebuildNodeAncestory_stmt = $query->prepare();
     }
     $this->rebuildNodeAncestory_stmt->bindValue(1, $this->_hierarchyId);
     $this->rebuildNodeAncestory_stmt->bindValue(2, $idString);
     $treeNode = $this->_tree->getNode($idString);
     $treeNodes = $this->_tree->traverse($treeNode, false, -1);
     if (count($treeNodes) > 1) {
         foreach (array_keys($treeNodes) as $i => $key) {
             $node = $this->_cache[$key][0];
             // If the node was deleted, but the cache still has a key for it,
             // continue.
             if (!is_object($node)) {
                 continue;
             }
             $nodeId = $node->getId();
             // 				printpre($nodeId->getIdString());
             if (!$nodeId->isEqual($id)) {
                 foreach ($treeNodes[$key]['children'] as $ancestorChildId) {
                     $this->rebuildNodeAncestory_stmt->bindValue(3, $nodeId->getIdString());
                     $this->rebuildNodeAncestory_stmt->bindValue(4, $treeNodes[$key][1]);
                     $this->rebuildNodeAncestory_stmt->bindValue(5, $ancestorChildId);
                     $this->rebuildNodeAncestory_stmt->execute();
                 }
             } else {
                 $this->rebuildNodeAncestory_stmt->bindValue(3, null);
                 $this->rebuildNodeAncestory_stmt->bindValue(4, '0');
                 $this->rebuildNodeAncestory_stmt->bindValue(5, null);
                 $this->rebuildNodeAncestory_stmt->execute();
             }
         }
     }
 }
Пример #21
0
 function isEqual(Id $id)
 {
     return $id->getIdString() == $this->_id ? true : false;
 }
 /**
  * Create a CourseGradeRecord for the specified Agent (student),
  * CourseOffering, CourseGradeType, and CourseGrade.  Note that the intent
  * is that this is a summative grade.
  *
  * @param object Id $agentId
  * @param object Id $courseOfferingId
  * @param object Type $courseGradeType
  * @param object mixed $courseGrade (original type: java.io.Serializable)
  *
  * @return object CourseGradeRecord
  *
  * @throws object CourseManagementException An exception
  *		   with one of the following messages defined in
  *		   org.osid.coursemanagement.CourseManagementException may be
  *		   thrown:	{@link
  *		   org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#UNKNOWN_TYPE
  *		   UNKNOWN_TYPE}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#UNKNOWN_ID
  *		   UNKNOWN_ID}
  *
  * @access public
  */
 function createCourseGradeRecord(Id $agentId, Id $courseOfferingId, Type $courseGradeType, $courseGrade)
 {
     $idManager = Services::getService("IdManager");
     $dbManager = Services::getService("DatabaseManager");
     $courseOffering = $this->getCourseOffering($courseOfferingId);
     if ($courseGradeType != null && !$courseGradeType->isEqual($courseOffering->getGradeType())) {
         throwError(new Error("Cannot create a CourseGradeRecord if the GradeType differs from the CourseOffering", "CourseManagementManager", true));
     }
     $query = new InsertQuery();
     $query->setTable('cm_grade_rec');
     $query->setColumns(array('fk_student_id', 'fk_cm_offer', 'name', 'grade'));
     $values[] = "'" . addslashes($agentId->getIdString()) . "'";
     $values[] = "'" . addslashes($courseOfferingId->getIdString()) . "'";
     $values[] = "'CourseGradeRecord'";
     $values[] = "'" . addslashes($courseGrade) . "'";
     $query->addRowOfValues($values);
     $query->setAutoIncrementColumn('id', 'cm_grade_rec_id_seq');
     $result = $dbManager->query($query);
     $id = $result->getLastAutoIncrementValue();
     $ret = new HarmoniCourseGradeRecord($idManager->getId($id));
     return $ret;
 }
 /**
  * Get an array of the string Ids of the groups that contain the particular
  * Id.
  * 
  * @param object Id $agentOrGroupId
  * @return array
  * @access private
  * @since 11/29/04
  */
 function _getContainingGroupIdStrings(Id $agentOrGroupId)
 {
     $agentOrGroupIdString = $agentOrGroupId->getIdString();
     // Check our cache first and only do the search if we don't have
     // the ancestors yet.
     if (!isset($this->_groupAncestorsCache[$agentOrGroupIdString]) || !is_array($this->_groupAncestorsCache[$agentOrGroupIdString])) {
         $groupIds = array();
         $agentManager = Services::getService("Agent");
         $ancestorSearchType = new HarmoniType("Agent & Group Search", "edu.middlebury.harmoni", "AncestorGroups");
         $containingGroups = $agentManager->getGroupsBySearch($agentOrGroupId, $ancestorSearchType);
         while ($containingGroups->hasNext()) {
             $group = $containingGroups->next();
             $groupId = $group->getId();
             $groupIds[] = $groupId->getIdString();
         }
         $this->_groupAncestorsCache[$agentOrGroupIdString] = $groupIds;
     }
     return $this->_groupAncestorsCache[$agentOrGroupIdString];
 }
Пример #24
0
 /**
  * Forcibly set the creator of this Asset. This is meant to be used when importing
  * from backups.
  *  
  * WARNING: NOT IN OSID
  *
  * @param object Id $agentId
  * @return void
  * @access public
  * @since 1/25/08
  */
 public function forceSetCreator(Id $agentId)
 {
     $dbHandler = Services::getService("DatabaseManager");
     $query = new UpdateQuery();
     $query->setTable("dr_asset_info");
     $query->addValue("creator", $agentId->getIdString());
     $query->addWhere("asset_id='" . $this->getId()->getIdString() . "'");
     $dbHandler->query($query, $this->_dbIndex);
     $this->_creator = $agentId->getIdString();
 }
Пример #25
0
    echo $description;
    ?>
</blockquote>
<?php 
}
?>
	
	<p><?php 
echo BBCode::parse($body);
?>
</p>

<?php 
if (!empty($mlt)) {
    ?>
    <p><h4>More Like This:</h4>
<?php 
    foreach ($mlt as $fetched) {
        echo '<a href="' . Url::format('article/view/' . Id::create($fetched, 'news')) . '">' . $fetched['title'] . '</a><br />';
    }
    ?>
</p>
<?php 
}
if ($published && empty($revision) && empty($preview)) {
    $data = array('_id' => $_id, 'rating' => $rating, 'type' => 'Articles', 'where' => 'article');
    echo Partial::render('like', $data);
}
?>
</div>
 /**
  * Answer the Externally-defined group Ids that are the children of the group id passed.
  * 
  * @param object Id $hierarchyParentId
  * @return array
  * @access public
  * @since 11/6/07
  */
 public function getExternalChildGroupIds(Id $hierarchyParentId)
 {
     $query = new SelectQuery();
     $query->addTable('agent_external_children');
     $query->addColumn('fk_child');
     $query->addWhereEqual('fk_parent', $hierarchyParentId->getIdString());
     $dbc = Services::getService("DBHandler");
     $result = $dbc->query($query, $this->_configuration->getProperty('database_index'));
     $idMgr = Services::getService("Id");
     $children = array();
     while ($result->hasMoreRows()) {
         $children[] = $idMgr->getId($result->field('fk_child'));
         $result->advanceRow();
     }
     return $children;
 }
Пример #27
0
 /**
  * Add an Id to the Queue
  * 
  * @param object Id $id
  * @return void
  * @access public
  * @since 12/20/05
  */
 function queueId(Id $id)
 {
     $this->queueIdString($id->getIdString());
 }
Пример #28
0
 /**
  * Remove a student from the roster.
  * 
  * @param object Id $agentId
  * 
  * @throws object CourseManagementException An exception
  *		   with one of the following messages defined in
  *		   org.osid.coursemanagement.CourseManagementException may be
  *		   thrown:	{@link
  *		   org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#UNKNOWN_ID
  *		   UNKNOWN_ID}
  * 
  * @access public
  */
 function removeStudent(Id $agentId)
 {
     $dbManager = Services::getService("DatabaseManager");
     $query = new DeleteQuery();
     $query->setTable('cm_enroll');
     $query->addWhere("fk_cm_section='" . addslashes($this->_id->getIdString()) . "'");
     $query->addWhere("fk_student_id='" . addslashes($agentId->getIdString()) . "'");
     $dbManager->query($query);
 }
Пример #29
0
 /**
  * Delete a Part and all its Parts.
  * 
  * @param object Id $partId
  * 
  * @throws object RepositoryException An exception with one of
  *		   the following messages defined in
  *		   org.osid.repository.RepositoryException may be thrown: {@link
  *		   org.osid.repository.RepositoryException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.repository.RepositoryException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.repository.RepositoryException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.repository.RepositoryException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  * 
  * @access public
  */
 function deletePart(Id $partId)
 {
     $string = $partId->getIdString();
     if (preg_match("/(.*)-(" . implode("|", array_keys($this->_parts)) . ")/", $string, $r)) {
         $recordId = $r[1];
         $field = $r[2];
         if ($this->_isLastPart($field)) {
             $dbHandler = Services::getService("DatabaseManager");
             // Delete the data
             $query = new DeleteQuery();
             $query->setTable("dr_file_url");
             $query->setWhere("fk_file = '" . $this->_id->getIdString() . "'");
             $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
             // Delete the thumbnail
             $query = new DeleteQuery();
             $query->setTable("dr_thumbnail");
             $query->setWhere("fk_file = '" . $this->_id->getIdString() . "'");
             $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
             // delete the file row.
             $query = new DeleteQuery();
             $query->setTable("dr_file");
             $query->setWhere("id = '" . $this->_id->getIdString() . "'");
             $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
         } else {
             $this->_parts[$field]->updateValue("NULL");
         }
     } else {
         throwError(new Error(RepositoryException::UNKNOWN_ID() . ": {$string}", "FileRecord", true));
     }
     $this->_asset->updateModificationDate();
 }
Пример #30
0
 /**
  * @param Id $id
  * @return bool
  */
 public function equalsTo(Id $id)
 {
     return $this->value == $id->getId();
 }