Changeset 537

Show
Ignore:
Timestamp:
05/20/08 20:43:23 (8 months ago)
Author:
aarkerio
Message:

Discussions

Location:
trunk/app
Files:
8 modified

Legend:

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

    r529 r537  
    125125   $this->layout    = 'admin'; 
    126126 
    127    $this->pageTitle = 'Comments on Blogs'; 
    128        
     127   $this->pageTitle = 'Comments on News'; 
     128 
     129   $this->Discussion->bindModel(array('belongsTo'=> array('News' =>array('className'=> 'News', 'foreignKey'=> 'new_id' ))));    
     130 
    129131   $conditions  = null; 
     132    
     133   $fields = array('Discussion.id','News.id','News.title','Discussion.id','Discussion.comment', 'Discussion.created', 'Discussion.username', 'Discussion.user_id', 'Discussion.status'); 
    130134 
    131    $fields = array("Discussion.id", "News.title", "Discussion.id", "Discussion.comment", "Discussion.created", "Discussion.username", "Discussion.user_id"); 
    132    $order           = "Discussion.id DESC"; 
    133         
     135   $order  = "Discussion.id DESC"; 
     136    
     137   $limit  = 50;      
     138     
    134139   $this->set('data', $this->Discussion->findAll($conditions, $fields, $order, $limit)); 
    135140 } 
    136141  
    137  public function admin_edit($id) 
     142 public function admin_edit($id=null) 
    138143 { 
    139     if (empty($this->data["Discussion"])) 
    140     { 
     144    if (empty($this->data["Discussion"])): 
     145 
    141146        $this->layout = 'admin'; 
    142          
    143         $this->Discussion->poll_id = $id; 
    144                
    145         $this->data = $this->Discussion->read(); 
    146     } 
    147     else 
    148     { 
     147                       
     148        $this->data = $this->Discussion->read(null, $id); 
     149    
     150    else: 
     151 
    149152        $this->Sanitize = new Sanitize; 
    150153         
    151154        $this->Sanitize->clean($this->data["Discussion"]); 
    152155         
    153         if ($this->Discussion->save($this->data["Discussion"])) 
    154         { 
    155             $this->msgFlash('/polls/listing'); 
    156         } 
    157     } 
    158 } 
     156        if ($this->Discussion->save($this->data["Discussion"])): 
     157             $this->msgFlash('Disccusion saved', '/admin/discussions/listing'); 
     158    endif; 
     159    endif; 
     160 } 
    159161 
    160  public function admin_delete($id) 
     162 // change status enabled/disabled actived 
     163 public function admin_change($discussion_id, $status) 
     164 {  
     165     $this->data['Discussion']['status'] = ($status == 0 ) ? 1 : 0; 
     166      
     167     $this->data['Discussion']['id']     = $discussion_id; 
     168      
     169    if ($this->Discussion->save($this->data['Discussion'])): 
     170          $this->msgFlash('Discussio status changed', '/admin/discussions/listing'); 
     171    endif; 
     172 } 
     173 
     174 public function admin_delete($discussion_id) 
    161175 { 
    162176    // deletes comment on database 
    163     $this->Discussion->del($id); 
    164     $this->msgFlash('Comment deleted', '/admin/commentnews/listing'); 
    165   } 
     177   if ( $this->Discussion->del($discussion_id) ): 
     178        $this->msgFlash('Comment deleted', '/admin/discussions/listing'); 
     179   endif; 
     180 } 
    166181} 
    167182?> 
  • trunk/app/controllers/news_controller.php

    r515 r537  
    5353         
    5454        $this->Portal->statics(); // Charge Portal components aka Sidebars 
    55     } 
     55 } 
    5656     
    57     public function view($id = null) 
    58     { 
    59         if ($id == null) 
    60         { 
     57 public function view($new_id = null) 
     58 { 
     59  if ( $new_id == null || !intval($new_id) ): 
    6160            $this->redirect("/"); 
    62         } 
    63          
    64         $this->layout = 'portal'; 
    65  
    66         $this->pageTitle = '::News'; 
    67          
    68         $conditions = array("News.status"=>1, "News.id"=>$id); 
    69          
    70         $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"); 
    71          
    72         $this->set('data', $this->News->find($conditions, $fields, null, 2)); 
    73          
    74         $this->Portal->statics(); // Charge Portal components aka Sidebars 
    75     } 
     61  endif; 
     62         
     63  $this->layout = 'portal'; 
     64 
     65  $this->pageTitle = '::News'; 
     66 
     67  $this->News->User->unbindAll(); 
     68         
     69  $conditions = array('News.status'=>1, 'News.id'=>$new_id); 
     70         
     71  $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'); 
     72         
     73  $this->set('data', $this->News->find($conditions, $fields, null, 2)); 
     74         
     75  $this->Portal->statics(); // Charge Portal components aka Sidebars 
     76 } 
    7677   
    7778    /** 
  • trunk/app/models/discussion.php

    r407 r537  
    1111  public $name = 'Discussion'; 
    1212   
    13   public $belongsTo = array('News' => 
     13  /* public $belongsTo = array('News' => 
    1414                         array('className'     => 'News', 
    1515                               'conditions'    => null, 
     
    2121                               'finderQuery'   => '' 
    2222                         ) 
    23                   ); 
     23                  ); */ 
    2424 
    2525  public $validate = array( 
  • trunk/app/models/news.php

    r535 r537  
    2020             'Theme' => array( 
    2121                             'className'    => 'Theme',     
    22                              'foreignKey'   => 'theme_id' 
     22                             'foreignKey'   => 'theme_id'  
    2323                              ) 
    2424             ); 
     
    2626  public $hasMany  = array( 
    2727             'Discussion' => array( 
    28                              'className'    => 'Discussion', 
    29                              'foreignKey'   => 'new_id' 
    30                                ) 
    31              ); 
     28                                   'className'    => 'Discussion', 
     29                                   'foreignKey'   => 'new_id', 
     30                                   'conditions'   => 'Discussion.status = 1' 
     31                                   ) 
     32                         ); 
    3233 
    3334     public $validate = array( 
  • trunk/app/models/theme.php

    r535 r537  
    22/** 
    33*  Karamelo E-Learning Platform 
    4 *  Manuel Montoya 2002-2007  
    5 *  Chipotle Software 
    6 *  GPLv3 manuel<at>mononeurona.org 
     4*  Manuel Montoya 2002-2008  
     5*  Chipotle Software tm 
     6*  GPLv3 manuel<ARROBA>mononeurona<PUNTO>org 
    77*/  
    8 class Theme extends AppModel 
    9 { 
     8class Theme extends AppModel { 
     9 
    1010public $name = 'Theme'; 
    1111 
    12 public $hasMany  = array( 
     12 /* public $hasMany  = array( 
    1313             "News" => array( 
    1414                             "className"    => "News", 
    1515                             "foreignKey"   => "theme_id" 
    16                                )); 
     16                               )); */ 
    1717 
    1818public $validate = array( 
  • trunk/app/views/discussions/admin_listing.ctp

    r529 r537  
    11<?php 
    2 die(debug($data)); 
     2//die(debug($data)); 
    33echo $html->addCrumb('Control Tools', '/admin/news/start');  
    44echo $html->addCrumb('Comments', '/admin/comments/listing');  
     
    88 
    99foreach ($data as $val): 
    10    $tmp  = $html->link($val['Discussion']['title'], '/users/entry/'. $cU['User']['username'] . '/'.$val['Discussion']['id']) . '<br />'; 
    11    $tmp .= $val['Comment']['created'].' <b>'.$val['Comment']['username'].' wrote:</b><br />'; 
    12    $tmp .= $html->para(null, $val['Comment']['comment']); 
    13    $tmp .= $gags->confirmDel($val['Comment']['id'], 'Comment'); 
    14    echo $html->div(null, $tmp); 
     10   $st   = ( $val['Discussion']['status'] == 1 ) ? 'Published' : 'Non published';  
     11   $tmp  = $html->link($val['News']['title'], '/news/view/'.$val['News']['id']) . '<br />'; 
     12   $tmp .= $val['Discussion']['created'].' <b>'.$val['Discussion']['username'].' wrote:</b><br />'; 
     13   $tmp .= $html->para(null, $val['Discussion']['comment']); 
     14   $tmp .= $html->para(null, $html->link($st, '/admin/discussions/change/'.$val['Discussion']['id'].'/'.$val['Discussion']['status'])); 
     15   $tmp .= $gags->confirmDel($val['Discussion']['id'], 'Discussion'); 
     16   echo $html->div('grayblock', $tmp); 
    1517endforeach; 
    1618?> 
    17  
  • trunk/app/views/news/view.ctp

    r497 r537  
    11<?php 
     2// die(debug($data)); 
    23echo $html->div('titnew', $data['News']['title']); 
    34 
     
    89<?php 
    910 
    10 echo $html->div('img_new', $html->link( 
     11 echo $html->div('img_new', $html->link( 
    1112                        $html->image('themes/'.$data['Theme']['img'],  
    1213                            array("alt"=>$data['Theme']['theme'], "title"=>$data['Theme']['theme'], "class"=>"themes")),  
     
    1415                    null, null, false)); 
    1516  
    16     echo $data['News']['body'];  
     17 echo $data['News']['body'];  
    1718?> 
    1819     
     
    4344  foreach($data['Discussion'] as $v) 
    4445  { 
    45       $bg = ($i%2==0) ? "#e2e2e2" : "#fff"; 
    46                
    47       echo '<div class="comentnew" style="background-color:'.$bg.'">';   
    48       echo $time->timeAgoInWords($v['created']) . ' <b>'. $v['username']    . '</b> wrote:<br />'; 
    49       echo $v["comment"]; 
    50       echo "</div>"; 
     46      $bg = ($i%2 == 0) ? "#e2e2e2" : "#fff"; 
     47           
     48      $tmp  = $html->para(null,$time->timeAgoInWords($v['created']) . ' <b>'. $v['username']    . '</b> wrote:<br />', array('style'=>'font-size:8pt;font-family:Georgia;')); 
     49      $tmp .= $html->para(null, $v['comment']); 
     50      echo $html->div('divblock', $tmp, array('style'=>'background-color:'.$bg));  
    5151      $i++; 
    5252  } 
  • trunk/app/webroot/img/themes

    • Property svn:ignore set to
      *