public function modifyAction($I_id)
 {
     $this->haveAccess();
     $S_name = $_POST['name'];
     $O_profileMapper = new ProfileMapper();
     $O_profile = $O_profileMapper->findById($I_id);
     if ($S_name != $O_profile->getname()) {
         try {
             $O_profile->setName($S_name);
             $O_profileMapper->update($O_profile);
             die(header('Location:/user/default/'));
         } catch (Exception $e) {
             Session::setSession('error', $e->getMessage());
         }
     } else {
         die(header('Location:/profile/edit/' . $I_id));
     }
 }
Example #2
0
 public function findPerPage($A_limit)
 {
     $I_firstOfPage = $A_limit['firstOfPage'];
     $I_perPage = $A_limit['perPage'];
     $S_sql = 'SELECT id, login, operator_id, inspector_id, profile_id FROM user LIMIT ' . $I_firstOfPage . ', ' . $I_perPage;
     $O_connection = new Connection();
     if ($A_data = $O_connection->requestDb($S_sql, $A_params = null, self::CLASS_NAME)) {
         $A_users = null;
         foreach ($A_data as $key => $value) {
             $O_user = $A_data[$key];
             if (!is_null($O_user->getOperatorId())) {
                 try {
                     $O_operatorMapper = new OperatorMapper();
                     $O_operator = $O_operatorMapper->findById($O_user->getOperatorId());
                     $O_user->setOperator($O_operator);
                     $O_teamMapper = new TeamMapper();
                     $O_team = $O_teamMapper->findByOperator($O_user->getOperatorId());
                     $O_operator->setTeam($O_team);
                 } catch (Exception $e) {
                     echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
                 }
             }
             if (!is_null($O_user->getInspectorId())) {
                 try {
                     $O_inspectorMapper = new InspectorMapper();
                     $O_inspector = $O_inspectorMapper->findById($O_user->getInspectorId());
                     $O_user->setInspector($O_inspector);
                 } catch (Exception $e) {
                     echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
                 }
             }
             if (!is_null($O_user->getProfileId())) {
                 try {
                     $O_profileMapper = new ProfileMapper();
                     $O_profile = $O_profileMapper->findById($O_user->getProfileId());
                     $O_user->setProfile($O_profile);
                 } catch (Exception $e) {
                     echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
                 }
             }
             $A_users[] = $O_user;
         }
     } else {
         throw new Exception("Une erreur s'est produite");
     }
     return $A_users;
 }
 public function newAction()
 {
     $this->isAdmin();
     $O_companyMapper = new CompanyMapper();
     $O_company = $O_companyMapper->findAll();
     $O_profileMapper = new ProfileMapper();
     $O_profile = $O_profileMapper->findAll();
     Buffer::flushBuffer('user/new', array('company' => $O_company, 'profile' => $O_profile));
 }