Changeset 331

Show
Ignore:
Timestamp:
03/23/08 13:42:50 (10 months ago)
Author:
aarkerio
Message:

Update

Location:
trunk/app
Files:
2 added
12 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/app_controller.php

    r325 r331  
    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', 'reply', 'register', 'insert', 'vote', 'entry', 'download', 'blog','portfolio', 'about', 'message', 'directory', 'bloggers', 'add', 'rss', 'discussion') ); 
     22     $this->Auth->allow( array('view', 'display', 'subscribe', 'recover', 'reply', 'register', 'insert', 'vote', 'entry', 'download', 'blog','portfolio', 'about',  
     23                               'message', 'search', 'directory', 'bloggers', 'add', 'rss', 'discussion') ); 
    2324     $this->Auth->autoRedirect = true; 
    2425     $this->set('cU', $this->Auth->user());  // $cU current user array to use in the views if user logged 
  • trunk/app/config/sql/karamelo_postgres.sql

    r330 r331  
    229229); 
    230230 
    231 CREATE TABLE replies ( -- replies to topics in forums   
     231CREATE TABLE replies ( -- replies to topics in forums 
    232232 id serial PRIMARY KEY, 
    233233 reply text NOT NULL, 
  • trunk/app/controllers/forums_controller.php

    r325 r331  
    33*  Chipotle Software TM 
    44*  Manuel Montoya 2002-2008  
    5 *  GPLv3 manuel<arroba>mononeurona<punto>org 
     5*  GPLv3 manuel<arroba>mononeurona<punto>org ASMO 
    66*/  
    77  
     
    3131         
    3232        $fields     = array("Forum.title", "Forum.id", "Forum.user_id", "Forum.description", "Forum.catforum_id", "Topic.id");  
    33  
     33         
    3434        $data       = $this->Forum->find($conditions, null, null, 2); 
    35  
     35         
    3636        $this->pageTitle = $data['Catforum']['title'] . ' Forum'; 
    3737        //die(debug($data)); 
    3838        $this->set('data', $data); 
    3939         
    40     $this->layout    = $this->Edublog->layout($data['Forum']['user_id']); 
    41           
     40        $this->layout    = $this->Edublog->layout($data['Forum']['user_id']); 
     41         
    4242        $this->Edublog->blog($data['Forum']['user_id']); // blogger elements 
    4343 } 
     
    5454        //die(debug($data)); 
    5555        $this->pageTitle = $data[0]['Forum']['title'] . ' Forum'; 
    56         
     56         
    5757        $this->set('data', $data); 
    5858         
    59     $this->layout    = $this->Edublog->layout($user_id); 
    60           
     59        $this->layout    = $this->Edublog->layout($user_id); 
     60         
    6161        $this->Edublog->blog($user_id); // blogger elements 
    6262 } 
    63  
     63  
    6464 public function view($username, $user_id, $forum_id, $topic_id)  
    6565 {       
     
    7474        $this->set('data', $this->Forum->find($conditions, $fields, null, 2)); 
    7575         
    76     $this->layout    = $this->Edublog->layout($user_id); 
    77      
     76        $this->layout    = $this->Edublog->layout($user_id); 
     77         
    7878        $this->Edublog->blog($user_id); // blogger elements 
    7979 } 
     
    8888 } 
    8989 
    90  public function admin_topics($forum_id)  
     90 public function admin_topics( $f_id ) 
    9191 {   
    92     if ( !intval($forum_id) ) 
     92    $forum_id = (int) $f_id; 
     93     
     94    if ( !is_int($forum_id) ) 
    9395    { 
    9496      $this->redirect('/'); 
    9597    } 
    96  
     98     
    9799    $this->layout = 'admin'; 
    98100     
     
    105107 {  
    106108   $this->layout = 'admin'; 
    107    
     109    
    108110   if ( !empty( $this->data['Forum'] ) ) 
    109111   { 
     
    115117      
    116118     $this->Forum->create(); 
    117  
     119      
    118120     if ( $this->Forum->save($this->data['Forum']) ) 
    119121     { 
    120122         $this->msgFlash('Forum created', '/admin/catforums/listing'); 
    121123     } 
    122    }  
    123    else  
     124   } 
     125   else 
    124126   { 
    125      $this->set('catforum_id', $catforum_id); 
     127      $this->set('catforum_id', $catforum_id); 
    126128   } 
    127129 } 
    128130  
    129   public function admin_edit($id = null) 
    130   { 
     131 public function admin_edit($id = null) 
     132 { 
    131133    if (empty($this->data['Forum'])) 
    132134    {    
     
    139141    else 
    140142    { 
    141         $this->Sanitize = new Sanitize; 
    142      
    143     $this->Sanitize->clean($this->data['Forum']); 
    144       
    145         if ($this->Forum->save($this->data['Forum'])) 
    146         { 
     143       $this->Sanitize = new Sanitize; 
     144        
     145       $this->Sanitize->clean($this->data['Forum']); 
     146        
     147       if ($this->Forum->save($this->data['Forum'])) 
     148       { 
    147149            $this->msgFlash('Forum updated', '/admin/catforums/listing'); 
    148150            exit(); 
    149         } 
     151       } 
    150152    } 
    151153 } 
     
    175177    } 
    176178 } 
    177    
     179 
    178180} 
    179181?> 
  • trunk/app/controllers/messages_controller.php

    r330 r331  
    33*  Chipotle Software TM 
    44*  Manuel Montoya 2002-2008  
    5 *  GPLv3 manuel<arroba>mononeurona<punto>org 
     5*  GPLv3 manuel<arroba>mononeurona<punto>org ASMO 
    66*/  
     7 
     8uses('sanitize'); 
     9 
     10class MessagesController extends AppController 
     11{ 
     12 public $helpers       = array('Javascript', 'Ajax', 'Fck', 'Time'); 
    713  
    8 uses('sanitize'); 
    9  
    10 class MessagesController extends AppController 
    11  
    12  public $helpers       = array('Javascript', 'Ajax', 'Fck', 'Time'); 
    13     
    1414 public $components    = array('Portal', 'Security', 'Email', 'Session'); 
    15  
     15  
    1616 public function isAuthorized()  
    17  {       
     17 {   
    1818    if (isset( $this->params[Configure::read('Routing.admin')] ))  
    1919    { 
    2020        if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 )  // admin and teachers 
    2121        { 
    22         return true; 
    23         }  
    24     }  
     22          return true; 
     23        } 
     24    } 
    2525    return false;  // go away !! 
    2626 } 
     
    7575        $this->pageTitle = 'Write Message'; 
    7676         
    77         $conditions = array("User.username ~ '".$this->data["Message"]["string"] ."'"); 
    78          
    79         $fields = array("User.username", "User.id"); 
    80          
    81         $order = "User.username"; 
    82          
     77        $conditions      = array("User.username ~* '".'ad' ."'"); 
     78         
     79        $fields          = array("User.username", "User.id"); 
     80         
     81        $order           = "User.username"; 
     82         
     83        $this->Message->User->unbindModel($this->Message->User->notNow); 
     84         
    8385        $limit = 15; 
    8486         
    85         $this->User = new User; 
    86          
    87         $this->set('data', $this->User->findAll($conditions, $fields, $order, $limit));      // Using Portal component 
     87        $this->set('data', $this->Message->User->findAll($conditions, $fields, $order, $limit));  
    8888         
    8989        $this->render('search', 'ajax'); 
     
    106106     { 
    107107           $this->Sanitize = new Sanitize; 
    108          
     108            
    109109           $this->Sanitize->html($this->data["Message"]["title"]); 
    110          
     110            
    111111           $this->Sanitize->html($this->data["Message"]["body"]); 
    112          
     112            
    113113           $this->Message->create(); 
    114  
    115             if ($this->Message->save($this->data["Message"])) 
    116         { 
     114            
     115           if ($this->Message->save($this->data["Message"])) 
     116           { 
    117117                $this->sendMail($this->data["Message"]["user_id"], $this->data["Message"]["username"], $this->data["Message"]["title"]); 
    118  
     118                 
    119119                if ( isset($this->data["Message"]["admin"])) 
    120         { 
     120                { 
    121121                      $this->render('sentadmin','ajax'); 
    122122                } 
    123123                else 
    124124                { 
    125               $this->render('send', 'ajax'); 
    126         } 
     125                    $this->render('send', 'ajax'); 
     126                } 
    127127        } 
    128128     } 
  • trunk/app/controllers/topics_controller.php

    r329 r331  
    7575 public function reply($user_id, $forum_id, $topic_id)  
    7676 { 
    77     // adds new reply to topic 
    78  
     77       // adds new reply to topic 
     78        
    7979       $this->layout    = $this->Edublog->layout($user_id); 
    8080        
     
    8585 } 
    8686  
    87  /********   ADMIN METHODS ********/ 
    88  public function admin_listing() 
     87 /***===   ADMIN METHODS ===********/ 
     88 public function admin_listing($topic_id) 
    8989 { 
    90         $this->layout = 'admin'; 
    91         $this->pageTitle = 'Forums'; 
     90        $this->layout    = 'admin'; 
     91         
     92        $this->pageTitle = 'Topics'; 
    9293         
    93         $conditions = array("user_id"=>$this->Auth->user('id')); 
    94         $fields     = array("id", "title", "description", "status"); 
     94        $conditions = array("Topic.user_id"=>$this->Auth->user('id'), "Topic.id"=>$topic_id); 
     95         
     96        $fields     = array("id", "subject", "message", "status", "created"); 
    9597         
    96         $this->set('data', $this->Topic->findAll($conditions, $fields));      
     98        $this->set('data', $this->Topic->find($conditions, $fields, null, 2));      
    9799 } 
    98100  
    99101 public function admin_edit($id = null) 
    100102 { 
    101     if (empty($this->data)) 
    102     { 
    103         $this->Topic->id = $id; 
    104          
    105         $this->data = $this->Topic->read(); 
    106     } 
    107     else 
    108     { 
     103       if (empty($this->data)) 
     104       { 
     105           $this->Topic->id = $id; 
     106            
     107           $this->data = $this->Topic->read(); 
     108       } 
     109       else 
     110       { 
    109111        if ($this->Topic->save($this->data['Topic'])) 
    110112        { 
    111113            $this->flash('Your virtual classroom  has been updated.','/vclassrooms'); 
    112114        } 
    113     } 
     115      } 
    114116 } 
    115  
     117  
    116118 // change status published/draft 
    117119 public function admin_change($id, $status, $forum_id) 
     
    132134    } 
    133135 } 
    134  
    135  public function delete($topic_id, $forum_id) 
     136  
     137 public function admin_delete($topic_id, $forum_id) 
    136138 { 
    137139     if ( $this->Topic->del($topic_id) ) 
    138140     { 
    139         $this->msgFlash('','/admin/forums/topics/'.$forum_id); 
     141        $this->msgFlash('Topic deleted','/admin/forums/topics/'.$forum_id); 
    140142     } 
    141  }   
     143 }  
    142144} 
  • trunk/app/models/catforum.php

    r322 r331  
    33*  Chipotle Software 
    44*  Manuel Montoya 2002-2008  
    5 *  GPLv3 manuel<at>mononeurona<dot>org 
     5*  GPLv3 manuel<arroba>mononeurona<punto>org ASMO 
    66*/  
    77//File: /app/models/catforum.php 
     
    2727                  ); 
    2828public $validate = array( 
    29       'title' => VALID_NOT_EMPTY,         //'/[a-z0-9\_\-]{3,}$/i', 
     29      'title' => VALID_NOT_EMPTY, 
    3030      'message' => VALID_NOT_EMPTY, 
    3131      'user_id' => VALID_NOT_EMPTY, 
  • trunk/app/models/message.php

    r282 r331  
    33*  Karamelo eLearning Platform 
    44*  Chipotle Software 2002-2008  
    5 *  GPLv3 manuel<arroba>mononeurona<punto>org 
     5*  GPLv3 manuel<arroba>mononeurona<punto>org ASMO 
    66**/  
    77 
     
    1111     
    1212    public $belongsTo = 'User'; 
     13     
     14    public $validate = array( 
     15      'title' => VALID_NOT_EMPTY, 
     16      'body' => VALID_NOT_EMPTY, 
     17      'user_id' => VALID_NOT_EMPTY, 
     18      'sender_id' => VALID_NOT_EMPTY 
     19      ); 
     20 
    1321} 
    14  
    1522?> 
  • trunk/app/models/user.php

    r282 r331  
    3636    ) 
    3737  ); 
    38      
    39      
    40     public $validate = array( 
     38   
     39  public $notNow = array('hasMany'=>array('Entry', 'Category', 'Acquaintance', 'Faq', 'Glossary', 'Vclassroom', 'Lesson', 'Confirm')); 
     40   
     41  public $validate = array( 
    4142      'login'    => VALID_NOT_EMPTY, 
    4243      'pwd' => VALID_NOT_EMPTY, 
  • trunk/app/views/forums/admin_topics.ctp

    r322 r331  
    2121foreach ($data['Topic'] as $val) 
    2222 { 
     23   $message = substr($val['message'], 0, 40) . '...'; 
     24    
    2325   $st =  ($val['status'] == 1 ) ? 'Published' : 'Hidden'; 
    24    $t  =  '<b>'.$val['subject']  . '</b><br />'; 
    25    $t .=  $val['message']        . '<br />'; 
     26   $t  =  $html->link($val['subject'], '/admin/topics/listing/'.$val['id'], array('title'=>'View discussions'))  . '<br />'; 
     27   $t .=  $message               . '<br />'; 
    2628   $t .=  'Status: ' .   $html->link($st, '/admin/topics/change/'.$val['id'].'/'.$val['status'].'/'.$val['forum_id'], array('title'=>'Change status'))      . '<br />'; 
    2729   $t .=  $val['created']         . '<br />'; 
  • trunk/app/views/messages/admin_add.ctp

    r330 r331  
    3232  echo $ajax->form();  
    3333  echo $form->hidden('Message.sender_id',  array("value"=>$cU['User']['id'])); 
    34   echo $form->hidden('Message.username', array("value"=>$cU['User']['username'])); 
     34  echo $form->hidden('Message.username',   array("value"=>$cU['User']['username'])); 
    3535?> 
    3636<fieldset> 
    3737<legend>Write Message:</legend> 
    38   <?php  
    39    
     38<?php 
    4039  echo $form->label('Message.user_id', 'Send message to:' ) . '<br />'; 
    4140   
    42   echo '<div id="updater"></div>'; 
     41  echo $ajax->div('updater') . $ajax->divEnd('updater') ; 
    4342   
    4443  echo $cU['User']['username'] . "  escribe: <br />"; 
    45   echo $form->label('Message.title', 'Asunto:' ) . "<br />"; 
    4644  echo $form->input('Message.title', array("size" => 35, "maxlength" => 50)) . "<br />"; 
    4745  echo $form->error('Message.title', 'Asunto is required.');  
    48    
    49   ?> 
     46?> 
    5047   
    5148</p> 
    5249  <br /> 
    53   <?php echo $form->label('Message.body', 'Message:' );?><br /> 
    54   <?php echo $form->textarea('Message.body', array("cols"=>50, "rows"=>8)) ?> 
    55   <?php echo $fck->load('MessageBody', 'Basic', 500, 200); ?> 
    56   <?php echo $form->error('Message.body', 'Message is required.'); ?> 
     50 <?php  
     51     echo $form->label('Message.body', 'Message:' ); 
     52     echo $form->textarea('Message.body', array("cols"=>50, "rows"=>8)); 
     53     echo $fck->load('MessageBody', 'Basic', 500, 200);  
     54     echo $form->error('Message.body', 'Message is required.');  
     55 ?> 
    5756  <br /> 
    5857  </p> 
  • trunk/app/views/messages/search.ctp

    r330 r331  
    11<?php 
    2 //var_dump($data); 
     2//die(debug($data)); 
    33 
    44$values = array(); 
     
    88    $values[$val["User"]["id"]] = $val["User"]["username"]; 
    99} 
    10  
     10//die(debug($values)); 
    1111echo $form->select('Message.user_id', $values, null, null, null, false); 
    1212 
  • trunk/app/webroot/js/prototype.js

    r1 r331  
    1 /*  Prototype JavaScript framework, version 1.5.0_rc1 
    2  *  (c) 2005 Sam Stephenson <sam@conio.net> 
     1/*  Prototype JavaScript framework, version 1.5.1.2 
     2 *  (c) 2005-2008 Sam Stephenson 
    33 * 
    44 *  Prototype is freely distributable under the terms of an MIT-style license. 
    5  *  For details, see the Prototype web site: http://prototype.conio.net/ 
     5 *  For details, see the Prototype web site: http://www.prototypejs.org/ 
    66 * 
    77/*--------------------------------------------------------------------------*/ 
    88 
    99var Prototype = { 
    10   Version: '1.5.0_rc1', 
     10  Version: '1.5.1.2', 
     11 
     12  Browser: { 
     13    IE:     !!(window.attachEvent && !window.opera), 
     14    Opera:  !!window.opera, 
     15    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, 
     16    Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1 
     17  }, 
     18 
    1119  BrowserFeatures: { 
    12     XPath: !!document.evaluate 
    13   }, 
    14  
    15   ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', 
    16   emptyFunction: function() {}, 
     20    XPath: !!document.evaluate, 
     21    ElementExtensions: !!window.HTMLElement, 
     22    SpecificElementExtensions: 
     23      (document.createElement('div').__proto__ !== 
     24       document.createElement('form').__proto__) 
     25  }, 
     26 
     27  ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>', 
     28  JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, 
     29 
     30  emptyFunction: function() { }, 
    1731  K: function(x) { return x } 
    1832} 
     
    4761  }, 
    4862 
     63  toJSON: function(object) { 
     64    var type = typeof object; 
     65    switch(type) { 
     66      case 'undefined': 
     67      case 'function': 
     68      case 'unknown': return; 
     69      case 'boolean': return object.toString(); 
     70    } 
     71    if (object === null) return 'null'; 
     72    if (object.toJSON) return object.toJSON(); 
     73    if (object.ownerDocument === document) return; 
     74    var results = []; 
     75    for (var property in object) { 
     76      var value = Object.toJSON(object[property]); 
     77      if (value !== undefined) 
     78        results.push(property.toJSON() + ': ' + value); 
     79    } 
     80    return '{' + results.join(', ') + '}'; 
     81  }, 
     82 
    4983  keys: function(object) { 
    5084    var keys = []; 
     
    76110  var __method = this, args = $A(arguments), object = args.shift(); 
    77111  return function(event) { 
    78     return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments))); 
     112    return __method.apply(object, [event || window.event].concat(args)); 
    79113  } 
    80114} 
     
    82116Object.extend(Number.prototype, { 
    83117  toColorPart: function() { 
    84     var digits = this.toString(16); 
    85     if (this < 16) return '0' + digits; 
    86     return digits; 
     118    return this.toPaddedString(2, 16); 
    87119  }, 
    88120 
     
    94126    $R(0, this, true).each(iterator); 
    95127    return this; 
     128  }, 
     129 
     130  toPaddedString: function(length, radix) { 
     131    var string = this.toString(radix || 10); 
     132    return '0'.times(length - string.length) + string; 
     133  }, 
     134 
     135  toJSON: function() { 
     136    return isFinite(this) ? this.toString() : 'null'; 
    96137  } 
    97138}); 
     139 
     140Date.prototype.toJSON = function() { 
     141  return '"' + this.getFullYear() + '-' + 
     142    (this.getMonth() + 1).toPaddedString(2) + '-' + 
     143    this.getDate().toPaddedString(2) + 'T' + 
     144    this.getHours().toPaddedString(2) + ':' + 
     145    this.getMinutes().toPaddedString(2) + ':' + 
     146    this.getSeconds().toPaddedString(2) + '"'; 
     147}; 
    98148 
    99149var Try = { 
     
    101151    var returnValue; 
    102152 
    103     for (var i = 0; i < arguments.length; i++) { 
     153    for (var i = 0, length = arguments.length; i < length; i++) { 
    104154      var lambda = arguments[i]; 
    105155      try { 
     
    146196  } 
    147197} 
     198Object.extend(String, { 
     199  interpret: function(value) { 
     200    return value == null ? '' : String(value); 
     201  }, 
     202  specialChar: { 
     203    '\b': '\\b', 
     204    '\t': '\\t', 
     205    '\n': '\\n', 
     206    '\f': '\\f', 
     207    '\r': '\\r', 
     208    '\\': '\\\\' 
     209  } 
     210}); 
     211 
    148212Object.extend(String.prototype, { 
    149213  gsub: function(pattern, replacement) { 
     
    154218      if (match = source.match(pattern)) { 
    155