コード例 #1
0
ファイル: accessControl.php プロジェクト: AdiTal/server
 public function preSave(PropelPDO $con = null)
 {
     if ($this->isColumnModified(accessControlPeer::DELETED_AT)) {
         if ($this->isDefault === true) {
             throw new kCoreException("Default access control profile [" . $this->getId() . "] can't be deleted", kCoreException::ACCESS_CONTROL_CANNOT_DELETE_PARTNER_DEFAULT);
         }
         $defaultAccessControl = $this->getPartner()->getDefaultAccessControlId();
         if (!$defaultAccessControl) {
             throw new kCoreException("no default access control on partner", kCoreException::NO_DEFAULT_ACCESS_CONTROL);
         }
         entryPeer::updateAccessControl($this->getPartnerId(), $this->id, $defaultAccessControl);
     }
     return parent::preSave($con);
 }
 /**
  * Delete Access Control Profile by id
  * 
  * @action delete
  * @param int $id
  */
 function deleteAction($id)
 {
     $dbAccessControl = accessControlPeer::retrieveByPK($id);
     if (!$dbAccessControl) {
         throw new KalturaAPIException(KalturaErrors::ACCESS_CONTROL_ID_NOT_FOUND, $id);
     }
     if ($dbAccessControl->getIsDefault()) {
         throw new KalturaAPIException(KalturaErrors::CANNOT_DELETE_DEFAULT_ACCESS_CONTROL);
     }
     $c = new Criteria();
     $c->add(entryPeer::ACCESS_CONTROL_ID, $dbAccessControl->getId());
     // move entries to the default access control
     $entryCount = entryPeer::doCount($c);
     if ($entryCount > 0) {
         entryPeer::updateAccessControl($this->getPartnerId(), $id, $this->getPartner()->getDefaultAccessControlId());
     }
     $dbAccessControl->setDeletedAt(time());
     $dbAccessControl->save();
 }