Show
Ignore:
Timestamp:
02/22/08 13:58:35 (11 months ago)
Author:
aarkerio
Message:

Changes on users and entries

Files:
1 modified

Legend:

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

    r77 r246  
    11<?php 
    22/**  
    3 Chipotle Software  
    4 GPL v3 
     3*   Chipotle Software 2002-2008 
     4*   GPLv3  manuel<arroba>mononeurona<punto>org  
    55**/ 
    66//File: /app/controllers/comentnews_controller.php 
    77 
    88uses('sanitize'); 
    9 loadModel('News'); 
    10 loadModel('User'); 
    119 
    1210class CommentnewsController extends AppController 
    1311{ 
    14     public $name       = 'Commentnews'; 
     12 public $name       = 'Commentnews'; 
    1513     
    16     public $helpers    = array('Form', 'Javascript', 'Ajax', 'Time', 'Gags'); 
     14 public $helpers    = array('Javascript', 'Ajax', 'Time', 'Gags'); 
    1715     
    18     public $components = array('Security', 'Captcha', 'Email'); 
     16 public $components = array('Security', 'Captcha', 'Email'); 
     17 
     18 public function isAuthorized()  
     19 { 
     20   if ( $this->Auth->user('group') != 1 )  
     21   { 
     22     $this->Auth->deny(array('admin_delete', 'admin_listing', 'admin_edit')); 
     23   } 
     24   if ( $this->Auth->user() ) 
     25   { 
     26     $this->Auth->allow(array('newcomment')); 
     27   } 
     28  return true; 
     29 } 
    1930     
    20  public function add() 
    21  {       
    22         if ( ! empty($this->data["Commentnews"]) ) 
    23          { 
    24            $this->Sanitize = new Sanitize; 
     31 public function newcomment() 
     32 { 
     33   die('sadsadasdsa');   
     34   die(var_dump($this->data)); 
     35 
     36   if ( !empty($this->data["Commentnews"]) ) 
     37   { 
     38     $this->Sanitize = new Sanitize; 
    2539            
    26            $this->Sanitize->cleanArray($this->data); 
     40     $this->Sanitize->cleanArray($this->data); 
    2741            
    28            $this->data["Commentnews"]["comment"] = nl2br($this->data["Commentnews"]["comment"]); 
     42     $this->data["Commentnews"]["comment"] = nl2br($this->data["Commentnews"]["comment"]); 
    2943            
    30            if ( $this->othAuth->user('id') ) 
    31            { 
    32               $this->data["Commentnews"]["user_id"] = $this->othAuth->user('id'); 
    33            } 
    34            else 
    35            { 
    36                if ($this->data["Commentnews"]["captcha"] != $this->Session->read('captcha') || strlen($this->data["Commentnews"]["captcha"]) < 3) 
    37                { 
    38                   $this->flash('Code incorrect, please pulse back button', '/news/display/'.$this->data["Commentnews"]["new_id"], 20);  //    wrong captcha, spambot ?? 
    39                   exit(); 
    40                } 
     44     if ( $this->Auth->user('id') ) 
     45     { 
     46              $this->data["Commentnews"]["user_id"] = $this->Auth->user('id'); 
     47     } 
     48     else 
     49     { 
     50       if ($this->data["Commentnews"]["captcha"] != $this->Session->read('captcha') || strlen($this->data["Commentnews"]["captcha"]) < 3) 
     51       { 
     52         $this->flash('Code incorrect, please pulse back button', '/news/view/'.$this->data["Commentnews"]["new_id"], 6);  // wrong captcha, spambot ?? 
     53         exit(); 
     54       } 
    4155                 
    42                 $this->data["Commentnews"]["user_id"] = 0; 
    43            } 
     56         $this->data["Commentnews"]["user_id"] = 0; 
     57     } 
    4458             
    45           if ( $this->Commentnews->save($this->data["Commentnews"]) ) //save the comment 
    46           { 
    47                 $this->News = new News; 
     59      if ( $this->Commentnews->save($this->data["Commentnews"]) ) //save the comment 
     60      { 
     61          $this->News = new News; 
    4862                 
    49                 $user_id  = $this->News->field('user_id', array("News.id"=>$this->data["Commentnews"]["new_id"])); 
     63          $user_id  = $this->News->field('user_id', array("News.id"=>$this->data["Commentnews"]["new_id"])); 
    5064                 
    51                 $this->sendMail($user_id, $this->data["Commentnews"]["new_id"]); 
     65          $this->sendMail($user_id, $this->data["Commentnews"]["new_id"]); 
    5266                 
    53                 $this->redirect('/news/display/'.$this->data["Commentnews"]["new_id"].'#cnews'); 
    54           } 
     67          $this->redirect('/news/view/'.$this->data["Commentnews"]["new_id"].'#cnews'); 
    5568       } 
     69    } 
    5670 } 
    5771  
     
    7084        $data = $this->User->find(array("User.id"=>$user_id), $fields); 
    7185        //exit($data["User"]["email"]); 
    72         $this->Email->sender    = '::MonoNeurona.org::'; 
     86        $this->Email->sender    = '::Karamelo::'; 
    7387        $this->Email->to        = $data["User"]["email"]; 
    74         $this->Email->subject   = '::MonoNeurona.org:: New comment on your front-page New'; 
     88        $this->Email->subject   = '::Karamelo:: New comment on your front-page New'; 
    7589        $this->Email->sendAs    = 'html'; 
    7690        $this->Email->template  = null; 
     
    8094        //Note: the text can be an array, each element will appear as a 
    8195        //seperate line in the message body. 
    82         $url   = '<img src="http://www.mononeurona.org/img/admin/new_user.jpg" alt="MonoNeurona" title="MonoNeurona" /><br />'; 
     96        $url   = 'Karamelo<br />'; 
    8397        $url  .= '<h2>'.$data["User"]["username"].'</h2><p>You have a new comment in your new: '; 
    84         $url  .= '<a href="http://'.$_SERVER['SERVER_NAME'].'/news/display/'.$new_id.'">'; 
    85         $url  .= 'http://'.$_SERVER['SERVER_NAME'].'/news/display/'.$new_id.'</a></p>'; 
     98        $url  .= '<a href="http://'.$_SERVER['SERVER_NAME'].'/news/view/'.$new_id.'">'; 
     99        $url  .= 'http://'.$_SERVER['SERVER_NAME'].'/news/view/'.$new_id.'</a></p>'; 
    86100         
    87101        //die($url); 
     
    101115 public function admin_listing($limit=20) 
    102116 { 
    103       $this->layout    = 'admin'; 
    104       $this->pageTitle = 'Comments on Blogs'; 
     117   $this->layout    = 'admin'; 
     118 
     119   $this->pageTitle = 'Comments on Blogs'; 
    105120       
    106       $conditions      = null; 
    107       $fields          = array("Commentnews.id", "News.title", "Commentnews.id", "Commentnews.comment", "Commentnews.created", "Commentnews.name", "Commentnews.user_id"); 
    108       $order           = "Commentnews.id DESC"; 
     121   $conditions  = null; 
     122 
     123   $fields = array("Commentnews.id", "News.title", "Commentnews.id", "Commentnews.comment", "Commentnews.created", "Commentnews.name", "Commentnews.user_id"); 
     124   $order           = "Commentnews.id DESC"; 
    109125        
    110       $this->set('data', $this->Commentnews->findAll($conditions, $fields, $order, $limit, null, 2)); 
     126   $this->set('data', $this->Commentnews->findAll($conditions, $fields, $order, $limit, null, 2)); 
    111127 } 
    112128  
     
    136152 public function admin_delete($id) 
    137153 { 
    138         // deletes task from database 
    139         $this->Commentnews->del($id); 
    140         $this->msgFlash('Comment deleted', '/admin/commentnews/listing'); 
     154    // deletes comment on database 
     155    $this->Commentnews->del($id); 
     156    $this->msgFlash('Comment deleted', '/admin/commentnews/listing'); 
    141157  } 
    142158}