Changeset 343


Ignore:
Timestamp:
03/03/10 09:58:32 (2 years ago)
Author:
aarkerio
Message:

update todos

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/controllers/contacts_controller.php

    r256 r343  
    11<?php 
    22/** 
    3 *  Chipotle Software 
    4 *  Manuel Montoya 2002-2009  
    5 *  GPL manuel<at>mononeurona.org 
     3*  Chipotle Software (c) 
     4*  Manuel Montoya 2002-2010 
     5*  GPLv3 manuel<at>mononeurona.org 
    66*/  
    77 
     
    2222 /*** ====  ADMIN SECTION    =====****/ 
    2323 
    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       ); 
    3433 
    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 } 
    4139 
    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          {  
    5849               $this->msgFlash('An new contact has been added!','/admin/contacts/listing'); 
    5950               exit(); 
    60              } 
    61        } 
    62   } 
     51      } 
     52   } 
     53 } 
    6354  
    6455 public function admin_listing() 
    6556 { 
    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 } 
    7665 
    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  { 
    8170        $this->layout        = 'admin'; 
    8271         
     
    8473         
    8574        $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)): 
    9779           $this->msgFlash('Contact has been saved!','/admin/contacts/listing'); 
    9880            exit(); 
    99         } 
     81         endif; 
    10082    } 
    10183} 
  • trunk/controllers/pages_controller.php

    r329 r343  
    22/** 
    33*  Chipotle Software 
    4 *  Manuel Montoya 2002-2009 
    5 *  GPL manuel<at>mononeurona<dot>org 
     4*  Manuel Montoya 2002-2010 
     5*  GPLv3 manuel<at>mononeurona<dot>org 
    66*/  
    77  
     
    6363   $this->pageTitle = $data['Page']['title']; 
    6464  } 
    65      
     65 
     66/** 
     67 * Description 
     68 * @access public 
     69 * @return void 
     70 */  
    6671 public function author($username, $id)  
    6772 {    
     
    7681   $this->set('data', $this->Page->find('all', $params));  
    7782 } 
    78     
     83 
     84/** 
     85 * Description 
     86 * @access public 
     87 * @return void 
     88 */ 
    7989 public function printing($page_id) 
    8090 {   
     
    91101  $this->set('data', $data); 
    92102 } 
    93     
     103 
     104/** 
     105 * Description 
     106 * @access public 
     107 * @return void 
     108 */ 
    94109 public function last()  
    95110 {   
     
    103118 } 
    104119 
     120/** 
     121 * Description 
     122 * @access public 
     123 * @return void 
     124 */ 
    105125 public function search() 
    106126 { 
     
    115135   
    116136 /*****=== SECTION ADMIN =====*/  
     137/** 
     138 * Description 
     139 * @access public 
     140 * @return void 
     141 */ 
    117142 public function admin_listing($section_id)  
    118143 { 
     
    125150   $this->set('data', $this->Page->find('all', $params));      
    126151 } 
    127     
     152 
     153/** 
     154 * Description 
     155 * @access public 
     156 * @return void 
     157 */ 
    128158 public function admin_sections()  
    129159 { 
     
    132162   $this->set('data', $this->Page->Section->find('all')); 
    133163 }   
    134   
     164 
     165/** 
     166 * Description 
     167 * @access public 
     168 * @return void 
     169 */ 
    135170 public function admin_edit($page_id = null) 
    136171 { 
    137172  $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'])): 
    143175     $this->data['Page']['updated'] = 'now()'; 
    144176     # New page 
     
    162194 } 
    163195  
     196/** 
     197 * Description 
     198 * @access public 
     199 * @return void 
     200 */ 
    164201 public function admin_delete($page_id) 
    165202 { 
  • trunk/controllers/todos_controller.php

    r336 r343  
    22/** 
    33*  Chipotle Software 
    4 *  Manuel Montoya 2002-2009  
    5 *  GPL manuel<at>mononeurona.org 
     4*  Manuel Montoya 2002-2010 
     5*  GPLv3 manuel<at>mononeurona<punto>org 
    66*/  
    77 
    8 App::import('Model','User'); 
    98App::import('Sanitize'); 
    109 
    1110class TodosController extends AppController { 
    1211     
    13     public $helpers       = array('Html', 'Javascript', 'Ajax', 'Form', 'User', 'Fck', 'Gags'); 
     12 public $helpers       = array('Html', 'Javascript', 'Ajax', 'Form', 'User', 'Fck', 'Gags'); 
    1413     
    15     public $components    = array('Security',  'Email'); 
     14 public $components    = array('Email'); 
     15 
    1616 public function beforeFilter()  
    1717 { 
     
    4949 } 
    5050 
     51/** 
     52 * Feeder 
     53 * @access public 
     54 */ 
    5155 public function rss($username)  
    5256 {    
    5357   $this->layout    = 'rss'; 
    54    $this->User = new User; 
    5558     
    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)); 
    5760     
    5861   $params = array( 
     
    7578        $this->Email->from      = 'noreply@mononeurona.org'; 
    7679         
    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 />'; 
    7982        $url  .= '<a href="http://'.$_SERVER['SERVER_NAME'].'/admin/todos/listing/">'; 
    8083        $url  .= 'http://'.$_SERVER['SERVER_NAME'].'/admin/todos/listing/</a></p>'; 
    8184         
    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; 
    9090 } 
    9191 
    92 /***  
    93 ====  ADMIN SECTION    ===== 
    94 ****/ 
     92/*** ====  ADMIN SECTION    =====****/ 
     93 
    9594 public function admin_add()  
    9695 { 
    97    $this->layout    = 'ajax'; 
    98     
    99    if (!empty($this->data['Todo'])) 
    100    {   
     96  $this->layout    = 'ajax';    
     97  if (!empty($this->data['Todo'])):   
    10198      $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              ); 
    106106             
    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 } 
    117112 
    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 } 
    132124 
    133 public function admin_edit() 
    134 { 
     125 public function admin_edit() 
     126 { 
    135127    $this->layout        = 'ajax'; 
    136128     
    137129    if (isset($this->data["Todo"]["get"])) // get indicate shows edit form action  
    138130    { 
    139         $this->Todo->id  = $this->data["Todo"]["id"]; 
    140          
     131        $this->Todo->id  = $this->data['Todo']['id']; 
    141132        $this->data = $this->Todo->read(); 
    142          
    143         $this->set('data', $this->data ); 
    144          
     133        $this->set('data', $this->data );        
    145134        $this->render('admin_edit', 'ajax'); 
    146135    } 
    147136    else 
    148137    { 
     138      $this->data['Todo']['modified'] = 'now()'; 
    149139         
    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; 
    160143    } 
    161144} 
     
    163146 public function admin_export($username) 
    164147 { 
    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)); 
    170151 } 
    171152 
    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; 
    175158     
    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 
    186165 public function admin_delete($id) 
    187166 { 
    188     if (isset($this->data["Todo"]["get"])) // get indicate shows edit form action  
    189     { 
     167  if (isset($this->data['Todo']['get'])) // get indicate shows edit form action  
     168  { 
    190169        $this->Todo->del($id); 
    191     } 
    192     else 
    193     { 
     170  } 
     171  else 
     172  { 
    194173           $this->Todo->del($id); 
    195174       $this->msgFlash('Todo has been deleted!', '/admin/todos/listing'); 
    196175       exit(); 
    197      } 
     176   } 
    198177 } 
    199178} 
  • trunk/models/todo.php

    r70 r343  
    11<?php 
    22/** 
    3 Centauro 2002-2007 
    4 Chipotle Software GPLv3 
    5 Manuel Montoya -- manuel<AT>mononeurona<DOT>org 
    6 */ 
     3 * Centauro 2002-2010 
     4 * Chipotle Software (c) GPLv3 
     5 * Manuel Montoya -- manuel<AT>mononeurona<DOT>org 
     6 */ 
    77 
    88class Todo extends AppModel 
    99{ 
    10     // Its always good practice to include this variable. 
     10    # Its always good practice to include this variable. 
    1111    public $name        = 'Todo'; 
    1212     
     
    1717                                 'foreignKey' => 'user_id' 
    1818                           ) 
    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                    );    
    3320} 
    34  
    3521?> 
  • trunk/models/user.php

    r340 r343  
    2929    
    3030   public $hasMany = array( 
    31     "Entry" => array( 
    32       "className" => "Entry" 
     31    'Entry' => array( 
     32      'className' => 'Entry' 
    3333    ), 
    34     "Themeblog" => array( 
    35       "className" => "Themeblog" 
     34    'Themeblog' => array( 
     35      'className' => 'Themeblog' 
    3636    ), 
    37     "Bookmark" => array( 
    38       "className" => "Bookmark" 
     37    'Bookmark' => array( 
     38      'className' => 'Bookmark' 
    3939    ), 
    40     "Page" => array( 
    41       "className" => "Page" 
     40    'Page' => array( 
     41      'className' => 'Page' 
    4242    ), 
    4343    "Podcast" => array( 
  • trunk/views/todos/admin_listing.ctp

    r194 r343  
    22echo $html->div('title_section', 'My TO-DOs'); 
    33 
    4 echo $html->div(null, null, array('style'=>'float:right;width:100px;position:absolute;top:30px;left:800px')); 
    5    
     4echo $html->div(null, null, array('style'=>'float:right;width:100px;position:absolute;top:30px;left:800px'));   
    65     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); 
    87 ?> 
    98</div> 
     
    3534 <legend>Quick add</legend> 
    3635   <?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)); 
    3937    echo $ajax->submit('Save', array('url'      => '/admin/todos/add/',  
    4038                                          'updat'    => 'todolist', 
     
    4947<table class="tbadmin" style="width:100%"> 
    5048<?php 
    51  
    5249$th = array ('Edit', 'Name', 'Priority', 'Deadline', 'Completed', 'Created', 'Delete'); 
    5350echo $html->tableHeaders($th);   
     
    6966        ); 
    7067        
    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'")); 
    7370     
    7471endforeach; 
Note: See TracChangeset for help on using the changeset viewer.