public function findallAction()
 {
     $role = new Acl_Model_Role();
     $roles = $role->findAll();
     $default_role = $role->findDefaultRoleId();
     $data = array();
     foreach ($roles as $role) {
         $is_default_role = false;
         if ($role->getId() == $default_role) {
             $is_default_role = true;
         }
         $data[] = array("id" => $role->getId(), "code" => $role->getCode(), "label" => $role->getLabel(), "default" => $is_default_role);
     }
     $this->_sendHtml($data);
 }
 public function findAction()
 {
     $admin = new Admin_Model_Admin();
     $admin->find($this->getRequest()->getParam("admin_id"));
     $data = array();
     if ($admin->getId()) {
         $data["admin"] = $admin->getData();
         $data["section_title"] = $this->_("Edit the user %s", $admin->getFirstname() . " " . $admin->getLastname());
     } else {
         $data["section_title"] = $this->_("Create a new user");
     }
     $data["applications_section_title"] = $this->_("Manage access");
     $countries = Zend_Registry::get('Zend_Locale')->getTranslationList('Territory', null, 2);
     asort($countries, SORT_LOCALE_STRING);
     $data["country_codes"] = $countries;
     $roles = $admin->getAvailableRole();
     $data["roles"] = $roles;
     $role = new Acl_Model_Role();
     $default_role_id = $role->findDefaultRoleId();
     $data["default_role_id"] = $default_role_id;
     $this->_sendHtml($data);
 }
 public function signuppostAction()
 {
     if ($data = $this->getRequest()->getPost()) {
         try {
             // Check l'email et le mot de passe
             if (empty($data['email']) or !Zend_Validate::is($data['email'], 'emailAddress')) {
                 throw new Exception($this->_('Please enter a valid email address.'));
             }
             if (empty($data['password']) or strlen($data['password']) < 6) {
                 throw new Exception($this->_('The password must be at least 6 characters.'));
             }
             if (empty($data['confirm_password']) or $data['password'] != $data['confirm_password']) {
                 throw new Exception($this->_('The password and the confirmation does not match.'));
             }
             $admin = new Admin_Model_Admin();
             $admin->findByEmail($data['email']);
             if ($admin->getId()) {
                 throw new Exception($this->_('We are sorry but this email address is already used.'));
             }
             $role = new Acl_Model_Role();
             if ($default_role = $role->findDefaultRoleId()) {
                 $admin->setRoleId($default_role);
             }
             // Créé le user
             $admin->setEmail($data['email'])->setPassword($data['password'])->save();
             // Met le user en session
             $this->getSession()->setAdmin($admin);
             $admin->sendAccountCreationEmail($data["password"]);
             $redirect_to = 'admin/application/list';
         } catch (Exception $e) {
             if ($this->getSession()->isLoggedIn()) {
                 $redirect_to = 'admin/application/list';
             } else {
                 $this->getSession()->addError($e->getMessage());
                 $redirect_to = "/";
             }
         }
         $this->redirect($redirect_to);
     }
 }