Changeset 339
- Timestamp:
- 03/24/08 17:06:55 (10 months ago)
- Location:
- trunk/app
- Files:
-
- 3 added
- 25 modified
-
app_controller.php (modified) (1 diff)
-
app_model.php (modified) (1 diff)
-
config/core.php (modified) (2 diffs)
-
config/sql/karamelo_postgres.sql (modified) (1 diff)
-
controllers/acquaintances_controller.php (modified) (1 diff)
-
controllers/answers_controller.php (modified) (1 diff)
-
controllers/catfaqs_controller.php (modified) (3 diffs)
-
controllers/catglossaries_controller.php (modified) (1 diff)
-
controllers/colleges_controller.php (modified) (2 diffs)
-
controllers/comments_controller.php (modified) (2 diffs)
-
controllers/confirms_controller.php (modified) (2 diffs)
-
controllers/entries_controller.php (modified) (2 diffs)
-
controllers/forums_controller.php (modified) (2 diffs)
-
controllers/recovers_controller.php (modified) (5 diffs)
-
controllers/topics_controller.php (modified) (2 diffs)
-
controllers/users_controller.php (modified) (5 diffs)
-
controllers/webquests_controller.php (modified) (2 diffs)
-
models/user.php (modified) (1 diff)
-
views/elements/email/text/confirmation.ctp (modified) (1 diff)
-
views/elements/email/text/recover.ctp (added)
-
views/elements/email/text/simple_message.ctp (added)
-
views/elements/login.ctp (modified) (1 diff)
-
views/elements/login_hide.ctp (modified) (1 diff)
-
views/layouts/email/html/default.ctp (modified) (1 diff)
-
views/layouts/email/text/default.ctp (modified) (1 diff)
-
views/recovers/newpwd.ctp (added)
-
views/users/login.ctp (modified) (2 diffs)
-
views/users/register.ctp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/app_controller.php
r336 r339 16 16 public function beforeFilter() 17 17 { 18 $this->Auth->fields = array('username' => ' username', 'password' => 'pwd');18 $this->Auth->fields = array('username' => 'email', 'password' => 'pwd'); 19 19 $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); 20 20 $this->Auth->loginRedirect = array('controller' => 'news', 'action' => 'display'); -
trunk/app/app_model.php
r1 r339 1 1 <?php 2 2 class AppModel extends Model{ 3 4 public function expects() 5 { 6 $models = array(); 7 8 $arguments = func_get_args(); 9 10 foreach($arguments as $index => $argument) 11 { 12 if (is_array($argument)) 13 { 14 if (count($argument) > 0) 15 { 16 $arguments = array_merge($arguments, $argument); 17 } 18 19 unset($arguments[$index]); 3 4 public $assocs = array( 5 'Book' => array( 6 'type' => 'belongsTo', 7 'className' => 'Book', 8 'foreignKey' => 'collection_id', 9 ), 10 'Story' => array( 11 'type' => 'hasOne', 12 'className' => 'Story', 13 ), 14 'Album' => array( 15 'type' => 'belongsTo', 16 'className' => 'Album', 17 'foreignKey' => 'collection_id', 18 ), 19 'Photo' => array( 20 'type' => 'hasOne', 21 'className' => 'Photo', 22 ), 23 'Post' => array( 24 'type' => 'hasMany', 25 'className' => 'Post', 26 'order' => 'Post.id DESC', 27 ), 28 ); 29 30 public function expects($array) 31 { 32 foreach ($array as $assoc) 33 { 34 $this->bindModel 35 ( 36 array($this->assocs[$assoc]['type'] => 37 array($assoc => $this->assocs[$assoc]))); 20 38 } 21 } 22 23 if (count($arguments) == 0) 24 { 25 $models[$this->name] = array(); 26 } 27 else 28 { 29 foreach($arguments as $argument) 30 { 31 if (strpos($argument, '.') !== false) 32 { 33 $model = substr($argument, 0, strpos($argument, '.')); 34 $child = substr($argument, strpos($argument, '.') + 1); 35 36 if ($child == $model) 37 { 38 $models[$model] = array(); 39 } 40 else 41 { 42 $models[$model][] = $child; 43 } 44 } 45 else 46 { 47 $models[$this->name][] = $argument; 48 } 49 } 50 } 51 52 foreach($models as $model => $children) 53 { 54 if ($model != $this->name && isset($this->$model)) 55 { 56 $this->$model->expects($children); 57 } 58 } 59 60 if (isset($models[$this->name])) 61 { 62 foreach($models as $model => $children) 63 { 64 if ($model != $this->name) 65 { 66 $models[$this->name][] = $model; 67 } 68 } 69 70 $models = array_unique($models[$this->name]); 71 72 $unbind = array(); 73 74 $relations = array ('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); 75 76 foreach($relations as $relation) 77 { 78 if (isset($this->$relation)) 79 { 80 foreach($this->$relation as $currentModel) 81 { 82 if (!in_array($currentModel['className'], $models)) 83 { 84 $unbind[$relation][] = $currentModel['className']; 85 } 86 } 87 } 88 } 89 90 if (count($unbind) > 0) 91 { 92 $this->unbindModel($unbind); 93 } 94 } 95 } 96 97 98 public function unbindAll($params = array()) 99 { 100 foreach($this->__associations as $ass) 101 { 102 if(!empty($this->{$ass})) 103 { 104 $this->__backAssociation[$ass] = $this->{$ass}; 105 if(isset($params[$ass])) 106 { 107 foreach($this->{$ass} as $model => $detail) 108 { 109 if(!in_array($model,$params[$ass])) 110 { 111 $this->__backAssociation = array_merge($this->__backAssociation, $this->{$ass}); 112 unset($this->{$ass}[$model]); 113 } 114 } 115 } 116 else 117 { 118 $this->__backAssociation = array_merge($this->__backAssociation, $this->{$ass}); 119 $this->{$ass} = array(); 120 } 121 122 } 123 } 124 return true; 125 } 39 } 126 40 } 127 41 ?> -
trunk/app/config/core.php
r333 r339 98 98 * Actual value depends on 'Security.level' setting. 99 99 */ 100 Configure::write('Session.timeout', ' 220');100 Configure::write('Session.timeout', '120'); 101 101 /** 102 102 * If set to false, sessions are not automatically started. … … 120 120 * 'Security.level' is set to 'high'. 121 121 */ 122 Configure::write('Security.level', ' medium');122 Configure::write('Security.level', 'high'); 123 123 /** 124 124 * A random string used in security hashing methods. 125 125 */ 126 Configure::write('Security.salt', 'DYhG93b0qyJfIxfs vgTR5UubWwvniR2G0FgaC9mi');126 Configure::write('Security.salt', 'DYhG93b0qyJfIxfs66vgTR5UubWwvniR2G0FgaC9mi'); 127 127 /** 128 128 * Compress CSS output by removing comments, whitespace, repeating tags, etc. -
trunk/app/config/sql/karamelo_postgres.sql
r333 r339 531 531 ); 532 532 533 -- this is a table to keep temp ral data, is used to recover the user passwords533 -- this is a table to keep temporal data, is used to recover the user password -- see recovers_controller.php file 534 534 CREATE TABLE "recovers" ( 535 535 "id" serial PRIMARY KEY, 536 "user_id" int REFERENCES users (id) ON DELETE CASCADE, 537 "email" varchar(50), 538 "random_string" varchar(150), -- the confirmation string sended to email user to reset his password 536 "user_id" int REFERENCES users(id) ON DELETE CASCADE, 537 "random" varchar(150) NOT NULL UNIQUE, -- the confirmation string sended to email user to reset his password 539 538 "created" timestamp(0) with time zone DEFAULT now() NOT NULL 540 539 ); 540 541 541 --- This models (Test, Webquest ans Treasure) belongsTO to vclassrooms 542 542 -- Webquest -
trunk/app/controllers/acquaintances_controller.php
r322 r339 12 12 13 13 public $components = array('Edublog'); 14 15 public function beforeFilter() 16 { 17 $this->Auth->allow(array('display')); 18 parent::beforeFilter(); 19 } 14 20 15 21 public function isAuthorized() -
trunk/app/controllers/answers_controller.php
r328 r339 11 11 class AnswersController extends AppController 12 12 { 13 public $helpers = array('Ajax');14 13 public $helpers = array('Ajax'); 14 15 15 public function isAuthorized() 16 16 { -
trunk/app/controllers/catfaqs_controller.php
r305 r339 10 10 class CatfaqsController extends AppController 11 11 { 12 public $helpers = array('Ajax', 'User', 'Gags'); 13 14 public $components = array('Edublog'); 15 12 public $helpers = array('Ajax', 'User', 'Gags'); 13 14 public $components = array('Edublog'); 15 16 public function beforeFilter() 17 { 18 $this->Auth->allow(array('display', 'view')); 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($catfaq_id, $user_id) 29 35 { 30 36 $this->pageTitle = 'FAQ'; 31 37 32 38 $this->layout = $this->Edublog->layout($user_id); 33 39 … … 35 41 36 42 $conditions = array("Catfaq.id"=>$catfaq_id, "Catfaq.status"=>1); 37 43 38 44 $fields = array("id", "title", "body", "categories_id"); 39 45 -
trunk/app/controllers/catglossaries_controller.php
r317 r339 14 14 public $components = array('Edublog'); 15 15 16 public function isAuthorized()16 public function beforeFilter() 17 17 { 18 if (isset($this->params[Configure::read('Routing.admin')])) 19 { 20 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2) 21 { 22 return true; 23 } 24 } 25 return false; 18 $this->Auth->allow(array('display', 'view')); 19 parent::beforeFilter(); 26 20 } 27 21 22 public function isAuthorized() 23 { 24 if (isset( $this->params[Configure::read('Routing.admin')] )) 25 { 26 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) // admin and teachers 27 { 28 return true; 29 } 30 } 31 return false; // go away !! 32 } 33 28 34 public function display($username) 29 35 { -
trunk/app/controllers/colleges_controller.php
r274 r339 3 3 * Karamelo E-Learning Platform 4 4 * Manuel Montoya 2002-2008 5 * GPL License manuel<at>mononeurona<punto>org5 * GPLv3 License manuel<at>mononeurona<punto>org 6 6 * Chipotle Software TM 7 7 */ … … 15 15 public $components = array('Portal'); 16 16 17 public function beforeFilter() 18 { 19 $this->Auth->allow(array('view')); 20 parent::beforeFilter(); 21 } 22 17 23 public function isAuthorized() 18 { 19 if ( $this->action == 'delete')20 {21 if ($this->Auth->user('group_id') == 1) 22 {24 { 25 if (isset( $this->params[Configure::read('Routing.admin')] )) 26 { 27 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) // admin and teachers 28 { 23 29 return true; 24 } else { 25 return false; 26 } 27 } 28 29 return true; 30 } 31 } 32 return false; // go away !! 30 33 } 34 31 35 32 36 public function view() -
trunk/app/controllers/comments_controller.php
r325 r339 15 15 public $helpers = array('Fck', 'News', 'Time', 'Gags', 'Session'); 16 16 17 public function beforeFilter() 18 { 19 $this->Auth->allow(array('view', 'add')); 20 parent::beforeFilter(); 21 } 22 17 23 public function isAuthorized() 18 24 { … … 26 32 return false; // go away !! 27 33 } 34 28 35 29 36 public function view($username=null, $entry_id=null) -
trunk/app/controllers/confirms_controller.php
r247 r339 3 3 * Karamelo E-Learning Platform 4 4 * Chipotle Software 2002-2008 5 * GPLv3 manuel<a t>mononeurona<punto>org5 * GPLv3 manuel<arroba>mononeurona<punto>org 6 6 */ 7 //File: /app/controllers/ users_controller.php7 //File: /app/controllers/confirms_controller.php 8 8 9 9 uses('sanitize'); … … 11 11 class ConfirmsController extends AppController 12 12 { 13 public function isAuthorized() 14 { 15 if ($this->action == 'delete') 16 { 17 if ($this->Auth->user('group_id') == 1) 18 { 13 14 public function beforeFilter() 15 { 16 $this->Auth->allow(array('signup')); 17 parent::beforeFilter(); 18 } 19 20 public function isAuthorized() 21 { 22 if (isset( $this->params[Configure::read('Routing.admin')] )) 23 { 24 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) // admin and teachers 25 { 19 26 return true; 20 } else {21 return false; 22 }23 }27 } 28 } 29 return false; // go away !! 30 } 24 31 25 return true; 26 } 27 28 public function signup($secret = null) 29 { 30 $this->pageTitle = 'Active User Account'; 31 32 $conditions = array("secret" => $secret); 33 34 $fields = array('id', 'user_id'); 35 36 $data = $this->Confirm->find($conditions, $fields); 37 38 //die(var_dump($data)); 39 40 if ($data != false) 41 { 42 $this->User = new User; 43 44 $this->data['User']['id'] = $data['Confirm']['user_id']; 45 $this->data['User']['active'] = 1; 46 47 if ($this->User->save($this->data) && $this->Confirm->delete($data['Confirm']['id'])) 48 { 49 $this->flash('Your account has been activatedd', '/users/login'); 50 } 51 else 52 { 32 public function signup($secret = null) 33 { 34 $this->pageTitle = 'Active User Account'; 35 36 $conditions = array("secret" => $secret); 37 38 $fields = array('id', 'user_id'); 39 40 $data = $this->Confirm->find($conditions, $fields); 41 42 //die(var_dump($data)); 43 44 if ($data != null) 45 { 46 $this->User = new User; 47 48 $this->data['User']['id'] = $data['Confirm']['user_id']; 49 $this->data['User']['active'] = 1; 50 51 if ($this->User->save($this->data) && $this->Confirm->delete($data['Confirm']['id'])) 52 { 53 $this->flash('Your account has been activated', '/users/login'); 54 } 55 else 56 { 53 57 $this->flash('Problem, please report to support@mononeurona.org', '/users/login'); 54 }55 }56 else57 {58 } 59 } 60 else 61 { 58 62 $this->flash('There is not such account', '/users/login'); 59 } 60 } 61 63 } 64 } 62 65 } 63 66 ?> -
trunk/app/controllers/entries_controller.php
r301 r339 14 14 public $components = array('Edublog', 'Portal'); 15 15 16 public function beforeFilter() 17 { 18 $this->Auth->allow(array('rss', 'search')); 19 parent::beforeFilter(); 20 } 21 16 22 public function isAuthorized() 17 23 { … … 26 32 } 27 33 28 public function results($string)29 {30 $this->layout = 'portal';31 32 $conditions = array("Entry.body"=>$string);33 34 $this->set('data', $this->Entry->findAll($conditions, $order));35 }36 37 34 public function rss($username) 38 35 { -
trunk/app/controllers/forums_controller.php
r333 r339 13 13 14 14 public $components = array('Edublog'); 15 16 public function isAuthorized()15 16 public function beforeFilter() 17 17 { 18 if (isset($this->params[Configure::read('Routing.admin')])) 19 { 20 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2) 21 { 22 return true; 23 } 24 } 25 return false; // go away!! 18 $this->Auth->allow(array('display', 'discussion', 'view')); 19 parent::beforeFilter(); 26 20 } 27 21 22 public function isAuthorized() 23 { 24 if (isset( $this->params[Configure::read('Routing.admin')] )) 25 { 26 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) // admin and teachers 27 { 28 return true; 29 } 30 } 31 return false; // go away !! 32 } 33 28 34 public function display($forum_id) 29 35 { … … 79 85 } 80 86 87 /* === ADMIN METHODS == */ 81 88 public function admin_listing() 82 89 { -
trunk/app/controllers/recovers_controller.php
r338 r339 12 12 public $helpers = array('Javascript', 'Ajax', 'Form', 'Fck'); 13 13 14 public $components = array('Security', 'Portal', ' Adds');14 public $components = array('Security', 'Portal', 'Email', 'Adds'); 15 15 16 public function beforeFilter()16 public function beforeFilter() 17 17 { 18 $this->Auth->allow(array('check', ' display', 'recover'));18 $this->Auth->allow(array('check', 'newpwd', 'recover')); 19 19 parent::beforeFilter(); 20 20 } … … 49 49 if ( !empty( $this->data["User"] ) ) 50 50 { 51 $user_id = $this->Recover->User->field('id', array( "email" => $this->data["User"]["email"]));51 $user_id = $this->Recover->User->field('id', array('email' => $this->data['User']['email'], 'active'=>1)); 52 52 53 53 if ($user_id == null) 54 54 { 55 $this->set('error_message', "Error: email <b>" . $this->data["User"]["email"] . "</b> does not exist on database");56 $this->render('check', 'ajax');55 $this->set('error_message', "Error: email <b>" . $this->data["User"]["email"] . "</b> does not exist on database"); 56 $this->render('check', 'ajax'); 57 57 } 58 else 58 else // email exist
