예제 #1
0
 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);
 }
 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);
         }
         $c = new Criteria();
         $c->add(entryPeer::ACCESS_CONTROL_ID, $this->getId());
         $entryCount = entryPeer::doCount($c);
         if ($entryCount > 0) {
             throw new kCoreException("Default access control profile [" . $this->getId() . "] is linked with [{$entryCount}] entries and can't be deleted", kCoreException::ACCESS_CONTROL_CANNOT_DELETE_USED_PROFILE);
         }
     }
     return parent::preSave($con);
 }