Changeset 336
- Timestamp:
- 03/24/08 14:42:08 (10 months ago)
- Location:
- trunk/app
- Files:
-
- 3 added
- 1 removed
- 7 modified
-
app_controller.php (modified) (2 diffs)
-
controllers/lessons_controller.php (modified) (2 diffs)
-
controllers/news_controller.php (modified) (2 diffs)
-
controllers/recovers_controller.php (added)
-
controllers/users_controller.php (modified) (11 diffs)
-
models/recover.php (added)
-
views/elements/login.ctp (modified) (1 diff)
-
views/elements/login_hide.ctp (modified) (1 diff)
-
views/recovers (added)
-
views/users/index.ctp (deleted)
-
views/users/recover.ctp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/app_controller.php
r335 r336 7 7 8 8 class AppController extends Controller { 9 9 10 10 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 14 16 public function beforeFilter() 15 17 { … … 20 22 $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; 21 23 $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('*'); 23 25 $this->Auth->autoRedirect = true; 24 26 $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 10 10 class LessonsController extends AppController 11 11 { 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 16 22 public function isAuthorized() 17 23 { … … 25 31 return false; // go away !! 26 32 } 27 33 28 34 public function view($username, $id) 29 { 35 { 30 36 $user_id = $this->Lesson->User->field('id', array('User.username'=>$username)); 31 37 32 38 $this->layout = $this->Edublog->layout($user_id); 33 39 34 40 $this->Edublog->blog($user_id); // blogger elements 35 41 36 42 $this->LessonTitle = 'Lesson'; 37 43 -
trunk/app/controllers/news_controller.php
r311 r336 14 14 15 15 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 { 19 25 if (isset($this->params[Configure::read('Routing.admin')])) 20 26 { … … 25 31 } 26 32 return false; // go away!! 27 }28 29 public function display($page=1)30 {33 } 34 35 public function display($page=1) 36 { 31 37 $this->layout = 'portal'; 32 38 33 39 $this->pageTitle = 'Karamelo::Home'; 34 40 35 41 $conditions = array("News.status"=>1); 36 42 37 43 $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"); 38 44 -
trunk/app/controllers/users_controller.php
r335 r336 12 12 { 13 13 public $helpers = array('Ajax', 'Fck', 'Gags'); 14 14 15 15 public $components = array('Edublog', 'Portal', 'Email', 'Adds'); 16 16 17 17 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 19 25 public function isAuthorized() 20 26 { … … 28 34 return false; // go away !! 29 35 } 30 36 31 37 public function blog($username = null, $page=1) 32 38 { … … 45 51 46 52 $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 48 54 $conditions = array("Entry.user_id"=>$user_id, "Entry.status"=>1); 49 55 50 56 $limit = 20; 51 57 … … 55 61 56 62 $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 { 63 69 $this->redirect('/blog/'.$username); 64 70 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 { 73 79 $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 82 88 if ( $entry_id != null && is_numeric( $entry_id ) ) // show only one new 83 89 { … … 91 97 $this->Edublog->blog($user_id); // blogger elements 92 98 } 93 99 94 100 public function portfolio($username) 95 101 { … … 122 128 } 123 129 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 else141 {142 $this->Recover = new Recover; //confirm model143 144 $this->data['Recover']['user_id'] = $user_id; //the user id145 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 163 130 public function alumni() 164 131 { … … 183 150 $this->layout = 'portal'; 184 151 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 185 161 $this->pageTitle = 'Students :: Karamelo E-learning on Web 2.0'; 186 162 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 196 163 $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 component215 164 } 216 165 … … 246 195 $this->layout = 'portal'; 247 196 } 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 258 198 public function bloggers($order = 'username', $desc = 'DESC') 259 199 { … … 295 235 { 296 236 $this->Portal->statics(); // Using Portal component 297 237 298 238 $this->layout = 'portal'; 299 239 300 240 $this->pageTitle = 'Login :: Karamelo E-learning'; 301 241 } 302 242 } 303 243 304 244 public function logout() 305 245 { … … 307 247 308 248 $this->Session->setFlash('Logout'); 309 249 310 250 $this->redirect($this->Auth->logout()); 311 251 } 312 252 313 253 public function register() 314 254 { … … 325 265 { 326 266 $this->layout = 'ajax'; 327 267 328 268 $this->Sanitize = new Sanitize; 329 269 330 270 $this->Sanitize->html($this->data["User"]["name"]); 331 271 332 272 $this->Sanitize->html($this->data["User"]["username"]); 333 273 334 274 $this->Sanitize->html($this->data["User"]["description"]); 335 275 336 276 $this->Sanitize->html($this->data["User"]["email"]); 337 277 338 278 // adds new classroom to database 339 279 if (!empty($this->data['User'])) 340 280 { 341 281 $message = array("oops"=>"Oooppps!"); 342 282 343 283 /** Check Passwd **/ 344 284 if (strlen($this->data['User']['pwd']) < 6) -
trunk/app/views/elements/login.ctp
r246 r336 15 15 <?php 16 16 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')); 18 18 ?> 19 19 </div> -
trunk/app/views/elements/login_hide.ctp
r276 r336 30 30 echo $form->end('Login'); 31 31 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')); 33 33 ?> 34 34 </div> -
trunk/app/views/users/recover.ctp
r242 r336 6 6 <div class="spaced" id="form_register"> 7 7 8 <?php echo $ html->formTag(null, 'post', array('onsubmit'=>'return false')); ?>8 <?php echo $ajax->form(); ?> 9 9 10 10 <fieldset> … … 13 13 <p>Type the email used on your account:</p> 14 14 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"=>"@")); ?> 16 16 <br /><br /> 17 17 18 <?php echo $ajax->submit('Send', array("url" => "/ users/check/",18 <?php echo $ajax->submit('Send', array("url" => "/recovers/check/", 19 19 "update"=>"updater", 20 20 "loading" => "Element.show('charging2');Element.hide('updater')",
