コード例 #1
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("/(.*)-(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));
     }
 }
コード例 #2
0
 /**
  * Creates a new Authorization object, caches it, and inserts it into the database.
  * @access public
  * @param ref object agentId who is authorized to perform this Function for this Qualifer and its descendants
  * @param ref object functionId the Id of the Function for this Authorization
  * @param ref object qualifierId the Id of the Qualifier for this Authorization
  * @param object DateAndTime effectiveDate when the Authorization becomes effective
  * @param object DateAndTime expirationDate when the Authorization stops being effective
  * @return ref object Authorization
  **/
 function createAuthorization(Id $agentId, Id $functionId, Id $qualifierId, $effectiveDate = NULL, $expirationDate = NULL)
 {
     // ** parameter validation
     ArgumentValidator::validate($effectiveDate, OptionalRule::getRule(IntegerValidatorRule::getRule()), true);
     ArgumentValidator::validate($expirationDate, OptionalRule::getRule(IntegerValidatorRule::getRule()), true);
     // ** end of parameter validation
     // create the authorization object
     $idManager = Services::getService("Id");
     $id = $idManager->createId();
     $idValue = $id->getIdString();
     // figure out whether it's dated or not
     $dated = isset($effectiveDate) && isset($expirationDate);
     if ($dated) {
         $authorization = new HarmoniAuthorization($idValue, $agentId, $functionId, $qualifierId, true, $this, $effectiveDate, $expirationDate);
     } else {
         $authorization = new HarmoniAuthorization($idValue, $agentId, $functionId, $qualifierId, true, $this);
     }
     $dbHandler = Services::getService("DatabaseManager");
     if (isset($this->harmoni_db)) {
         if (!isset($this->createAZ_stmt)) {
             $query = $this->harmoni_db->insert();
             $query->setTable("az_authorization");
             $query->addRawValue("authorization_id", "?");
             $query->addRawValue("fk_agent", "?");
             $query->addRawValue("fk_function", "?");
             $query->addRawValue("fk_qualifier", "?");
             $query->addRawValue("authorization_effective_date", "?");
             $query->addRawValue("authorization_expiration_date", "?");
             $this->createAZ_stmt = $query->prepare();
         }
         $this->createAZ_stmt->bindValue(1, $idValue);
         $this->createAZ_stmt->bindValue(2, $agentId->getIdString());
         $this->createAZ_stmt->bindValue(3, $functionId->getIdString());
         $this->createAZ_stmt->bindValue(4, $qualifierId->getIdString());
         if (is_object($effectiveDate)) {
             $this->createAZ_stmt->bindValue(5, $dbHandler->toDBDate($effectiveDate, $this->_dbIndex));
         } else {
             $this->createAZ_stmt->bindValue(5, null);
         }
         if (is_object($expirationDate)) {
             $this->createAZ_stmt->bindValue(6, $dbHandler->toDBDate($expirationDate, $this->_dbIndex));
         } else {
             $this->createAZ_stmt->bindValue(6, null);
         }
         // 			try {
         $this->createAZ_stmt->execute();
         // 			} catch (Zend_Db_Statement_Exception $e) {
         // 				throw new OperationFailedException("An Explicit Authorization already exists for '$agentId' to '$functionId' at '$qualifierId'");
         // 			}
     } else {
         // now insert into database
         $dbHandler = Services::getService("DatabaseManager");
         $query = new InsertQuery();
         $query->setTable("az_authorization");
         $columns = array();
         $columns[] = "authorization_id";
         $columns[] = "fk_agent";
         $columns[] = "fk_function";
         $columns[] = "fk_qualifier";
         if ($dated) {
             $columns[] = "authorization_effective_date";
             $columns[] = "authorization_expiration_date";
         }
         $query->setColumns($columns);
         $values = array();
         $values[] = "'" . addslashes($idValue) . "'";
         $values[] = "'" . addslashes($agentId->getIdString()) . "'";
         $values[] = "'" . addslashes($functionId->getIdString()) . "'";
         $values[] = "'" . addslashes($qualifierId->getIdString()) . "'";
         if ($dated) {
             if (is_object($effectiveDate)) {
                 $values[] = $dbHandler->toDBDate($effectiveDate, $this->_dbIndex);
             } else {
                 $values[] = "NULL";
             }
             if (is_object($expirationDate)) {
                 $values[] = $dbHandler->toDBDate($expirationDate, $this->_dbIndex);
             } else {
                 $values[] = "NULL";
             }
         }
         $query->setValues($values);
         try {
             $dbHandler->query($query, $this->_dbIndex);
         } catch (DuplicateKeyDatabaseException $e) {
             throw new OperationFailedException("An Explicit Authorization already exists for '{$agentId}' to '{$functionId}' at '{$qualifierId}'");
         }
     }
     $this->_authorizations[$idValue] = $authorization;
     return $authorization;
 }
