Changeset 321
- Timestamp:
- 03/12/08 13:35:16 (10 months ago)
- Location:
- trunk/app
- Files:
-
- 2 added
- 11 modified
-
app_controller.php (modified) (1 diff)
-
controllers/forums_controller.php (modified) (1 diff)
-
controllers/podcasts_controller.php (modified) (9 diffs)
-
controllers/topics_controller.php (modified) (4 diffs)
-
models/forum.php (modified) (1 diff)
-
models/podcast.php (modified) (1 diff)
-
views/catforums/admin_listing.ctp (modified) (1 diff)
-
views/forums/admin_edit.ctp (modified) (2 diffs)
-
views/forums/admin_topics.ctp (added)
-
views/forums/display.ctp (modified) (2 diffs)
-
views/podcasts/rss.ctp (modified) (3 diffs)
-
views/topics/add.ctp (modified) (2 diffs)
-
webroot/img/static/logout.gif (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/app_controller.php
r319 r321 20 20 $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; 21 21 $this->Auth->authorize = 'controller'; 22 $this->Auth->allow( array('view', 'display', 'subscribe', 'recover', 'register', 'insert', 'vote', 'download', 'blog','portfolio', 'about', 'message' ) );22 $this->Auth->allow( array('view', 'display', 'subscribe', 'recover', 'register', 'insert', 'vote', 'download', 'blog','portfolio', 'about', 'message', 'directory', 'bloggers', 'add', 'rss') ); 23 23 $this->Auth->autoRedirect = true; 24 24 $this->set('cU', $this->Auth->user()); // $cU current user array to use in the views if user logged -
trunk/app/controllers/forums_controller.php
r320 r321 66 66 $this->set('data', $this->Forum->findAll($conditions)); 67 67 } 68 69 public function admin_topics($forum_id) 70 { 71 if ( !intval($forum_id) ) 72 { 73 $this->redirect('/'); 74 } 75 76 $this->layout = 'admin'; 77 78 $conditions = array("Forum.user_id"=>$this->Auth->user('id'), "Forum.id"=>$forum_id); 79 80 $this->set('data', $this->Forum->find($conditions)); 81 } 68 82 69 83 public function admin_add($catforum_id = null) -
trunk/app/controllers/podcasts_controller.php
r313 r321 3 3 * Karamelo E-Learning Platform 4 4 * Manuel Montoya 2002-2008 5 * GPLv3 manuel<a rroba>mononeurona<punto>org5 * GPLv3 manuel<at>mononeurona<punto>org 6 6 */ 7 7 … … 10 10 11 11 class PodcastsController extends AppController { 12 13 public $helpers = array('Ajax', 'Gags'); 14 15 public $components = array('Edublog'); 16 17 public function isAuthorized() 18 { 19 if (isset($this->params[Configure::read('Routing.admin')])) 20 { 21 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2) 22 { 23 return true; 24 } 25 } 26 return false; 27 } 28 29 public function index($username=null, $entry_id=null) 30 { 31 $this->pageTitle = $username . '\'s Podcast'; 32 33 $conditions = array("status"=>1); // podcast must be actived 34 35 if ($username != null) 36 { 37 $user_id = $this->User->field('id', array("username"=>$username)); 38 39 $conditions["user_id"] = $user_id; 40 41 $this->set('username', $username); 42 } 43 44 if ($entry_id != null) 45 { 46 $conditions["id"] = $entry_id; 47 } 48 49 $fields = array("id", "title", "description", "created", "lenght", "user_id", "filename"); 50 $order = "id DESC"; 51 $limit = 12; 52 53 $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit, null, true)); 54 } 55 56 public function display($username, $user_id) 57 { 58 $this->pageTitle = $username .'\'s Podcast'; 59 60 $conditions = array("Podcast.status"=>1, "Podcast.user_id"=>$user_id); 61 62 $fields = array("Podcast.id", "Podcast.title", "Podcast.created", "Podcast.user_id", "Podcast.filename", "Podcast.description"); 63 64 $order = "Podcast.title"; 65 66 $this->set('data', $this->Podcast->findAll($conditions, $fields, $order)); 67 68 $this->layout = $this->Edublog->layout($user_id); 69 70 $this->Edublog->blog($user_id); // blogger elements 12 13 public $helpers = array('Javascript', 'Ajax', 'User', 'Gags'); 14 15 public function rss($username) 16 { 17 $this->layout = "rss"; 18 19 if ($username == null) 20 { 21 $this->redirect('/'); 22 } 23 24 $this->Podcast->User->unbindModel(array('hasMany'=>array('Entry', 'Lesson', 'Category', 'Vclassroom', 'Faq', 'Acquaintance'))); 25 26 $User = $this->Podcast->User->find(array("User.username"=>$username)); 27 //die(debug($User)); 28 $this->set('User', $User); 29 30 // die(debug($User)); 31 32 $conditions = array("status"=>1, "user_id"=>$User['User']['id']); 33 34 $fields = array("Podcast.id", "Podcast.title", "Podcast.description", "Podcast.created", "Podcast.duration", "Podcast.title", "Podcast.description"); 35 36 $order = "Podcast.created DESC"; 37 38 $limit = 12; 39 40 $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit)); 71 41 } 72 42 … … 85 55 $this->set('data', $this->Podcast->findAll($conditions, $fields)); 86 56 } 87 88 public function all($username=null, $entry_id=null) 89 { 90 $this->layout = 'portal'; 91 92 $this->pageTitle = $username . '\'s Podcast'; 93 94 $conditions = array("status"=>1); 95 96 if ($username != null) 97 { 98 $user_id = $this->User->field('id', array("username"=>$username)); 99 100 $conditions["user_id"] = $user_id; 101 } 102 103 if ($entry_id != null) 104 { 105 $conditions["id"] = $entry_id; 106 } 107 108 // print_r($conditions); 109 110 $fields = array("id", "title", "description", "created", "length", "duration"); 111 $order = "id DESC"; 112 $limit = 12; 113 114 $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit, null, true)); 115 116 $this->set('Element', $this->Portal->statics()); // Using Portal component 117 } 118 119 public function rss($username) 120 { 121 122 $user_id = $this->Podcast->User->field('id', array('User.username'=>$username)); 123 124 $this->layout = "rss"; 125 126 if ($username == null) 127 { 128 $this->redirect('/'); 129 } 130 131 $conditions = array("status"=>1, "user_id"=>$user_id); 132 133 $fields = array("id", "title", "description", "created", "duration", "title", "description"); 134 135 $order = "Podcast.created DESC"; 136 137 $this->set('data', $this->Podcast->findAll($conditions, $fields, $order)); 138 } 139 140 /**** 141 ====ADMIN SECTION==== 142 ****/ 143 144 public function admin_listing() 145 { 146 $this->pageTitle = $this->Auth->user('username') . '\'s Podcasts'; 147 148 $this->layout = 'admin'; 149 150 $conditions = array("Podcast.user_id"=>$this->Auth->user('id')); 151 $fields = array("id", "title", "description", "created", "length", "status", "filename"); 152 $order = "Podcast.id DESC"; 153 $limit = 20; 154 155 $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit)); 156 } 157 158 public function admin_add() 159 { 57 58 /*********** 59 ====ADMIN METHODS==== 60 ***/ 61 62 public function admin_listing() 63 { 64 $this->pageTitle = $this->othAuth->user('username') . '\'s Podcasts'; 65 66 $this->layout = 'admin'; 67 68 $conditions = array("Podcast.user_id"=>$this->othAuth->user('id')); 69 $fields = array("id", "title", "description", "created", "length"); 70 $order = "Podcast.id DESC"; 71 $limit = 12; 72 73 $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit, null, 1)); 74 } 75 76 public function admin_add() 77 { 160 78 161 79 $this->layout = 'admin'; … … 164 82 { 165 83 84 // echo "tmp_name : ". $this->data['Podcast']['file']['tmp_name'] . "<br />";// 85 166 86 $this->Sanitize = new Sanitize; 167 87 168 $this->Sanitize->cleanArray($this->data ["Podcast"]);88 $this->Sanitize->cleanArray($this->data); //Hopefully this is enough 169 89 170 90 /* SUBMITTED INFORMATION - use what you need … … 179 99 $uploaddir = "../webroot/files/podcasts"; 180 100 181 $maxfilesize = 20971520; // 20 MB max size101 $maxfilesize = 10485760; // 10 MB max size 182 102 183 103 $podfile_name = $this->data['Podcast']['file']['name']; … … 194 114 195 115 if ( $type != "audio/mpeg" ) 196 { // Is a valid file??116 { //Es un archivo valido ?? 197 117 $ErrMsg = "<h1>ERROR</h1> the file $podfile_name $podfile is not valid.<br>"; 198 118 $ErrMsg .= "<p>Only .mp3 files<br><br>"; … … 207 127 { 208 128 $ErrMsg = "<h1>ERROR</h1> The image is too big.<br>"; 209 $ErrMsg .= "<p>Bigger than 10.0 MB <br><br>";210 $ErrMsg .= "The current size: " . $podfile_size ."</p>\n";129 $ErrMsg .= "<p>Bigger than 10.0 MB <br><br>"; 130 $ErrMsg .= "The current size: " . $podfile_size ."</p>\n"; 211 131 212 /** delete uploaded file */213 unlink($podfile);214 $this->flash($ErrMsg,'/admin/podcasts/add/');132 /** delete uploaded file */ 133 unlink($podfile); 134 $this->flash($ErrMsg,'/admin/podcasts/add/'); 215 135 } 216 136 217 137 $field = "id"; 218 138 219 $conditions = array("user_id" => $this-> Auth->user('id'));139 $conditions = array("user_id" => $this->othAuth->user('id')); 220 140 221 141 $order = "Podcast.id DESC"; 222 142 223 $current_id = $this->Podcast->field($field, $conditions, $order);224 225 $next_id = ($current_id + 1);143 $current_id = $this->Podcast->field($field, $conditions, $order); 144 145 $next_id = ($current_id + 1); 226 146 227 $extension = $this-> Adds->last3chars($podfile_name);147 $extension = $this->get_extension($podfile_name); 228 148 229 149 if ($extension != 'mp3') 230 150 { 231 die("This does not look like one MP3 file :". $extension);232 } 233 234 $Name = $this->Auth->user('username') . "_" . $next_id . '.'. $extension;151 die("This does not look like one MP3 file"); 152 } 153 154 $Name = $this->othAuth->user('username') . "_" . $next_id . '.'. $extension; 235 155 236 156 /** setup final file location and name */ … … 244 164 { 245 165 /** move file to proper directory ==*/ 246 if (! move_uploaded_file($podfile, $newfile))166 if (!copy($podfile, $newfile)) 247 167 { 248 168 /** if an error occurs the file could not 249 169 be written, read or possibly does not exist ==*/ 250 170 251 $this->flash('Error Uploading File.', '/admin/podcasts/listing/');171 $this->flash('Error Uploading File.', '/admin/podcasts/listing/'); 252 172 } 253 173 } … … 268 188 $this->data['Podcast']['created'] = $created; 269 189 270 $this->Podcast->create();271 272 190 if ($this->Podcast->save($this->data)) 273 191 { 274 $this-> msgFlash('Podcast saved.','/admin/podcasts/listing');192 $this->flash('Your podcast has been saved.','/podcasts/listing'); 275 193 } 276 } 277 else 278 { 279 $this->set('subjects', $this->Podcast->Subject->generateList(null, 'title')); 280 } 281 194 195 /** delete the temporary uploaded file **/ 196 unlink($podfile); 282 197 } 283 198 284 public function admin_edit($id = null) 285 { 286 $this->layout = 'admin'; 287 288 if (empty($this->data['Faq'])) 289 { 290 $this->set('subjects', $this->Podcast->Subject->generateList(null, 'title')); 291 $this->Podcast->id = $id; 292 $this->data = $this->Podcast->read(); 293 294 } 295 else 296 { 297 $this->Sanitize = new Sanitize; 298 299 $this->Sanitize->cleanArray($this->data["Podcast"]); 300 301 if ($this->Podcast->save($this->data['Podcast'])) 302 { 303 $this->msgFlash('Podcast saved','/admin/podcasts/listing/'.$this->data['Podcast']['id']); 304 } 305 } 306 } 307 /*** DELETE **/ 308 public function admin_delete($id) 309 { 310 $file = $this->Podcast->field("Podcast.filename", array("Podcast.id"=>$id)); 311 312 $this->Podcast->del($id); 313 314 /** delete podcast from hard disk**/ 315 unlink("../webroot/files/podcasts/" . $file); 316 $this->msgFlash('Podcast deleted', '/admin/podcasts/listing'); 317 } 318 319 // change user status actived/no actived 320 public function admin_change($id, $status) 321 { 322 $this->data['Podcast']['status'] = ($status == 0 ) ? 1 : 0; 323 324 $this->data['Podcast']['id'] = $id; 325 326 if ($this->Podcast->save($this->data['Podcast'])) 327 { 328 $this->msgFlash('Podcast updated', '/admin/podcasts/listing'); 329 } 330 } 199 } 200 331 201 } 332 202 ?> -
trunk/app/controllers/topics_controller.php
r247 r321 18 18 if (isset($this->params[Configure::read('Routing.admin')])) 19 19 { 20 if ($this->Auth->user('group_id') != 1)20 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) 21 21 { 22 return false;22 return true; 23 23 } 24 24 } 25 return true;25 return false; 26 26 } 27 27 … … 45 45 46 46 } 47 public function display($user_id, $forum_id, $topic_id){ 48 47 48 public function display($user_id, $forum_id, $topic_id) 49 { 49 50 $this->pageTitle = 'Forums'; 50 51 … … 67 68 { 68 69 $this->layout = 'admin'; 69 70 70 $this->pageTitle = 'Forums'; 71 71 72 $conditions = array("user_id"=>$this-> othAuth->user('id'));72 $conditions = array("user_id"=>$this->Auth->user('id')); 73 73 $fields = array("id", "title", "description", "status"); 74 74 75 //$this->Subject = new Subject; 76 77 $this->set('data', $this->Topic->findAll($conditions, $fields)); 78 75 $this->set('data', $this->Topic->findAll($conditions, $fields)); 79 76 } 80 77 … … 87 84 $this->Sanitize = new Sanitize; 88 85 89 $this->Sanitize->clean Array($this->data['Topic']);86 $this->Sanitize->clean($this->data['Topic']); 90 87 91 $this->data['Topic']['user_id'] = $this-> othAuth->user('id');88 $this->data['Topic']['user_id'] = $this->Auth->user('id'); 92 89 93 90 $this->Topic->create(); 94 91 95 if ($this->Topic->save($this->data))96 {97 $this->flash('New topic had been added.','/topics/view/'.$this->data['Topic']["user_id"].'/'. $this->data['Topic']['forum_id']);98 }92 if ($this->Topic->save($this->data)) 93 { 94 $this->flash('New topic had been added.','/topics/view/'.$this->data['Topic']["user_id"].'/'. $this->data['Topic']['forum_id']); 95 } 99 96 } 100 97 else -
trunk/app/models/forum.php
r282 r321 13 13 array('className' => 'Topic', 14 14 'foreignkey' => 'forum_id', 15 'conditions' => 'Topic.topic_id = 1',16 'order' => 'id',17 'fields' => 'id, subject, created, user_id, views'15 'conditions' => null, 16 'order' => null, 17 'fields' => null 18 18 )); 19 19 public $belongsTo = array('Catforum' => -
trunk/app/models/podcast.php
r282 r321 7 7 8 8 class Podcast extends AppModel { 9 10 9 11 10 public $belongsTo = array( 12 11 "User" => array( -
trunk/app/views/catforums/admin_listing.ctp
r319 r321 53 53 ); 54 54 55 echo $html->tableCells($tr, array("style"=>"border:1px solid gray;background-color:#c0c0c0"),55 echo $html->tableCells($tr, array("style"=>"border:1px solid gray;background-color:#c0c0c0"), 56 56 array("style"=>"border:1px solid gray;background-color:#c0c0c0")); 57 foreach ( $val['Forum'] as $v) 57 58 foreach ( $val['Forum'] as $v) // forum in catforums 58 59 { 59 60 echo '<tr><td> </td> <td> '. $gags->sendEdit($v["id"], 'forums') .'</td>'; 60 echo '<td>' . $ v["title"].'</td> <td colspan="2"> '. $v["description"] .' </td>';61 echo '<td>' . $gags->setStatus($v['status']).'</td> <td> ' . $gags->confirmDel($v[ "id"], 'forums') . '</td> </tr>';61 echo '<td>' . $html->link($v["title"], '/admin/forums/topics/'.$v['id']) .'</td> <td colspan="2"> '. $v["description"] .' </td>'; 62 echo '<td>' . $gags->setStatus($v['status']).'</td> <td> ' . $gags->confirmDel($v['id'], 'forums') . '</td> </tr>'; 62 63 } 63 64 } -
trunk/app/views/forums/admin_edit.ctp
r253 r321 1 1 <div class="spaced"> 2 2 <?php 3 echo $ html->formTag('/admin/forums/edit/', 'post');4 echo $ html->hidden('Forum/id');3 echo $form->create('Forum'); 4 echo $form->hidden('Forum.id'); 5 5 ?> 6 6 <fieldset> … … 8 8 9 9 <?php 10 echo $form->labelTag('Forum/title', 'Title:') . "<br />"; 11 echo $html->input('Forum/title', array('size'=>60, 'maxlength'=>90)); 12 echo $html->tagErrorMsg('Forum/title','Please enter a title.'); 10 echo $form->input('Forum.title', array('size'=>60, 'maxlength'=>90)); 11 echo $form->error('Forum.title','Please enter a title.'); 13 12 ?> 14 13 <br /> 15 14 <br /> 16 15 <?php 17 echo $form->labelTag('Forum/description', 'Description:') . "<br />"; 18 echo $html->input('Forum/description', array("size" => 60, "maxlength" => 90)); 19 echo $html->tagErrorMsg('Forum/description','Please enter a description.'); 16 echo $form->input('Forum.description', array("size" => 60, "maxlength" => 90)); 17 echo $form->error('Forum.description','Please enter a description.'); 20 18 ?> 21 19 22 20 <br /><br /> 23 <?php echo $form->labelTag('Forum/status', 'Status:') . "<br />"; ?> 24 <?php echo $html->checkbox('Forum/status', null, array("value"=>1)); ?> 21 <?php 22 echo $form->label('Forum.status', 'Status:') . "<br />"; 23 echo $form->checkbox('Forum.status'); 24 ?> 25 25 <br /><br /> 26 <p style="clear:both"></p> 27 <?php echo $html->submit('Update') ?> 28 < /fieldset>29 </form> 26 <p style="clear:both"></p></fieldset> 27 28 <?php echo $form->end('Save'); ?> 29 30 30 </div> 31 -
trunk/app/views/forums/display.ctp
r253 r321 50 50 echo '<div style="text-align:center;width:50%;padding:6px">'; 51 51 52 if ( ! $othAuth->sessionValid() )52 if ( ! isset( $cU ) ) 53 53 { 54 54 echo $this->renderElement('login'); … … 63 63 <?php echo $html->image('static/new.gif', array("alt"=>"Comentario nuevo", "title"=>"Comentario nuevo")); ?> Comentario nuevo<br /> 64 64 </p> 65 66 -
trunk/app/views/podcasts/rss.ctp
r272 r321 1 1 <?php 2 //die(debug($data)); 2 3 /** 3 * 2002-200 7- MonoNeuorna.org4 * 2002-2008 - MonoNeuorna.org 4 5 * Manuel Montoya <manuel_ARRROBA_mononeurona_PUNTO_org 5 6 * GPLv3 … … 9 10 ?> 10 11 11 <!-- generator=" Centauro 0.5" -->12 <!-- generator="Karamelo 0.2" --> 12 13 <rss version="2.0" 13 14 xmlns:content="http://purl.org/rss/1.0/modules/content/" … … 20 21 21 22 <channel> 22 <title><?php echo $ data["User"]["username"]; ?> podcast</title>23 <link>>http://<?php echo $_SERVER['SERVER_NAME'] ?>/blog/<?php echo $ data["User"]["username"];?></link>24 <description><?php echo $ data["User"]["tags"]; ?></description>23 <title><?php echo $User["User"]["username"]; ?> podcast</title> 24 <link>>http://<?php echo $_SERVER['SERVER_NAME'] ?>/blog/<?php echo $User['User']['username'];?></link> 25 <description><?php echo $User["User"]["tags"]; ?></description> 25 26 <generator>Jedit.org</generator> 26 27 <docs>http://blogs.law.harvard.edu/tech/rss</docs> 27 28 <language>es-mx</language> 28 <copyright><?php echo $ data["User"]; ?></copyright>29 <webMaster><?php echo $ data["User"]["email"];?></webMaster>29 <copyright><?php echo $User["User"]['username']; ?></copyright> 30 <webMaster><?php echo $User["User"]["email"];?></webMaster> 30 31 <pubDate><?php echo $created; ?></pubDate> 31 32 <lastBuildDate><?php echo $last_episode; ?></lastBuildDate> 32 33 33 <itunes:author><?php echo $ data["User"]["username"];?></itunes:author>34 <itunes:author><?php echo $User["User"]["username"];?></itunes:author> 34 35 <itunes:subtitle><?php echo $subtitle;?></itunes:subtitle> 35 <itunes:keywords><?php echo $ data["User"]["tags"];?></itunes:keywords>36 <itunes:keywords><?php echo $User["User"]["tags"];?></itunes:keywords> 36 37 <itunes:category text="Freedom"> 37 38 <itunes:category text="Freedom" /> 38 39 </itunes:category> 39 40 <itunes:owner> 40 <itunes:name><?php echo $ data["User"]["name_blog"]; ?></itunes:name>41
