Changeset 699 for trunk/app/controllers

Show
Ignore:
Timestamp:
08/06/08 17:10:36 (4 months ago)
Author:
aarkerio
Message:

New validate arrays

Location:
trunk/app/controllers
Files:
2 modified

Legend:

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

    r698 r699  
    4848 public function view($username, $catglossary_id) 
    4949 { 
    50        $this->pageTitle = 'Glossary'; 
     50       $this->pageTitle = __('Glossary', true); 
    5151        
    5252       $user_id    = $this->Catglossary->User->field('id', array("User.username"=>$username)); 
  • trunk/app/controllers/messages_controller.php

    r696 r699  
    2323         $this->Auth->allow(array('message','deliver','listing','compose','display','add','send','autocomplete','sentmessages','delete')); 
    2424  else: 
    25          $this->redirect('/users/login'); 
    26          return false; 
     25         $this->Auth->allow(array('message', 'fromoutside')); 
    2726  endif; 
    2827 } 
     
    3029 public function message($username) // show form to send message to teacher 
    3130 {       
    32         $this->pageTitle = 'Contact'; 
    33          
    34     $user_id = $this->Message->User->field('id', array('username'=>$username)); 
     31  $this->pageTitle = __('Contact', true); 
     32         
     33  $user_id = $this->Message->User->field('id', array('username'=>$username)); 
    3534         
    36         $this->layout    = $this->Edublog->layout($user_id); 
    37          
    38         $this->Edublog->blog($user_id); 
     35  $this->layout    = $this->Edublog->layout($user_id); 
     36         
     37  $this->Edublog->blog($user_id); 
    3938 } 
    4039  
     
    6463       
    6564      $this->set('nick', $nick); 
     65 } 
     66 
     67 public function fromoutside() 
     68 { 
     69   if (!empty($this->data['Message'])): 
     70       
     71      $this->Sanitize = new Sanitize; 
     72            
     73      $this->Sanitize->clean($this->data['Message']); 
     74       
     75      $msg  = (string) $this->data['Message']['title'] ."\n"; 
     76      $msg .= $this->data['Message']['body'] ."\n";  
     77      $msg .= __('Email', true).': '.$this->data['Message']['email'];  
     78       
     79      if ($this->__sendOutside($this->data['Message']['user_id'], $msg)): 
     80          $this->render('sent', 'ajax');  
     81      else: 
     82          $this->getSupport(); 
     83      endif; 
     84   endif; 
    6685 } 
    6786/* 
     
    7190 public function deliver() 
    7291 {     
    73     if (!empty($this->data['Message'])): 
     92  if (!empty($this->data['Message'])): 
    7493       
    7594      $this->Sanitize = new Sanitize; 
     
    195214 
    196215  /* == PRIVATE == **/ 
    197   private function __sendMail($user_id) 
    198   {  
    199     $email = $this->Message->User->field('User.email', array('User.id'=>$user_id));   
     216 private function __sendMail($user_id) 
     217 {  
     218    $email = $this->Message->User->field('User.email', array('User.id'=>$user_id)); 
    200219    $this->layout          = 'default'; 
    201220    $this->Email->to       = $email; 
     
    209228    //Do not pass any args to send() 
    210229    if ( $this->Email->send() ): 
    211               return true; 
     230           return true; 
    212231    else: 
    213                   return false; 
     232           return false; 
    214233    endif; 
    215234 } 
    216235 
    217   private function __sendAll($user_id, $vclassroom_id, $blogger_id) 
    218   {  
     236 private function __sendOutside($user_id, $msg) 
     237 {   
     238    $this->Message->User->unbindAll(); 
     239    $email = $this->Message->User->field('User.email', array('User.id'=>$user_id)); 
     240    $this->layout          = 'default'; 
     241    $this->Email->to       = $email; 
     242 
     243    // this could be just a string too 
     244    $this->Email->subject  = 'Karamelo e-Learning:: New message from anonymous'; 
     245    $this->Email->replyTo  = 'support@karamelo.org'; 
     246    $this->Email->from     = 'Chipotle-software.com'; 
     247    $this->Email->template = 'anonymous';  
     248    $this->Email->sendAs   = 'text'; // because we like to send pretty mail 
     249    //Do not pass any args to send() 
     250    $this->set('msg', $msg); 
     251 
     252    if ( $this->Email->send() ): 
     253           return true; 
     254    else: 
     255           return false; 
     256    endif; 
     257 } 
     258 
     259 private function __sendAll($user_id, $vclassroom_id, $blogger_id) 
     260 {  
    219261    $email = $this->Message->User->field('User.email', array('User.id'=>$user_id)); 
    220262