コード例 #3
0
 /**
  * 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));
     }
 }
コード例 #4
0
 /**
  * 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));
     }
 }
コード例 #5
0
 function isEqual(Id $id)
 {
     return $id->getIdString() == $this->_id ? true : false;
 }
コード例 #6
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;
 }
コード例 #7
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();
 }
コード例 #8
0
 /**
  * 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()];
 }
コード例 #9
0
 /**
  * Import a historical version, for instance from a backup system.
  * 
  * @param object DOMDocument $versionXml The version markup.
  * @param object Id $agentId The agent id that created the version.
  * @param object DateAndTime $timestamp The time the version was created.
  * @param string $comment A comment associated with the version.
  * @return void
  * @access public
  * @since 1/23/08
  */
 public function importVersion(DOMDocument $versionXml, Id $agentId, DateAndTime $timestamp, $comment)
 {
     $query = new InsertQuery();
     $query->setTable('segue_plugin_version');
     $query->addValue('node_id', $this->getId());
     $query->addValue('tstamp', $timestamp->asString());
     $query->addValue('agent_id', $agentId->getIdString());
     $query->addValue('comment', $comment);
     $query->addValue('version_xml', $versionXml->saveXML());
     $dbc = Services::getService('DBHandler');
     $dbc->query($query, IMPORTER_CONNECTION);
     unset($this->versions);
 }
コード例 #10
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("/(.+)::(.+)::([0-9]+)/", $string, $r)) {
         $recordId = $r[1];
         $label = $r[2];
         $index = $r[3];
         if ($this->_record->getID() == $recordId) {
             $this->_record->deleteValue($label, $index);
             $this->_record->commit(TRUE);
         }
     } else {
         throwError(new Error(RepositoryException::UNKNOWN_ID() . ": {$string}", "HarmoniPart", true));
     }
     $this->_asset->updateModificationDate();
 }
コード例 #11
0
 /**
  * Create a new CourseGroup
  * 
  * @param object Id $id The Identifier to use for this Course Group. This may
  *						be related to some sort of course code if desired.
  * @param string $displayName
  * @return object SegueCourseGroup
  * @access public
  * @since 8/20/07
  */
 public function createCourseGroup(Id $id, $displayName)
 {
     $agentMgr = Services::getService("Agent");
     $idMgr = Services::getService("Id");
     $rootGroup = $agentMgr->getGroup($idMgr->getId("edu.middlebury.segue.coursegroups"));
     $propType = new Type("segue", "edu.middlebury", "coursegroup");
     $properties = new HarmoniProperties($propType);
     $idString = $id->getIdString();
     $properties->addProperty("CourseGroupId", $idString);
     $courseGroup = $agentMgr->createGroup($displayName, new Type('segue', 'edu.middlebury', 'coursegroup'), "", $properties);
     $rootGroup->add($courseGroup);
     return $this->getCourseForGroup($courseGroup);
 }
