Esempio n. 1
0
 public function executeJsonUpdate(sfWebRequest $request)
 {
     $isAjax = $request->isXmlHttpRequest();
     if (!$isAjax) {
         return $this->redirect('@homepage');
     }
     $id = $request->getParameter('id');
     $group = sfGuardGroupPeer::retrieveByPK($id);
     if (!$group) {
         $group_form = new sfGuardGroupForm();
     } else {
         $group_form = new sfGuardGroupForm($group);
     }
     $result = $this->processForm($request, $group_form);
     try {
         // remove existing permissions for the given group
         $c = new Criteria();
         $c->add(EtvaPermissionGroupPeer::GROUP_ID, $request->getParameter('id'), Criteria::EQUAL);
         $g_p = EtvaPermissionGroupPeer::doSelect($c);
         //filter group permissions
         foreach ($g_p as $p) {
             $p->delete();
         }
         // add new permission set
         $perm_list = $request->getParameter('sf_guard_group_permission_list');
         $perm_list_dec = json_decode($perm_list);
         foreach ($perm_list_dec as $object) {
             $g_p = new EtvaPermissionGroup();
             $g_p->setGroupId($request->getParameter('id'));
             $g_p->setEtvapermId($object);
             $g_p->save();
         }
     } catch (Exception $e) {
         $result = array('success' => false, 'error' => 'Could not perform operation', 'agent' => sfConfig::get('config_acronym'), 'info' => 'Could not perform operation');
     }
     if (!$result['success']) {
         $error = $this->setJsonError($result);
         return $this->renderText($error);
     }
     $msg_i18n = $this->getContext()->getI18N()->__('Group saved successfully');
     $response = array('success' => true, 'agent' => 'Central Management', 'response' => $msg_i18n, 'group_id' => $result['object']['Id']);
     $return = json_encode($response);
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     return $this->renderText($return);
 }
Esempio n. 2
0
 public function getsfGuardGroup($con = null)
 {
     if ($this->asfGuardGroup === null && $this->group_id !== null) {
         include_once 'plugins/sfGuardPlugin/lib/model/om/BasesfGuardGroupPeer.php';
         $this->asfGuardGroup = sfGuardGroupPeer::retrieveByPK($this->group_id, $con);
     }
     return $this->asfGuardGroup;
 }
Esempio n. 3
0
 public function executeEditWin(sfWebRequest $request)
 {
     $this->sf_guard_group = sfGuardGroupPeer::retrieveByPK($request->getParameter('id'));
     $this->form = $this->configuration->getForm($this->sf_guard_group);
     //die ('$request->getParameter(id): '.$request->getParameter('id'));
 }
 /**
  * Check if a group exists given to an id.
  * @param Int $group_id
  * @return Boolean
  */
 public static function groupExists($id)
 {
     return sfGuardGroupPeer::retrieveByPK($id) ? true : false;
 }
Esempio n. 5
0
 public function executeChangeRole($request)
 {
     $this->form = new ChangeRoleForm(array(), array('actual_user' => $this->getUser()));
     $values = $request->getParameter($this->form->getName());
     if (isset($values['roles']) && !empty($values['roles'])) {
         $this->getUser()->clearCredentials();
         $new_login_role = sfGuardGroupPeer::retrieveByPK($values['roles']);
         $this->getUser()->setLoginRole($new_login_role->getName());
         //die(var_dump($this->getUser()->getAttribute('login_role')));
         $this->getUser()->addCredentials(sfGuardPermissionPeer::retrieveAllCredentialsForARole(sfGuardGroupPeer::retrieveByName($this->getUser()->getLoginRole())));
     }
     return $this->redirect("mainBackend/index");
 }