pax_global_header 0000666 0000000 0000000 00000000064 12647727470 0014532 g ustar 00root root 0000000 0000000 52 comment=0cf22e59c0eb366039a8a4039a0e47db8d650656
helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/ 0000775 0000000 0000000 00000000000 12647727470 0020170 5 ustar 00root root 0000000 0000000 helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/README 0000664 0000000 0000000 00000000132 12647727470 0021044 0 ustar 00root root 0000000 0000000 The Helpdesk module is originally develloped by CaseySoftware, LLC and
adapted by M2X BV.
helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/addedit.php 0000664 0000000 0000000 00000055344 12647727470 0022312 0 ustar 00root root 0000000 0000000 loadCalendarJS();
$item_id = (int) w2PgetParam($_GET, 'item_id', 0);
$projects = getAllowedProjectsForJavascript(1);
$allowedProjects=getAllowedProjects(0,1);
$proj_ids=array();
foreach ($allowedProjects as $proj) {
$proj_ids[]=$proj['project_id'];
}
$tasks = getAllowedTasksForJavascript($proj_ids,1);
$ict = w2PgetSysVal( 'HelpDeskCallType' );
$ics = w2PgetSysVal( 'HelpDeskSource' );
$ios = w2PgetSysVal( 'HelpDeskService' );
$iap = w2PgetSysVal( 'HelpDeskApplic' );
$ipr = w2PgetSysVal( 'HelpDeskPriority' );
$isv = w2PgetSysVal( 'HelpDeskSeverity' );
$ist = w2PgetSysVal( 'HelpDeskStatus' );
$isa = w2PgetSysVal( 'HelpDeskAuditTrail' );
$helpdesk = new CHelpDesk();
$helpdesk->load($item_id);
$q = new w2p_Database_Query;
$q->addQuery('*');
$q->addTable('helpdesk_items');
$q->addWhere('item_id = ' .$item_id);
$hditem = $q->loadHash();
// Check permissions for this record
if ($item_id) {
// Already existing item
$canEdit = $perms->checkModule($m, 'edit') && hditemEditable($hditem);
} else {
$canEdit = $perms->checkModule($m, 'add');
}
if (!$canEdit) {
$AppUI->redirect(ACCESS_DENIED);
}
// Use new default 'assigned to' ---KZHAO
if (!@$hditem["item_assigned_to"]) {
if ($HELPDESK_CONFIG['default_assigned_to_current_user']=='-1') {
@$hditem["item_assigned_to"] = 0;
if (!@$hditem["item_status"]) {
@$hditem["item_status"]=0;
}
} elseif ($HELPDESK_CONFIG['default_assigned_to_current_user']=='0') {
@$hditem["item_assigned_to"] = $AppUI->user_id;
if (!@$hditem["item_status"]) {
@$hditem["item_status"]=1;
}
} else {
@$hditem["item_assigned_to"] = $HELPDESK_CONFIG['default_assigned_to_current_user'];
if (!@$hditem["item_status"]) {
@$hditem["item_status"]=1;
}
}
}
if (!@$hditem["item_company_id"] && $HELPDESK_CONFIG['default_company_current_company']) {
@$hditem["item_company_id"] = $AppUI->user_company;
}
$itemtitleprefix = $HELPDESK_CONFIG['new_hd_item_title_prefix'];
// KZHAO : 8-8-2006
// get current user's company id and use it to filter users
$q = new w2p_Database_Query;
$q->addQuery('DISTINCT cn.contact_company,cp.company_name');
$q->addTable('contacts','cn');
$q->addTable('users','u');
$q->addJoin('companies','cp','cn.contact_company=cp.company_id');
$q->addWhere('u.user_id=' . $AppUI->user_id . ' AND u.user_contact=cn.contact_id ');
$allowedComp = $q->loadHashList();
if (!count($allowedComp)) {
echo "ERROR: No company found for current user!!
";
$compId=0;
} elseif (count($allowedComp)==1) {
$tmp=array_keys($allowedComp);
$compId=$tmp[0];
if ($HELPDESK_CONFIG['default_company_current_company']) {
$allowedCompanies = arrayMerge( $allowedComp, array( 0 => '' ));
} else {
$allowedCompanies = arrayMerge( array( 0 => '' ), $allowedComp );
}
$allowedCompanies = arrayMerge( $allowedCompanies, getAllowedCompanies() );
} else {
echo "ERROR: Multiple companies found for current user!!!
";
$compId=0;
}
// Determine whether current user is a client
if ($compId!=$HELPDESK_CONFIG['the_company']) {
$client_disable=' disabled ';
} else {
$client_disable=' ';
}
// setup contact list for javascript
$q = new w2p_Database_Query;
$q->addQuery('c.contact_id,u.user_id, contact_email, contact_phone,
CONCAT_WS(\' \',c.contact_first_name, c.contact_last_name) as full_name');
$q->addTable('contacts','c');
$q->addJoin('users','u','c.contact_id=u.user_contact');
$list = $q->loadList();
foreach ($list as $row) {
$contacts[] = "[{$row['contact_id']},{$row['user_id']},'" . addslashes($row['full_name']) . "', '" . addslashes($row['contact_email']) . "','" . addslashes($row['contact_phone']) . "']";
}
$users = getAllowedUsers($compId,1);
//Use new watcher list --KZHAO
if ($item_id) {
// if editing an existing helpdesk item, get its watchers from database
$q = new w2p_Database_Query;
$q->addQuery('helpdesk_item_watchers.user_id, contact_email,
CONCAT(contact_first_name, \' \',contact_last_name) as name');
$q->addTable('helpdesk_item_watchers');
$q->addJoin('users','','helpdesk_item_watchers.user_id = users.user_id');
$q->addJoin('contacts','c','user_contact = contact_id');
$q->addWhere('item_id = ' . $item_id );
$q->addOrder('contact_last_name, contact_first_name');
$watchers = $q->loadHashList();
} else { // for a new item, check default
$q = new w2p_Database_Query;
$q->addQuery('max(item_id)');
$q->addTable('helpdesk_items');
$new_item_id = $q->loadResult()+1;
if ($HELPDESK_CONFIG['default_watcher'] && $HELPDESK_CONFIG['default_watcher_list']) {
$watchers = explode(',',$HELPDESK_CONFIG['default_watcher_list']);
}
}
// Setup the title block
$ttl = $item_id ? 'Editing Help Desk Item' : 'Adding Help Desk Item';
$titleBlock = new w2p_Theme_TitleBlock( $ttl, 'helpdesk.png', $m, "$m.$a" );
$titleBlock->addCrumb( "?m=helpdesk", 'home' );
$titleBlock->addCrumb( "?m=helpdesk&a=list", 'list');
if ($item_id) {
$titleBlock->addCrumb( "?m=helpdesk&a=view&item_id=$item_id", 'view this item' );
}
$titleBlock->show();
if ($item_id) {
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$item_date = new w2p_Utilities_Date( $hditem["item_created"] );
$deadline_date = intval($hditem["item_deadline"]) ?
new w2p_Utilities_Date($hditem["item_deadline"]) : new w2p_Utilities_Date();
$tc = $item_date->format( "$df $tf" );
} else {
$item_date = new w2p_Utilities_Date();
$deadline_date = new w2p_Utilities_Date();
$item_date = $item_date->format( FMT_DATETIME_MYSQL );
$hditem["item_created"] = $item_date;
}
?>
helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/changelog 0000664 0000000 0000000 00000002273 12647727470 0022046 0 ustar 00root root 0000000 0000000 2009-07-16 - Field "Hours worked" added to helpdesk item edit form. Can be used to log spent time when creating new item
2009-07-20 - permissions related updates
2009-07-22 - notification system redesigned to be more flexible and to minimize emails sent:
- only one email is sent when tasklog modified status/calltype/etc.
- unified email format for tasklogs and ticket modifications emails
- if ticket is created and remain Unassigned email is sent
to an address defined in helpdesk configuration in case of email notification required
- added configuration radioboxes to choose whether watchers / requestor
are notified about all logs or only about status changes (incl. requestor change & calltype change)
- emails are not sent to current user
- if ticket is created by an user from non-helpdesk company, the user is filled-in as requestor
- localization applied on notification texts ( I hope everywhere )
2009-07-24 - when adding watchers notifications were not send always correctly. Unified with another notification emails.
helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/configure.php 0000664 0000000 0000000 00000027660 12647727470 0022675 0 ustar 00root root 0000000 0000000 redirect(ACCESS_DENIED);
}
@include_once( "./functions/admin_func.php" );
$HELPDESK_CONFIG = array();
$HELPDESK_CONFIG = loadConfig();
// get a list of permitted companies
$company = new CCompany();
$companies = $company->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name');
$companies = arrayMerge(array('0' => ''), $companies);
// Get all active users -- KZHAO
$activeUsers=getAllowedUsers(0,1);
$assignUsers=arrayMerge( array(-1=>'', 0 => 'Current User' ), $activeUsers);
$utypes = w2PgetSysVal('UserType');
//define user type list
$user_types = arrayMerge( $utypes, array( '-1' => $AppUI->_('None') ) );
/* All config options, their descriptions and their default values are defined
* here. Add new config options here. Type can be "checkbox", "text", "radio" or
* "select". If the type is "radio," it must include a set of buttons. If it's
* "select" then be sure to include a 'list' entry with the options. if the key
* starts with headingXXX then it will just display the contents on the value.
* This is used for grouping.
*/
$config_options = array(
"heading1" => $AppUI->_('Paging Options'),
"items_per_page" => array(
"description" => $AppUI->_('Helpdesk Items Per Page'),
"value" => 30,
'type' => 'text'
),
"status_log_items_per_page" => array(
"description" => $AppUI->_('Helpdesk Logs Per Page'),
"value" => 15,
'type' => 'text'
),
"pages_per_side" => array(
"description" => $AppUI->_('Helpdesk Pages Per Side'),
"value" => 5,
'type' => 'text'
),
"heading2" => $AppUI->_('Permission Options'),
"the_company" => array(
"description" => $AppUI->_('Helpdesk Host Company'),
"value" => '',
'type' => 'select',
'list' => $companies
),
"no_company_editable" => array(
"description" => $AppUI->_('Allow Helpdesk Items without Company'),
"value" => '0',
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
'minimum_edit_level' => array(
'description' => $AppUI->_('Helpdesk Min Level'),
'value' => 9,
'type' => 'select',
'list' => @$user_types
),
"use_project_perms" => array(
"description" => $AppUI->_('Helpdesk Use Project Perms'),
"value" => '0',
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
'minimum_report_level' => array(
'description' => $AppUI->_('Helpdesk Min Rep Level'),
'value' => 9,
'type' => 'select',
'list' => @$user_types
),
// KZHAO: 2-6-2007
// Change/add default settings
"heading3" => $AppUI->_('New Item Default Selections'),
// MiraKlim 18.05.2009 -added format for new HD item name
"new_hd_item_title_prefix" => array(
"description" => $AppUI->_('Default item title prefix'),
"value" => 'HD-%05d',
'type' => 'text'
),
"default_assigned_to_current_user" => array(
"description" => $AppUI->_('Default Assigned To'),
"value" => '',
'type' => 'select',
'list' => $assignUsers
),
"default_company_current_company" => array(
"description" => $AppUI->_('Default Company'),
"value" => 1,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Current User\'s Company'),
0 => $AppUI->_('None'))
),
"default_watcher" => array(
"description" => $AppUI->_('Use Default Watcher(s)'),
"value" => 0,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
"default_watcher_list" => array(
"description" => $AppUI->_('Default Watchers'),
"value" => 0,
'type' => 'multiselect',
'list' => $activeUsers
),
"heading4" => $AppUI->_('Search Fields On Item List'),
"search_criteria_search" => array(
"description" => $AppUI->_('Title/Summary Search'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_call_type" => array(
"description" => $AppUI->_('Call Type'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_company" => array(
"description" => $AppUI->_('Company'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_status" => array(
"description" => $AppUI->_('Status'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_call_source" => array(
"description" => $AppUI->_('Call Source'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_project" => array(
"description" => $AppUI->_('Project'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_assigned_to" => array(
"description" => $AppUI->_('Assigned To'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_priority" => array(
"description" => $AppUI->_('Priority'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_application" => array(
"description" => $AppUI->_('Application'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_requestor" => array(
"description" => $AppUI->_('Requestor'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_severity" => array(
"description" => $AppUI->_('Severity'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_service" => array(
"description" => $AppUI->_('Service'),
"value" => 1,
'type' => 'checkbox'
),
//KZHAO 9-12-2006
// Configurable fields for email notification
"heading5" => $AppUI->_('Notification Email Options'),
"default_notify_by_email" => array(
"description" => $AppUI->_('Email notification as default for new item'),
"value" => 1,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
"task_watchers_notification" => array(
"description" => $AppUI->_('Watchers notification'),
"value" => 1,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Always'),
0 => $AppUI->_('Status change'))
),
"task_requestor_notification" => array(
"description" => $AppUI->_('Requestor notification'),
"value" => 1,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Always'),
0 => $AppUI->_('Status change'))
),
"notify_email_address" => array(
"description" => $AppUI->_('New unassigned items notification address'),
"value" => 'support@yourcompany.com',
'type' => 'text'
),
"email_subject" => array(
"description" => $AppUI->_('Email subject (trailed by ticket number)'),
"value" => 'The Company registered your recent request',
'type' => 'text'
),
"email_header" => array(
"description" => $AppUI->_('Email header'),
"value" => 'The Company Ticket Management Registry',
'type' => 'text'
)
);
//if this is a submitted page, overwrite the config file.
if(w2PgetParam( $_POST, "Save", '' )!=''){
$q = new w2p_Database_Query();
if (!$q) {
$AppUI->setMsg($AppUI->_('Configuration table not accessible.'), UI_MSG_ERROR );
} else {
foreach ($config_options as $key=>$value){
if(substr($key,0,7)=='heading') continue;
$val="";
switch($value['type']){
case 'checkbox':
$val = isset($_POST[$key])?"1":"0";
break;
case 'text':
$val = isset($_POST[$key])?$_POST[$key]:"";
break;
case 'select':
$val = isset($_POST[$key])?$_POST[$key]:"0";
break;
case 'multiselect':
if(isset($_POST[$key])){
foreach ($_POST[$key] as $idx=>$watcher){
$val .= $watcher.",";
}
$val=trim($val,',');
}
else $val=0;
break;
case 'radio':
$val = $_POST[$key];
break;
default:
break;
}
$q->addTable('helpdesk_config');
$q->addUpdate('config', $key);
$q->addUpdate('value', $val);
$q->addWhere('config = "' . $key . '"');
if (!$q->exec()) {
$AppUI->setMsg(db_error(), UI_MSG_ERROR);
}
$q->clear();
}
$AppUI->setMsg( $AppUI->_('Configuration has been successfully updated'), UI_MSG_OK );
}
} else if(w2PgetParam( $_POST, $AppUI->_('cancel'), '' )!=''){
$AppUI->redirect("m=system&a=viewmods");
}
//Read the current config values from the config table and update the array.
$HELPDESK_CONFIG = loadConfig();
foreach ($config_options as $key=>$value){
if(isset($HELPDESK_CONFIG[$key])){
$config_options[$key]['value']=$HELPDESK_CONFIG[$key];
}
}
// setup the title block
$titleBlock = new w2p_Theme_TitleBlock( 'Configure Help Desk Module', 'helpdesk.png', $m, "$m.$a" );
$titleBlock->addCrumb( "?m=system", "System Admin" );
$titleBlock->addCrumb( "?m=system&a=viewmods", "Modules" );
$titleBlock->show();
?>
helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/do_contact_lookup.php 0000664 0000000 0000000 00000000533 12647727470 0024410 0 ustar 00root root 0000000 0000000 lookup_contact($contact_id);
die();
helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/do_dellog.php 0000664 0000000 0000000 00000001720 12647727470 0022631 0 ustar 00root root 0000000 0000000 acl();
if ($del) {
if (!$perms->checkModule('task_log', 'delete')) {
$AppUI->redirect(ACCESS_DENIED);
}
} elseif ($isNotNew) {
if (!$perms->checkModule('task_log', 'edit')) {
$AppUI->redirect(ACCESS_DENIED);
}
} else {
if (!$perms->checkModule('task_log', 'add')) {
$AppUI->redirect(ACCESS_DENIED);
}
}
$obj = new CTask_Log();
if (!$obj->bind($_POST)) {
$AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
$AppUI->redirect();
}
$redir='m=helpdesk&a=view&tab=0&item_id=' . $obj->task_log_help_desk_id;
$AppUI->setMsg('Task Log');
if ($del) {
if (($msg = $obj->delete())) {
$AppUI->setMsg($msg, UI_MSG_ERROR);
} else {
$AppUI->setMsg('deleted', UI_MSG_ALERT);
}
}
$AppUI->redirect($redir);
helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/do_item_aed.php 0000664 0000000 0000000 00000024346 12647727470 0023143 0 ustar 00root root 0000000 0000000 0);
$updated_date = new w2p_Utilities_Date();
$update = $updated_date->format( FMT_DATETIME_MYSQL );
$notify_all = isset($_POST['item_notify']) ? w2PgetParam( $_POST,'item_notify',0) : $HELPDESK_CONFIG['default_notify_by_email'];
if ($do_task_log) { // called from HD task log
//first update the status on to current helpdesk item.
$hditem = new CHelpDesk();
$hditem->load( $item_id );
$hditem->item_updated = $update;
$new_status = w2PgetParam( $_POST, 'item_status', 0 );
$new_calltype = w2PgetParam( $_POST, 'item_calltype', 0 );
$new_assignee = w2PgetParam( $_POST, 'item_assigned_to', 0 );
$users = getAllowedUsers();
$log_status_msg='';
$update_item = false;
if ($new_status!=$hditem->item_status) {
$status_msg = $hditem->log_status(11,$AppUI->_($ist[$hditem->item_status]),$AppUI->_($ist[$new_status]));
$log_status_msg .= $status_msg . "\n";
$hditem->item_status = $new_status;
$update_item = true;
}
if ($new_calltype!=$hditem->item_calltype) {
$status_msg = $hditem->log_status(9,$AppUI->_($ict[$hditem->item_calltype]),$AppUI->_($ict[$new_calltype]));
$log_status_msg .= $status_msg . "\n";
$hditem->item_calltype = $new_calltype;
$update_item = true;
}
if ($new_assignee!=$hditem->item_assigned_to) {
$status_msg = $hditem->log_status(5,$AppUI->_($users[$hditem->item_assigned_to]),$AppUI->_($users[$new_assignee]));
$log_status_msg .= $status_msg . "\n";
$hditem->item_assigned_to = $new_assignee;
$update_item = true;
}
if ($update_item) {
if (!$hditem->store()) {
$AppUI->setMsg( $hditem->getError(), UI_MSG_ERROR );
$AppUI->redirect('m=helpdesk&a=view&item_id=' . $hditem->item_id);
}
}
//then create/update the task log
$obj = new CTask_Log();
if (!$obj->bind( $_POST )) {
$AppUI->setMsg( $obj->getError(), UI_MSG_ERROR );
$AppUI->redirect('m=helpdesk&a=view&item_id=' . $hditem->item_id);
}
if ($obj->task_log_date) {
$date = new w2p_Utilities_Date($obj->task_log_date . date('Hi'));
$obj->task_log_date = $date->format( FMT_DATETIME_MYSQL );
}
$AppUI->setMsg('Task Log');
$obj->task_log_costcode = $obj->task_log_costcode;
if (!$obj->store()) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
$AppUI->redirect('m=helpdesk&a=view&item_id=' . $hditem->item_id);
} else {
$body = $AppUI->_('Summary') . " : " . $obj->task_log_name . "\n";
$body .= $AppUI->_('Description') . " : \n" . $obj->task_log_description . "\n";
if ($log_status_msg) {
$body .= "\n" . $AppUI->_('Updates') . " : \n" . $log_status_msg;
$hditem->notifymsg(STATUSTASK_LOG, $body);
} else {
$hditem->notifymsg(TASK_LOG, $body);
}
if ($AppUI->msgNo != UI_MSG_ERROR) {
$AppUI->setMsg( @$_POST['task_log_id'] ? 'updated' : 'added', UI_MSG_OK, true );
}
}
$AppUI->redirect("m=helpdesk&a=view&item_id=$item_id&tab=0");
} else { // for creating or editting Helpdesk items
$hditem = new CHelpDesk();
if ( !$hditem->bind( $_POST )) {
$AppUI->setMsg( $hditem->error, UI_MSG_ERROR );
$AppUI->redirect('m=helpdesk&a=view&item_id=' . $hditem->item_id);
}
$AppUI->setMsg( 'Help Desk Item', UI_MSG_OK );
if ($del) {// to delete an item
$hditem->load( $item_id );
$hditem->item_updated = $udate;
if (!$hditem->store()) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
$AppUI->redirect();
}
if ($hditem->delete()) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
} else {
$AppUI->setMsg( 'deleted', UI_MSG_OK, true );
$hditem->log_status(18,'Item '.$AppUI->_('Deleted'),1);
$AppUI->redirect('m=helpdesk&a=list');
}
} else { // edit or new
if ($new_item) {
$item_date = new w2p_Utilities_Date();
$idate = $item_date->format( FMT_DATETIME_MYSQL );
$hditem->item_created = $idate;
$hditem->item_updated = $udate;
$hditem->item_notify = $notify_all;
} else {
$hditem->item_notify = $notify_all;
$hditem->item_updated = $udate;
$status_log_msg = $hditem->log_status_changes();
}
//KZHAO 8-10-2006
// get the deadline for the HD item
$dl = ((int) $deadline) ? new w2p_Utilities_Date($deadline) : new w2p_Utilities_Date();
$dl->setTime(23,59,59);
$hditem->item_deadline = $dl->format( FMT_DATETIME_MYSQL );
// Kang: 3-15-2007
// file uploading
if (isset( $_FILES['hdfile']) && isset($_FILES['hdfile']['name']) && $_FILES['hdfile']['name']!='') {
$file_obj = new CFile();
$file_info=array();
$acl =& $AppUI->acl();
if ( ! $acl->checkModule('files', 'add')) {
$AppUI->setMsg($AppUI->_( "noDeletePermission" ));
$AppUI->redirect(ACCESS_DENIED);
}
$file_obj->_message = 'added';
$file_info['file_version'] = 1.0;
$file_info['file_category'] = 0;
$file_info['file_parent'] = 0;
$file_info['file_project'] = $hditem->item_project_id;
if (!$new_item) {
$file_info['file_description'] = $AppUI->_('This file is associated with helpdesk item') . ' ' .$hditem->item_id . ' ('. $hditem->item_title . ')';
$file_info['file_helpdesk_item'] = $hditem->item_id;
}
$file_info['file_owner']=$AppUI->user_id;
if (!$file_obj->bind( $file_info )) {
$AppUI->setMsg( $file_obj->getError(), UI_MSG_ERROR );
$AppUI->redirect();
}
$upload=null;
$upload = $_FILES['hdfile'];
if ($upload['size'] < 1) {
if (!$file_id) {
$AppUI->setMsg( 'Upload file size is zero. Process aborted.', UI_MSG_ERROR );
$AppUI->redirect('m=helpdesk&a=view&item_id='.$hditem->item_id);
}
} else {
// store file with a unique name
$file_obj->file_name = $upload['name'];
$file_obj->file_type = $upload['type'];
$file_obj->file_size = $upload['size'];
$file_obj->file_date = str_replace("'", '', $db->DBTimeStamp(time()));
$file_obj->file_real_filename = uniqid( rand() );
$res = $file_obj->moveTemp( $upload );
if (!$res) {
$AppUI->setMsg( 'File could not be written', UI_MSG_ERROR );
$AppUI->redirect();
}
}
if (! $file_obj->file_version_id) {
$q = new w2p_Database_Query;
$q->addTable('files');
$q->addQuery('file_version_id');
$q->addOrder('file_version_id DESC');
$q->setLimit(1);
$sql = $q->prepare();
$latest_file_version = $q->loadResult($sql);
$file_obj->file_version_id = $latest_file_version + 1;
}
if (($msg = $file_obj->store()) !== true) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
}
// add the link of the file to the description of the helpdesk item
$hd_file_info="\n------------------\n" . $AppUI->_('Associated File Name:'). ' '.$file_obj->file_name;
$hd_file_info.=" Link: ".$w2Pconfig['base_url']."/fileviewer.php?file_id=".$file_obj->file_id;
$hd_file_info.="\n------------------\n";
$hditem->item_summary=$hditem->item_summary . $hd_file_info;
}// end of file uploading
if (!$hditem->store()) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
} else {
if ($new_item) {
// new item creation
$status_log_msg = $hditem->log_status(0,$AppUI->_('Ticket').' '.$AppUI->_('Created'),'',1);
//Lets create a log for the item creation:
$obj = new CHelpDesk();
$new_item_log = array('task_log_id' => 0,'task_log_help_desk_id' => $hditem->item_id, 'task_log_creator' => $AppUI->user_id, 'task_log_name' => 'Item Created: '.$_POST['item_title'], 'task_log_date' => $hditem->item_created, 'task_log_description' => $_POST['item_title'], 'task_log_hours' => $_POST['task_log_hours'], 'task_log_costcode' => $_POST['task_log_costcode']);
if (!$obj->bind( $new_item_log )) {
$AppUI->setMsg( $obj->getError(), UI_MSG_ERROR );
$AppUI->redirect();
}
if (($msg = $obj->store()) !== true) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
$AppUI->redirect();
}
// Generate the description for attached file
if ($file_obj) {
$file_obj->file_description = $AppUI->_('This file is associated with helpdesk item') . ' ' .$hditem->item_id . ' ('. $hditem->item_title . ')';
$file_obj->file_helpdesk_item=$hditem->item_id;
if (($msg = $file_obj->store()) !== true) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
}
}
}
// KZHAO 8-7-2006
doWatchers(w2PgetParam( $_POST, 'watchers', 0 ), $hditem, $notify_all);
// KZHAO 8-7-2006
if ($AppUI->msgNo != UI_MSG_ERROR) {
$AppUI->setMsg( $new_item ? ($AppUI->_('Help Desk Item') .' '. $AppUI->_('added')) : ($AppUI->_('Help Desk Item') . ' ' . $AppUI->_('updated')) , UI_MSG_OK, false );
}
$AppUI->redirect('m=helpdesk&a=view&item_id='.$hditem->item_id);
}
}
} helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/export.php 0000664 0000000 0000000 00000010262 12647727470 0022223 0 ustar 00root root 0000000 0000000 addQuery('*');
$q->addTable('helpdesk_items');
$q->addWhere('item_id = ' . $item_id);
$hditem = $q->loadHash();
// Check permissions for this record
if ($item_id) {
// Already existing item
$canEdit = $perms->checkModule($m, 'edit') && hditemEditable($hditem);
} else {
echo "Cannot find the item id!";
return;
}
if (!$canEdit) {
$AppUI->redirect(ACCESS_DENIED);
}
//KZHAO 10-24-2006
//Load helpdesk item
$org_hditem = new CHelpDesk();
$org_hditem->load( $item_id );
//Check required information before export
if (!@$hditem["item_project_id"]) {
$AppUI->setMsg( "Project must be specified for this item before exporting to task!" , UI_MSG_ERROR );
$AppUI->redirect("m=helpdesk&a=view&item_id=$item_id");
}
//KZHAO 7-10-2007
// Item with associated task cannot be exported
if (@$hditem["item_task_id"]) {
$AppUI->setMsg( "Item with associated task cannot be exported to another task!" , UI_MSG_ERROR );
$AppUI->redirect("m=helpdesk&a=view&item_id=$item_id");
}
//KZHAO 10-24-2006
// Check status
if ($ist[@$hditem["item_status"]]=="Closed") {
$AppUI->setMsg( "Closed helpdesk items cannot be exported to tasks!" , UI_MSG_ERROR );
$AppUI->redirect("m=helpdesk&a=view&item_id=$item_id");
}
if (!@$hditem["item_assigned_to"] && $HELPDESK_CONFIG['default_assigned_to_current_user']) {
@$hditem["item_assigned_to"] = $AppUI->user_id;
@$hditem["item_status"] = 1;
}
if (!@$hditem["item_company_id"] && $HELPDESK_CONFIG['default_company_current_company']) {
@$hditem["item_company_id"] = $AppUI->user_company;
}
// Setup the title block
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$item_date = new w2p_Utilities_Date( $hditem["item_created"] );
$deadline_date = new w2p_Utilities_Date( $hditem["item_deadline"] );
$tc = $item_date->format( "$df $tf" );
$dateNow = new w2p_Utilities_Date();
$dateNowSQL = $dateNow->format( FMT_DATETIME_MYSQL );
$newTask = new CTask();
$ref_task ="This task was created from Helpdesk item #".$item_id.".\n";
$ref_task.= "-----------------------\n";
if (@$hditem["item_priority"]==0 || @$hditem["item_priority"]==2) {
$taskPrio=0;
} elseif (@$hditem["item_priority"]==1) {
$taskPrio=-1;
} else {
$taskPrio=1;
}
$hditem["item_deadline"] = (isset($hditem["item_deadline"])) ? $hditem["item_deadline"] : $dateNowSQL;
$taskInfo= array( "task_id"=>0,
"task_name"=> @$hditem["item_title"],
"task_project"=> @$hditem["item_project_id"],
"task_start_date"=> $dateNowSQL,
"task_end_date"=>@$hditem["item_deadline"],
"task_priority"=>$taskPrio,
"task_owner"=> $AppUI->user_id,
"task_creator"=>$AppUI->user_id,
"task_description"=> $ref_task.@$hditem["item_summary"],
"task_contacts" => @$hditem["item_requestor_id"],
"task_related_url"=> $w2Pconfig['base_url']."/index.php?m=helpdesk&a=view&item_id=".$item_id
);
echo "
";
$result= $newTask->bind( $taskInfo);
if (!$result) {
$AppUI->setMsg( $newTask->getError(), UI_MSG_ERROR );
$AppUI->redirect();
}
$result = $newTask->store();
if (is_array($result)) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
$AppUI->redirect(); // Store failed don't continue?
} else {
$ref_hd ="This helpdesk item has been exported to task #".$newTask->task_id.".\n";
$ref_hd.="Link: ".$w2Pconfig['base_url']."/index.php?m=tasks&a=view&task_id=".$newTask->task_id."\n";
$ref_hd.="---------------------------\n";
$org_hditem->item_status=2;
$org_hditem->item_updated=$dateNowSQL;
$org_hditem->item_summary=$ref_hd.$org_hditem->item_summary;
$result = $org_hditem->store();
if (is_array($result)) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
$AppUI->redirect();
}
$newTask->updateAssigned($hditem["item_assigned_to"], array($hditem["item_assigned_to"] => 100));
$AppUI->setMsg( 'Task added!', UI_MSG_OK);
$AppUI->redirect("m=helpdesk&a=view&item_id=$item_id&tab=0");
}
helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/hd_upgrade.sql 0000664 0000000 0000000 00000000520 12647727470 0023010 0 ustar 00root root 0000000 0000000 -- Upgrade script for helpdesk module
-- Use this script only if you have already installed helpdesk module into dotproject.
-- Kang 12/19/2006
-- The LinuxBox Corp. www.linuxbox.com
-- Ann Arbor, MI
ALTER TABLE helpdesk_items ADD item_updated datetime DEFAULT NULL;
ALTER TABLE helpdesk_items ADD item_deadline datetime DEFAULT NULL;
helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/helpdesk.class.php 0000664 0000000 0000000 00000045523 12647727470 0023615 0 ustar 00root root 0000000 0000000 Created
1=>"item_title", //Title
2=>"item_requestor", //Requestor Name
3=>"item_requestor_email", //Requestor E-mail
4=>"item_requestor_phone", //Requestor Phone
5=>"item_assigned_to", //Assigned To
6=>"item_notify", //Notify by e-mail
7=>"item_company_id", //Company
8=>"item_project_id", //Project
9=>"item_calltype", //Call Type
10=>"item_source", //Call Source
11=>"item_status", //Status
12=>"item_priority", //Priority
13=>"item_severity", //Severity
14=>"item_service", //Service - operating System, ...
15=>"item_application", //Application
16=>"item_summary", //Summary
17=>"item_deadline" //Deadline
// 18=>Deleted
);
// Help Desk class
class CHelpDesk extends w2p_Core_BaseObject
{
public $item_id = NULL;
public $item_title = NULL;
public $item_summary = NULL;
public $item_calltype = NULL;
public $item_source = NULL;
public $item_service = NULL;
public $item_application = NULL;
public $item_priority = NULL;
public $item_severity = NULL;
public $item_status = NULL;
public $item_project_id = NULL;
public $item_company_id = NULL;
public $item_assigned_to = NULL;
public $item_notify = 0;
public $item_requestor = NULL;
public $item_requestor_id = NULL;
public $item_requestor_email = NULL;
public $item_requestor_phone = NULL;
public $item_requestor_type = NULL;
public $item_created_by = NULL;
public $item_created = NULL;
public $item_modified = NULL;
//public $item_updated = NULL;
public $item_deadline =NULL;
public function __construct()
{
parent::__construct('helpdesk_items', 'item_id','helpdesk');
}
public function check()
{
$errorArray = array();
$baseErrorMsg = get_class($this) . '::store-check failed - ';
return $errorArray;
}
public function store()
{
$stored = false;
$errorMsgArray = $this->check();
if (count($errorMsgArray) > 0) {
return $errorMsgArray;
}
$this->item_summary = strip_tags($this->item_summary);
//if type indicates a contact or a user, then look up that phone and email
//for those entries
switch ($this->item_requestor_type) {
case '0'://it's not a user or a contact
break;
case '1'://it's a system user
$q = $this->_getQuery();
$q->addTable('users','u');
$q->addQuery('u.user_id as id');
$q->addQuery("CONCAT(c.contact_first_name,' ', c.contact_last_name) as name");
$q->addQuery("contact_email as email, contact_phone as phone");
$q->addJoin('contacts','c','u.user_contact = c.contact_id');
$q->addWhere('u.user_id='.$this->item_requestor_id);
break;
case '2': //it's only a contact
$q = $this->_getQuery();
$q->addTable('contacts','c');
$q->addQuery("CONCAT(c.contact_first_name,' ', c.contact_last_name) as name");
$q->addQuery("contact_email as email, contact_phone as phone");
$q->addWhere('contact_id='.$this->item_requestor_id);
break;
default:
break;
}
// get requestor's information
if (isset($q)) {
$result = $q->loadHash();
$q->clear();
$this->item_requestor_email = $result['email'];
$this->item_requestor_phone = $result['phone'];
$this->item_requestor = $result['name'];
}
/*
* TODO: I don't like the duplication on each of these two branches, but I
* don't have a good idea on how to fix it at the moment...
*
* TODO: Each of these branches should have a permissions check
* included. Review one fo the core core classes - like CLink - for
* the standard structure.
*/
$stored = false;
$q = $this->_getQuery();
$this->item_modified = $q->dbfnNowWithTZ();
if ($this->item_id) {
if (($msg = parent::store())) {
return $msg;
}
$stored = true;
}
if (0 == $this->item_id) {
$this->item_created = $q->dbfnNowWithTZ();
if (($msg = parent::store())) {
return $msg;
}
$stored = true;
}
return $stored;
}
public function lookup_contact($contact_id)
{
$contact = new CContact();
$contact->load($contact_id);
return $contact->contact_first_name.' '.$contact->contact_last_name.'||'.$contact->contact_phone.'||'.$contact->contact_email.'||';
}
public function delete()
{
// This section will grant every request to delete an HDitem
$k = $this->_tbl_key;
if ($oid) {
$this->$k = intval( $oid );
}
//load the item first so we can get the item_title for history
$this->load($this->item_id);
addHistory($this->_tbl, $this->$k, 'delete', $this->item_title, $this->item_project_id);
$result = null;
$q = $this->_getQuery();
$q->setDelete($this->_tbl);
$q->addWhere("$this->_tbl_key = '".$this->$k."'");
if (!$q->exec()) {
$result = db_error();
}
$q->clear();
$q->setDelete('helpdesk_item_status');
$q->addWhere("status_item_id = '".$this->item_id."'");
if (!$q->exec()) {
$result .= db_error();
}
$q->clear();
$q->setDelete('helpdesk_item_watchers');
$q->addWhere("item_id = '".$this->item_id."'");
if (!$q->exec()) {
$result .= db_error();
}
$q->clear();
$q->setDelete('task_log');
$q->addWhere("task_log_help_desk_id = '".$this->item_id."'");
if (!$q->exec()) {
$result .= db_error();
}
$q->clear();
return $result;
}
////////////////////////////////////////////////////////////////////////////////
// MiraKlim - for compatibility with unmodified files.class.php
public function notify($type, $log_id, $newhdi=0)
{
$this->notifymsg($type, 'Notify called');
}
public function notifymsg($type, $log_msg, $email_list=null)
{
global $w2Pconfig, $HELPDESK_CONFIG;
if (!isset($email_list)) {
$email_list = array();
if (($type!=TASK_LOG) || $HELPDESK_CONFIG['task_watchers_notification'] ) {
// Pull up the email address of everyone on the watch list
// this list does not include the assignee
$q = $this->_getQuery();
$q->addTable('helpdesk_item_watchers','hdw');
$q->addQuery('contact_email');
$q->addJoin('users','u','hdw.user_id = u.user_id');
$q->addJoin('contacts','c','u.user_contact = c.contact_id');
$q->addWhere("hdw.item_id='".$this->item_id."'");
$log_user_email = $q->loadHashList();
$log_user_email = array_keys($log_user_email);
foreach ($log_user_email as $user_email) {
if (trim($user_email)) {
$email_list[] = $user_email;
}
}
$q->clear();
}
if (($type!=TASK_LOG) || $HELPDESK_CONFIG['task_requestor_notification']) {
//add the requestor email to the list of mailing people
$email_list[] = $this->item_requestor_email;
//add the assigned user email to the list of mailing people
if (isset($this->item_assigned_to)) {
$assigned_user_email = array();
$q = $this->_getQuery();
$q->addTable('users','u');
$q->addQuery('contact_email');
$q->addJoin('contacts','c','u.user_contact = c.contact_id');
$q->addWhere('u.user_id='.$this->item_assigned_to);
$log_user_email = $q->loadHashList();
$log_user_email = array_keys($log_user_email);
foreach ($log_user_email as $user_email) {
if (trim($user_email) ) {
$email_list[] = $user_email;
}
}
$q->clear();
}
}
}
// Use subject and header from config.php
$subject = $HELPDESK_CONFIG['email_subject']."---".$this->_AppUI->_('Item')."#{$this->item_id} ";
$body .= $HELPDESK_CONFIG{'email_header'} . "\n";
$body .= $this->_AppUI->_('Item') . " : " . $this->item_id . "\n";
$body .= $this->_AppUI->_('Subject') . " : " . $this->item_title."\n";
$body .= $this->_AppUI->_('Requestor') . " : " . $this->item_requestor . "\n";
$body .= $this->_AppUI->_('Link') . " : " . $w2Pconfig['base_url']."/index.php?m=helpdesk&a=view&item_id=" . $this->item_id. "\n";
switch ($type) {
case STATUS_LOG:
case NEW_ITEM_LOG:
if ($type==NEW_ITEM_LOG) {
$subject .= $this->_AppUI->_('Created');
if (!isset($this->item_status) || ($ist[$this->item_status]=='Unassigned') ) {
$email_list[] = $HELPDESK_CONFIG['notify_email_address'];
}
} else {
$subject .= $this->_AppUI->_('Updated');
}
$body .= $this->_AppUI->_('Call Type') . " : " . $ict[$this->item_calltype]."\n";
$body .= $this->_AppUI->_('Status') . " : " . $ist[$this->item_status]."\n";
$body .= $this->_AppUI->_('Summary') . " : \n" . $this->item_summary."\n";
$body .= $this->_AppUI->_('Updates') . " : \n" . $log_msg . "\n";
break;
case TASK_LOG:
$subject .= $this->_AppUI->_('Task Log');
$body .= "\n" . $this->_AppUI->_('Task Log') . "\n" . $log_msg . "\n";
break;
case STATUSTASK_LOG:
$subject .= $this->_AppUI->_('Task+Status Log');
$body .= "\n" . $this->_AppUI->_('Task+Status Log') . "\n" . $log_msg . "\n";
break;
case NEW_WATCHER_LOG:
$subject .= $this->_AppUI->_('Watchers Notification');
$body = $this->_AppUI->_('You have been added to the watchers list for Help Desk item') . "\n" . $body . "\n" . $log_msg . "\n";
break;
}
//if there's no one in the list, skip the rest.
if (count($email_list)>0) {
$email_list=array_unique($email_list);
foreach ($email_list as $assigned_to_email) {
$mail = new w2p_Utilities_Mail();
if ($mail->ValidEmail($assigned_to_email) && ($this->_AppUI->user_email!=$assigned_to_email)) {
// KZHAO 9-12-2006
$to=$assigned_to_email;
if ($mail->ValidEmail($this->_AppUI->user_email)) {
$email = $this->_AppUI->user_email;
} else {
$email = $HELPDESK_CONFIG['notify_email_address'];
}
// Mail it
$mail->Subject($subject, $locale_char_set);
$mail->From($email);
$mail->To($assigned_to_email);
$mail->Body($body, isset( $GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : "");
$mail->Send();
}
}
}
}
public function hook_search()
{
$search['table'] = 'helpdesk_items';
$search['table_alias'] = 'h';
$search['table_module'] = 'helpdesk';
$search['table_key'] = 'h.item_id';
$search['table_link'] = 'index.php?m=helpdesk&a=view&item_id=';
$search['table_title'] = 'Helpdesk';
$search['table_orderby'] = 'item_title';
$search['table_orderby'] = 'item_title';
$search['search_fields'] = array('item_title', 'item_summary',
'item_application', 'item_requestor', 'item_requestor_email',
'task_log_name', 'task_log_description');
$search['display_fields'] = $search['search_fields'];
$search['table_joins'] = array(array('table' => 'task_log',
'alias' => 'tl', 'join' => 'h.item_id = tl.task_log_help_desk_id'));
return $search;
}
public function log_status_changes()
{
global $ist, $ict, $ics, $ios, $iap, $ipr, $isv, $ist, $field_event_map;
if (w2PgetParam( $_POST, "item_id")) {
$item_id = (int) w2PgetParam( $_POST, "item_id");
$hditem = new CHelpDesk();
$hditem->load($item_id);
$count=0;
$status_changes_summary="";
foreach ($field_event_map as $key => $value) {
if (eval("return (isset(\$this->$value) && (\$hditem->$value != \$this->$value));")) {
$old = $new = "";
$count++;
switch ($value) {
// Create the comments here
case 'item_assigned_to':
$q = $this->_getQuery();
$q->addQuery('user_id, concat(contact_first_name,\' \',contact_last_name) as user_name');
$q->addTable('users');
$q->addJoin('contacts','','user_contact = contact_id');
$q->addWhere('user_id in ('.($hditem->$value?$hditem->$value:'0').
($this->$value&&$hditem->$value?', ':'').
($this->$value?$this->$value:'').')');
$ids = $q->loadList();
foreach ($ids as $row) {
if ($row["user_id"]==$this->$value) {
$new = $row["user_name"];
} elseif ($row["user_id"]==$hditem->$value) {
$old = $row["user_name"];
}
}
break;
case 'item_company_id':
// $q = new w2p_Database_Query();
$q = $this->_getQuery();
$q->addQuery('company_id, company_name');
$q->addTable('companies');
$q->addWhere('company_id in ('.($hditem->$value?$hditem->$value:'').
($this->$value&&$hditem->$value?', ':'').
($this->$value?$this->$value:'').')');
$ids = $q->loadList();
foreach ($ids as $row) {
if ($row["company_id"]==$this->$value) {
$new = $row["company_name"];
} elseif ($row["company_id"]==$hditem->$value) {
$old = $row["company_name"];
}
}
break;
case 'item_project_id':
// $q = new w2p_Database_Query();
$q = $this->_getQuery();
$q->addQuery('project_id, project_name');
$q->addTable('projects');
$q->addWhere('project_id in ('.($hditem->$value?$hditem->$value:'').
($this->$value&&$hditem->$value?', ':'').
($this->$value?$this->$value:'').')');
$ids = $q->loadList();
foreach ($ids as $row) {
if ($row["project_id"]==$this->$value) {
$new = $row["project_name"];
} elseif ($row["project_id"]==$hditem->$value) {
$old = $row["project_name"];
}
}
break;
case 'item_calltype':
$old = $this->_AppUI->_($ict[$hditem->$value]);
$new = $this->_AppUI->_($ict[$this->$value]);
break;
case 'item_source':
$old = $this->_AppUI->_($ics[$hditem->$value]);
$new = $this->_AppUI->_($ics[$this->$value]);
break;
case 'item_status':
$old = $this->_AppUI->_($ist[$hditem->$value]);
$new = $this->_AppUI->_($ist[$this->$value]);
break;
case 'item_priority':
$old = $this->_AppUI->_($ipr[$hditem->$value]);
$new = $this->_AppUI->_($ipr[$this->$value]);
break;
case 'item_severity':
$old = $this->_AppUI->_($isv[$hditem->$value]);
$new = $this->_AppUI->_($isv[$this->$value]);
break;
case 'item_service':
$old = $this->_AppUI->_($ios[$hditem->$value]);
$new = $this->_AppUI->_($ios[$this->$value]);
break;
case 'item_application':
$old = $this->_AppUI->_($iap[$hditem->$value]);
$new = $this->_AppUI->_($iap[$this->$value]);
break;
case 'item_notify':
$old = $hditem->$value ? $this->_AppUI->_('On') : $this->_AppUI->_('Off');
$new = $this->$value ? $this->_AppUI->_('On') : $this->_AppUI->_('Off');
break;
case 'item_deadline':
$old = $hditem->$value;
$new = $this->$value;
if (strcmp($new,'N/A')) {
unset($new);
}
break;
default:
$old = trim($hditem->$value);
$new = trim($this->$value);
break;
}// end of switch
if (!eval("return \$new == \$old;")) {
if ($new=='') {$new = ' ';}
$last_status_comment = $this->log_status($key, $old, $new);
$status_changes_summary .= $last_status_comment . "\n";
}
}//end of if
}//end of loop
if ($this->item_notify && $count) {
$this->notifymsg(STATUS_LOG, $status_changes_summary);
}
return $status_changes_summary;
}
}
public function log_status($audit_code, $commentfrom="", $commentto="", $notify=0)
{
global $isa ;
if ($commentto) {
$sep = ' ';
$sepend = ' ';
if ($audit_code==16) {
$sep = "------ ";
$sepend = " \n";
}
$comment = $sep . $this->_AppUI->_('changed from'). $sepend . " \"" . addslashes($commentfrom) . "\" ";
$comment .= $sep . $this->_AppUI->_('to') . $sepend . " \"" . addslashes($commentto) . "\"";
} else {
$comment=$commentfrom;
}
$sql = "
INSERT INTO helpdesk_item_status
(status_item_id,status_code,status_date,status_modified_by,status_comment)
VALUES('{$this->item_id}','{$audit_code}',NOW(),'{$this->_AppUI->user_id}','$comment')";
db_exec($sql);
if (db_error()) {
return false;
}
$log_id = mysql_insert_id();
if (($this->item_notify) && $notify==1) {
$this->notifymsg(($audit_code==0) ? NEW_ITEM_LOG : STATUS_LOG , $comment);
}
return $isa[$audit_code] . " " . $comment;
}
}
helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/helpdesk.functions.php 0000664 0000000 0000000 00000052771 12647727470 0024523 0 ustar 00root root 0000000 0000000 addQuery('*');
$q->addTable('helpdesk_config');
if (!$q->exec()) {
$AppUI->setMsg(db_error(), UI_MSG_ERROR);
return null;
}
while ($row = $q->fetchRow()) {
$config[$row['config']] = $row['value'];
}
$q->clear();
return $config;
}
function storeConfig($confdata=0)
{
$q = new w2p_Database_Query();
foreach($confdata as $key=>$value) {
$q->addTable('helpdesk_config');
$q->addUpdate('config', $key);
$q->addUpdate('value', $value);
$q->addWhere('config = "'. $key . '"');
if (!$q->exec()) {
db_error();
return false;
}
$q->clear();
}
return true;
}
function getAllowedUsers($companyid=0,$activeOnly=0)
{
global $HELPDESK_CONFIG, $AppUI, $m;
//populate user list with all users from permitted companies
$q = new w2p_Database_Query;
$q->addQuery('user_id, CONCAT(contact_first_name, \' \',contact_last_name) as fullname');
$q->addTable('users');
$q->addJoin('contacts','','user_contact = contact_id');
$q->addWhere(getCompanyPerms('user_company', PERM_EDIT, $HELPDESK_CONFIG['the_company']) .' OR ' .getCompanyPerms('contact_company', PERM_EDIT, $HELPDESK_CONFIG['the_company'] ));
$q->addOrder('contact_last_name, contact_first_name');
$users = $q->loadHashList();
//Filter inactive users
if ($activeOnly) {
$perms =& $AppUI->acl();
$cnt=0;
$userids=array_keys($users);
foreach ($userids as $row) {
if ($perms->isUserPermitted($row) == false) {
// echo "Inactive!!!!".$row."
";
unset($users[$row]);
}
//$cnt++;
}
}
return $users;
}
//KZHAO 8-8-2006
// eliminate non-user's companies if needed
function getAllowedCompanies($companyId=0)
{
global $AppUI;
$company = new CCompany();
$allowedCompanies = $company->getAllowedRecords( $AppUI->user_id, 'company_id,company_name', 'company_name' );
if ($companyId!=0 && $companyId!=$HELPDESK_CONFIG['the_company']) {
$compIds=array_keys($allowedCompanies);
foreach ($compIds as $row) {
if($row!=$companyId)
unset($allowedCompanies[$row]);
}
}
return $allowedCompanies;
}
function getAllowedProjects($list = 0, $activeOnly = 0)
{
global $AppUI, $HELPDESK_CONFIG;
$project = new CProject();
return $project->getAllowedProjects($AppUI->user_id, $activeOnly);
}
// Add a parameter for active projects-- Kang
function getAllowedProjectsForJavascript($activeonly = 0)
{
global $HELPDESK_CONFIG, $AppUI;
$allowedProjects = getAllowedProjects();
$projects = array();
foreach ($allowedProjects as $project) {
$projects[] = "[{$project['project_company']},{$project['project_id']},'"
. addslashes($project['project_name']) . "']";
}
return $projects;
}
//----------------------------------------------
//Kang--retrieve a list of tasks for helpdesk items
// Note: may need more access control here
function getAllowedTasksForJavascript($project_ids,$activeOnly=1)
{
global $HELPDESK_CONFIG, $AppUI;
$tasks = array();
if (!isset($project_ids) || !is_array($project_ids) || !count($project_ids)) {
return;
}
$q = new w2p_Database_Query;
$q->addQuery('task_id, task_name, task_project');
$q->addTable('tasks');
$q->addWhere('task_project IN (' . implode(',',$project_ids) .') ');
if ($activeOnly) {
$q->addWhere('task_status=0 AND task_percent_complete!=100.00');
}
$q->addOrder('task_name');
$allowedTask = $q->loadList();
foreach ($allowedTask as $row) {
$tasks[]="[{$row['task_project']},{$row['task_id']},'"
. addslashes($row['task_name'])."']";
}
return $tasks;
}
/* Function to build a where clasuse that will restrict the list of Help Desk
* items to only those viewable by a user. The viewable items include
* 1. Items the user created
* 2. Items that are assigned to the user
* 3. Items where the user is the requestor
* 4. Items of a company you have permissions for
*/
function getItemPerms()
{
global $HELPDESK_CONFIG, $AppUI;
$permarr = array();
//pull in permitted companies
$allowedCompanies = getAllowedCompanies();
$allowedProjects = getAllowedProjects();
//if there are none listed, make sure that sql returns nothing
if (!$allowedCompanies) {
return "0=1";
}
foreach ($allowedCompanies as $k=>$v) {
$companyIds[] = $k;
}
$companyIds = implode(",", $companyIds);
$permarr[] = "(item_company_id in ("
.$companyIds
.") OR item_created_by="
.$AppUI->user_id
.") ";
//it's assigned to the current user
$permarr[] = "item_assigned_to=".$AppUI->user_id;
//it's requested by a user and that user is you
$permarr[] = " (item_requestor_type=1 AND item_requestor_id=".$AppUI->user_id.') ' ;
if ($HELPDESK_CONFIG['use_project_perms']) {
$projectIds = array_keys($allowedProjects);
} else {
foreach ($allowedProjects as $p) {
$projectIds[] = $p['project_id'];
}
}
if (count($projectIds)) {
$projarr[] = " AND item_project_id in (0,".implode(", ", $projectIds).")";
} else {
$projarr[] = " AND item_project_id in (0)";
}
$sql = '('.implode("\n OR ", $permarr).')'.implode('',$projarr);
return $sql;
}
// Function to build a where clause to be appended to any sql that will narrow
// down the returned data to only permitted company data
function getCompanyPerms($mod_id_field,$perm_type=NULL,$the_company=NULL)
{
GLOBAL $AppUI, $perms, $m;
//pull in permitted companies
$allowedCompanies = getAllowedCompanies();
//if there are none listed, make sure that sql returns nothing
if (!$allowedCompanies) {
return "0=1";
}
$allowedCompanies = array_keys($allowedCompanies);
if (is_numeric($the_company)) {
$allowedCompanies[] = $the_company;
}
return "($mod_id_field in (".implode(",", $allowedCompanies)."))";
}
function hditemReadable($hditem)
{
return hditemPerm($hditem, PERM_READ);
}
function hditemEditable($hditem)
{
return hditemPerm($hditem, PERM_EDIT);
}
function hditemPerm($hditem, $perm_type)
{
global $HELPDESK_CONFIG, $AppUI, $m;
$perms = & $AppUI->acl();
$created_by = $hditem['item_created_by'];
$company_id = isset($hditem['item_company_id'])?$hditem['item_company_id']:'';
$assigned_to = isset($hditem['item_assigned_to'])?$hditem['item_assigned_to']:'';
$requested_by = isset($hditem['item_requestor_id'])?$hditem['item_requestor_id']:'';
switch ($perm_type) {
case PERM_READ:
$company_perm = $perms->checkModuleItem('companies', 'view', $company_id);
break;
case PERM_EDIT:
// If the item is not assigned to a company, figure out if we can edit it
if ($company_id == 0) {
if ($HELPDESK_CONFIG['no_company_editable']) {
$company_perm = 1;
} else {
$company_perm = 0;
}
} else {
$company_perm = $perms->checkModuleItem('companies', 'view', $company_id);
}
break;
default:
die ("Wrong permission type was passed");
}
/* User is allowed if
1. He has the company permission
2. He is the creator
3. He is the assignee
4. He is the requestor
*/
if($company_perm ||
($created_by == $AppUI->user_id) ||
($assigned_to == $AppUI->user_id) ||
($requested_by == $AppUI->user_id)) {
return true;
} else {
return false;
}
}
function hditemCreate()
{
global $m, $AppUI;
$perms = & $AppUI->acl();
if ($perms->checkModule($m, 'add'))
return true;
return false;
}
function dump($var)
{
print "";
print_r($var);
print "
";
}
// Added by KZHAO: 8-4-2006
// convert mysql date format into PHP date format
function get_mysql_to_epoch($sqldate)
{
list( $year, $month, $day, $hour, $minute, $second )= split( '([^0-9])', $sqldate );
//echo $year.",".$month.",".$day;
return date( 'U', mktime( $hour, $minute, $second, $month, $day, $year) );
}
// KZHAO: get how long ago
function get_time_ago($mysqltime)
{
global $AppUI;
$wrong=0;
$timestamp=get_mysql_to_epoch($mysqltime);
$elapsed_seconds = time() - $timestamp;
// KZHAO 8-10-2006
// dealing with time in the future
if ($elapsed_seconds<0) {
return ("N/A");
} elseif ($elapsed_seconds < 60) { // seconds ago
if ($elapsed_seconds) {
$interval = $elapsed_seconds;
} else {
$interval = 1;
}
$output = "sec.";
} elseif ($elapsed_seconds < 3600) { // minutes ago
$interval = round($elapsed_seconds / 60);
$output = "min.";
} elseif ($elapsed_seconds < 86400) { // hours ago
$interval = round($elapsed_seconds / 3600);
$output = "hr.";
} elseif ($elapsed_seconds < 604800) { // days ago
$interval = round($elapsed_seconds / 86400);
$output = "day";
} elseif ($elapsed_seconds < 2419200) { // weeks ago
$interval = round($elapsed_seconds / 604800);
$output = "week";
} elseif ($elapsed_seconds < 29030400) { // months ago
$interval = round($elapsed_seconds / 2419200);
$output = " month";
} else { // years ago
$interval = round($elapsed_seconds / 29030400);
$output = "year";
}
if ($interval > 1) {
$output .= "s";
}
$output = " ".$AppUI->_($output);
$output .= " ".$AppUI->_('ago');
$output = $interval.$output;
return($output);
}
//KZHAO 8-10-2006
// handle the deadline
function get_due_time($mysqltime, $listView=0)
{
global $AppUI;
$ago=1;
$color="000000";
$color_soon="ff0000";// red
$color_days="990066";//pink
$color_weeks="cc6600";// brown
$color_months="339900";//green
$color_long="66ff00";//
$timestamp=get_mysql_to_epoch($mysqltime);
$elapsed_seconds = time() - $timestamp;
// KZHAO 8-10-2006
// dealing with time in the future
if ($elapsed_seconds<0) {
$elapsed_seconds=$timestamp-time();
$ago=0;
}
if ($elapsed_seconds < 60) { // seconds ago
$interval = $elapsed_seconds;
$output = "sec.";
$color=$color_soon;
} elseif ($elapsed_seconds < 3600) { // minutes ago
$interval = round($elapsed_seconds / 60);
$output = "min.";
$color=$color_soon;
} elseif ($elapsed_seconds < 86400) { // hours ago
$interval = round($elapsed_seconds / 3600);
$output = "hr.";
$color=$color_soon;
} elseif ($elapsed_seconds < 604800) { // days ago
$interval = round($elapsed_seconds / 86400);
$output = "day";
if($interval<=3)
$color=$color_soon; //red
else
$color=$color_days;//orange
} elseif ($elapsed_seconds < 2419200) { // weeks ago
$interval = round($elapsed_seconds / 604800);
$output = "week";
$color=$color_weeks;
} elseif ($elapsed_seconds < 29030400) { // months ago
$interval = round($elapsed_seconds / 2419200);
$output = " month";
$color=$color_months;
} else { // years ago
$interval = round($elapsed_seconds / 29030400);
$output = "year";
$color=$color_long;
}
if ($interval > 1) {
$output .= "s";
}
$output = " ".$AppUI->_($output);
//Only display time for list view
if ($listView) {
if($ago)
$output =$interval." ".$output." ".$AppUI->_('ago');
else
$output = "".$interval.$output."";
} else {
if ($ago) {
$output .= " ".$AppUI->_('ago');
$output = "Deadline is ".$interval.$output;
} else {
$output = "Due in ".$interval.$output."";
//$output ="Due in "
}
}
return($output);
}
function linkLinks($data)
{
$data = strip_tags($data);
$search_email = '/([\w-]+([.][\w_-]+){0,4}[@][\w_-]+([.][\w-]+){1,3})/';
$search_http = '/(http(s)?:\/\/[^\s]+)/i';
$data = preg_replace($search_email,"$1",$data);
$data = preg_replace($search_http,"$1",$data);
return $data;
}
// dealing with the helpdesk_item_watchers table in DB and send emails
// send emails to acknowledge that they are added to the watcher list
function doWatchers($list, $hditem, $notify_all) {//KZHAO 8-7-2006
global $AppUI;
# Create the watcher list
$watcherlist = split(',', $list);
$q = new w2p_Database_Query;
$q->addQuery('user_id');
$q->addTable('helpdesk_item_watchers');
$q->addWhere('item_id=' . $hditem->item_id);
$current_users = $q->loadHashList();
$current_users = array_keys($current_users);
# Delete the existing watchers as the list might have changed
$sql = "DELETE FROM helpdesk_item_watchers WHERE item_id=" . $hditem->item_id;
db_exec($sql);
if (!$del) {
if ($list) {
foreach ($watcherlist as $watcher) {
$q = new w2p_Database_Query;
$q->addQuery('user_id, c.contact_email');
$q->addTable('users');
$q->addJoin('contacts','c','user_contact = contact_id');
$q->addWhere('user_id=' . $watcher);
if ($notify_all) {
$rows = $q->loadlist($sql);
$email_list = array();
foreach ($rows as $row) {
# Send the notification that they've been added to a watch list.
//KZHAO 8-3-2006: only when users choose to send emails
if (!in_array($row['user_id'],$current_users)) {
$email_list[] = $row['contact_email'];
}
}
$hditem->notifymsg(NEW_WATCHER_LOG, '', $email_list);
}
$sql = "INSERT INTO helpdesk_item_watchers VALUES(". $hditem->item_id . "," . $watcher . ",'Y')";
db_exec($sql);
}
}
}
}
/*
* opened = 0
* closed = 1
* mine = 2
*/
function vw_idx_handler($type)
{
global $m, $ipr, $ist, $AppUI, $HELPDESK_CONFIG;
global $project_id;
$ipr = w2PgetSysVal( 'HelpDeskPriority' );
$ist = w2PgetSysVal( 'HelpDeskStatus' );
$where = $date_field_name = $date_field_title = "";
switch ($type) {
case 0:// newly created open ticket today
$date_field_title = $AppUI->_('Opened On');
$date_field_name = "item_created";
$where .= "(TO_DAYS(NOW()) - TO_DAYS(his.status_date) = 0) AND item_status = 1 AND (his.status_code = 0)";
break;
case 1:// Closed today
$date_field_title = $AppUI->_('Closed On');
$date_field_name = "status_date";
$where .= "item_status=2 AND (TO_DAYS(NOW()) - TO_DAYS(status_date) = 0) AND status_code=11";
break;
case 2: // Mine open
$date_field_title = $AppUI->_('Opened On');
$date_field_name = "item_created";
$where .= "item_assigned_to={$AppUI->user_id} AND item_status !=2 ";
break;
case 3: // Any state by project
$date_field_title = $AppUI->_('Opened On');
$date_field_name = "item_created";
$where .= "item_project_id = $project_id";
break;
default:
print "Shouldn't be here (for now)";
exit(1);
}
$df = $AppUI->getPref( 'SHDATEFORMAT' );
$tf = $AppUI->getPref( 'TIMEFORMAT' );
$format = $df." ".$tf;
/*
* Unassigned = 0
* Open = 1
* Closed = 2
* On hold = 3
* Delete = 4
* Testing = 5
*/
$item_perms = getItemPerms();
$q = new w2p_Database_Query;
$q->addQuery('hi.*, CONCAT(co.contact_first_name,\' \',co.contact_last_name) assigned_fullname');
$q->addQuery('contact_email AS assigned_email');
$q->addQuery('p.project_id,p.project_name,p.project_color_identifier,his.status_date sd');
$q->addTable('helpdesk_items','hi');
$q->addJoin('helpdesk_item_status','his','his.status_item_id = hi.item_id');
$q->addJoin('users','u','u.user_id = hi.item_assigned_to');
$q->addJoin('contacts','co','co.contact_id = u.user_contact');
$q->addJoin('projects','p','p.project_id = hi.item_project_id');
$q->addWhere($where . ' AND ' . $item_perms);
$q->addGroup('item_id');
$q->addOrder('item_id');
$items = $q->loadList();
?>
_('Number'); ?> |
_('Requestor'); ?> |
_('Title'); ?> |
_('Summary'); ?> |
_('Assigned To'); ?> |
_('Status'); ?> |
_('Priority'); ?> |
_('Updated'); ?> |
_('Project'); ?> |
|
format( $format );
} else {
$tc = ' ';
}
if ($row['status_date']) {
$datesd = new w2p_Utilities_Date( $row['status_date'] );
$sd = $datesd->format( $format );
} else {
$sd = ' ';
}
?>
|
".$row['item_requestor']."";
} else {
print $row['item_requestor'];
}
?>
|
|
'; ?> |
load($row['item_assigned_to']);
$contact = new CContact();
$contact->contact_id = $user->user_contact;
$contactMethods = $contact->getContactMethods(array('email_primary'));
$assigned_email = $contactMethods['email_primary'];
print "{$row['assigned_fullname']}";
} else {
print $row['assigned_fullname'] ? $row['assigned_fullname'] : "-";
}
?>
|
_($ist[@$row['item_status']]); ?> |
_($ipr[@$row['item_priority']]); ?> |
|
-
|
|
$name$arrow";
return $link;
}
helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/helpdesk_tab.view.files.php 0000664 0000000 0000000 00000002576 12647727470 0025412 0 ustar 00root root 0000000 0000000 getAllowedRecords($AppUI->user_id);
$denied_folders_ary = $cfObj->getDeniedRecords($AppUI->user_id);
$limited = ((count( $allowed_folders_ary ) < $cfObj->countFolders()) ? true : false);
if (!$limited) {
$canEdit = true;
} elseif ($limited && array_key_exists($folder, $allowed_folders_ary)) {
$canEdit = true;
} else {
$canEdit = false;
}
$showProject = false;
if (getPermission('files', 'edit')) {
echo ('' . $AppUI->_('Attach a file') . '');
echo w2PshowImage('stock_attach-16.png', 16, 16, '', '', $m);
}
$canAccess_folders = getPermission('file_folders', 'access');
if ($canAccess_folders) {
$folder = w2PgetParam($_GET, 'folder', 0);
require( W2P_BASE_DIR . '/modules/files/folders_table.php' );
} elseif (getPermission('files', 'view')) {
require( W2P_BASE_DIR . '/modules/files/index_table.php' );
}
helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/images/ 0000775 0000000 0000000 00000000000 12647727470 0021435 5 ustar 00root root 0000000 0000000 helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/images/ct0.png 0000664 0000000 0000000 00000000401 12647727470 0022624 0 ustar 00root root 0000000 0000000 ‰PNG
IHDR ð$ë’ tIMEÓPuFä pHYs ÒÝ~ü 0PLTEÿÿÆï¥çk„Þ9R÷ÖÞç{Œ÷½ÆÎ ç„„ÿÞÞçssÖ11Þ9BïÎ ç:B tRNS @æØf WIDATxÚc`€ v$†±"˜áÆbEÆ îº¬ìL ¼\l
ìÌÜÀŒ*ƒ)¡“$ÅÀPÁ R׎0nÛ! ¨1@cÒ IEND®B`‚ helpdesk-0cf22e59c0eb366039a8a4039a0e47db8d650656/images/ct1.png 0000664 0000000 0000000 00000001574 12647727470 0022641 0 ustar 00root root 0000000 0000000 ‰PNG
IHDR óÿa bKGD ÿ ÿ ÿ ½§“ tIMEÖ :36ë IDAT8]“mh•uÆ÷ÿyÎyvÎ<Îæ¦n
+õCDN£’ÁRƒ¤Ì`+¢°Å ¾D/sJ«e2*éåCkÑC5’jëe¨Ðš ér’/s³Ú ‡l;;Ïsžçÿ¿ûP’ó‚ß·ûâææºn™ne1)9¨±ÞŠ/Çm¨/xyÃfb”ŒªuG\‰÷sp¦^–¾è×íΆƒõ?ã
íAhµÉxÚð´Úð´ÆãÝh±…Ýó‹Sm¦SÛH_õ‰¹Ý¿i«P<„¿r« 'ùZ‡Ž5Ž=A\ì„%Õ&ØÖ[æÕÝ÷Ø´ÊwÚ„àµnzæ7˜êFINvá~?†ûùH&0s íÀ9„=¹tÓ^_K—*ãäì¼]}ôHa;·¤Žág|ªrx«kÐ+E/ ž€³ÄèœT0·–ôü—ßÙ4áOMÜâíh0Ïù[ž½ÃÛØ(’ÿÉÍæÅNÃêMyÊ—/@Ïår®‚öOÒ¬oðpv1xV¤ìàQÏ ò ·t£qQ?ˆHš‰ØñÆŒ “bç›?õ+`Iñ¼üc