コード例 #12
0
ファイル: Node.class.php プロジェクト: adamfranco/harmoni
 /**
  * Changes the parent of this Node by adding a new parent and removing the
  * old parent.
  * 
  * @param object Id $oldParentId
  * @param object Id $newParentId
  * 
  * @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#ATTEMPTED_RECURSION
  *		   ATTEMPTED_RECURSION}
  * 
  * @access public
  */
 function changeParent(Id $oldParentId, Id $newParentId)
 {
     if ($oldParentId->isEqual($newParentId)) {
         return;
     }
     $authZ = $this->_cache->getAuthorizationManager();
     $isAuthorizedCache = $authZ->getIsAuthorizedCache();
     $isAuthorizedCache->dirtyNode($this->_id);
     // Store the current ancestor Ids for AuthZ updating
     $oldAncestorIds = $this->getAncestorIds();
     $this->_cache->removeParent($oldParentId->getIdString(), $this->_id->getIdString());
     $this->_cache->addParent($newParentId->getIdString(), $this->_id->getIdString());
     // Instruct the Authorization system to remove any implicit AZs given
     // the removal of our ancestors.
     $removedAncestors = $this->idsRemoved($oldAncestorIds, $this->getAncestorIds());
     $authZ->getAuthorizationCache()->deleteHierarchyImplictAZs($this, $removedAncestors);
     // Instruct the Authorization system to add any implicit AZs given
     // the addintion of our ancestors.
     $addedAncestors = $this->idsAdded($oldAncestorIds, $this->getAncestorIds());
     $authZ->getAuthorizationCache()->createHierarchyImplictAZs($this, $addedAncestors);
 }
コード例 #13
0
 /**
  * Add an Agent commitment to this ScheduleItem.
  * 
  * @param object Id $agentId
  * @param object Type $agentStatus
  * 
  * @throws object SchedulingException An exception with one of
  *         the following messages defined in
  *         org.osid.scheduling.SchedulingException may be thrown:   {@link
  *         org.osid.scheduling.SchedulingException#OPERATION_FAILED
  *         OPERATION_FAILED}, {@link
  *         org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  *         PERMISSION_DENIED}, {@link
  *         org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  *         CONFIGURATION_ERROR}, {@link
  *         org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  *         UNIMPLEMENTED}, {@link
  *         org.osid.scheduling.SchedulingException#UNKNOWN_ID UNKNOWN_ID},
  *         {@link org.osid.scheduling.SchedulingException#UNKNOWN_TYPE
  *         UNKNOWN_TYPE}, {@link
  *         org.osid.shared.SharedException#ALREADY_ADDED ALREADY_ADDED}
  * 
  * @access public
  */
 function addAgentCommitment(Id $agentId, Type $agentStatus)
 {
     $dbHandler = Services::getService("DBHandler");
     $query = new SelectQuery();
     $query->addTable('sc_commit');
     $query->addWhere("fk_sc_item='" . addslashes($this->_id->getIdString()) . "'");
     $query->addWhere("fk_agent_id='" . addslashes($agentId->getIdString()) . "'");
     $query->addColumn('id');
     //@TODO id is not really needed here--a count should probably be returned.
     $res = $dbHandler->query($query);
     if ($res->getNumberOfRows() == 0) {
         $typeIndex = $this->_typeToIndex('commit_stat', $agentStatus);
         $query = new InsertQuery();
         $query->setTable('sc_commit');
         $values[] = "'" . addslashes($agentId->getIdString()) . "'";
         $values[] = "'" . addslashes($typeIndex) . "'";
         $values[] = "'" . addslashes($this->_id->getIdString()) . "'";
         $query->setColumns(array('fk_agent_id', 'fk_sc_commit_stat_type', 'fk_sc_item'));
         $query->addRowOfValues($values);
         $query->setAutoIncrementColumn('id', 'id_sequence');
         $dbHandler->query($query);
     } else {
         print "<b>Warning!</b> Agent with id " . $agentId->getIdString() . "is already added to ScheduleItem " . $this->getDisplayName() . ".  Use changeAgentCommitment() to change the commitment status.";
     }
 }
