Changeset 336

Show
Ignore:
Timestamp:
03/24/08 14:42:08 (10 months ago)
Author:
aarkerio
Message:

Move recover from users

Location:
trunk/app
Files:
3 added
1 removed
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/app_controller.php

    r335 r336  
    77 
    88class AppController extends Controller { 
    9  
     9  
    1010 public $components = array('Auth', 'Cookie', 'Security'); 
    11  
    12  public $helpers = array('Html', 'Form', 'Session'); 
    13  
     11  
     12 public $helpers    = array('Html', 'Form', 'Session'); 
     13  
     14 //deprecated public $allow      = array('view', 'display', 'subscribe', 'recover', 'reply', 'register', 'insert', 'vote', 'entry', 'download', 'blog','portfolio', 'about', 'signup', 'message', 'search', 'directory', 'bloggers', 'add', 'rss', 'discussion');  
     15  
    1416 public function beforeFilter() 
    1517 { 
     
    2022     $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; 
    2123     $this->Auth->authorize = 'controller';   
    22      $this->Auth->allow( array('view', 'display', 'subscribe', 'recover', 'reply', 'register', 'insert', 'vote', 'entry', 'download', 'blog','portfolio', 'about', 'signup', 'message', 'search', 'directory', 'bloggers', 'add', 'rss', 'discussion') ); 
     24     $this->Auth->deny('*'); 
    2325     $this->Auth->autoRedirect = true; 
    2426     $this->set('cU', $this->Auth->user());  // $cU current user array to use in the views if user logged 
  • trunk/app/controllers/lessons_controller.php

    r302 r336  
    1010class LessonsController extends AppController 
    1111{ 
    12   public $helpers       = array('Ajax', 'User', 'Fck', 'Gags'); 
    13      
    14   public $components    = array('Edublog'); 
    15  
     12 public $helpers       = array('Ajax', 'User', 'Fck', 'Gags'); 
     13  
     14 public $components    = array('Edublog'); 
     15  
     16 public function beforeFilter()  
     17 { 
     18    $this->Auth->allow(array('view', 'display')); 
     19    parent::beforeFilter(); 
     20 } 
     21  
    1622 public function isAuthorized()  
    1723 {       
     
    2531    return false;  // go away !! 
    2632 } 
    27  
     33  
    2834 public function view($username, $id) 
    29  {    
     35 {       
    3036        $user_id           = $this->Lesson->User->field('id', array('User.username'=>$username)); 
    31   
     37         
    3238        $this->layout      = $this->Edublog->layout($user_id); 
    33  
     39         
    3440        $this->Edublog->blog($user_id); // blogger elements 
    35  
     41         
    3642        $this->LessonTitle = 'Lesson'; 
    3743         
  • trunk/app/controllers/news_controller.php

    r311 r336  
    1414   
    1515  public $components       = array('Portal'); 
    16  
    17   public function isAuthorized() 
    18   { 
     16   
     17  public function beforeFilter()  
     18 { 
     19    $this->Auth->allow(array('view', 'display', 'rss')); 
     20    parent::beforeFilter(); 
     21 } 
     22  
     23 public function isAuthorized() 
     24 { 
    1925      if (isset($this->params[Configure::read('Routing.admin')])) 
    2026      { 
     
    2531      } 
    2632      return false; // go away!! 
    27   } 
    28                                                                  
    29   public function display($page=1)  
    30   {      
     33 } 
     34  
     35 public function display($page=1)  
     36 {      
    3137        $this->layout = 'portal'; 
    3238         
    3339        $this->pageTitle = 'Karamelo::Home'; 
    34  
     40         
    3541        $conditions = array("News.status"=>1); 
    36  
     42         
    3743        $fields     = array("News.id", "News.title", "News.comments", "News.body", "News.created", "News.reference", "News.theme_id", "News.user_id", "Theme.img", "Theme.theme", "User.username", "Subject.title", "Subject.id"); 
    3844         
  • trunk/app/controllers/users_controller.php

    r335 r336  
    1212{ 
    1313 public $helpers        = array('Ajax', 'Fck', 'Gags'); 
    14      
     14  
    1515 public $components     = array('Edublog', 'Portal', 'Email', 'Adds'); 
    16  
     16  
    1717 public $paginate       = array('limit' => 5, 'order' => array('Page.created' => 'desc')); 
    18  
     18  
     19 public function beforeFilter()  
     20 { 
     21    $this->Auth->allow(array('blog', 'entry','portfolio', 'about', 'check', 'register', 'directory', 'bloggers')); 
     22    parent::beforeFilter(); 
     23 } 
     24  
    1925 public function isAuthorized()  
    2026 {       
     
    2834    return false;  // go away !! 
    2935 } 
    30  
     36  
    3137 public function blog($username = null, $page=1)  
    3238 { 
     
    4551         
    4652     $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   
     53      
    4854     $conditions = array("Entry.user_id"=>$user_id, "Entry.status"=>1); 
    49  
     55      
    5056     $limit      = 20; 
    5157         
     
    5561         
    5662     $this->Edublog->blog($user_id); 
    57     } 
    58      
    59     public function entry($username = null, $entry_id = null)  
    60     { 
    61         if ($entry_id == null) 
    62         { 
     63 } 
     64  
     65 public function entry($username, $entry_id)  
     66 { 
     67     if ($entry_id == null) 
     68     { 
    6369           $this->redirect('/blog/'.$username); 
    6470           exit; 
    65         } 
    66          
    67         $this->pageTitle = $username . '\'s Blog'; 
    68          
    69         $user_id = $this->User->field("id", array("username"=>$username)); 
    70          
    71         if ($username == null || $user_id == null) 
    72         { 
     71     } 
     72      
     73     $this->pageTitle = $username . '\'s Blog'; 
     74      
     75     $user_id = $this->User->field("id", array("username"=>$username)); 
     76      
     77     if ($username == null || $user_id == null) 
     78     { 
    7379           $this->redirect("/"); 
    74         } 
    75          
    76         $this->Entry     = new Entry; 
    77          
    78         $order    = "Entry.id DESC"; 
    79          
    80         $fields   = array("Entry.title", "Entry.body", "Entry.created", "Entry.user_id", "Entry.discution", "Entry.subject_id", "Entry.id", "User.username", "Subject.title", "Subject.id"); 
    81          
     80     } 
     81      
     82     $this->Entry     = new Entry; 
     83      
     84     $order    = "Entry.id DESC"; 
     85      
     86     $fields   = array("Entry.title", "Entry.body", "Entry.created", "Entry.user_id", "Entry.discution", "Entry.subject_id", "Entry.id", "User.username", "Subject.title", "Subject.id"); 
     87      
    8288        if ( $entry_id != null && is_numeric( $entry_id ) ) // show only one new 
    8389        { 
     
    9197        $this->Edublog->blog($user_id); // blogger elements 
    9298 } 
    93     
     99  
    94100 public function portfolio($username)  
    95101 { 
     
    122128 } 
    123129 
    124  /*** Recover password check****/ 
    125  public function check() 
    126  {     
    127         $this->Sanitize = new Sanitize; 
    128          
    129         $this->Sanitize->clean($this->data["User"]); 
    130          
    131         if ( ! empty( $this->data["User"] ) ) 
    132         { 
    133            $user_id = $this->User->field('id', array("email" => $this->data["User"]["email"] )); 
    134             
    135            if ($user_id == null) 
    136            { 
    137                    $this->set('error_message', "Error: email <b>" . $this->data["User"]["email"] . "</b> does not exist on database"); 
    138                    $this->render('check', 'ajax'); 
    139            } 
    140            else 
    141            {    
    142                $this->Recover = new Recover;                                                    //confirm model 
    143  
    144                $this->data['Recover']['user_id']  = $user_id;   //the user id 
    145  
    146                $this->data['Recover']['random']   = $this->Adds->genPassword(14); 
    147                 
    148                $this->Recover->create(); 
    149                 
    150                if ( $this->Recover->save($this->data['Recover']) ) 
    151                { 
    152                    if ( $this->sendRecover($this->data["User"]['email'], $this->data['Recover']['random']) )  
    153                    { 
    154                        $this->set('message', "Success. An email has been sent to: <b>".$this->data["User"]["email"]) . "</b>"; 
    155                         
    156                        $this->render('check', 'ajax'); 
    157                    } 
    158                } 
    159            } 
    160         } 
    161    } 
    162         
    163130  public function alumni() 
    164131  { 
     
    183150        $this->layout    = 'portal'; 
    184151         
     152        $this->pageTitle = 'Parents :: Karamelo E-learning on Web 2.0'; 
     153         
     154        $this->Portal->statics(); // Using Portal component 
     155 } 
     156  
     157 public function academics() 
     158 { 
     159        $this->layout    = 'portal'; 
     160         
    185161        $this->pageTitle = 'Students :: Karamelo E-learning on Web 2.0'; 
    186162         
    187         $this->Cover = new Cover; 
    188          
    189         $conditions  = array("Cover.status"=>1, "Cover.group_id"=>4); 
    190         $fields      = array("id", "title", "body", "created"); 
    191         $order       = "Cover.id DESC"; 
    192         $limit       = 1; 
    193          
    194         $this->set('cover', $this->Cover->findAll($conditions, $fields, $order, $limit)); 
    195  
    196163        $this->Portal->statics(); // Using Portal component 
    197     } 
    198  
    199     public function academics() 
    200     { 
    201         $this->layout    = 'portal'; 
    202          
    203         $this->pageTitle = 'Students :: Karamelo E-learning on Web 2.0'; 
    204          
    205         $this->Cover = new Cover; 
    206          
    207         $conditions  = array("Cover.status"=>1, "Cover.group_id"=>2); 
    208         $fields      = array("id", "title", "body", "created"); 
    209         $order       = "Cover.id DESC"; 
    210         $limit       = 1; 
    211          
    212         $this->set('cover', $this->Cover->findAll($conditions, $fields, $order, $limit)); 
    213          
    214         $this->set('Element', $this->Portal->statics()); // Using Portal component 
    215164  } 
    216165   
     
    246195        $this->layout    = 'portal'; 
    247196 } 
    248      
    249  public function recover() 
    250  { 
    251         $this->pageTitle = 'Recover password :: Karamelo E-learning on Web 2.0'; 
    252          
    253         $this->Portal->statics(); // Using Portal component  
    254  
    255         $this->layout    = 'portal'; 
    256  } 
    257      
     197  
    258198 public function bloggers($order = 'username', $desc = 'DESC') 
    259199 {    
     
    295235    { 
    296236          $this->Portal->statics(); // Using Portal component 
    297  
     237           
    298238          $this->layout    = 'portal'; 
    299         
     239           
    300240          $this->pageTitle = 'Login :: Karamelo E-learning'; 
    301241    } 
    302242 } 
    303  
     243  
    304244 public function logout()  
    305245 { 
     
    307247    
    308248   $this->Session->setFlash('Logout'); 
    309  
     249    
    310250   $this->redirect($this->Auth->logout()); 
    311251 } 
    312  
     252  
    313253 public function register() 
    314254 { 
     
    325265 {    
    326266  $this->layout = 'ajax'; 
    327  
     267   
    328268  $this->Sanitize = new Sanitize; 
    329      
     269   
    330270  $this->Sanitize->html($this->data["User"]["name"]); 
    331  
     271   
    332272  $this->Sanitize->html($this->data["User"]["username"]); 
    333273   
    334274  $this->Sanitize->html($this->data["User"]["description"]); 
    335  
     275   
    336276  $this->Sanitize->html($this->data["User"]["email"]); 
    337  
     277   
    338278  // adds new classroom to database 
    339279  if (!empty($this->data['User'])) 
    340280  { 
    341281   $message     = array("oops"=>"Oooppps!"); 
    342      
     282    
    343283   /** Check Passwd **/ 
    344284   if (strlen($this->data['User']['pwd']) < 6) 
  • trunk/app/views/elements/login.ctp

    r246 r336  
    1515 <?php  
    1616   echo $html->para(null, $html->link('Join us!', '/users/register'));  
    17    echo $html->para(null, $html->link('forgot your password?', '/users/recover'));  
     17   echo $html->para(null, $html->link('forgot your password?', '/recovers/recover'));  
    1818 ?> 
    1919 </div> 
  • trunk/app/views/elements/login_hide.ctp

    r276 r336  
    3030       echo $form->end('Login'); 
    3131       echo $html->para(null, $html->link('Join us!', '/users/register')); 
    32        echo $html->para(null, $html->link('forgot your password?', '/users/recover'));  
     32       echo $html->para(null, $html->link('forgot your password?', '/recovers/recover'));  
    3333 ?> 
    3434</div> 
  • trunk/app/views/users/recover.ctp

    r242 r336  
    66<div class="spaced" id="form_register"> 
    77 
    8 <?php echo $html->formTag(null, 'post', array('onsubmit'=>'return false')); ?> 
     8<?php echo $ajax->form(); ?> 
    99 
    1010<fieldset> 
     
    1313    <p>Type the email used on your account:</p> 
    1414      
    15      <?php echo $html->input('User/email', array("size" => 20, "maxlength" => 45, "value"=>"@")); ?> 
     15     <?php echo $form->input('User.email', array("size" => 50, "maxlength" => 50, "value"=>"@")); ?> 
    1616     <br /><br /> 
    1717      
    18      <?php echo $ajax->submit('Send', array("url" => "/users/check/",  
     18     <?php echo $ajax->submit('Send', array("url" => "/recovers/check/",  
    1919                                         "update"=>"updater", 
    2020                                         "loading" => "Element.show('charging2');Element.hide('updater')",