Changeset 348

Show
Ignore:
Timestamp:
03/26/08 12:17:56 (10 months ago)
Author:
aarkerio
Message:

Fix help bug report

Location:
trunk/app
Files:
2 added
4 modified

Legend:

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

    r247 r348  
    33*  Chipotle Software TM 
    44*  Manuel Montoya 2002-2008  
    5 *  GPLv3 manuel<at>mononeurona<dot>org 
     5*  GPLv3 manuel<arroba>mononeurona<punto>org 
    66*/  
    77 
     
    1212 public $helpers       = array('Javascript', 'Ajax', 'Fck', 'Gags'); 
    1313    
    14  public $components    = array('Portal', 'Edublog'); 
     14 public $components    = array('Portal', 'Edublog', 'Email'); 
    1515 
     16 public function beforeFilter()  
     17 { 
     18     $this->Auth->allow(array('display', 'tour')); 
     19     parent::beforeFilter(); 
     20 } 
     21   
    1622 public function isAuthorized()  
    17  { 
    18     if ($this->action == 'delete')  
    19       { 
    20     if ($this->Auth->user('group_id') == 1)  
    21           { 
    22         return true; 
    23           } else { 
    24         return false; 
    25           } 
    26       } 
    27   
    28     return true; 
    29   } 
     23 {       
     24    if (isset( $this->params[Configure::read('Routing.admin')] ))  
     25    { 
     26         if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 )  // admin and teachers 
     27     { 
     28           return true; 
     29         }  
     30    }  
     31        return false;  // go away !! 
     32 } 
    3033 
    3134 public function tour()  
     
    5457        $this->set('data', $this->Help->findAll($conditions, $fields)); 
    5558 } 
    56  
    57  public function newticket()  
     59  
     60 /**  === ADMIN METHODS === **/ 
     61 //bug report 
     62 public function admin_newticket()  
    5863 { 
    5964        $this->layout    = 'admin'; 
     
    6368        $this->set('data', $this->Help->findAll($conditions, $fields)); 
    6469 } 
     70  
     71 public function admin_submit() 
     72 {      
     73       if ( !empty( $this->data['Help'] ) ) 
     74       {   
     75      $this->Sanitize = new Sanitize; 
     76           
     77          $this->Sanitize->clean($this->data['Help']); 
     78       
     79      $report  = $this->Auth->user('username') .' with email '. $this->Auth->user('email') .', wrote: '; 
     80       
     81      $report .= $this->data['Help']['report'] .'.  Kind: ' . $this->data['Help']['kind']; 
     82       
     83          if ( $this->_sendNewReport( $report ) ) 
     84          { 
     85                 $this->msgFlash('Email sent, Thanks!', '/admin/entries/start'); 
     86      } 
     87           
     88        } 
     89 } 
     90  
    6591 public function about()  
    6692 { 
     
    6995        $this->set('Element', $this->Portal->statics()); // Charge Portal components aka Sidebars 
    7096 } 
    71     
    72  /** 
    73   === ADMIN METHODS ===  
    74  **/ 
    75     
    76    public function admin_listing() 
    77    { 
     97  
     98 public function admin_listing() 
     99 { 
    78100      $this->layout = 'admin'; 
    79101      $conditions = null; 
     
    84106       
    85107      $this->set('data', $this->Help->findAll($conditions, $fields, $order)); 
    86    } 
    87     
    88    public function admin_add()  
    89    { 
     108 } 
     109  
     110 public function admin_add()  
     111 { 
    90112     $this->layout = 'admin'; 
    91  
     113      
    92114     if (!empty($this->data['Help'])) 
    93115     { 
     
    125147        } 
    126148    } 
    127 } 
    128    
    129   public function admin_delete($id) 
    130   { 
     149 } 
     150  
     151 public function admin_delete($id) 
     152 { 
    131153      $this->Help->del($id); 
    132154      $this->msgFlash('Help deleted','/admin/helps/listing'); 
    133155  } 
     156   
     157 /** ===PRIVATE ===*/ 
     158 private function _sendNewReport($report)  
     159 { 
     160    $this->Email->to       = 'mmontoya@gmail.com'; 
     161    $this->Email->bcc      = array('contact@chipotle-software.com');  // note 
     162    // this could be just a string too 
     163    $this->Email->subject  = 'Karamelo e-Learning:: bug report'; 
     164    $this->Email->replyTo  = 'support@karamelo.org'; 
     165    $this->Email->from     = 'Chipotle-software.com'; 
     166    $this->Email->template = 'report'; // note no '.ctp' 
     167    //Send as 'html', 'text' or 'both' (default is 'text') 
     168    $this->Email->sendAs   = 'text'; // because we like to send pretty mail 
     169    //Set view variables as normal 
     170    $this->set('report', $report); 
     171    //Do not pass any args to send()  
     172    if ( $this->Email->send() )  
     173    { 
     174            return true;  
     175    }  
     176    else 
     177    { 
     178            return false; 
     179    } 
     180 } 
    134181} 
    135182?> 
  • trunk/app/views/elements/admin_menu.ctp

    r319 r348  
    4545  </li> 
    4646 
    47   <li><a href="/helps/index/set">Help</a> 
     47  <li><?php echo $html->link('Helps', '/admin/helps/listing'); ?> 
    4848        <ul> 
    49           <li><a href="/helps/newticket">Report Bug</a> </li> 
    50            <li><a href="http://www.chipotle-software.com/index.php?id=9">Get support</a> </li> 
     49          <li><?php echo $html->link('Report bug', '/admin/helps/newticket'); ?> </li> 
     50           <li><?php echo $html->link('Get support', 'http://www.chipotle-software.com/index.php?id=9'); ?></li> 
    5151       </ul> 
    5252  </li> 
  • trunk/app/views/elements/login.ctp

    r342 r348  
    44<legend> Login</legend> 
    55  <?php  
    6    echo  $form->input('User.email', array('size' => 15, 'maxlength'=> 45)) . '<br />'; 
    7    echo  $form->label('User.pwd', 'Password: '); 
    8    echo  $form->password('User.pwd', array('id' => 'user_pwd', 'size' => 9, 'maxlength' => 9)); 
     6   echo  $form->input('User.email', array('size' => 15, 'maxlength'=> 45, 'between'=>'<br />')) . '<br />'; 
     7   echo  $form->label('User.pwd', 'Password: ').'<br />'; 
     8   echo  $form->password('User.pwd', array('id' => 'user_pwd', 'size' => 9, 'maxlength' => 9)) . '<br />'; 
    99   echo  $form->label('User.remember_me', 'Remember me: '); 
    1010   echo  $form->checkbox('User.remember_me'); 
  • trunk/app/views/helps/newticket.ctp

    r303 r348  
    11<h1>Reporting bugs</h1> 
    2  
    3 <p>You can help the Karamelo developrment team by reporting bugs and making suggestions to improve this application. </p> 
    4  
    5  
    6  
    72<?php  
    8  
    9   echo $form->create('Help', array('admin_submit')); 
    10  
     3  echo $html->para(null, 'You can help the Karamelo development team by reporting bugs and making suggestions to improve this application.'); 
     4  echo $form->create('Help', array('action'=>'submit')); 
     5   
    116  echo $form->label('Help.report', 'Description:') . '<br />'; 
    127  echo $form->textarea('Help.report', array('rows'=>8, 'cols'=>60)) . '<br />'; 
    13  
     8   
    149  echo $form->label('Help.kind', 'Kind:') . '<br />'; 
    1510  echo $form->select('Help.kind', array('Enhancement'=>'Enhancement', 'Bug'=>'Bug', 'Suggestion'=>'Suggestion'), null, null, false) . '<br />'; 
    16  
     11   
    1712  echo $form->end('Send'); 
    18  
     13   
    1914  $html->link('Submit new ticket', 'http://trac.mononeurona.org/karamelo/newticket');  
    2015