コード例 #14
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());
 }
コード例 #15
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()]);
 }
コード例 #16
0
 /**
  * Answer true if the Agent Id passed is an instructor of this course
  * 
  * @param object Id $agentId
  * @return boolean
  * @access public
  * @since 8/20/07
  */
 public function isInstructor(Id $agentId)
 {
     $agentManager = Services::getService("Agent");
     // Since in this implementation "instructor" status is determined by
     // membership in one of several groups designated as "Faculty" and hence
     // will be the same accross all courses in which the user is a member,
     // we are caching "instructor" status in a class variable.
     if (!isset(self::$isInstructor[$agentId->getIdString()])) {
         if (!isset($_SESSION['coursemanagement_isinstructor'])) {
             $_SESSION['coursemanagement_isinstructor'] = array();
         }
         if (!isset($_SESSION['coursemanagement_isinstructor'][$agentId->getIdString()])) {
             // 			if ($agentId->getIdString() != '7362') {
             // 				$agentManager = Services::getService("Agent");
             // 				$agent = $agentManager->getAgentOrGroup($agentId);
             // 				printpre("Checking if instructor. ".$agentId->getIdString()." (".$agent->getDisplayName().") not in:");
             // 				printpre(self::$isInstructor);
             //
             // 				throw new Exception("testing");
             // 			}
             // Match the groups the user is in against our configuration of
             // groups whose members should have personal sites.
             $ancestorSearchType = new HarmoniType("Agent & Group Search", "edu.middlebury.harmoni", "AncestorGroups");
             $containingGroups = $agentManager->getGroupsBySearch($agentId, $ancestorSearchType);
             $isInstructor = false;
             while (!$isInstructor && $containingGroups->hasNext()) {
                 $group = $containingGroups->next();
                 foreach (self::$instructorGroups as $validGroupId) {
                     if ($validGroupId->isEqual($group->getId())) {
                         $isInstructor = true;
                         break;
                     }
                 }
             }
             $_SESSION['coursemanagement_isinstructor'][$agentId->getIdString()] = $isInstructor;
         }
         self::$isInstructor[$agentId->getIdString()] = $_SESSION['coursemanagement_isinstructor'][$agentId->getIdString()];
     }
     // Also verify that the user is a member in our group.
     $agent = $agentManager->getAgent($agentId);
     return self::$isInstructor[$agentId->getIdString()] && $this->getGroup()->contains($agent, true);
 }
コード例 #17
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();
             }
         }
     }
 }
コード例 #18
0
 /**
  * Answer a hierarchy node with the id specified
  * 
  * @param object Id $id
  * @return object Node
  * @access private
  * @since 4/7/08
  */
 private function getNode_Harmoni_Db(Id $id)
 {
     $idValue = $id->getIdString();
     if (!isset($this->getNode_stmt)) {
         $query = $this->harmoni_db->select();
         // find the hierarchy id for this node
         $query->addColumn("fk_hierarchy", "hierarchy_id", "az2_node");
         $query->addTable("az2_node");
         $joinc = "fk_hierarchy = " . "az2_hierarchy.id";
         $query->addTable("az2_hierarchy", INNER_JOIN, $joinc);
         $query->addWhereEqual("az2_node.id", $idValue);
         $this->getNode_stmt = $query->prepare();
     }
     $this->getNode_stmt->bindValue(1, $idValue);
     $this->getNode_stmt->execute();
     $result = $this->getNode_stmt->fetchAll();
     $this->getNode_stmt->closeCursor();
     if (count($result) != 1) {
         throw new UnknownIdException("Could not find node of id, '" . $id->getIdString() . "'.");
     }
     $nodeRow = $result[0];
     $idManager = Services::getService("Id");
     $hierarchyId = $nodeRow['hierarchy_id'];
     // get the hierarchy
     $hierarchy = $this->getHierarchy($idManager->getId($hierarchyId));
     $node = $hierarchy->getNode($id);
     return $node;
 }
