Changeset 438

Show
Ignore:
Timestamp:
04/28/08 17:15:07 (9 months ago)
Author:
aarkerio
Message:

Treasures changes

Location:
trunk/app
Files:
12 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/sql/postgresql/treasures_vclassrooms.sql

    r436 r438  
    11--HABTM 
    22CREATE TABLE "treasures_vclassrooms" ( 
    3   "treasure_id"   int NOT NULL REFERENCES treasures(id), 
    4   "vclassroom_id" int NOT NULL REFERENCES vclassrooms(id), 
    5   PRIMARY KEY  ("vclassroom_id", "treasure_id") 
     3 "id" serial PRIMARY KEY, 
     4 "treasure_id" int NOT NULL REFERENCES treasures(id) ON DELETE CASCADE, 
     5 "vclassroom_id" int NOT NULL REFERENCES vclassrooms(id) ON DELETE CASCADE, 
     6  UNIQUE  ("treasure_id", "vclassroom_id") 
    67); 
    78 
  • trunk/app/controllers/helps_controller.php

    r435 r438  
    88*  @package Karamelo 
    99*/ 
    10 // file : app/controller/faqs_controller.php 
     10// file : app/controller/helps_controller.php 
    1111 
    1212uses('sanitize'); 
     
    118118     if (!empty($this->data['Help'])) 
    119119     { 
     120          //die(debug($this->data['Help'])); 
    120121        $this->Sanitize = new Sanitize; 
    121122         
     
    126127        $this->Help->create(); 
    127128 
    128           if ($this->Help->save($this->data['Help'])) 
    129       { 
    130           $id = $this->Help->getLastInsertID(); 
     129        if ($this->Help->save($this->data['Help'])) 
     130         { 
     131               $id = $this->Help->getLastInsertID(); 
    131132              $this->msgFlash('Help saved','/admin/helps/edit/'.$id); 
    132        } 
     133         } 
    133134      }  
    134135 } 
  • trunk/app/controllers/images_controller.php

    r394 r438  
    88*  @package Karamelo 
    99*/ 
    10 // file : app/controller/faqs_controller.php  
     10// file : app/controller/images_controller.php 
     11 
    1112uses('sanitize'); 
    1213 
    1314class ImagesController extends AppController 
    1415{ 
    15   public $helpers       = array('Ajax',  'User'); 
    16      
     16  public $helpers       = array('Ajax'); 
     17   
    1718  public $components    = array('Adds'); 
    18  
     19   
    1920  public function isAuthorized()  
    2021  {       
     
    2829    return false;  // go away !! 
    2930 } 
    30    
    31   public function index($id = null) 
    32   { 
    33         $this->pageTitle = 'View Active Users'; 
    34         $this->set('data', $this->User->findAll());  
    35         $this->set('color', 'blue'); 
    36   } 
    37   /*** 
    38   === ADMIN METHODS 
    39   ***/     
    40   public function admin_listing($set = null) 
    41   {    
     31  
     32 /***  === ADMIN METHODS  ***/ 
     33  
     34 public function admin_listing($set = null) 
     35 {    
    4236        // $set defines if display in admin layout or in small popup window 
    4337        if ($set == null) 
     
    6256        $order      = "Image.id DESC"; 
    6357         
    64         $data       = $this->Image->findAll($conditions, $fields, $order, $limit); 
    65          
    66         $this->set('data', $data); 
    67     } 
    68     
    69     public function admin_add($type = null)  
    70     { 
    71      
    72     //die(print_r($this->data)); 
    73      
     58        $this->set('data', $this->Image->findAll($conditions, $fields, $order, $limit)); 
     59    } 
     60    
     61 public function admin_add($set = null)  
     62 { 
     63     
     64    //die(debug($this->data)); 
     65      
     66    if ($this->data['Image']['file']['error'] == 1) 
     67    { 
     68         $this->flash('Error uploading image, please contact the support team', '/admin/images/listing'); 
     69     } 
     70      
    7471    $this->layout    = 'admin'; 
    7572     
     
    9289    /** uploaddir:  directory relative to where script is running */ 
    9390     
    94     if ( isset($type) && $type == 'avatar')   // avatar or user image? 
    95     { 
    96         $uploaddir    = "../webroot/img/avatars"; 
    97     }  
    98     else  
    99     { 
    100         $uploaddir    = "../webroot/img/imgusers"; 
    101     } 
     91    $uploaddir    = "../webroot/img/imgusers"; 
    10292     
    10393    $maxfilesize  = 2097152; /** 2MB max size */ 
     
    127117    if ( $imgfile_size > $maxfilesize)  
    128118    { 
    129      $ErrMsg  = "<h1>ERROR</h1> The image is too big.<br>"; 
     119          $ErrMsg  = "<h1>ERROR</h1> The image is too big.<br>"; 
    130120         $ErrMsg .= "<p>Bigger than 2.0 MB <br><br>"; 
    131121         $ErrMsg .= "Current size: " . $imgfile_size ."</p>\n"; 
     
    163153       } 
    164154   } 
    165     
    166    /*** Create thumb***/ 
    167     if ( $type != 'avatar') 
    168     { 
    169          $this->createThumb($final_filename); 
    170     } 
     155     
     156   /**  made thumb **/ 
     157   $this->createThumb($final_filename); 
     158     
    171159   /** Database stuff  **/ 
    172160    
     
    179167   {      
    180168     $this->redirect($this->data['Image']['return']); //go back to display gallery 
    181      exit(); 
    182169   } 
    183170    
  • trunk/app/controllers/tests_controller.php

    r431 r438  
    162162 } 
    163163 
    164  private function chk($user_id) // preview tests before send 
     164 private function chk($user_id) // preview tests before send, this method is for 0.3 version     
    165165 { 
    166166    try { 
  • trunk/app/controllers/treasures_controller.php

    r437 r438  
    55*  GPLv3 manuel<at>mononeurona<dot>org 
    66*/  
     7//File: /app/controllers/treasures_controller.php 
     8 
     9 
    710uses('sanitize'); 
     11uses('L10n'); 
    812 
    913class TreasuresController extends AppController { 
     
    1923        if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 )  // admin and teachers 
    2024        { 
    21         return true; 
     25           return true; 
    2226        }  
    2327    }  
     
    9195  } 
    9296   
    93   public function admin_add() 
    94   { 
     97  public function admin_vclassrooms($treasure_id) 
     98  {     
     99   $this->pageTitle = $this->Auth->user('username') . '\'s Treasure'; 
     100       
     101   $this->layout = 'admin'; 
     102       
     103   $conditions   = array('Vclassroom.user_id'=>$this->Auth->user('id'), 'Vclassroom.status'=>1); 
     104    
     105   $this->set('data', $this->Treasure->Vclassroom->findAll($conditions));  
     106 
     107   $this->Treasure->unbindModel(array('belongsTo'=>array('User'))); 
     108 
     109   $this->set('treasures',$this->Treasure->TreasuresVclassroom->findAll(array('TreasuresVclassroom.treasure_id' => $treasure_id))); 
     110    
     111   $this->set('treasure_id', $treasure_id); 
     112 } 
     113  
     114  public function admin_link2class()  
     115 { 
     116    $this->layout    = 'admin'; 
     117    // add to database 
     118   if ( !empty($this->data['TreasuresVclassroom']) ) 
     119   { 
     120      $this->Sanitize = new Sanitize; 
     121            
     122      $this->Sanitize->clean($this->data['TreasuresVclassroom']); 
     123                  
     124      $this->Treasure->TreasuresVclassroom->create(); 
     125       
     126      if ( $this->Treasure->TreasuresVclassroom->save($this->data['TreasuresVclassroom'])) 
     127      { 
     128               $this->msgFlash('Treasure assigned', '/admin/treasures/vclassrooms/'.$this->data['TreasuresVclassroom']['treasure_id']); 
     129      } 
     130      else 
     131      {  
     132              die('Something is wrong, please report this bug'); 
     133      } 
     134   } 
     135 } 
     136 
     137  public function admin_unlink2class()  
     138 { 
     139    $this->layout    = 'admin'; 
     140    // add to database 
     141   if ( !empty($this->data['TreasuresVclassroom']) ) 
     142   { 
     143      $this->Sanitize = new Sanitize; 
     144            
     145      $this->Sanitize->clean($this->data['TreasuresVclassroom']); 
     146                  
     147      if ( $this->Treasures->TreasuresVclassroom->delete($this->data['TreasuresVclassroom']['id'])) 
     148      { 
     149               $this->msgFlash('Test unlinked', '/admin/tests/vclassrooms/'.$this->data['TreasuresVclassroom']['treasure_id']); 
     150      } 
     151      else 
     152      {  
     153              die('Something is wrong, please report this bug'); 
     154      } 
     155   } 
     156 } 
     157  
     158 public function admin_add() 
     159 { 
    95160       $this->layout    = 'admin'; 
    96161       // adds new blog entries  
    97162       if ( !empty($this->data['Treasure']) )   
    98      {  
    99       $this->Sanitize = new Sanitize; 
    100        
     163        {  
     164           $this->Sanitize = new Sanitize; 
     165           
    101166          $this->Sanitize->html($this->data["Treasure"]["title"]); 
    102  
     167           
    103168          $this->Sanitize->html($this->data["Treasure"]["instructions"]); 
    104169          
     
    109174          if ($this->Treasure->save($this->data['Treasure'])) 
    110175          {  
    111          $id = $this->Treasure->getLastInsertId(); 
    112              $this->msgFlash('Treasure registered', '/admin/treasures/edit/'.$id); 
     176              $id = $this->Treasure->getLastInsertId(); 
     177             $this->msgFlash('Treasure saved', '/admin/treasures/edit/'.$id); 
    113178          }  
    114179          else  
     
    162227 } 
    163228  
    164  public function admin_delete($id) 
    165  { 
    166     $this->Treasure->del($id); 
    167      
    168     $this->msgFlash('Treasure deleted', '/admin/treasures/listing'); 
    169   } 
     229 public function admin_delete() 
     230 { 
     231    if ($this->Treasure->del($this->data['Treasure']['id'])) 
     232     { 
     233      $this->msgFlash('Treasure deleted', '/admin/treasures/listing'); 
     234    } 
     235 } 
    170236} 
    171237?> 
  • trunk/app/models/treasure.php

    r162 r438  
    11<?php 
    2 /**  Chipotle Software 2002-2007 GPLv3 **/ 
     2/** 
     3*  Karamelo eLearning Platform 
     4*  Chipotle Software 2002-2008  
     5*  GPLv3 manuel<arroba>mononeurona<punto>org 
     6**/  
     7 
    38class Treasure extends AppModel { 
    49 
     
    611    
    712   public $belongsTo = 'User'; 
    8  
     13    
     14    public $hasAndBelongsToMany = array('Vclassroom' => 
     15                       array('className'             => 'Vclassroom', 
     16                         'joinTable'             => 'treasures_vclassrooms', 
     17                         'foreignKey'            => 'treasure_id', 
     18                         'associationForeignKey' => 'vclassroom_id', 
     19                         'conditions'            => null, 
     20                         'order'                 => null, 
     21                         'limit'                 => '', 
     22                         'unique'                => true, 
     23                         'finderQuery'           => '', 
     24                         'deleteQuery'           => '' 
     25                         ) 
     26                            );    
     27     
    928   public $validate = array( 
    1029      'user_id' => VALID_NOT_EMPTY, 
  • trunk/app/views/helps/admin_edit.ctp

    r435 r438  
    1515<tr> 
    1616  <td> 
    17   <?php echo $html->input('Help.url', array("size" => 30, "maxlength" => 100)); ?> 
     17  <?php echo $form->input('Help.url', array("size" => 30, "maxlength" => 100)); ?> 
    1818 
    1919</td> 
    2020<td> 
    2121   <?php  
    22     echo $form->labe('Help.lang', 'Lang:') .'<br />'; 
     22    echo $form->label('Help.lang', 'Lang:') .'<br />'; 
    2323    $langs = array("en"=>"English", "es"=>"Espanol", "fr"=>"Francaise", "de"=>"Deutschland", "af"=>"Afrikaans", "id"=>"Indonesian"); 
    2424    echo $form->select('Help.lang', $langs, null, null, null, false);  
     
    3333<tr><td colspan="3"> 
    3434   <?php  
    35      echo $form->label('Help.help', 'Help:' ); 
    36      echo $form->textarea('Help.help', array('cols'=>80, 'rows'=>25))  
    37      echo $fck->load('HelpHelp', 'Karamelo', 700, 300);  
     35     echo $form->label('Help.help', 'Help:'); 
     36     echo $form->textarea('Help.help', array('cols'=>80, 'rows'=>25));  
     37     echo $fck->load('HelpHelp', 'Karamelo', 700, 600);  
    3838   ?>  
    3939</td></tr> 
    4040 
    4141<tr> 
    42   <td colspan="3"><?php echo $form->label( 'Help.end', 'End edition:' ); echo $form->checkbox('Help.end', array('value'=>1)); ?></td> 
     42  <td colspan="3"><?php echo $form->label( 'Help.end', 'End edition:') . $form->checkbox('Help.end', array('value'=>1)); ?></td> 
    4343</tr> 
    4444<tr><td colspan="3"> 
  • trunk/app/views/images/admin_add.ctp

    r268 r438  
    1 <?php echo $javascript->link('myfunctions'); ?> 
    2  
    3 <div class="title_section">Add new image</div> 
    4  
    5 <div class="spaced"> 
    6  
    7 <?php echo $html->formTag('/images/add/','post', array("enctype"=>"multipart/form-data") ); ?> 
    8 <?php echo $html->hiddenTag('Image/user_id', $othAuth->user('id')); ?> 
    9 <?php echo $html->hiddenTag('return', '/users/edit'); ?> 
     1<?php  
     2 echo $javascript->link('myfunctions'); 
     3  
     4 echo $html->div('title_section', 'Add new image'); 
     5  
     6 echo $form->create('Image', array("enctype"=>"multipart/form-data") ); 
     7 echo $form->hidden('return', array('value'=>'/admin/images/listing'));  
     8?> 
    109   
    1110<fieldset> 
    1211  <legend>Image</legend> 
    13     
    14    <p> 
    15    <?php echo $form->labelTag( 'Image/file', 'Title:' );?><br /> 
    16    <?php echo $html->file('Image/file'); ?> 
    17    <?php echo $html->tagErrorMsg('Image/file', 'Title is required.'); ?> 
    18    
    19   <br /> 
    20   <?php echo $html->submit('Upload'); ?> 
     12   <?php  
     13     echo $form->label( 'Image.file', 'Title:' ); 
     14    echo $form->file('Image.file');  
     15    echo $form->end('Upload');  
     16  ?> 
    2117</fieldset> 
    22 </form> 
    23 </div> 
     18 
  • trunk/app/views/images/admin_listing.ctp

    r375 r438  
    1919  <td style="text-align:left;" colspan="5">   
    2020  <?php  
    21      echo $form->create('Image', array('action'=>'add', 'enctype'=>'multipart/form-data'));  
     21     echo $form->create('Image', array('enctype'=>'multipart/form-data'));  
    2222     echo $form->hidden('Image.return', array('value'=>'/admin/images/listing/'.$return));  
    2323  ?> 
    2424  <fieldset> 
    25      <legend>Upload Image</legend> 
     25     <legend><?php echo __('Upload Image'); ?></legend> 
    2626      
    27      <?php echo $form->label('Image.file', 'File:' ); 
     27     <?php echo $form->label('Image.file', 'File:'); 
    2828           echo $form->file('Image.file');  
    29            echo $form->error('Image.file', 'Title is required.');  
    30            echo '</fieldset>'; 
     29           echo $form->error('Image.file', 'File is required.'); 
    3130           echo $form->end('Upload');  
    3231      ?> 
     32  </fieldset> 
    3333</td> 
    3434</tr> 
  • trunk/app/views/treasures/admin_edit.ctp

    r437 r438  
    22 
    33 echo $html->addCrumb('Control Tools', '/admin/entries/start');   
    4  echo $html->addCrumb('News', '/admin/treasures/listing');  
     4 echo $html->addCrumb('Treasures', '/admin/treasures/listing');  
    55 echo $html->getCrumbs(' / ');  
    66 echo $form->create('Treasure',array('onsubmit'=>'return chkForm()'));  
  • trunk/app/views/treasures/admin_listing.ctp

    r437 r438  
    1717         echo $html->div('butonright', $gags->sendEdit($val['Treasure']['id'], 'treasures')); 
    1818         echo $html->div('div_title', $val['Treasure']['title']); 
    19          echo $html->para(null, '<b>Treasure description:</b> '.$val['Treasure']['description']); 
    2019 
    21          echo $html->link('Questions', '/admin/treasures/questions/'.$val['Treasure']['id']); 
    22          echo $html->link($html->image('admin/questions_icon.gif', array('alt'=>'Questions', 'title'=>'Questions')),  
    23                           '/admin/treasures/questions/'.$val['Treasure']['id'], null, null, false) . '<br />'; 
    2420         if ( count($val['Vclassroom']) < 1 )  
    2521         {