Changeset 492
- Timestamp:
- 05/15/08 17:05:35 (7 months ago)
- Location:
- trunk/app
- Files:
-
- 1 added
- 8 modified
-
controllers/entries_controller.php (modified) (1 diff)
-
controllers/podcasts_controller.php (modified) (1 diff)
-
controllers/users_controller.php (modified) (4 diffs)
-
views/entries/rss.ctp (modified) (2 diffs)
-
views/layouts/podfeeder.ctp (added)
-
views/layouts/rss.ctp (modified) (1 diff)
-
views/messages/listing.ctp (modified) (1 diff)
-
views/users/edit.ctp (modified) (2 diffs)
-
webroot/css/portal/portal.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/entries_controller.php
r491 r492 42 42 $this->layout = 'rss'; 43 43 $conditions = array("Entry.status"=>1, "Entry.user_id"=>$user_id); 44 $fields = array("Entry.id", "Entry.title", "Entry.created", "Entry.body", "Entry.subject_id", "Entry.user_id", "User.username" );44 $fields = array("Entry.id", "Entry.title", "Entry.created", "Entry.body", "Entry.subject_id", "Entry.user_id", "User.username", "User.name_blog"); 45 45 $order = 'Entry.id DESC'; 46 46 $limit = 20; -
trunk/app/controllers/podcasts_controller.php
r447 r492 75 75 public function rss($username) 76 76 { 77 $this->layout = " rss";77 $this->layout = "podfeeder"; 78 78 79 79 if ($username == null) -
trunk/app/controllers/users_controller.php
r480 r492 19 19 public function beforeFilter() 20 20 { 21 if ( !empty($this->data['User'] ) ):21 if ( isset($this->data['User']['pwd'] ) ): 22 22 if ( strlen($this->data['User']['pwd']) < 6): 23 23 unset($this->data['User']['pwd']); … … 25 25 endif; 26 26 27 $this->Auth->allow(array('blog', 'entry','portfolio', 'edit', 'about', 'register', 'directory', 'bloggers', 'insert', 'validate', 'logout')); 28 27 $actions = array('blog','entry','portfolio','edit','about','register','avatar','directory','bloggers','insert','validate','logout'); 28 29 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3 ): 30 array_push($actions, 'avatar'); 31 endif; 32 33 $this->Auth->allow($actions); 34 29 35 parent::beforeFilter(); 30 36 } … … 33 39 { 34 40 if (isset( $this->params[Configure::read('Routing.admin')] )): 35 36 41 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ): // admin and teachers 37 return true;42 return true; 38 43 endif; 39 40 44 endif; 41 45 … … 429 433 endif; 430 434 } 431 435 /**** AVATAR ***/ 436 public function avatar() 437 { 438 $this->layout = 'ajax'; 439 //die( debug($this->data)); 440 if (!empty($this->data['User']) && is_uploaded_file($this->data['User']['file']['tmp_name'])) 441 { 442 443 $this->Sanitize = new Sanitize; 444 445 $this->Sanitize->clean($this->data['User']); //Hopefully this is enough 446 447 /** SUBMITTED INFORMATION - use what you need 448 * temporary filename (pointer): $imgfile 449 * original filename : $imgfile_name 450 * size of uploaded file : $imgfile_size 451 * mime-type of uploaded file : $imgfile_type 452 */ 453 454 /** uploaddir: directory relative to where script is running */ 455 $uploaddir = "../webroot/img/avatars"; 456 457 $maxfilesize = 2097152; /** 2MB max size */ 458 459 $imgfile_name = $this->data['User']['file']['name']; 460 461 $imgfile_size = $this->data['User']['file']['size']; 462 463 $imgfile = $this->data['User']['file']['tmp_name']; 464 465 $type = $this->data['User']['file']['type']; 466 467 list($width, $height, $typeimg, $attr) = getimagesize($imgfile); 468 469 /** Security: checks to see if file is an image, if not do not allow upload ==*/ 470 471 if ( $type != "image/jpeg" && $type != "image/pjpeg" && $type != "image/png" && $type != "image/gif") 472 { /** is this a valid file? */ 473 $ErrMsg = "<h1>ERROR</h1> the file $imgfile_name $imgfile is not valid.<br>"; 474 $ErrMsg .= "<p>Only .jpg, .gif or .png files<br><br>"; 475 $ErrMsg .= "Current type file: " . $type . "</p>\n"; 476 477 /** delete uploaded file */ 478 unlink($imgfile); 479 die($this->flash($ErrMsg, '/admin/users/edit/') ); 480 } 481 482 if ( $imgfile_size > $maxfilesize) 483 { 484 $error = "Error. The image is too big. Bigger than 2.0 MB Current size: " . $imgfile_size ."\n"; 485 486 /** delete uploaded file */ 487 unlink($imgfile); 488 $this->flash($error,'/users/edit/'); 489 return false; 490 } 491 492 //check size 493 if ($width > 100 || $height > 100) 494 { 495 $error = " The image is too large. "; 496 $error .= "Width or height is larger than 100 pixels. Current size: width ". $width ."px height ". $height ."px\n"; 497 498 /** delete uploaded file */ 499 unlink($imgfile); 500 $this->flash($error,'/users/edit/'); 501 return false; 502 } 503 504 $extension = $this->Adds->get_extension($type); 505 506 $Name = $this->Auth->user('username') . "_avatar" . $extension; 507 508 /** setup final file location and name */ 509 /** change spaces to underscores in filename */ 510 $final_filename = str_replace(" ", "_", $Name); 511 //die($final_filename); 512 $newfile = $uploaddir . "/" . $final_filename; 513 514 /** do extra security check to prevent malicious abuse */ 515 if (is_uploaded_file($imgfile)) 516 { 517 /** move file to proper directory ==*/ 518 if (!copy($imgfile, $newfile)) 519 { 520 /** if an error occurs the file could not be written, read or possibly does not exist */ 521 die($this->flash('Error Uploading File.', '/users/edit/')); 522 } 523 } 524 525 /** delete the temporary uploaded file **/ 526 unset($this->data['User']['file']); // We do'nt need this anymore 527 unlink($imgfile); 528 529 /** Database stuff **/ 530 $this->data['User']['avatar'] = $final_filename; 531 532 if ($this->User->save($this->data['User'])): 533 $this->msgFlash('Image update', '/users/edit/'); 534 else: 535 die('Error saving'); 536 endif; 537 538 } 539 } 432 540 /*** ===== ADMIN METHODS==== ****/ 433 541 public function admin_login() -
trunk/app/views/entries/rss.ctp
r491 r492 1 1 <?php 2 die(debug($data));2 // die(count($data)); 3 3 ?> 4 <rss version="2.0">5 4 <channel> 6 <title>Karamelo</title> 7 <link><?php echo $_SERVER['SERVER_NAME'] ?></link> 8 <description>edublog</description> 9 <language>en</language> 10 5 <title>Karamelo</title> 6 <link><?php echo $_SERVER['SERVER_NAME']; ?></link> 7 <description>Edublog</description> 8 <language>en</language> 9 <image> 10 <title>MonoNeurona - Minuto x Minuto</title> 11 <url>/img/static/cwclogo.jpg</url> 12 <link>http://<?php echo $_SERVER['SERVER_NAME']; ?></link> 13 <width>100</width> 14 <height>71</height> 15 </image> 11 16 <?php 12 17 foreach ($data as $v): 13 die(debug($v));18 14 19 $body = substr($v["Entry"]['body'],0,300) . "..."; 15 20 ?> 16 21 <item> 17 22 <title><?php echo $v["Entry"]['title']; ?></title> 18 <link>http://<?php echo $_SERVER['SERVER_NAME'] ?>/users/entry/<?php echo $v["User"]['username']; ?>/<?php echo $v["Entry"]['id'] ?></link>23 <link>http://<?php echo $_SERVER['SERVER_NAME']; ?>/users/entry/<?php echo $v["User"]['username']; ?>/<?php echo $v["Entry"]['id'] ?></link> 19 24 <comments><?php echo $_SERVER['SERVER_NAME'] ?>/users/entry/<?php echo $v["User"]['username']; ?>/<?php echo $v["Entry"]['id'] ?></comments> 20 <description><![CDATA['<?php echo $body ?>']]></description>25 <description><![CDATA['<?php echo $body ?>']]></description> 21 26 <pubDate><?php echo $v["Entry"]['created'] ?></pubDate> 22 <creator><?php echo $v["Entry"]['created'] ?></creator>27 <creator><?php echo $v["Entry"]['created'] ?></creator> 23 28 <category><?php echo $v["Entry"]['subject_id']; ?></category> 24 29 <guid><?php echo $_SERVER['SERVER_NAME'] ?>/users/entry/<?php echo $v["User"]['username']; ?>/<?php echo $v["Entry"]['id'] ?></guid> … … 27 32 28 33 </channel> 29 </rss> -
trunk/app/views/layouts/rss.ctp
r446 r492 1 1 <?php echo '<?xml version="1.0" encoding="UTF-8" ?>'."\n"; ?> 2 <rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">2 <rss version="2.0"> 3 3 <?php echo $content_for_layout; ?> 4 4 </rss> -
trunk/app/views/messages/listing.ctp
r490 r492 1 <script type="text/javascript"> 2 window.onload = timedMsg; 3 </script> 1 4 <?php 5 6 $session->flash(); 7 2 8 // die(debug($data)); 3 9 echo $html->link($html->image('admin/compose_on.gif', array("alt"=>"Compose New Message", "title"=>"Compose New Message")), -
trunk/app/views/users/edit.ctp
r491 r492 48 48 49 49 <fieldset> 50 <legend> Upload new avatar</legend>50 <legend><?php echo __('Upload new avatar'); ?></legend> 51 51 <?php 52 52 echo $html->para(null, 'An image 40 x 40 pixels'); … … 54 54 echo $form->file('User.file'); 55 55 echo $form->error('User.file', 'Title is required.'); 56 ?> 57 58 <br /></fieldset> 59 <?php echo $form->end('Upload'); ?> 56 echo $form->end('Upload'); 57 ?> 58 </fieldset> 60 59 61 60 <script type="text/javascript"> -
trunk/app/webroot/css/portal/portal.css
r411 r492 400 400 401 401 .title_portal{ font-size:18pt; color:#30a6f0;font-weight:bold;font-family:Arial;margin:0;} 402 403 /* Message by flash CakePHP stuff */ 404 .message 405 { 406 position:absolute; 407 top:40px; 408 left:800px; 409 width:200px; 410 font-size:7pt; 411 font-weight:bold; 412 color:white; 413 border: solid 1px orange; 414 padding:2px; 415 background-color:#66cc00; 416 text-align:center; 417 }
