|
Support Incident Tracker GIT4.x
|
Go to the source code of this file.
Functions | |
| if(realpath(__FILE__)==realpath($_SERVER['SCRIPT_FILENAME'])) | user_permission ($userid, $permission) |
| user_id ($username, $password) | |
| user_password ($id) | |
| user_realname ($id, $allowhtml=FALSE) | |
| user_email ($id) | |
| user_phone ($id) | |
| user_mobile ($id) | |
| user_signature ($id) | |
| user_message ($id) | |
| user_status ($id) | |
| user_accepting ($id) | |
| user_activeincidents ($userid) | |
| user_countincidents ($id) | |
| user_incidents ($id) | |
| user_holiday ($userid, $type=0, $year, $month, $day, $length=FALSE) | |
| user_count_holidays ($userid, $type, $date=0, $approved=array(HOL_APPROVAL_NONE, HOL_APPROVAL_GRANTED, HOL_APPROVAL_DENIED)) | |
| user_holiday_entitlement ($userid) | |
| user_holiday_resetdate ($userid) | |
| user_drop_down ($name='', $id=0, $accepting=TRUE, $exclude=FALSE, $attribs= '', $return=true) | |
| user_group_id ($userid) | |
| user_online_icon ($user) | |
| user_online ($user) | |
| user_accepting_status ($userid) | |
| user_status_name ($userid) | |
| priority_icon ($id) | |
| userstatus_name ($id) | |
| holiday_type ($id) | |
| holiday_approval_status ($approvedid, $approvedby=-1) | |
| check_group_holiday ($userid, $date, $length='day') | |
| valid_username ($username) | |
| generate_password ($length=8) | |
| software_backup_userid ($userid, $softwareid) | |
| set_user_status ($userid, $newstatus) | |
| userstatus_summaryline ($userstatus= '', $accepting= '') | |
| get_user_config_vars ($userid) | |
| check_group_holiday | ( | $ | userid, |
| $ | date, | ||
| $ | length = 'day' |
||
| ) |
check to see if any fellow group members have holiday on the date specified
| int | $userid | - user ID |
| int | $date | - UNIX Timestamp |
| string | $length | - 'day', 'pm' or 'am' |
Definition at line 796 of file user.inc.php.
References $dbHolidays, $dbUsers, $groupid, $length, $mresult, $msql, $userid, E_USER_WARNING, user_group_id(), and user_realname().
Referenced by display_holiday_table().
{
global $dbUsers, $dbHolidays;
$namelist = '';
$groupid = user_group_id($userid);
if (!empty($groupid))
{
// list group members
$msql = "SELECT id AS userid FROM `{$dbUsers}` ";
$msql .= "WHERE groupid='{$groupid}' AND id != '$userid' ";
$mresult = mysql_query($msql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
while ($member = mysql_fetch_object($mresult))
{
// check to see if this group member has holiday
$hsql = "SELECT id FROM `{$dbHolidays}` WHERE userid='{$member->userid}' AND date = FROM_UNIXTIME({$date}) ";
if ($length == 'am' OR $length == 'pm')
{
$hsql .= "AND (length = '{$length}' OR length = 'day') ";
}
$hresult = mysql_query($hsql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
if (mysql_num_rows($hresult) >= 1)
{
$namelist .= user_realname($member->userid)." ($length)";
$namelist .= " ";
}
}
}
return $namelist;
}
| generate_password | ( | $ | length = 8 | ) |
Generates and returns a random alphanumeric password
Definition at line 869 of file user.inc.php.
References $length.
Referenced by User::add(), Contact::add(), and process_new_contact().
{
$possible = '0123456789'.'abcdefghijkmnpqrstuvwxyz'.'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.'-';
// $possible = '23456789'.'abcdefghjkmnpqrstuvwxyz'.'ABCDEFGHJKLMNPQRSTUVWXYZ'.'-';
// not using 1's 0's etc. to save confusion
// '-=!&';
$str = '';
while (mb_strlen($str) < $length)
{
$str .= mb_substr($possible, (rand() % mb_strlen($possible)),1);
}
return $str;
}
| get_user_config_vars | ( | $ | userid | ) |
Gets the list of user vars with values
| int | $userid | - User ID |
Definition at line 1027 of file user.inc.php.
References $CONFIG, $dbUserConfig, $result, $sql, and debug_log().
Referenced by login().
{
global $dbUserConfig, $CONFIG;
// Load user config defaults from global config
debug_log(print_r($CONFIG['user_config_defaults'], true), true);
if (is_array($CONFIG['user_config_defaults']))
{
$userconfig = $CONFIG['user_config_defaults'];
}
// Load user configuration, overriding any defaults
$sql = "SELECT * FROM `{$dbUserConfig}` WHERE userid = {$userid}";
$result = @mysql_query($sql);
if ($result AND mysql_num_rows($result) > 0)
{
while ($conf = mysql_fetch_object($result))
{
if ($conf->value === 'TRUE') $conf->value = TRUE;
if ($conf->value === 'FALSE') $conf->value = FALSE;
if (substr($conf->value, 0, 6) == 'array(')
{
eval("\$val = {$conf->value};");
$conf->value = $val;
}
$userconfig[$conf->config] = $conf->value;
}
}
debug_log('userconfig'.print_r($userconfig,true), true);
return $userconfig;
}
| holiday_approval_status | ( | $ | approvedid, |
| $ | approvedby = -1 |
||
| ) |
Definition at line 734 of file user.inc.php.
References $status, $strApprovalStatusUnknown, $strApproved, $strApprovedFree, $strArchivedApproved, $strArchivedApprovedFree, $strArchivedDenied, $strArchivedNotRequested, $strArchivedRequested, $strDenied, $strNotRequested, and $strRequested.
{
global $strApproved, $strApprovedFree, $strRequested, $strNotRequested, $strDenied;
global $strArchivedDenied, $strArchivedNotRequested, $strArchivedRequested;
global $strArchivedApproved, $strArchivedApprovedFree, $strApprovalStatusUnknown;
// We add 10 to normal status when we archive holiday
switch ($approvedid)
{
case -2:
$status = $strNotRequested;
break;
case -1:
$status = $strDenied;
break;
case 0:
if ($approvedby == 0)
{
$status = $strNotRequested;
}
else
{
$status = $strRequested;
}
break;
case 1:
$status = $strApproved;
break;
case 2:
$status = $strApprovedFree;
break;
case 8:
$status = $strArchivedNotRequested;
break;
case 9:
$status = $strArchivedDenied;
break;
case 10:
$status = $strArchivedRequested;
break;
case 11:
$status = $strArchivedApproved;
break;
case 12:
$status = $strArchivedApprovedFree;
break;
default:
$status = $strApprovalStatusUnknown;
break;
}
return $status;
}
| holiday_type | ( | $ | id | ) |
Definition at line 704 of file user.inc.php.
References $holidaytype, and $id.
{
switch ($id)
{
case HOL_HOLIDAY:
$holidaytype = $GLOBALS['strHoliday'];
break;
case HOL_SICKNESS:
$holidaytype = $GLOBALS['strAbsentSick'];
break;
case HOL_WORKING_AWAY:
$holidaytype = $GLOBALS['strWorkingAway'];
break;
case HOL_TRAINING:
$holidaytype = $GLOBALS['strTraining'];
break;
case HOL_FREE:
$holidaytype = $GLOBALS['strCompassionateLeave'];
break;
case HOL_PUBLIC:
$holidaytype = $GLOBALS['strPublicHoliday'];
break;
default:
$holidaytype = $GLOBALS['strUnknown'];
break;
}
return ($holidaytype);
}
| priority_icon | ( | $ | id | ) |
Definition at line 667 of file user.inc.php.
{
global $CONFIG;
switch ($id)
{
case 1:
$html = "<img src='{$CONFIG['application_webpath']}images/low_priority.gif' width='10' height='16' alt='{$GLOBALS['strLowPriority']}' title='{$GLOBALS['strLowPriority']}' />";
break;
case 2:
$html = "<img src='{$CONFIG['application_webpath']}images/med_priority.gif' width='10' height='16' alt='{$GLOBALS['strMediumPriority']}' title='{$GLOBALS['strMediumPriority']}' />";
break;
case 3:
$html = "<img src='{$CONFIG['application_webpath']}images/high_priority.gif' width='10' height='16' alt='{$GLOBALS['strHighPriority']}' title='{$GLOBALS['strHighPriority']}' />";
break;
case 4:
$html = "<img src='{$CONFIG['application_webpath']}images/crit_priority.gif' width='16' height='16' alt='{$GLOBALS['strCriticalPriority']}' title='{$GLOBALS['strCriticalPriority']}' />";
break;
default:
$html = '?';
break;
}
return $html;
}
| set_user_status | ( | $ | userid, |
| $ | newstatus | ||
| ) |
| int | $userid | The user who's status you want to set |
| string | $newstatus | - Either a user status ID or 'Yes' or 'No' |
Definition at line 932 of file user.inc.php.
References $dbUsers, $newstatus, $result, $sql, $userid, debug_log(), E_USER_ERROR, incident_backup_switchover(), and userstatus_summaryline().
Referenced by saction_SetUserStatus().
{
global $dbUsers;
switch ($newstatus)
{
case USERSTATUS_IN_OFFICE:
$accepting = 'Yes';
break;
case USERSTATUS_NOT_IN_OFFICE:
$accepting = 'No';
break;
case USERSTATUS_IN_MEETING:
// don't change
$accepting = '';
break;
case USERSTATUS_AT_LUNCH:
$accepting = '';
break;
case USERSTATUS_ON_HOLIDAY:
$accepting = 'No';
break;
case USERSTATUS_WORKING_FROM_HOME:
$accepting = 'Yes';
break;
case USERSTATUS_ON_TRAINING_COURSE:
$accepting = 'No';
break;
case USERSTATUS_ABSENT_SICK:
$accepting = 'No';
break;
case USERSTATUS_WORKING_AWAY:
// don't change
$accepting = '';
break;
case 'Yes':
case 'yes':
$accepting = 'Yes';
$newstatus = '';
break;
case 'No':
case 'no':
$accepting = 'No';
$newstatus = '';
break;
}
$sql = "UPDATE `{$dbUsers}` SET ";
if (!empty($newstatus)) $sql .= "status='$newstatus'";
if (!empty($newstatus) AND !empty($accepting)) $sql .= ', ';
if (!empty($accepting)) $sql .= "accepting='$accepting'";
$sql .= " WHERE id='{$userid}' LIMIT 1";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_ERROR);
debug_log("setting status: $sql", TRUE);
incident_backup_switchover($userid, $accepting);
$t = new TriggerEvent("TRIGGER_USER_CHANGED_STATUS", array('userid' => $userid));
return userstatus_summaryline($newstatus, $accepting);
}
| software_backup_userid | ( | $ | userid, |
| $ | softwareid | ||
| ) |
Definition at line 888 of file user.inc.php.
References $backupid, $dbUserSoftware, $result, $sql, E_USER_WARNING, and user_accepting().
Referenced by incident_backup_switchover().
{
global $dbUserSoftware;
$backupid = 0; // default
// Find out who is the substitute for this user/skill
$sql = "SELECT backupid FROM `{$dbUserSoftware}` WHERE userid = '{$userid}' AND softwareid = '{$softwareid}'";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
list($backupid) = mysql_fetch_row($result);
$backup1 = $backupid;
// If that substitute is not accepting then try and find another
if (empty($backupid) OR user_accepting($backupid) != 'Yes')
{
$sql = "SELECT backupid FROM `{$dbUserSoftware}` WHERE userid='{$backupid}' AND userid!='{$userid}' ";
$sql .= "AND softwareid='{$softwareid}' AND backupid!='{$backup1}'";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
list($backupid) = mysql_fetch_row($result);
$backup2 = $backupid;
}
// One more iteration, is the backup of the backup accepting? If not try another
if (empty($backupid) OR user_accepting($backupid)!='Yes')
{
$sql = "SELECT backupid FROM `{$dbUserSoftware}` WHERE userid='{$backupid}' AND userid!='{$userid}' ";
$sql .= "AND softwareid='{$softwareid}' AND backupid!='{$backup1}' AND backupid!='{$backup2}'";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
list($backupid) = mysql_fetch_row($result);
}
return ($backupid);
}
| user_accepting | ( | $ | id | ) |
Check whether the given user is accepting
| int | $id | The userid of the user to check |
| 'Yes' | User is accepting |
| 'No' | User is not accepting |
| 'NoSuchUser' | The given user does not exist |
Definition at line 245 of file user.inc.php.
References $id, and db_read_column().
Referenced by accepting_drop_down(), incident_backup_switchover(), software_backup_userid(), user_accepting_status(), and userstatus_summaryline().
{
$accepting = db_read_column('accepting', $GLOBALS['dbUsers'], $id);
if ($accepting == '') $accepting = "NoSuchUser";
return $accepting;
}
| user_accepting_status | ( | $ | userid | ) |
Returns whether the user is accepting or not
| int | $userid | ID of the user |
Definition at line 640 of file user.inc.php.
References $userid, and user_accepting().
{
if (user_accepting($userid) == 'Yes')
{
return 'accepting';
}
else
{
return 'not accepting';
}
}
| user_activeincidents | ( | $ | userid | ) |
Count the number of active incidents for a given user
| int | $id | The userid of the user to check |
Definition at line 260 of file user.inc.php.
References $CONFIG, $count, $dbContacts, $dbIncidents, $dbPriority, $now, $result, $sql, and E_USER_WARNING.
{
global $CONFIG, $now, $dbIncidents, $dbContacts, $dbPriority;
$count = 0;
// This SQL must match the SQL in incidents.php
$sql = "SELECT COUNT(i.id) ";
$sql .= "FROM `{$dbIncidents}` AS i, `{$dbContacts}` AS c, `{$dbPriority}` AS pr WHERE contact = c.id AND i.priority = pr.id ";
$sql .= "AND (owner='{$userid}' OR towner='{$userid}') ";
$sql .= "AND (status!='2') "; // not closed
// the "1=2" obviously false else expression is to prevent records from showing unless the IF condition is true
$sql .= "AND ((timeofnextaction > 0 AND timeofnextaction < $now) OR ";
$sql .= "(IF ((status >= 5 AND status <=8), ($now - lastupdated) > ({$CONFIG['regular_contact_days']} * 86400), 1=2 ) "; // awaiting
$sql .= "OR IF (status='1' OR status='3' OR status='4', 1=1 , 1=2) "; // active, research, left message - show all
$sql .= ") AND timeofnextaction < $now ) ";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
else list($count) = mysql_fetch_row($result);
return ($count);
}
| user_count_holidays | ( | $ | userid, |
| $ | type, | ||
| $ | date = 0, |
||
| $ | approved = array(HOL_APPROVAL_NONE, HOL_APPROVAL_GRANTED, HOL_APPROVAL_DENIED) |
||
| ) |
Count a users holidays of specified type
| integer | $userid | . User ID |
| integer | $type,. | Holiday type |
| integer | $date,. | (optional) UNIX timestamp. Only counts holidays before this date |
| array | $approved | (optional) An array of approval statuses to include when ommitted a default is used |
Definition at line 402 of file user.inc.php.
References $approved, $date, $dbHolidays, $result, $sql, debug_log(), and E_USER_WARNING.
{
global $dbHolidays;
$sql = "SELECT id FROM `{$dbHolidays}` WHERE userid='{$userid}' ";
$sql .= "AND type='{$type}' AND length='day' ";
if ($date > 0) $sql .= "AND `date` < FROM_UNIXTIME({$date})";
if (is_array($approved))
{
$sql .= "AND (";
for ($i = 0; $i < sizeof($approved); $i++)
{
$sql .= "approved = {$approved[$i]} ";
if ($i < sizeof($approved)-1) $sql .= "OR ";
}
$sql .= ") ";
}
else
{
$sql .= "AND (approved = ".HOL_APPROVAL_NONE." OR approved = ".HOL_APPROVAL_GRANTED.") ";
}
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
$full_days = mysql_num_rows($result);
$sql = "SELECT id FROM `{$dbHolidays}` ";
$sql .= "WHERE userid='{$userid}' AND type='{$type}' AND (length='pm' OR length='am') ";
if (is_array($approved))
{
$sql .= "AND (";
for ($i = 0; $i < sizeof($approved); $i++)
{
$sql .= "approved = {$approved[$i]} ";
if ($i < sizeof($approved)-1) $sql .= "OR ";
}
$sql .= ") ";
}
else
{
$sql .= "AND (approved = ".HOL_APPROVAL_NONE." OR approved = ".HOL_APPROVAL_GRANTED.") ";
}
if ($date > 0)
{
$sql .= "AND `date` < {$date}";
}
debug_log($sql); // ###INL###
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
$half_days = mysql_num_rows($result);
$days_holiday = $full_days + ($half_days / 2);
return $days_holiday;
}
| user_countincidents | ( | $ | id | ) |
Counts a users open incidents
| int | $id | The userid of the user to check |
Definition at line 291 of file user.inc.php.
References $count, $dbIncidents, $result, $sql, and E_USER_WARNING.
{
global $dbIncidents;
$count = 0;
$sql = "SELECT COUNT(id) FROM `{$dbIncidents}` WHERE (owner='{$id}' OR towner='{$id}') AND (status!=2)";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
else list($count) = mysql_fetch_row($result);
return ($count);
}
| user_drop_down | ( | $ | name = '', |
| $ | id = 0, |
||
| $ | accepting = TRUE, |
||
| $ | exclude = FALSE, |
||
| $ | attribs = '', |
||
| $ | return = true |
||
| ) |
Returns the HTML for a drop down list of users, with the given name and with the given id selected.
| string | $name,. | Name attribute |
| int | $id,. | User ID to pre-select |
| bool | $accepting,. | when true displays the accepting status. hides it when false |
| int | $exclude,. | User ID not to list |
| string | $attribs,. | Extra attributes for the select control |
Definition at line 498 of file user.inc.php.
References $dbUsers, $id, $result, $return, $show, $sql, and E_USER_WARNING.
Referenced by cfgVarInput(), dashboard_watch_incidents_edit(), and show_edit_site().
{
// INL 1Jul03 Now only shows users with status > 0 (ie current users)
// INL 2Nov04 Optional accepting field, to hide the status 'Not Accepting'
// INL 19Jan05 Option exclude field to exclude a user, or an array of
// users
global $dbUsers;
$sql = "SELECT id, realname, accepting FROM `{$dbUsers}` WHERE status > 0 ORDER BY realname ASC";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
$html .= "<select name='{$name}' id='{$name}' ";
if (!empty($attribs))
{
$html .= " $attribs";
}
$html .= ">\n";
if ($id == 0)
{
$html .= "<option selected='selected' value='0'></option>\n";
}
while ($users = mysql_fetch_object($result))
{
$show = TRUE;
if ($exclude != FALSE)
{
if (is_array($exclude))
{
if (!in_array($users->id, $exclude)) $show = TRUE;
else $show = FALSE;
}
else
{
if ($exclude!=$users->id) $show = TRUE;
else $show = FALSE;
}
}
if ($show == TRUE)
{
$html .= "<option ";
if ($users->id == $id) $html .= "selected='selected' ";
if ($users->accepting == 'No' AND $accepting == TRUE)
{
$html .= " class='expired' ";
}
$html .= "value='{$users->id}'>";
$html .= "{$users->realname}";
if ($users->accepting == 'No' AND $accepting == TRUE)
{
$html .= ", {$GLOBALS['strNotAccepting']}";
}
$html .= "</option>\n";
}
}
$html .= "</select>\n";
if ($return)
{
return $html;
}
else
{
echo $html;
}
}
| user_email | ( | $ | id | ) |
Return a users email address
| id | int. User ID |
Definition at line 166 of file user.inc.php.
References $_SESSION, $dbUsers, $id, and db_read_column().
| user_group_id | ( | $ | userid | ) |
| int | $userid | - userid to find group for |
Definition at line 573 of file user.inc.php.
References $dbUsers, $groupid, $result, $sql, and E_USER_WARNING.
Referenced by check_group_holiday().
| user_holiday | ( | $ | userid, |
| $ | type = 0, |
||
| $ | year, | ||
| $ | month, | ||
| $ | day, | ||
| $ | length = FALSE |
||
| ) |
gets users holiday information for a certain day given an optional type and optional length returns both type and length and approved as an array
| int | $userid,. | The userid of the holiday to retrieve |
| int | $type,. | The holiday type. e.g. sickness |
| int | $year,. | Year. eg. 2008 |
| int | $month,. | Month. eg. 11 = November |
| int | $day,. | Day |
| string | $length,. | 'am', 'pm', 'day' or FALSE to list all |
Definition at line 346 of file user.inc.php.
References $approved, $dbHolidays, $length, $result, $sql, $type, and E_USER_WARNING.
Referenced by draw_calendar().
{
global $dbHolidays;
$sql = "SELECT * FROM `{$dbHolidays}` WHERE `date` = '{$year}-{$month}-{$day}' ";
if ($type !=0 )
{
$sql .= "AND (type='$type' OR type='".HOL_PUBLIC."' OR type='".HOL_FREE."') ";
$sql .= "AND IF(type!=".HOL_PUBLIC.", userid='{$userid}', 1=1) ";
}
else
{
$sql .= " AND userid='{$userid}' ";
}
if ($length != FALSE)
{
$sql .= "AND length='{$length}' ";
}
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
if (mysql_num_rows($result) == 0)
{
return FALSE;
}
else
{
$totallength = 0;
while ($holiday = mysql_fetch_object($result))
{
$type = $holiday->type;
$length = $holiday->length;
$approved = $holiday->approved;
$approvedby = $holiday->approvedby;
// hmm... not sure these next lines are required.
if ($length == 'am' && $totallength == 0) $totallength = 'am';
if ($length == 'pm' && $totallength == 0) $totallength = 'pm';
if ($length == 'am' && $totallength == 'pm') $totallength = 'day';
if ($length == 'pm' && $totallength == 'am') $totallength = 'day';
if ($length == 'day') $totallength = 'day';
}
return array($type, $totallength, $approved, $approvedby);
}
}
| user_holiday_entitlement | ( | $ | userid | ) |
Return the users holiday entitlement
| integer | $userid,. | User ID |
Definition at line 470 of file user.inc.php.
References $userid, and db_read_column().
{
return db_read_column('holiday_entitlement', $GLOBALS['dbUsers'], $userid);
}
| user_holiday_resetdate | ( | $ | userid | ) |
Return the users holiday entitlement reset/rollover date
| integer | $userid,. | User ID |
Definition at line 482 of file user.inc.php.
References $userid, db_read_column(), and mysql2date().
{
return mysql2date(db_read_column('holiday_resetdate', $GLOBALS['dbUsers'], $userid) . ' 17:00:00');
}
| user_id | ( | $ | username, |
| $ | password | ||
| ) |
Returns an integer representing the id of the user identified by his/her username and password
| string | $username,. | A username |
| string | $password,. | An MD5 hashed password |
| int | 0 The user did not exist |
| int | >=1 The userid of the matching user |
Definition at line 55 of file user.inc.php.
References $dbUsers, $result, $sql, $user, $userid, and E_USER_WARNING.
Referenced by Trigger::__construct(), Trigger::getUser_id(), and Trigger::setUser_id().
{
global $dbUsers;
$sql = "SELECT id FROM `{$dbUsers}` ";
$sql .= "WHERE username='$username' AND password='{$password}'";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
if (mysql_num_rows($result) == 0)
{
$userid = 0;
}
else
{
$user = mysql_fetch_object($result);
$userid = $user->id;
}
return $userid;
}
| user_incidents | ( | $ | id | ) |
Counts number of incidents and priorty for a given user
| int | $id | The userid of the user to check |
Definition at line 311 of file user.inc.php.
References $arr, $dbIncidents, $obj, $result, $sql, and E_USER_WARNING.
{
global $dbIncidents;
$sql = "SELECT priority, count(priority) AS num FROM `{$dbIncidents}` ";
$sql .= "WHERE (owner = $id OR towner = $id) AND status != 2 ";
$sql .= "GROUP BY priority";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
$arr = array(PRIORITY_LOW => '0', PRIORITY_MEDIUM => '0', PRIORITY_HIGH => '0', PRIORITY_CRITICAL => '0');
if (mysql_num_rows($result) > 0)
{
while ($obj = mysql_fetch_object($result))
{
$arr[$obj->priority] = $obj->num;
}
}
return $arr;
}
| user_message | ( | $ | id | ) |
Return a users away message
| id | int. User ID |
Definition at line 218 of file user.inc.php.
References $id, and db_read_column().
{
return db_read_column('message', $GLOBALS['dbUsers'], $id);
}
| user_mobile | ( | $ | id | ) |
Return a users mobile phone number
| id | int. User ID |
Definition at line 196 of file user.inc.php.
References $id, and db_read_column().
{
return db_read_column('mobile', $GLOBALS['dbUsers'], $id);
}
| user_online | ( | $ | user | ) |
Returns users online status
| int | $user | The user ID of the user to check |
Definition at line 615 of file user.inc.php.
References $dbUsers, $iconset, $now, $result, $sql, $startofsession, E_USER_WARNING, and mysql2date().
{
global $iconset, $now, $dbUsers, $startofsession;
$sql = "SELECT lastseen FROM `{$dbUsers}` WHERE id={$user}";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
$users = mysql_fetch_object($result);
if (mysql2date($users->lastseen) > $startofsession)
{
return TRUE;
}
else
{
return FALSE;
}
}
| user_online_icon | ( | $ | user | ) |
An icon showing a users online status
| int | $user | The user ID of the user to check |
Definition at line 591 of file user.inc.php.
References $dbUsers, $iconset, $now, $result, $sql, $startofsession, $strOffline, $strOnline, E_USER_WARNING, icon(), and mysql2date().
{
global $iconset, $now, $dbUsers, $strOffline, $strOnline, $startofsession;
$sql = "SELECT lastseen FROM `{$dbUsers}` WHERE id={$user}";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
$users = mysql_fetch_object($result);
if (mysql2date($users->lastseen) > $startofsession)
{
return icon('online', 16, $strOnline);
}
else
{
return icon('offline', 16, $strOffline);
}
}
| user_password | ( | $ | id | ) |
Return a users password
| int | $id | User ID |
Definition at line 82 of file user.inc.php.
References $dbUsers, $id, and db_read_column().
{
global $dbUsers;
return db_read_column('password', $dbUsers, $id);
}
| if (realpath(__FILE__)==realpath($_SERVER['SCRIPT_FILENAME'])) user_permission | ( | $ | userid, |
| $ | permission | ||
| ) |
Returns TRUE or FALSE to indicate whether a given user has a given permission
| int | $userid,. | The userid to check |
| int | $permission | or array. The permission id to check, or an array of id's to check |
Definition at line 24 of file user.inc.php.
References $_SESSION, and $permission.
Referenced by contracts_for_contacts_table(), dashboard_incoming_display(), html_action_links(), list_incidents(), and sit_error_handler().
{
// Default is no access
$accessgranted = FALSE;
if (!is_array($permission))
{
$permission = array($permission);
}
foreach ($permission AS $perm)
{
if (@in_array($perm, $_SESSION['permissions']) == TRUE) $accessgranted = TRUE;
else $accessgranted = FALSE;
// Permission 0 is always TRUE (general acess)
if ($perm == 0) $accessgranted = TRUE;
}
return $accessgranted;
}
| user_phone | ( | $ | id | ) |
Return a users phone number
| id | int. User ID |
Definition at line 185 of file user.inc.php.
References $id, and db_read_column().
{
return db_read_column('phone', $GLOBALS['dbUsers'], $id);
}
| user_realname | ( | $ | id, |
| $ | allowhtml = FALSE |
||
| ) |
Return a users real name
| int | $id,. | A user ID |
| bool | $allowhtml,. | may return HTML if TRUE, only ever returns plain text if FALSE |
Definition at line 97 of file user.inc.php.
References $_SESSION, $CONFIG, $dbEscalationPaths, $dbUsers, $from, $id, $result, $sql, $status, E_USER_WARNING, and elseif.
Referenced by check_group_holiday(), dashboard_tasks(), dashboard_user_incidents(), display_holiday_table(), generate_row(), incident_backup_switchover(), kb_article(), make_incident_billing_array(), new_note_form(), saction_SetUserStatus(), show_notes(), and site_salesperson().
{
global $update_body;
global $incidents;
global $CONFIG;
global $dbUsers, $dbEscalationPaths;
if ($id >= 1)
{
if ($id == $_SESSION['userid'])
{
return $_SESSION['realname'];
}
else
{
$sql = "SELECT realname, status FROM `{$dbUsers}` WHERE id='{$id}' LIMIT 1";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
list($realname, $status) = mysql_fetch_row($result);
if ($allowhtml == FALSE OR $status > 0)
{
return $realname;
}
else
{
return "<span class='deleted'>{$realname}</span>";
}
}
}
elseif (!empty($incidents->email))
{
// TODO this code does not belong here
// The SQL is also looking at all escalation paths not just the relevant
// one.
//an an incident
preg_match('/From:[ A-Za-z@\.]*/', $update_body, $from);
if (!empty($from))
{
$frommail = mb_strtolower(mb_substr(mb_strstr($from[0], '@'), 1));
$customerdomain = mb_strtolower(mb_substr(mb_strstr($incidents->email, '@'), 1));
if ($frommail == $customerdomain) return $GLOBALS['strCustomer'];
$sql = "SELECT name, email_domain FROM `{$dbEscalationPaths}`";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
while ($escpath = mysql_fetch_object($result))
{
if (!empty($escpath->email_domain))
{
if (strstr(strtolower($frommail), strtolower($escpath->email_domain)))
{
return $escpath->name;
}
}
}
}
}
//Got this far not returned anything so
return $CONFIG['application_shortname']; // No from email address
}
| user_signature | ( | $ | id | ) |
Return a users email signature
| id | int. User ID |
Definition at line 207 of file user.inc.php.
References $id, and db_read_column().
{
return db_read_column('signature', $GLOBALS['dbUsers'], $id);
}
| user_status | ( | $ | id | ) |
Return a users current away status
| id | int. User ID |
Definition at line 230 of file user.inc.php.
References $id, and db_read_column().
Referenced by saction_SetUserStatus(), and userstatus_summaryline().
{
return db_read_column('status', $GLOBALS['dbUsers'], $id);
}
| user_status_name | ( | $ | userid | ) |
Returns the status of a user
| int | $userid | ID of the user |
Definition at line 659 of file user.inc.php.
References $status, $userid, and db_read_column().
{
$status = db_read_column('name', $GLOBALS['dbUserStatus'], $userid);
return $GLOBALS[$status];
}
| userstatus_name | ( | $ | id | ) |
Returns a string representation of the user status
| int | $id | The user status to get the string for |
Definition at line 697 of file user.inc.php.
References $id, $status, and db_read_column().
Referenced by dashboard_holidays(), saction_SetUserStatus(), and userstatus_summaryline().
{
$status = db_read_column('name', $GLOBALS['dbUserStatus'], $id);
return $GLOBALS[$status];
}
| userstatus_summaryline | ( | $ | userstatus = '', |
| $ | accepting = '' |
||
| ) |
Return the current users status and accepting incidents statuses for use in the header bar
| int | $userstatus | - User status ID |
| string | $accepting | - Accepting incidents 'Yes' or 'No' |
Definition at line 1001 of file user.inc.php.
References $_SESSION, user_accepting(), user_status(), and userstatus_name().
Referenced by set_user_status().
{
if ($userstatus == '')
{
$userstatus = user_status($_SESSION['userid']);
}
if ($accepting == '')
{
$accepting = user_accepting($_SESSION['userid']);
}
$html = "<span id='userstatus_summaryline'>";
$html .= userstatus_name($userstatus);
if ($accepting != 'Yes')
{
$html .= " | {$GLOBALS['strNotAcceptingIncidents']}";
}
$html .= "</span>";
return $html;
}
| valid_username | ( | $ | username | ) |
Checks is a given username is unique
| string | $username | - username |
Definition at line 837 of file user.inc.php.
References $result, $sql, $username, and cleanvar().
{
$username = cleanvar($username);
$valid = TRUE;
if (!empty($username))
{
$tables = array('dbUsers', 'dbContacts');
foreach ($tables AS $table)
{
$sql = "SELECT username FROM `{$GLOBALS[$table]}` WHERE username='{$username}'";
if ($result = mysql_query($sql) AND mysql_num_rows($result) != 0)
{
$valid = FALSE;
}
}
}
else
{
$valid = FALSE;
}
return $valid;
}