Changeset 343
- Timestamp:
- 03/03/10 09:58:32 (2 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
controllers/contacts_controller.php (modified) (3 diffs)
-
controllers/pages_controller.php (modified) (9 diffs)
-
controllers/todos_controller.php (modified) (4 diffs)
-
models/todo.php (modified) (2 diffs)
-
models/user.php (modified) (1 diff)
-
views/todos/admin_listing.ctp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/controllers/contacts_controller.php
r256 r343 1 1 <?php 2 2 /** 3 * Chipotle Software 4 * Manuel Montoya 2002-20 095 * GPL manuel<at>mononeurona.org3 * Chipotle Software (c) 4 * Manuel Montoya 2002-2010 5 * GPLv3 manuel<at>mononeurona.org 6 6 */ 7 7 … … 22 22 /*** ==== ADMIN SECTION =====****/ 23 23 24 public function admin_export($username) 25 { 26 27 $this->layout = 'ajax'; 28 29 $user_id = $this->Contact->User->field('User.id', array("User.username"=>$username)); 30 31 $conditions = array("Contact.user_id"=>$user_id); 32 33 $fields = array("firstname", "lastname", "title", "nickname", "email1", "email2", "homephone", "workphone", "cellphone", "fax", "cp", "website", "skype", "msn", "address", "organization", "birthday"); 24 public function admin_export($username) 25 { 26 $this->layout = 'ajax'; 27 $user_id = $this->Contact->User->field('User.id', array("User.username"=>$username)); 28 $params = array( 29 'conditions' => array('Contact.user_id'=>$user_id), 30 'fields' => array('firstname', 'lastname', 'title', 'nickname', 'email1', 'email2', 'homephone', 'workphone', 'cellphone', 'fax', 31 'cp', 'website', 'skype', 'msn', 'address', 'organization', 'birthday') 32 ); 34 33 35 $data = $this->Contact->findAll($conditions); 36 #die(debug($data)); 37 $this->set('data', $data); 38 39 $this->set('username', $username); 40 } 34 $data = $this->Contact->find('all', $params); 35 #die(debug($data)); 36 $this->set('data', $data); 37 $this->set('username', $username); 38 } 41 39 42 public function admin_add() 43 { 44 $this->layout = 'admin'; 45 46 if (!empty($this->data["Contact"])) 47 { 48 49 50 Sanitize::clean($this->data["Contact"]); //Hopefully this is enough 51 52 $this->data["Contact"]["user_id"] = $this->Auth->user('id'); 53 54 $this->data["Contact"]["birthday"] = $this->data['Contact']['birthday']; 55 56 if ( $this->Contact->save($this->data["Contact"])) 57 { 40 public function admin_add() 41 { 42 $this->layout = 'admin'; 43 if (!empty($this->data["Contact"])) 44 { 45 $this->data['Contact']['user_id'] = $this->Auth->user('id'); 46 $this->data['Contact']['birthday'] = $this->data['Contact']['birthday']; 47 if ( $this->Contact->save($this->data["Contact"])) 48 { 58 49 $this->msgFlash('An new contact has been added!','/admin/contacts/listing'); 59 50 exit(); 60 }61 }62 }51 } 52 } 53 } 63 54 64 55 public function admin_listing() 65 56 { 66 $this->layout = 'admin'; 67 $this->pageTitle = 'Contacts'; 68 69 $conditions = array("user_id" => $this->Auth->user('id')); 70 71 $fields = array("id", "firstname", "lastname", "title", "nickname", "email1", "workphone", "cellphone", "website", "msn", "address", "birthday"); 72 $order = "firstname ASC"; 73 74 $this->set('data', $this->Contact->findAll($conditions, $fields, $order)); 75 } 57 $this->layout = 'admin'; 58 $this->pageTitle = 'Contacts'; 59 $params = array('conditions' => array('user_id' => $this->Auth->user('id')), 60 'fields' => array('id', 'firstname', 'lastname', 'title', 'nickname', 'email1', 'workphone', 'cellphone', 61 'website', 'msn', 'address', 'birthday'), 62 'order' => 'firstname ASC'); 63 $this->set('data', $this->Contact->find('all', $params)); 64 } 76 65 77 public function admin_edit($id=null)78 {79 if (empty($this->data["Contact"]))80 {66 public function admin_edit($id=null) 67 { 68 if (empty($this->data["Contact"])) 69 { 81 70 $this->layout = 'admin'; 82 71 … … 84 73 85 74 $this->data = $this->Contact->read(); 86 } 87 else 88 { 89 90 91 Sanitize::clean($this->data["Contact"]); 92 93 $this->data["Contact"]["birthday"] = $this->data['Contact']['birthday']; 94 95 if ($this->Contact->save($this->data["Contact"])) 96 { 75 } 76 else 77 { 78 if ($this->Contact->save($this->data)): 97 79 $this->msgFlash('Contact has been saved!','/admin/contacts/listing'); 98 80 exit(); 99 }81 endif; 100 82 } 101 83 } -
trunk/controllers/pages_controller.php
r329 r343 2 2 /** 3 3 * Chipotle Software 4 * Manuel Montoya 2002-20 095 * GPL manuel<at>mononeurona<dot>org4 * Manuel Montoya 2002-2010 5 * GPLv3 manuel<at>mononeurona<dot>org 6 6 */ 7 7 … … 63 63 $this->pageTitle = $data['Page']['title']; 64 64 } 65 65 66 /** 67 * Description 68 * @access public 69 * @return void 70 */ 66 71 public function author($username, $id) 67 72 { … … 76 81 $this->set('data', $this->Page->find('all', $params)); 77 82 } 78 83 84 /** 85 * Description 86 * @access public 87 * @return void 88 */ 79 89 public function printing($page_id) 80 90 { … … 91 101 $this->set('data', $data); 92 102 } 93 103 104 /** 105 * Description 106 * @access public 107 * @return void 108 */ 94 109 public function last() 95 110 { … … 103 118 } 104 119 120 /** 121 * Description 122 * @access public 123 * @return void 124 */ 105 125 public function search() 106 126 { … … 115 135 116 136 /*****=== SECTION ADMIN =====*/ 137 /** 138 * Description 139 * @access public 140 * @return void 141 */ 117 142 public function admin_listing($section_id) 118 143 { … … 125 150 $this->set('data', $this->Page->find('all', $params)); 126 151 } 127 152 153 /** 154 * Description 155 * @access public 156 * @return void 157 */ 128 158 public function admin_sections() 129 159 { … … 132 162 $this->set('data', $this->Page->Section->find('all')); 133 163 } 134 164 165 /** 166 * Description 167 * @access public 168 * @return void 169 */ 135 170 public function admin_edit($page_id = null) 136 171 { 137 172 $this->layout = 'admin'; 138 $this->set('sections', Set::combine($this->Page->Section->find('all', 139 array('order'=>'description')), 140 '{n}.Section.id','{n}.Section.description')); 141 if (!empty($this->data['Page'])): 142 $this->data['Page']['title'] = Sanitize::paranoid($this->data['Page']['title'], $this->para_allowed); 173 $this->set('sections', Set::combine($this->Page->Section->find('all',array('order'=>'description')),'{n}.Section.id','{n}.Section.description')); 174 if (!empty($this->data['Page'])): 143 175 $this->data['Page']['updated'] = 'now()'; 144 176 # New page … … 162 194 } 163 195 196 /** 197 * Description 198 * @access public 199 * @return void 200 */ 164 201 public function admin_delete($page_id) 165 202 { -
trunk/controllers/todos_controller.php
r336 r343 2 2 /** 3 3 * Chipotle Software 4 * Manuel Montoya 2002-20 095 * GPL manuel<at>mononeurona.org4 * Manuel Montoya 2002-2010 5 * GPLv3 manuel<at>mononeurona<punto>org 6 6 */ 7 7 8 App::import('Model','User');9 8 App::import('Sanitize'); 10 9 11 10 class TodosController extends AppController { 12 11 13 public $helpers = array('Html', 'Javascript', 'Ajax', 'Form', 'User', 'Fck', 'Gags');12 public $helpers = array('Html', 'Javascript', 'Ajax', 'Form', 'User', 'Fck', 'Gags'); 14 13 15 public $components = array('Security', 'Email'); 14 public $components = array('Email'); 15 16 16 public function beforeFilter() 17 17 { … … 49 49 } 50 50 51 /** 52 * Feeder 53 * @access public 54 */ 51 55 public function rss($username) 52 56 { 53 57 $this->layout = 'rss'; 54 $this->User = new User;55 58 56 $user_id = (int) $this-> User->field('id', array("User.username"=>$username));59 $user_id = (int) $this->Todo->User->field('id', array('User.username'=>$username)); 57 60 58 61 $params = array( … … 75 78 $this->Email->from = 'noreply@mononeurona.org'; 76 79 77 $url .= '<h2>'.$v[ "User"]["username"].'</h2><p>You must finish <b>' .$v["Todo"]["name"]. '</b> with priority '.$v["Todo"]["priority"].' during the next 24 hours';78 $url .= '<br />Deadline date: ' . $v[ "Todo"]["deadline"] .'<br />';80 $url .= '<h2>'.$v['User']['username'].'</h2><p>You must finish <b>' .$v['Todo']['name']. '</b> with priority '.$v['Todo']['priority'].' during the next 24 hours'; 81 $url .= '<br />Deadline date: ' . $v['Todo']['deadline'] .'<br />'; 79 82 $url .= '<a href="http://'.$_SERVER['SERVER_NAME'].'/admin/todos/listing/">'; 80 83 $url .= 'http://'.$_SERVER['SERVER_NAME'].'/admin/todos/listing/</a></p>'; 81 84 82 if ( $this->Email->send($url) ) 83 { 84 return true; 85 } 86 else 87 { 88 return false; 89 } 85 if ( $this->Email->send($url) ): 86 return True; 87 else: 88 return False; 89 endif; 90 90 } 91 91 92 /*** 93 ==== ADMIN SECTION ===== 94 ****/ 92 /*** ==== ADMIN SECTION =====****/ 93 95 94 public function admin_add() 96 95 { 97 $this->layout = 'ajax'; 98 99 if (!empty($this->data['Todo'])) 100 { 96 $this->layout = 'ajax'; 97 if (!empty($this->data['Todo'])): 101 98 $this->data['Todo']['user_id'] = (int) $this->Auth->user('id'); 102 103 if ( $this->Todo->save($this->data)) 104 { 105 $conditions = array("Todo.user_id" => $this->Auth->user('id')); 99 100 if ( $this->Todo->save($this->data)): 101 $params = array( 102 'conditions' => array('Todo.user_id' => $this->Auth->user('id')), 103 'fields' => array('Todo.id', 'Todo.user_id', 'Todo.name', 'Todo.deadline', 'Todo.priority', 'Todo.created', 'Todo.modified', 'Todo.completed'), 104 'order' => 'Todo.id DESC' 105 ); 106 106 107 $fields = array("Todo.id", "Todo.user_id", "Todo.name", "Todo.deadline", "Todo.priority", "Todo.created", "Todo.modified", "Todo.completed"); 108 109 $order = "Todo.id DESC"; 110 111 $this->set('data', $this->Todo->findAll($conditions, $fields, $order)); 112 113 $this->render('updated', 'ajax'); 114 } 115 } 116 } 107 $this->set('data', $this->Todo->find('all', $params)); 108 $this->render('updated', 'ajax'); 109 endif; 110 endif; 111 } 117 112 118 public function admin_listing($order_field = 'id') 119 { 120 $this->layout = 'admin'; 121 122 $this->pageTitle = $this->Auth->user('username') . 'TODOs'; 123 124 $conditions = array("Todo.user_id" => $this->Auth->user('id')); 125 126 $fields = array("Todo.id", "Todo.user_id", "Todo.name", "Todo.priority", "Todo.created", "Todo.modified", "Todo.completed", "Todo.deadline"); 127 128 $order = "Todo.completed ASC, Todo." . $order_field . " DESC"; 129 130 $this->set('data', $this->Todo->findAll($conditions, $fields, $order)); 131 } 113 public function admin_listing($order_field = 'id') 114 { 115 $this->layout = 'admin'; 116 $this->pageTitle = $this->Auth->user('username') . 'TODOs'; 117 $params = array( 118 'conditions' => array('Todo.user_id' => $this->Auth->user('id')), 119 'fields' => array('Todo.id', 'Todo.user_id', 'Todo.name', 'Todo.priority', 'Todo.created', 'Todo.modified', 'Todo.completed', 'Todo.deadline'), 120 'order' => 'Todo.completed ASC, Todo.' . $order_field . ' DESC' 121 ); 122 $this->set('data', $this->Todo->find('all', $params)); 123 } 132 124 133 public function admin_edit()134 {125 public function admin_edit() 126 { 135 127 $this->layout = 'ajax'; 136 128 137 129 if (isset($this->data["Todo"]["get"])) // get indicate shows edit form action 138 130 { 139 $this->Todo->id = $this->data["Todo"]["id"]; 140 131 $this->Todo->id = $this->data['Todo']['id']; 141 132 $this->data = $this->Todo->read(); 142 143 $this->set('data', $this->data ); 144 133 $this->set('data', $this->data ); 145 134 $this->render('admin_edit', 'ajax'); 146 135 } 147 136 else 148 137 { 138 $this->data['Todo']['modified'] = 'now()'; 149 139 150 151 Sanitize::clean($this->data["Todo"]); 152 153 $this->data["Todo"]["modified"] = 'now()'; 154 155 if ($this->Todo->save($this->data["Todo"])) 156 { 157 $this->msgFlash('Todo has been saved!','/admin/todos/listing'); 158 exit(); 159 } 140 if ($this->Todo->save($this->data)): 141 $this->msgFlash('Todo has been saved!','/admin/todos/listing'); 142 endif; 160 143 } 161 144 } … … 163 146 public function admin_export($username) 164 147 { 165 $this->layout = 'admin'; 166 167 $conditions = array("Todo.id"=>$id, "Todo.user_id"=>$this->Auth->user('id')); 168 169 $this->set('data', $this->Todo->find($conditions)); 148 $this->layout = 'admin'; 149 $params = array('conditions' => array('Todo.id'=>$id, 'Todo.user_id'=>$this->Auth->user('id'))); 150 $this->set('data', $this->Todo->find('first', $params)); 170 151 } 171 152 172 public function admin_change($todo_id, $status) 173 { 174 $this->layout = 'ajax'; 153 public function admin_change($todo_id, $status) 154 { 155 $this->layout = 'ajax'; 156 $this->data['Todo']['id'] = $todo_id; 157 $this->data['Todo']['completed'] = ($status == 0) ? 1 : 0; 175 158 176 $this->data["Todo"]["id"] = $todo_id; 177 178 $this->data["Todo"]["completed"] = ($status == 0) ? 1 : 0; 179 180 if ($this->Todo->save($this->data["Todo"])) 181 { 182 $this->msgFlash('ToDo has been changed','/admin/todos/listing'); 183 exit(); 184 } 185 } 159 if ($this->Todo->save($this->data)): 160 $this->msgFlash('ToDo has been changed','/admin/todos/listing'); 161 exit(); 162 endif; 163 } 164 186 165 public function admin_delete($id) 187 166 { 188 if (isset($this->data["Todo"]["get"])) // get indicate shows edit form action189 {167 if (isset($this->data['Todo']['get'])) // get indicate shows edit form action 168 { 190 169 $this->Todo->del($id); 191 }192 else193 {170 } 171 else 172 { 194 173 $this->Todo->del($id); 195 174 $this->msgFlash('Todo has been deleted!', '/admin/todos/listing'); 196 175 exit(); 197 }176 } 198 177 } 199 178 } -
trunk/models/todo.php
r70 r343 1 1 <?php 2 2 /** 3 Centauro 2002-2007 4 Chipotle SoftwareGPLv35 Manuel Montoya -- manuel<AT>mononeurona<DOT>org6 */3 * Centauro 2002-2010 4 * Chipotle Software (c) GPLv3 5 * Manuel Montoya -- manuel<AT>mononeurona<DOT>org 6 */ 7 7 8 8 class Todo extends AppModel 9 9 { 10 //Its always good practice to include this variable.10 # Its always good practice to include this variable. 11 11 public $name = 'Todo'; 12 12 … … 17 17 'foreignKey' => 'user_id' 18 18 ) 19 ); 20 21 /* public $hasMany = array('Project' => 22 array('className' => 'Project', 23 'conditions' => '', 24 'order' => 'id ASC', 25 'foreignKey' => 'page_id' 26 ) ); 27 */ 28 29 public $validate = array( 30 'name' => VALID_NOT_EMPTY, //'/[a-z0-9\_\-]{3,}$/i', 31 'user_id' => VALID_NOT_EMPTY 32 ); 19 ); 33 20 } 34 35 21 ?> -
trunk/models/user.php
r340 r343 29 29 30 30 public $hasMany = array( 31 "Entry"=> array(32 "className" => "Entry"31 'Entry' => array( 32 'className' => 'Entry' 33 33 ), 34 "Themeblog"=> array(35 "className" => "Themeblog"34 'Themeblog' => array( 35 'className' => 'Themeblog' 36 36 ), 37 "Bookmark"=> array(38 "className" => "Bookmark"37 'Bookmark' => array( 38 'className' => 'Bookmark' 39 39 ), 40 "Page"=> array(41 "className" => "Page"40 'Page' => array( 41 'className' => 'Page' 42 42 ), 43 43 "Podcast" => array( -
trunk/views/todos/admin_listing.ctp
r194 r343 2 2 echo $html->div('title_section', 'My TO-DOs'); 3 3 4 echo $html->div(null, null, array('style'=>'float:right;width:100px;position:absolute;top:30px;left:800px')); 5 4 echo $html->div(null, null, array('style'=>'float:right;width:100px;position:absolute;top:30px;left:800px')); 6 5 echo $html->link($html->image('static/rss-icon.gif', array('alt'=>'RSS', 'title'=>'ToDos RSS')), 7 '/todos/rss/'.$session->read('Auth.User.username'), null, false, false);6 '/todos/rss/'.$session->read('Auth.User.username'), Null, False, False); 8 7 ?> 9 8 </div> … … 35 34 <legend>Quick add</legend> 36 35 <?php 37 echo $form->label('Todo.name', 'TODO:') . $form->input('Todo.name', array('size' => 35, 'maxlength'=>80)); 38 echo $form->error('Todo.name', 'A name is required.'); 36 echo $form->input('Todo.name', array('size' => 35, 'maxlength'=>80)); 39 37 echo $ajax->submit('Save', array('url' => '/admin/todos/add/', 40 38 'updat' => 'todolist', … … 49 47 <table class="tbadmin" style="width:100%"> 50 48 <?php 51 52 49 $th = array ('Edit', 'Name', 'Priority', 'Deadline', 'Completed', 'Created', 'Delete'); 53 50 echo $html->tableHeaders($th); … … 69 66 ); 70 67 71 echo $html->tableCells($tr, array('class'=>"altRow", "onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='altRow'"),72 array('class'=>'evenRow',"onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='evenRow'"));68 echo $html->tableCells($tr, array('class'=>"altRow", "onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='altRow'"), 69 array('class'=>'evenRow',"onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='evenRow'")); 73 70 74 71 endforeach;
Note: See TracChangeset
for help on using the changeset viewer.
