本文整理汇总了PHP中shd_allowed_to函数的典型用法代码示例。如果您正苦于以下问题:PHP shd_allowed_to函数的具体用法?PHP shd_allowed_to怎么用?PHP shd_allowed_to使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shd_allowed_to函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shd_profile_areas
/**
* Sets up the profile menu additions.
*
* @param array $profile_areas Current profile_areas.
*
* @since 2.0
*/
function shd_profile_areas(&$profile_areas)
{
global $sourcedir, $modSettings, $context, $txt;
static $called = false;
if ($called) {
return;
}
if (empty($called)) {
$called = true;
}
// SimpleDesk sections. Added here after the initial cleaning is done, so that we can do our own permission checks without arguing with SMF's system (so much)
if (empty($modSettings['helpdesk_active'])) {
return;
}
shd_load_language('sd_language/SimpleDeskProfile');
// Put it here so we can reuse it for the left menu a bit
$context['helpdesk_menu'] = array('title' => $txt['shd_profile_area'], 'areas' => array('hd_profile' => array('label' => $txt['shd_profile_main'], 'file' => 'sd_source/SimpleDesk-Profile.php', 'function' => 'shd_profile_main', 'enabled' => shd_allowed_to('shd_view_profile_any') || $context['user']['is_owner'] && shd_allowed_to('shd_view_profile_own'), 'permission' => array('own' => array('is_not_guest'), 'any' => array('is_not_guest'))), 'hd_prefs' => array('label' => $txt['shd_profile_preferences'], 'file' => 'sd_source/SimpleDesk-Profile.php', 'function' => 'shd_profile_main', 'enabled' => shd_allowed_to('shd_view_preferences_any') || $context['user']['is_owner'] && shd_allowed_to('shd_view_preferences_own'), 'permission' => array('own' => array('shd_view_preferences_own'), 'any' => array('shd_view_preferences_any'))), 'hd_showtickets' => array('label' => $txt['shd_profile_show_tickets'], 'file' => 'sd_source/SimpleDesk-Profile.php', 'function' => 'shd_profile_main', 'enabled' => $context['user']['is_owner'] && shd_allowed_to('shd_view_ticket_own') || shd_allowed_to('shd_view_ticket_any'), 'permission' => array('own' => array('shd_view_ticket_own'), 'any' => array('shd_view_ticket_any'))), 'hd_permissions' => array('label' => $txt['shd_profile_permissions'], 'file' => 'sd_source/SimpleDesk-Profile.php', 'function' => 'shd_profile_main', 'enabled' => shd_allowed_to('admin_helpdesk'), 'permission' => array('own' => array('admin_helpdesk'), 'any' => array('admin_helpdesk'))), 'hd_actionlog' => array('label' => $txt['shd_profile_actionlog'], 'file' => 'sd_source/SimpleDesk-Profile.php', 'function' => 'shd_profile_main', 'enabled' => empty($modSettings['shd_disable_action_log']) && (shd_allowed_to('shd_view_profile_log_any') || $context['user']['is_owner'] && shd_allowed_to('shd_view_profile_log_own')), 'permission' => array('own' => array('shd_view_profile_log_own'), 'any' => array('shd_view_profile_log_any')))));
// Kill the existing profile menu but save it in a temporary place first.
$old_profile_areas = $profile_areas;
$profile_areas = array();
// Now, where we add this depends very much on what mode we're in. In HD only mode, we want our menu first before anything else.
if (!empty($modSettings['shd_helpdesk_only'])) {
require_once $sourcedir . '/Profile-Modify.php';
// Move some stuff around.
$context['helpdesk_menu']['areas']['permissions'] = array('label' => $txt['shd_show_forum_permissions'], 'file' => 'Profile-View.php', 'function' => 'showPermissions', 'enabled' => allowedTo('manage_permissions'));
$context['helpdesk_menu']['areas']['tracking'] = array('label' => $txt['trackUser'], 'file' => 'Profile-View.php', 'function' => 'tracking', 'subsections' => array('activity' => array($txt['trackActivity'], 'moderate_forum'), 'ip' => array($txt['trackIP'], 'moderate_forum'), 'edits' => array($txt['trackEdits'], 'moderate_forum')), 'enabled' => allowedTo('moderate_forum'));
$profile_areas['helpdesk'] = $context['helpdesk_menu'];
$profile_areas += $old_profile_areas;
unset($profile_areas['info']['areas']['permissions'], $profile_areas['info']['areas']['tracking']);
$remove = array('info' => array('summary', 'statistics', 'showposts', 'viewwarning'), 'edit_profile' => array('forumprofile', 'ignoreboards', 'lists', 'notification'), 'profile_action' => array('issuewarning'));
if (!empty($modSettings['shd_disable_pm'])) {
$remove['profile_action'][] = 'sendpm';
$remove['edit_profile'][] = 'pmprefs';
}
foreach ($remove as $area => $items) {
foreach ($items as $item) {
if (!empty($profile_areas[$area]['areas'][$item])) {
$profile_areas[$area]['areas'][$item]['enabled'] = false;
}
}
}
$profile_areas['edit_profile']['areas']['theme']['file'] = 'sd_source/SimpleDesk-Profile.php';
$profile_areas['edit_profile']['areas']['theme']['function'] = 'shd_profile_theme_wrapper';
} else {
foreach ($old_profile_areas as $area => $details) {
if ($area == 'edit_profile') {
$profile_areas['helpdesk'] = $context['helpdesk_menu'];
}
$profile_areas[$area] = $details;
}
}
// Now engage any hooks.
call_integration_hook('shd_hook_profilemenu', array(&$profile_areas));
}
示例2: shd_profile_actionlog
function shd_profile_actionlog($memID)
{
global $context, $txt, $scripturl, $sourcedir, $user_info, $settings;
loadTemplate('sd_template/SimpleDesk-Profile');
shd_load_language('sd_language/SimpleDeskProfile');
require_once $sourcedir . '/sd_source/Subs-SimpleDeskAdmin.php';
$context['action_log'] = shd_load_action_log_entries(-1, 10, '', '', 'la.id_member = ' . $memID);
$context['action_log_count'] = shd_count_action_log_entries('la.id_member = ' . $memID);
$context['action_full_log'] = allowedTo('admin_forum') || shd_allowed_to('admin_helpdesk', 0);
$context['page_title'] = $txt['shd_profile_area'] . ' - ' . $txt['shd_profile_actionlog'];
$context['sub_template'] = 'shd_profile_actionlog';
}
示例3: shd_helpdesk_listing
//.........这里部分代码省略.........
$query = shd_db_query('', '
SELECT COUNT(hdt.id_ticket)
FROM {db_prefix}helpdesk_tickets AS hdt
INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr_first ON (hdt.id_first_msg = hdtr_first.id_msg)
INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr_last ON (hdt.id_last_msg = hdtr_last.id_msg)
INNER JOIN {db_prefix}helpdesk_depts AS hdd ON (hdt.id_dept = hdd.id_dept)
' . (!empty($block['sort']['sql']['join']) ? $block['sort']['sql']['join'] : '') . $context['filter_join'] . '
WHERE {query_see_ticket}' . (!empty($block['where']) ? ' AND ' . $block['where'] : '') . (!empty($context['shd_department']) ? ' AND hdt.id_dept = {int:dept}' : '') . $context['filter_where'], array('dept' => $context['shd_department'], 'user' => $context['user']['id'], 'field' => $_REQUEST['field'], 'filter' => $_REQUEST['filter'], 'type_ticket' => CFIELD_TICKET, 'active' => 1));
list($context['ticket_blocks'][$block_key]['count']) = $smcFunc['db_fetch_row']($query);
$block['count'] = $context['ticket_blocks'][$block_key]['count'];
$smcFunc['db_free_result']($query);
if ($block['start'] >= $block['count']) {
$context['ticket_blocks'][$block_key]['start'] = max(0, (int) $block['count'] - ((int) $block['count'] % (int) $block['num_per_page'] == 0 ? $block['num_per_page'] : (int) $block['count'] % (int) $block['num_per_page']));
$block['start'] = $context['ticket_blocks'][$block_key]['start'];
}
}
$query = shd_db_query('', '
SELECT hdt.id_ticket, hdt.id_dept, hdd.dept_name, hdt.id_last_msg, hdt.id_member_started, hdt.id_member_updated,
hdt.id_member_assigned, hdt.subject, hdt.status, hdt.num_replies, hdt.deleted_replies, hdt.private, hdt.urgency,
hdt.last_updated, hdtr_first.poster_name AS ticket_opener, hdtr_last.poster_name AS respondent, hdtr_last.poster_time,
IFNULL(hdlr.id_msg, 0) AS log_read' . (!empty($block['sort']['sql']['select']) ? ', ' . $block['sort']['sql']['select'] : '') . '
FROM {db_prefix}helpdesk_tickets AS hdt
INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr_first ON (hdt.id_first_msg = hdtr_first.id_msg)
INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr_last ON (hdt.id_last_msg = hdtr_last.id_msg)
INNER JOIN {db_prefix}helpdesk_depts AS hdd ON (hdt.id_dept = hdd.id_dept)
LEFT JOIN {db_prefix}helpdesk_log_read AS hdlr ON (hdt.id_ticket = hdlr.id_ticket AND hdlr.id_member = {int:user})
' . (!empty($block['sort']['sql']['join']) ? $block['sort']['sql']['join'] : '') . $context['filter_join'] . '
WHERE {query_see_ticket}' . (!empty($block['where']) ? ' AND ' . $block['where'] : '') . (!empty($context['shd_department']) ? ' AND hdt.id_dept = {int:dept}' : '') . $context['filter_where'] . '
ORDER BY ' . (!empty($block['sort']['sql']['sort']) ? $block['sort']['sql']['sort'] : 'hdt.id_last_msg ASC') . '
LIMIT {int:start}, {int:items_per_page}', array('dept' => $context['shd_department'], 'user' => $context['user']['id'], 'start' => $block['start'], 'items_per_page' => $block['num_per_page'], 'field' => $_REQUEST['field'], 'filter' => $_REQUEST['filter'], 'type_ticket' => CFIELD_TICKET, 'active' => 1));
while ($row = $smcFunc['db_fetch_assoc']($query)) {
$is_own = $user_info['id'] == $row['id_member_started'];
censorText($row['subject']);
$new_block = array('id' => $row['id_ticket'], 'display_id' => str_pad($row['id_ticket'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT), 'dept_link' => empty($context['shd_department']) && $context['shd_multi_dept'] ? '[<a href="' . $scripturl . '?' . $context['shd_home'] . ';dept=' . $row['id_dept'] . '">' . $row['dept_name'] . '</a>] ' : '', 'link' => '<a href="' . $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $row['id_ticket'] . ($_REQUEST['sa'] == 'recyclebin' ? ';recycle' : '') . '">' . $row['subject'] . '</a>', 'subject' => $row['subject'], 'status' => array('level' => $row['status'], 'label' => $txt['shd_status_' . $row['status']]), 'starter' => array('id' => $row['id_member_started'], 'name' => $row['ticket_opener']), 'last_update' => timeformat($row['last_updated']), 'assigned' => array('id' => $row['id_member_assigned']), 'respondent' => array('id' => $row['id_member_updated'], 'name' => $row['respondent']), 'urgency' => array('level' => $row['urgency'], 'label' => $row['urgency'] > TICKET_URGENCY_HIGH ? '<span class="error">' . $txt['shd_urgency_' . $row['urgency']] . '</span>' : $txt['shd_urgency_' . $row['urgency']]), 'is_unread' => $row['id_last_msg'] > $row['log_read'], 'new_href' => $row['id_last_msg'] <= $row['log_read'] ? '' : $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $row['id_ticket'] . '.new' . ($_REQUEST['sa'] == 'recyclebin' ? ';recycle' : '') . '#new', 'private' => $row['private'], 'actions' => array('movedept' => !empty($context['shd_multi_dept']) && (shd_allowed_to('shd_move_dept_any', $context['shd_department']) || $is_own && shd_allowed_to('shd_move_dept_own', $context['shd_department'])) ? '<a href="' . $scripturl . '?action=helpdesk;sa=movedept;ticket=' . $row['id_ticket'] . ';home;' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . $txt['shd_move_dept'] . '"><img src="' . $settings['default_images_url'] . '/simpledesk/movedept.png" alt="' . $txt['shd_move_dept'] . '" /></a>' : ''), 'num_replies' => $row['num_replies'], 'replies_href' => $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $row['id_ticket'] . '.msg' . $row['id_last_msg'] . '#msg' . $row['id_last_msg'] . ($_REQUEST['sa'] == 'recyclebin' ? ';recycle' : ''), 'all_replies' => (int) $row['num_replies'] + (int) $row['deleted_replies']);
if ($row['status'] == TICKET_STATUS_CLOSED) {
$new_block['actions'] += array('resolve' => shd_allowed_to('shd_unresolve_ticket_any', $context['shd_department']) || $is_own && shd_allowed_to('shd_unresolve_ticket_own', $context['shd_department']) ? '<a href="' . $scripturl . '?action=helpdesk;sa=resolveticket;ticket=' . $row['id_ticket'] . ';home;' . $context['shd_dept_link'] . $context['session_var'] . '=' . $context['session_id'] . '" title="' . $txt['shd_ticket_unresolved'] . '"><img src="' . $settings['default_images_url'] . '/simpledesk/unresolved.png" alt="' . $txt['shd_ticket_unresolved'] . '" /></a>' : '');
} elseif ($row['status'] == TICKET_STATUS_DELETED) {
$new_block['actions'] += array('restore' => shd_allowed_to('shd_restore_ticket_any', $context['shd_department']) || $is_own && shd_allowed_to('shd_restore_ticket_own', $context['shd_department']) ? '<a href="' . $scripturl . '?action=helpdesk;sa=restoreticket;ticket=' . $row['id_ticket'] . ';home;' . $context['shd_dept_link'] . $context['session_var'] . '=' . $context['session_id'] . '" title="' . $txt['shd_ticket_restore'] . '"><img src="' . $settings['default_images_url'] . '/simpledesk/restore.png" alt="' . $txt['shd_ticket_restore'] . '" /></a>' : '', 'permadelete' => shd_allowed_to('shd_delete_recycling', $context['shd_department']) ? '<a href="' . $scripturl . '?action=helpdesk;sa=permadelete;ticket=' . $row['id_ticket'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . $txt['shd_delete_permanently'] . '" onclick="return confirm(' . JavaScriptEscape($txt['shd_delete_permanently_confirm']) . ');"><img src="' . $settings['default_images_url'] . '/simpledesk/delete.png" alt="' . $txt['shd_delete_permanently'] . '" /></a>' : '');
} else {
$langstring = '';
if (shd_allowed_to('shd_assign_ticket_any', $context['shd_department'])) {
$langstring = empty($row['id_member_assigned']) ? $txt['shd_ticket_assign'] : $txt['shd_ticket_reassign'];
} elseif (shd_allowed_to('shd_assign_ticket_own', $context['shd_department']) && (empty($row['id_member_assigned']) || $row['id_member_assigned'] == $context['user']['id'])) {
$langstring = $row['id_member_assigned'] == $context['user']['id'] ? $txt['shd_ticket_unassign'] : $txt['shd_ticket_assign_self'];
}
if (!empty($langstring)) {
$new_block['actions']['assign'] = '<a href="' . $scripturl . '?action=helpdesk;sa=assign;ticket=' . $row['id_ticket'] . ';home;' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . $langstring . '"><img src="' . $settings['default_images_url'] . '/simpledesk/assign.png" alt="' . $langstring . '" /></a>';
}
$new_block['actions'] += array('resolve' => shd_allowed_to('shd_resolve_ticket_any', $context['shd_department']) || $is_own && shd_allowed_to('shd_resolve_ticket_own', $context['shd_department']) ? '<a href="' . $scripturl . '?action=helpdesk;sa=resolveticket;ticket=' . $row['id_ticket'] . ';home;' . $context['shd_dept_link'] . $context['session_var'] . '=' . $context['session_id'] . '" title="' . $txt['shd_ticket_resolved'] . '"><img src="' . $settings['default_images_url'] . '/simpledesk/resolved.png" alt="' . $txt['shd_ticket_resolved'] . '" /></a>' : '', 'tickettotopic' => empty($modSettings['shd_helpdesk_only']) && shd_allowed_to('shd_ticket_to_topic', $context['shd_department']) && ($row['deleted_replies'] == 0 || shd_allowed_to('shd_access_recyclebin')) ? '<a href="' . $scripturl . '?action=helpdesk;sa=tickettotopic;ticket=' . $row['id_ticket'] . ';' . $context['shd_dept_link'] . $context['session_var'] . '=' . $context['session_id'] . '" title="' . $txt['shd_ticket_move_to_topic'] . '"><img src="' . $settings['default_images_url'] . '/simpledesk/tickettotopic.png" alt="' . $txt['shd_ticket_move_to_topic'] . '" /></a>' : '', 'delete' => shd_allowed_to('shd_delete_ticket_any', $context['shd_department']) || $is_own && shd_allowed_to('shd_delete_ticket_own') ? '<a href="' . $scripturl . '?action=helpdesk;sa=deleteticket;ticket=' . $row['id_ticket'] . ';' . $context['shd_dept_link'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . $txt['shd_ticket_delete'] . '" onclick="return confirm(' . JavaScriptEscape($txt['shd_delete_confirm']) . ');"><img src="' . $settings['default_images_url'] . '/simpledesk/delete.png" alt="' . $txt['shd_ticket_delete'] . '" /></a>' : '');
}
$context['ticket_blocks'][$block_key]['tickets'][$row['id_ticket']] = $new_block;
$users[] = $row['id_member_started'];
$users[] = $row['id_member_updated'];
$users[] = $row['id_member_assigned'];
$tickets[$row['id_ticket']] = array();
}
$smcFunc['db_free_result']($query);
}
$users = array_unique($users);
if (!empty($users)) {
loadMemberData($users, false, 'minimal');
}
foreach ($context['ticket_blocks'] as $block_id => $block) {
if (empty($block['tickets'])) {
continue;
}
示例4: shd_add_to_boardindex
function shd_add_to_boardindex(&$boardIndexOptions, &$categories)
{
global $context, $modSettings, $smcFunc, $board, $txt, $scripturl, $settings;
// Does the category exist? If it has no boards, it actually might not exist, daft as it sounds.
// But it's more tricky than that, too! We need to be at the board index, not in a child board.
if (!empty($board)) {
return;
}
call_integration_hook('shd_hook_boardindex_before', array(&$boardIndexOptions, &$categories));
// OK, so what helpdesks are we displaying?
$depts = shd_allowed_to('access_helpdesk', false);
if (empty($depts)) {
return;
}
$cat_list = array();
$query = $smcFunc['db_query']('', '
SELECT id_dept, dept_name, description, board_cat, before_after
FROM {db_prefix}helpdesk_depts
WHERE id_dept IN ({array_int:depts})
ORDER BY before_after DESC, dept_order', array('depts' => $depts));
$depts = array_flip($depts);
while ($row = $smcFunc['db_fetch_assoc']($query)) {
if ($row['board_cat'] == 0) {
unset($depts[$row['id_dept']]);
continue;
}
$depts[$row['id_dept']] = $row;
$cat_list[] = $row['board_cat'];
$context['dept_list'][$row['id_dept']] = array('id_dept' => $row['id_dept'], 'dept_name' => $row['dept_name'], 'dept_desc' => $row['description'], 'tickets' => array('open' => 0, 'closed' => 0, 'assigned' => 0), 'new' => false);
}
if (empty($context['dept_list'])) {
return;
}
$cat_list = array_unique($cat_list);
// Do we have all these categories?
foreach ($cat_list as $k => $v) {
if (!empty($categories[$v])) {
unset($cat_list[$k]);
}
}
if (!empty($cat_list)) {
// Uh oh, we have to load a category or two.
$new_cats = array();
$request = $smcFunc['db_query']('', '
SELECT c.id_cat, c.name, c.can_collapse, IFNULL(cc.id_member, 0) AS is_collapsed
FROM {db_prefix}categories AS c
LEFT JOIN {db_prefix}collapsed_categories AS cc ON (cc.id_cat = c.id_cat AND cc.id_member = {int:current_member})
WHERE c.id_cat IN ({array_int:cat})', array('cat' => $cat_list, 'current_member' => $context['user']['id']));
while ($this_cat = $smcFunc['db_fetch_assoc']($request)) {
$new_cats[$this_cat['id_cat']] = array('id' => $this_cat['id_cat'], 'name' => $this_cat['name'], 'is_collapsed' => isset($this_cat['can_collapse']) && $this_cat['can_collapse'] == 1 && $this_cat['is_collapsed'] > 0, 'can_collapse' => isset($this_cat['can_collapse']) && $this_cat['can_collapse'] == 1, 'collapse_href' => isset($this_cat['can_collapse']) ? $scripturl . '?action=collapse;c=' . $this_cat['id_cat'] . ';sa=' . ($this_cat['is_collapsed'] > 0 ? 'expand;' : 'collapse;') . $context['session_var'] . '=' . $context['session_id'] . '#c' . $this_cat['id_cat'] : '', 'collapse_image' => isset($this_cat['can_collapse']) ? '<img src="' . $settings['images_url'] . '/' . ($this_cat['is_collapsed'] > 0 ? 'expand.png" alt="+"' : 'collapse.png" alt="-"') . ' />' : '', 'href' => $scripturl . '#c' . $this_cat['id_cat'], 'boards' => array(), 'new' => false);
$new_cats[$this_cat['id_cat']]['link'] = '<a id="c' . $this_cat['id_cat'] . '" href="' . (isset($this_cat['can_collapse']) ? $new_cats[$this_cat['id_cat']]['collapse_href'] : $new_cats[$this_cat['id_cat']]['href']) . '">' . $this_cat['name'] . '</a>';
}
$smcFunc['db_free_result']($request);
// So, did we add any new categories? If we didn't, something's wrong - abort safely NOW.
if (empty($new_cats)) {
return;
}
// OK, so we have some categories to integrate.
$old_cats = $categories;
$categories = array();
$request = $smcFunc['db_query']('', '
SELECT id_cat
FROM {db_prefix}categories
ORDER BY cat_order');
while ($row = $smcFunc['db_fetch_assoc']($request)) {
if (isset($old_cats[$row['id_cat']])) {
$categories[$row['id_cat']] = $old_cats[$row['id_cat']];
} elseif (isset($new_cats[$row['id_cat']])) {
$categories[$row['id_cat']] = $new_cats[$row['id_cat']];
}
}
$smcFunc['db_free_result']($request);
}
// So, OK, the categories exist. Now we need to create our magic boards, and integrate them.
// First we do the after's, in order.
foreach ($depts as $dept) {
if (empty($dept['before_after'])) {
continue;
}
$dept['link'] = count($depts) != 0 ? ';dept=' . $dept['id_dept'] : '';
$new_board = shd_dept_board($dept);
$categories[$dept['board_cat']]['boards'][$new_board['id']] = $new_board;
}
// OK, now for the before's. Because we're merging, that means we're doing them last-first.
$depts = array_reverse($depts);
foreach ($depts as $dept) {
if (!empty($dept['before_after'])) {
continue;
}
$dept['link'] = count($depts) != 0 ? ';dept=' . $dept['id_dept'] : '';
$new_board = shd_dept_board($dept);
$categories[$dept['board_cat']]['boards'] = array_merge(array($new_board['id'] => $new_board), $categories[$dept['board_cat']]['boards']);
}
// Last but not least, fix up the replacements and some figuring out.
shd_get_ticket_counts();
shd_get_unread_departments();
if (empty($context['shd_buffer_preg_replacements'])) {
$context['shd_buffer_preg_replacements'] = array();
}
foreach ($context['dept_list'] as $dept => $dept_details) {
//.........这里部分代码省略.........
示例5: shd_load_canned_replies
/**
* Loads the possible permutations of canned replies.
*
* @since 2.0
*/
function shd_load_canned_replies()
{
global $context, $smcFunc, $user_info;
if ($context['user']['is_admin'] || shd_allowed_to('admin_helpdesk', $context['shd_department'])) {
$visible = '';
} elseif (shd_allowed_to('shd_staff', $context['shd_department'])) {
$visible = '
AND hdcr.vis_staff = 1';
} else {
$visible = '
AND hdcr.vis_user = 1';
}
$context['canned_replies'] = array();
$query = $smcFunc['db_query']('', '
SELECT hdcr.id_reply, hdcr.title, hdcrc.id_cat, hdcrc.cat_name
FROM {db_prefix}helpdesk_cannedreplies AS hdcr
INNER JOIN {db_prefix}helpdesk_cannedreplies_cats AS hdcrc ON (hdcr.id_cat = hdcrc.id_cat)
INNER JOIN {db_prefix}helpdesk_cannedreplies_depts AS hdcrd ON (hdcrd.id_reply = hdcr.id_reply)
WHERE hdcrd.id_dept = {int:dept}
AND hdcr.active = 1' . $visible . '
ORDER BY hdcrc.cat_order, hdcr.reply_order', array('dept' => $context['shd_department']));
while ($row = $smcFunc['db_fetch_assoc']($query)) {
if (!isset($context['canned_replies'][$row['id_cat']])) {
$context['canned_replies'][$row['id_cat']] = array('name' => $row['cat_name'], 'replies' => array());
}
$context['canned_replies'][$row['id_cat']]['replies'][$row['id_reply']] = $row['title'];
}
}
示例6: shd_attachment_info
function shd_attachment_info($attach_info)
{
global $scripturl, $context, $modSettings, $txt, $sourcedir, $smcFunc;
$filename = preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', htmlspecialchars($attach_info['filename']));
$deleteable = shd_allowed_to('shd_delete_attachment', $context['ticket']['dept']);
$attach = array('id' => $attach_info['id_attach'], 'name' => $filename, 'size' => round($attach_info['filesize'] / 1024, 2) . ' ' . $txt['kilobyte'], 'byte_size' => $attach_info['filesize'], 'href' => $scripturl . '?action=dlattach;ticket=' . $context['ticket_id'] . '.0;attach=' . $attach_info['id_attach'], 'link' => shd_attach_icon($filename) . ' <a href="' . $scripturl . '?action=dlattach;ticket=' . $context['ticket_id'] . '.0;attach=' . $attach_info['id_attach'] . '">' . htmlspecialchars($attach_info['filename']) . '</a>', 'is_image' => !empty($modSettings['attachmentShowImages']) && !empty($attach_info['width']) && !empty($attach_info['height']), 'can_delete' => $deleteable);
if ($attach['is_image']) {
$attach += array('real_width' => $attach_info['width'], 'width' => $attach_info['width'], 'real_height' => $attach_info['height'], 'height' => $attach_info['height']);
// Let's see, do we want thumbs?
if (!empty($modSettings['attachmentThumbnails']) && !empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && ($attach_info['width'] > $modSettings['attachmentThumbWidth'] || $attach_info['height'] > $modSettings['attachmentThumbHeight']) && strlen($attach_info['filename']) < 249) {
// A proper thumb doesn't exist yet? Create one!
if (empty($attach_info['id_thumb']) || $attach_info['thumb_width'] > $modSettings['attachmentThumbWidth'] || $attach_info['thumb_height'] > $modSettings['attachmentThumbHeight'] || $attach_info['thumb_width'] < $modSettings['attachmentThumbWidth'] && $attach_info['thumb_height'] < $modSettings['attachmentThumbHeight']) {
$filename = getAttachmentFilename($attach_info['filename'], $attach_info['id_attach'], $attach_info['id_folder']);
require_once $sourcedir . '/Subs-Graphics.php';
if (createThumbnail($filename, $modSettings['attachmentThumbWidth'], $modSettings['attachmentThumbHeight'])) {
// So what folder are we putting this image in?
if (!empty($modSettings['currentAttachmentUploadDir'])) {
if (!is_array($modSettings['attachmentUploadDir'])) {
$modSettings['attachmentUploadDir'] = json_decode($modSettings['attachmentUploadDir'], true);
}
$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
$id_folder_thumb = $modSettings['currentAttachmentUploadDir'];
} else {
$path = $modSettings['attachmentUploadDir'];
$id_folder_thumb = 1;
}
// Calculate the size of the created thumbnail.
$size = @getimagesize($filename . '_thumb');
list($attach_info['thumb_width'], $attach_info['thumb_height']) = $size;
$thumb_size = filesize($filename . '_thumb');
// These are the only valid image types for SMF.
$validImageTypes = array(1 => 'gif', 2 => 'jpeg', 3 => 'png', 5 => 'psd', 6 => 'bmp', 7 => 'tiff', 8 => 'tiff', 9 => 'jpeg', 14 => 'iff');
// What about the extension?
$thumb_ext = isset($validImageTypes[$size[2]]) ? $validImageTypes[$size[2]] : '';
// Figure out the mime type.
if (!empty($size['mime'])) {
$thumb_mime = $size['mime'];
} else {
$thumb_mime = 'image/' . $thumb_ext;
}
$thumb_filename = $attach_info['filename'] . '_thumb';
$thumb_hash = getAttachmentFilename($thumb_filename, false, null, true);
// Add this beauty to the database.
$smcFunc['db_insert']('', '{db_prefix}attachments', array('id_folder' => 'int', 'id_msg' => 'int', 'attachment_type' => 'int', 'filename' => 'string', 'file_hash' => 'string', 'size' => 'int', 'width' => 'int', 'height' => 'int', 'fileext' => 'string', 'mime_type' => 'string'), array($id_folder_thumb, 0, 3, $thumb_filename, $thumb_hash, (int) $thumb_size, (int) $attach_info['thumb_width'], (int) $attach_info['thumb_height'], $thumb_ext, $thumb_mime), array('id_attach'));
$old_id_thumb = $attach_info['id_thumb'];
$attach_info['id_thumb'] = $smcFunc['db_insert_id']('{db_prefix}attachments', 'id_attach');
if (!empty($attach_info['id_thumb'])) {
// Update the tables to notify that we has us a thumbnail
$smcFunc['db_query']('', '
UPDATE {db_prefix}attachments
SET id_thumb = {int:id_thumb}
WHERE id_attach = {int:id_attach}', array('id_thumb' => $attach_info['id_thumb'], 'id_attach' => $attach_info['id_attach']));
$smcFunc['db_insert']('replace', '{db_prefix}helpdesk_attachments', array('id_attach' => 'int', 'id_ticket' => 'int', 'id_msg' => 'int'), array($attach_info['id_thumb'], $attach_info['id_ticket'], $attach_info['id_msg']), array('id_attach'));
$thumb_realname = getAttachmentFilename($thumb_filename, $attach_info['id_thumb'], $id_folder_thumb, false, $thumb_hash);
rename($filename . '_thumb', $thumb_realname);
// Do we need to remove an old thumbnail?
if (!empty($old_id_thumb)) {
require_once $sourcedir . '/ManageAttachments.php';
removeAttachments(array('id_attach' => $old_id_thumb), '', false, false);
}
}
}
}
// Only adjust dimensions on successful thumbnail creation.
if (!empty($attach_info['thumb_width']) && !empty($attach_info['thumb_height'])) {
$attach['width'] = $attach_info['thumb_width'];
$attach['height'] = $attach_info['thumb_height'];
}
}
if (!empty($attach_info['id_thumb'])) {
$attach['thumbnail'] = array('id' => $attach_info['id_thumb'], 'href' => $scripturl . '?action=dlattach;ticket=' . $context['ticket_id'] . '.0;attach=' . $attach_info['id_thumb'] . ';image');
}
$attach['thumbnail']['has_thumb'] = !empty($attach_info['id_thumb']);
// If thumbnails are disabled, check the maximum size of the image.
if (!$attach['thumbnail']['has_thumb'] && (!empty($modSettings['max_image_width']) && $attach_info['width'] > $modSettings['max_image_width'] || !empty($modSettings['max_image_height']) && $attach_info['height'] > $modSettings['max_image_height'])) {
if (!empty($modSettings['max_image_width']) && (empty($modSettings['max_image_height']) || $attach_info['height'] * $modSettings['max_image_width'] / $attach_info['width'] <= $modSettings['max_image_height'])) {
$attach['width'] = $modSettings['max_image_width'];
$attach['height'] = floor($attach_info['height'] * $modSettings['max_image_width'] / $attach_info['width']);
} elseif (!empty($modSettings['max_image_width'])) {
$attach['width'] = floor($attach['width'] * $modSettings['max_image_height'] / $attach['height']);
$attach['height'] = $modSettings['max_image_height'];
}
} elseif ($attach['thumbnail']['has_thumb']) {
// Make it a popup (since invariably it'll break the layout otherwise)
$attach['thumbnail']['javascript'] = 'return reqWin(\'' . $attach['href'] . ';image\', ' . ($attach_info['width'] + 20) . ', ' . ($attach_info['height'] + 20) . ', true);';
}
}
return $attach;
}
示例7: shd_get_postable_depts
function shd_get_postable_depts()
{
global $context, $smcFunc;
$depts = shd_allowed_to('shd_new_ticket', false);
$context['postable_dept_list'] = array();
$context['ticket_form']['custom_field_dept'] = 0;
if (!empty($depts)) {
$query = $smcFunc['db_query']('', '
SELECT id_dept, dept_name
FROM {db_prefix}helpdesk_depts
WHERE id_dept IN ({array_int:depts})
ORDER BY dept_order', array('depts' => $depts));
while ($row = $smcFunc['db_fetch_assoc']($query)) {
$context['postable_dept_list'][$row['id_dept']] = $row['dept_name'];
}
$smcFunc['db_free_result']($query);
// We do actually need to get the first one for the purposes of custom fields. But only the first one.
foreach ($context['postable_dept_list'] as $id => $dept) {
$context['ticket_form']['custom_field_dept'] = $id;
break;
}
}
}
示例8: shd_unread_posts
/**
* Handles fetching the information for the helpdesk display within the unread and unread replies pages.
*
* The content is 'appended' below the unread posts information by way of a template layer.
*
* @since 2.0
*/
function shd_unread_posts()
{
global $smcFunc, $context, $user_info, $sourcedir, $txt, $scripturl, $user_profile, $modSettings;
// Are we using Dragooon's very swish mobile theme, or other wireless? If so, disable this.
if (WIRELESS || isset($_REQUEST['thememode']) && $_REQUEST['thememode'] == 'mobile' || isset($_COOKIE['smf4m_cookie']) && $_COOKIE['smf4m_cookie'] == 'mobile') {
$modSettings['shd_disable_unread'] = true;
}
// We're only displaying this to staff. We didn't do this check on bootstrapping, no sense doing it every page load.
if (shd_allowed_to('shd_staff', 0) && empty($modSettings['shd_disable_unread'])) {
// Get the data
$context['shd_preferences'] = shd_load_user_prefs();
$context['shd_unread_info'] = array();
if (empty($context['shd_preferences']['display_unread_type']) || $context['shd_preferences']['display_unread_type'] == 'outstanding') {
// Get all the outstanding tickets
$context['block_title'] = $txt['shd_tickets_open'];
$request = shd_db_query('', '
SELECT hdt.id_ticket, hdt.subject, hdt.id_ticket, hdt.num_replies, hdt.last_updated,
hdtr_first.poster_name, hdt.urgency, hdt.status, hdt.id_member_started, hdt.id_member_assigned, hdt.id_last_msg AS log_read
FROM {db_prefix}helpdesk_tickets AS hdt
INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr_first ON (hdt.id_first_msg = hdtr_first.id_msg)
INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr_last ON (hdt.id_last_msg = hdtr_last.id_msg)
WHERE {query_see_ticket}
AND hdt.status IN ({array_int:status})
ORDER BY hdt.urgency DESC, hdt.last_updated', array('status' => array(TICKET_STATUS_NEW, TICKET_STATUS_PENDING_STAFF)));
} elseif ($context['shd_preferences']['display_unread_type'] == 'unread') {
// Only unread ones
$context['block_title'] = $txt['shd_unread_tickets'];
$request = shd_db_query('', '
SELECT hdt.id_ticket, hdt.subject, hdt.id_ticket, hdt.num_replies, hdt.last_updated,
hdtr_first.poster_name, hdt.urgency, hdt.status, hdt.id_member_started, hdt.id_member_assigned, IFNULL(hdlr.id_msg, 0) AS log_read
FROM {db_prefix}helpdesk_tickets AS hdt
INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr_first ON (hdt.id_first_msg = hdtr_first.id_msg)
INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr_last ON (hdt.id_last_msg = hdtr_last.id_msg)
LEFT JOIN {db_prefix}helpdesk_log_read AS hdlr ON (hdt.id_ticket = hdlr.id_ticket AND hdlr.id_member = {int:user})
WHERE {query_see_ticket}
AND hdt.status IN ({array_int:status})
AND (hdlr.id_msg IS NULL OR hdlr.id_msg < hdt.id_last_msg)
ORDER BY hdt.urgency DESC, hdt.last_updated', array('user' => $context['user']['id'], 'status' => array(TICKET_STATUS_NEW, TICKET_STATUS_PENDING_STAFF)));
}
if (!empty($request)) {
$members = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$row['id_ticket_display'] = str_pad($row['id_ticket'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT);
$row['updated'] = timeformat($row['last_updated']);
$context['shd_unread_info'][] = $row;
if ($row['id_member_started'] != 0) {
$members[] = $row['id_member_started'];
}
if ($row['id_member_assigned'] != 0) {
$members[] = $row['id_member_assigned'];
}
}
loadMemberData(array_unique($members));
foreach ($context['shd_unread_info'] as $key => $ticket) {
if (!empty($user_profile[$ticket['id_member_started']])) {
$context['shd_unread_info'][$key]['ticket_starter'] = shd_profile_link($user_profile[$ticket['id_member_started']]['member_name'], $ticket['id_member_started']);
} else {
$context['shd_unread_info'][$key]['ticket_starter'] = $ticket['poster_name'];
}
if (!empty($user_profile[$ticket['id_member_assigned']])) {
$context['shd_unread_info'][$key]['ticket_assigned'] = shd_profile_link($user_profile[$ticket['id_member_assigned']]['member_name'], $ticket['id_member_assigned']);
} else {
$context['shd_unread_info'][$key]['ticket_assigned'] = '<span class="error">' . $txt['shd_unassigned'] . '</span>';
}
}
// And set up the template too.
loadTemplate('sd_template/SimpleDesk-Unread', 'helpdesk');
$context['template_layers'][] = 'shd_unread';
}
}
// OK, time to get out of here. If we're here, it's because we have a $_REQUEST['action'] of 'unread' or 'unreadreplies', both of which
// are defined in $context['shd_unread_actions'] thanks to shd_init_actions back in Subs-SimpleDesk.php.
require_once $sourcedir . '/' . $context['shd_unread_actions'][$_REQUEST['action']][0];
$context['shd_unread_actions'][$_REQUEST['action']][1]();
}
示例9: template_search
/**
* Displays the list of possible searching criteria.
*
* @see shd_search()
* @since 2.0
*/
function template_search()
{
global $context, $txt, $scripturl, $settings, $modSettings;
// Back to the helpdesk.
echo '
<div class="floatleft">
', template_button_strip(array($context['navigation']['back']), 'bottom'), '
</div><br class="clear" /><br />';
if (!empty($modSettings['shd_new_search_index'])) {
echo '
<div class="errorbox"><img src="', $settings['default_images_url'], '/simpledesk/warning.png" alt="*" class="shd_icon_minihead" /> ', shd_allowed_to('admin_helpdesk', 0) ? $txt['shd_search_warning_admin'] : $txt['shd_search_warning_nonadmin'], '</div>';
}
echo '
<div class="cat_bar">
<h3 class="catbg">
<img src="', $settings['default_images_url'], '/simpledesk/search.png" alt="*" />
', $txt['shd_search'], '
</h3>
</div>
<div class="roundframe">
<form action="', $scripturl, '?action=helpdesk;sa=search2" method="post">
<div class="content">
<br />
<dl class="settings">
<dt>
<strong>', $txt['shd_search_text'], '</strong>
</dt>
<dd>
<input type="text" name="search" value="" size="40" maxlength="100" class="input_text" />
</dd>
<dt>
<strong>', $txt['shd_search_match'], '</strong>
</dt>
<dd>
<select name="searchtype">
<option value="all">', $txt['shd_search_match_all'], '</option>
<option value="any">', $txt['shd_search_match_any'], '</option>
</select>
</dd>
</dl>
<br />
<dl class="settings">
<dt>
<strong>', $txt['shd_search_where'], '</strong>
</dt>
<dd>
<input type="checkbox" class="input_check" checked="checked" name="search_subjects" /> ', $txt['shd_search_where_subjects'], '<br />
<input type="checkbox" class="input_check" checked="checked" name="search_tickets" /> ', $txt['shd_search_where_tickets'], '<br />
<input type="checkbox" class="input_check" checked="checked" name="search_replies" /> ', $txt['shd_search_where_replies'], '<br />
</dd>
</dl>';
if (count($context['dept_list']) == 1) {
$array = array_keys($context['dept_list']);
echo '
<input type="hidden" name="search_dept[]" value="', $array[0], '" />';
} else {
echo '
<hr />
<dl class="settings">
<dt>
<strong>', $txt['shd_search_dept'], '</strong>
</dt>
<dd>';
foreach ($context['dept_list'] as $id => $name) {
echo '
<input type="checkbox" class="input_check" checked="checked" name="search_dept[]" value="', $id, '" /> ', $name, '<br />';
}
echo '
</dd>
</dl>';
}
echo '
<hr />
<dl class="settings">
<dt>
<strong>', $txt['shd_search_scope'], '</strong>
</dt>
<dd>
<input type="checkbox" class="input_check" checked="checked" name="scope_open" /> ', $txt['shd_search_scope_open'], '<br />
<input type="checkbox" class="input_check" checked="checked" name="scope_closed" /> ', $txt['shd_search_scope_closed'], '<br />
<input type="checkbox" class="input_check" checked="checked" name="scope_recycle" /> ', $txt['shd_search_scope_recycle'], '<br />
</dd>
</dl>
<hr />
<dl class="settings">
<dt>
<strong>', $txt['shd_search_urgency'], '</strong>
</dt>
<dd>';
// All the urgency levels, currently 0-5.
for ($i = 0; $i <= 5; $i++) {
echo '
<input type="checkbox" class="input_check" checked="checked" name="urgency[]" value="', $i, '" /> ', $txt['shd_urgency_' . $i], '<br />';
}
//.........这里部分代码省略.........
示例10: shd_movedept2
/**
* Handles the actual assignment form, validates it and carries it out.
*
* Primarily this is just about receiving the form, making the same checks that {@link shd_movedept()} does and then
* logging the action before updating the database.
*
* @see shd_movedept()
* @since 2.0
*/
function shd_movedept2()
{
global $context, $smcFunc, $user_info, $sourcedir, $txt, $scripturl;
checkSession();
checkSubmitOnce('check');
if (empty($context['ticket_id'])) {
fatal_lang_error('shd_no_ticket', false);
}
if (isset($_POST['send_pm']) && (!isset($_POST['pm_content']) || trim($_POST['pm_content']) == '') && (empty($modSettings['shd_helpdesk_only']) || empty($modSettings['shd_disable_pm']))) {
fatal_lang_error('shd_move_no_pm', false);
}
// Just in case, are they cancelling?
if (isset($_REQUEST['cancel'])) {
redirectexit('action=helpdesk;sa=ticket;ticket=' . $context['ticket_id']);
}
if (empty($context['shd_multi_dept'])) {
fatal_lang_error('shd_cannot_move_dept', false);
}
$dest = isset($_REQUEST['to_dept']) ? (int) $_REQUEST['to_dept'] : 0;
if (empty($dest) || !shd_allowed_to('access_helpdesk', $dest)) {
fatal_lang_error('shd_cannot_move_dept', false);
}
$context['shd_return_to'] = isset($_REQUEST['home']) ? 'home' : 'ticket';
// Get ticket details - and kick it out if they shouldn't be able to see it.
$query = shd_db_query('', '
SELECT id_member_started, subject, hdt.id_dept, dept_name
FROM {db_prefix}helpdesk_tickets AS hdt
INNER JOIN {db_prefix}helpdesk_depts AS hdd ON (hdt.id_dept = hdd.id_dept)
WHERE {query_see_ticket} AND id_ticket = {int:ticket}', array('ticket' => $context['ticket_id']));
$log_params = array();
if ($row = $smcFunc['db_fetch_row']($query)) {
list($ticket_starter, $subject, $context['current_dept'], $context['current_dept_name']) = $row;
} else {
$smcFunc['db_free_result']($query);
fatal_lang_error('shd_no_ticket');
}
$smcFunc['db_free_result']($query);
if ($context['current_dept'] == $dest) {
fatal_lang_error('shd_cannot_move_dept', false);
}
if (shd_allowed_to('shd_move_dept_any', $context['current_dept']) || shd_allowed_to('shd_move_dept_own', $context['current_dept']) && $ticket_starter == $user_info['id']) {
// Find the new department. We've already established the user can see it, but we need its name.
$query = $smcFunc['db_query']('', '
SELECT id_dept, dept_name
FROM {db_prefix}helpdesk_depts
WHERE id_dept IN ({int:dest})', array('dest' => $dest));
list($new_dept, $dept_name) = $smcFunc['db_fetch_row']($query);
$smcFunc['db_free_result']($query);
// Just before we move, call any interesting hooks. We do normally have a lot of fun staff in $context and $_POST, but the department ID and name aren't in either.
call_integration_hook('shd_hook_movedept', array(&$new_dept, &$dept_name));
$log_params = array('subject' => $subject, 'ticket' => $context['ticket_id'], 'old_dept_id' => $context['current_dept'], 'old_dept_name' => $context['current_dept_name'], 'new_dept_id' => $new_dept, 'new_dept_name' => $dept_name);
shd_log_action('move_dept', $log_params);
$smcFunc['db_query']('', '
UPDATE {db_prefix}helpdesk_tickets
SET id_dept = {int:new_dept}
WHERE id_ticket = {int:ticket}', array('new_dept' => $new_dept, 'ticket' => $context['ticket_id']));
// Now, notify the ticket starter if that's what we wanted to do.
if (isset($_POST['send_pm'])) {
require_once $sourcedir . '/Subs-Post.php';
$request = shd_db_query('pm_find_username', '
SELECT id_member, real_name
FROM {db_prefix}members
WHERE id_member = {int:user}
LIMIT 1', array('user' => $ticket_starter));
list($userid, $username) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
// Fix the content
$replacements = array('{user}' => $username, '{subject}' => $subject, '{current_dept}' => $context['current_dept_name'], '{new_dept}' => $dept_name, '{link}' => $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $context['ticket_id']);
$message = str_replace(array_keys($replacements), array_values($replacements), $_POST['pm_content']);
$recipients = array('to' => array($ticket_starter), 'bcc' => array());
sendpm($recipients, $txt['shd_ticket_moved_subject'], un_htmlspecialchars($message));
}
shd_clear_active_tickets($context['current_dept']);
shd_clear_active_tickets($new_dept);
if (!empty($context['shd_return_to']) && $context['shd_return_to'] == 'home') {
redirectexit($context['shd_home'] . ';dept=' . $new_dept);
} else {
redirectexit('action=helpdesk;sa=ticket;ticket=' . $context['ticket_id']);
}
} else {
fatal_lang_error('shd_no_perm_move_dept', false);
}
}
示例11: shd_admin_bootstrap
/**
* Perform all the operations required for SimpleDesk to safely start operations inside the admin panel.
*
* @param array &$admin_areas The full admin area array from SMF's Admin.php.
* @since 2.0
*/
function shd_admin_bootstrap(&$admin_areas)
{
global $sourcedir, $modSettings, $txt, $context, $scripturl;
// Load the main admin language files and any needed for SD plugins in the admin panel.
require_once $sourcedir . '/sd_source/SimpleDesk-Admin.php';
shd_load_language('sd_language/SimpleDeskAdmin');
shd_load_plugin_files('hdadmin');
shd_load_plugin_langfiles('hdadmin');
// Now add the main SimpleDesk menu
if (!empty($modSettings['helpdesk_active'])) {
// The helpdesk action log
if (empty($modSettings['shd_disable_action_log'])) {
$admin_areas['maintenance']['areas']['logs']['subsections']['helpdesklog'] = array($txt['shd_admin_helpdesklog'], 'admin_forum', 'url' => $scripturl . '?action=admin;area=helpdesk_info;sa=actionlog');
}
// The main menu
$admin_areas['helpdesk_info'] = array('title' => $txt['shd_helpdesk'], 'enabled' => allowedTo('admin_forum') || shd_allowed_to('admin_helpdesk', 0), 'areas' => array('helpdesk_info' => array('label' => $txt['shd_admin_info'], 'file' => 'sd_source/SimpleDesk-Admin.php', 'icon' => 'shd/simpledesk.png', 'function' => 'shd_admin_main', 'subsections' => array('main' => array($txt['shd_admin_info']), 'actionlog' => array($txt['shd_admin_actionlog'], 'enabled' => empty($modSettings['shd_disable_action_log'])), 'support' => array($txt['shd_admin_support']))), 'helpdesk_options' => array('label' => $txt['shd_admin_options'], 'file' => 'sd_source/SimpleDesk-Admin.php', 'icon' => 'shd/options.png', 'function' => 'shd_admin_main', 'subsections' => array('display' => array($txt['shd_admin_options_display']), 'posting' => array($txt['shd_admin_options_posting']), 'admin' => array($txt['shd_admin_options_admin']), 'standalone' => array($txt['shd_admin_options_standalone']), 'actionlog' => array($txt['shd_admin_options_actionlog']), 'notifications' => array($txt['shd_admin_options_notifications']))), 'helpdesk_cannedreplies' => array('label' => $txt['shd_admin_cannedreplies'], 'file' => 'sd_source/SimpleDesk-Admin.php', 'icon' => 'shd/cannedreplies.png', 'function' => 'shd_admin_main', 'subsections' => array()), 'helpdesk_customfield' => array('label' => $txt['shd_admin_custom_fields'], 'file' => 'sd_source/SimpleDesk-Admin.php', 'icon' => 'shd/custom_fields.png', 'function' => 'shd_admin_main', 'subsections' => array()), 'helpdesk_depts' => array('label' => $txt['shd_admin_departments'], 'file' => 'sd_source/SimpleDesk-Admin.php', 'icon' => 'shd/departments.png', 'function' => 'shd_admin_main', 'subsections' => array()), 'helpdesk_permissions' => array('label' => $txt['shd_admin_permissions'], 'file' => 'sd_source/SimpleDesk-Admin.php', 'icon' => 'shd/permissions.png', 'function' => 'shd_admin_main', 'subsections' => array()), 'helpdesk_plugins' => array('label' => $txt['shd_admin_plugins'], 'file' => 'sd_source/SimpleDesk-Admin.php', 'icon' => 'shd/plugins.png', 'function' => 'shd_admin_main', 'subsections' => array()), 'helpdesk_maint' => array('label' => $txt['shd_admin_maint'], 'file' => 'sd_source/SimpleDesk-Admin.php', 'icon' => 'shd/maintenance.png', 'function' => 'shd_admin_main', 'subsections' => array('main' => array($txt['shd_admin_maint']), 'search' => array($txt['shd_maint_search_settings'])))));
// Now engage any hooks.
call_integration_hook('shd_hook_adminmenu', array(&$admin_areas));
}
}
示例12: shd_notify_ticket_options
function shd_notify_ticket_options()
{
global $context, $txt, $smcFunc;
$ticketinfo = shd_load_ticket();
// This does permissions to access the ticket too.
$ticket_starter = $ticketinfo['starter_id'] == $context['user']['id'];
checkSession();
if (empty($_REQUEST['notifyaction'])) {
$_REQUEST['notifyaction'] = '';
}
// Get any existing entry.
$query = $smcFunc['db_query']('', '
SELECT notify_state
FROM {db_prefix}helpdesk_notify_override
WHERE id_member = {int:user}
AND id_ticket = {int:ticket}', array('user' => $context['user']['id'], 'ticket' => $context['ticket_id']));
if ($smcFunc['db_num_rows']($query) == 0) {
$old_state = NOTIFY_PREFS;
} else {
list($old_state) = $smcFunc['db_fetch_row']($query);
}
$smcFunc['db_free_result']($query);
switch ($_REQUEST['notifyaction']) {
case 'monitor_on':
if (!shd_allowed_to('shd_monitor_ticket_any', $ticketinfo['dept']) && (!$ticket_starter || !shd_allowed_to('shd_monitor_ticket_own', $ticketinfo['dept']))) {
fatal_lang_error('cannot_monitor_ticket', false);
}
// Unlike turning it off, we might be turning it on from either just off, or ignored, so log that fact.
if ($old_state == NOTIFY_ALWAYS) {
break;
} elseif ($old_state == NOTIFY_NEVER) {
// Log turning off ignore list first
shd_log_action('unignore', array('ticket' => $context['ticket_id'], 'subject' => $ticketinfo['subject']));
}
// Then add the new status.
$smcFunc['db_insert']('replace', '{db_prefix}helpdesk_notify_override', array('id_member' => 'int', 'id_ticket' => 'int', 'notify_state' => 'int'), array($context['user']['id'], $context['ticket_id'], NOTIFY_ALWAYS), array('id_member', 'id_ticket'));
shd_log_action('monitor', array('ticket' => $context['ticket_id'], 'subject' => $ticketinfo['subject']));
break;
case 'monitor_off':
if (!shd_allowed_to('shd_monitor_ticket_any', $ticketinfo['dept']) && (!$ticket_starter || !shd_allowed_to('shd_monitor_ticket_own', $ticketinfo['dept']))) {
fatal_lang_error('cannot_unmonitor_ticket', false);
}
// Just delete the old status.
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}helpdesk_notify_override
WHERE id_member = {int:member}
AND id_ticket = {int:ticket}', array('member' => $context['user']['id'], 'ticket' => $context['ticket_id']));
shd_log_action('unmonitor', array('ticket' => $context['ticket_id'], 'subject' => $ticketinfo['subject']));
break;
case 'ignore_on':
if (!shd_allowed_to('shd_ignore_ticket_any', $ticketinfo['dept']) && (!$ticket_starter || !shd_allowed_to('shd_ignore_ticket_own', $ticketinfo['dept']))) {
fatal_lang_error('cannot_monitor_ticket', false);
}
// Unlike turning it off, we might be turning it on from either just off, or ignored, so log that fact.
if ($old_state == NOTIFY_NEVER) {
break;
} elseif ($old_state == NOTIFY_ALWAYS) {
// Log turning off ignore list first
shd_log_action('unmonitor', array('ticket' => $context['ticket_id'], 'subject' => $ticketinfo['subject']));
}
$smcFunc['db_insert']('replace', '{db_prefix}helpdesk_notify_override', array('id_member' => 'int', 'id_ticket' => 'int', 'notify_state' => 'int'), array($context['user']['id'], $context['ticket_id'], NOTIFY_NEVER), array('id_member', 'id_ticket'));
shd_log_action('ignore', array('ticket' => $context['ticket_id'], 'subject' => $ticketinfo['subject']));
break;
case 'ignore_off':
if (!shd_allowed_to('shd_ignore_ticket_any', $ticketinfo['dept']) && (!$ticket_starter || !shd_allowed_to('shd_ignore_ticket_own', $ticketinfo['dept']))) {
fatal_lang_error('cannot_unmonitor_ticket', false);
}
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}helpdesk_notify_override
WHERE id_member = {int:member}
AND id_ticket = {int:ticket}', array('member' => $context['user']['id'], 'ticket' => $context['ticket_id']));
shd_log_action('unignore', array('ticket' => $context['ticket_id'], 'subject' => $ticketinfo['subject']));
break;
default:
break;
}
redirectexit('action=helpdesk;sa=ticket;ticket=' . $context['ticket_id']);
}
示例13: shd_reply_restore
function shd_reply_restore()
{
global $smcFunc, $user_info, $context, $sourcedir;
checkSession('get');
$_REQUEST['reply'] = empty($_REQUEST['reply']) ? 0 : (int) $_REQUEST['reply'];
if (empty($_REQUEST['reply'])) {
fatal_lang_error('shd_no_ticket', false);
}
// Check we can actually see the ticket we're restoring from, and that we can restore this reply
$query_ticket = shd_db_query('', '
SELECT hdt.id_ticket, hdt.id_dept, hdtr.id_member, hdt.id_member_started, hdt.id_member_updated, hdt.num_replies, hdt.subject, hdt.status, hdtr.message_status
FROM {db_prefix}helpdesk_tickets AS hdt
INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr ON (hdt.id_ticket = hdtr.id_ticket)
WHERE {query_see_ticket}
AND hdtr.id_msg = {int:reply}
AND hdt.id_first_msg != {int:reply2}', array('reply' => $_REQUEST['reply'], 'reply2' => $_REQUEST['reply']));
if ($row = $smcFunc['db_fetch_assoc']($query_ticket)) {
$smcFunc['db_free_result']($query_ticket);
if ($row['status'] == TICKET_STATUS_DELETED || $row['status'] == TICKET_STATUS_CLOSED || $row['message_status'] != MSG_STATUS_DELETED || !shd_allowed_to('shd_restore_reply_any', $row['id_dept']) && (!shd_allowed_to('shd_restore_reply_own', $row['id_dept']) || $user_info['id'] != $row['id_member'])) {
fatal_lang_error('shd_cannot_restore_reply', false);
}
$context['ticket_id'] = (int) $row['id_ticket'];
$subject = $row['subject'];
$starter = $row['id_member_started'];
$replier = $row['id_member_updated'];
$num_replies = $row['num_replies'];
} else {
$smcFunc['db_free_result']($query_ticket);
fatal_lang_error('shd_no_ticket', false);
}
// The ticket's id is in $context['ticket_id'], the reply id in $_REQUEST['reply'].
call_integration_hook('shd_hook_restorereply');
// OK, let's clear this one, hasta la vista... ticket.
shd_db_query('', '
UPDATE {db_prefix}helpdesk_ticket_replies
SET message_status = {int:msg_status_deleted}
WHERE id_msg = {int:reply}', array('msg_status_deleted' => MSG_STATUS_NORMAL, 'reply' => $_REQUEST['reply']));
// Captain's Log, stardate 18.3.10.1010
shd_log_action('restore_reply', array('ticket' => $context['ticket_id'], 'subject' => $subject, 'msg' => $_REQUEST['reply']));
// Fix the topic data
list($starter, $replier, $num_replies) = shd_recalc_ids($context['ticket_id']);
$query_reply = shd_db_query('', '
UPDATE {db_prefix}helpdesk_tickets
SET status = {int:status}
WHERE id_ticket = {int:ticket}', array('ticket' => $context['ticket_id'], 'status' => shd_determine_status('restorereply', $starter, $replier, $num_replies, $row['id_dept'])));
// Expire the cache of count(active tickets)
shd_clear_active_tickets($row['id_dept']);
redirectexit('action=helpdesk;sa=ticket;ticket=' . $context['ticket_id']);
}
示例14: shd_admin_maint_massdeptmove
function shd_admin_maint_massdeptmove()
{
global $context, $txt, $smcFunc, $sourcedir;
checkSession('request');
$context['page_title'] = $txt['shd_admin_maint_massdeptmove'];
$depts = shd_allowed_to('access_helpdesk', false);
$_POST['id_dept_from'] = isset($_POST['id_dept_from']) ? (int) $_POST['id_dept_from'] : 0;
$_POST['id_dept_to'] = isset($_POST['id_dept_to']) ? (int) $_POST['id_dept_to'] : 0;
if ($_POST['id_dept_from'] == 0 || $_POST['id_dept_to'] == 0 || !in_array($_POST['id_dept_from'], $depts) || !in_array($_POST['id_dept_to'], $depts)) {
fatal_lang_error('shd_unknown_dept', false);
} elseif ($_POST['id_dept_from'] == $_POST['id_dept_to']) {
fatal_lang_error('shd_admin_maint_massdeptmove_samedept', false);
}
$clauses = array();
if (empty($_POST['moveopen'])) {
$clauses[] = 'AND status NOT IN (' . implode(',', array(TICKET_STATUS_NEW, TICKET_STATUS_PENDING_USER, TICKET_STATUS_PENDING_STAFF, TICKET_STATUS_WITH_SUPERVISOR, TICKET_STATUS_ESCALATED)) . ')';
}
if (empty($_POST['moveclosed'])) {
$clauses[] = 'AND status != ' . TICKET_STATUS_CLOSED;
}
if (empty($_POST['movedeleted'])) {
$clauses[] = 'AND status != ' . TICKET_STATUS_DELETED;
}
$_POST['movelast_less_days'] = isset($_POST['movelast_less_days']) && !empty($_POST['movelast_less']) ? (int) $_POST['movelast_less_days'] : 0;
if ($_POST['movelast_less_days'] > 0) {
$clauses[] = 'AND last_updated >= ' . (time() - $_POST['movelast_less_days'] * 86400);
}
$_POST['movelast_more_days'] = isset($_POST['movelast_more_days']) && !empty($_POST['movelast_more']) ? (int) $_POST['movelast_more_days'] : 0;
if ($_POST['movelast_more_days'] > 0) {
$clauses[] = 'AND last_updated < ' . (time() - $_POST['movelast_more_days'] * 86400);
}
// OK, let's start. How many tickets are there to move?
if (empty($_POST['massdeptmove'])) {
$query = $smcFunc['db_query']('', '
SELECT COUNT(*)
FROM {db_prefix}helpdesk_tickets
WHERE id_dept = {int:dept_from} ' . implode(' ', $clauses), array('dept_from' => $_POST['id_dept_from']));
list($count) = $smcFunc['db_fetch_row']($query);
$smcFunc['db_free_result']($query);
if (!empty($count)) {
$_POST['massdeptmove'] = $count;
} else {
$_GET['done'] = true;
}
}
// OK, so we know we're going to be doing some tickets, or do we?
$_POST['tickets_done'] = isset($_POST['tickets_done']) ? (int) $_POST['tickets_done'] : 0;
if (isset($_GET['done']) || $_POST['tickets_done'] >= $_POST['massdeptmove']) {
$context['sub_template'] = 'shd_admin_maint_massdeptmovedone';
return;
}
// So, do this batch.
$step_count = 10;
$tickets = array();
// We don't need to get particularly clever; whatever tickets we did in any previous batch, well, they will be gone by now.
$query = $smcFunc['db_query']('', '
SELECT id_ticket, subject
FROM {db_prefix}helpdesk_tickets
WHERE id_dept = {int:dept_from} ' . implode(' ', $clauses) . '
ORDER BY id_ticket
LIMIT {int:step}', array('dept_from' => $_POST['id_dept_from'], 'step' => $step_count));
while ($row = $smcFunc['db_fetch_assoc']($query)) {
$tickets[$row['id_ticket']] = $row['subject'];
}
$smcFunc['db_free_result']($query);
if (!empty($tickets)) {
// Get department ids.
$query = $smcFunc['db_query']('', '
SELECT id_dept, dept_name
FROM {db_prefix}helpdesk_depts
WHERE id_dept IN ({array_int:depts})', array('depts' => array($_POST['id_dept_from'], $_POST['id_dept_to'])));
$depts = array();
while ($row = $smcFunc['db_fetch_assoc']($query)) {
$depts[$row['id_dept']] = $row['dept_name'];
}
$smcFunc['db_free_result']($query);
// OK, we have the ticket ids. Now we'll move the set and log each one moved.
$smcFunc['db_query']('', '
UPDATE {db_prefix}helpdesk_tickets
SET id_dept = {int:dept_to}
WHERE id_ticket IN ({array_int:ids})', array('dept_to' => $_POST['id_dept_to'], 'ids' => array_keys($tickets)));
// This is the same every time.
$log_params = array('old_dept_id' => $_POST['id_dept_from'], 'old_dept_name' => $depts[$_POST['id_dept_from']], 'new_dept_id' => $_POST['id_dept_to'], 'new_dept_name' => $depts[$_POST['id_dept_to']]);
foreach ($tickets as $id => $subject) {
$log_params['subject'] = $subject;
$log_params['ticket'] = $id;
shd_log_action('move_dept', $log_params);
}
shd_clear_active_tickets($_POST['id_dept_from']);
shd_clear_active_tickets($_POST['id_dept_to']);
$_POST['tickets_done'] += $step_count;
}
// Prepare to shove everything we need into the form so we can go again.
$context['continue_countdown'] = 3;
$context['continue_get_data'] = '?action=admin;area=helpdesk_maint;sa=massdeptmove;' . $context['session_var'] . '=' . $context['session_id'];
$context['continue_post_data'] = '
<input type="hidden" name="id_dept_from" value="' . $_POST['id_dept_from'] . '" />
<input type="hidden" name="id_dept_to" value="' . $_POST['id_dept_to'] . '" />
<input type="hidden" name="tickets_done" value="' . $_POST['tickets_done'] . '" />
<input type="hidden" name="massdeptmove" value="' . $_POST['massdeptmove'] . '" />';
//.........这里部分代码省略.........
示例15: shd_main_menu
/**
* Add the SimpleDesk options to the main site menu.
*
* @param array &$menu_buttons The main menu buttons as provided by Subs.php.
* @since 2.0
*/
function shd_main_menu(&$menu_buttons)
{
global $context, $txt, $scripturl, $modSettings;
if (!empty($modSettings['helpdesk_active'])) {
// Stuff we'll always do in SD if active
$helpdesk_admin = $context['user']['is_admin'] || shd_allowed_to('admin_helpdesk', 0);
// 1. Add the main menu if we can.
if (shd_allowed_to(array('access_helpdesk', 'admin_helpdesk'), 0) && empty($modSettings['shd_hidemenuitem'])) {
// Because some items may have been removed at this point, let's try a list of possible places after which we can add the button.
$order = array('search', 'profile', 'forum', 'pm', 'help', 'home');
$pos = null;
foreach ($order as $item) {
if (isset($menu_buttons[$item])) {
$pos = $item;
break;
}
}
if ($pos === null) {
$menu_buttons['helpdesk'] = array();
} else {
// OK, we're adding it after something.
$temp = $menu_buttons;
$menu_buttons = array();
foreach ($temp as $k => $v) {
$menu_buttons[$k] = $v;
if ($k == $pos) {
$menu_buttons['helpdesk'] = array();
}
}
}
$menu_buttons['helpdesk'] += array('title' => $modSettings['helpdesk_active'] && SMF != 'SSI' ? shd_get_active_tickets() : $txt['shd_helpdesk'], 'href' => $scripturl . '?action=helpdesk;sa=main', 'show' => true, 'active_button' => false, 'sub_buttons' => array('newticket' => array('title' => $txt['shd_new_ticket'], 'href' => $scripturl . '?action=helpdesk;sa=newticket', 'show' => SMF == 'SSI' ? false : shd_allowed_to('shd_new_ticket', 0)), 'newproxyticket' => array('title' => $txt['shd_new_ticket_proxy'], 'href' => $scripturl . '?action=helpdesk;sa=newticket;proxy', 'show' => SMF == 'SSI' ? false : shd_allowed_to('shd_new_ticket', 0) && shd_allowed_to('shd_post_proxy', 0)), 'closedtickets' => array('title' => $txt['shd_tickets_closed'], 'href' => $scripturl . '?action=helpdesk;sa=closedtickets', 'show' => SMF == 'SSI' ? false : shd_allowed_to(array('shd_view_closed_own', 'shd_view_closed_any'), 0)), 'recyclebin' => array('title' => $txt['shd_recycle_bin'], 'href' => $scripturl . '?action=helpdesk;sa=recyclebin', 'show' => SMF == 'SSI' ? false : shd_allowed_to('shd_access_recyclebin', 0))));
if ($helpdesk_admin) {
$menu_buttons['helpdesk']['sub_buttons']['admin'] = array('title' => $txt['admin'], 'href' => $scripturl . '?action=admin;area=helpdesk_info', 'show' => SMF == 'SSI' ? false : empty($modSettings['shd_hidemenuitem']) && $helpdesk_admin, 'sub_buttons' => shd_main_menu_admin($helpdesk_admin));
}
$item = false;
foreach ($menu_buttons['helpdesk']['sub_buttons'] as $key => $value) {
if (!empty($value['show'])) {
$item = $key;
} else {
unset($menu_buttons['helpdesk']['sub_buttons'][$key]);
}
}
if (!empty($item)) {
$menu_buttons['helpdesk']['sub_buttons'][$item]['is_last'] = true;
}
}
// Add the helpdesk admin option to the admin menu, if board integration is disabled.
if (!empty($modSettings['shd_hidemenuitem']) && $helpdesk_admin) {
// It's possible the admin button got eaten already, so we may have to recreate it.
if (empty($menu_buttons['admin'])) {
$admin_menu = array('title' => $txt['admin'], 'href' => $scripturl . '?action=admin', 'show' => true, 'active_button' => false, 'sub_buttons' => array());
// Trouble is, now we've done that, it's in the wrong damn place. So step through and insert our menu into just after the SD menu
$old_menu_buttons = $menu_buttons;
$menu_buttons = array();
$added = false;
foreach ($old_menu_buttons as $area => $detail) {
if (!$added && ($area == 'moderate' || $area == 'profile')) {
$menu_buttons['admin'] = $admin_menu;
$added = true;
}
$menu_buttons[$area] = $detail;
}
}
// Make sure the button is visible if you can admin forum
$menu_buttons['admin']['show'] = true;
// Remove the is_last item
foreach ($menu_buttons['admin']['sub_buttons'] as $key => $value) {
if (!empty($value['is_last'])) {
unset($menu_buttons['admin']['sub_buttons'][$key]['is_last']);
}
}
// Add the new button
$menu_buttons['admin']['sub_buttons']['helpdesk_admin'] = array('title' => $txt['shd_helpdesk'], 'href' => $scripturl . '?action=admin;area=helpdesk_info', 'show' => true, 'is_last' => true, 'sub_buttons' => shd_main_menu_admin($helpdesk_admin));
}
if (shd_allowed_to(array('shd_view_profile_own', 'shd_view_profile_any'), 0)) {
// Hmm, this could be tricky. It's possible the main menu has been eaten by permissions at this point, so just in case, reconstruct what's missing.
if (empty($menu_buttons['profile'])) {
$profile_menu = array('title' => $txt['profile'], 'href' => $scripturl . '?action=profile', 'active_button' => false, 'sub_buttons' => array());
// Trouble is, now we've done that, it's in the wrong damn place. So step through and insert our menu into just after the SD menu
$old_menu_buttons = $menu_buttons;
$menu_buttons = array();
$added = false;
foreach ($old_menu_buttons as $area => $detail) {
$menu_buttons[$area] = $detail;
if ($area == 'helpdesk') {
$menu_buttons['profile'] = $profile_menu;
$added = true;
}
}
if (!$added) {
$menu_buttons['profile'] = $profile_menu;
}
}
// Remove the is_last item
//.........这里部分代码省略.........