コード例 #1
0
 /**
  * AddAttributes
  * Add a list of attributes in a group
  * @param integer $groupid
  * @param array $servers 
  * @return boolean
  */
 public static function AddServers($groupid, array $servers)
 {
     if (!empty($servers)) {
         foreach ($servers as $serverID) {
             $srv = new ServersGroupsIndexes();
             $srv->server_id = $serverID;
             $srv->group_id = $groupid;
             $srv->save();
         }
         return true;
     }
     return false;
 }
コード例 #2
0
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $form = $this->getForm("/admin/serversgroups/process");
     $request = $this->getRequest();
     // Create the buttons in the edit form
     $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/serversgroups/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/serversgroups/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null)));
     try {
         // Check if we have a POST request
         if (!$request->isPost()) {
             return $this->_helper->redirector('list', 'serversgroups', 'admin');
         }
         if ($form->isValid($request->getPost())) {
             // Get the values posted
             $params = $form->getValues();
             // Save the data
             $id = ServersGroups::saveAll($params['name'], $params['fill_type'], $params['active'], $this->getRequest()->getParam('group_id'));
             // Delete the old group
             ServersGroupsIndexes::deleteAllServers($id);
             if (!empty($params['servers'])) {
                 ServersGroupsIndexes::AddServers($id, $params['servers']);
             }
             $this->_helper->redirector('edit', 'serversgroups', 'admin', array('id' => $id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success'));
         } else {
             $this->view->form = $form;
             $this->view->title = $this->translator->translate("Servers Groups");
             $this->view->description = $this->translator->translate("Here you can edit the group detail");
             return $this->render('applicantform');
         }
     } catch (Exception $e) {
         $this->_helper->redirector('edit', 'serversgroups', 'admin', array('id' => $id, 'mex' => $e->getMessage(), 'status' => 'danger'));
     }
 }