Пример #1
0
 /**
  * Code to be run after persisting the object
  * @param PropelPDO $con
  */
 public function postSave(PropelPDO $con = null)
 {
     // update plugin permissions in the database
     if (is_array($this->setEnabledPlugins)) {
         foreach ($this->setEnabledPlugins as $pluginName => $enabled) {
             if ($enabled) {
                 PermissionPeer::enablePlugin($pluginName, $this->getId());
             } else {
                 PermissionPeer::disablePlugin($pluginName, $this->getId());
             }
         }
     }
     // update special services permissions in the database
     if (is_array($this->setEnabledServices)) {
         foreach ($this->setEnabledServices as $permissionName => $enabled) {
             if ($enabled) {
                 PermissionPeer::enableForPartner($permissionName, PermissionType::SPECIAL_FEATURE, $this->getId());
             } else {
                 PermissionPeer::disableForPartner($permissionName, $this->getId());
             }
         }
     }
     $this->setEnabledPlugins = array();
     $this->setEnabledServices = array();
     $ksObj = kSessionUtils::crackKs(kCurrentContext::$ks);
     $currentKuser = null;
     if (is_object($ksObj)) {
         $currentKuser = kuserPeer::getKuserByEmail($ksObj->user, -2);
     }
     if ($currentKuser) {
         $allowedPartners = $currentKuser->getAllowedPartners();
         if (isset($allowedPartners) && !empty($allowedPartners)) {
             $partnersArray = array_map('trim', explode(',', $allowedPartners));
             if (!in_array($this->getId(), $partnersArray)) {
                 $currentKuser->setAllowedPartners($allowedPartners . ',' . $this->getId());
             }
         } else {
             $currentKuser->setAllowedPartners($this->getId());
         }
         $currentKuser->save();
     }
 }
Пример #2
0
 /**
  * Code to be run after persisting the object
  * @param PropelPDO $con
  */
 public function postSave(PropelPDO $con = null)
 {
     // update plugin permissions in the database
     if (is_array($this->setEnabledPlugins)) {
         foreach ($this->setEnabledPlugins as $pluginName => $enabled) {
             if ($enabled) {
                 PermissionPeer::enablePlugin($pluginName, $this->getId());
             } else {
                 PermissionPeer::disablePlugin($pluginName, $this->getId());
             }
         }
     }
     // update special services permissions in the database
     if (is_array($this->setEnabledServices)) {
         foreach ($this->setEnabledServices as $permissionName => $enabled) {
             if ($enabled) {
                 PermissionPeer::enableForPartner($permissionName, PermissionType::SPECIAL_FEATURE, $this->getId());
             } else {
                 PermissionPeer::disableForPartner($permissionName, $this->getId());
             }
         }
     }
     $this->setEnabledPlugins = array();
     $this->setEnabledServices = array();
     parent::postSave($con);
 }