This file is indexed.

/usr/share/horde/sesha/lib/Sesha.php is in php-horde-sesha 1.0.0~beta1-11ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php
/**
 * This is the base Sesha class.
 *
 * Copyright 2004-2007 Andrew Coleman <mercury@appisolutions.net>
 * Copyright 2007-2012 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author  Andrew Coleman <mercury@appisolutions.net>
 * @package Sesha
 */
class Sesha
{
    /** Sort by stock id. */
    const SORT_STOCKID = 100;
    /** Sort by stock name. */
    const SORT_NAME = 101;
    /** Sort by stock note. */
    const SORT_NOTE = 102;
    /** Sort in ascending order. */
    const SORT_ASCEND = 0;
    /** Sort in descending order. */
    const SORT_DESCEND = 1;

    // Search Field Constants

    const SEARCH_ID = 1;
    const SEARCH_NAME = 2;
    const SEARCH_NOTE = 4;
    const SEARCH_PROPERTY = 8;

    /**
     * This function will return the list of available categories.
     *
     * @return mixed  Array of categories on success; PEAR_Error on failure.
     */
    public function listCategories()
    {
        $sesha_driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create();
        return $sesha_driver->getCategories();
    }

    /**
     * Returns a Hord_Form_Type_stringlist value split to an array.
     *
     * @param string $string  A comma separated string list.
     *
     * @return array  The string list as an array.
     */
    public function getStringlistArray($string)
    {
        $string = str_replace("'", "\'", $string);
        $values = explode(',', $string);

        foreach ($values as $value) {
            $value = trim($value);
            $value_array[$value] = $value;
        }

        return $value_array;
    }

    /**
     * Comparison function for sorting inventory stock by id.
     *
     * @param array $a  Item one.
     * @param array $b  Item two.
     *
     * @return integer  1 if item one is greater, -1 if item two is greater;
     *                  0 if they are equal.
     */
    protected function _sortByStockID($a, $b)
    {
        if ($a['stock_id'] == $b['stock_id']) return 0;
        return ($a['stock_id'] > $b['stock_id']) ? 1 : -1;
    }

    /**
     * Comparison function for reverse sorting stock by id.
     *
     * @param array $a  Item one.
     * @param array $b  Item two.
     *
     * @return integer  -1 if item one is greater, 1 if item two is greater;
     *                  0 if they are equal.
     */
    protected function _rsortByStockID($a, $b)
    {
        if ($a['stock_id'] == $b['stock_id']) return 0;
        return ($a['stock_id'] > $b['stock_id']) ? -1 : 1;
    }

    /**
     * Comparison function for sorting inventory stock by name.
     *
     * @param array $a  Item one.
     * @param array $b  Item two.
     *
     * @return integer  1 if item one is greater, -1 if item two is greater;
     *                  0 if they are equal.
     */
    protected function _sortByName($a, $b)
    {
        if ($a['stock_name'] == $b['stock_name']) return 0;
        return ($a['stock_name'] > $b['stock_name']) ? 1 : -1;
    }

    /**
     * Comparison function for reverse sorting stock by name.
     *
     * @param array $a  Item one.
     * @param array $b  Item two.
     *
     * @return integer  -1 if item one is greater, 1 if item two is greater;
     *                  0 if they are equal.
     */
    protected function _rsortByName($a, $b)
    {
        if ($a['stock_name'] == $b['stock_name']) return 0;
        return ($a['stock_name'] > $b['stock_name']) ? -1 : 1;
    }

    /**
     * Comparison function for sorting inventory stock by a property.
     *
     * @param array $a  Item one.
     * @param array $b  Item two.
     *
     * @return integer  1 if item one is greater, -1 if item two is greater;
     *                  0 if they are equal.
     */
    protected function _sortByProperty($a, $b)
    {
        if ($a[$GLOBALS['_sort_property']] == $b[$GLOBALS['_sort_property']]) return 0;
        return ($a[$GLOBALS['_sort_property']] > $b[$GLOBALS['_sort_property']]) ? 1 : -1;
    }

    /**
     * Comparison function for reverse sorting stock by a property.
     *
     * @param array $a  Item one.
     * @param array $b  Item two.
     *
     * @return integer  -1 if item one is greater, 1 if item two is greater;
     *                  0 if they are equal.
     */
    protected function _rsortByProperty($a, $b)
    {
        if ($a[$GLOBALS['_sort_property']] == $b[$GLOBALS['_sort_property']]) return 0;
        return ($a[$GLOBALS['_sort_property']] > $b[$GLOBALS['_sort_property']]) ? -1 : 1;
    }

    /**
     * Comparison function for sorting inventory stock by note.
     *
     * @param array $a  Item one.
     * @param array $b  Item two.
     *
     * @return integer  1 if item one is greater, -1 if item two is greater;
     *                  0 if they are equal.
     */
    protected function _sortByNote($a, $b)
    {
        if ($a['note'] == $b['note']) return 0;
        return ($a['note'] > $b['note']) ? 1 : -1;
    }

    /**
     * Comparison function for reverse sorting stock by note.
     *
     * @param array $a  Item one.
     * @param array $b  Item two.
     *
     * @return integer  -1 if item one is greater, 1 if item two is greater;
     *                  0 if they are equal.
     */
    protected function _rsortByNote($a, $b)
    {
        if ($a['note'] == $b['note']) return 0;
        return ($a['note'] > $b['note']) ? -1 : 1;
    }

    /**
     * Amend Sesha's list of menu items with a new button and generate output.
     */
    public static function menu()
    {
        $sidebar = Horde::menu(array('menu_ob' => true))->render();
        $perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
        if (Sesha::isAdmin(Horde_Perms::READ) ||
            $perms->hasPermission('sesha:addStock', $GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
            $sidebar->addNewButton(
                _("_Add Stock"),
                Horde::url('stock.php')->add('actionId', 'add_stock'));
        }
        Horde::startBuffer();
        return $GLOBALS['injector']->getInstance('Horde_View_Topbar')->render()
            . $sidebar . Horde::endBuffer();
    }



    public static function isAdmin($permLevel = Horde_Perms::DELETE)
    {
        return ($GLOBALS['registry']->isAdmin() || $GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission('sesha:admin', $GLOBALS['registry']->getAuth(), $permLevel));
    }
}