Changeset 400

Show
Ignore:
Timestamp:
04/15/08 23:02:23 (9 months ago)
Author:
aarkerio
Message:

Comment on new

Location:
trunk/app
Files:
1 added
11 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/app_controller.php

    r374 r400  
    11<?php 
    22/** 
    3 *     Karamelo eLearning Platform 
    4 *     Chipotle Software 2002-2008 
    5 *     GPLv3 manuel<arroba>mononeurona<punto>org 
    6 **/ 
     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*/ 
     10//file: app_controller.php 
    711 
    812class AppController extends Controller { 
     
    2428     $this->set('cU', $this->Auth->user());  // $cU current user array to use in the views if user logged 
    2529 } 
    26  
     30   
    2731 public function msgFlash($msg, $to) 
    2832 { 
  • trunk/app/controllers/acquaintances_controller.php

    r393 r400  
    88*  @package Karamelo 
    99*/ 
     10// file: app/controllers/acquaitances_controller.php 
    1011 
    1112uses('sanitize'); 
     
    5051 /** === ADMIN METHODS === ***/ 
    5152 public function admin_listing() 
    52  {     
    53       $this->layout    = 'admin'; 
     53 {  
     54   $this->layout = 'admin'; 
     55    
     56   $conditions   = array("user_id" => $this->Auth->user('id')); 
    5457       
    55       $conditions   = array("user_id" => $this->Auth->user('id')); 
     58   //$fields     = array("id", "title", "description", "pubdate", "size"); 
    5659       
    57       //$fields     = array("id", "title", "description", "pubdate", "size"); 
    58        
    59       $this->set('data', $this->Acquaintance->findAll($conditions)); 
     60   $this->set('data', $this->Acquaintance->findAll($conditions)); 
    6061 } 
    6162  
    6263 public function admin_add($id = null) 
    6364 { 
     65    $this->layout = 'admin'; 
     66 
    6467    if (empty($this->data["Acquaintance"])) 
    6568    { 
    66         $this->layout = 'admin'; 
    67          
    6869        $this->Acquaintance->id = $id; 
    6970         
     
    8889  
    8990 public function admin_edit($id = null) 
    90   { 
     91 { 
     92    $this->layout = 'admin'; 
     93 
    9194    if (empty($this->data["Acquaintance"])) 
    9295    { 
    93         $this->layout = 'admin'; 
    94          
    9596        $this->data = $this->Acquaintance->read(null, $id); 
    9697    } 
  • trunk/app/controllers/answers_controller.php

    r393 r400  
    6363 public function admin_edit($answer_id = null) 
    6464 {   
    65     $this->layout = 'admin'; 
    66      
    6765    if (empty($this->data["Answer"])) 
    6866    {    
     
    9997  public function admin_questions($test_id) 
    10098  { 
    101        $this->layout    = 'admin'; 
    102          
    10399        $this->pageTitle = 'Answers'; 
    104100         
  • trunk/app/controllers/commentnews_controller.php

    r394 r400  
    1212uses('sanitize'); 
    1313 
     14App::import('Model','User'); 
     15 
    1416class CommentnewsController extends AppController 
    1517{ 
     
    1921     
    2022 public $components = array('Captcha'); 
     23 
     24 public function beforeFilter()  
     25 { 
     26    $this->Auth->allow(array('captcha', 'insert', 'rss')); 
     27    parent::beforeFilter(); 
     28 } 
    2129 
    2230 public function isAuthorized()  
     
    3543 { 
    3644    
    37    die(var_dump($this->data)); 
     45   //die(var_dump($this->data)); 
    3846 
    39    if ( !empty($this->data["Commentnews"]) ) 
     47   if ( !empty($this->data['Commentnews']) ) 
    4048   { 
    4149     $this->Sanitize = new Sanitize; 
    4250            
    43      $this->Sanitize->clean($this->data); 
     51     $this->Sanitize->clean($this->data['Commentnews']); 
    4452            
    45      $this->data["Commentnews"]["comment"] = nl2br($this->data["Commentnews"]["comment"]); 
     53     $this->data['Commentnews']['comment'] = nl2br($this->data['Commentnews']['comment']); 
    4654            
    4755     if ( $this->Auth->user('id') ) 
    4856     { 
    49               $this->data["Commentnews"]["user_id"] = $this->Auth->user('id'); 
     57          $this->data['Commentnews']['user_id'] = $this->Auth->user('id'); 
    5058     } 
    5159     else 
     
    5765       } 
    5866                 
    59          $this->data["Commentnews"]["user_id"] = 0; 
     67         $this->data['Commentnews']['user_id'] = 0; 
    6068     } 
    6169      
    6270     $this->Commentnews->create(); 
    6371          
    64      if ( $this->Commentnews->save($this->data["Commentnews"]) ) //save the comment 
     72     if ( $this->Commentnews->save($this->data['Commentnews']) ) //save the comment 
    6573     { 
    66           $this->News = new News; 
     74          $user_id  = $this->Commentnews->News->field('user_id', array('News.id'=>$this->data['Commentnews']['new_id'])); 
    6775                 
    68           $user_id  = $this->News->field('user_id', array("News.id"=>$this->data["Commentnews"]["new_id"])); 
     76          $this->__sendMail($user_id, $this->data['Commentnews']['new_id']); 
    6977                 
    70           $this->sendMail($user_id, $this->data["Commentnews"]["new_id"]); 
    71                  
    72           $this->redirect('/news/view/'.$this->data["Commentnews"]["new_id"].'#cnews'); 
    73        } 
     78          $this->redirect('/news/view/'.$this->data['Commentnews']['new_id'].'#cnews'); 
     79     } 
     80   } 
     81 } 
     82   
     83 /* == PRIVATE == **/ 
     84 private function _sendEmail($user_id, $new_id) 
     85 {   
     86   $User = new User; 
     87 
     88   $this->User->unbindModel(array("hasMany"=>array('Entry', 'Lesson', 'Faq', 'Vclassroom', 'Acquaintance')));                 
     89                                                                               
     90   $user = $this->User->find(array('User.id'=>$user_id), array("User.name", "User.email")); 
     91  
     92    $this->layout          = 'newcomment'; 
     93    $this->Email->to       = $user['email']; 
     94    $this->Email->subject  = 'Karamelo e-Learning:: New comment'; 
     95    $this->Email->replyTo  = 'support@karamelo.org'; 
     96    $this->Email->from     = 'Chipotle-software.com'; 
     97    $this->Email->template = 'confirmation'; // note no '.ctp' 
     98    //Send as 'html', 'text' or 'both' (default is 'text') 
     99    $this->Email->sendAs   = 'text'; // because we like to send pretty mail 
     100    //Set view variables as normal 
     101    $this->set('name',   $user['name']); 
     102    $this->set('new_id', $new_id); 
     103 
     104    //Do not pass any args to send()  
     105    if ( $this->Email->send() )  
     106    { 
     107            return true;  
     108    }  
     109    else 
     110    { 
     111            return false; 
    74112    } 
    75113 } 
    76   
     114 
    77115 public function captcha() 
    78116 { 
    79117       return $this->Captcha->render(); 
    80118 } 
    81   
    82  private function sendMail($user_id, $new_id)  
    83  { 
    84          
    85         $this->User = new User; 
    86          
    87         $fields = array('email', 'username'); 
    88          
    89         $data = $this->User->find(array("User.id"=>$user_id), $fields); 
    90         //exit($data["User"]["email"]); 
    91         $this->Email->sender    = '::Karamelo::'; 
    92         $this->Email->to        = $data["User"]["email"]; 
    93         $this->Email->subject   = '::Karamelo:: New comment on your front-page New'; 
    94         $this->Email->sendAs    = 'html'; 
    95         $this->Email->template  = null; 
    96         $this->Email->from      = 'noreply@mononeurona.org'; 
    97         //$this->set('foo', 'Cake tastes good today');  
    98         //Set the body of the mail as we send it. 
    99         //Note: the text can be an array, each element will appear as a 
    100         //seperate line in the message body. 
    101         $url   = 'Karamelo<br />'; 
    102         $url  .= '<h2>'.$data["User"]["username"].'</h2><p>You have a new comment in your new: '; 
    103         $url  .= '<a href="http://'.$_SERVER['SERVER_NAME'].'/news/view/'.$new_id.'">'; 
    104         $url  .= 'http://'.$_SERVER['SERVER_NAME'].'/news/view/'.$new_id.'</a></p>'; 
    105          
    106         //die($url); 
    107          
    108         if ( $this->Email->send($url) )  
    109         { 
    110             return true;  
    111         }  
    112         else  
    113         { 
    114              
    115             exit("Error!!"); 
    116         } 
    117  }   
    118   
     119 
    119120/*****#### ADMIN METHODS  #####*****/ 
    120121 public function admin_listing($limit=20) 
  • trunk/app/controllers/entries_controller.php

    r394 r400  
    7373  
    7474 public function admin_add() 
    75  { 
    76    $this->layout    = 'admin'; 
     75 {  
     76   $this->layout = 'admin'; 
    7777 
    7878   $this->set('subjects', Set::combine($this->Entry->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 
     
    104104 public function admin_start($order = null) 
    105105 { 
    106         if (!$this->Auth->user('id')) 
    107         { 
    108             die($this->redirect('/users/general')); // Get Out!!! 
    109         } 
     106     $this->layout = 'admin'; 
     107 
     108     if ( !$this->Auth->user()) 
     109     { 
     110            $this->redirect('/users/login'); // Get Out!!! 
     111     } 
    110112         
    111         $this->layout    = 'admin'; 
    112         $this->pageTitle = 'Entries'; 
    113          
    114         $conditions = null; 
    115         $fields     = array("id", "title", "body", "subject_id"); 
    116         $data       = $this->Entry->findAll( $conditions, $fields, $order, null, null, true ); 
    117          
    118         $this->set('data', $data);  
    119   } 
     113     $this->pageTitle = 'Welcome! '. $this->Auth->user('username'); 
     114 } 
    120115   
    121    public function admin_listing($page=1, $order = null)  
    122    { 
    123        $this->layout    = 'admin'; 
     116 public function admin_listing($page=1, $order = null)  
     117 {  
     118    $this->layout = 'admin';       
     119 
     120    $conditions = array("Entry.user_id"=>$this->Auth->user('id')); 
    124121        
    125        $conditions = array("Entry.user_id"=>$this->Auth->user('id')); 
     122    $fields     = null; 
    126123        
    127        $fields     = null; 
     124    $limit      = 20; 
    128125        
    129        $limit      = 20; 
    130         
    131        $this->set('data', $this->Entry->findAll($conditions, $fields, $order, $limit)); 
    132   } 
     126    $this->set('data', $this->Entry->findAll($conditions, $fields, $order, $limit)); 
     127 } 
    133128   
    134   public function admin_edit($id = null) 
    135   { 
    136      $this->layout    = 'admin';   
    137      
    138      $this->set('subjects', Set::combine($this->Entry->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 
     129 public function admin_edit($id = null) 
     130 { 
     131   $this->layout = 'admin';     
     132 
     133   $this->set('subjects',Set::combine($this->Entry->Subject->find('all',array('order'=>'title')),"{n}.Subject.id","{n}.Subject.title")); 
    139134      
    140      if (empty($this->data["Entry"])) 
     135     if (empty($this->data['Entry'])) 
    141136     { 
    142137         $this->data = $this->Entry->read(null, $id); 
     
    146141         $this->Sanitize = new Sanitize; 
    147142       
    148          $this->Sanitize->paranoid($this->data["Entry"]["title"]); 
     143         $this->Sanitize->paranoid($this->data['Entry']['title']); 
    149144          
    150          $this->Sanitize->html($this->data["Entry"]["body"]); 
     145         $this->Sanitize->html($this->data['Entry']['body']); 
    151146 
    152147         if ($this->Entry->save($this->data['Entry'])) 
  • trunk/app/controllers/news_controller.php

    r336 r400  
    11<?php 
    22/** 
    3  *  Karamelo E-Learning Platform 
    4  *  Manuel Montoya 2002-2008  
    5  *  GPLv3 License manuel<at>mononeurona<punto>org 
    6  *  Chipotle Software 
    7 */  
     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*/ 
     10//file:  app/controllers/news_controller.php 
    811 
    912uses('Sanitize'); 
     
    1114class NewsController extends AppController { 
    1215   
    13   public $helpers          = array('Ajax', 'Fck', 'News', 'Time', 'Gags'); 
    14    
    15   public $components       = array('Portal'); 
    16    
    17   public function beforeFilter()  
     16 public $helpers          = array('Ajax', 'Fck', 'News', 'Time', 'Gags'); 
     17   
     18 public $components       = array('Portal'); 
     19   
     20 public function beforeFilter()  
    1821 { 
    19     $this->Auth->allow(array('view', 'display', 'rss')); 
     22    $this->Auth->allow(array('view', 'display', 'rss', 'category')); 
    2023    parent::beforeFilter(); 
    2124 } 
     
    9497  } 
    9598   
    96    public function category($id = null, $order=null)  
     99   public function category($id=null, $order=null)  
    97100   {   
    98101      $this->layout = 'portal'; 
    99102       
    100       if ($id != null) 
    101       { 
    102         $conditions["Theme.id"] = $id; 
     103      if ($id == null) 
     104      { 
     105         $this->redirect('/'); 
    103106      } 
     107 
     108      $conditions = array('Theme.id' => $id); 
    104109       
    105110      $fields = array("News.id", "News.title", "Theme.theme", "Theme.img"); 
     
    107112      $this->pageTitle = 'News Category'; 
    108113       
    109       $limit = null; 
    110        
    111       $this->News->bindModel( 
    112         array('belongsTo' => array( 
    113                 'Theme' => array( 
    114                     'className' => 'Theme' 
    115                  ) 
    116              ) 
    117           ) 
    118       ); 
     114      $limit = 30; 
    119115       
    120116      $this->set('data', $this->News->findAll($conditions, $fields, $order, $limit)); 
    121117       
    122       $this->set('Element', $this->Portal->statics()); // Charge Portal components aka Sidebars 
     118      $this->Portal->statics();  // Charge Portal components aka Sidebars 
    123119   } 
    124120   
  • trunk/app/controllers/newsletters_controller.php

    r361 r400  
    6666  } 
    6767 
    68   /*** 
    69   === ADMIN METHODS 
    70   ***/  
     68  /***  === ADMIN METHODS ***/  
    7169 
    7270  public function admin_add() 
    7371  { 
    74     $this->layout    = 'admin'; 
    75   
    7672    if (!empty($this->data['Newsletter'])) 
    7773    { 
     
    150146  public function admin_edit($newsletter_id=null) 
    151147  { 
    152     $this->layout    = 'admin'; 
    153   
    154148    if (!empty($this->data['Newsletter'])) 
    155149    {  
     
    186180        $this->pageTitle = $this->Auth->user('username') . '\'s News'; 
    187181         
    188         $this->layout = 'admin'; 
    189          
    190182        $conditions   = null; //array("Newsletter.status" => 1); 
    191183        $fields       = array("id", "title", "body", "created", "status", "delivered"); 
  • trunk/app/controllers/replies_controller.php

    r333 r400  
    3434     $this->Edublog->blog($user_id); 
    3535      
    36      $conditions = array("Reply.status"=>1, "Reply.id"=>$topic_id); 
     36     $conditions = array('Reply.status'=>1, 'Reply.id'=>$topic_id); 
    3737     $fields     = null; 
    38      $order      = "Reply.created DESC"; 
     38     $order      = 'Reply.created DESC'; 
    3939      
    4040     $this->set('data', $this->Reply->find($conditions, $fields, $order)); 
     
    6060 } 
    6161  
    62  /** 
    63     ---  ADMIN METHODS  --- 
    64  **/ 
     62 /**    ---  ADMIN METHODS  ---  **/ 
    6563  
    6664 public function admin_edit($id = null) 
  • trunk/app/controllers/wikis_controller.php

    r371 r400  
    11<?php 
    22/** 
    3 *  Karamelo E-Learning Platform -- Chipotle Software TM 
    4 *  Manuel Montoya 2002-2008  
    5 *  GPLv3 manuel<arroba>mononeurona<punto>org 
    6 */  
     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*/ 
     10//File: /app/controllers/commentnews_controller.php 
    711 
    812uses('sanitize'); 
  • trunk/app/views/news/display.ctp

    r399 r400  
    11<?php 
    2 //die(debug($data)); 
     2// die(debug($data)); 
    33 
    44echo $html->div('title_section', 'News'); 
     
    66foreach ($data as $val) 
    77{ 
    8   //echo $ajax->divEnd('wrapnew'); 
    9   echo $html->div('news_title', $html->link($val['News']['title'], '/news/view/'. $val['News']['id'])); 
     8  $tmp  = $html->div('news_title', $html->link($val['News']['title'], '/news/view/'. $val['News']['id'])); 
    109   
    11   echo $html->div('news_date',  $val['News']['created']); 
     10  $tmp .= $html->div('news_date',  $val['News']['created']); 
    1211 
    13   echo $html->div('news_body', 
     12  $tmp .= $html->div('news_body', 
    1413                            $html->div('img_new', $html->link( 
    15                                                           $html->image('themes/'.$data['Theme']['img'],  
    16                                                                             array('alt'=>$data['Theme']['theme'],  
    17                                                                                    'title'=>$data['Theme']['theme'],  
     14                                                          $html->image('themes/'.$val['Theme']['img'],  
     15                                                                            array('alt'=>$val['Theme']['theme'],  
     16                                                                                   'title'=>$val['Theme']['theme'],  
    1817                                                                                   'class'=>'themes') 
    1918                                                                           ),  
    20                                   '/news/category/'.$data['News']['theme_id'], null, null, false 
     19                                  '/news/category/'.$val['News']['theme_id'], null, null, false 
    2120                                                   ) 
    2221                                      ) 
     
    2423   
    2524   
    26   echo $val['News']['body']; 
     25  $tmp .= $val['News']['body']; 
    2726   
    2827  if (strlen($val['News']['reference'])  > 5 )  // the reference 
    2928  { 
    30       echo $html->div(null, $html->link('Reference: ', $val['News']['reference'])); 
     29      $tmp .= $html->div(null, $html->link('Reference', $val['News']['reference'])); 
    3130  } 
    32    
    33    echo '</div>'; 
     31     
     32  echo $html->div('wrapnew', $tmp);  
    3433 } 
    3534?> 
  • trunk/app/views/news/view.ctp

    r399 r400  
    5959<p> 
    6060<?php  
    61    echo $form->create('Commentnews',array("action"=>"add","onsubmit"=>"return validateNew()")); 
    62    echo $form->hidden('Commentnews.new_id', $data['News']['id']);  
    63    echo $form->hidden('Commentnews.level', 1); 
    64    echo $form->hidden('Commentnews.comentnew_id', 1); 
     61   echo $form->create('Commentnews', array('action'=>'add',"onsubmit"=>"return validateNew()")); 
     62   echo $form->hidden('Commentnews.new_id', array('value'=>$data['News']['id']));  
     63   echo $form->hidden('Commentnews.level', array('value'=>1)); 
     64   echo $form->hidden('Commentnews.comentnew_id', array('value'=>1)); 
    6565?> 
    6666<fieldset> 
    6767   <legend>Add comment:</legend> 
    68  
    6968  <?php  
    7069   if ( isset( $cU['User']['id'] ) )  
    7170   { 
    72        echo $form->hidden('Commentnews.user_id', $cU['User']['id']); 
    73        echo $form->hidden('Commentnews.name', $cU['User']['username']); 
    74        echo '<b>'. $cU['User']['username'] . '</b>  writes. '; 
     71       echo $form->hidden('Commentnews.user_id', array('value'=> $cU['User']['id'])); 
     72       echo $form->hidden('Commentnews.name',  array('value'=>$cU['User']['username'])); 
     73       echo '<b>'. $cU['User']['username'] . '</b>  write: <br />'; 
    7574  } 
    7675  else 
    7776  { 
    78       echo $form->hidden('Commentnews.user_id', 0); 
    79       echo $form->input('Commentnews.name', array("size" => 25, "maxlength" => 50)); 
    80       echo $form->label('Commentnews.name', ' Name:' ); 
    81       echo $form->error('Commentnews.name', 'Name is required.'); 
     77      echo $form->hidden('Commentnews.user_id', array('value'=> 0)); 
     78      echo $form->input('Commentnews.name', array('size'=> 25, 'maxlength' => 40)); 
    8279      
    83       echo '<br /><br /> <img src="'. $html->url('/comentnews/captcha') .'" alt="Captcha" /> <br />'; 
     80      echo '<br /><br /> <img src="'. $html->url('/comentnews/captcha') .'" alt="Captcha" title="Captcha" /> <br />'; 
    8481      echo $form->input('Commentnews.captcha', array("size" => 6, "maxlength" => 6)); 
    85       echo $form->label('Commentnews.cptcha', 'Introduce el codigo, todas la letras son minusculas' ); 
     82      echo $form->label('Commentnews.captcha', 'Introduce el código, todas la letras son minúsculas' ); 
    8683  } 
    8784   
    88   echo $form->label('Commentnews.comment', 'Comment:' ); 
    89   echo $form->textarea('Commentnews.comment', array("cols"=>70, "rows"=>10)); 
    90   echo $form->error('Commentnews.comment', 'Comment is required.'); ?> 
    91   <br /> 
    92  </p> 
    93    
    94   <br /> 
    95      <?php echo $form->end('Add comment') ?> 
    96 </fieldset> 
     85  echo $form->textarea('Commentnews.comment', array('cols'=>60, 'rows'=>10)); 
    9786 
    98      <?php } ?> 
     87?> 
     88