Changeset 774
- Timestamp:
- 09/23/08 21:12:59 (2 months ago)
- Location:
- trunk/app/controllers
- Files:
-
- 8 modified
-
answers_controller.php (modified) (2 diffs)
-
medias_controller.php (modified) (2 diffs)
-
podcasts_controller.php (modified) (4 diffs)
-
replies_controller.php (modified) (2 diffs)
-
reports_controller.php (modified) (4 diffs)
-
shares_controller.php (modified) (2 diffs)
-
themeblogs_controller.php (modified) (2 diffs)
-
themes_controller.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/answers_controller.php
r730 r774 83 83 84 84 $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' 90 87 $this->set('data', $this->Answer->findAll($conditions, $fields, $order)); 91 88 } … … 104 101 public function admin_delete($answer_id, $question_id) 105 102 { 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; 116 107 } 117 108 } -
trunk/app/controllers/medias_controller.php
r540 r774 95 95 } 96 96 } 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 { 126 114 $this->redirect('/medias/listing/'); 127 } else {115 } else { 128 116 $this->flash('Problem!!', '/medias/listing/'); 129 } 130 131 } 117 } 118 } 132 119 133 120 /*** DELETE **/ … … 142 129 143 130 /**** ADD MEDIA FILE ***/ 144 public function add() {145 131 public function add() 132 { 146 133 //die(print_r($this->params)); 147 134 -
trunk/app/controllers/podcasts_controller.php
r757 r774 172 172 // valid file ?? 173 173 $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 ==*/ 176 175 unlink($podfile); 177 $this->flash($err,'/admin/podcasts/add/' );176 $this->flash($err,'/admin/podcasts/add/', 3); 178 177 return false; 179 178 endif; … … 184 183 /** delete uploaded file ==*/ 185 184 unlink($podfile); 186 $this->flash($err,'/admin/podcasts/add/' );185 $this->flash($err,'/admin/podcasts/add/', 3); 187 186 return false; 188 187 189 188 endif; 190 189 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'; 197 193 $current_id = $this->Podcast->field($field, $conditions, $order); 198 199 194 $next_id = ($current_id + 1); 200 201 195 $extension = $this->Adds->last3chars($podfile_name); // get the file extesion 202 196 … … 219 213 /** if an error occurs the file could not 220 214 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); 223 216 return false; 224 217 endif; … … 240 233 $this->data['Podcast']['created'] = $created; 241 234 $this->data['Podcast']['user_id'] = $this->Auth->user('id'); 242 243 $this->Podcast->create(); 244 235 245 236 if ($this->Podcast->save($this->data)): 246 237 $this->msgFlash('Your podcast has been saved.','/admin/podcasts/listing'); -
trunk/app/controllers/replies_controller.php
r742 r774 67 67 $this->data = $this->Reply->read(); 68 68 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; 73 72 endif; 74 73 } … … 78 77 { 79 78 $this->data['Reply']['status'] = ($status == 0 ) ? 1 : 0; 80 81 79 $this->data['Reply']['id'] = (int) $reply_id; 82 83 80 if ($this->Reply->save($this->data, array('validate'=>false))): 84 81 $this->msgFlash(__('Status modified', true), '/admin/topics/listing/'.$topic_id); -
trunk/app/controllers/reports_controller.php
r741 r774 28 28 { 29 29 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); 31 31 endif; 32 32 … … 56 56 /** delete uploaded file ==*/ 57 57 unlink($file); 58 $this->flash($msg, '/admin/shares/listing' );58 $this->flash($msg, '/admin/shares/listing', 3); 59 59 return false; 60 60 endif; … … 65 65 /** delete uploaded file ==*/ 66 66 unlink($file); 67 $this->flash($msg, $url );67 $this->flash($msg, $url, 3); 68 68 return false; 69 69 endif; … … 94 94 if (!move_uploaded_file($file, $newfile)): 95 95 /** 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); 97 97 return false; 98 98 endif; -
trunk/app/controllers/shares_controller.php
r733 r774 107 107 /** delete uploaded file ==*/ 108 108 unlink($file); 109 $this->flash($msg, '/admin/shares/listing' );109 $this->flash($msg, '/admin/shares/listing', 3); 110 110 return false; 111 111 endif; … … 115 115 /** delete uploaded file ==*/ 116 116 unlink($file); 117 $this->flash($msg, '/admin/shares/listing' );117 $this->flash($msg, '/admin/shares/listing', 3); 118 118 return false; 119 119 endif; 120 120 121 121 $conditions = array('user_id' => $this->Auth->user('id')); 122 123 122 $order = 'Share.id DESC'; 124 125 123 $current_id = $this->Share->field('id', $conditions, $order); 126 127 124 $next_id = ($current_id + 1); 128 129 125 $extension = $this->get_extension($file_name); 130 131 126 $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'); 132 127 -
trunk/app/controllers/themeblogs_controller.php
r540 r774 43 43 $this->Themeblog->save(); 44 44 45 if ($this->Themeblog->save($this->data['Themeblog'])) 46 { 45 if ($this->Themeblog->save($this->data['Themeblog'])): 47 46 $conditions = array("user_id" => $this->Auth->user('id')); 48 49 47 $this->set('data', $this->Themeblog->findAll($conditions)); 50 51 48 $this->render('themes', 'ajax'); 52 } 53 else { 54 55 $this->flash('Database error!', '/entries/listing'); 56 } 49 endif; 57 50 } 58 51 } … … 61 54 { 62 55 $this->layout = 'ajax'; 63 64 if (empty($this->data["Themeblog"])) 65 { 56 if (empty($this->data['Themeblog'])): 66 57 $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'))); 70 59 $this->render('row', 'ajax'); 71 } 72 else 73 { 60 else: 74 61 $this->Sanitize = new Sanitize; 75 76 62 $this->Sanitize->clean($this->data['Themeblog']); 77 78 if ($this->Themeblog->save($this->data['Themeblog'])) 79 { 63 if ($this->Themeblog->save($this->data['Themeblog'])): 80 64 $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')); 84 66 //exit(print_r($data)); 85 86 67 $this->set('data', $data); 87 88 68 $this->render('admin_cancel', 'ajax'); 89 }90 }91 }92 69 endif; 70 endif; 71 } 72 93 73 public function admin_cancel($id = null) 94 74 { 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'); 102 79 } 103 104 public function admin_delete($ id)80 81 public function admin_delete($theme_id) 105 82 { 106 83 // 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')); 111 86 $this->set('data', $this->Themeblog->findAll($conditions, null, "title")); 112 113 87 $this->render('themes', 'ajax'); 114 88 } -
trunk/app/controllers/themes_controller.php
r540 r774 7 7 8 8 uses('sanitize'); 9 uses('l10n');10 9 11 class ThemesController extends AppController 12 { 10 class ThemesController extends AppController { 11 13 12 public $helpers = array('Ajax', 'Gags'); 14 13 … … 19 18 } 20 19 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 } 34 29 35 public function admin_edit($id = null)36 {37 $this->layout = 'admin';30 public function admin_edit($id = null) 31 { 32 $this->layout = 'admin'; 38 33 39 if (empty($this->data["Theme"])) 40 { 34 if (empty($this->data['Theme'])): 41 35 $this->Theme->id = $id; 42 36 $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 } 57 45 58 46 public function admin_add() … … 65 53 if (!empty($this->data['Theme']) && is_uploaded_file($this->data['Theme']['file']['tmp_name'])) 66 54 { 67 68 55 $this->Sanitize = new Sanitize; 69 56 … … 97 84 if ( $type != "image/jpeg" && $type != "image/pjpeg" && $type != "image/png" && $type != "image/gif"): 98 85 /** 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."; 100 87 $error .= "Current type file: " . $type . " \n"; 101 102 88 /** delete uploaded file */ 103 89 unlink($imgfile); 104 $this->flash($ ErrMsg,'/admin/themes/listing/');90 $this->flash($error,'/admin/themes/listing/', 3); 105 91 106 92 endif; 107 93 108 94 if ( $imgfile_size > $maxfilesize): 109 110 95 $error = "Error. The Theme is too big. Bigger than 2.0 MB. Current size: " . $imgfile_size ."\n"; 111 96 /** delete uploaded file */ … … 117 102 //check size 118 103 if ($width > 120 || $height > 120): 119 120 104 $error = "Error. The image is too large. Widht or height is larger than 120 pixels"; 121 105 $error .= "Current size: width ". $width ."px height ". $height ."px \n"; 122 123 106 /** delete uploaded file */ 124 107 unlink($imgfile); … … 126 109 return false; 127 110 endif; 128 129 130 /** setup final file location and name */131 /** change spaces to underscores in filename */132 $final_filename = str_replace(" ", "_", $imgfile_name);133 111 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; 135 116 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)): 138 119 /** move file to proper directory ==*/ 139 120 if ( !move_uploaded_file($imgfile, $newfile) ): 140 121 /** if an error occurs the file could not 141 122 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); 144 124 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; 156 132 } 157 133 } … … 159 135 public function admin_delete($theme_id) 160 136 { 161 $file = $this->Theme->field("Theme.img", array("Theme.id"=>$theme_id));137 $file = $this->Theme->field("Theme.img", array("Theme.id"=>$theme_id)); 162 138 163 if ( $this->Theme->del($theme_id) ) 164 { 139 if ( $this->Theme->del($theme_id) ): 165 140 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 } 169 144 } 170 145 ?>
