Changeset 401

Show
Ignore:
Timestamp:
04/16/08 03:07:25 (9 months ago)
Author:
aarkerio
Message:

Comment on new

Location:
trunk/app
Files:
13 modified
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/app/config/sql/karamelo_postgres.sql

    r395 r401  
    1391393, 1, 1); 
    140140 
    141 -- Discutions on news 
    142 CREATE TABLE commentnews ( 
    143  id serial PRIMARY KEY, 
    144  new_id int NOT NULL REFERENCES news(id) ON DELETE CASCADE, 
    145  name varchar(100), 
    146  comment text NOT NULL, 
     141-- Discussions on portal news 
     142CREATE TABLE discussions ( 
     143 "id" serial PRIMARY KEY, 
     144 "new_id" int NOT NULL REFERENCES news(id) ON DELETE CASCADE, 
     145 "name" varchar(100), 
     146 "comment" text NOT NULL, 
    147147 "created" timestamp(0) with time zone DEFAULT now() NOT NULL, 
    148  level int NOT NULL, 
    149  comentnew_id int NOT NULL, 
    150  user_id int REFERENCES news(id) NOT NULL, 
    151  status int NOT NULL DEFAULT 0 
     148 "level" int NOT NULL, 
     149 "discussion_id" int NOT NULL, 
     150 "user_id" int REFERENCES news(id) NOT NULL, 
     151 "status" int NOT NULL DEFAULT 0 
    152152); 
    153153 
     
    163163INSERT INTO licenses (title) VALUES ('CopyRigth License'); 
    164164 
    165 --Edis (Educative elements) 
    166 CREATE TABLE edis ( 
    167  id serial PRIMARY KEY, 
    168  title varchar(150) NOT NULL, 
    169  tags varchar(150) NOT NULL, 
    170  description text, 
    171  status smallint NOT NULL DEFAULT 0, 
    172  created timestamp(0) with time zone DEFAULT now() NOT NULL, 
    173  modified timestamp(0) with time zone DEFAULT now() NOT NULL, 
    174  license_id integer NOT NULL REFERENCES licenses(id) ON DELETE CASCADE, 
    175  user_id integer NOT NULL REFERENCES users(id) ON DELETE CASCADE 
    176 ); 
    177  
    178165-- ** Forums tables beggins ** 
    179 CREATE TABLE catforums (  -- phorums categories 
     166CREATE TABLE catforums (  -- forums categories 
    180167 id serial PRIMARY KEY, 
    181168 title varchar(150) NOT NULL, 
     
    183170 created timestamp(0) with time zone DEFAULT now() NOT NULL, 
    184171 user_id integer NOT NULL REFERENCES users(id) ON DELETE CASCADE, 
    185  status int NOT NULL DEFAULT 0 -- Activated = 1,  Deactivated=0 
     172 status int NOT NULL DEFAULT 0 -- Enabled = 1,  Disabled = 0 
    186173); 
    187174 
  • trunk/app/controllers/commentnews_controller.php

    r400 r401  
    88*  @package Karamelo 
    99*/ 
    10 //File: /app/controllers/commentnews_controller.php 
     10//File: /app/controllers/discusions_controller.php 
    1111 
    1212uses('sanitize'); 
     
    1414App::import('Model','User'); 
    1515 
    16 class CommentnewsController extends AppController 
     16class DiscusionsController extends AppController 
    1717{ 
    18  public $name       = 'Commentnews'; 
    19      
    2018 public $helpers    = array('Ajax', 'Time', 'Gags'); 
    2119     
     
    2422 public function beforeFilter()  
    2523 { 
    26     $this->Auth->allow(array('captcha', 'insert', 'rss')); 
     24    $this->Auth->allow(array('captcha', 'add', 'rss')); 
    2725    parent::beforeFilter(); 
    2826 } 
     
    4038 } 
    4139 
    42  public function insert() 
    43  { 
    44     
    45    //die(var_dump($this->data)); 
     40 public function add() 
     41 {    
     42   echo 'entre !!!<br />'; 
     43  die(debug($this->data['Commentnews'])); 
    4644 
    4745   if ( !empty($this->data['Commentnews']) ) 
  • trunk/app/controllers/components/captcha.php

    r23 r401  
    11<?php  
     2/** 
     3*  Karamelo e-Learning Platform 
     4*  Chipotle Software TM   2002-2008 
     5*  GPLv3 
     6*  @author Manuel Montoya manuel<arroba>mononeurona<punto>org 
     7*  @version 0.2 
     8*  @package Karamelo 
     9*/ 
     10//File: /app/controllers/components/captcha.php 
    211 
    312class CaptchaComponent extends Object 
    413{ 
     14  public function initialize()  
     15  { 
     16     
     17  } 
     18 
    519    public function startup(&$controller) 
    620    { 
     
    1024    public function render() 
    1125    { 
    12         vendor('kcaptcha/kcaptcha'); 
     26      if ( !vendor('kcaptcha/kcaptcha')) 
     27      { 
     28       die('Problem in captcha component'); 
     29      } 
    1330         
    1431        $kcaptcha = new KCAPTCHA(); 
  • trunk/app/controllers/news_controller.php

    r400 r401  
    1313 
    1414class NewsController extends AppController { 
     15 
     16 public $name = 'News'; 
    1517   
    1618 public $helpers          = array('Ajax', 'Fck', 'News', 'Time', 'Gags'); 
     
    4446        $conditions = array("News.status"=>1); 
    4547         
    46         $fields     = array("News.id", "News.title", "News.comments", "News.body", "News.created", "News.reference", "News.theme_id", "News.user_id", "Theme.img", "Theme.theme", "User.username", "Subject.title", "Subject.id"); 
     48        $fields     = null; 
    4749         
    4850        $order      = "News.id DESC"; 
    4951                     
    50         $limit      = 15; 
    51          
    52         $this->set('data', $this->News->findAll($conditions)); 
     52        $limit      = 10; 
     53         
     54        $this->set('data', $this->News->findAll($conditions, $fields, $order)); 
    5355         
    5456        $this->Portal->statics(); // Charge Portal components aka Sidebars 
  • trunk/app/models/discussion.php

    r282 r401  
    55*  GPLv3 manuel<arroba>mononeurona<punto>org 
    66**/  
     7//file: app/models/discussion.php 
    78 
    8 class Commentnews extends AppModel 
     9class Discussion extends AppModel 
    910{ 
    10   public $name = 'Commentnews'; 
     11  public $name = 'Discussion'; 
    1112   
    1213  public $belongsTo = array('News' => 
     
    2425  public $validate = array( 
    2526                      'username' => array( 
    26                      'rule' => array('minLength', 6),   
     27                     'rule' => array('minLength', 2),   
    2728                                          'message' => 'Usernames must be at least 6 characters long.' 
    2829                     )  
  • trunk/app/models/news.php

    r399 r401  
    2525     
    2626  public $hasMany  = array( 
    27              'Commentnews' => array( 
    28                              'className'    => 'Commentnews', 
     27             'Discussion' => array( 
     28                             'className'    => 'Discussion', 
    2929                             'foreignKey'   => 'new_id' 
    3030                               ) 
  • trunk/app/models/wiki.php

    r371 r401  
    11<?php 
     2/** 
     3*  Karamelo eLearning Platform 
     4*  Chipotle Software 2002-2008  
     5*  GPLv3 manuel<arroba>mononeurona<punto>org 
     6**/  
     7//file: app/models/wiki.php 
     8 
    29class Wiki extends AppModel { 
    310 
  • trunk/app/vendors/kcaptcha/kcaptcha.php

    r1 r401  
    11<?php 
    2  
    32# KCAPTCHA PROJECT VERSION 1.2.4 
    43 
     
    1716# See kcaptcha_config.php for customizing 
    1817 
    19 class KCAPTCHA{ 
     18class KCAPTCHA { 
    2019 
    2120    // generates keystring and image 
    22     function KCAPTCHA(){ 
     21    public function KCAPTCHA(){ 
    2322 
    2423        require(dirname(__FILE__).'/kcaptcha_config.php'); 
     
    202201        } 
    203202 
    204         if(function_exists("imagejpeg")){ 
     203        if (function_exists("imagejpeg")) 
     204                { 
    205205            header("Content-Type: image/jpeg"); 
    206206            imagejpeg($img2, null, $jpeg_quality); 
  • trunk/app/views/news/admin_add.ctp

    r301 r401  
    66   echo $html->addCrumb('News', '/admin/news/listing'); 
    77   echo $html->getCrumbs(' / '); 
    8    echo $form->create('News', array('action'=>'admin_add', 'onsubmit'=>'return validateNew()'));  
     8   echo $form->create('News', array('onsubmit'=>'return validateNew()'));  
     9 
     10   echo $html->div('title_section', 'Add new'); 
    911?> 
    1012<table> 
     
    2426<td> 
    2527<?php  
    26    echo $form->input('News.reference', array("size" => 30, "maxlength" => 250, "value"=>"http://"));  
     28   echo $form->input('News.reference', array('size'=> 30, 'maxlength'=> 250, 'value'=>'http://'));  
    2729 ?> 
    2830</td> 
     
    3436  <?php  
    3537     echo $form->label('News.Body', 'Body:' ); 
    36      echo $form->textarea('News.body', array("cols"=>80, "rows"=>45)); 
     38     echo $form->textarea('News.body', array('cols'=>80, 'rows'=>35)); 
    3739     echo $fck->load('NewsBody', 'Karamelo');  
    38      echo $form->error('News.body', 'Body is required.'); 
    39  ?> 
     40  ?> 
    4041</td></tr> 
    4142<tr><td colspan="2"> 
    4243  <?php  
    4344     echo $form->label('News.status', 'Published:' ); 
    44      echo $form->checkbox('News.status', null, array("value"=>1));  
     45     echo $form->checkbox('News.status', array('value'=>1));  
    4546  ?> 
    4647</td> 
     
    4849  <?php  
    4950     echo $form->label('News.comments', 'Comments actived:' ); 
    50      echo $form->checkbox('News.comments', null, array("value"=>1));  
     51     echo $form->checkbox('News.comments', array('value'=>1));  
    5152  ?> 
    5253</td> 
     
    5455   <?php  
    5556     echo $form->label('News.end', 'Finish editing:'); 
    56      echo $form->checkbox('News.end', null, array("value"=>1));  
     57     echo $form->checkbox('News.end', array('value'=>1));  
    5758    ?> 
    5859</td> 
  • trunk/app/views/news/admin_edit.ctp

    r311 r401  
    44  echo $html->addCrumb('News', '/admin/news/listing');  
    55  echo $html->getCrumbs(' / ');  
     6 
     7  echo $html->para(null, $html->link($html->image('actions/new.png', array("alt"=>"Add new", "title"=>"Add new")), '/admin/news/add', null, false, false)); 
    68 
    79  echo $form->create('News', array('onsubmit'=>'return validateNew()'));  
     
    1214<td> 
    1315<?php  
    14   echo $form->input('News.title', array("size" => 40, "maxlength" => 120)); 
     16  echo $form->input('News.title', array('size' => 40, 'maxlength' => 120)); 
    1517  echo $form->error('News.title', 'Title is required.');  
    1618?> 
     
    2325</td> 
    2426<td> 
    25   <?php echo $form->input('News.reference', array("size" => 30, "maxlength" => 250, "value"=>"http://"));  ?> 
     27  <?php echo $form->input('News.reference', array("size" => 30, "maxlength" => 250, 'value'=>'http://'));  ?> 
    2628</td> 
    2729<td> 
     
    3234  <?php  
    3335     echo $form->label('News.Body', 'Body:') . '<br />'; 
    34      echo $form->textarea('News.body', array("cols"=>80, "rows"=>45));  
     36     echo $form->textarea('News.body', array('cols'=>80, 'rows'=>35));  
    3537     echo $fck->load('NewsBody', 'Karamelo');  
    36      echo $form->error('News.body', 'News is required.');  
    3738  ?> 
    3839</td></tr> 
     
    4041  <td> 
    4142 <?php  
    42      echo $form->label('News.status', 'Published:' ); 
     43     echo $form->label('News.status', 'Published:'); 
    4344     echo $form->checkbox('News.status', array("value"=>1));  
    4445  ?> 
     
    5253 <td colspan="2"> 
    5354 <?php  
    54       echo $form->label('News.end', 'Finish editing:' ); 
     55      echo $form->label('News.end', 'Finish editing:'); 
    5556      echo $form->checkbox('News.end', array("value"=>1));  
    5657 ?> 
  • trunk/app/views/news/display.ctp

    r400 r401  
    22// die(debug($data)); 
    33 
    4 echo $html->div('title_section', 'News'); 
     4echo $html->div('title_portal', 'News in campus'); 
    55 
    66foreach ($data as $val) 
     
    2929      $tmp .= $html->div(null, $html->link('Reference', $val['News']['reference'])); 
    3030  } 
    31      
     31    
     32  if ($val['News']['comments'] == 1 )  // the reference 
     33  { 
     34    $tmp .= $html->div(null, $html->link('Put your comment', '/news/view/'.$val['News']['id'])); 
     35  }  
    3236  echo $html->div('wrapnew', $tmp);  
    3337 } 
  • trunk/app/views/news/view.ctp

    r400 r401  
    1 <div class="titnew"><?php echo $data['News']['title']; ?></div> 
     1<?php 
     2echo $html->div('titnew', $data['News']['title']); 
    23 
    3 <div class="redaccion">From  <i><?php echo $data['Theme']['theme']; ?> dept</i>,  
    4     posted by  
    5 <?php  
    6   echo $html->link($data['User']['username'], '/users/blogger/'.$data['User']['username']).' on '. $data['News']['created'];  
     4echo $html->div('redaccion', 'From  <i>'.$data['Theme']['theme'].' dept</i>, posted by '.$html->link($data['User']['username'], '/users/blogger/'.$data['User']['username']).' on '. $data['News']['created']);  
    75?> 
    8 </div>  
     6 
    97<div class="bodynew"> 
    10      
    118<?php 
    129 
     
    2320    <span style="font-size:7pt;">Permalink:</span> <br /> 
    2421    <?php echo $html->link( 
    25                'http://'.$_SERVER['SERVER_NAME'].'/news/display/'.$data['News']['id'],  
    26                            'http://'.$_SERVER['SERVER_NAME'].'/news/display/'.$data['News']['id'] 
     22               'http://'.$_SERVER['SERVER_NAME'].'/news/view/'.$data['News']['id'],  
     23                           'http://'.$_SERVER['SERVER_NAME'].'/news/view/'.$data['News']['id'] 
    2724               );  
    2825?> 
     
    3734                           null, 
    3835                           false); 
    39      
    40      
     36       
    4137echo $news->socialNets($data['News']['id'], $data['News']['title']); // Social nets buttons 
    4238     
     
    4541  $i = 1; 
    4642  echo '<div id="cnews">'; 
    47   foreach($data["Commentnews"] as $v) 
     43  foreach($data['Discussion'] as $v) 
    4844  { 
    4945      $bg = ($i%2==0) ? "#e2e2e2" : "#fff"; 
     
    5652  } 
    5753  echo "</div>"; 
    58 ?> 
    59 <p> 
    60 <?php  
    61    echo $form->create('Commentnews', array('action'=>'add',"onsubmit"=>"return validateNew()")); 
    62    echo $form->hidden('Commentnews.new_id', array('value'=>$data['News']['id']));  
    63    echo $form->hidden('Commentnews.level', array('value'=>1)); 
    64    echo $form->hidden('Commentnews.comentnew_id', array('value'=>1)); 
     54 
     55  echo $form->create('Discussion', array('action'=>'add')); 
     56  echo $form->hidden('Discussion.new_id', array('value'=>$data['News']['id']));  
     57  echo $form->hidden('Discussion.level', array('value'=>1)); 
     58  echo $form->hidden('Discussion.comentnew_id', array('value'=>1)); 
    6559?> 
    6660<fieldset> 
    6761   <legend>Add comment:</legend> 
    68   <?php  
    69    if ( isset( $cU['User']['id'] ) )  
    70    { 
    71        echo $form->hidden('Commentnews.user_id', array('value'=> $cU['User']['id'])); 
    72        echo $form->hidden('Commentnews.name',  array('value'=>$cU['User']['username'])); 
     62<?php  
     63  if ( isset( $cU['User']['id'] ) ): 
     64       echo $form->hidden('Discussion.user_id', array('value'=> $cU['User']['id'])); 
     65       echo $form->hidden('Discussion.name',  array('value'=>$cU['User']['username'])); 
    7366       echo '<b>'. $cU['User']['username'] . '</b>  write: <br />'; 
    74   } 
    75   else 
    76   { 
    77       echo $form->hidden('Commentnews.user_id', array('value'=> 0)); 
    78       echo $form->input('Commentnews.name', array('size'=> 25, 'maxlength' => 40)); 
     67 
     68  else: 
     69 
     70      echo $form->hidden('Discussion.user_id', array('value'=> 0)); 
     71      echo $form->input('Discussion.name', array('size'=> 25, 'maxlength' => 40)); 
    7972      
    80       echo '<br /><br /> <img src="'. $html->url('/comentnews/captcha') .'" alt="Captcha" title="Captcha" /> <br />'; 
    81       echo $form->input('Commentnews.captcha', array("size" => 6, "maxlength" => 6)); 
    82       echo $form->label('Commentnews.captcha', 'Introduce el código, todas la letras son minúsculas' ); 
    83   } 
     73      echo '<br /><br /> <img src="'. $html->url('/discussions/captcha') .'" alt="Captcha" title="Captcha" /> <br />'; 
     74      echo $form->input('Discussion.captcha', array("size" => 6, "maxlength" => 6)); 
     75      echo $form->label('Discussion.captcha', 'Introduce el código, todas la letras son minúsculas' ); 
     76  endif; 
    8477   
    85   echo $form->textarea('Commentnews.comment', array('cols'=>60, 'rows'=>10)); 
    86  
    87 ?> 
    88   </fieldset> 
    89 <?php echo $form->end('Send comment'); ?> 
     78  echo $form->textarea('Discussion.comment', array('cols'=>60, 'rows'=>10)) . $form->end('Send comment'); ?> 
    9079 
    9180 
    9281<?php } ?> 
    93 </div> 
     82</div><!-- bodynew --> 
  • trunk/app/webroot/css/portal/portal.css

    r360 r401  
    394394 
    395395.divblock{ padding:4px;margin:2px; border:1px solid gray; } 
     396 
     397.title_portal{ font-size:18pt; color:#30a6f0;font-weight:bold;font-family:Arial;margin:0;}