Exemple #1
0
 public function save(PropelPDO $con = null)
 {
     if ($this->isColumnModified(accessControlPeer::DELETED_AT)) {
         if ($this->isDefault === true) {
             throw new Exception("Default access control profile can't be deleted");
         }
         $c = new Criteria();
         $c->add(entryPeer::ACCESS_CONTROL_ID, $this->getId());
         $entryCount = entryPeer::doCount($c);
         if ($entryCount > 0) {
             throw new Exception("Access control profile is linked with entries and can't be deleted");
         }
     }
     if ($this->isNew()) {
         $c = new Criteria();
         $c->add(accessControlPeer::PARTNER_ID, $this->partner_id);
         $count = accessControlPeer::doCount($c);
         if ($count >= Partner::MAX_ACCESS_CONTROLS) {
             throw new kCoreException("Max number of access control profiles was reached", kCoreException::MAX_NUMBER_OF_ACCESS_CONTROLS_REACHED);
         }
     }
     parent::save($con);
     // set this conversion profile as partners default
     $partner = PartnerPeer::retrieveByPK($this->partner_id);
     if ($partner && $this->isDefault === true) {
         $partner->setDefaultAccessControlId($this->getId());
         $partner->save();
     }
 }