Changeset 307

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

Rewrite hepers

Location:
trunk/app
Files:
10 modified

Legend:

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

    r302 r307  
    2424    return false;  // go away !! 
    2525 } 
    26  
     26  
    2727 public function display($username, $user_id) 
    2828 { 
     
    3636   
    3737       $this->set('data', $this->Acquaintance->findAll($conditions)); 
    38   } 
     38 } 
    3939  
    4040 /** ADMIN METHODS***/ 
     
    4343      $this->layout    = 'admin'; 
    4444       
    45       $conditions   = array("user_id" => $this->othAuth->user('id')); 
     45      $conditions   = array("user_id" => $this->Auth->user('id')); 
    4646       
    4747      //$fields     = array("id", "title", "description", "pubdate", "size"); 
     
    6464       $this->Sanitize = new Sanitize; 
    6565        
    66        $this->Sanitize->cleanArray($this->data["Acquaintance"]);  
     66       $this->Sanitize->clean($this->data["Acquaintance"]);  
    6767        
    68        $this->data['Acquaintance']['user_id'] = $this->othAuth->user('id'); 
     68       $this->data['Acquaintance']['user_id'] = $this->Auth->user('id'); 
    6969           
    7070       $this->Acquaintance->create(); 
     
    8585        $this->Acquaintance->id = $id; 
    8686         
    87         $this->Subject     = new Subject; 
    88          
    89         $this->set('subjects', $this->Subject->generateList());          
    90          
    9187        $this->data = $this->Acquaintance->read(); 
    9288    } 
     
    9591       $this->Sanitize = new Sanitize; 
    9692        
    97        $this->Sanitize->cleanArray($this->data["Acquaintance"]); //Hopefully this is enough 
     93       $this->Sanitize->clean($this->data["Acquaintance"]);  
    9894        
    9995       if ($this->Acquaintance->save($this->data['Acquaintance'])) 
     
    114110           $this->flash('Error, call support', '/admin/acquaintances/listing'); 
    115111      } 
    116   }} 
     112  } 
     113} 
    117114?> 
  • trunk/app/controllers/glossaries_controller.php

    r247 r307  
    33*  Karamelo E-Learning Platform 
    44*  Manuel Montoya 2002-2008  
    5 *  GPL manuel<at>mononeurona.org 
     5*  GPLv3 manuel<at>mononeurona.org 
    66*/  
    77  
     
    1010class GlossariesController extends AppController 
    1111{ 
    12  public $helpers       = array('Ajax', 'User', 'Fck', 'Gags'); 
     12 public $helpers      = array('Ajax', 'User', 'Fck', 'Gags'); 
    1313     
    1414 public $components   = array('Edublog'); 
    1515  
    1616 public function isAuthorized()  
    17  { 
    18     if ($this->action == 'delete')  
    19       { 
    20     if ($this->Auth->user('group_id') == 1)  
    21           { 
     17 {       
     18    if (isset( $this->params[Configure::read('Routing.admin')] ))  
     19    { 
     20        if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 )  // admin and teachers 
     21        { 
    2222        return true; 
    23           } else { 
    24         return false; 
    25           } 
    26       } 
    27   
    28     return true; 
     23        }  
     24    }  
     25    return false;  // go away !! 
    2926 } 
    3027     
     
    4845        $this->Edublog->blog($user_id); // blogger elements 
    4946 } 
    50  
    5147      
    5248 /***  
     
    6056        $this->pageTitle = 'Glossary'; 
    6157         
    62         $conditions = array("Glossary.catglossary_id"=>$catglossary_id, "Glossary.user_id"=>$this->othAuth->user('id')); 
     58        $conditions = array("Glossary.catglossary_id"=>$catglossary_id, "Glossary.user_id"=>$this->Auth->user('id')); 
    6359         
    6460        $fields     = array("Glossary.id", "Glossary.item", "Glossary.definition", "Glossary.catglossary_id", "Catglossary.title"); 
     
    7470 { 
    7571        $this->layout = 'ajax'; 
    76          $this->set('catglossary_id', $catglossary_id); 
    77           $this->render('new', 'ajax'); 
     72    $this->set('catglossary_id', $catglossary_id); 
     73    $this->render('new', 'ajax'); 
    7874 } 
    7975  
     
    107103    $this->set('catglossary_id', $catglossary_id); 
    108104     
    109       if (!empty($this->data["Glossary"])) 
    110       { 
     105    if (!empty($this->data["Glossary"])) 
     106    { 
    111107        $this->Sanitize = new Sanitize; 
    112108         
    113         $this->Sanitize->cleanArray($this->data["Glossary"]); //Hopefully this is enough 
     109        $this->Sanitize->clean($this->data["Glossary"]); //Hopefully this is enough 
    114110         
    115           $this->data["Glossary"]["user_id"] = $this->othAuth->user('id'); 
     111    $this->data["Glossary"]["user_id"] = $this->Auth->user('id'); 
    116112           
    117           $this->Glossary->create(); 
     113    $this->Glossary->create(); 
    118114           
    119115        if ($this->Glossary->save($this->data["Glossary"])) 
    120          { 
     116    { 
    121117           $this->msgFlash('Item has been saved.','/admin/glossaries/listing/'.$this->data["Glossary"]["catglossary_id"]); 
    122          } 
    123118     } 
    124    } 
     119     } 
     120 } 
    125121    
    126122 public function admin_delete($id, $catglossary_id) 
  • trunk/app/controllers/quotes_controller.php

    r247 r307  
    1717      if (isset($this->params[Configure::read('Routing.admin')])) 
    1818      { 
    19                              if ($this->Auth->user('group_id') != 1) 
    20                                       { 
    21                                                    return false; 
    22                                                              } 
    23                                                             } 
    24                                                                return true; 
    25  } 
    26                                                             
     19    if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2) 
     20    { 
     21        return true; 
     22    } 
     23      } 
     24  return false; 
     25 }                                                          
    2726 
    2827 public function admin_add()  
     
    3231         $this->Sanitize = new Sanitize; 
    3332          
    34          $this->Sanitize->cleanArray($this->data); //Hopefully this is enough 
     33         $this->Sanitize->clean($this->data); //Hopefully this is enough 
    3534          
    36          $this->data['Quote']['user_id'] = $this->othAuth->user('id'); 
     35         $this->data['Quote']['user_id'] = $this->Auth->user('id'); 
    3736          
    3837         if ( $this->Quote->save($this->data['Quote'])) 
     
    4948      $this->pageTitle = 'Quotes'; 
    5049       
    51       $conditions      = array("user_id" => $this->othAuth->user('id')); 
     50      $conditions      = array("user_id" => $this->Auth->user('id')); 
    5251      $fields          = array("id", "quote", "author"); 
    5352      $order           = "author DESC"; 
     
    7069        $this->Sanitize = new Sanitize; 
    7170         
    72         $this->Sanitize->cleanArray($this->data); 
     71        $this->Sanitize->clean($this->data); 
    7372         
    7473        if ($this->Quote->save($this->data)) 
     
    8281 public function admin_delete($id) 
    8382 { 
    84         // deletes task from database 
    85                 //die($this->data['Quote']['id']); 
    86         $this->Quote->del($id); 
    87         $this->redirect('/admin/quotes/listing'); 
    88         exit(); 
     83      if ($this->Quote->del($id)) 
     84      { 
     85          $this->msgFlash('Quote deleted','/admin/quotes/listing'); 
     86      }  
     87      else 
     88      { 
     89           $this->flash('Error, call support', '/admin/quotes/listing'); 
     90      } 
    8991  } 
    9092} 
  • trunk/app/controllers/users_controller.php

    r292 r307  
    333333 { 
    334334    $this->layout    = 'portal'; 
    335   
     335     
    336336    $conditions = array("id"=>'>1', "id"=>"<5"); 
    337  
     337     
    338338    $this->set('groups', Set::combine($this->User->Group->find('all'), "{n}.Group.id","{n}.Group.name")); 
    339  
     339     
    340340    $this->Portal->statics(); // Using Portal components 
    341341 } 
  • trunk/app/views/acquaintances/admin_edit.ctp

    r256 r307  
    1 <?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?>  
    2 <?php echo $html->addCrumb('Links', '/admin/acquaintances/listing'); ?>  
    3 <?php echo $html->getCrumbs(' / '); ?> 
     1<?php  
     2  echo $html->addCrumb('Control Tools', '/admin/entries/start');  
     3  echo $html->addCrumb('Links', '/admin/acquaintances/listing');  
     4  echo $html->getCrumbs(' / ');  
    45 
    5 <?php echo $html->formTag('/admin/acquaintances/edit/','post'); ?> 
    6  
    7 <?php echo $html->hiddenTag('Acquaintance/id'); ?> 
     6  echo $form->create('Acquaintance', array('action'=>'admin_edit')); 
     7  echo $form->hidden('Acquaintance.id');  
     8?> 
    89 
    910<fieldset> 
    1011<legend>Edit link</legend> 
    1112 <?php  
    12    echo $form->labelTag('Acquaintance/name', 'Name:' );  
    13    echo $html->input('Acquaintance/name', array("size" => 50, "maxlength" => 50)); 
    14    echo $html->tagErrorMsg('Acquaintance/name', 'Title is required.');  
     13   echo $form->input('Acquaintance.name', array("size" => 50, "maxlength" => 50)); 
     14   echo $form->error('Acquaintance.name', 'Title is required.');  
    1515?> 
    16 <p> 
     16 
    1717<?php 
    18   echo $form->labelTag('Acquaintance/description', 'Description:'); 
    19   echo $html->textarea('Acquaintance/description', array("cols" => 40, "rows" =>4)); 
    20 ?> 
    21 </p>   
    22 <?php    
    23    echo $form->labelTag('Acquaintance/url', 'Link:' );  
    24    echo $html->input('Acquaintance/url', array("size" => 65, "maxlength" => 220)); 
    25    echo $html->tagErrorMsg('Acquaintance/url', 'Link is required.'). '<br />';  
    26   
    27     echo $html->submit('Save');  
     18  echo $html->para(null, 
     19   $form->label('Acquaintance.description', 'Description:') . $form->textarea('Acquaintance.description', array("cols" => 40, "rows" =>4)) 
     20  ); 
     21 
     22   echo $form->input('Acquaintance.url', array("size" => 65, "maxlength" => 220)); 
     23   echo $form->error('Acquaintance.url', 'Link is required.'). '<br />';  
     24   echo '</fieldset>'; 
     25   echo $form->end('Save');  
    2826 ?> 
    29 </fieldset> 
    30 </form> 
    31  
  • trunk/app/views/acquaintances/admin_listing.ctp

    r256 r307  
    44?> 
    55 
    6 <div class="title_section"><?php echo $othAuth->user('username'); ?>'s Acquaintances</div> 
     6<div class="title_section"><?php echo $cU['User']['username']; ?>'s Acquaintances</div> 
    77 
    88<script type="text/javascript">  
     
    2525 
    2626<div id="trh" style="margin:0;padding:0;padding-left:40px;width:80%;display:none;"> 
    27 <?php echo $html->formTag('/admin/acquaintances/add/','post'); ?> 
     27<?php echo $form->create('Acquaintance', array('action'=>'admin_add')); ?> 
    2828 <fieldset> 
    2929 <legend>New Acquaintance</legend> 
    30    <?php echo $form->labelTag('Acquaintance/name', 'Site:'); ?><br /> 
    31    <?php echo $html->input('Acquaintance/name', array("size" => 30, "maxlength"=>50)); ?> 
    32    <?php echo $html->tagErrorMsg('Acquaintance/name', 'A name is required.'); ?> 
     30   <?php  
     31    echo $form->label('Acquaintance.name', 'Site:') . '<br />'; 
     32    echo $form->input('Acquaintance.name', array("size" => 30, "maxlength"=>50));  
     33    echo $form->error('Acquaintance.name', 'A name is required.');  
     34   ?> 
    3335   <br /><br /> 
    3436<p> 
    3537<?php 
    36   echo $form->labelTag('Acquaintance/description', 'Description:'); 
    37   echo $html->textarea('Acquaintance/description', array("cols" => 40, "rows" =>3)); 
     38  echo $form->label('Acquaintance.description', 'Description:'); 
     39  echo $form->textarea('Acquaintance.description', array("cols" => 40, "rows" =>3)); 
    3840?> 
    3941</p>   
    4042<?php  
    41     echo $form->labelTag('Acquaintance/url', 'URL:') . "<br />"; 
    42     echo $html->input('Acquaintance/url', array("size" => 60, "maxlength"=>300, "value"=>"http://")); 
    43     echo $html->tagErrorMsg('Acquaintance/url', 'An author is required.');  
     43    echo $form->label('Acquaintance.url', 'URL:') . '<br />'; 
     44    echo $form->input('Acquaintance.url', array("size" => 60, "maxlength"=>300, "value"=>"http://")); 
     45    echo $form->error('Acquaintance.url', 'An author is required.');  
    4446?> 
    4547    
    4648   <div style="clear:both"></div> 
    47   <?php echo $html->submit('Add') ?> 
    48 </fieldset> 
     49   </fieldset> 
     50  <?php echo $form->end('Save'); ?> 
    4951</form> 
    5052 
    5153</div> 
    5254 <?php $session->flash(); ?> 
     55  
    5356<table style="width:100%"> 
    5457<?php 
  • trunk/app/views/entries/admin_edit.ctp

    r301 r307  
    1010   echo $html->addCrumb('Control Tools', '/admin/entries/start');  
    1111   echo $html->addCrumb('Entries', '/admin/entries/listing');  
    12   echo $html->getCrumbs(' / ');  
     12   echo $html->getCrumbs(' / ');  
    1313?> 
    1414 
  • trunk/app/views/quotes/admin_edit.ctp

    r272 r307  
    1 <?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?>  
    2 <?php echo $html->addCrumb('Quote', '/admin/quotes/listing'); ?>  
    3 <?php echo $html->getCrumbs(' / '); ?> 
     1<?php  
     2 echo $html->addCrumb('Control Tools', '/admin/entries/start');  
     3 echo $html->addCrumb('Quote', '/admin/quotes/listing');  
     4 echo $html->getCrumbs(' / '); 
    45 
    5 <?php echo $html->formTag('/admin/quotes/edit/','post'); ?> 
     6 echo $form->create('Quote', array('url' => 'quotes/admin_edit'));  
     7 echo $form->hidden('Quote.id'); 
     8?> 
     9<fieldset> 
     10<legend>Edit quote</legend> 
     11 <?php  
     12   echo $form->input('Quote.quote', array("size" => 60, "maxlength" => 150)); 
     13   echo $form->error('Quote.quote', 'Title is required.');  
     14    
     15   echo $form->input('Quote.author', array("size" => 25, "maxlength" => 70)); 
     16   echo $form->error('Quote.author', 'Author is required.');  
    617 
    7 <?php echo $html->hiddenTag('Quote/id'); ?> 
     18   echo '</fieldset>'; 
     19   echo $form->end('Save');   
     20?> 
    821 
    9 <fieldset> 
    10 <legend>Edit new</legend> 
    11  <?php  
    12    echo $form->labelTag( 'Quote/quote', 'Quote:' );  
    13    echo $html->input('Quote/quote', array("size" => 60, "maxlength" => 150)); 
    14    echo $html->tagErrorMsg('Quote/quote', 'Title is required.');  
    15     
    16    echo $form->labelTag( 'Quote/quote', 'Author:' );  
    17    echo $html->input('Quote/author', array("size" => 25, "maxlength" => 70)); 
    18    echo $html->tagErrorMsg('Quote/author', 'Author is required.');  
    19  ?> 
    20  
    21   <?php echo $html->submit('Send');  ?> 
    22 </fieldset> 
    23 </form> 
    24  
  • trunk/app/views/quotes/admin_listing.ctp

    r272 r307  
    1 <?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?>  
    2 <?php echo $html->getCrumbs(' / '); ?> 
     1<?php  
     2  echo $html->addCrumb('Control Tools', '/admin/entries/start');  
     3  echo $html->getCrumbs(' / ');  
     4?> 
    35 
    46<div class="title_section">Quick News</div> 
     
    2022</script> 
    2123 
    22 <p><?php echo $html->link($html->image('admin/new.gif', array("alt"=>"Add new", "title"=>"Add new")), '#', array("onclick"=>"hU()"), false, false); ?></p> 
     24<?php  
     25echo $html->para(null, $html->link($html->image('actions/new.png', array("alt"=>"Add new", "title"=>"Add new")), '#', array("onclick"=>"hU()"), false, false)); ?> 
    2326 
    2427<div id="trh" style="margin:0;padding:0;padding-left:40px;width:80%;display:none;"> 
    25 <?php echo $html->formTag('/admin/quotes/add/','post'); ?> 
     28<?php echo $form->create('Quote', array('action'=>'admin_add')); ?> 
    2629 <fieldset> 
    27  <legend>New quote</legend> 
    28    <?php echo $form->labelTag('Quote/quote', 'Quote:'); ?><br /> 
    29    <?php echo $html->input('Quote/quote', array("size" => 60, "maxlength"=>130)); ?> 
    30    <?php echo $html->tagErrorMsg('Quote/quote', 'A quote is required.'); ?> 
     30 <legend>New quote</legend 
     31   <?php  
     32   echo $form->input('Quote.quote', array("size" => 60, "maxlength"=>130)); 
     33   echo $form->error('Quote.quote', 'A quote is required.');  
    3134    
    32    <?php echo $form->labelTag('Quote/author', 'Author:') . "<br />"; ?> 
    33    <?php echo $html->input('Quote/author', array("size" => 60, "maxlength"=>130)); ?> 
    34    <?php echo $html->tagErrorMsg('Quote/author', 'An author is required.'); ?> 
     35   echo $form->input('Quote/author', array("size" => 60, "maxlength"=>130)); 
     36   echo $form->error('Quote.author', 'An author is required.');  
     37?> 
    3538    
    3639   <div style="clear:both"></div> 
    37   <?php echo $html->submit('Add') ?> 
    3840</fieldset> 
    39 </form> 
     41  <?php echo $form->end('Save'); ?> 
    4042 
    4143</div> 
  • trunk/app/views/vclassrooms/admin_edit.ctp

    r256 r307  
    66 echo $html->getCrumbs(' / ');  
    77 
    8  echo $html->formTag('/admin/vclassrooms/edit','post', array("onsubmit"=>"chkForm()")); 
    9  echo $html->hidden('Vclassroom/id'); 
     8 echo $form->create('Vclassroom',array('action'=>'admin_edit', "onsubmit"=>"chkForm()")); 
     9 echo $form->hidden('Vclassroom.id'); 
    1010?> 
    1111 
     
    1313  <legend>New Group</legend>  
    1414  <p> 
    15   <?php echo $form->labelTag('Vclassroom/name', 'Name:' );?> 
    16   <?php echo $html->input('Vclassroom/name', array("size" => 40, "maxlength" => 60)); ?> 
    17   <?php echo $html->tagErrorMsg('Vclassroom/name', 'A name is required.'); ?> 
     15  <?php  
     16     echo $form->input('Vclassroom.name', array("size" => 40, "maxlength" => 60));  
     17     echo $form->error('Vclassroom.name', 'A name is required.');  
     18  ?> 
    1819  </p><br /> 
    1920  
    20   <label>Activate classroom:</label><br /> 
    21   <?php echo $html->checkbox('Vclassroom/status', null, array("value"=>1)); ?> 
     21   
     22  <?php  
     23     echo $form->label('Vclassroom.status', 'Status:'); 
     24     echo $form->checkbox('Vclassroom.status', array("value"=>1));  
     25?> 
    2226  <br /></p> 
    2327   
     
    3842    ?> 
    3943   
    40   <label>Members only by invitation:</label><br /> 
    41   <?php echo $html->checkbox('Vclassroom/access', null, $attr); ?> 
     44 
     45  <?php  
     46     echo $form->label('Vclassroom.access', 'Members only by invitation:'); 
     47     echo $form->checkbox('Vclassroom.access', $attr);  
     48  ?> 
    4249  <br /><br /> 
    4350   
     
    4552   
    4653  <div id="invi_code" style="display:<?php echo $display; ?>;"> 
    47      <label>CODE:</label> 
    48      <?php echo $html->input('Vclassroom/secret', array("size" => 5, "maxlength" => 6)); ?> 
     54     <?php  
     55     echo $form->label('Vclassroom.secret', 'CODE:'); 
     56     echo $html->input('Vclassroom.secret', array("size" => 5, "maxlength" => 6));  
     57    ?> 
    4958     <br /><br /> 
    5059  </div> 
    5160  <div style="clear:both"></div> 
    52   <br /> 
    53   <?php echo $html->submit('Save'); ?> 
    54 </fieldset> 
    55 </form> 
     61  <br /></fieldset> 
     62  <?php echo $form->end('Save'); ?> 
    5663 
    5764<script type="text/javascript">