Changeset 409

Show
Ignore:
Timestamp:
04/18/08 14:30:29 (9 months ago)
Author:
aarkerio
Message:

Discussions fixed

Location:
trunk/app
Files:
4 added
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/core.php

    r407 r409  
    1414 * In development mode, you need to click the flash message to continue. 
    1515 */ 
    16     Configure::write('debug', 1); 
     16    Configure::write('debug', 2); 
    1717/** 
    1818 * Application wide charset encoding 
     
    7575 * 
    7676 */ 
    77     Configure::write('Session.save', 'cake'); 
     77    Configure::write('Session.save', 'database'); 
    7878/** 
    7979 * The name of the table used to store CakePHP database sessions. 
     
    199199 *                  ); 
    200200 */ 
    201     Cache::config('default', array('engine' => 'File')); 
     201     Cache::config('default', array('engine' => 'File')); 
    202202?> 
  • trunk/app/config/sql/karamelo_postgres.sql

    r401 r409  
    148148 "level" int NOT NULL, 
    149149 "discussion_id" int NOT NULL, 
    150  "user_id" int REFERENCES news(id) NOT NULL, 
     150 "user_id" int REFERENCES users(id) NOT NULL, 
    151151 "status" int NOT NULL DEFAULT 0 
    152152); 
  • trunk/app/controllers/discussions_controller.php

    r407 r409  
    1616class DiscussionsController extends AppController 
    1717{ 
    18  public $name = 'Discussions'; 
     18 public $name          = 'Discussions'; 
    1919 
    20  public $helpers    = array('Ajax', 'Time', 'Gags'); 
    21      
    22  public $components = array('Captcha'); 
     20 public $helpers       = array('Ajax', 'Gags'); 
     21 
     22 public $components    = array('Captcha', 'Email'); 
    2323 
    2424 public function beforeFilter()  
    2525 { 
    26     $this->Auth->allow(array('captcha', 'agregar', 'renka')); 
     26    $this->Auth->allow(array('captcha', 'add')); 
    2727    parent::beforeFilter(); 
    2828 } 
     
    4040 } 
    4141 
    42  public function agregar() 
     42 public function add() 
    4343 { 
    44   
    45   $this->layout = 'portal'; 
    46    
    47   echo 'I am in agregar function !!!<br />'; 
    48  
    49   die(debug($this->data)); 
     44   //die(debug($this->data)); 
    5045 
    5146   if ( !empty($this->data['Discussion']) ) 
    5247   { 
     48     $this->data['Discussion']['level']         = 1; 
     49     $this->data['Discussion']['discussion_id'] = 1; 
     50 
    5351     $this->Sanitize = new Sanitize; 
    5452            
     
    5755     $this->data['Discussion']['comment'] = nl2br($this->data['Discussion']['comment']); 
    5856            
    59      if ( $this->Auth->user('id') ) 
     57     if ( $this->Auth->user() ) 
    6058     { 
    61           $this->data['Discussion']['user_id'] = $this->Auth->user('id'); 
     59          $this->data['Discussion']['user_id']  = $this->Auth->user('id'); 
     60          $this->data['Discussion']['username'] = $this->Auth->user('username'); 
    6261     } 
    6362     else 
    6463     { 
    65        if ($this->data['Discussion']['captcha'] != $this->Session->read('captcha') || strlen($this->data['Discussion']['captcha']) < 3) 
     64       /*if ($this->data['Discussion']['captcha'] != $this->Session->read('captcha') || strlen($this->data['Discussion']['captcha']) < 3) 
    6665       { 
    6766         $this->flash('Code incorrect, please pulse back button', '/news/view/'.$this->data["Discussion"]["new_id"], 6);  // wrong captcha, spambot ?? 
    68          exit(); 
    69        } 
     67       } */ 
    7068                 
    7169         $this->data['Discussion']['user_id'] = 0; 
     
    8482   } 
    8583 } 
    86    
     84 
    8785 /* == PRIVATE == **/ 
    88  private function __sendEmail($user_id, $new_id) 
     86 private function __sendMail($user_id, $new_id) 
    8987 {   
    90    $User = new User; 
     88   $this->User = new User; 
    9189 
    9290   $this->User->unbindModel(array("hasMany"=>array('Entry', 'Lesson', 'Faq', 'Vclassroom', 'Acquaintance')));                 
    9391                                                                               
    94    $user = $this->User->find(array('User.id'=>$user_id), array("User.name", "User.email")); 
    95   
    96     $this->layout          = 'newcomment'; 
    97     $this->Email->to       = $user['email']; 
     92   $val = $this->User->find(array('User.id'=>$user_id), array("User.name", "User.email")); 
     93    
     94    $this->layout          = 'default'; 
     95    $this->Email->to       = $val['User']['email']; 
    9896    $this->Email->subject  = 'Karamelo e-Learning:: New comment'; 
    9997    $this->Email->replyTo  = 'support@karamelo.org'; 
    10098    $this->Email->from     = 'Chipotle-software.com'; 
    101     $this->Email->template = 'confirmation'; // note no '.ctp' 
     99    $this->Email->template = 'newdiscussion'; // note no '.ctp' 
    102100    //Send as 'html', 'text' or 'both' (default is 'text') 
    103101    $this->Email->sendAs   = 'text'; // because we like to send pretty mail 
    104102    //Set view variables as normal 
    105     $this->set('name',   $user['name']); 
     103    $this->set('name',   $val['User']['name']); 
    106104    $this->set('new_id', $new_id); 
    107105 
     
    115113            return false; 
    116114    } 
    117  } 
    118  
    119  public function renka() 
    120  { 
    121    $this->layout = 'portal'; 
    122    //return $this->Captcha->render(); 
    123115 } 
    124116 
  • trunk/app/controllers/users_controller.php

    r374 r409  
    1919 public function beforeFilter()  
    2020 { 
    21     $this->Auth->allow(array('blog', 'entry','portfolio', 'about', 'register', 'directory', 'bloggers', 'insert', 'validate')); 
     21    $this->Auth->allow(array('blog', 'entry','portfolio', 'about', 'register', 'directory', 'bloggers', 'insert', 'validate', 'logout')); 
    2222    parent::beforeFilter(); 
    2323 } 
  • trunk/app/views/news/display.ctp

    r401 r409  
    66foreach ($data as $val) 
    77{ 
    8   $tmp  = $html->div('news_title', $html->link($val['News']['title'], '/news/view/'. $val['News']['id'])); 
     8  echo '<div class="wrapnew">'; 
     9  
     10  echo $html->div('news_title', $html->link($val['News']['title'], '/news/view/'. $val['News']['id'])); 
    911   
    10   $tmp .= $html->div('news_date',  $val['News']['created']); 
     12  echo $html->div('news_date',  $val['News']['created']); 
    1113 
    12   $tmp .= $html->div('news_body', 
     14  echo $html->div('news_body', 
    1315                            $html->div('img_new', $html->link( 
    1416                                                          $html->image('themes/'.$val['Theme']['img'],  
     
    2325   
    2426   
    25   $tmp .= $val['News']['body']; 
    26    
    27   if (strlen($val['News']['reference'])  > 5 )  // the reference 
     27  echo $val['News']['body']; 
     28 
     29  if ($val['News']['comments'] == 1 )  // comments enabled on this new 
    2830  { 
    29       $tmp .= $html->div(null, $html->link('Reference', $val['News']['reference'])); 
    30   } 
    31     
    32   if ($val['News']['comments'] == 1 )  // the reference 
    33   { 
    34     $tmp .= $html->div(null, $html->link('Put your comment', '/news/view/'.$val['News']['id'])); 
     31    echo $html->para(null, $html->link('Put your comment', '/news/view/'.$val['News']['id'])); 
    3532  }  
    36   echo $html->div('wrapnew', $tmp);  
     33 
     34 
     35?> 
     36  <br /> 
     37    <span style="font-size:7pt;">Permalink:</span> <br /> 
     38    <?php echo $html->link( 
     39               'http://'.$_SERVER['SERVER_NAME'].'/news/view/'.$val['News']['id'],  
     40                           'http://'.$_SERVER['SERVER_NAME'].'/news/view/'.$val['News']['id'] 
     41               );  
     42?> 
     43    <br /><br /> 
     44    <b>Reference:</b> 
     45     
     46    <?php echo $html->link( 
     47                           $html->image('static/newwindow.gif', array("alt"=>"Open new window", "title"=>"Open new window")), 
     48                           $val['News']['reference'], 
     49                           array("onclick"=>"window.open(this.href, '_help', 'status,scrollbars,resizable,width=800,height=600,left=10,top=10,menubar,toolbar')"),  
     50                           null, 
     51                           null, 
     52                           false); 
     53       
     54echo $news->socialNets($val['News']['id'], $val['News']['title']); // Social nets buttons 
     55       
     56     
     57 
     58  echo '</div>'; 
    3759 } 
    3860?> 
  • trunk/app/views/news/view.ctp

    r407 r409  
    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['username']    . '</b> wrote:<br />'; 
    4949      echo $v["comment"]; 
    5050      echo "</div>"; 
     
    5353  echo "</div>"; 
    5454 
    55   echo $form->create('Discussion', array('action'=>'agregar')); 
    56   //echo '<form action="/discussions/agregar" method="post">'; 
     55if ( isset( $cU['User']['id'] ) ): 
     56  echo $form->create('Discussion', array('action'=>'add')); 
     57  echo $form->hidden('Discussion.new_id', array('value'=>$data['News']['id']));  
    5758?> 
    58  
    59  
    6059<fieldset> 
    6160   <legend>Write comment:</legend> 
    6261<?php  
    63   echo $form->hidden('Discussion.new_id', array('value'=>$data['News']['id']));  
    64   echo $form->hidden('Discussion.level', array('value'=>1)); 
    65   echo $form->hidden('Discussion.comentnew_id', array('value'=>1)); 
    66  
    67   if ( isset( $cU['User']['id'] ) ): 
    68        echo $form->hidden('Discussion.user_id', array('value'=> $cU['User']['id'])); 
    69        echo $form->hidden('Discussion.name',  array('value'=>$cU['User']['username'])); 
    70        echo '<b>'. $cU['User']['username'] . '</b>  write: <br />'; 
    71  
    72   else: 
    73  
    74       echo $form->hidden('Discussion.user_id', array('value'=> 0)); 
    75       echo $form->input('Discussion.name', array('size'=> 25, 'maxlength' => 40)); 
    76       // echo '<br /><br /> <img src="'. $html->url('/discussions/captcha') .'" alt="Captcha" title="Captcha" /> <br />'; 
    77       //echo $form->input('Discussion.captcha', array("size" => 6, "maxlength" => 6)); 
    78       //echo $form->label('Discussion.captcha', 'Introduce el código, todas la letras son minúsculas' ).'<br />'; 
    79   endif; 
    80    
    81   echo $form->textarea('Discussion.comment', array('cols'=>60, 'rows'=>10)) . $form->end('Send comment');  
    82  
     62    echo $form->label('Discussion.comment', '<b>'. $cU['User']['username'] . '</b>  write:').'<br />';  
     63    echo $form->textarea('Discussion.comment', array('cols'=>60, 'rows'=>10)); 
     64    echo $form->end('Send comment'); 
     65 else: 
     66    echo $html->para(null, $html->link('Login to write comments', '/users/login'));  
     67 endif;  
    8368}  
    8469?>