Changeset 492

Show
Ignore:
Timestamp:
05/15/08 17:05:35 (7 months ago)
Author:
aarkerio
Message:

Message interfase

Location:
trunk/app
Files:
1 added
8 modified

Legend:

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

    r491 r492  
    4242      $this->layout    = 'rss'; 
    4343      $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"); 
    4545      $order           = 'Entry.id DESC'; 
    4646      $limit           = 20; 
  • trunk/app/controllers/podcasts_controller.php

    r447 r492  
    7575 public function rss($username)  
    7676 {    
    77     $this->layout = "rss"; 
     77    $this->layout = "podfeeder"; 
    7878     
    7979    if ($username == null) 
  • trunk/app/controllers/users_controller.php

    r480 r492  
    1919 public function beforeFilter()  
    2020 { 
    21    if ( !empty($this->data['User'] ) ):  
     21   if ( isset($this->data['User']['pwd'] ) ):  
    2222       if ( strlen($this->data['User']['pwd']) < 6): 
    2323         unset($this->data['User']['pwd']); 
     
    2525   endif; 
    2626 
    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 
    2935  parent::beforeFilter(); 
    3036 } 
     
    3339 {       
    3440    if (isset( $this->params[Configure::read('Routing.admin')] )): 
    35  
    3641        if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ):  // admin and teachers 
    37         return true; 
     42          return true; 
    3843    endif;  
    39  
    4044    endif;  
    4145 
     
    429433   endif; 
    430434 } 
    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 
    432540 /***    ===== ADMIN METHODS====   ****/ 
    433541 public function admin_login()  
  • trunk/app/views/entries/rss.ctp

    r491 r492  
    11<?php  
    2 die(debug($data));  
     2// die(count($data));  
    33?> 
    4 <rss version="2.0"> 
    54<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> 
    1116<?php 
    1217foreach ($data as $v):   
    13     die(debug($v)); 
     18    
    1419    $body   = substr($v["Entry"]['body'],0,300) . "..."; 
    1520?> 
    1621 <item> 
    1722   <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> 
    1924   <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> 
    2126        <pubDate><?php  echo $v["Entry"]['created'] ?></pubDate> 
    22           <creator><?php  echo $v["Entry"]['created'] ?></creator> 
     27        <creator><?php  echo $v["Entry"]['created'] ?></creator> 
    2328        <category><?php echo $v["Entry"]['subject_id']; ?></category> 
    2429        <guid><?php echo $_SERVER['SERVER_NAME'] ?>/users/entry/<?php echo $v["User"]['username']; ?>/<?php echo $v["Entry"]['id'] ?></guid> 
     
    2732 
    2833</channel> 
    29 </rss> 
  • trunk/app/views/layouts/rss.ctp

    r446 r492  
    11<?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"> 
    33  <?php echo $content_for_layout; ?> 
    44</rss> 
  • trunk/app/views/messages/listing.ctp

    r490 r492  
     1<script type="text/javascript"> 
     2   window.onload = timedMsg; 
     3</script> 
    14<?php  
     5 
     6$session->flash();  
     7 
    28// die(debug($data)); 
    39echo $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  
    4848 
    4949<fieldset> 
    50   <legend>Upload new avatar</legend> 
     50  <legend><?php echo __('Upload new avatar'); ?></legend> 
    5151   <?php  
    5252     echo $html->para(null, 'An image 40 x 40 pixels'); 
     
    5454     echo $form->file('User.file');  
    5555     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> 
    6059 
    6160<script type="text/javascript"> 
  • trunk/app/webroot/css/portal/portal.css

    r411 r492  
    400400 
    401401.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}