Changeset 346

Show
Ignore:
Timestamp:
03/25/08 12:38:24 (10 months ago)
Author:
aarkerio
Message:

Newsletter fixed

Location:
trunk/app
Files:
1 added
6 removed
9 modified

Legend:

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

    r292 r346  
    183183} 
    184184 
    185   /*** DELETE  **/  
    186   public function admin_delete() 
    187   { 
     185 /*** DELETE  **/  
     186 public function admin_delete() 
     187 { 
    188188    $file = $this->Image->field("Image.file", array("Image.id"=>$this->data['Image']['id'])); 
    189189     
     
    194194    unlink("../webroot/img/imgusers/thumbs/" . $file); 
    195195    $this->redirect($this->data['Image']['return']); 
    196   } 
     196 } 
    197197   
    198   protected function createThumb($file)  
    199   {      
     198 protected function createThumb($file)  
     199 {      
    200200     $imgfile        = "../webroot/img/imgusers/"           .  $file;            // system path 
    201201      
  • trunk/app/controllers/newsletters_controller.php

    r328 r346  
    108108  } 
    109109 
    110   private function sendNewsletter($newsletter_id) 
     110  private function _sendNewsletter($newsletter_id) 
    111111  { 
    112112     $conditions   = array("Newsletter.status" => 1, "Newsletter.id" => $newsletter_id); 
     
    153153  
    154154    if (!empty($this->data['Newsletter'])) 
    155     { 
     155    {  
    156156       $this->Sanitize = new Sanitize; 
    157157                
    158        $this->Sanitize->paranoid($this->data["Newsletter"]["title"]); 
    159  
    160        $this->Sanitize->html($this->data["Newsletter"]["body"]); 
    161                 
    162        $this->data["Newsletter"]['user_id'] = $this->Auth->user('id'); 
    163      
    164        $this->Newsletter->create(); 
     158       $this->Sanitize->paranoid($this->data['Newsletter']['title']); 
     159 
     160       $this->Sanitize->html($this->data['Newsletter']['body']); 
    165161    
    166162      if ($this->Newsletter->save($this->data['Newsletter'])) 
    167           {  
    168                $this->msgFlash('Newsletter saved', '/admin/newsletter/listing'); 
     163          { 
     164           if ( $this->data['Newsletter']['end'] == 1  )  
     165           { 
     166                   $this->msgFlash('Newsletter saved', '/admin/newsletters/listing'); 
     167               } 
     168               else 
     169               { 
     170                   $this->msgFlash('Newsletter saved', '/admin/newsletters/edit/'.$this->data['Newsletter']['id']);  
     171           } 
    169172          }  
    170173          else  
     
    172175            $this->flash('Database error!', '/news/listing'); 
    173176          } 
     177    } 
     178    else 
     179    { 
     180       $this->data     = $this->Newsletter->read(null, $newsletter_id); 
    174181    } 
    175182  } 
  • trunk/app/controllers/vclassrooms_controller.php

    r328 r346  
    33*  Karamelo eLearning Platform 
    44*  Manuel Montoya 2002-2008 
    5 *  GPLv3 manuel<at>mononeurona<punto>org 
     5*  GPLv3 manuel<arroba>mononeurona<punto>org 
    66*/  
    77  
     
    1313  
    1414 public $components    = array('Edublog'); 
    15   
     15 
     16 public function beforeFilter() 
     17 { 
     18      $this->Auth->allow(array('show', 'jointoclass')); 
     19      parent::beforeFilter(); 
     20 } 
    1621 public function isAuthorized() 
    1722 { 
     
    7075 } 
    7176  
    72  //Check if the user already exist in the classroom 
    73  protected function chkMember($vclassroom_id) 
    74  {  
    75    $already_member = false; 
    76  
    77    $conditions = array('"Vclassroom"."id"'=>$vclassroom_id); 
    78    
    79    $data = $this->Vclassroom->find($conditions); 
    80     
    81    foreach ($data['User'] as $user) 
    82    { 
    83       if ($user['id'] == $this->Auth->user('id'))     
    84       { 
    85        $already_member = true;  // yes, is already member 
    86       }    
    87    } 
    88   
    89    return $already_member;  
    90  } 
    91  
    92   
    93 /*** 
    94    == ADMIN METHODS 
    95 ***/    
     77 /***   == ADMIN METHODS === ***/    
    9678 
    9779 public function admin_listing() 
  • trunk/app/models/vclassroom.php

    r340 r346  
    6363                         ) 
    6464                    ); 
     65 //Check if the user already exist in the classroom 
     66 protected function chkMember($vclassroom_id) 
     67 {  
     68   $already_member = false; 
     69 
     70   $conditions = array('"Vclassroom"."id"'=>$vclassroom_id); 
     71   
     72   $data = $this->find($conditions); 
     73    
     74   foreach ($data['User'] as $user) 
     75   { 
     76      if ($user['id'] == $this->Auth->user('id'))     
     77      { 
     78       $already_member = true;  // yes, is already member 
     79      }    
     80   } 
     81   return $already_member;  
     82 } 
    6583 
    6684  public $validate = array( 
  • trunk/app/views/events/admin_edit.ctp

    r314 r346  
    1616<table style="margin:0 auto 0 auto;"> 
    1717<tr><td> 
    18 <?php echo $html->formTag('/admin/entries/edit/','post'); ?> 
    19 <?php echo $html->hiddenTag('Entry/user_id', $othAuth->user('id')) ?> 
    20 <?php echo $html->hiddenTag('Entry/id') ?> 
     18<?php echo $html->formTag('Event'); ?> 
     19<?php echo $html->hiddenTag('Event.id') ?> 
    2120 
    22   <?php echo $form->labelTag( 'Entry/title', 'Title' );?><br />  
    23   <?php echo $html->input('Entry/title', array("size" => 40, "maxlength" => 50, "class"=>"formas")); ?> 
    24   <?php echo $html->tagErrorMsg('Entry/title', 'Title is required.'); ?> 
     21  <?php echo $form->labelTag( 'Event.title', 'Title' );?><br />  
     22  <?php echo $html->input('Event.title', array("size" => 40, "maxlength" => 50, "class"=>"formas")); ?> 
     23  <?php echo $html->tagErrorMsg('Event.title', 'Title is required.'); ?> 
    2524  </td> 
    2625  <td> 
    27        <?php echo $form->labelTag('Entry/subject_id', 'Subject:' );?> 
    28        <?php echo $html->selectTag('Entry/subject_id', $subjects); ?> 
     26       <?php echo $form->labelTag('Event.subject_id', 'Subject:' );?> 
     27       <?php echo $html->selectTag('Event.subject_id', $subjects); ?> 
    2928  </td> 
    3029   <td> 
     
    3433  <tr> 
    3534  <td colspan="3"> 
    36       <?php echo $form->labelTag( 'Entry/Body', 'Body:' );?><br /> 
    37       <?php echo $html->textarea('Entry/body', array("class"=>"formas", "cols"=>80, "rows"=>45)) ?> 
    38       <?php echo $fck->load('Entry/body', 'Karamelo'); ?>  
    39       <?php echo $html->tagErrorMsg('Entry/body', 'Body is required.'); ?> 
     35      <?php echo $form->labelTag( 'Event.Body', 'Body:' );?><br /> 
     36      <?php echo $html->textarea('Event.body', array("class"=>"formas", "cols"=>80, "rows"=>45)) ?> 
     37      <?php echo $fck->load('Event.body', 'Karamelo'); ?>  
     38      <?php echo $html->tagErrorMsg('Event.body', 'Body is required.'); ?> 
    4039  </td></tr> 
    4140  <tr> 
    4241  <td> 
    43       <?php echo $form->labelTag( 'Entry/status', 'Published:' );?><br /> 
    44       <?php echo $html->checkbox('Entry/status', null, array("value" => 1)); ?> 
     42      <?php echo $form->labelTag( 'Event.status', 'Published:' );?><br /> 
     43      <?php echo $html->checkbox('Event.status', null, array("value" => 1)); ?> 
    4544  </td> 
    4645  <td> 
    47       <?php echo $form->labelTag( 'Entry/discution', 'Comments allowed:' );?><br /> 
    48       <?php echo $html->checkbox('Entry/discution', null, array("value" => 1)); ?> 
     46      <?php echo $form->labelTag( 'Event.discution', 'Comments allowed:' );?><br /> 
     47      <?php echo $html->checkbox('Event.discution', null, array("value" => 1)); ?> 
    4948  </td> 
    5049  <td> 
    51        <?php echo $form->labelTag( 'Entry/end', 'Finish edition:' );?><br /> 
    52        <?php echo $html->checkbox('Entry/end', null, array("value" => 1)); ?> 
     50       <?php echo $form->labelTag( 'Event.end', 'Finish edition:' );?><br /> 
     51       <?php echo $html->checkbox('Event.end', null, array("value" => 1)); ?> 
    5352   </td> 
    5453  </tr> 
    5554  <tr> 
    5655  <td colspan="3"> 
    57        <?php echo $html->submit('Save') ?> 
    58        </form> 
     56       <?php echo $form->end('Save'); ?> 
    5957  </td> 
    6058  </tr> 
  • trunk/app/views/images/admin_listview.ctp

    r268 r346  
    4242 <br /> 
    4343   <?php  
    44    if ( $othAuth->user('id') == $val['Image']['user_id'] ) 
     44   if ( $cU['User']['id'] == $val['Image']['user_id'] ) 
    4545   { 
    46         echo  $html->formTag('/admin/images/delete/'.$val['Image']['id'], 'post'); 
    47         echo $html->hiddenTag('Image/return', '/admin/images/listing'); 
    48         echo  $html->submit('Delete'); 
    49         echo "</form>"; 
     46        echo $form->create('Image', array('action'=>'admin_delete')); 
     47        echo $form->hidden('Image.return', array('value'=>'/admin/images/listing')); 
     48        echo $form->hidden('Image.id', array('value'=>$val['Image']['id'])); 
     49    echo $form->end('Delete'); 
    5050   } 
    5151   ?> 
  • trunk/app/views/newsletters/admin_add.ctp

    r277 r346  
    1 <?php echo $javascript->link('myfunctions'); ?> 
    2 <?php echo $javascript->link('fckeditor/fckeditor'); ?>  
     1<?php  
     2    echo $javascript->link('myfunctions'); 
     3    echo $javascript->link('fckeditor/fckeditor');  
    34 
    4 <?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?>  
    5 <?php echo $html->addCrumb('Entries', '/admin/newsletters/listing'); ?>  
    6 <?php echo $html->getCrumbs(' / '); ?> 
    7 <?php echo $html->formTag('/admin/newsletters/add/','post'); ?> 
     5    echo $html->addCrumb('Control Tools', '/admin/entries/start');  
     6    echo $html->addCrumb('Entries', '/admin/newsletters/listing');  
     7    echo $html->getCrumbs(' / ');  
     8 
     9    echo $form->create('Newsletter');  
     10?> 
    811 
    912<fieldset> 
    10 <legend>New n</legend> 
     13<legend>New newsletter</legend> 
    1114 
    1215<table style="margin:0 auto 0 auto;"> 
    13 <tr><td> 
    14    
    15   <?php echo $form->labelTag('Newsletter/title', 'Title:' );?><br />  
    16   <?php echo $html->input('Newsletter/title', array("size" => 50, "maxlength" => 50)); ?> 
    17   <?php echo $html->tagErrorMsg('Newsletter/title', 'Title is required.'); ?> 
     16<tr> 
     17   <td> 
     18    <?php 
     19      echo $form->input('Newsletter.title', array("size" => 50, "maxlength" => 50)); 
     20    ?> 
    1821  </td> 
    1922   <td> 
    20   <?php echo $html->link($html->image('admin/myimages.jpg', array("alt"=>"My Images", "title"=>"My Images")), '#', array("onclick"=>"javascript:window.open('/admin/images/listing/set', 'blank', 'toolbar=no, scrollbars=yes,width=700,height=500')"), null, false) ?></p> 
     23    <?php  
     24        echo $html->link($html->image('admin/myimages.jpg', array("alt"=>"My Images", "title"=>"My Images")),  
     25                         '#',  
     26                         array("onclick"=>"javascript:window.open('/admin/images/listing/set', 'blank', 'toolbar=no, scrollbars=yes,width=700,height=500')"), null, false); ?></p> 
    2127  </td> 
    2228  </tr> 
    2329  <tr><td colspan="2"> 
    24   <?php echo $form->labelTag( 'Newsletter/Body', 'Body:' );?><br /> 
    25   <?php echo $html->textarea('Newsletter/body', array("class"=>"formas", "cols"=>60, "rows"=>17)); ?> 
    26   <?php echo $fck->load('Newsletter/body', 'Karamelo'); ?>  
    27   <?php echo $html->tagErrorMsg('Newsletter/body', 'Body is required.'); ?> 
     30  <?php  
     31    echo $form->label('Newsletter.Body', 'Text:'); 
     32    echo $form->textarea('Newsletter.body', array("cols"=>60, "rows"=>17));  
     33    echo $fck->load('NewsletterBody', 'Karamelo');  
     34  ?> 
    2835  </td> 
    2936</tr>  
    3037<tr> 
    3138  <td> 
    32        <?php echo $form->labelTag( 'Newsletter/status', 'Published:' );?> 
    33        <?php echo $html->checkbox('Newsletter/status', null, array("value"=>1)); ?> 
     39       <?php 
     40            echo $form->label('Newsletter.status', 'Published:'); 
     41            echo $form->checkbox('Newsletter.status', null, array('value'=>1));  
     42        ?> 
    3443  </td> 
    3544   <td> 
    36        <?php echo $form->labelTag( 'Newsletter/end', 'Finish edition:' );?><br /> 
    37        <?php echo $html->checkbox('Newsletter/end', null, array("value" => 1)); ?> 
     45       <?php  
     46            echo $form->label('Newsletter.end', 'Finish edition:' ); 
     47            echo $form->checkbox('Newsletter.end', array('value' => 1));  
     48       ?> 
    3849   </td> 
    3950  </tr> 
    40   <tr><td colspan="2"> 
    41   <?php echo $html->submit('Save'); ?> 
     51  <tr><td colspan="2"></fieldset> 
     52  <?php echo $form->end('Save'); ?> 
    4253</td></tr> 
    4354</table> 
    44 </fieldset> 
    45 </form> 
  • trunk/app/views/tests/chk.ctp

    r264 r346  
    44//die(print_r($data)); 
    55 
    6 if ( $othAuth->sessionValid() ) 
     6if ( isset( $cU['User']['id'] ) ) 
    77{ 
    88 echo '<h1>'. $data['Test']['title'] . '</h1>'; 
    99 echo '<p>'.  $data['Test']['description'] . '</p>'; 
    1010 
    11  echo $html->formTag('/tests/chk/','post', array("onsubmit"=>"return validateNew()"));  
    12  echo $html->hidden('Test/id', array("value"=>$data['Test']['id'])); 
     11 echo $form->create('/tests/chk/','post', array("onsubmit"=>"return validateNew()"));  
     12 echo $form->hidden('Test.id', array("value"=>$data['Test']['id'])); 
    1313 
    1414 foreach ($data['Question'] as $val) 
  • trunk/app/views/vclassrooms/show.ctp

    r256 r346  
    1313  echo   $data['Ecourse']['description'] . "</p>"; 
    1414   
    15   if ( $othAuth->user('group_id')  )  // a student is login in so, show "Join" button  
     15  if ( isset( $cU['User']['id'] )  )  // a student is login in so, show "Join" button  
    1616  {   
    1717     echo $ajax->form(); 
     
    2323     echo $html->input('Vclassroom/code', array("size" => 6, "maxlength"=>6)); 
    2424      
    25      echo $ajax->submit('Join to this class '. $othAuth->user('username'), array("url" => "/vclassrooms/jointoclass/",  
     25     echo $ajax->submit('Join to this class '.$cU['User']['username'], array("url" => "/vclassrooms/jointoclass/",  
    2626                                         "update"=>"updater", 
    2727                                         "loading" => "Element.show('charging');Element.hide('updater')",