Blame view

modules/admin/controller/authController.php 1.26 KB
8d65d0ce   andryeyev   init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  <?php
  
  Class Admin_AuthController Extends baseController {
  
  public function preDispatch($action){
   IF($action != "index"){
    $auth = new Auth();
    if($auth->is_login_session() == false)Redirect($this->url.'/admin/auth/');
   }
  }
  
  public function index() 
  {
    $this->loadBlock = false;
    if(isset($this->postParam['login'],$this->postParam['psw'])){
     $auth = new Auth();
     $res = $auth->login($this->postParam['login'],$this->postParam['psw']);
     if($res == true)Redirect($this->url.'/admin/');
     else $this->error[] = "Íåâåðíûé ëîãèí!";
    }
  }
  
  public function users(){
     $auth = new Auth();
     $this->tpl->assign('users', $auth->getUsers());
  }
  
  public function save($id = 0){
    $auth = new Auth();
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
       $this->error = $auth->valid($this->postParam,$id);
       if(!$this->error){
        $auth->save($this->postParam);
        Redirect($this->url.'/admin/auth/users/');
       }
    }
    if($id != null){
     $row = $auth->view($id);
     $this->tpl->assign('user', $row);
    }
  }
  
  public function _exit(){
     $auth = new Auth();
     $auth->_exit();
     Redirect($this->url.'/admin/auth/');
  }
  
  public function delete($id = null){
    if($id != null){
     $auth = new Auth();
     $auth->delete($id);
     Redirect($this->url.'/admin/auth/users/');
    }
  }
  
  
  }
  ?>