Changeset 774 for trunk

Show
Ignore:
Timestamp:
09/23/08 21:12:59 (2 months ago)
Author:
aarkerio
Message:

Test Unit fixed

Location:
trunk/app/controllers
Files:
8 modified

Legend:

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

    r730 r774  
    8383         
    8484     $conditions = array('Answer.user_id'=>$this->Auth->user('id'), 'Answer.id'=>$test_id); 
    85          
    86      $fields     = array("Answer.id", "Answer.user_id", "Answer.title", "Answer.description"); 
    87          
    88      $order    = 'Answer.id DESC'; 
    89          
     85     $fields     = array('Answer.id', 'Answer.user_id', 'Answer.title', 'Answer.description'); 
     86     $order      = 'Answer.id DESC' 
    9087     $this->set('data', $this->Answer->findAll($conditions, $fields, $order)); 
    9188  } 
     
    104101  public function admin_delete($answer_id, $question_id)  
    105102  { 
    106       // deletes from database 
    107        
    108       if ( $this->Answer->del($answer_id) ) 
    109       { 
    110             $this->msgFlash('Answer deleted', '/admin/questions/answers/'.$question_id); 
    111       }  
    112       else  
    113       { 
    114             $this->flash('Database error!', '/admin/tests/listing'); 
    115       } 
     103    // deletes from datab 
     104    if ( $this->Answer->del($answer_id) ): 
     105            $this->msgFlash(__('Answer deleted', true), '/admin/questions/answers/'.$question_id); 
     106    endif; 
    116107  } 
    117108} 
  • trunk/app/controllers/medias_controller.php

    r540 r774  
    9595        } 
    9696    } 
    97 } 
    98  
    99   public function listing($order = null) { 
    100         
    101        $this->layout    = 'admin'; 
    102         
    103        $conditions = array("Media.user_id"=>$this->Auth->user('id')); 
    104         
    105        $fields     = array("id", "file", "user_id", "size", "created", "status"); 
    106         
    107        if ($order == null) 
    108        { 
    109            $ordenation = "Media.id DESC"; 
    110        } else { 
    111            $ordenation = "Media.".$order." DESC"; 
    112        } 
    113         
    114        $this->set('data', $this->Media->findAll($conditions, $fields, $ordenation)); 
    115         
    116    } 
    117     
    118     public function change($id, $status) 
    119     {    
    120         $this->params['data']['Media']['status'] = ($status == 0 ) ? 1 : 0; 
    121          
    122         $this->params['data']['Media']['id']    = $id; 
    123          
    124         if ($this->Media->save($this->params['data'])) 
    125           { 
     97 } 
     98 
     99 public function listing($order = null)  
     100 { 
     101  $this->layout    = 'admin'; 
     102  $conditions = array("Media.user_id"=>$this->Auth->user('id')); 
     103  $fields     = array("id", "file", "user_id", "size", "created", "status"); 
     104  $ordenation = "Media.id DESC"; 
     105  $this->set('data', $this->Media->findAll($conditions, $fields, $ordenation)); 
     106 } 
     107  
     108 public function change($id, $status) 
     109 { 
     110  $this->data['Media']['status'] = ($status == 0 ) ? 1 : 0; 
     111  $this->data['Media']['id']    = $id; 
     112  if ($this->Media->save($this->data)) 
     113  { 
    126114            $this->redirect('/medias/listing/'); 
    127           } else { 
     115  } else { 
    128116           $this->flash('Problem!!', '/medias/listing/'); 
    129         } 
    130          
    131     } 
     117  } 
     118 } 
    132119    
    133120  /*** DELETE  **/  
     
    142129   
    143130 /****   ADD MEDIA FILE   ***/ 
    144  public function add() { 
    145      
     131 public function add()  
     132 {     
    146133    //die(print_r($this->params)); 
    147134     
  • trunk/app/controllers/podcasts_controller.php

    r757 r774  
    172172      // valid file ?? 
    173173      $err =   "ERROR the file $podfile_name $podfile is not valid. Only .mp3 files. The current type file: " . $type; 
    174          
    175         /** delete uploaded file ==*/ 
     174       /**== delete uploaded file ==*/ 
    176175       unlink($podfile); 
    177        $this->flash($err,'/admin/podcasts/add/'); 
     176       $this->flash($err,'/admin/podcasts/add/', 3); 
    178177       return false; 
    179178    endif; 
     
    184183       /** delete uploaded file ==*/ 
    185184       unlink($podfile); 
    186        $this->flash($err,'/admin/podcasts/add/'); 
     185       $this->flash($err,'/admin/podcasts/add/', 3); 
    187186       return false; 
    188187     
    189188    endif; 
    190189     
    191     $field       = "id"; 
    192      
    193     $conditions  = array("user_id" =>  $this->Auth->user('id')); 
    194      
    195     $order       = "Podcast.id DESC"; 
    196      
     190    $field       = 'id'; 
     191    $conditions  = array('user_id' =>  $this->Auth->user('id')); 
     192    $order       = 'Podcast.id DESC'; 
    197193    $current_id  = $this->Podcast->field($field, $conditions, $order); 
    198      
    199194    $next_id     = ($current_id + 1); 
    200       
    201195    $extension   = $this->Adds->last3chars($podfile_name); // get the file extesion 
    202196     
     
    219213             /** if an error occurs the file could not 
    220214               be written, read or possibly does not exist ==*/ 
    221    
    222            $this->flash('Error Uploading File.', '/admin/podcasts/listing/'); 
     215           $this->flash('Error Uploading File.', '/admin/podcasts/listing/', 3); 
    223216           return false; 
    224217        endif; 
     
    240233   $this->data['Podcast']['created']     = $created; 
    241234   $this->data['Podcast']['user_id']     = $this->Auth->user('id'); 
    242     
    243    $this->Podcast->create(); 
    244     
     235   
    245236   if ($this->Podcast->save($this->data)): 
    246237       $this->msgFlash('Your podcast has been saved.','/admin/podcasts/listing'); 
  • trunk/app/controllers/replies_controller.php

    r742 r774  
    6767        $this->data = $this->Reply->read(); 
    6868   else: 
    69     
    70         if ($this->Reply->save($this->data['Reply'])): 
    71              $this->flash(__('Reply updated', true),'/admin/topics/listing/'.$this->data['Reply']['topic_id']); 
    72     endif; 
     69     if ($this->Reply->save($this->data['Reply'])): 
     70          $this->msgFlash(__('Reply updated', true),'/admin/topics/listing/'.$this->data['Reply']['topic_id']); 
     71     endif; 
    7372   endif; 
    7473 } 
     
    7877 {   
    7978    $this->data['Reply']['status'] = ($status == 0 ) ? 1 : 0; 
    80       
    8179    $this->data['Reply']['id']     = (int) $reply_id; 
    82       
    8380    if ($this->Reply->save($this->data, array('validate'=>false))): 
    8481       $this->msgFlash(__('Status modified', true), '/admin/topics/listing/'.$topic_id); 
  • trunk/app/controllers/reports_controller.php

    r741 r774  
    2828 { 
    2929   if ($this->data['Report']['file']['error'] == 1): 
    30         $this->flash('Error uploading file, please contact the support team. Push Back button', '/'); 
     30        $this->flash('Error uploading file, please contact the support team. Push Back button', '/', 3); 
    3131   endif; 
    3232 
     
    5656        /**  delete uploaded file ==*/ 
    5757         unlink($file); 
    58          $this->flash($msg, '/admin/shares/listing'); 
     58         $this->flash($msg, '/admin/shares/listing', 3); 
    5959         return false; 
    6060    endif; 
     
    6565      /**  delete uploaded file ==*/ 
    6666      unlink($file); 
    67       $this->flash($msg, $url); 
     67      $this->flash($msg, $url, 3); 
    6868      return false; 
    6969    endif; 
     
    9494     if (!move_uploaded_file($file, $newfile)): 
    9595        /** if an error occurs the file could not be written, read or possibly does not exist ==*/         
    96                  $this->flash('Error Uploading File'); 
     96                 $this->flash('Error Uploading File', '/', 3); 
    9797                 return false; 
    9898              endif; 
  • trunk/app/controllers/shares_controller.php

    r733 r774  
    107107        /**  delete uploaded file ==*/ 
    108108        unlink($file); 
    109         $this->flash($msg, '/admin/shares/listing'); 
     109        $this->flash($msg, '/admin/shares/listing', 3); 
    110110        return false; 
    111111    endif; 
     
    115115        /**  delete uploaded file ==*/ 
    116116        unlink($file); 
    117         $this->flash($msg, '/admin/shares/listing'); 
     117        $this->flash($msg, '/admin/shares/listing', 3); 
    118118        return false; 
    119119    endif; 
    120120     
    121121    $conditions  = array('user_id' =>  $this->Auth->user('id')); 
    122      
    123122    $order       = 'Share.id DESC'; 
    124      
    125123    $current_id  = $this->Share->field('id', $conditions, $order); 
    126  
    127124    $next_id     = ($current_id + 1); 
    128      
    129125    $extension   = $this->get_extension($file_name); 
    130      
    131126    $allowed     = array('pdf', 'doc', 'xls', 'xcf', 'ppt', 'sxw', 'odt', 'odc', 'swf', 'ods', 'odp', 'abw', 'html', 'zip', 'rar', 'gz', 'png', 'jpg', 'gif', 'svg', 'mp3', 'ogg', 'flac', 'txt'); 
    132127     
  • trunk/app/controllers/themeblogs_controller.php

    r540 r774  
    4343        $this->Themeblog->save(); 
    4444     
    45         if ($this->Themeblog->save($this->data['Themeblog'])) 
    46         {    
     45        if ($this->Themeblog->save($this->data['Themeblog'])): 
    4746            $conditions = array("user_id" => $this->Auth->user('id')); 
    48              
    4947        $this->set('data', $this->Themeblog->findAll($conditions)); 
    50              
    5148        $this->render('themes', 'ajax'); 
    52         } 
    53         else { 
    54            
    55           $this->flash('Database error!', '/entries/listing'); 
    56         } 
     49        endif; 
    5750     } 
    5851  } 
     
    6154  { 
    6255     $this->layout    = 'ajax'; 
    63       
    64      if (empty($this->data["Themeblog"])) 
    65      {      
     56     if (empty($this->data['Themeblog'])): 
    6657           $this->Themeblog->unbindModel(array('hasMany' => array('Entry'))); 
    67             
    68            $this->set('data', $this->Themeblog->find(array("id"=>$id), array("title", "id"))); 
    69             
     58           $this->set('data', $this->Themeblog->find(array("id"=>$id), array('title', 'id'))); 
    7059           $this->render('row', 'ajax'); 
    71      } 
    72      else 
    73      { 
     60     else: 
    7461         $this->Sanitize = new Sanitize; 
    75           
    7662         $this->Sanitize->clean($this->data['Themeblog']); 
    77           
    78          if ($this->Themeblog->save($this->data['Themeblog'])) 
    79          { 
     63         if ($this->Themeblog->save($this->data['Themeblog'])): 
    8064            $this->Themeblog->unbindModel(array('hasMany' => array('Entry'))); 
    81              
    82             $data = $this->Themeblog->find(array("id"=>$this->data['Themeblog']['id']), array("title", "id")); 
    83              
     65            $data = $this->Themeblog->find(array("id"=>$this->data['Themeblog']['id']), array('title', 'id')); 
    8466            //exit(print_r($data)); 
    85              
    8667            $this->set('data', $data); 
    87              
    8868            $this->render('admin_cancel', 'ajax'); 
    89          } 
    90      } 
    91    } 
    92    
     69         endif; 
     70     endif; 
     71  } 
     72 
    9373  public function admin_cancel($id = null) 
    9474  { 
    95         $this->layout    = 'ajax'; 
    96          
    97         $this->Themeblog->unbindModel(array('hasMany' => array('Entry'))); 
    98          
    99         $this->set('data', $this->Themeblog->find(array("id"=>$id), array("title", "id"))); 
    100          
    101         $this->render('admin_cancel', 'ajax'); 
     75    $this->layout    = 'ajax'; 
     76    $this->Themeblog->unbindModel(array('hasMany' => array('Entry'))); 
     77    $this->set('data', $this->Themeblog->find(array("id"=>$id), array('title', 'id'))); 
     78    $this->render('admin_cancel', 'ajax'); 
    10279  } 
    103    
    104   public function admin_delete($id) 
     80 
     81  public function admin_delete($theme_id) 
    10582  { 
    10683    // deletes category from DBKARAMELO database 
    107      $this->Themeblog->del($id); 
    108       
    109      $conditions = array("user_id" => $this->Auth->user('id')); 
    110       
     84     $this->Themeblog->del($theme_id); 
     85     $conditions = array('user_id' => $this->Auth->user('id')); 
    11186     $this->set('data', $this->Themeblog->findAll($conditions, null, "title")); 
    112       
    11387     $this->render('themes', 'ajax'); 
    11488  } 
  • trunk/app/controllers/themes_controller.php

    r540 r774  
    77  
    88uses('sanitize'); 
    9 uses('l10n'); 
    109 
    11 class ThemesController extends AppController 
    12 { 
     10class ThemesController extends AppController { 
     11 
    1312 public $helpers       = array('Ajax', 'Gags'); 
    1413 
     
    1918 } 
    2019 
    21   /* === ADMIN METHODS === */                                                            
    22   public function admin_listing($order = null) 
    23   { 
    24        $this->layout = 'admin'; 
    25         
    26        $conditions   = null; 
    27         
    28        $fields       = array("theme", "img", "id", "description"); 
    29         
    30        $order        = "Theme.theme"; 
    31         
    32        $this->set('data', $this->Theme->findAll($conditions, $fields, $order)); 
    33    } 
     20 /* === ADMIN METHODS === */                                                             
     21 public function admin_listing($order = null) 
     22 { 
     23   $this->layout = 'admin';       
     24   $conditions   = null;     
     25   $fields       = array("theme", "img", "id", "description"); 
     26   $order        = "Theme.theme"; 
     27   $this->set('data', $this->Theme->findAll($conditions, $fields, $order)); 
     28 } 
    3429   
    35   public function admin_edit($id = null) 
    36   { 
    37      $this->layout    = 'admin'; 
     30 public function admin_edit($id = null) 
     31 { 
     32   $this->layout    = 'admin'; 
    3833      
    39      if (empty($this->data["Theme"])) 
    40      { 
     34   if (empty($this->data['Theme'])): 
    4135         $this->Theme->id  = $id; 
    4236         $this->data       = $this->Theme->read(); 
    43      } 
    44      else 
    45      {    
    46          $this->Sanitize = new Sanitize; 
    47           
    48          $this->Sanitize->clean($this->data["Theme"]); 
    49           
    50          if ($this->Theme->save($this->data["Theme"])) 
    51          { 
    52             $this->msgFlash('Theme has been saved', '/admin/themes/listing'); 
    53             exit(); 
    54          } 
    55      } 
    56    } 
     37   else: 
     38         $this->Sanitize = new Sanitize;  
     39         $this->Sanitize->clean($this->data['Theme']); 
     40         if ($this->Theme->save($this->data['Theme']): 
     41            $this->msgFlash(__('Data saved', true), '/admin/themes/listing'); 
     42     endif; 
     43   endif; 
     44} 
    5745   
    5846 public function admin_add()  
     
    6553 if (!empty($this->data['Theme']) && is_uploaded_file($this->data['Theme']['file']['tmp_name'])) 
    6654 { 
    67      
    6855   $this->Sanitize = new Sanitize; 
    6956     
     
    9784   if ( $type != "image/jpeg" && $type != "image/pjpeg" && $type != "image/png" && $type != "image/gif"): 
    9885       /** is this a valid file? */ 
    99        $error   = "ERROR the file $imgfile_name $imgfile_name is not valid.<br>Only .jpg, .gif or .png files."; 
     86       $error   = "ERROR the file $imgfile_name $imgfile_name is not valid. Only .jpg, .gif or .png files."; 
    10087       $error  .= "Current type file: " . $type . " \n"; 
    101                 
    10288       /** delete uploaded file  */ 
    10389       unlink($imgfile); 
    104        $this->flash($ErrMsg,'/admin/themes/listing/'); 
     90       $this->flash($error,'/admin/themes/listing/', 3); 
    10591   
    10692    endif; 
    10793     
    10894    if ( $imgfile_size > $maxfilesize): 
    109  
    11095         $error  = "Error. The Theme is too big. Bigger than 2.0 MB. Current size: " . $imgfile_size ."\n";         
    11196         /** delete uploaded file */ 
     
    117102    //check size 
    118103    if ($width > 120 || $height > 120): 
    119  
    120104         $error  = "Error. The image is too large. Widht or height is larger than 120 pixels"; 
    121105         $error .= "Current size: width ". $width ."px  height ". $height ."px \n"; 
    122               
    123106         /** delete uploaded file */ 
    124107         unlink($imgfile); 
     
    126109         return false; 
    127110    endif; 
    128  
    129          
    130       /** setup final file location and name */ 
    131       /** change spaces to underscores in filename  */ 
    132       $final_filename = str_replace(" ", "_", $imgfile_name); 
    133111     
    134       $newfile        = $uploaddir . "/" . $final_filename; 
     112    /** setup final file location and name */ 
     113    /** change spaces to underscores in filename  */ 
     114    $final_filename = str_replace(" ", "_", $imgfile_name); 
     115    $newfile        = $uploaddir . "/" . $final_filename; 
    135116     
    136        /** do extra security check to prevent malicious abuse */ 
    137       if (is_uploaded_file($imgfile)): 
     117    /** do extra security check to prevent malicious abuse */ 
     118    if (is_uploaded_file($imgfile)): 
    138119           /** move file to proper directory ==*/ 
    139120     if ( !move_uploaded_file($imgfile, $newfile) ): 
    140121           /** if an error occurs the file could not 
    141122               be written, read or possibly does not exist ==*/ 
    142           
    143            $this->flash('Error Uploading File.', '/admin/Themes/listing/'); 
     123           $this->flash(__('Error Uploading File', true), '/admin/Themes/listing/', 3); 
    144124       endif; 
    145       endif; 
    146     
    147      /** Database stuff  **/ 
    148     
    149      $this->data['Theme']['img']    = $final_filename; 
    150     
    151      $this->Theme->create(); 
    152     
    153      if ($this->Theme->save($this->data['Theme'])):      
    154           $this->msgFlash('Theme saved', '/admin/themes/listing');  
    155      endif; 
     125    endif; 
     126 
     127    /** Database stuff  **/ 
     128    $this->data['Theme']['img']    = $final_filename; 
     129    if ($this->Theme->save($this->data['Theme'])):      
     130          $this->msgFlash(__('Data saved', true), '/admin/themes/listing');  
     131    endif; 
    156132  } 
    157133 } 
     
    159135 public function admin_delete($theme_id) 
    160136 {  
    161     $file = $this->Theme->field("Theme.img", array("Theme.id"=>$theme_id)); 
     137   $file = $this->Theme->field("Theme.img", array("Theme.id"=>$theme_id)); 
    162138           
    163      if ( $this->Theme->del($theme_id) ) 
    164      { 
     139   if ( $this->Theme->del($theme_id) ): 
    165140         unlink("../webroot/img/themes/" . $file); 
    166          $this->msgFlash('Theme removed', '/admin/themes/listing'); 
    167      } 
    168   } 
     141         $this->msgFlash(__('Data removed', true), '/admin/themes/listing'); 
     142   endif; 
     143 } 
    169144} 
    170145?>