Skip to content
Snippets Groups Projects
class.team.php 7.25 KiB
<?php
/*********************************************************************
    class.team.php

    Teams

    Peter Rotich <peter@osticket.com>
    Copyright (c)  2006-2013 osTicket
    http://www.osticket.com

    Released under the GNU General Public License WITHOUT ANY WARRANTY.
    See LICENSE.TXT for details.

    vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/

class Team {

    var $id;
    var $ht;

    var $members;

    function Team($id) {

        return $this->load($id);
    }

    function load($id=0) {

        if(!$id && !($id=$this->getId()))
            return false;
        
        $sql='SELECT team.*,count(member.staff_id) as members '
            .' FROM '.TEAM_TABLE.' team '
            .' LEFT JOIN '.TEAM_MEMBER_TABLE.' member USING(team_id) '
            .' WHERE team.team_id='.db_input($id)
            .' GROUP BY team.team_id ';

        if(!($res=db_query($sql)) || !db_num_rows($res))
            return false;

        $this->ht=db_fetch_array($res);
        $this->id=$this->ht['team_id'];
        $this->members=array();

        return $this->id;
    }

    function reload() {
        return $this->load($this->getId());
    }

    function asVar() {
        return $this->getName();
    }

    function getId() {
        return $this->id;
    }

    function getName() {
        return $this->ht['name'];
    }

    function getNumMembers() {
        return $this->ht['members'];
    }

    function getMembers() {