Пример #1
0
 /**
  * Adds an {@link EventListener} to be triggered whenever an event is thrown.
  * @param string $eventType The string event type for which this {@link EventListener} is listening (example: "edu.middlebury.harmoni.action_executed")
  * @param ref object $eventListener the {@link EventListener} object.
  * @access public
  * @return ref object
  */
 function addEventListener($eventListener)
 {
     ArgumentValidator::validate($eventListener, HasMethodsValidatorRule::getRule("handleEvent"), true);
     //		if (!isset($this->_eventListeners[$eventType]) || !is_array($this->_eventListeners[$eventType])) {
     //			$this->_eventListeners[$eventType] = array();
     //		}
     //		$this->_eventListeners[$eventType][] =$eventListener;
     $this->_eventListeners[] = $eventListener;
 }
 /**
  * Answer true if the value passed is a valid option
  * 
  * @param string $value
  * @return boolean
  * @access public
  * @since 4/28/06
  */
 function isOption($value)
 {
     if (is_object($value)) {
         ArgumentValidator::validate($value, HasMethodsValidatorRule::getRule("asString"));
         return parent::isOption($value->asString());
     } else {
         return parent::isOption($value);
     }
 }
 /**
  * Set the size of the new input components
  * 
  * @param integer $size
  * @return void
  * @access public
  * @since 5/1/06
  */
 function setSize($size)
 {
     $hasMethods = HasMethodsValidatorRule::getRule("setSize");
     if ($hasMethods->check($this->_new)) {
         $this->_new->setSize(40);
     }
     if ($hasMethods->check($this->_select)) {
         $this->_select->setSize(40);
     }
 }
 /**
  * Set the input component
  * 
  * @param object WComponent $input
  * @return object WComponent
  * @access public
  * @since 10/20/05
  */
 function setInputComponent($input)
 {
     ArgumentValidator::validate($input, ExtendsValidatorRule::getRule("WizardComponent"));
     ArgumentValidator::validate($input, HasMethodsValidatorRule::getRule("addOnChange"));
     $this->_input = $input;
     $this->_input->setParent($this);
     return $this->_input;
 }
Пример #5
0
 /**
  * Optional: Set the publish date
  * 
  * @param object DateAndTime $pubDate
  * @return void
  * @access public
  * @since 8/7/06
  */
 function setPubDate($pubDate)
 {
     ArgumentValidator::validate($pubDate, HasMethodsValidatorRule::getRule("asDateAndTime"));
     $this->_pubDate = $pubDate->asDateAndTime();
 }
Пример #6
0
 /**
  * Update the date at which this Asset expires.
  * 
  * @param object DateAndTime $expirationDate
  * 
  * @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#EFFECTIVE_PRECEDE_EXPIRATION}
  * 
  * @access public
  */
 function updateExpirationDate($expirationDate)
 {
     ArgumentValidator::validate($expirationDate, OptionalRule::getRule(HasMethodsValidatorRule::getRule("asDateAndTime")));
     // Make sure that we have dates from the DB if they exist.
     $this->_loadDates();
     // Update our date in preparation for DB updating
     $this->_expirationDate = $expirationDate;
     // Store the dates
     $this->_storeDates();
 }
Пример #7
0
 /**
  * Adds an {@link EventListener} to be triggered whenever an event is thrown.
  * @param string $eventType The string event type for which this {@link EventListener} is listening (example: "edu.middlebury.harmoni.action_executed")
  * @param ref object $eventListener the {@link EventListener} object.
  * @access public
  * @return ref object
  */
 function addEventListener($eventListener)
 {
     ArgumentValidator::validate($eventListener, HasMethodsValidatorRule::getRule("handleEvent"), true);
     $this->_eventListeners[] = $eventListener;
     return $eventListener;
 }
 /**
  * Sets the value of this Component to the {@link SObject} passed.
  * @param ref object $value The {@link SObject} value to use.
  *
  * @return void
  **/
 function setValue($value)
 {
     ArgumentValidator::validate($value, HasMethodsValidatorRule::getRule("asString"));
     parent::setValue($value->asString());
 }
