Changeset 631

Show
Ignore:
Timestamp:
07/07/08 20:33:12 (3 months ago)
Author:
aarkerio
Message:

Adding annotations

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/comments_controller.php

    r593 r631  
    11<?php 
    22/** 
    3 *  Karamelo e-Learning Platform 
    4 *  Chipotle Software TM   2002-2008 
    5 *  GPLv3 
    6 *  @author Manuel Montoya manuel<arroba>mononeurona<punto>org 
    7 *  @version 0.2 
    8 *  @package Karamelo 
    9 */ 
     3 *  Karamelo e-Learning Platform 
     4 *  Chipotle Software TM   2002-2008 
     5 *  GPLv3 
     6 *  @author Manuel Montoya manuel<arroba>mononeurona<punto>org 
     7 *  @version 0.2 
     8 *  @package Karamelo 
     9 */ 
    1010// file : app/controller/comments_controller.php 
    1111 
     
    1414class CommentsController extends AppController { 
    1515  
    16  public $name     = 'Comments'; 
     16  public $name     = 'Comments'; 
    1717  
    18  public $helpers = array('Fck', 'News', 'Time', 'Gags', 'Session'); 
     18  public $helpers = array('Fck', 'News', 'Time', 'Gags', 'Session'); 
    1919 
    20  public function beforeFilter()  
    21  { 
     20  public function beforeFilter()  
     21  { 
    2222    parent::beforeFilter(); 
    2323    $this->Auth->allow(array('view', 'add')); 
    24  } 
     24  } 
    2525   
    26  public function view($username=null, $entry_id=null) 
    27  {     
    28       $this->pageTitle = $username . '\'s Comments'; 
     26  public function view($username=null, $entry_id=null) 
     27  {     
     28    $this->pageTitle = $username . '\'s Comments'; 
    2929       
    30       $conditions      = array("status"=>1); 
     30    $conditions      = array("status"=>1); 
    3131       
    32       if ($username != null): 
    33             $user_id    = $this->User->field('id', array("username"=>$username)); 
    34             $conditions["user_id"] = $user_id; 
    35       endif; 
     32    if ($username != null): 
     33      $user_id    = $this->User->field('id', array("username"=>$username)); 
     34    $conditions["user_id"] = $user_id; 
     35    endif; 
    3636       
    37       if ($entry_id != null): 
    38             $conditions["id"] = $entry_id;   
    39       endif; 
     37    if ($entry_id != null): 
     38      $conditions["id"] = $entry_id;   
     39    endif; 
    4040       
    41       $fields     = array("id", "title", "description", "pubdate", "size"); 
    42       $order      = "id DESC"; 
    43       $limit      = 12; 
     41    $fields     = array("id", "title", "description", "pubdate", "size"); 
     42    $order      = "id DESC"; 
     43    $limit      = 12; 
    4444       
    45       $this->set('username',$username); 
    46       $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit, null, true));  
    47  } 
     45    $this->set('username',$username); 
     46    $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit, null, true));  
     47  } 
    4848  
    49  public function add()  
    50  { 
    51    if (!empty($this->data["Comment"]) ): 
    52         
    53        $this->Sanitize = new Sanitize; 
     49  public function add()  
     50  { 
     51    if (!empty($this->data["Comment"]) ): 
     52          
     53      $this->Sanitize = new Sanitize; 
    5454        
    55        $this->Sanitize->clean($this->data["Comment"]); //Hopefully this is enough 
     55    $this->Sanitize->clean($this->data["Comment"]); //Hopefully this is enough 
    5656        
    57        $this->Comment->create(); 
     57    $this->Comment->create(); 
    5858        
    59        if ($this->Comment->save($this->data["Comment"])): 
    60            $this->msgFlash('Comment added', $this->data['Comment']['redirect_to'].'/#comments'); 
    61        endif; 
    62    endif; 
    63  } 
     59    if ($this->Comment->save($this->data["Comment"])): 
     60      $this->msgFlash('Comment added', $this->data['Comment']['redirect_to'].'/#comments'); 
     61    endif; 
     62    endif; 
     63  } 
    6464  
    65  /**    ===== ADMIN METHODS ====== **/ 
     65  /**    ===== ADMIN METHODS ====== **/ 
    6666  
    67  // change status enabled/disabled actived 
    68  public function admin_change($comment_id, $status) 
    69  {  
    70      $this->data['Comment']['status'] = ($status == 0 ) ? 1 : 0; 
     67  // change status enabled/disabled actived 
     68  public function admin_change($comment_id, $status) 
     69  {  
     70    $this->data['Comment']['status'] = ($status == 0 ) ? 1 : 0; 
    7171      
    72      $this->data['Comment']['id']     = $comment_id; 
     72    $this->data['Comment']['id']     = $comment_id; 
    7373       
    74      if ($this->Comment->save($this->data['Comment'])): 
    75         $this->msgFlash('Comment status changed', '/admin/entries/comments'); 
    76      endif; 
    77  } 
     74    if ($this->Comment->save($this->data['Comment'])): 
     75      $this->msgFlash('Comment status changed', '/admin/entries/comments'); 
     76    endif; 
     77  } 
    7878  
    79  public function admin_edit($id=null) 
    80  {    
    81      $this->layout    = 'admin'; 
     79  public function admin_edit($id=null) 
     80  {    
     81    $this->layout    = 'admin'; 
    8282      
    83      if ( empty( $this->data["Comment"] ) ): 
    84          $this->data      = $this->Comment->read(null, $id); 
    85      else: 
    86          $this->Sanitize = new Sanitize; 
     83    if ( empty( $this->data["Comment"] ) ): 
     84      $this->data      = $this->Comment->read(null, $id); 
     85    else: 
     86    $this->Sanitize = new Sanitize; 
    8787          
    88          $this->Sanitize->html($this->data["Comment"]["comment"]); 
     88    $this->Sanitize->html($this->data["Comment"]["comment"]); 
    8989          
    90          if ($this->Comment->save($this->data["Comment"])):   
    91              $this->msgFlash('Comment saved!', '/admin/comments/edit/'.$this->data["Comment"]["id"]); 
    92     endif; 
    93      endif; 
    94  } 
     90    if ($this->Comment->save($this->data["Comment"])):   
     91      $this->msgFlash('Comment saved!', '/admin/comments/edit/'.$this->data["Comment"]["id"]); 
     92    endif; 
     93    endif; 
     94  } 
    9595  
    96  public function admin_delete($id) 
    97  { 
    98    if ($this->Comment->del($id)): 
    99         $this->msgFlash('Comment deleted', '/admin/comments/listing'); 
    100    endif; 
    101  } 
     96  public function admin_delete($id) 
     97  { 
     98    if ($this->Comment->del($id)): 
     99      $this->msgFlash('Comment deleted', '/admin/comments/listing'); 
     100    endif; 
     101  } 
    102102} 
    103103?>