Changeset 461 for trunk/app/models

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

Forums and topics improveds

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/models/topic.php

    r333 r461  
    22/** 
    33*  Karamelo eLearning Platform 
    4 *  Chipotle Software 2002-2008  
     4*  Chipotle Software 2002-2008 
     5*  @author: Manuel Montoya  
    56*  GPLv3 manuel<arroba>mononeurona<punto>org 
    67**/  
     8// file: app/models/topic.php 
    79 
    810class Topic extends AppModel 
     
    4648        ); */ 
    4749 
    48   public function addVisitor($users = array(), $user_id, $topic_id)   
    49   { // this is just to set a flag to indicate user is visiting topic for first time 
    50      
    51     $ids = array(); 
    52     //die(var_dump( $users  )); 
    53     foreach ($users as $v) 
    54     {  
    55        array_push($ids, $v['id']); 
    56     } 
    57      
    58     if ( in_array($user_id, $ids) ) 
    59     { 
    60       return false; 
    61     } 
    62     else 
    63     { 
    64         $this->data['Visitor']['topic_id'] = $topic_id;  
    65         $this->data['Visitor']['user_id']  = $user_id; 
    66         $this->Visitor->create(); 
    67  
    68         if ( $this->Visitor->save( $this->data['Visitor'] ) ) 
    69         { 
    70           return true; 
    71         } 
    72         else 
    73         { 
    74           die('Error on addVisitor function'); 
    75         } 
    76     } 
    77     return true; 
    78   } 
    79  
    80   public $validate = array( 
     50 public $validate = array( 
    8151      'subject' => VALID_NOT_EMPTY, 
    8252      'message' => VALID_NOT_EMPTY, 
     
    8454      'forum_id' => VALID_NOT_EMPTY 
    8555      ); 
     56 
     57  public function addVisitor($topic_id, $user_id)   
     58  {  
     59    $this->data['Visitor']['topic_id'] = $topic_id;  
     60    $this->data['Visitor']['user_id']  = $user_id; 
     61 
     62    $this->Visitor->create(); 
     63 
     64    if ( $this->Visitor->save( $this->data['Visitor'] ) ): 
     65          return true; 
     66    else: 
     67          die('Error on addVisitor function'); 
     68    endif; 
     69 
     70    return true; 
     71  } 
    8672} 
    8773?>