Changeset 407

Show
Ignore:
Timestamp:
04/16/08 17:24:40 (9 months ago)
Author:
aarkerio
Message:

Updates on polls

Location:
trunk/app
Files:
1 removed
11 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/app_controller.php

    r400 r407  
    1212class AppController extends Controller { 
    1313  
    14  public $components = array('Auth', 'Cookie', 'Security', 'Session'); 
     14 public $components = array('Auth', 'Cookie', 'Session', 'Security'); 
    1515  
    1616 public $helpers    = array('Html', 'Form', 'Session'); 
  • trunk/app/config/core.php

    r406 r407  
    1414 * In development mode, you need to click the flash message to continue. 
    1515 */ 
    16     Configure::write('debug', 2); 
     16    Configure::write('debug', 1); 
    1717/** 
    1818 * Application wide charset encoding 
  • trunk/app/config/routes.php

    r276 r407  
    1414 * developement. 
    1515 */ 
    16     Router::connect('/tests', array('controller' => 'tests', 'action' => 'index')); 
     16// Router::connect('/tests', array('controller' => 'tests', 'action' => 'index')); 
    1717?> 
  • trunk/app/controllers/discussions_controller.php

    r406 r407  
    4242 public function agregar() 
    4343 { 
     44  
    4445  $this->layout = 'portal'; 
    45     
    46   echo 'I am in add function !!!<br />'; 
     46   
     47  echo 'I am in agregar function !!!<br />'; 
    4748 
    4849  die(debug($this->data)); 
  • trunk/app/controllers/polls_controller.php

    r328 r407  
    2525 } 
    2626                                                                   
    27 /** 
    28 == ADMIN METHODS 
    29 **/ 
     27/**== ADMIN METHODS **/ 
    3028 
    31 public function admin_add()  
    32 { 
     29 public function admin_listing() 
     30 { 
    3331      $this->layout    = 'admin'; 
    34       $this->pageTitle = 'Add Poll'; 
     32      $this->pageTitle = 'Polls'; 
    3533       
    36      if (!empty($this->data["Poll"])) 
    37      { 
    38          $this->Sanitize = new Sanitize; 
     34      $conditions      = array("user_id" => $this->Auth->user('id')); 
     35      $fields          = array("id", "question", "created", "status"); 
     36      $order           = "created DESC"; 
     37       
     38      $this->set('data', $this->Poll->findAll($conditions, $fields, $order, null, null, 2)); 
     39 } 
     40  
     41 public function admin_add()  
     42 { 
     43  $this->layout    = 'admin'; 
     44  $this->pageTitle = 'Add Poll'; 
     45       
     46  if (!empty($this->data['Poll'])) 
     47  { 
     48    $this->Sanitize = new Sanitize; 
    3949          
    40          $this->Sanitize->clean($this->data['Poll']); //Hopefully this is enough 
     50    $this->Sanitize->clean($this->data['Poll']); //Hopefully this is enough 
    4151          
    42          $this->Pollrow = new Pollrow; 
     52    $this->Pollrow = new Pollrow; 
    4353          
    44          $this->data['Poll']['user_id'] = $this->Auth->user('id'); 
     54    $this->data['Poll']['user_id'] = $this->Auth->user('id'); 
    4555      
    4656     $this->Poll->create(); 
    4757          
    48          if ( $this->Poll->save($this->data['Poll'])) 
    49          {    
    50                 $this->Poll->id    = false; 
    51                 $this->Pollrow->id = false; 
     58    if ( $this->Poll->save($this->data['Poll'])) 
     59    {    
     60        $this->Poll->id    = false; 
     61        $this->Pollrow->id = false; 
    5262                 
    53                 $poll_id = $this->Poll->getLastInsertID(); 
     63        $poll_id = $this->Poll->getLastInsertID(); 
    5464                 
    55                 $colors = array('green', 'blue', 'brown', 'yellow', 'orange', 'red', 'black'); 
     65        $colors = array('green', 'blue', 'brown', 'yellow', 'orange', 'red', 'black'); 
    5666                 
    5767                $i = 0; 
     
    6979                } 
    7080             
    71             exit($this->redirect('/admin/polls/listing')); 
     81            $this->msgFlash('Poll saved', '/admin/polls/listing'); 
    7282             
    73             }  
    74             else 
    75             { 
    76                   $this->flash('/admin/polls/listing', 'Error Pollrow model'); 
    77             }  
    78        } 
    79   } 
     83     }  
     84     else 
     85     { 
     86            $this->flash('/admin/polls/listing', 'Error Pollrow model'); 
     87     }  
     88   } 
     89 } 
    8090  
    81  public function admin_listing() 
    82    { 
    83       $this->layout    = 'admin'; 
    84       $this->pageTitle = 'Polls'; 
    85        
    86       $conditions      = array("user_id" => $this->othAuth->user('id')); 
    87       $fields          = array("id", "question", "created", "status"); 
    88       $order           = "created DESC"; 
    89        
    90       $this->set('data', $this->Poll->findAll($conditions, $fields, $order, null, null, 2)); 
    91    } 
    92     
    93 public function admin_edit($id=null) 
    94 { 
     91 public function admin_edit($poll_id=null) 
     92 { 
    9593     
    9694    if (empty($this->data['Poll'])) 
    9795    { 
    9896        $this->layout = 'admin'; 
    99          
    100         $this->Poll->id = $id; 
    10197               
    102         $this->data = $this->Poll->read(); 
     98        $this->data = $this->Poll->read(null, $poll_id); 
    10399    } 
    104100    else 
     
    114110        } 
    115111    } 
    116 } 
    117  
    118   public function admin_delete($id) 
    119   { 
    120         // deletes task from database 
    121                 //die($this->data['Poll']['id']); 
    122         $this->Poll->del($id); 
    123         $this->msgFlash('Poll deleted', '/admin/polls/listing'); 
    124      exit(); 
     112 } 
     113  
     114 public function admin_delete($id) 
     115 { 
     116        if ( $this->Poll->del($id) ) 
     117        { 
     118           $this->msgFlash('Poll deleted', '/admin/polls/listing'); 
     119        } 
    125120  } 
    126121} 
  • trunk/app/models/discussion.php

    r401 r407  
    2424 
    2525  public $validate = array( 
    26                       'username' => array( 
    27                      'rule' => array('minLength', 2),   
     26                      'comment' => array( 
     27                           'rule' => array('minLength', 2),   
    2828                                          'message' => 'Usernames must be at least 6 characters long.' 
    2929                     )  
  • trunk/app/models/news.php

    r401 r407  
    3333     public $validate = array( 
    3434           'title' => VALID_NOT_EMPTY, 
    35        'user_id' => VALID_NOT_EMPTY, 
     35            'user_id' => VALID_NOT_EMPTY, 
    3636           'body' => VALID_NOT_EMPTY, 
    37        'status' => VALID_NOT_EMPTY 
     37            'status' => VALID_NOT_EMPTY 
    3838     ); 
    3939  
  • trunk/app/views/errors/error404.ctp

    r313 r407  
    1 Karamelo: error404.thtml 
     1<h1><?php echo $name;   ?></h1> 
     2<p><?php echo $message; ?></p> 
     3 
  • trunk/app/views/news/admin_listing.ctp

    r301 r407  
    44  <?php  
    55     echo $html->link($html->image('actions/new.png', array("alt"=>"Add new", "title"=>"Add new")), '/admin/news/add', null, false, false); 
    6      echo $html->link($html->image('static/forum.gif', array("alt"=>"See comments", "title"=>"See comments")), '/admin/commentnews/listing', null, false, false); 
     6     echo $html->link($html->image('static/forum.gif', array("alt"=>"See comments", "title"=>"See comments")), '/admin/discussions/listing', null, false, false); 
    77  ?> 
    88 
  • trunk/app/views/news/view.ctp

    r406 r407  
    4646               
    4747      echo '<div class="comentnew" style="background-color:'.$bg.'">';   
    48       echo $time->timeAgoInWords($v["created"]) . " <b>". $v["name"]    . "</b> wrote:<br />"; 
     48      echo $time->timeAgoInWords($v['created']) . ' <b>'. $v['name']    . '</b> wrote:<br />'; 
    4949      echo $v["comment"]; 
    5050      echo "</div>"; 
     
    5454 
    5555  echo $form->create('Discussion', array('action'=>'agregar')); 
     56  //echo '<form action="/discussions/agregar" method="post">'; 
    5657?> 
     58 
     59 
    5760<fieldset> 
    5861   <legend>Write comment:</legend> 
  • trunk/app/views/polls/admin_add.ctp

    r268 r407  
    11 
    2 <?php echo $html->formTag('/admin/polls/add/','post'); ?> 
     2<?php echo $form->create('Poll'); ?> 
    33<fieldset> 
    44<legend>New Poll</legend> 
    5   <?php echo $form->labelTag('Poll/question', 'Question:') . "<br />"; ?> 
    6   <?php echo $html->input('Poll/question', array("size" => 60, "maxlength"=>130)); ?> 
    7   <?php echo $html->tagErrorMsg('Poll/question', 'A question is required.'); ?> 
     5  <?php  
     6    echo $form->input('Poll.question', array("size" => 60, "maxlength"=>100)); 
     7  ?> 
     8   
    89  <div style="margin:15px auto 15px auto;border:1px dotted gray;padding-left:40px;width:80%;"> 
    910 
    1011<?php  
    1112for ($i=1;$i<10;$i++)  
    12 { 
    13    echo $form->labelTag('Row/answer'.$i, 'Answer ' . $i . ':') . "<br />";  
    14    echo $html->input('Row/answer'.$i, array("size" => 50, "maxlenght"=>100));   
     13{  
     14  echo $form->input('Row.answer'.$i, array('size' => 50, 'maxlenght'=>100));   
    1515} 
    1616?> 
     
    1818 
    1919<?php  
    20   echo $form->labelTag('Poll/status', 'Published:') . "<br />";  
    21   echo $html->checkbox('Poll/status');  
     20  echo $form->label('Poll.status', 'Published:') . "<br />";  
     21  echo $form->checkbox('Poll.status', array('value'=>1));  
    2222?> 
    2323 
    24 <div style="clear:both"></div> 
    25 <?php echo $html->submit('Add'); ?> 
    26 </fieldset> 
    27 </form> 
     24<div style="clear:both"></div></fieldset> 
    2825 
     26<?php echo $form->end('Save'); ?> 
     27 
     28