Changeset 653

Show
Ignore:
Timestamp:
07/15/08 14:38:50 (3 months ago)
Author:
aarkerio
Message:

Messages and news imprved

Location:
trunk/app
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/sql/postgresql/news.sql

    r436 r653  
    55  body text NOT NULL, 
    66  created timestamp(0) with time zone DEFAULT now() NOT NULL, 
    7   reference varchar(350) NOT NULL, 
     7  reference varchar(350), 
    88  theme_id int NOT NULL REFERENCES themes(id) ON DELETE CASCADE, 
    99  status smallint NOT NULL,   -- 0 = draft, 1 = published 
  • trunk/app/controllers/discussions_controller.php

    r636 r653  
    1414class DiscussionsController extends AppController 
    1515{ 
    16  public $name          = 'Discussions'; 
    17  
    1816 public $helpers       = array('Ajax', 'Gags'); 
    1917 
     
    4644     $this->data['Discussion']['comment'] = nl2br($this->data['Discussion']['comment']); 
    4745            
    48      if ( $this->Auth->user() ) 
    49      { 
     46     if ( $this->Auth->user() ): 
    5047          $this->data['Discussion']['user_id']  = $this->Auth->user('id'); 
    5148          $this->data['Discussion']['username'] = $this->Auth->user('username'); 
    52      } 
    53      else 
    54      { 
     49     else: 
    5550       /*if ($this->data['Discussion']['captcha'] != $this->Session->read('captcha') || strlen($this->data['Discussion']['captcha']) < 3) 
    5651       { 
     
    5954                 
    6055         $this->data['Discussion']['user_id'] = 0; 
    61      } 
     56     endif; 
    6257          
    6358     if ( $this->Discussion->save($this->data) ):  //save the comment 
     
    6762          $this->__sendMail($user_id, $this->data['Discussion']['new_id']); 
    6863                 
    69           $this->redirect('/news/view/'.$this->data['Discussion']['new_id'].'#cnews'); 
     64          $this->msgFlash(__('Message waiting for approval', true), '/news/view/'.$this->data['Discussion']['new_id'].'#cnews'); 
    7065     endif; 
    7166   } 
     
    115110   $this->layout    = 'admin'; 
    116111 
    117    $this->pageTitle = 'Comments on News'; 
     112   $this->pageTitle = __('Comments on News', true); 
    118113 
    119114   $this->Discussion->bindModel(array('belongsTo'=> array('News' =>array('className'=> 'News', 'foreignKey'=> 'new_id' ))));    
     115    
     116   $this->paginate['fields'] = array('Discussion.id','News.id','News.title','Discussion.id','Discussion.comment', 'Discussion.created', 'Discussion.user_id', 'Discussion.status', 'User.username');  
     117   $this->paginate['conditions']   = null; 
     118   $this->paginate['order']        = "Discussion.id DESC"; 
     119   $this->paginate['limit']        = 30; 
     120   $data = $this->paginate('Discussion'); 
    120121 
    121    $conditions  = null; 
    122     
    123    $fields = array('Discussion.id','News.id','News.title','Discussion.id','Discussion.comment', 'Discussion.created', 'Discussion.user_id', 'Discussion.status', 'User.username'); 
    124  
    125    $order  = "Discussion.id DESC"; 
    126     
    127    $limit  = 50;      
     122   $this->set(compact('data')); 
    128123     
    129    $this->set('data', $this->Discussion->findAll($conditions, $fields, $order, $limit)); 
    130124 } 
    131125  
  • trunk/app/controllers/messages_controller.php

    r652 r653  
    6565      $this->set('nick', $nick); 
    6666 } 
    67   
     67/* 
     68 * deliver method, used to deliver message in /messages/message and /message/compose  views 
     69 * 
     70 */ 
    6871 public function deliver() 
    69  { 
    70      
     72 {     
    7173    if (!empty($this->data['Message'])): 
    7274       
    73            $this->Sanitize = new Sanitize; 
    74             
    75            $this->Sanitize->html($this->data['Message']['title']); 
    76             
    77            $this->Sanitize->html($this->data['Message']['body']); 
    78             
    79            $this->data['Message']['sender']   = $this->Auth->user('id');  
    80            $this->data['Message']['username'] = $this->Auth->user('username'); 
    81  
    82            if ( $this->Message->save($this->data) ): 
    83                 $this->__sendMail($this->data['Message']['user_id']); 
     75      $this->Sanitize = new Sanitize; 
     76            
     77      $this->Sanitize->html($this->data['Message']['title']); 
     78            
     79      $this->Sanitize->html($this->data['Message']['body']); 
     80            
     81      $this->data['Message']['sender']   = $this->Auth->user('id');  
     82            
     83      if ( !isset( $this->data['Message']['user_id'] ) ): 
     84        $this->data['Message']['user_id'] = $this->Message->User->field('User.id',array('User.username'=>trim($this->data['Message']['sender']))); 
     85      endif; 
     86 
     87      if ( $this->Message->save($this->data) ): 
     88            $this->__sendMail($this->data['Message']['user_id']); 
     89            if ( isset($this->data['Message']['ajax']) ): 
     90           $this->render('sent', 'ajax');     
     91        else: 
    8492            $this->msgFlash(__('Message sent', true), '/messages/listing'); 
    85            endif; 
     93            endif; 
     94      endif; 
    8695   endif; 
    8796 } 
  • trunk/app/controllers/news_controller.php

    r648 r653  
    119119         
    120120      $this->layout = 'admin'; 
    121          
    122       $conditions   = array("News.user_id" => $this->Auth->user('id') );             // only the user's news 
    123       $fields       = array("id", "title", "body", "created", "reference", "status", "theme_id", "user_id"); 
    124       $order        = "News.id DESC"; 
    125       $limit      = 20; 
    126          
    127       $this->set('data', $this->News->findAll($conditions, $fields, $order, $limit));  
     121      $this->News->unbindModel(array('hasMany'=>array('Discussion')));   
     122      $this->paginate['conditions']   = null; 
     123      $this->paginate['fields']       = array('News.id', 'News.title', 'News.created', 'News.status',  'News.user_id', 'User.username'); 
     124      $this->paginate['order']        = 'News.id DESC'; 
     125      $this->paginate['limit']        = 20; 
     126      $data = $this->paginate('News'); 
     127 
     128      $this->set(compact('data')); 
    128129  } 
    129130   
  • trunk/app/locale/spa/LC_MESSAGES/default.po

    r652 r653  
    44msgid  "View all Lessons" 
    55msgstr "Todas las lecciones" 
     6 
     7msgid  "Message waiting for approval" 
     8msgstr "Mensaje en espera de aprobación" 
    69 
    710msgid  "Your current groups" 
  • trunk/app/views/discussions/admin_listing.ctp

    r636 r653  
    11<?php 
    22//die(debug($data)); 
    3 echo $html->addCrumb('Control Tools', '/admin/news/start');  
    4 echo $html->addCrumb('Comments', '/admin/comments/listing');  
     3echo $html->addCrumb('Control Panel', '/admin/news/start');  
     4echo $html->addCrumb(__('News', true), '/admin/news/listing');  
    55echo $html->getCrumbs(' / ');  
    66  
    7 echo $html->div('title_section', 'Comments on News'); 
     7echo $html->div('title_section', __('Comments on News', true)); 
    88 
    99foreach ($data as $val): 
     
    1616   echo $html->div('grayblock', $tmp); 
    1717endforeach; 
     18 
     19 
     20$t  = $html->div(null,$paginator->prev('« '. __('Previous', true).' ',null,null,array('class'=>'disabled')),array('style'=>'width:100px;float:left')); 
     21$t .= $html->div(null, $paginator->next(' '.__('Next', true).' »', null, null, array('class' => 'disabled')),array('style'=>'width:100px;float:right')); 
     22$t .= $html->div(null,$paginator->counter(), array('style'=>'width:200px;float:center')); 
     23echo  $html->div(null,$t, array('style'=>'font-size:9pt;width:400px;margin:15px auto;')); 
    1824?> 
  • trunk/app/views/messages/message.ctp

    r652 r653  
    1515  echo $ajax->form(); 
    1616  echo $form->hidden('Message.user_id', array('value'=>$blog['User']['id'])); 
     17  echo $form->hidden('Message.ajax', array('value'=>1)); 
    1718?> 
    1819<fieldset> 
    1920  <legend>Message to teacher from <?php echo $session->read('Auth.User.username'); ?>:</legend> 
    2021     <?php  
    21         echo $form->input('Message.title', array("size" => 30, "maxlength" => 50));  
     22        echo $form->input('Message.title', array('size' => 30, 'maxlength' => 50, 'label'=>__('Title', true), 'between'=>': '));  
    2223        echo $form->error('Message.title', 'Title is required.');  
    2324         
     
    3132                                         "complete" => "Element.hide('charging');Effect.Appear('updater')" 
    3233        ));  
    33         ?> 
     34   ?> 
    3435</fieldset> 
    3536</form> 
  • trunk/app/views/messages/sent.ctp

    r257 r653  
    1 <p>Message sent</p> 
     1<?php 
     2e($html->para(null, __('Thx', true).'! '.__('Message sent', true))); 
     3?> 
  • trunk/app/views/news/admin_listing.ctp

    r620 r653  
    11<?php 
     2//die(debug($data)); 
    23  echo $html->div('title_section', __('News', true)); 
    3   echo $html->link($html->image('actions/new.png', array("alt"=>"Add new", "title"=>"Add new")), '/admin/news/add', null, false, false); 
     4  echo $html->link($html->image('actions/new.png', array('alt'=>__('Add new', true), 'title'=>__('Add new', true))), '/admin/news/add', null, false, false); 
     5  echo '&nbsp;&nbsp;&nbsp;';  
    46  echo $html->link($html->image('static/forum.gif', array("alt"=>"See comments", "title"=>"See comments")), '/admin/discussions/listing', null, false, false); 
    57?> 
     
    79<?php 
    810 
    9 $th = array ('Edit', 'Title', 'Status', 'Delete'); 
     11$th = array(__('Edit', true), __('Title', true), __('Author', true), __('Status', true), __('Delete', true)); 
    1012echo $html->tableHeaders($th);   
    1113foreach ($data as $key=>$val): 
     
    1416        $gags->sendEdit($val['News']['id'], 'news'), 
    1517        $val['News']['title'], 
     18        $val['User']['username'], 
    1619        $html->link($st, '/admin/news/change/'.$val['News']['status'].'/'.$val['News']['id']), 
    1720        $gags->confirmDel($val['News']['id'], 'news') 
     
    2629 
    2730<?php  
    28 // echo $pagination;  
     31$t  = $html->div(null,$paginator->prev('« '.__('Previous', true). ' ',null,null,array('class'=>'disabled')),array('style'=>'width:100px;float:left')); 
     32$t .= $html->div(null, $paginator->next(' '.__('Next', true). ' »', null, null, array('class' => 'disabled')),array('style'=>'width:100px;float:right')); 
     33$t .= $html->div(null,$paginator->counter(), array('style'=>'width:200px;float:center')); 
     34echo  $html->div(null,$t, array('style'=>'font-size:9pt;width:400px;margin:15px auto;')); 
    2935?> 
  • trunk/app/views/news/display.ctp

    r636 r653  
    5252endforeach; 
    5353 
    54 $t  = $html->div(null,$paginator->prev('« Previous ',null,null,array('class'=>'disabled')),array('style'=>'width:100px;float:left')); 
    55 $t .= $html->div(null, $paginator->next(' Next »', null, null, array('class' => 'disabled')),array('style'=>'width:100px;float:right')); 
     54$t  = $html->div(null,$paginator->prev('«'. __('Previous', true).' ',null,null,array('class'=>'disabled')),array('style'=>'width:100px;float:left')); 
     55$t .= $html->div(null, $paginator->next(' '.__('Next', true).' »', null, null, array('class' => 'disabled')),array('style'=>'width:100px;float:right')); 
    5656$t .= $html->div(null,$paginator->counter(), array('style'=>'width:200px;float:center')); 
    5757echo  $html->div(null,$t, array('style'=>'font-size:9pt;width:400px;margin:15px auto;'));