~sit-developers/sit/master

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
<?php
// manage_users.php - Overview of users, with links to managing them
//
// SiT (Support Incident Tracker) - Support call tracking system
// Copyright (C) 2010-2014 The Support Incident Tracker Project
// Copyright (C) 2000-2009 Salford Software Ltd. and Contributors
//
// This software may be used and distributed according to the terms
// of the GNU General Public License, incorporated herein by reference.
//

// This Page Is Valid XHTML 1.0 Transitional! 16Nov05

require ('core.php');
$permission = PERM_ADMIN; // Administrate
require (APPLICATION_LIBPATH . 'functions.inc.php');
// This page requires authentication
require (APPLICATION_LIBPATH . 'auth.inc.php');

$title = $strManageUsers;

include (APPLICATION_INCPATH . 'htmlheader.inc.php');

$sort = clean_fixed_list($_REQUEST['sort'], array('','realname','role','jobtitle','email','phone','fax','status','accepting'));

$sql  = "SELECT *,u.id AS userid FROM `{$dbUsers}` AS u, `{$dbRoles}` AS r ";
$sql .= "WHERE u.roleid = r.id ";

// sort users by realname by default
if (!isset($sort) || $sort == "realname") $sql .= " ORDER BY IF(status> 0,1,0) DESC, realname ASC";
else if ($sort == "username") $sql .= " ORDER BY IF(status> 0,1,0) DESC, username ASC";
else if ($sort == "role") $sql .= " ORDER BY roleid ASC";
else if ($sort == "jobtitle") $sql .= " ORDER BY title ASC";
else if ($sort == "email") $sql .= " ORDER BY email ASC";
else if ($sort == "phone") $sql .= " ORDER BY phone ASC";
else if ($sort == "fax") $sql .= " ORDER BY fax ASC";
else if ($sort == "status")  $sql .= " ORDER BY status ASC";
else if ($sort == "accepting") $sql .= " ORDER BY accepting ASC";

$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);

echo "<h2>".icon('user', 32, $strManageUsers)." {$strManageUsers}</h2>";
echo "<p class='contextmenu' align='center'>";
$operations = array();
$operations[$strNewUser] = array('url' => 'user_new.php?action=showform', PERM_USER_ADD);
$operations[$strRolePermissions] = array('url' => 'edit_user_permissions.php', 'perm' => PERM_USER_EDIT);
$operations[$strUserGroups] = 'usergroups.php';
if ($CONFIG['holidays_enabled'])
{
    $operations[$strEditHolidayEntitlement] = 'edit_holidays.php';
}
echo html_action_links($operations);
echo "</p>";
echo "<table class='maintable'>";
echo "<tr>";
echo "<th><a href='{$_SERVER['PHP_SELF']}?sort=realname'>{$strName}</a> ";
echo "(<a href='{$_SERVER['PHP_SELF']}?sort=username'>{$strUsername}</a>)</th>";
echo "<th><a href='{$_SERVER['PHP_SELF']}?sort=email'>{$strEmail}</a></th>";
echo "<th><a href='{$_SERVER['PHP_SELF']}?sort=role'>{$strRole}</a></th>";
echo "<th>{$strStatus}</th>";
if ($CONFIG['use_ldap'])
{
    echo "<th>{$strSource}".help_link('UserSource')."</th>";
}
echo "<th>{$strActions}</th>";

echo "</tr>\n";

// show results
$class = 'shade1';
while ($users = mysql_fetch_object($result))
{
    // define class for table row shading
    if ($users->status == 0) $class = 'expired';
    // print HTML
    echo "<tr class='{$class}' onclick='trow(event);'>\n";
    echo "<td>{$users->realname}";
    echo " (";
    if ($users->userid == 1) echo "<strong>";
    echo "{$users->username}";
    if ($users->userid == 1) echo "</strong>";
    echo ")</td>";

    echo "<td>";
    echo $users->email;
    echo "</td>";

    echo "<td>{$users->rolename}</td>";
    echo "<td>";
    if (user_permission($sit[2], PERM_USER_DISABLE))
    {
        if ($users->status > 0) echo "{$strEnabled}";
        else echo "{$strDisabled}";
    }
    else echo "-";

    echo "</td>";
    if ($CONFIG['use_ldap'])
    {
        echo "<td>";
        if ($users->user_source == 'sit')
        {
            echo $CONFIG['application_shortname'];
        }
        elseif ($users->user_source == 'ldap')
        {
            echo $strLDAP;
        }
        else
        {
            echo $strUnknown;
        }
    }
    echo "</td>";
    echo "<td>";
    $operations = array();
    $operations[$strEdit] = array('url' => "user_profile_edit.php?userid={$users->userid}", 'perm' => PERM_USER_EDIT);
    if ($users->status > 0)
    {
        if ($users->userid > 1 AND $users->user_source == 'sit')
        {
            $operations[$strResetPassword] = "forgotpwd.php?action=sendpwd&amp;userid={$users->userid}";
        }
        $operations[$strSetSkills] = "edit_user_skills.php?user={$users->userid}";
        $operations[$strSetSubstitutes] = "edit_backup_users.php?user={$users->userid}";
        if ($users->userid > 1)
        {
            $operations[$strPermissions] = "edit_user_permissions.php?action=edit&amp;user={$users->userid}";
        }
    }
    echo html_action_links($operations);
    echo "</td>";

    echo "</tr>\n";
    // invert shade
    if ($class == 'shade2') $class = "shade1";
    else $class = "shade2";

}
echo "</table>\n";

// free result and disconnect
mysql_free_result($result);

include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
?>