Changeset 325

Show
Ignore:
Timestamp:
03/19/08 16:27:43 (10 months ago)
Author:
aarkerio
Message:

Little changes on edublog entry and I added replies controller to answer topics

Location:
trunk/app
Files:
1 added
18 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/app_controller.php

    r324 r325  
    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', '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', 'message', 'directory', 'bloggers', 'add', 'rss', 'discussion') ); 
    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/config/core.php

    r324 r325  
    1414 * In development mode, you need to click the flash message to continue. 
    1515 */ 
    16     Configure::write('debug', 2); 
     16    Configure::write('debug', 1); 
    1717/** 
    1818 * Application wide charset encoding 
  • trunk/app/config/sql/karamelo_postgres.sql

    r322 r325  
    198198); 
    199199 
    200 --Forums tables 
     200-- ** Forums tables beggins ** 
    201201CREATE TABLE catforums (  -- phorums categories 
    202202 id serial PRIMARY KEY, 
     
    217217); 
    218218 
    219 CREATE TABLE topics ( -- question and aswers in phorums   
     219CREATE TABLE topics ( -- question and aswers in forums   
    220220 id serial PRIMARY KEY, 
    221221 subject varchar(150) NOT NULL, 
     
    225225 user_id integer NOT NULL REFERENCES users(id) ON DELETE CASCADE, 
    226226 status int NOT NULL DEFAULT 1, 
    227  level int NOT NULL DEFAULT 0,   --level 0 = topic starts 
    228  topic_id int NOT NULL DEFAULT 1, -- topic id and level 2 giveme answers  
    229227 views int NOT NULL DEFAULT 0  -- number of times the topic has been seen 
    230228); 
     229 
     230CREATE TABLE replies ( -- replies to topics in forums   
     231 id serial PRIMARY KEY, 
     232 reply text NOT NULL, 
     233 created timestamp(0) with time zone DEFAULT now() NOT NULL, 
     234 topic_id integer NOT NULL REFERENCES topics(id) ON DELETE CASCADE, 
     235 user_id integer NOT NULL REFERENCES users(id) ON DELETE CASCADE, 
     236 status int NOT NULL DEFAULT 1 
     237); 
     238-- ** Forums tables ends ** 
    231239 
    232240-- News letters 
  • trunk/app/controllers/catforums_controller.php

    r323 r325  
    4646        ======= ADMIN METHODS   ======= 
    4747 ******/ 
    48  public function admin_listing($admin = null, $order=null) 
     48 public function admin_listing() 
    4949 { 
    5050        $this->layout = 'admin'; 
     
    5454        $conditions = array("user_id"=>$this->Auth->user('id')); 
    5555         
    56         if ($this->Auth->user('group_id') == 1 && $admin != null) 
    57         { 
    58             $conditions["website"] = 1; 
    59         } 
     56        $fields     = array("id", "title", "description","created", "status"); 
     57         
     58        $order      = 'Catforum.id ASC'; 
    6059         
    61         $fields     = array("id", "title", "description","created", "status"); 
    62          
    63         $this->set('data', $this->Catforum->findAll($conditions, $fields, $order, null, null, 2));  
     60        $this->set('data', $this->Catforum->findAll($conditions, $fields, $order));  
    6461     
    65     } 
    66      
    67     public function admin_add()  
    68     { 
    69      
    70      $this->layout = 'admin'; 
    71         // adds new classroom to database 
    72     if (!empty($this->data['Catforum'])) 
    73      {      
     62 } 
     63  
     64 public function admin_add()  
     65 { 
     66   
     67  $this->layout = 'admin'; 
     68  // adds new classroom to database 
     69  if (!empty($this->data['Catforum'])) 
     70  {        
    7471          $this->Sanitize = new Sanitize; 
    7572           
     
    108105        } 
    109106    } 
    110   } 
    111    
    112   public function admin_delete($id) 
    113   { 
     107 } 
     108 // change status published/draft 
     109 public function admin_change($status, $forum_id) 
     110 {   
     111    if ( !is_numeric($status)  ||  !intval($forum_id) ) 
     112    {  
     113      $this->redirect('/'); 
     114    } 
     115     
     116    $this->data['Forum']['status'] = ($status == 0 ) ? 1 : 0; 
     117      
     118    $this->data['Forum']['id']     = $id; 
     119      
     120    if ($this->Forum->save($this->data['Forum'])) 
     121    { 
     122    $this->msgFlash('Status changed', '/admin/catforums/listing'); 
     123    } 
     124 } 
     125  
     126 public function admin_delete($id) 
     127 { 
    114128        // deletes task from database 
    115129        $this->Catforum->del($id); 
     
    117131                $this->msgFlash('Forum deleted', '/admin/catforums/listing'); 
    118132                exit(); 
    119   } 
    120133 } 
     134} 
    121135?> 
  • trunk/app/controllers/comments_controller.php

    r302 r325  
    4545      } 
    4646       
    47       // print_r($conditions); 
    48        
    4947      $fields     = array("id", "title", "description", "pubdate", "size"); 
    5048      $order      = "id DESC"; 
     
    5755 public function add()  
    5856 { 
    59        
    6057      if (!empty($this->data["Comment"]) ) 
    6158      { 
     59        
    6260       $this->Sanitize = new Sanitize; 
    6361        
    64        $this->Sanitize->cleanArray($this->data["Comment"]); //Hopefully this is enough 
     62       $this->Sanitize->clean($this->data["Comment"]); //Hopefully this is enough 
    6563        
    6664       $this->Comment->create(); 
    67          
     65        
    6866        if ($this->Comment->save($this->data["Comment"])) 
    6967        { 
    7068           $this->msgFlash('Comment added', $this->data['Comment']['redirect_to'].'/#comments'); 
    71            exit(); 
    7269        } 
    7370      } 
     
    8077 public function admin_listing() 
    8178 {     
    82       $this->pageTitle = $this->othAuth->user('username') . '\'s Comments'; 
     79      $this->pageTitle = $this->Auth->user('username') . '\'s Comments'; 
    8380       
    8481      $this->layout = 'admin'; 
    8582       
    86       $conditions   = array("Comment.user_id"=>$this->othAuth->user('id')); 
     83      $conditions   = array("Comment.user_id"=>$this->Auth->user('id')); 
    8784      $fields       = array("Comment.id", "Comment.created", "Comment.comment", "Comment.user_id", "Comment.username", "Entry.title", "Entry.id"); 
    8885      $order        = "Comment.id DESC"; 
  • trunk/app/controllers/components/edublog.php

    r274 r325  
    11<?php  
    22/** 
    3  * Edublog component By Manuel Montoya. 
    4  * comments, bug reports are welcome:     manuel _AT_ mononeurona _DOT_ org 
     3 * Edublog component By Manuel Montoya. 2002-2008 
     4 * comments, bug reports are welcome:     manuel _ARROBA_ mononeurona _PUNTO_ org 
    55 * @author aarkerio 
    66 * @version 0.2 
  • trunk/app/controllers/forums_controller.php

    r322 r325  
    150150    } 
    151151 } 
    152   // change status published/draft 
    153   public function admin_change($id, $status) 
    154   {   
     152 // change status published/draft 
     153 public function admin_change($status, $forum_id) 
     154 {   
     155    if ( !is_numeric($status)  ||  !intval($forum_id) ) 
     156    {  
     157      $this->redirect('/'); 
     158    } 
     159     
    155160    $this->data['Forum']['status'] = ($status == 0 ) ? 1 : 0; 
    156161      
     
    159164    if ($this->Forum->save($this->data['Forum'])) 
    160165    { 
    161     $this->msgFlash('Forum status changed', '/admin/catforums/listing/'); 
     166    $this->msgFlash('Status changed', '/admin/catforums/listing'); 
    162167    } 
    163   } 
     168 } 
     169  
    164170 public function admin_delete($id) 
    165171 { 
  • trunk/app/controllers/topics_controller.php

    r324 r325  
    1616 public function isAuthorized() 
    1717 { 
    18           if (isset($this->params[Configure::read('Routing.admin')])) 
    19          { 
    20               if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) 
    21               { 
    22                     return true; 
    23               } 
    24          } 
     18     if (isset($this->params[Configure::read('Routing.admin')])) 
     19     { 
     20          if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) 
     21          { 
     22                return true; 
     23          } 
     24     } 
    2525  return false; 
    2626 } 
    2727  
    28  public function view($user_id, $forum_id) 
     28 public function view($username, $forum_id) 
    2929 { 
    3030     $this->pageTitle = 'Forums'; 
    31       
     31      
     32     $user_id = $this->Topic->User->field('id', array('User.username'=>$username)); 
     33      
    3234     $this->layout    = $this->Edublog->layout($user_id); 
    3335      
     
    5759     $order      = "Topic.created DESC"; 
    5860      
    59      $this->set('data', $this->Topic->findAll($conditions, $fields, $order)); 
     61     $this->set('data', $this->Topic->find($conditions, $fields, $order)); 
    6062 } 
    6163  
     
    7375 public function add($username=null, $forum_id = null)  
    7476 { 
    75    
    7677   if (!empty($this->data['Topic'])) 
    7778   {  
    78       
    7979     $this->Sanitize = new Sanitize; 
    8080      
     
    8787     if ($this->Topic->save($this->data)) 
    8888     {  
    89           $this->flash('New topic had been added.','/topics/view/'.$this->data['Topic']["user_id"].'/'. $this->data['Topic']['forum_id']); 
     89          $this->flash('Topic added', '/forums/display/'.$this->data['Topic']['forum_id']); 
    9090     } 
    9191   }  
     
    9393   { 
    9494      $user_id = $this->Topic->User->field('id', array('User.username'=>$username)); 
    95  
     95       
    9696      $this->layout    = $this->Edublog->layout($user_id); 
    97         
     97       
    9898      $this->Edublog->blog($user_id); 
    99         
     99       
    100100      $this->set('forum_id', $forum_id); 
    101101    } 
     
    103103 } 
    104104  
    105   public function reply($user_id = null, $forum_id = null) { 
    106      
    107     // adds new topic to forum 
    108     if (!empty($this->data["Topic"])) 
    109     {  
    110        // die(print_r($this->data)); 
    111        $this->Sanitize = new Sanitize; 
    112        
    113        $this->Sanitize->cleanArray($this->data["Topic"]); 
    114        
    115        if ($this->Topic->save($this->data)) 
    116        {  
    117          $this->flash('New topic had been added.','/topics/view/'.$this->data['Topic']["user_id"].'/'. $this->data['Topic']['forum_id']); 
    118        } 
    119      }  
    120      else  
    121      { 
     105 public function reply($user_id, $forum_id, $topic_id)  
     106 { 
     107    // adds new reply to topic 
     108 
    122109       $this->layout    = $this->Edublog->layout($user_id); 
    123110        
     
    125112        
    126113       $this->set('forum_id', $forum_id); 
    127     } 
     114       $this->set('topic_id', $topic_id); 
    128115 } 
    129116  
     
    160147    if ($this->Topic->save($this->data['Topic'])) 
    161148    { 
    162     $this->msgFlash('Topic status changed', '/admin/forums/topics/'.$forum_id); 
     149       $this->msgFlash('Topic status changed', '/admin/forums/topics/'.$forum_id); 
    163150    } 
    164151 } 
  • trunk/app/views/catforums/admin_edit.ctp

    r258 r325  
    11<div class="spaced"> 
    22<?php  
    3     echo $html->formTag('/admin/catforums/edit/', 'post');  
    4     echo $html->hidden('Catforum/id'); 
     3    echo $form->create('Catforum');  
     4    echo $form->hidden('Catforum.id'); 
    55?> 
    66<fieldset> 
     
    88 
    99<?php 
    10     echo $form->labelTag('Catforum/title', 'Title:') . "<br />"; 
    11     echo $html->input('Catforum/title', array('size'=>60, 'maxlength'=>90)); 
    12     echo $html->tagErrorMsg('Catforum/title','Please enter a title.');  
     10    echo $form->input('Catforum.title', array('size'=>60, 'maxlength'=>90)); 
     11    echo $form->error('Catforum.title','Please enter a title.');  
    1312?> 
    1413<br /> 
    1514<br /> 
    1615<?php  
    17    echo $form->labelTag('Catforum/description', 'Description:') . "<br />";  
    18    echo $html->input('Catforum/description', array("size" => 60, "maxlength" => 90)); 
    19    echo $html->tagErrorMsg('Catforum/description','Please enter a description.'); 
     16   echo $form->input('Catforum.description', array("size" => 60, "maxlength" => 90)); 
     17   echo $form->error('Catforum.description','Please enter a description.'); 
    2018?> 
    2119 
    2220<br /><br /> 
    23 <?php echo $form->labelTag('Catforum/status', 'Status:') . "<br />"; ?> 
    24 <?php echo $html->checkbox('Catforum/status'); ?> 
     21<?php  
     22    echo $form->label('Catforum.status', 'Status:') . "<br />"; 
     23    echo $form->checkbox('Catforum.status', array('value'=>1)); 
     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<?php echo $form->end('Update'); ?> 
     28 
    3029</div> 
    3130 
  • trunk/app/views/catforums/admin_listing.ctp

    r321 r325  
    6060         echo '<tr><td>&nbsp;</td> <td> '.  $gags->sendEdit($v["id"], 'forums') .'</td>'; 
    6161         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>'; 
     62         echo '<td>' . $html->link($gags->setStatus($v['status']), '/admin/forums/change/'.$v['status'].'/'.$v['id']).'</td>  <td> ' .  $gags->confirmDel($v['id'], 'forums') . '</td> </tr>'; 
    6363      } 
    6464 } 
  • trunk/app/views/catforums/display.ctp

    r322 r325  
    2727 } 
    2828?> 
    29  
  • trunk/app/views/forums/display.ctp

    r323 r325  
    55 echo '<div style="padding:6px;border:1px dotted gray;margin:15px 0 15px 0">'; 
    66   echo '<div style="padding:6px;border:1px solid orange;font-size:17pt;color:orange;font-weight:bold">'.$data["Forum"]["title"].'</div>'; 
    7      echo '<span ="font-size:pt">'. $data["Forum"]["description"] . "</span>";        
    8      echo '<div style="width:100px;margin-top:15px">'; 
    9      echo $html->link($html->image('static/new_post.gif', array("alt"=>"Add new topic", "title"=>"Add new topic")),  
     7    echo '<span ="font-size:pt">'. $data["Forum"]["description"] . "</span>";        
     8    echo '<div style="width:100px;margin-top:15px">'; 
     9    echo $html->link($html->image('static/new_post.gif', array("alt"=>"Add new topic", "title"=>"Add new topic")),  
    1010                      '/topics/add/'.$blog["User"]["username"].'/'.$data["Forum"]["id"],  
    1111                      null, null, false); 
    12      echo '</div>'; 
     12    echo '</div>'; 
    1313          
    14      //Topics 
    15      echo '<table style="border-collapse:collapse;width:100%">'; 
    16         if ( count($data["Topic"]) == 0) 
    17         { 
     14    //Topics 
     15    echo '<table style="border-collapse:collapse;width:100%">'; 
     16     if ( count($data["Topic"]) == 0) 
     17     { 
    1818                 echo '<tr><td colspan="6"><br /><h4>There is not topic on this forum yet</h4></td></tr>'; 
    19         } 
    20         else 
    21         { 
     19     } 
     20     else 
     21     { 
    2222                $th = array('Read', 'Topics', 'Replies', 'Author', 'Views', 'Last Post'); 
    2323                echo $html->tableHeaders($th); 
    24         } 
    25         //die(print_r($data["Topic"])); 
     24      } 
     25      //die(print_r($data["Topic"])); 
    2626             
    27         foreach ($data["Topic"] as $val) 
    28         { 
    29      if ($val['level'] == 0) 
    30      { 
    31          $tr = array ( 
     27      foreach ($data["Topic"] as $val) 
     28      { 
     29         $tr = array ( 
    3230         $html->image('static/folder.gif'),  
    3331         $html->link($val['subject'], '/topics/display/'.$data['Forum']['user_id'].'/'.$val['forum_id'].'/'.$val['id']), 
     
    4038               echo $html->tableCells($tr, array("style"=>"border:1px solid gray;padding:6px;background-color:#e8f6fe"),  
    4139                                            array("style"=>"border:1px solid gray;padding:6px;background-color:#c0c0c0")); 
    42      } 
    43          } 
     40        
     41       } 
    4442               
    45           echo '</table>'; 
    46              
    47      echo '</div>'; 
     43       echo '</table>';  
     44       echo '</div>'; 
    4845  
    4946  
  • trunk/app/views/layouts/admin.ctp

    r317 r325  
    5050 
    5151   <div id="footer"> 
    52           <p>Powered by the <a href="http://www.chipotle-software.com/" rel="external">Karamelo Project &copy; GPLv3</a></p> 
     52          <p>Powered by the <a href="http://www.chipotle-software.com/" rel="external">Karamelo Project &copy; 2002-2008 GPLv3</a> </p> 
    5353   </div> 
    5454 
  • trunk/app/views/layouts/rubyx.ctp

    r281 r325  
    172172                <p id="createdby">created by <a href="http://www.nuvio.cz">Nuvio | Webdesign</a> <!-- DON?T REMOVE, PLEASE! --></p>  
    173173              
    174             <p id="copyright">Chipotle Software &copy; 2002-2007. Creative Commons. Some rights reserved.</p>  
     174            <p id="copyright">Chipotle Software &copy; 2002-2008. Creative Commons. Some rights reserved.</p>  
    175175        </div> <!-- /footer -->  
    176176  
  • trunk/app/views/topics/display.ctp

    r322 r325  
    11<?php 
    2 die(debug($data)); 
     2//die(debug($data)); 
     3 
     4echo '<h1>'. $data['Forum']['title'] .'</h1>'; 
     5echo '<p>'. $data['User']['username'] . ' write: <b>'.$data['Topic']['subject'] .'</b>  <span class="dates">'.$data['Topic']['created'].'</span></p>'; 
     6 
    37echo '<div>'; 
    48 
    5 echo $html->link( 
     9echo $html->link(  // add topic 
    610                 $html->image( 
    711                              'static/new_topic.gif', array("alt"=>"New topic", "title"=>"New topic") 
    812                             ), 
    9                   '/topics/add/'.$blog[0]["User"]["id"].'/'.$phorum_id,  
     13                  '/topics/add/'.$blog["User"]["username"].'/'.$data['Forum']['id'],  
    1014                  false, false, null 
    11                  );  
     15                 ); 
    1216 
    13 echo $html->link($html->image('static/reply.gif', array("alt"=>"Reply", "title"=>"Reply")), '/topics/reply/'.$blog[0]["User"]["id"].'/'.$topic_id, false, false, null);  
     17echo $html->link(  // add reply 
     18                 $html->image( 
     19                              'static/reply.gif', array("alt"=>"Reply", "title"=>"Reply")),  
     20                              '/topics/reply/'.$blog["User"]["id"].'/'.$data['Forum']['id'] .'/'.$data['Topic']['id'],  
     21                              false, false, null);  
    1422 
    1523echo '</div>'; 
     24 
    1625echo '<div style="padding:5px;border:1px dotted black;background-color:#c0c0c0;margin:10px 5px 10px 5px">'; 
    17      
    18 foreach ($data as $key => $val) { 
    19     echo '<div> Title:<a href="/topics/display/'.$data[$key]['Topic']['id'].'">'. $data[$key]['Topic']['subject'].'</a><br />'; 
    20     echo $data[$key]['Topic']['message']; 
     26  
     27 if ( count($data['Reply']) < 1 ) 
     28 { 
     29     echo '<h2>No replies yet</h2>'; 
     30 } 
     31  
     32 foreach ($data['Reply'] as $val)  
     33 { 
     34    echo '<div> Title:<a href="/topics/display/'.$val['id'].'">'. $val['subject'].'</a><br />'; 
     35    echo $val['message']; 
    2136     
    2237    echo '</div>';  
    23 } 
     38 } 
    2439echo '</div>'; 
    2540 
    2641 
    27 echo '<div>'; 
    28 echo $html->link($html->image('static/new_topic.gif', array("alt"=>"New topic", "title"=>"New topic")), '/topics/add/'.$blog[0]["User"]["id"].'/'.$phorum_id, false, false, null);  
    29  
    30 echo $html->link($html->image('static/reply.gif', array("alt"=>"Reply", "title"=>"Reply")), '/topics/reply/'.$blog[0]["User"]["id"].'/'.$topic_id, false, false, null);  
    31  
    32  
    33 echo '</div>'; 
    34  
    3542?> 
  • trunk/app/views/topics/reply.ctp

    r314 r325  
    11 
    2 <?php echo $javascript->link('myfunctions'); ?> 
    3  
    4 <div> 
    5 <?php echo $html->addCrumb('Phorums', '/phorums/view/'.$blog[0]["User"]["id"]); ?>  
    6 <?php echo $html->getCrumbs(' / '); ?> 
    7 </div> 
    8 <div class="title_section">New Topic</div> 
     2<div class="title_section">Reply</div> 
    93 
    104<div class="spaced"> 
    115 
    12 <?php //echo $html->formTag('/topics/add/'. $blog[0]["User"]["id"] .'/'. $phorum_id, 'post');  
     6<?php  
     7 if ( isset ($cU) ): 
     8   echo $form->create('Reply', array('action'=>'add')); 
     9   echo $form->hidden('Reply.redirect_to', array('value'=>'/topics/display/'.$blog['User']['id'].'/