/** * 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)); } }