Changeset 54

Show
Ignore:
Timestamp:
08/09/07 12:55:08 (17 months ago)
Author:
aarkerio
Message:

General update

Location:
trunk/app
Files:
17 modified

Legend:

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

    r53 r54  
    245245INSERT INTO permissions (id, name) VALUES (64, 'admin/glossaries/listing'); 
    246246--Categories Glossaries 
    247 INSERT INTO permissions (id, name) VALUES (65, 'catglossaries/add'); 
    248 INSERT INTO permissions (id, name) VALUES (66, 'catglossaries/edit'); 
    249 INSERT INTO permissions (id, name) VALUES (67, 'catglossaries/delete'); 
    250 INSERT INTO permissions (id, name) VALUES (68, 'catglossaries/listing'); 
     247INSERT INTO permissions (id, name) VALUES (65, 'admin/catglossaries/add'); 
     248INSERT INTO permissions (id, name) VALUES (66, 'admin/catglossaries/edit'); 
     249INSERT INTO permissions (id, name) VALUES (67, 'admin/catglossaries/delete'); 
     250INSERT INTO permissions (id, name) VALUES (68, 'admin/catglossaries/listing'); 
    251251--E-courses 
    252252INSERT INTO permissions (id, name) VALUES (69, 'admin/ecourses/add'); 
  • trunk/app/controllers/catglossaries_controller.php

    r31 r54  
    2626    } 
    2727     
    28     public function listing() 
     28    /***  
     29    === ADMIM METHODS 
     30    ***/ 
     31    public function admin_listing() 
    2932    { 
    3033        $this->layout = 'admin'; 
     
    3841        $this->set('data', $this->Catglossary->findAll( $conditions, $fields, $order, null, null, false));  
    3942     
    40     } 
    41      
    42     public function add() 
    43     { 
     43 } 
     44  
     45 public function admin_add() 
     46 { 
    4447        $this->layout = 'admin'; 
    4548        // adds new classroom to database 
    46        if (!empty($this->params['data'])) 
     49       if (!empty($this->data)) 
    4750       { 
    4851        $this->Sanitize = new Sanitize; 
    4952         
    50         $this->Sanitize->cleanArray($this->params['data']); //Hopefully this is enough 
     53        $this->Sanitize->cleanArray($this->data["Catglossary"]); //Hopefully this is enough 
    5154         
    52         if ($this->Catglossary->save($this->params['data'])) 
    53        { 
    54            //$this->set('data', $this->Catglossaries->index()); 
    55            $this->flash('Your Category Glossary has been saved.','/catglossaries/listing'); 
    56             
    57        //$this->render('todo', 'ajax'); 
    58       } 
     55        $this->Catglossary->clearUpFields(); 
     56        $this->Catglossary->create(); 
     57         
     58        if ($this->Catglossary->save($this->data["Catglossary"])) 
     59        { 
     60           $this->flash('Category Glossary saved.','/admin/catglossaries/listing'); 
     61        } 
    5962    }     
     63 } 
     64 
     65public function admin_edit($id=null) 
     66{ 
     67     $this->layout    = 'admin'; 
     68      
     69     if ( empty( $this->data["Catglossary"] ) ) 
     70     { 
     71         $this->Catglossary->id  = $id; 
     72          
     73         $this->data      = $this->Catglossary->read(); 
     74     } 
     75     else 
     76     {    
     77         $this->Sanitize = new Sanitize; 
     78          
     79         $this->Sanitize->html($this->data["Catglossary"]["title"]); 
     80          
     81         $this->Sanitize->html($this->data["Catglossary"]["body"]); 
     82          
     83         if ($this->Catglossary->save($this->data["Catglossary"])) 
     84         {   
     85            $this->msgFlash('Your category has been saved!', '/admin/catglossaries/edit/'.$this->data["Catglossary"]["id"]); 
     86         } 
     87     } 
     88 } 
     89  
     90 public function admin_delete($id) 
     91 { 
     92      if ($this->Catglossary->del($id)) 
     93      { 
     94          $this->msgFlash('Category deleted', '/admin/catglossaries/listing'); 
     95      } 
    6096    } 
    6197  } 
  • trunk/app/controllers/lessons_controller.php

    r31 r54  
    1010class LessonsController extends AppController 
    1111{ 
    12     public $helpers       = array('Ajax', 'Form', 'User', 'Fck'); 
     12    public $helpers       = array('Ajax', 'Form', 'User', 'Fck', 'Gags'); 
    1313     
    1414    public $components    = array('Edublog'); 
     
    4949    } 
    5050     
    51     public function all($user_id) { 
    52          
     51    public function all($user_id)  
     52    {    
    5353        $this->LessonTitle = 'Portfolio Blog'; 
    5454         
     
    6767    } 
    6868     
     69    /*** 
     70    === ADMIN METHODS 
     71    ****/ 
    6972    public function admin_listing() 
    7073    {    
     
    8588    
    8689    
    87    public function add() 
     90   public function admin_add() 
    8891   { 
    89         $this->layout    = 'admin'; 
    90         // adds new classroom to database 
    91     if (!empty($this->params['data'])) 
     92    $this->layout    = 'admin'; 
     93     
     94    if (!empty($this->data["Lesson"])) 
    9295    { 
    9396        $this->Sanitize = new Sanitize; 
    9497         
    95         $this->Sanitize->cleanArray($this->params['data']); //Hopefully this is enough 
     98        $this->Sanitize->html($this->data["Lesson"]["title"]); 
    9699         
    97           if ($this->Lesson->save($this->params['data'])) 
    98       { 
    99            $this->redirect('/lessons/listing/'); 
    100       } 
     100        $this->Sanitize->html($this->data["Lesson"]["body"]); 
     101         
     102        $this->data["Lesson"]["user_id"] = $this->othAuth->user('id');;  
     103         
     104        if ($this->Lesson->save($this->data["Lesson"])) 
     105        { 
     106           $this->msgFlash('Lesson saved', '/admin/lessons/listing/'); 
     107        } 
    101108    } 
    102    } 
     109  } 
     110  
     111public function admin_edit($id=null) 
     112{ 
     113     $this->layout    = 'admin'; 
     114      
     115     if ( empty( $this->data["Lesson"] ) ) 
     116     { 
     117         $this->Lesson->id  = $id; 
     118          
     119         $this->data      = $this->Lesson->read(); 
     120     } 
     121     else 
     122     {    
     123         $this->Sanitize = new Sanitize; 
     124          
     125         $this->Sanitize->html($this->data["Lesson"]["title"]); 
     126          
     127         $this->Sanitize->html($this->data["Lesson"]["body"]); 
     128          
     129         if ($this->Lesson->save($this->data["Lesson"])) 
     130         {    
     131             if ( $this->data["Lesson"]["end"] == 1 ) 
     132             { 
     133                                 $this->redirect('/admin/lessons/listing'); 
     134             } 
     135             else 
     136             { 
     137                                 $this->msgFlash('Your story has been saved!', '/admin/lessons/edit/'.$this->data["Lesson"]["id"]); 
     138             } 
     139        } 
     140     } 
     141 } 
     142  
     143 public function admin_delete($id) 
     144 { 
     145      if ($this->Lesson->del($id)) 
     146      { 
     147          $this->msgFlash('Lesson deleted', '/admin/lessons/listing'); 
     148      }  
     149      else 
     150      { 
     151           $this->flash('Error, call support', '/admin/lessons/listing'); 
     152      } 
     153  } 
    103154} 
    104155?> 
  • trunk/app/controllers/tests_controller.php

    r31 r54  
    1111  public $helpers = array('Form', 'Ajax'); 
    1212   
    13   public function index(){ 
     13  public function index() 
     14  { 
    1415         
    1516        $number = $this->Test->findCount();   
  • trunk/app/controllers/vclassmembers_controller.php

    r31 r54  
    11<?php 
    2 /* 
     2/** 
    33*  Karamelo E-Learning Platform 
    4 *  Manuel Montoya 2002-2006  
    5 GPL manuel<at>mononeurona.org 
     4*  Manuel Montoya 2002-2007 
     5Chipotle Software GPLv3 manuel<at>mononeurona.org 
    66*/  
    77  
     
    2727   } 
    2828    
    29    public function add($user_id = null, $classroom_id = null, $student_id = null) 
     29   public function jointoclass() 
    3030   { 
    31      
    32     $this->Vclassroom = new Vclassroom;  //Instantiate the model    
    33      
    34     if (empty($this->params['data'])) { 
     31    if (!empty($this->data["Vclassmember"]))  
     32    {    
     33        $code = $this->Vclassmember->Vclassroom->field('code', array("Vclassroom.id"=>$this->data['Vclassmember']['vclassroom_id'])); 
    3534         
    36         $this->layout    = $this->Edublog->layout($user_id); 
    37         $this->set('blog', $this->Edublog->blog($user_id)); 
    38          
    39         $conditions = array("id"=>$classroom_id); 
    40          
    41         $fields = array("id", "name", "invitation", "code"); 
    42          
    43         $data = $this->Vclassroom->find($conditions, $fields, null, true); 
    44          
    45         //echo $data['Vclassroom']['code']; 
    46          
    47         $check = $this->chkMember($classroom_id); 
    48          
    49         $this->set('check', $check); 
    50          
    51         $this->set('data', $data); 
    52      
    53     } 
    54     else  // adds new classroom to database 
    55     {  
    56         $this->Sanitize = new Sanitize; 
    57          
    58         $this->Sanitize->cleanArray($this->params['data']); //Hopefully this is enough 
    59          
    60         //print_r($this->params['data']); 
    61          
    62         //die(print_r($data)); 
    63          
    64         //echo $data['Vclassroom']['code']; 
    65          
    66         if ( $this->params['data']['Vclassmember']['invitation'] == 1 ) 
    67         {  
    68             $code = $this->Vclassroom->field('code', array("Vclassroom.id"=>$this->params['data']['Vclassmember']['vclassroom_id'])); 
     35        if ($code != $this->data['Vclassmember']['code'] || $code == null) //code is correct 
     36        { 
     37            $this->set('msg', 'Code is incorrect'); 
     38            $this->render('jointoclass', 'ajax'); 
     39            exit(); 
     40        } 
     41        elseif($this->chkMember($this->data['Vclassmember']['vclassroom_id'])) // the studen is not member 
     42        { 
     43            $this->set('msg', 'You are already member of this class!'); 
     44            $this->render('jointoclass', 'ajax'); 
     45            exit(); 
     46          
     47        } 
     48        else 
     49        { 
     50            $this->data['Vclassmember']['vclassroom_id']; 
    6951             
    70             if ($this->params['data']['Vclassmember']['code'] != $code) 
    71             { 
    72               die($this->flash('Your code is invalid', '/vclassmembers/add/'.$this->params['data']['Vclassmember']['user_id'].'/'.$this->params['data']['Vclassmember']['vclassroom_id'])); 
     52            $this->data['Vclassmember']['user_id']   = $this->othAuth->user('id'); 
     53             
     54            $this->Vclassmember->create(); 
     55             
     56            if ($this->Vclassmember->save($this->data['Vclassmember'])) 
     57            {   
     58               $this->set('msg', 'You have joined to this class succesfully!'); 
     59               $this->render('jointoclass', 'ajax'); 
     60               exit(); 
    7361            } 
    7462        } 
    75          
    76         if ($this->Vclassmember->save($this->params['data'])) 
    77         {  
    78           $link = '/vclassrooms/show/'. $this->params['data']['Vclassmember']['user_id'] .'/'. $this->params['data']['Vclassmember']['vclassroom_id']; 
    79               
    80           $this->flash('Your has been added to classroom.', $link); 
    81         } 
    8263    } 
    83      
    8464 } 
     65  
    8566 //Check if the user already exist in the classroom 
    86  protected function chkMember($classroom_id) 
    87  { 
    88    $check      = true; 
    89     
    90    $user_id    = $this->othAuth->user('id'); 
    91     
    92    $conditions = array('"Vclassmember"."user_id"'=>$user_id, '"Vclassmember"."vclassroom_id"'=>$classroom_id); 
     67 protected function chkMember($vclassroom_id) 
     68 {  
     69   $conditions = array('"Vclassmember"."user_id"'=>$this->othAuth->user('id'), '"Vclassmember"."vclassroom_id"'=>$vclassroom_id); 
    9370    
    9471   $val = $this->Vclassmember->field('id', $conditions); 
    9572    
    9673   if ( $val === false) 
    97     { 
    98      $check = false; 
    99     } 
    100     
    101    return $check; 
     74   { 
     75         return false; 
     76   } 
     77   else 
     78   { 
     79         return true; 
     80   } 
    10281 } 
    10382   
    104   public function edit($id = null) 
     83  public function admin_edit($id = null) 
    10584  { 
    10685    if (empty($this->data)) 
     
    11998} 
    12099   
    121   public function delete($id) 
     100  public function admin_delete($id) 
    122101  { 
    123102        // deletes task from database 
    124103        $this->Vclassmember->del($id); 
    125         $this->flash('Your virtual classroom  has been updated.','/vclassrooms'); 
     104        $this->msgFlash('Stuent has been deleted','/admin/vclassrooms/start'); 
    126105  } 
    127    
    128106} 
  • trunk/app/controllers/vclassrooms_controller.php

    r31 r54  
    1010class VclassroomsController extends AppController 
    1111 
    12    public $helpers       = array('Ajax', 'Form', 'Fck'); 
     12   public $helpers       = array('Ajax', 'Form', 'Fck', 'Gags'); 
    1313    
    1414   public $components    = array('Edublog'); 
    15     
    16    public function listing() 
    17    { 
     15 
     16   public function show($user_id, $id)  
     17    { 
     18         
     19        $this->pageTitle = 'Classrooms'; 
     20        $this->layout    = $this->Edublog->layout($user_id); 
     21        $this->set('blog', $this->Edublog->blog($user_id)); 
     22         
     23        $conditions = array("Vclassroom.status"=>1, "Vclassroom.id"=>$id); 
     24        $fields     = array("Vclassroom.id", "Vclassroom.name", "Vclassroom.description", "Vclassroom.subject_id", "Vclassroom.created", "Vclassroom.user_id", "Subject.title"); 
     25        $order      = "Vclassroom.name DESC"; 
     26         
     27        $this->set('data', $this->Vclassroom->find($conditions, $fields, $order, null, null, 2, 2)); 
     28    } 
     29      
     30/*** 
     31== ADMIN METHODS 
     32***/    
     33 public function admin_listing() 
     34 { 
    1835      $this->layout = 'admin'; 
    1936      $conditions = array("user_id"=>$this->othAuth->user('id')); 
     
    3047   } 
    3148    
    32    public function show($user_id, $id) { 
    33          
    34         $this->pageTitle = 'Classrooms'; 
    35         $this->layout    = $this->Edublog->layout($user_id); 
    36         $this->set('blog', $this->Edublog->blog($user_id)); 
    37          
    38         $conditions = array("Vclassroom.status"=>1, "Vclassroom.id"=>$id); 
    39         $fields     = array("Vclassroom.id", "Vclassroom.name", "Vclassroom.description", "Vclassroom.subject_id", "Vclassroom.created", "Vclassroom.user_id"); 
    40         $order      = "Vclassroom.name DESC"; 
    41          
    42         $this->set('data', $this->Vclassroom->findAll($conditions, $fields, $order, null, null, 2, 2)); 
    43     } 
    44     
    45    public function add() { 
     49    public function admin_add() { 
    4650     
    47     // adds new classroom to database 
    48     if (!empty($this->params['data'])) 
     51    if (!empty($this->data["Vclassroom"])) 
    4952    { 
    5053        $this->Sanitize = new Sanitize; 
    5154         
    52         $this->Sanitize->cleanArray($this->params['data']); //Hopefully this is enough 
     55        $this->Sanitize->cleanArray($this->data["Vclassroom"]); //Hopefully this is enough 
    5356         
    54         if ($this->Vclassroom->save($this->params['data'])) 
     57        if ($this->Vclassroom->save($this->data["Vclassroom"])) 
    5558         { 
    56            $this->redirect('/vclassrooms/listing'); 
    57          } 
    58     } else { 
     59           $this->redirect('/admin/vclassrooms/listing'); 
     60         } 
     61    }  
     62    else  
     63    { 
    5964      $this->layout = 'admin'; 
    6065       
     
    6974      $O = $this->Vclassroom->field('order', $conditions, $order); 
    7075       
    71       $Order = $O + 1; 
     76      $Order = $O + 1; //patch to list 1=>1 
    7277       
    7378      $this->set('Order', $Order); 
     
    7580         
    7681 } 
    77   
    78   public function edit($id = null) 
     82  /** 
     83  *   
     84  *  args id  
     85  *   
     86  **/  
     87  public function admin_edit($id = null) 
    7988  { 
    80       
    8189    if (empty($this->data)) 
    8290    { 
     
    93101    else 
    94102    { 
    95         if ($this->Vclassroom->save($this->data['Vclassroom'])) 
    96         { 
    97             $this->flash('Your virtual classroom  has been updated.','/vclassrooms/listing'); 
    98         } 
     103         $this->Sanitize = new Sanitize; 
     104        
     105       $this->Sanitize->cleanArray($this->data["Vclassroom"]); //Hopefully this is enough 
     106        
     107       if ($this->Vclassroom->save($this->data['Vclassroom'])) 
     108       { 
     109          $this->msgFlash('Your virtual classroom  has been updated.','/admin/vclassrooms/listing'); 
     110       } 
    99111    } 
    100112} 
    101113   
    102   public function delete($id) 
     114  public function admin_delete($id) 
    103115  { 
    104         // deletes task from database 
    105116        if ($this->Vclassroom->del($id)) 
    106         { 
    107           $this->redirect('/vclassrooms/listing'); 
    108         }  
    109         else 
    110         { 
    111            $this->flash('Error, call support', '/vclassrooms/listing'); 
    112         } 
     117      { 
     118          $this->msgFlash('Classroom deleted','/admin/vclassrooms/listing'); 
     119      }  
     120      else 
     121      { 
     122           $this->flash('Error, call support', '/admin/vclassrooms/listing'); 
     123      } 
    113124  } 
    114125   
  • trunk/app/views/elements/subjects.thtml

    r45 r54  
    22    echo '<div style="text-align:center;margin:15px auto 15px auto;">'; 
    33    echo  $ajax->link($html->image("static/subjects.png", array("alt"=>"Subjects", "title"=>"Subjects", "style"=>"border:1px solid #fff")), '/subjects/display', array("update" => "qn", 
    4     "loading"=>"Element.show('loading3');", "complete"=>"Element.hide('loading3');Effect.Appear('updater')"),  
     4    "loading"=>"Element.show('loading3');", "complete"=>"Element.hide('loading3');Effect.Appear('qn')"),  
    55                null, false); 
    66    echo "</div>"; 
  • trunk/app/views/elements/vclassrooms.thtml

    r1 r54  
    11<div class="temas">Classrooms</div> 
    2 <? 
    3 //var_dump($podcast); 
    4  
    5 foreach ($blog[0]["Vclassroom"] as $key => $val) { 
    6   echo '<a class="petit" href="/vclassrooms/show/'.$val['user_id'].'/'. $val['id'] . '">&gt;'. $val['name'] . '</a><br />'; 
     2<?php 
     3foreach ($blog[0]["Vclassroom"] as $key => $val)  
     4{ 
     5  echo $html->link($val['name'], '/vclassrooms/show/'.$val['user_id'].'/'. $val['id'], array("class"=>"petit")) . "<br />\n"; 
    76} 
    8  
    97?> 
    108 
  • trunk/app/views/galleries/admin_listing.thtml

    r18 r54  
     1<script type="text/javascript"> 
     2   window.onload = timedMsg; 
     3</script> 
     4<?php $session->flash(); ?> 
    15<?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?>  
    26<?php echo $html->getCrumbs(' / '); ?> 
    37 
    4 <p><?php echo $html->link($html->image('admin/new.gif', array("alt"=>"Add new gallery", "title"=>"Add new gallery")), '/admin/galleries/add', null, false, false) ?></p> 
     8<p><?php echo $html->link($html->image('admin/new.gif', array("alt"=>"Add new page", "title"=>"Add new page")), '/admin/galleries/add', null, false, false) ?></p> 
    59 
    610<table class="tbadmin"> 
  • trunk/app/views/lessons/admin_add.thtml

    r19 r54  
    44?> 
    55 
    6 <div class="title_section">Add new Lesson</div> 
    7  
    8 <div class="spaced"> 
    9  
    10 <?php echo $html->formTag('/lessons/add/','post'); ?> 
     6<?php echo $html->formTag('/admin/lessons/add/','post'); ?> 
    117<fieldset> 
    12   <p> 
    13   <?php echo $form->labelTag( 'Lesson/title', 'Title:' );?><br /> 
    14   <?php echo $html->input('Lesson/title', array("size" => 50, "maxlength" => 120, "class"=>"formas")); ?> 
    15   <?php echo $html->tagErrorMsg('Lesson/title', 'Title is required.'); ?> 
    16   <br /><br /> 
    17    
    18   <p><?php echo $form->labelTag( 'Lesson/body', 'Body:' );?><br /> 
    19   <?php echo $html->textarea('Lesson/body', array("class"=>"formas", "cols"=>80, "rows"=>45)) ?> 
    20   <?php echo $fck->load('Lesson/body', 'Karamelo'); ?>  
    21   <?php echo $html->tagErrorMsg('Lesson/body', 'Body is required.'); ?> 
    22   <br /> 
    23   </p> 
    24    
    25   <p><?php echo $form->labelTag( 'Lesson/status', 'Published:' );?><br /> 
    26   <?php echo $html->checkbox('Lesson/status'); ?> 
    27   <br /><br /> 
    28    
    29   <p><?php echo $form->labelTag( 'Lesson/disc', 'Comments allowed to this Lesson:' );?><br /> 
    30   <?php echo $html->checkbox('Lesson/disc'); ?> 
    31   <br /><br /> 
    32    
    33   <?php echo $html->hiddenTag('Lesson/user_id', $othAuth->user('id')) ?> 
    34    
    35    
    36   <br /> 
    37   <?php echo $html->submit('Send'); ?> 
     8<legend>Add Lesson</legend> 
     9<table> 
     10<tr><td> 
     11  <?php  
     12     echo $form->labelTag( 'Lesson/title', 'Title:' ); 
     13     echo $html->input('Lesson/title', array("size" => 50, "maxlength" => 120, "class"=>"formas")); 
     14     echo $html->tagErrorMsg('Lesson/title', 'Title is required.');  
     15  ?> 
     16  </td> 
     17  <td> 
     18  <?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) ?> 
     19</td> 
     20</tr> 
     21<tr> 
     22  <td colspan="2"> 
     23  <?php  
     24      echo $form->labelTag( 'Lesson/body', 'Body:' ); 
     25      echo $html->textarea('Lesson/body', array("class"=>"formas", "cols"=>80, "rows"=>45)); 
     26      echo $fck->load('Lesson/body', 'Karamelo'); 
     27      echo $html->tagErrorMsg('Lesson/body', 'Body is required.');  
     28  ?> 
     29  </td></tr> 
     30  <tr><td> 
     31  <?php  
     32     echo $form->labelTag( 'Lesson/status', 'Published:' ); 
     33     echo $html->checkbox('Lesson/status');  
     34  ?> 
     35  </td><td> 
     36  <?php  
     37      echo $form->labelTag( 'Lesson/disc', 'Comments allowed to this Lesson:' ); 
     38      echo $html->checkbox('Lesson/disc');  
     39  ?> 
     40  </td></tr> 
     41  <tr><td colspan="2">  
     42  <?php echo $html->submit('Save'); ?> 
     43</td></tr> 
     44</table> 
    3845</fieldset> 
    3946</form>