/**
  * Answer an TagInfoIterator that lists information on tags attached to an item.
  * 
  * @param object TaggedItem $item
  * @return object TagInfoIterator
  * @access public
  * @since 4/18/08
  */
 public function getTagInfoForItem(TaggedItem $item)
 {
     $query = new SelectQuery();
     $query->addTable('tag');
     $query->addColumn('value');
     $query->addColumn('user_id');
     $query->addColumn('tstamp');
     $query->addWhereEqual("fk_item", $item->getDatabaseId());
     $dbc = Services::getService("DatabaseManager");
     $result = $dbc->query($query, $this->getDatabaseIndex());
     $iterator = new HarmoniIterator(array());
     $idManager = Services::getService("Id");
     while ($result->hasNext()) {
         $row = $result->next();
         $iterator->add(new TagInfo(new Tag($row['value']), $item, $idManager->getId($row['user_id']), DateAndTime::fromString($row['tstamp'])));
     }
     return $iterator;
 }
 /**
  * Return the next Qualifier.
  *	
  * @return object Qualifier
  * 
  * @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#NO_MORE_ITERATOR_ELEMENTS
  *		   NO_MORE_ITERATOR_ELEMENTS}
  * 
  * @access public
  */
 function next()
 {
     // If this is the first element access, inform our AZ cache that we are
     // working with this set of nodes so that it can fetch AZs for all of
     // them at once.
     if ($this->_i == -1) {
         $isAuthorizedCache = IsAuthorizedCache::instance();
         $isAuthorizedCache->queueAssetArray($this->_elements);
     }
     return parent::next();
 }
 /**
  * Answer an iterator of groups that contain the Id. If $includeSubgroups
  * is true then groups will be returned if any descendent group contains
  * the Id.
  *
  * @param object Id $id
  * @return object AgentIterator
  * @access public
  * @since 2/23/06
  */
 function getGroupsContainingGroup($id, $includeSubgroups)
 {
     $result = $this->_queryDirectory('get_group', array('id' => $id->getIdString(), 'include_membership' => 'true'));
     $groups = new HarmoniIterator(array());
     foreach ($result->getElementsByTagNameNS('http://www.yale.edu/tp/cas', 'attribute') as $element) {
         if ($element->getAttribute('name') == 'MemberOf') {
             $groups->add(new CASGroup(new HarmoniId($element->getAttribute('value')), $this));
         }
     }
     return $groups;
 }
Beispiel #4
0
 /**
  * Answer the replies in ascending or descending time.
  * 
  * @param string $order The constant ASC or DESC for ascending time (oldest 
  *			first) or decending time (recent first).
  * @return iterator
  * @access public
  * @since 7/3/07
  */
 function getReplies($order = ASC)
 {
     // Load the replies, their creation times into arrays for caching and
     // easy sorting.
     if (!isset($this->_replies)) {
         $this->_replyIds = array();
         $this->_replyTimes = array();
         $mediaFileType = new Type('segue', 'edu.middlebury', 'media_file', 'A file that is uploaded to Segue.');
         $children = $this->_asset->getAssets();
         while ($children->hasNext()) {
             $child = $children->next();
             if (!$mediaFileType->isEqual($child->getAssetType())) {
                 $dateTime = $child->getCreationDate();
                 $this->_replyIds[] = $child->getId();
                 $this->_replyTimes[] = $dateTime->asString();
             }
         }
     }
     // Sort the reply Ids based on time.
     array_multisort($this->_replyIds, $this->_replyTimes, $order == ASC ? SORT_ASC : SORT_DESC);
     $null = null;
     $replies = new HarmoniIterator($null);
     $commentManager = CommentManager::instance();
     foreach ($this->_replyIds as $id) {
         $replies->add($commentManager->getComment($id));
     }
     return $replies;
 }
 /**
  * Answer all of the comments attached to an asset
  * 
  * @param object $assetOrId An Asset object or an Id object
  * @param string $order The constant ASC or DESC for ascending time (oldest 
  *			first) or decending time (recent first).
  * @return object Iterator
  * @access public
  * @since 7/3/07
  */
 function getAllComments($assetOrId, $order = ASC)
 {
     ArgumentValidator::validate($assetOrId, OrValidatorRule::getRule(ExtendsValidatorRule::getRule('Asset'), ExtendsValidatorRule::getRule('Id')));
     if (method_exists($assetOrId, 'getId')) {
         $asset = $assetOrId;
         $assetId = $asset->getId();
     } else {
         $repositoryManager = Services::getService("Repository");
         $idManager = Services::getService("Id");
         $repository = $repositoryManager->getRepository($idManager->getId("edu.middlebury.segue.sites_repository"));
         $asset = $repository->getAsset($assetOrId);
         $assetId = $assetOrId;
     }
     // Load the replies, their creation times into arrays for caching and
     // easy sorting.
     $assetIdString = $assetId->getIdString();
     if (!isset($this->_allComments[$assetIdString])) {
         $this->_allComments[$assetIdString] = array();
         $this->_allComments[$assetIdString]['ids'] = array();
         $this->_allComments[$assetIdString]['times'] = array();
         $rootComments = $this->getRootComments($asset);
         $allComments = new MultiIteratorIterator();
         while ($rootComments->hasNext()) {
             $allComments->addIterator($this->_getDescendentComments($rootComments->next()));
         }
         while ($allComments->hasNext()) {
             $comment = $allComments->next();
             $dateTime = $comment->getCreationDate();
             $this->_allComments[$assetIdString]['ids'][] = $comment->getId();
             $this->_allComments[$assetIdString]['times'][] = $dateTime->asSeconds();
         }
     }
     // Sort the comment Ids based on time.
     array_multisort($this->_allComments[$assetIdString]['times'], SORT_NUMERIC, $order == ASC ? SORT_ASC : SORT_DESC, $this->_allComments[$assetIdString]['ids']);
     $null = null;
     $comments = new HarmoniIterator($null);
     foreach ($this->_allComments[$assetIdString]['ids'] as $id) {
         $comments->add($this->getComment($id));
     }
     return $comments;
 }