Пример #9
0
 /**
  * the date when this Authorization stops being effective.
  * 
  * @param object DateAndTime $effectiveDate
  * 
  * @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#EFFECTIVE_PRECEDE_EXPIRATION}
  * 
  * @access public
  */
 function updateEffectiveDate($effectiveDate)
 {
     if (!$this->isExplicit()) {
         // "Cannot modify an implicit Authorization."
         throwError(new Error(AuthorizationException::OPERATION_FAILED(), "Authorization", true));
     }
     // ** parameter validation
     ArgumentValidator::validate($effectiveDate, HasMethodsValidatorRule::getRule("asDateAndTime"), true);
     // ** end of parameter validation
     // make sure effective date is before expiration date
     if ($effectiveDate->isGreaterThan($this->_expirationDate)) {
         throwError(new Error(AuthorizationException::EFFECTIVE_PRECEDE_EXPIRATION(), "Authorization", true));
     }
     if ($this->_effectiveDate->isEqualTo($effectiveDate)) {
         return;
     }
     // nothing to update
     // update the object
     $this->_effectiveDate = $effectiveDate;
     // update the database
     $dbHandler = Services::getService("DatabaseManager");
     $query = new UpdateQuery();
     $query->setTable("az2_explicit_az");
     $query->addWhereEqual("id", $this->_id);
     $timestamp = $dbHandler->toDBDate($effectiveDate, $this->_cache->_dbIndex);
     $query->addValue("effective_date", $timestamp);
     $queryResult = $dbHandler->query($query, $this->_cache->_dbIndex);
     if ($queryResult->getNumberOfRows() == 0) {
         throwError(new Error(AuthorizationException::OPERATION_FAILED(), "Authorization", true));
     }
     if ($queryResult->getNumberOfRows() > 1) {
         throwError(new Error(AuthorizationException::OPERATION_FAILED(), "Authorization", true));
     }
 }
Пример #10
0
 /**
  * Converts a DateAndTime object to a proper datetime/timestamp/time representation 
  * for the specified database object. $dateAndTime must implement asDateAndTime().
  * @access public
  * @param ref object DateAndTime The DateAndTime object to convert.
  * @param integer dbIndex The index of the database to use (0 by default).
  * @return mixed A proper datetime/timestamp/time representation for this Database.
  */
 function toDBDate(DateAndTime $dateAndTime, $dbIndex = 0)
 {
     // ** parameter validation
     ArgumentValidator::validate($dateAndTime, HasMethodsValidatorRule::getRule("asDateAndTime"), true);
     $this->_validateDBIndex($dbIndex);
     // ** end of parameter validation
     return $this->_databases[$dbIndex]->toDBDate($dateAndTime);
 }
 /**
  * Answer the component needed to modify a given PartStructure
  * 
  * @param object PartStructure $partStruct
  * @return object WizardComponent
  * @access public
  * @since 10/26/05
  */
 function getComponentForPartStruct($partStruct)
 {
     // get the correct component for this data type
     $component = PrimitiveIOManager::createComponentForPartStructure($partStruct);
     $hasMethods = HasMethodsValidatorRule::getRule("setSize");
     if ($hasMethods->check($component)) {
         $component->setSize(40);
     }
     return $component;
 }
Пример #12
0
 /**
  * Get the Asset with the specified unique Id that is appropriate for the
  * date specified.	The specified date allows a Repository implementation
  * to support Asset versioning.
  * 
  * @param object Id $assetId
  * @param object DateAndTime $date
  *	
  * @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#NO_OBJECT_WITH_THIS_DATE
  *		   NO_OBJECT_WITH_THIS_DATE}
  * 
  * @access public
  */
 function getAssetByDate(Id $assetId, $date)
 {
     ArgumentValidator::validate($date, HasMethodsValidatorRule::getRule("asDateAndTime"));
     die("Method <b>" . __FUNCTION__ . "()</b> declared in class <b> " . __CLASS__ . "</b> has not been implimented.");
     // Return an Asset where all Records have the values that they
     // would have on the specified date.
 }
Пример #13
0
 /**
  * Answer a comment object identified by Id or asset
  * 
  * @param mixed $assetOrId
  * @return object CommentNode
  * @access public
  * @since 7/3/07
  */
 function getComment($assetOrId)
 {
     ArgumentValidator::validate($assetOrId, OrValidatorRule::getRule(HasMethodsValidatorRule::getRule('getId'), HasMethodsValidatorRule::getRule('getIdString')));
     if (method_exists($assetOrId, 'getId')) {
         $asset = $assetOrId;
         $id = $asset->getId();
     } else {
         $id = $assetOrId;
     }
     // Cache the comment if needed
     if (!isset($this->_comments[$id->getIdString()])) {
         // Get the assset if we were passed an Id only
         if (!isset($asset)) {
             $repositoryManager = Services::getService("Repository");
             $idManager = Services::getService("Id");
             $repository = $repositoryManager->getRepository($idManager->getId("edu.middlebury.segue.sites_repository"));
             $asset = $repository->getAsset($id);
         }
         $this->_comments[$id->getIdString()] = new CommentNode($asset);
     }
     return $this->_comments[$id->getIdString()];
 }