コード例 #19
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.
 }
コード例 #20
0
 /**
  * Get all the Records of the specified RecordStructure for this Asset.
  * Iterators return a set, one at a time.
  * 
  * @param object Id $recordStructureId
  *  
  * @return object RecordIterator
  * 
  * @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 getRecordsByRecordStructure(Id $recordStructureId)
 {
     switch ($recordStructureId->getIdString()) {
         case 'dc':
             return new HarmoniIterator(array($this->dcRecord));
         case 'custom':
             return new HarmoniIterator(array($this->customRecord));
         default:
             throw new UnknownIdException();
     }
 }
コード例 #21
0
 /**
  * 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;
 }
コード例 #22
0
 /**
  * Delete a GradeRecord.  The first two parameters are required, but the
  * third may be left null to dignify any Type
  * 
  * @param object Id $gradableObjectId
  * @param object Id $agentId
  * @param object Type $GradeRecordType
  * 
  * @throws object GradingException An exception with one of the
  *         following messages defined in org.osid.grading.GradingException
  *         may be thrown:  {@link
  *         org.osid.grading.GradingException#OPERATION_FAILED
  *         OPERATION_FAILED}, {@link
  *         org.osid.grading.GradingException#PERMISSION_DENIED
  *         PERMISSION_DENIED}, {@link
  *         org.osid.grading.GradingException#CONFIGURATION_ERROR
  *         CONFIGURATION_ERROR}, {@link
  *         org.osid.grading.GradingException#UNIMPLEMENTED UNIMPLEMENTED},
  *         {@link org.osid.grading.GradingException#NULL_ARGUMENT
  *         NULL_ARGUMENT}, {@link
  *         org.osid.grading.GradingException#UNKNOWN_ID UNKNOWN_ID}
  * 
  * @access public
  */
 function deleteGradeRecord(Id $gradableObjectId, Id $agentId, Type $GradeRecordType)
 {
     $dbManager = Services::getService("DatabaseManager");
     $query = new DeleteQuery();
     $query->setTable('gr_record');
     $query->addWhere("fk_gr_gradable='" . addslashes($gradableObjectId->getIdString()) . "'");
     $query->addWhere("fk_agent_id='" . addslashes($agentId->getIdString()) . "'");
     if (!is_null($GradeRecordType)) {
         $query->addWhere("fk_gr_record_type='" . addslashes($this->_typeToIndex('record', $GradeRecordType)) . "'");
     }
     $dbManager->query($query);
 }
コード例 #23
0
ファイル: Tag.class.php プロジェクト: adamfranco/harmoni
 /**
  * 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;
 }
コード例 #24
0
 /**
  * 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();
 }
コード例 #25
0
 /**
  * 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];
 }
コード例 #26
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);
 }
コード例 #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
 /**
  * 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;
 }
コード例 #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
 /**
  * Get all the dates for the Asset with the specified unique Id.  These
  * dates allows a Repository implementation to support Asset versioning.
  * 
  * @param object Id $assetId
  *	
  * @return object LongValueIterator
  * 
  * @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}
  * 
  * @access public
  */
 function getAssetDates(Id $assetId)
 {
     $recordMgr = Services::getService("RecordManager");
     // Get the DataSets in the Asset's DataSetGroup
     $recordSet = $recordMgr->fetchRecordSet($assetId->getIdString());
     //		$recordSet->loadRecords(RECORD_FULL);
     //		$records =$dataSetGroup->fetchDataSets(TRUE);
     $dates = $recordSet->getMergedTagDates();
     // Create and return an iterator.
     $dateIterator = new HarmoniCalendarIterator($dates);
     return $dateIterator;
 }