Esempio n. 1
0
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $id = $this->params()->fromRoute('id');
     $lang = $this->params()->fromRoute('lang');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $userDetails = $this->layout()->getVariable('userDetails');
     /* Check user ID and UPDATE permission */
     if ($userDetails->id != $id and !$userDetails->acl->hasResource('users_update') and $id != '') {
         return $this->redirect()->toRoute('admin/not-authorized', array('lang' => 'it'));
     }
     /* Check user ID and INSERT permission */
     if ($id == '' and !$userDetails->acl->hasResource('users_add')) {
         return $this->redirect()->toRoute('admin/not-authorized', array('lang' => 'it'));
     }
     $helper = new UsersControllerHelper();
     $records = $helper->recoverWrapperRecordsById(new UsersGetterWrapper(new UsersGetter($em)), array('id' => $id, 'limit' => 1), $id);
     $form = new UsersForm();
     if (!empty($records)) {
         $form->addPasswords();
     } else {
         $form->addPasswordsMandatory();
     }
     /* Check Roles permission */
     if ($userDetails->acl->hasResource('users_roles_update')) {
         $rolesRecords = $helper->recoverWrapperRecords(new UsersRolesGetterWrapper(new UsersRolesGetter($em)), array());
         $rolesRecordsForDropDown = $helper->formatForDropwdown($rolesRecords, 'id', 'name');
         $form->addRoles($rolesRecordsForDropDown);
     }
     /* Check Settori permission */
     if ($userDetails->acl->hasResource('users_settori_update')) {
         $settoriRecords = $helper->recoverWrapperRecords(new UsersSettoriGetterWrapper(new UsersSettoriGetter($em)), array());
         $settoriRecordsForDropDown = $helper->formatForDropwdown($settoriRecords, 'id', 'nome');
         $form->addSettori($settoriRecordsForDropDown);
     }
     if (!empty($records)) {
         $formAction = $this->url()->fromRoute('admin/users-update', array('lang' => $lang));
         $formTitle = 'Modifica utente';
         $formDescription = 'Modifica dati utente. Per creare una <strong>password sicura</strong>, scegliere una string lunga almeno 8 caratteri e che contenga caratteri speciali, lettere maiuscole e\\o minuscole e numeri.';
         $form->setData($records[0]);
     } else {
         $formAction = $this->url()->fromRoute('admin/users-insert', array('lang' => $lang));
         $formTitle = 'Nuovo utente';
         $formDescription = 'Creazione nuovo utente. Per creare una <strong>password sicura</strong>, scegliere una string lunga almeno 8 caratteri e che contenga caratteri speciali, lettere maiuscole e\\o minuscole e numeri.';
     }
     $this->layout()->setVariables(array('form' => $form, 'formTitle' => $formTitle, 'formDescription' => $formDescription, 'formAction' => $formAction, 'formBreadCrumbCategory' => 'Utenti', 'formBreadCrumbCategoryLink' => $this->url()->fromRoute('admin/users-summary', array('lang' => $this->params()->fromRoute('lang'))), 'templatePartial' => self::formTemplate));
     $this->layout()->setTemplate($mainLayout);
 }
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     try {
         $helper = new UsersControllerHelper();
         $usersRespProcRecords = $helper->recoverWrapperRecords(new UsersRespProcGetterWrapper(new UsersRespProcGetter($em)), array('orderBy' => 'u.surname'));
         $idsToExclude = $helper->gatherIdsFromRecordset($usersRespProcRecords);
         $userRecords = $helper->recoverWrapperRecords(new UsersGetterWrapper(new UsersGetter($em)), array('fields' => 'u.id, u.name, u.surname', 'adminAccess' => 1, 'excludeId' => $idsToExclude, 'orderBy' => 'u.surname'));
         if (!empty($userRecords)) {
             $usersForDropDown = $helper->formatForDropwdown($userRecords, 'id', 'name');
         } else {
             $usersForDropDown = array();
         }
         $form = new UsersRespProcForm();
         $form->addUsers($usersForDropDown);
         $this->layout()->setVariables(array('form' => $form, 'usersRespProc' => $usersRespProcRecords, 'usersForDropDown' => $usersForDropDown, 'formDataCommonPath' => 'backend/templates/common/', 'formBreadCrumbCategory' => array(array('href' => $this->url()->fromRoute('admin/users-responsabili-procedimento', array('lang' => $this->params()->fromRoute('lang'))), 'label' => 'Atti di concessione', 'title' => 'Elenco atti di concessione')), 'formBreadCrumbTitle' => 'Responsabili procedimento', 'templatePartial' => 'users/resp-proc-management.phtml'));
     } catch (\Exception $e) {
     }
     $this->layout()->setTemplate($mainLayout);
 }