Show
Ignore:
Timestamp:
02/19/08 17:24:43 (9 months ago)
Author:
aarkerio
Message:

News update

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/users_controller.php

    r234 r241  
    88 
    99uses('sanitize'); 
    10 loadModel('Entry'); 
    11 loadModel('Podcast'); 
    12 loadModel('Catfaq'); 
    13 loadModel('Recover'); 
    1410 
    1511class UsersController extends AppController 
    1612{ 
    17     public $helpers          = array('Ajax', 'Form', 'User', 'Fck', 'Gags'); 
    18      
    19     public $components       = array('Security', 'Edublog', 'Portal', 'Email', 'Adds', 'Mypagination'); 
    20      
    21     public function index($id = null) 
    22     {    
    23         $this->pageTitle = 'View Active Users'; 
    24         $this->set('data', $this->User->findAll());  
    25         $this->set('color', 'blue'); 
    26     } 
    27      
    28     public function blog($username = null, $page=1)  
    29     { 
    30         $this->layout    = 'blog'; 
    31          
    32         $this->pageTitle = $username . '\'s Blog'; 
    33          
    34         $this->Entry     = new Entry; 
    35          
    36         $user_id = $this->User->field("id", array("username"=>$username)); 
    37          
    38         if ($username == null || $user_id == null) 
    39         { 
     13  public $helpers          = array('Ajax', 'Fck', 'Gags'); 
     14     
     15  //public $components       = array('Security', 'Edublog', 'Portal', 'Email', 'Adds'); 
     16 
     17  public function isAuthorized()  
     18  { 
     19           if (isset($this->params[Configure::read('Routing.admin')]))  
     20           { 
     21                  if ($this->Auth->user('role') == 'admin')  
     22                  { 
     23                      return false; 
     24                  } 
     25           } 
     26       return true; 
     27  } 
     28 
     29  public function blog($username = null, $page=1)  
     30  { 
     31     if ($username == null || $user_id == null) 
     32     { 
    4033           $this->redirect("/"); 
    41         } 
    42          
    43         $order    = "Entry.id DESC"; 
    44          
    45         $fields   = array("Entry.title", "Entry.body", "Entry.created", "Entry.user_id", "Entry.discution", "Entry.subject_id", "Entry.id", "User.username", "Subject.title", "Subject.id"); 
    46          
    47         //pagination 
    48         $total_rows = $this->Entry->findCount(array("Entry.user_id"=>$user_id, "Entry.status"=>1));  
    49          
    50         $lmt        = 10; // limit news 
    51          
    52         $targetpage = "/blog/".$username."/"; 
    53          
    54         $pagination = $this->Mypagination->init($total_rows, $page, $lmt, $targetpage); //Pagination 
    55          
    56         $this->set('pagination', $pagination); 
    57          
    58         $offset     = (($page * $lmt) - 10); 
    59          
    60         $limit      = $lmt . " OFFSET " . $offset; 
    61          
    62         $conditions = array("Entry.user_id"=>$user_id, "Entry.status"=>1); 
    63          
    64         $this->set('data', $this->Entry->findAll($conditions, $fields, $order, $limit));  
    65          
    66         $this->layout    = $this->Edublog->layout($user_id); 
    67          
    68         $this->Edublog->blog($user_id); 
     34     } 
     35      
     36     $this->layout    = 'blog'; 
     37         
     38     $this->pageTitle = $username . '\'s Blog'; 
     39         
     40     $this->Entry     = new Entry; 
     41         
     42     $user_id = $this->User->field("id", array("username"=>$username)); 
     43         
     44     $order    = "Entry.id DESC"; 
     45         
     46     $fields   = array("Entry.title", "Entry.body", "Entry.created", "Entry.user_id", "Entry.discution", "Entry.subject_id", "Entry.id", "User.username", "Subject.title", "Subject.id"); 
     47  
     48         
     49     $conditions = array("Entry.user_id"=>$user_id, "Entry.status"=>1); 
     50         
     51     $this->set('data', $this->Entry->findAll($conditions, $fields, $order, $limit));  
     52         
     53     $this->layout    = $this->Edublog->layout($user_id); 
     54         
     55     //$this->Edublog->blog($user_id); 
    6956    } 
    7057     
     
    271258        $limit      = null;         
    272259        $this->set('users', $this->User->findAll($conditions, $fields, $order, $limit, null, 2)); 
    273     } 
    274      
    275     public function karanet() 
    276     { 
     260  } 
     261     
     262  public function karanet() 
     263  { 
    277264        $this->pageTitle = 'Directory :: Karamelo E-learning on Web 2.0'; 
    278265         
     
    280267         
    281268        $this->layout    = 'portal'; 
    282     } 
    283      
    284     public function recover() 
    285     { 
     269 } 
     270     
     271 public function recover() 
     272 { 
    286273        $this->pageTitle = 'Recover password :: Karamelo E-learning on Web 2.0'; 
    287274         
     
    289276         
    290277        $this->layout    = 'portal'; 
    291     } 
    292      
    293     public function bloggers($order = 'username', $desc = 'DESC') 
    294     {    
     278 } 
     279     
     280 public function bloggers($order = 'username', $desc = 'DESC') 
     281 {    
    295282        $this->layout    = 'portal'; 
    296283         
     
    303290         
    304291        $this->set('Element', $this->Portal->statics()); // Using Portal component 
    305     } 
    306     public function login() 
    307     {  
    308        $this->layout    = 'portal'; 
     292 } 
     293       
     294 public function login() 
     295 { 
     296    $this->layout    = 'portal'; 
    309297        
    310        $this->pageTitle = 'Login :: Karamelo E-learning'; 
     298    $this->pageTitle = 'Login :: Karamelo E-learning'; 
    311299        
    312        $this->set('Element', $this->Portal->statics()); // Using Portal component 
    313         
    314        if (isset($this->data)) 
    315        {   
    316           $auth_num = $this->othAuth->login($this->data['User']); 
    317            
    318           $this->set('auth_msg', $this->othAuth->getMsg($auth_num)); 
    319        } 
    320        $this->set('auth_msg', 'Welcome!'); 
    321     } 
    322      
    323     public function logout() 
    324     {   
    325        $this->othAuth->logout(); 
    326         
    327        $this->redirect('/news/view'); 
    328     } 
    329      
    330    public function noaccess() 
    331    { 
    332       $this->flash("You don't have permissions to access this page.",'/users/login'); 
    333    } 
    334     
    335    public function register() 
    336    { 
     300    //$this->set('Element', $this->Portal->statics()); // Using Portal component 
     301     
     302    if ($this->Auth->user())  
     303    { 
     304            if (!empty($this->data))  
     305            { 
     306                if (empty($this->data['User']['remember_me']))  
     307                { 
     308                    $this->Cookie->del('User'); 
     309                } 
     310                else  
     311                { 
     312                    $cookie = array(); 
     313                    $cookie['email'] = $this->data['User']['email']; 
     314                    $cookie['token'] = $this->data['User']['pasword']; 
     315                    $this->Cookie->write('User', $cookie, true, '+2 weeks'); 
     316                } 
     317                unset($this->data['User']['remember_me']); 
     318            } 
     319 
     320            $this->redirect($this->Auth->redirect()); 
     321    } 
     322 } 
     323 
     324 public function logout()  
     325 { 
     326     $this->Session->setFlash("You've successfully logged out."); 
     327     $this->redirect($this->Auth->logout()); 
     328 } 
     329 
     330 public function register() 
     331 { 
    337332    $this->layout    = 'portal'; 
    338333     
     
    342337    $this->set('Element', $this->Portal->statics()); // Using Portal component 
    343338     
    344    } 
     339 } 
    345340    
    346341 public function insert()