Changeset 301

Show
Ignore:
Timestamp:
03/03/08 21:41:31 (10 months ago)
Author:
aarkerio
Message:

Update monday 3 march

Location:
trunk/app
Files:
17 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/sql/karamelo_postgres.sql

    r290 r301  
    313313  "code" varchar(15),  -- secret code to allow students join to the ecourse,  voM121x for instance 
    314314  "created" timestamp(0) with time zone DEFAULT now() NOT NULL, 
     315  "status" smallint DEFAULT 0 NOT NULL, 
    315316  "lang_id" int NOT NULL REFERENCES langs(id) 
    316317); 
  • trunk/app/controllers/ecourses_controller.php

    r247 r301  
    1010class EcoursesController extends AppController 
    1111{ 
    12   public $helpers      = array('Fck', 'Gags'); 
     12 public $helpers      = array('Fck', 'Gags', 'Paginator'); 
    1313   
    14   public $components   = array('Pagination'); 
     14 public function isAuthorized()  
     15 {       
     16    if (isset( $this->params[Configure::read('Routing.admin')] ))  
     17    { 
     18        if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 )  // admin and teachers 
     19        { 
     20        return true; 
     21        }  
     22    }  
     23    return false;  // go away !! 
     24 } 
    1525 
    16   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   } 
    30  
    31    /**** 
     26 /**** 
    3227     ===== ADMIN SECTION ========== 
    33    ****/ 
    34   public function admin_start() 
     28 ****/ 
     29 public function admin_start() 
    3530  { 
    3631       $this->layout = 'admin'; 
    3732        
    3833             
    39        $conditions   =  array("user_id"=>$this->othAuth->user('id')); 
     34       $conditions   =  array("user_id"=>$this->Auth->user('id')); 
    4035       $fields       =  array('id', 'title', 'access',  'status', 'code', 'description'); 
    4136       $order        =  "Ecourse.title DESC"; 
     
    4742        $this->layout = 'admin'; 
    4843         
    49         //pagination 
    50         //$total_rows = $this->Ecourse->findCount(array("user_id"=>$this->othAuth->user('id')));  
    51          
    52         $lmt        = 25; // limit news 
    53          
    54         $targetpage = "/admin/news/listing/"; 
    55          
    56     // $pagination = $this->Mypagination->init($total_rows, $page, $lmt, $targetpage); //Pagination 
    57          
    58     // $this->set('pagination', $pagination); 
    59  
    60          
    61         $conditions   =  array("user_id"=>$this->othAuth->user('id')); 
    62         $fields       =  array('id', 'title', 'access',  'status', 'code', 'description'); 
     44        $conditions   =  array("user_id"=>$this->Auth->user('id')); 
     45        $fields       =  array('id', 'title', 'status', 'code', 'description'); 
    6346        $order        =  "Ecourse.id DESC"; 
    64         $offset     = (($page * $lmt) - $lmt); 
    65         $limit      = $lmt . " OFFSET " . $offset; 
     47        $limit        =  10; 
    6648         
    6749        $this->set('data', $this->Ecourse->findAll($conditions, $fields)); 
     
    7254        $this->layout = 'admin'; 
    7355         
    74         //pagination 
    75         //$total_rows = $this->Ecourse->findCount(array("user_id"=>$this->othAuth->user('id')));  
    76          
    7756        $lmt        = 25; // limit news 
    7857         
    79         $targetpage = "/admin/news/listing/"; 
    80          
    81     // $pagination = $this->Mypagination->init($total_rows, $page, $lmt, $targetpage); //Pagination 
    82          
    83     // $this->set('pagination', $pagination); 
     58        $conditions   =  array("Ecourse.user_id"=>$this->Auth->user('id'), "Ecourse.id"=>$ecourse_id); 
     59        $fields       =  array('id', 'title', 'status', 'code'); 
     60        $order        =  "Ecourse.id DESC"; 
    8461 
    85          
    86         $conditions   =  array("Ecourse.user_id"=>$this->othAuth->user('id'), "Ecourse.id"=>$ecourse_id); 
    87         $fields       =  array('id', 'title', 'access',  'status', 'code'); 
    88         $order        =  "Ecourse.id DESC"; 
    89         //$offset     = (($page * $lmt) - $lmt); 
    90         //$limit      = $lmt . " OFFSET " . $offset; 
    91          
    9262        $this->set('data', $this->Ecourse->find($conditions, $fields)); 
    9363  } 
    9464  
    9565  public function admin_add()  
    96   { 
    97      
     66  {    
    9867    $this->layout    = 'admin';  
    9968     
     
    10271        $this->Sanitize = new Sanitize; 
    10372         
    104         $this->Sanitize->cleanArray($this->data["Ecourse"]); 
     73        $this->Sanitize->clean($this->data["Ecourse"]); 
    10574   
    106         $this->data['Ecourse']['user_id'] = $this->othAuth->user('id'); 
     75        $this->data['Ecourse']['user_id'] = $this->Auth->user('id'); 
    10776 
    10877        $this->Ecourse->create(); 
     
    11281                $this->msgFlash('Course saved', '/admin/ecourses/listing'); 
    11382        } 
    114      } 
     83    } 
    11584    else 
    11685    { 
    117         $this->set('subjects', $this->Ecourse->Subject->generateList(null, 'title'));        
    118      
    119         $this->set('langs', $this->Ecourse->Lang->generateList(null, 'lang', null, '{n}.Lang.id', '{n}.Lang.lang')); 
     86  
     87     $this->set('subjects', Set::combine($this->Ecourse->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 
     88 
     89     $this->set('langs', Set::combine($this->Ecourse->Lang->find('all', array('order' => 'lang')), "{n}.Lang.id","{n}.Lang.lang")); 
     90 
    12091    } 
    12192  } 
     
    167138 } 
    168139  /*** DELETE  **/  
    169   public function admin_delete($id) 
    170   { 
     140 public function admin_delete($id) 
     141 { 
    171142    $this->Ecourse->del($id); 
    172143     
    173144    $this->msgFlash('Course deleted', '/admin/ecourses/listing'); 
    174   }  
     145 }  
    175146} 
    176147?> 
  • trunk/app/controllers/entries_controller.php

    r292 r301  
    7373 public function admin_add() 
    7474 { 
    75     $this->layout    = 'admin'; 
     75   $this->layout    = 'admin'; 
    7676 
    77     $this->set('subjects', Set::combine($this->Entry->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 
     77   $this->set('subjects', Set::combine($this->Entry->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 
    7878       
    7979    if ( !empty($this->data["Entry"]) )   
  • trunk/app/controllers/news_controller.php

    r275 r301  
    33 *  Karamelo E-Learning Platform 
    44 *  Manuel Montoya 2002-2008  
    5  *  GPL License manuel<at>mononeurona<punto>org 
     5 *  GPLv3 License manuel<at>mononeurona<punto>org 
    66 *  Chipotle Software 
    77*/  
     
    1919      if (isset($this->params[Configure::read('Routing.admin')])) 
    2020      { 
    21                  if ($this->Auth->user('group_id') != 1) 
     21                 if ($this->Auth->user('group_id') == 1) 
    2222                 { 
    23                            return false; 
     23                           return true; 
    2424                 } 
    2525      } 
    26      return true; 
     26     return false; 
    2727  } 
    2828                                                                  
     
    120120   public function admin_listing($page=1)  
    121121   { 
    122         //pagination 
    123         $total_rows = $this->News->findCount(array("user_id"=>$this->othAuth->user('id')));  
    124          
    125         $lmt        = 25; // limit news 
    126          
    127         $targetpage = "/admin/news/listing/"; 
    128          
    129         $pagination = $this->Mypagination->init($total_rows, $page, $lmt, $targetpage); //Pagination 
    130          
    131         $this->set('pagination', $pagination); 
    132          
    133         $this->pageTitle = $this->othAuth->user('username') . '\'s News'; 
    134          
    135         $this->layout = 'admin'; 
    136          
    137         $conditions   = array("News.user_id" => $this->othAuth->user('id') );             // only the user's news 
    138         $fields       = array("id", "title", "body", "created", "reference", "status", "theme_id", "user_id"); 
    139         $order        = "News.id DESC"; 
    140          
    141         $offset     = (($page * $lmt) - $lmt); 
    142          
    143         $limit      = $lmt . " OFFSET " . $offset; 
    144          
    145         $this->set('data', $this->News->findAll($conditions, $fields, $order, $limit));  
     122      $this->pageTitle = 'News manager'; 
     123         
     124      $this->layout = 'admin'; 
     125         
     126      $conditions   = array("News.user_id" => $this->Auth->user('id') );             // only the user's news 
     127      $fields       = array("id", "title", "body", "created", "reference", "status", "theme_id", "user_id"); 
     128      $order        = "News.id DESC"; 
     129      $limit      = 20; 
     130         
     131      $this->set('data', $this->News->findAll($conditions, $fields, $order, $limit));  
    146132  } 
    147133   
     
    162148  { 
    163149    $this->layout    = 'admin'; 
    164  
    165     $this->set('themes', $this->News->Theme->generateList(null, 'theme ASC', null, '{n}.Theme.id', '{n}.Theme.theme')); 
     150  
     151    $this->set('subjects',Set::combine($this->News->Theme->find('all', array('order'=>'title')),"{n}.Subject.id","{n}.Subject.title")); 
    166152     
    167153    if (!empty($this->data["News"])) 
     
    179165         $this->data["News"]["body"] = utf8_encode($tmp); 
    180166          
    181          $this->data["News"]["user_id"] = $this->othAuth->user('id'); 
     167         $this->data["News"]["user_id"] = $this->Auth->user('id'); 
    182168          
    183169     if ($this->News->save($this->data["News"])) 
  • trunk/app/controllers/vclassrooms_controller.php

    r247 r301  
    1616 public function isAuthorized() 
    1717 { 
    18             if (isset($this->params[Configure::read('Routing.admin')])) 
    19                    { 
    20                                 if ($this->Auth->user('group_id') != 1) 
    21                                      { 
    22                                                   return false; 
    23                                                             } 
    24                                                            } 
    25                                                               return true; 
    26       } 
    27                                                            
    28    
     18         if (isset($this->params[Configure::read('Routing.admin')])) 
     19         { 
     20              if ($this->Auth->user('group_id') == 1) 
     21              { 
     22                        return true; 
     23          } 
     24         } 
     25      return false; 
     26 } 
     27                                                             
    2928 public function show($user_id, $id)  
    3029 { 
     
    6160        else 
    6261        { 
    63         if ($this->Vclassroom->addAssoc('User',  $this->othAuth->user('id'), $this->data["Vclassroom"]["vclassroom_id"])) 
     62        if ($this->Vclassroom->addAssoc('User',  $this->Auth->user('id'), $this->data["Vclassroom"]["vclassroom_id"])) 
    6463            {   
    6564               $this->set('msg', 'You have joined to this class succesfully!'); 
     
    8281   foreach ($data['User'] as $user) 
    8382   { 
    84       if ($user['id'] == $this->othAuth->user('id'))     
     83      if ($user['id'] == $this->Auth->user('id'))     
    8584      { 
    8685       $already_member = true;  // yes, is already member 
     
    9998 { 
    10099      $this->layout = 'admin'; 
    101       $conditions = array("Vclassroom.user_id"=>$this->othAuth->user('id')); 
     100      $conditions = array("Vclassroom.user_id"=>$this->Auth->user('id')); 
    102101      $fields     = array("Vclassroom.id", "Vclassroom.name", "Vclassroom.created", "Vclassroom.user_id", "Vclassroom.ecourse_id"); 
    103102      $order      = "Vclassroom.id DESC"; 
     
    112111      $this->layout = 'admin'; 
    113112       
    114       $conditions = array("Vclassroom.user_id"=>$this->othAuth->user('id'), "Vclassroom.id"=>$vclassroom_id); 
     113      $conditions = array("Vclassroom.user_id"=>$this->Auth->user('id'), "Vclassroom.id"=>$vclassroom_id); 
    115114       
    116115      $this->pageTitle = 'Class members'; 
     
    123122      $this->layout = 'popup'; 
    124123       
    125       $conditions = array("Vclassroom.user_id"=>$this->othAuth->user('id'), "Vclassroom.id"=>$vclassroom_id); 
     124      $conditions = array("Vclassroom.user_id"=>$this->Auth->user('id'), "Vclassroom.id"=>$vclassroom_id); 
    126125       
    127126      $this->pageTitle = 'Tests'; 
    128127       
    129128      $this->set('data', $this->Vclassroom->find($conditions)); 
    130       $this->set('test', $this->Vclassroom->Test->findAll(array("Test.user_id"=>$this->othAuth->user('id'), "Test.status"=>1))); 
     129      $this->set('test', $this->Vclassroom->Test->findAll(array("Test.user_id"=>$this->Auth->user('id'), "Test.status"=>1))); 
    131130 } 
    132131 // link webquest to classroom 
     
    135134      $this->layout = 'popup'; 
    136135       
    137       $conditions = array("Vclassroom.user_id"=>$this->othAuth->user('id'), "Vclassroom.id"=>$vclassroom_id); 
     136      $conditions = array("Vclassroom.user_id"=>$this->Auth->user('id'), "Vclassroom.id"=>$vclassroom_id); 
    138137       
    139138      $this->pageTitle = 'Webquest'; 
    140139       
    141140      $this->set('data', $this->Vclassroom->find($conditions)); 
    142       $this->set('webquest', $this->Vclassroom->Webquest->findAll(array("Webquest.user_id"=>$this->othAuth->user('id'), "Webquest.status"=>1))); 
     141      $this->set('webquest', $this->Vclassroom->Webquest->findAll(array("Webquest.user_id"=>$this->Auth->user('id'), "Webquest.status"=>1))); 
    143142 } 
    144143 // link treasure to classroom 
     
    147146      $this->layout = 'popup'; 
    148147       
    149       $conditions = array("Vclassroom.user_id"=>$this->othAuth->user('id'), "Vclassroom.id"=>$vclassroom_id); 
     148      $conditions = array("Vclassroom.user_id"=>$this->Auth->user('id'), "Vclassroom.id"=>$vclassroom_id); 
    150149       
    151150      $this->pageTitle = 'Treasure'; 
    152151       
    153152      $this->set('data', $this->Vclassroom->find($conditions)); 
    154       $this->set('treasure', $this->Vclassroom->Treasure->findAll(array("Treasure.user_id"=>$this->othAuth->user('id'), "Treasure.status"=>1))); 
     153      $this->set('treasure', $this->Vclassroom->Treasure->findAll(array("Treasure.user_id"=>$this->Auth->user('id'), "Treasure.status"=>1))); 
    155154 } 
    156155 public function admin_start($vclassroom_id) 
    157156 { 
    158157      $this->layout = 'admin'; 
    159       $conditions = array("Vclassroom.user_id"=>$this->othAuth->user('id'), "Vclassroom.id"=>$vclassroom_id); 
     158      $conditions = array("Vclassroom.user_id"=>$this->Auth->user('id'), "Vclassroom.id"=>$vclassroom_id); 
    160159      $fields     = array("Vclassroom.id", "Vclassroom.name", "Vclassroom.order", "Vclassroom.created", "Vclassroom.user_id", "Vclassroom.subject_id"); 
    161160      $order      = "Vclassroom.id DESC"; 
     
    174173        $this->Sanitize->cleanArray($this->data["Vclassroom"]);  
    175174 
    176         $this->data["Vclassroom"]["user_id"] = $this->othAuth->user('id'); 
     175        $this->data["Vclassroom"]["user_id"] = $this->Auth->user('id'); 
    177176        
    178177        $this->Vclassroom->create(); 
  • trunk/app/views/ecourses/admin_add.ctp

    r268 r301  
    1 <?php echo $html->formTag('/admin/ecourses/add','post', array("onsubmit"=>"return chkForm();")); ?> 
     1<?php echo $form->create('Ecourse', array('action'=>'admin_add', 'onsubmit'=>'return chkForm()')); ?> 
    22<fieldset> 
    33  <legend>New Course</legend> 
    4 <p>By default, your course is accessible to everybody. If you want some c0onfidentiality, the simplest way is to open registration during one week, ask the students to register themselves, then close registration and check for possible intruders in the user list.</p> 
    5   <?php  
    6     echo $form->labelTag('Ecourse/title', 'Title:'); 
    7     echo $html->input('Ecourse/title', array("size" => 30, "maxlength" => 90)) . ' e.g. History of Literature'; 
    8     echo $html->tagErrorMsg('Ecourse/title', 'A FAQ title is required.'); 
     4<p>By default, your course is accessible to everybody. If you want some confidentiality, the simplest way is to open registration during one week, ask the students to register themselves, then close registration and check for possible intruders in the user list.</p> 
     5<?php  
     6 echo $form->input('Ecourse.title', array("size" => 30, "maxlength" => 90)) . ' e.g. History of Literature'; 
     7 echo $form->error('Ecourse.title', 'A FAQ title is required.'); 
    98 
    10     echo $form->labelTag('Ecourse/description', 'Description:'); 
    11     echo $html->textarea('Ecourse/description', array("cols" => 40, "rows" =>4)); 
     9 echo $form->label('Ecourse.description', 'Description:'); 
     10 echo $form->textarea('Ecourse.description', array("cols" => 40, "rows" =>4)); 
    1211 
    13       
    14     echo $form->labelTag('Ecourse/code', 'Code:' ); 
    15     echo $html->input('Ecourse/code', array("size" => 12, "maxlenght" => 12))  . ' max. 12 characters, ie.ROM2121'; 
    16     echo $html->tagErrorMsg('Ecourse/code', 'A category description is required.'); 
    17   ?> 
    18   <br /><br /> 
    19 <?php 
    20     echo $form->labelTag('Ecourse/subject_id', 'Subject:'); 
    21     echo $html->selectTag('Ecourse/subject_id', $subjects, null, null, null, false); 
     12 echo $form->input('Ecourse.code', array("size" => 12, "maxlenght" => 12))  . ' max. 12 characters, ie.ROM2121'; 
     13 echo $form->error('Ecourse/code', 'A category description is required.'); 
     14  
     15 echo $form->label('Ecourse.subject_id', 'Subject:'); 
     16 echo $form->select('Ecourse.subject_id', $subjects, null, null, null, false); 
    2217 
    23     echo $form->labelTag('Ecourse/lang_id', 'Lang:'); 
    24     echo $html->selectTag('Ecourse/lang_id', $langs, null, null, null, false); 
     18 echo $form->label('Ecourse.lang_id', 'Lang:'); 
     19 echo $form->select('Ecourse.lang_id', $langs, null, null, null, false); 
    2520?> 
    2621 
    2722  <div style="clear:both"></div> 
    2823  <br /> 
    29   <?php echo $html->submit('Save') ?> 
     24  <?php echo $form->end('Save'); ?> 
    3025</fieldset> 
    31 </form> 
     26 
    3227<script type="text/javascript"> 
    3328/* <![CDATA[ */ 
     
    3934  { 
    4035       Div.style.display = "block"; 
    41    } 
    42    else 
    43    {  
     36  } 
     37  else 
     38  {  
    4439           Div.style.display = "none"; 
    45     } 
     40  } 
    4641 } 
    4742 
  • trunk/app/views/ecourses/admin_listing.ctp

    r268 r301  
    1 <?php 
    2 if ( isset($javascript) ): 
    3   echo $html->charsetTag('UTF-8'); 
    4   echo $javascript->link('prototype'); 
    5   echo $javascript->link('scriptaculous.js?load=effects'); 
    6 endif; 
    7 ?> 
    81<script type="text/javascript"> 
    92   window.onload = timedMsg; 
  • trunk/app/views/ecourses/admin_vclassrooms.ctp

    r268 r301  
    11<?php 
    22//exit(print_r($data)); 
    3  
    4 if ( isset($javascript) ): 
    5   echo $html->charsetTag('UTF-8'); 
    6   echo $javascript->link('prototype'); 
    7   echo $javascript->link('scriptaculous.js?load=effects'); 
    8 endif; 
    93 
    104echo $html->addCrumb('Control Tools', '/admin/entries/start'); 
  • trunk/app/views/entries/admin_add.ctp

    r292 r301  
    3232  <?php  
    3333     echo $form->label( 'Entry.Body', 'Body:' ); 
    34      echo $form->textarea('Entry/body', array("cols"=>80, "rows"=>30));  
    35      echo $fck->load('Entry/body', 'Karamelo');  
    36      echo $form->error('Entry/body', 'Body is required.');  
     34     echo $form->textarea('Entry.body', array("cols"=>80, "rows"=>30));  
     35     echo $fck->load('EntryBody', 'Default');  
     36     echo $form->error('Entry.body', 'Body is required.');  
    3737   ?> 
    3838  </td></tr> 
  • trunk/app/views/entries/admin_edit.ctp

    r292 r301  
    3838 <td colspan="3"> 
    3939  <?php  
    40      echo $form->label('Entry.Body', 'Body:'); 
     40     echo $form->label('Entry.body', 'Body:'); 
    4141     echo $form->textarea('Entry.body', array("cols"=>80, "rows"=>22)); 
    42      echo $fck->load('EntryBody', 'Karamelo');  
     42     echo $fck->load('EntryBody', 'Default');  
    4343     echo $form->error('Entry.body', 'Body is required.');  
    4444  ?> 
     
    4747  <td> 
    4848    <?php  
    49         echo $form->label( 'Entry/status', 'Published:' ); 
     49        echo $form->label('Entry/status', 'Published:' ); 
    5050        echo $form->checkbox('Entry/status', null, array("value" => 1));  
    5151    ?> 
     
    5353  <td> 
    5454 <?php  
    55    echo $form->label( 'Entry.discution', 'Comments allowed:' ); 
     55   echo $form->label('Entry.discution', 'Comments allowed:' ); 
    5656   echo $form->checkbox('Entry.discution', null, array("value" => 1));  
    5757?> 
  • trunk/app/views/entries/admin_listing.ctp

    r276 r301  
    3030foreach ($data as $val) { 
    3131       $tr = array ( 
    32         $gags->sendEdit($val['Entry']['id'], 'entries'), 
     32        $gags->sendEdit($val['Entry']['id'], 'Entry'), 
    3333        $val['Entry']['title'], 
    3434        $gags->setStatus($val['Entry']['status']), 
    35         $gags->confirmDel($val['Entry']['id'], 'entries') 
     35        $gags->confirmDel($val['Entry']['id'], 'Entry') 
    3636        ); 
    3737        
  • trunk/app/views/helpers/gags.php

    r276 r301  
    1212   public  $helpers = array('Html', 'Ajax', 'Form'); 
    1313    
    14    public function confirmDel($id, $controller)  
     14   public function confirmDel($id, $model)  
    1515   { 
    1616         
    17         $strB  = $this->Form->create(null, array('action'=>'/admin/'.$controller.'/delete/'.$id, "onsubmit"=>"return confirm('Are you sure to delete?')")); 
     17        $strB  = $this->Form->create($model, array('action'=>'/admin_delete/'.$id, "onsubmit"=>"return confirm('Are you sure to delete?')")); 
    1818        $strB .= $this->Form->end('Delete'); 
    1919         
     
    2121   } 
    2222    
    23    public function sendEdit($id, $controller)  
     23   public function sendEdit($id, $model)  
    2424   { 
    2525         
    26         $strB  = $this->Form->create(null, array('action'=>'/admin/'.$controller.'/edit/'.$id)); 
     26        $strB  = $this->Form->create($model, array('action'=>'admin_edit/'.$id)); 
    2727        $strB .= $this->Form->end('Edit'); 
    2828         
  • trunk/app/views/news/admin_add.ctp

    r238 r301  
    1 <?php echo $javascript->link('prototype'); ?> 
    2 <?php echo $javascript->link('myfunctions'); ?> 
    3 <?php echo $javascript->link('poll'); ?> 
    4 <?php echo $javascript->link('fckeditor/fckeditor'); ?>  
     1<?php  
     2   echo $javascript->link('myfunctions'); 
     3