Changeset 321

Show
Ignore:
Timestamp:
03/12/08 13:35:16 (10 months ago)
Author:
aarkerio
Message:

Changes on Forums

Location:
trunk/app
Files:
2 added
11 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/app_controller.php

    r319 r321  
    2020     $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; 
    2121     $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') ); 
    2323     $this->Auth->autoRedirect = true; 
    2424     $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  
    6666    $this->set('data', $this->Forum->findAll($conditions)); 
    6767 } 
     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 } 
    6882  
    6983 public function admin_add($catforum_id = null)  
  • trunk/app/controllers/podcasts_controller.php

    r313 r321  
    33*  Karamelo E-Learning Platform 
    44*  Manuel Montoya 2002-2008  
    5 *  GPLv3 manuel<arroba>mononeurona<punto>org 
     5*  GPLv3 manuel<at>mononeurona<punto>org 
    66*/  
    77 
     
    1010 
    1111class 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)); 
    7141 } 
    7242    
     
    8555        $this->set('data', $this->Podcast->findAll($conditions, $fields)); 
    8656    } 
    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     
     76public function admin_add()  
     77{ 
    16078     
    16179    $this->layout    = 'admin'; 
     
    16482    { 
    16583     
     84    // echo "tmp_name : ". $this->data['Podcast']['file']['tmp_name'] . "<br />";// 
     85     
    16686    $this->Sanitize = new Sanitize; 
    16787     
    168     $this->Sanitize->cleanArray($this->data["Podcast"]);  
     88    $this->Sanitize->cleanArray($this->data); //Hopefully this is enough 
    16989     
    17090    /* SUBMITTED INFORMATION - use what you need 
     
    17999    $uploaddir    = "../webroot/files/podcasts"; 
    180100     
    181     $maxfilesize  = 20971520; // 20 MB max size 
     101    $maxfilesize  = 10485760; // 10 MB max size 
    182102     
    183103    $podfile_name = $this->data['Podcast']['file']['name']; 
     
    194114     
    195115    if ( $type != "audio/mpeg" )  
    196     {   //Is a valid file ?? 
     116    {   //Es un archivo valido ?? 
    197117        $ErrMsg   = "<h1>ERROR</h1> the file $podfile_name $podfile is not valid.<br>"; 
    198118        $ErrMsg  .= "<p>Only .mp3 files<br><br>"; 
     
    207127    { 
    208128     $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"; 
    211131         
    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/'); 
    215135    } 
    216136     
    217137    $field       = "id"; 
    218138     
    219     $conditions  = array("user_id" =>  $this->Auth->user('id')); 
     139    $conditions  = array("user_id" =>  $this->othAuth->user('id')); 
    220140     
    221141    $order       = "Podcast.id DESC"; 
    222142     
    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); 
    226146      
    227     $extension   = $this->Adds->last3chars($podfile_name); 
     147    $extension   = $this->get_extension($podfile_name); 
    228148     
    229149    if ($extension != 'mp3') 
    230150    { 
    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; 
    235155      
    236156    /** setup final file location and name */ 
     
    244164    { 
    245165       /** move file to proper directory ==*/ 
    246        if (!move_uploaded_file($podfile, $newfile)) 
     166       if (!copy($podfile, $newfile)) 
    247167       { 
    248168          /** if an error occurs the file could not 
    249169               be written, read or possibly does not exist ==*/ 
    250170          
    251           $this->flash('Error Uploading File.', '/admin/podcasts/listing/'); 
     171         $this->flash('Error Uploading File.', '/admin/podcasts/listing/'); 
    252172       } 
    253173   } 
     
    268188   $this->data['Podcast']['created']     = $created; 
    269189    
    270    $this->Podcast->create(); 
    271  
    272190   if ($this->Podcast->save($this->data)) 
    273191   { 
    274        $this->msgFlash('Podcast saved.','/admin/podcasts/listing'); 
     192       $this->flash('Your podcast has been saved.','/podcasts/listing'); 
    275193   } 
    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); 
    282197} 
    283198 
    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 
    331201} 
    332202?> 
  • trunk/app/controllers/topics_controller.php

    r247 r321  
    1818          if (isset($this->params[Configure::read('Routing.admin')])) 
    1919         { 
    20               if ($this->Auth->user('group_id') != 1) 
     20              if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) 
    2121              { 
    22                     return false; 
     22                    return true; 
    2323              } 
    2424         } 
    25   return true; 
     25  return false; 
    2626  } 
    2727                                                             
     
    4545    
    4646   } 
    47    public function display($user_id, $forum_id, $topic_id){ 
    48       
     47 
     48   public function display($user_id, $forum_id, $topic_id) 
     49   {   
    4950     $this->pageTitle = 'Forums'; 
    5051      
     
    6768   { 
    6869        $this->layout = 'admin'; 
    69          
    7070        $this->pageTitle = 'Forums'; 
    7171         
    72         $conditions = array("user_id"=>$this->othAuth->user('id')); 
     72        $conditions = array("user_id"=>$this->Auth->user('id')); 
    7373        $fields     = array("id", "title", "description", "status"); 
    7474         
    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));      
    7976    } 
    8077    
     
    8784       $this->Sanitize = new Sanitize; 
    8885       
    89        $this->Sanitize->cleanArray($this->data['Topic']); 
     86       $this->Sanitize->clean($this->data['Topic']); 
    9087 
    91        $this->data['Topic']['user_id'] = $this->othAuth->user('id'); 
     88       $this->data['Topic']['user_id'] = $this->Auth->user('id'); 
    9289        
    9390       $this->Topic->create(); 
    9491       
    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       } 
    9996    }  
    10097    else  
  • trunk/app/models/forum.php

    r282 r321  
    1313                                     array('className'  => 'Topic',  
    1414                                           '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 
    1818                                           )); 
    1919public $belongsTo = array('Catforum' =>  
  • trunk/app/models/podcast.php

    r282 r321  
    77 
    88class Podcast extends AppModel { 
    9     
    10     
     9       
    1110       public $belongsTo  = array( 
    1211                                  "User" => array( 
  • trunk/app/views/catforums/admin_listing.ctp

    r319 r321  
    5353        ); 
    5454        
    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"),  
    5656                                   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 
    5859      { 
    5960         echo '<tr><td>&nbsp;</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>'; 
    6263      } 
    6364 } 
  • trunk/app/views/forums/admin_edit.ctp

    r253 r321  
    11<div class="spaced"> 
    22<?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'); 
    55?> 
    66<fieldset> 
     
    88 
    99<?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.');  
    1312?> 
    1413<br /> 
    1514<br /> 
    1615<?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.'); 
    2018?> 
    2119 
    2220<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?> 
    2525<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 
    3030</div> 
    31  
  • trunk/app/views/forums/display.ctp

    r253 r321  
    5050 echo '<div style="text-align:center;width:50%;padding:6px">'; 
    5151  
    52  if ( !$othAuth->sessionValid() )  
     52 if ( ! isset( $cU ) )  
    5353 { 
    5454            echo $this->renderElement('login'); 
     
    6363<?php echo $html->image('static/new.gif', array("alt"=>"Comentario nuevo", "title"=>"Comentario nuevo")); ?>      Comentario nuevo<br /> 
    6464</p> 
    65  
    66  
  • trunk/app/views/podcasts/rss.ctp

    r272 r321  
    11<?php 
     2//die(debug($data)); 
    23/** 
    3 *  2002-2007- MonoNeuorna.org 
     4*  2002-2008 - MonoNeuorna.org 
    45*  Manuel Montoya <manuel_ARRROBA_mononeurona_PUNTO_org  
    56*  GPLv3  
     
    910?> 
    1011 
    11 <!-- generator="Centauro 0.5" --> 
     12<!-- generator="Karamelo 0.2" --> 
    1213<rss version="2.0"  
    1314    xmlns:content="http://purl.org/rss/1.0/modules/content/" 
     
    2021 
    2122  <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> 
    2526    <generator>Jedit.org</generator> 
    2627    <docs>http://blogs.law.harvard.edu/tech/rss</docs> 
    2728    <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> 
    3031    <pubDate><?php echo $created; ?></pubDate> 
    3132    <lastBuildDate><?php echo $last_episode; ?></lastBuildDate> 
    3233    
    33     <itunes:author><?php echo $data["User"]["username"];?></itunes:author> 
     34    <itunes:author><?php echo $User["User"]["username"];?></itunes:author> 
    3435    <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> 
    3637    <itunes:category text="Freedom"> 
    3738      <itunes:category text="Freedom" /> 
    3839    </itunes:category> 
    3940    <itunes:owner> 
    40       <itunes:name><?php  echo $data["User"]["name_blog"]; ?></itunes:name> 
    41