Changeset 241

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

News update

Location:
trunk/app
Files:
6 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()  
  • trunk/app/views/elements/login.ctp

    r240 r241  
    11<div id="login">  
    2  
    3 <?php echo  $html->formTag('/users/login','post', array("onsubmit"=>"return validateLogin()")); ?> 
     2<?php echo  $form->create('User', array("action"=>"login", "onsubmit"=>"return validateLogin()")); ?> 
    43<fieldset> 
    54<legend> Login</legend> 
    65  <?php  
    7    echo  $form->labelTag( 'User/username', 'Username:' ) . "<br />";   
    8    echo  $html->input('User/username', array('id' => 'user_username', 'size' => '15', 'maxlength'=>'30')). '<br />'; 
    9    echo  $html->tagErrorMsg('User/username', 'Please enter your username') .'<br />';  
    10    echo  $form->labelTag( 'User/passwd', 'Password:' ) .'<br />'; 
    11    echo  $html->input('User/passwd', array('id' => 'user_passwd', 'size' => '9', 'type'=>'password')); 
    12    echo  $html->tagErrorMsg('User/passwd', 'Please enter your password!')  
     6   echo  $form->input('User.username', array('id' => 'user_username', 'size' => '15', 'maxlength'=>'30')). '<br />'; 
     7   echo  $form->input('User.passwd', array('id' => 'user_passwd', 'size' => '9', 'type'=>'password')); 
    138   ?><br /> 
    14   Remember me: <?php echo  $html->checkbox("User/cookie");?><br /> 
     9  Remember me: <?php echo  $form->checkbox("User.remember_me");?><br /> 
    1510  
    16  <?php echo $html->submit('Login'); ?> 
     11 <?php echo $form->end('Login'); ?> 
    1712</fieldset> 
    18 </form> 
    1913 
    2014 <p><?php echo $html->link('Join us!', '/users/register'); ?></p> 
  • trunk/app/views/elements/search.ctp

    r240 r241  
    2424</script> 
    2525<?php  
    26     echo $html->formTag('/entries/search/', 'post', array("onsubmit"=>"return chkSearch();")); 
    27     echo $html->input('Entry/terms', array("size" => 12, "value" => "Search...", "maxlength" => 40,  
     26    echo $form->create('Entry', array("action"=>"return chkSearch();")); 
     27    echo $form->input('Entry/terms', array("size" => 12, "value" => "Search...", "maxlength" => 40,  
    2828         "onblur" => "if(this.value=='') this.value='Search...';",  
    2929         "onfocus"=>"if(this.value=='Search...') this.value='';")); 
    30    echo $html->input('Send/button', array("src"=>"/img/search_go.gif", "type"=>"image", "value"=>"Search", "alt"=>"Search", "title"=>"Search")); 
     30   echo $form->end('Search'); 
    3131 ?> 
    32 </form> 
  • trunk/app/views/layouts/portal.ctp

    r240 r241  
    1 <?php echo '<?xml version="1.0"?>'; ?> 
    2 <?php echo $html->docType(); ?> 
     1<?php  
     2   echo '<?xml version="1.0"?>';  
     3   echo $html->docType();  
     4?> 
    35<html xmlns="http://www.w3.org/1999/xhtml"> 
    46<head> 
     
    911<?php 
    1012 if ( isset($javascript) ): 
    11     echo $html->charsetTag('UTF-8'); 
     13    echo $html->charset('UTF-8'); 
    1214    echo $javascript->link('prototype'); 
    1315    echo $javascript->link('myfunctions'); 
  • trunk/app/views/news/display.ctp

    r240 r241  
    44//die(var_dump($data)); 
    55 
    6 foreach ($data as $key => $val) 
     6foreach ($data as $val) 
    77{ 
    88  echo "<div class=\"wrapnew\">"; 
    9   echo "<div class=\"news_title\">". $val['News']['title']   . "</div>"; 
     9  echo "<div class=\"news_title\">". $html->link($val['News']['title'], '/news/view/'. $val['News']['id'])   . "</div>"; 
    1010  echo "<div class=\"news_date\">" . $val['News']['created'] . "</div>"; 
    1111  echo "<div class=\"news_body\">"; 
    1212   
    13   echo "Subject: ". $html->link($val['Subject']['title'], '/news/all/'.$val['Subject']['id'], null, false, false) . "<br /><br />"; 
     13  echo "Theme: ". $html->link($val['Theme']['theme'], '/news/theme/'.$val['Theme']['id'], null, false, false) . "<br /><br />"; 
    1414   
    1515  echo  $val['News']['body']    . "</div>"; 
  • trunk/app/webroot/css/portal/portal.css

    r233 r241  
    333333 }  
    334334 
     335.news_title{margin-top:15px;} 
     336 
     337.news_title a {font-size:14pt;font-weight:bold;color:orange;text-decoration:none;} 
     338 
    335339.news_theme {  
    336340         color:gray;