コード例 #1
0
ファイル: AdminController.php プロジェクト: staser/webacula
 public function webaculaUpdateAction()
 {
     $role_id = $this->_request->getParam('role_id');
     $role_name = $this->_request->getParam('role_name');
     if (empty($role_id) || empty($role_name)) {
         throw new Exception(__METHOD__ . ' : Empty input parameters');
     }
     $form = new FormWebaculaACL();
     $table = new Wbresources();
     if ($this->_request->isPost()) {
         // Проверяем валидность данных формы
         if ($form->isValid($this->_getAllParams())) {
             // update data
             try {
                 $table->updateResources($this->_request->getParam('webacula_resources'), $role_id);
             } catch (Zend_Exception $e) {
                 $this->view->exception = $this->view->translate->_('Exception') . ' : ' . $e->getMessage();
             }
             // clear all cache
             $this->cache_helper->clearAllCache();
             // render
             $this->_forward('role-main-form', 'admin', null, array('role_id' => $role_id, 'role_name' => $role_name, 'tabs_selected' => 'webacula'));
             // action, controller
             return;
         }
     }
     // create form
     // get resources
     $wbresources = $table->fetchAll($table->getAdapter()->quoteInto('role_id = ?', $role_id), 'id');
     $webacula_resources = null;
     foreach ($wbresources as $v) {
         $webacula_resources[] = $v->dt_id;
     }
     // fill form
     $form->populate(array('acl' => 'webacula', 'role_id' => $role_id, 'role_name' => $role_name));
     if (isset($webacula_resources)) {
         $form->populate(array('webacula_resources' => $webacula_resources));
     }
     $form->setAction($this->view->baseUrl . '/admin/role-main-form');
     $this->view->form = $form;
     $this->view->tabs_selected = $this->_jQueryUItabSelected['webacula'];
     // jQuery UI Tabs
     $this->renderScript('admin/role-main-form.phtml');
 }