Skip to content
Snippets Groups Projects
class.priority.php 1.81 KiB
Newer Older
Jared Hancock's avatar
Jared Hancock committed
<?php
/*********************************************************************
    class.priority.php

    Priority handle

    Peter Rotich <peter@osticket.com>
    Copyright (c)  2006-2013 osTicket
Jared Hancock's avatar
Jared Hancock committed
    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 Priority extends VerySimpleModel
implements TemplateVariable {
    static $meta = array(
        'table' => PRIORITY_TABLE,
        'pk' => array('priority_id'),
        'ordering' => array('-priority_urgency')
    );
Jared Hancock's avatar
Jared Hancock committed

    function getId() {
        return $this->priority_id;
Jared Hancock's avatar
Jared Hancock committed
    }

    function getTag() {
        return $this->priority;
Jared Hancock's avatar
Jared Hancock committed
    }

    function getDesc() {
        return $this->priority_desc;
Jared Hancock's avatar
Jared Hancock committed
    }

    function getColor() {
        return $this->priority_color;
Jared Hancock's avatar
Jared Hancock committed
    }

    function getUrgency() {
        return $this->priority_urgency;
Jared Hancock's avatar
Jared Hancock committed
    }

    function isPublic() {
        return $this->ispublic;
    // TemplateVariable interface
    function asVar() { return $this->getDesc(); }
    static function getVarScope() {
        return array(
            'desc' => __('Priority Level'),
    function __toString() {
        return $this->getDesc();
    }

Jared Hancock's avatar
Jared Hancock committed
    /* ------------- Static ---------------*/
    static function getPriorities( $publicOnly=false) {
Jared Hancock's avatar
Jared Hancock committed
        $priorities=array();

        $objects = static::objects()->values_flat('priority_id', 'priority_desc');
        if ($publicOnly)
            $objects->filter(array('ispublic'=>1));

        foreach ($objects as $row) {
Peter Rotich's avatar
Peter Rotich committed
            $priorities[$row[0]] = $row[1];
Jared Hancock's avatar
Jared Hancock committed
        }

        return $priorities;
    }

    function getPublicPriorities() {
        return self::getPriorities(true);
    }
}
?>