芝麻web文件管理V1.00
编辑当前文件:/home/p/r/i/prismawe/www/resupres/dddse/application/classes/Controller/user.php
get('erreur'); if (!isset($tmpError)){ $session->set('erreur', array()); } } public function action_login() { // If the user is already connected. if (Auth::instance()->logged_in()) { HTTP::redirect('admin'); } $this->template->content = View::factory('user/login') ->bind('message', $message); if (HTTP_Request::POST == $this->request->method()) { // Attempt to login user $remember = array_key_exists('remember', $this->request->post()) ? (bool) $this->request->post('remember') : FALSE; $success = Auth::instance()->login($this->request->post('login'), $this->request->post('password'), $remember); // If successful, redirect user if ($success) { HTTP::redirect('admin'); } else { $_SESSION['erreur'][] = 'La conexión fue suspendido, palabra incorrecta de paso.'; } } } public function action_logout() { // Log user out Auth::instance()->logout(true); // Redirect to login page HTTP::redirect(''); } public function action_home(){ $this->template->content = View::factory('user/home'); $user = ORM::factory('user', $_SESSION['user']['id']); $this->template->content->user = $user; $this->template->content->mois = $user->mois->where('annee', 'is not', null)->and_where('mois', 'is not', null)->find_all(); $this->template->content->autres = $user->mois->where('annee', 'is', null)->and_where('mois', 'is', null)->find_all(); $this->template->content->commentaire = $user->commentaire; } public function action_modifier(){ $session = Session::instance(); $accessRight = $session->get('access_right'); if(!in_array($accessRight, array('admin', 'super'))){ $_SESSION['eereur'][] = 'Accès interdit'; HTTP::redirect(); } $id = $this->request->param('id'); $user = ORM::factory('user', $id); $this->template->content = View::factory('user/modifier'); $this->template->content->admins = ORM::factory('user')->where('type', '!=', 'client')->find_all(); $this->template->content->admin_id = $user->parent_id; $this->template->content->type = $user->type; $this->template->content->id = $user->id; $this->template->content->login = $user->login; $this->template->content->nom = $user->nom; $this->template->content->prenom = $user->prenom; $this->template->content->email = $user->email; $this->template->content->commentaire = $user->commentaire; $this->template->content->titrecommentaire = $user->titrecommentaire; $this->template->content->raisonsocial = $user->raisonsocial; $this->template->content->adresse = $user->adresse; $this->template->content->codepostal = $user->codepostal; $this->template->content->ville = $user->ville; $this->template->content->pays = $user->pays; $this->template->content->telephone = $user->telephone; } public function action_supprimer(){ $session = Session::instance(); $accessRight = $session->get('access_right'); if(!in_array($accessRight, array('admin', 'super'))){ $_SESSION['eereur'][] = 'Accès interdit'; HTTP::redirect(); } $id = $this->request->param('id'); $user = ORM::factory('user', $id); if($user->loaded()){ $user->delete(); } HTTP::redirect(); } public function action_modifierpost(){ $session = Session::instance(); $accessRight = $session->get('access_right'); if(!in_array($accessRight, array('admin', 'super'))){ $_SESSION['eereur'][] = 'Accès interdit'; HTTP::redirect(); } //traitement formulaire if (HTTP_Request::POST == $this->request->method()) { $formV = Validation::factory(array_merge($_POST, $_FILES)) ->rule('admin', 'not_empty') ->rule('login', 'not_empty') ->rule('nom', 'not_empty') ->rule('prenom', 'not_empty') ->rule('email', 'email') ->rule('email', 'not_empty'); $data = $formV->as_array(); $admin = ORM::factory('user', $data['admin']); $id = $this->request->param('id'); $user = ORM::factory('user', $id); $erreur = false; $password = $this->request->post('password'); $passwordconf = $this->request->post('passwordconf'); if($user->loaded()){ //modification if($password != '' || $passwordconf != ''){ //cangement de password demandé if($password != $passwordconf){ $_SESSION['erreur'][] = 'Le mot de passe et la confirmation sont différents'; $erreur = true; }else $user->password = $password; } }else{ //nouveau user if($password != '' || $passwordconf != ''){ //cangement de password demandé if($password != $passwordconf){ $_SESSION['erreur'][] = 'Le mot de passe et la confirmation sont différents'; $erreur = true; }else $user->password = $password; }else{ $_SESSION['erreur'][] = 'Le mot de passe et la confirmation sont oligatoires'; $erreur = true; } } if($formV->check() && $admin->loaded() && !$erreur){ $admin = ORM::factory('user', $data['admin']); if($admin->type != 'client'){ $user->parent_id = $admin->id; if($admin->type == 'super') $user->type = 'admin'; else $user->type = 'client'; } $user->login = $data['login']; $user->nom = $data['nom']; $user->prenom = $data['prenom']; $user->email = $data['email']; $user->commentaire = $data['commentaire']; $user->raisonsocial = $data['raisonsocial']; $user->adresse = $data['adresse']; $user->codepostal = $data['codepostal']; $user->ville = $data['ville']; $user->pays = $data['pays']; $user->telephone = $data['telephone']; $user->save(); HTTP::redirect(); }else{ //on affiche le formulaire $this->template->content = View::factory('user/modifier'); $this->template->content->admins = ORM::factory('user')->where('type', '!=', 'client')->find_all(); $this->template->content->admin_id = $user->parent_id; $this->template->content->id = $user->id; $this->template->content->login = $user->login; $this->template->content->nom = $user->nom; $this->template->content->prenom = $user->prenom; $this->template->content->email = $user->email; $this->template->content->commentaire = $user->commentaire; $this->template->content->raisonsocial = $user->raisonsocial; $this->template->content->adresse = $user->adresse; $this->template->content->codepostal = $user->codepostal; $this->template->content->ville = $user->ville; $this->template->content->pays = $user->pays; $this->template->content->telephone = $user->telephone; } if(count($_SESSION['erreur'])>0){ }else{ } } } }