Example #1
0
 /**
  * Aktualizacja ról, które mają dostęp do filtra
  *
  * @param Base_Form_Abstract $form formularz z danymi do zapisania
  * @param integer $id id filtra
  * @return integer ilość poprawionych wierszy
  */
 public function shareFilter($form, $id)
 {
     $model = new RoleFilterResource();
     $values = $form->getValues();
     $model->getAdapter()->beginTransaction();
     $filters = $model->fetchAll('id_filter = ' . $id);
     foreach ($filters as $filter) {
         $filter->delete();
     }
     $ret = 0;
     try {
         foreach ($values as $role_id) {
             $tmp = $model->createRow(array('id_filter' => $id, 'id_role' => $role_id));
             $tmp->save();
             $ret++;
         }
         $model->getAdapter()->commit();
         $cm = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager');
         $cache = $cm->getCache('rolecache');
         $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     } catch (Exception $e) {
         $model->getAdapter()->rollBack();
     }
     return $ret;
 }