Skip to content
Snippets Groups Projects
class.thread.php 31.8 KiB
Newer Older
  • Learn to ignore specific revisions
  • Peter Rotich's avatar
    Peter Rotich committed
                    && ($r = new Response($id, $tid))
    
                    && $r->getId()==$id
                    )?$r:null;
    
        }
    }
    
    /* Note - Ticket thread entry of type note (Internal Note) */
    class Note extends ThreadEntry {
    
        function Note($id, $ticketId=0) {
            parent::ThreadEntry($id, 'N', $ticketId);
        }
    
        function getMessage() {
            return $this->getBody();
        }
    
    
    Peter Rotich's avatar
    Peter Rotich committed
        /* static */
        function create($vars, &$errors) {
            return self::lookup(self::add($vars, $errors));
        }
    
        function add($vars, &$errors) {
    
            //Check required params.
            if(!$vars || !is_array($vars) || !$vars['ticketId'])
                $errors['err'] = 'Missing or invalid data';
            elseif(!$vars['note'])
                $errors['note'] = 'Note required';
    
            if($errors) return false;
    
            //TODO: use array_intersect_key  when we move to php 5 to extract just what we need.
            $vars['type'] = 'N';
            $vars['body'] = $vars['note'];
    
            return ThreadEntry::add($vars);
        }
    
        function lookup($id, $tid=0, $type='N') {
    
            return ($id
    
                    && is_numeric($id)
    
    Peter Rotich's avatar
    Peter Rotich committed
                    && ($n = new Note($id, $tid))
    
                    && $n->getId()==$id
                    )?$n:null;