/**
 *	Display the admin page for this plugin, with a custom template.
 *
 *	@since 2.0
*/
function template_shd_frontpage_admin()
{
    global $context, $settings, $txt, $modSettings;
    if (empty($modSettings['shdp_frontpage_type'])) {
        $modSettings['shdp_frontpage_type'] = 'bbcode';
    }
    if (empty($modSettings['shdp_frontpage_appear'])) {
        $modSettings['shdp_frontpage_appear'] = 'firstdefault';
    }
    echo '
	<div id="admincenter">
		<form name="adminform" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>
		<div class="tborder">
			<div class="cat_bar grid_header">
				<h3 class="catbg">
					<img src="', shd_image_url('frontpage.png'), '" class="icon" alt="*"/> ', $txt['shdp_frontpage'], '
				</h3>
			</div>
			<div class="windowbg2">
				<div class="content">
					<dl class="permsettings">
						<dt style="width: 30%;">
							<a id="setting_shdp_frontpage_appear"></a> <span><label id="label_shdp_frontpage_appear" for="shdp_frontpage_appear">', $txt['shdp_frontpage_appear'], '</label></span>
						</dt>
						<dd style="width: 68%;">
							<select name="shdp_frontpage_appear" id="shdp_frontpage_appear">
								<option value="always"', $modSettings['shdp_frontpage_appear'] == 'always' ? ' selected="selected"' : '', '>', $txt['shdp_frontpage_appear_always'], '</option>
								<option value="firstload"', $modSettings['shdp_frontpage_appear'] == 'firstload' ? ' selected="selected"' : '', '>', $txt['shdp_frontpage_appear_firstload'], '</option>
								<option value="firstdefault"', $modSettings['shdp_frontpage_appear'] == 'firstdefault' ? ' selected="selected"' : '', '>', $txt['shdp_frontpage_appear_firstdefault'], '</option>
							</select>
							</dd>
					</dl>
					<hr class="hrcolor" />
					<dl class="permsettings">
						<dt style="width: 30%;">
							<a id="setting_shdp_frontpage_type"></a> <span><label id="label_shdp_frontpage_type" for="shdp_frontpage_type">', $txt['shdp_frontpage_type'], '</label></span>
						</dt>
						<dd style="width: 68%;">
							<select name="shdp_frontpage_type" id="shdp_frontpage_type" onchange="invertBBC();">
								<option value="bbcode"', $modSettings['shdp_frontpage_type'] == 'bbcode' ? ' selected="selected"' : '', '>', $txt['shdp_frontpage_type_bbcode'], '</option>
								<option value="php"', $modSettings['shdp_frontpage_type'] == 'php' ? ' selected="selected"' : '', '>', $txt['shdp_frontpage_type_php'], '</option>
							</select>
							</dd>
						<dt style="width: 30%;">
							<a id="setting_shdp_frontpage_content"></a> <span><label id="label_shdp_frontpage_content" for="shdp_frontpage_content">Main content</label></span>
						</dt>
						<dd style="width: 68%;">';
    $editor_context =& $context['controls']['richedit'][$context['post_box_name']];
    // The postbox
    echo '
							<div id="shd_bbcbox"', $modSettings['shdp_frontpage_type'] == 'php' ? ' style="display:none;"' : '', '></div>
							<div id="shd_smileybox"', $modSettings['shdp_frontpage_type'] == 'php' ? ' style="display:none;"' : '', '></div>';
    echo template_control_richedit($context['post_box_name'], 'shd_smileybox', 'shd_bbcbox');
    echo '
							</dd>
						</dl>
						<hr class="hrcolor" />
						<div class="righttext">
							<input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['save'], '" tabindex="', $context['tabindex']++, '" accesskey="s" class="button_submit" />
						</div>
					</div>
				<span class="botslice"><span></span></span>
			</div>
			</div>
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
		</form>
	</div>
	<script type="text/javascript"><!-- // --><![CDATA[
	function invertBBC()
	{
		var state = document.getElementById("shdp_frontpage_type").value == "bbcode";
		document.getElementById("shd_bbcbox").style.display = state ? "" : "none";
		document.getElementById("shd_smileybox").style.display = state ? "" : "none";
	}
	// ]]></script>';
}
/**
 *	Display the form to edit a role's permissions and settings.
 *
 *	@since 2.0
*/
function template_shd_edit_role()
{
    global $context, $settings, $txt, $modSettings, $scripturl;
    // This is to shortcut settings for the role we want.
    $role =& $context['shd_permissions']['user_defined_roles'][$_REQUEST['role']];
    // Start the page off, including the rename-role bit.
    echo '
				<div class="tborder">
					<div class="cat_bar">
						<h3 class="catbg">
							<img src="', $settings['default_images_url'], '/simpledesk/permissions.png" class="icon" alt="*" />
							', $txt['shd_admin_permissions'], '
						</h3>
					</div>
					<p class="sd_description">
						', $txt['shd_admin_permissions_homedesc'], '
					</p>
				</div>
				<script type="text/javascript"><!-- // --><![CDATA[
				function shd_chicon(obj)
				{
					var sSelect = document.getElementById(obj.id).value;
					var newClass = "";
					switch(sSelect)
					{
						case "disallow":
							newClass = "shd_no"; break;
						case "allow":
							newClass = "shd_yes"; break;
						case "allow_own":
							newClass = "shd_own"; break;
						case "allow_any":
							newClass = "shd_any"; break;
						default:
							newClass = ""; break;
					}
					document.getElementById(obj.id + "_icon").setAttribute("class", newClass);
				}

				function shd_toggleblock(block)
				{
					var collapsed = (document.getElementById("permheader_" + block).getAttribute("class") == "cat_bar");
					if (collapsed)
					{
						document.getElementById("permheader_" + block).setAttribute("class", "cat_bar cat_collapsed");
						document.getElementById("permcontent_" + block).style.display = "";
						document.getElementById("permfooter_" + block).style.display = "";
						document.getElementById("permexpandicon_" + block).src = ', JavaScriptEscape($settings['images_url'] . '/selected_open.png'), ';
					}
					else
					{
						document.getElementById("permheader_" + block).setAttribute("class", "cat_bar");
						document.getElementById("permcontent_" + block).style.display = "none";
						document.getElementById("permfooter_" + block).style.display = "none";
						document.getElementById("permexpandicon_" + block).src = ', JavaScriptEscape($settings['images_url'] . '/selected.png'), ';
					}
					document.getElementById("permexpandicon_" + block).style.display = "";
				}

				// ]', ']></script>
				<form action="', $scripturl, '?action=admin;area=helpdesk_permissions;sa=saverole" method="post">
					<div class="cat_bar cat_collapsed">
						<h3 class="catbg">
							<img src="', $settings['default_images_url'], '/simpledesk/position.png" alt="*" />
							', $txt['shd_edit_role'], '
						</h3>
					</div>
					<div class="roundframe">
						<div class="content">
							<dl class="settings">
								<dt><strong>', $txt['shd_is_based_on'], ':</strong></dt>
								<dd>
									<img alt="*" src="', $settings['default_images_url'], '/simpledesk/', $role['template_icon'], '" />
									', $role['template_name'], '
								</dd>
								<dt><strong>', $txt['shd_role_name'], ':</strong></dt>
								<dd><input type="text" name="rolename" id="rolename" value="', $role['name'], '" class="input_text" size="30" /></dd>
							</dl>
						</div>
					</div>
					<span class="lowerframe"><span></span></span>
					<br />';
    // Get ready to display the actual permissions
    $permission_set = array();
    foreach ($context['shd_permissions']['permission_list'] as $permission => $details) {
        if (!empty($details[2])) {
            $permission_set[$details[1]][] = $permission;
        }
    }
    $displayed_sets = array();
    foreach ($context['shd_permissions']['group_display'] as $cell => $rows) {
        echo '
					<div class="', $cell == 0 ? 'floatleft' : 'floatright', '" style="width: 49%">';
        foreach ($rows as $rowitem => $rowicon) {
            if (empty($permission_set[$rowitem])) {
                continue;
            }
            $displayed_sets[] = $rowitem;
            echo '
						<div class="cat_bar" id="permheader_', $rowitem, '">
							<h3 class="catbg">
								<span class="floatright">
									<a class="permcollapse" href="#" onclick="shd_toggleblock(\'', $rowitem, '\'); return false;">
										<img src="', $settings['images_url'], '/selected_open.png" id="permexpandicon_', $rowitem, '" style="display:none;" />
									</a>
								</span>
								<img src="', $settings['default_images_url'], '/simpledesk/', $rowicon, '" alt="*" />
								<a href="#" onclick="shd_toggleblock(\'', $rowitem, '\'); return false;">', $txt['shd_permgroup_' . $rowitem], '</a>
							</h3>
						</div>
						<div class="roundframe" id="permcontent_', $rowitem, '">
							<div class="content">
								<dl class="permsettings">';
            foreach ($permission_set[$rowitem] as $permission) {
                list($ownany, $group, $icon) = $context['shd_permissions']['permission_list'][$permission];
                // And what exactly are we displaying as the current?
                if ($ownany) {
                    if (!empty($role['permissions'][$permission . '_any']) && $role['permissions'][$permission . '_any'] == ROLEPERM_ALLOW) {
                        list($perm_class, $perm_value) = array('shd_any', 'allow_any');
                    } elseif (!empty($role['permissions'][$permission . '_own']) && $role['permissions'][$permission . '_own'] == ROLEPERM_ALLOW) {
                        list($perm_class, $perm_value) = array('shd_own', 'allow_own');
                    } else {
                        list($perm_class, $perm_value) = array('shd_no', 'disallow');
                    }
                } else {
                    if (empty($role['permissions'][$permission])) {
                        list($perm_class, $perm_value) = array('shd_no', 'disallow');
                    } elseif ($role['permissions'][$permission] == ROLEPERM_ALLOW) {
                        list($perm_class, $perm_value) = array('shd_yes', 'allow');
                    }
                }
                echo '
									<dt', (empty($txt['permissionhelp_' . $permission]) ? '' : ' title="' . $txt['permissionhelp_' . $permission] . '"') . '><img src="', shd_image_url($icon), '" alt="*" />', $txt['permissionname_' . $permission], '</dt>
									<dd class="shd_nowrap">
										<span id="perm_', $permission, '_icon" class="', $perm_class, '"></span>
										<select name="perm_', $permission, '" id="perm_', $permission, '" onchange="javascript:shd_chicon(this);">
											<option value="disallow"', $perm_value == 'disallow' ? ' selected="selected"' : '', '>', empty($txt['permissionname_' . $permission . '_no']) ? $txt['shd_roleperm_disallow'] : $txt['permissionname_' . $permission . '_no'], '&nbsp;</option>';
                if ($ownany) {
                    echo '
											<option value="allow_own"', $perm_value == 'allow_own' ? ' selected="selected"' : '', '>', $txt['permissionname_' . $permission . '_own'], '&nbsp;</option>
											<option value="allow_any"', $perm_value == 'allow_any' ? ' selected="selected"' : '', '>', $txt['permissionname_' . $permission . '_any'], '&nbsp;</option>';
                } else {
                    echo '
											<option value="allow"', $perm_value == 'allow' ? ' selected="selected"' : '', '>', empty($txt['permissionname_' . $permission . '_yes']) ? $txt['shd_roleperm_allow'] : $txt['permissionname_' . $permission . '_yes'], '&nbsp;</option>';
                }
                echo '
										</select>
									</dd>';
            }
            echo '
								</dl>
							</div>
						</div>
						<span class="lowerframe" id="permfooter_', $rowitem, '"><span></span></span>
						<br />';
        }
        echo '
					</div>';
    }
    if (!empty($displayed_sets)) {
        echo '
						<script type="text/javascript"><!-- // --><![CDATA[';
        if (!empty($displayed_sets)) {
            echo '
						var hidden_blocks = ["', implode('","', $displayed_sets), '"];
						for (i in hidden_blocks)
						{
							shd_toggleblock(hidden_blocks[i]);
						}';
        }
        echo '
						// ]', ']></script>';
    }
    echo '
					<div class="tborder floatleft" style="width: 100%;">
						<div class="cat_bar">
							<h3 class="catbg sd_no_margin">
								<img src="', $settings['default_images_url'], '/simpledesk/roles.png" alt="*" />
								', $txt['shd_role_membergroups'], '
							</h3>
						</div>
						<p class="sd_description shd_actionloginfo">
							', $txt['shd_role_membergroups_desc'], '
						</p>
						<table class="shd_ticketlist" cellspacing="0" width="100%">
							<tr class="titlebg">
								<td width="30%">', $txt['shd_role'], '</td>
								<td width="30%">', $txt['shd_badge_stars'], '</td>
								<td>', $txt['shd_assign_group'], '</td>
							</tr>';
    $use_bg2 = true;
    foreach ($context['membergroups'] as $id_group => $group) {
        echo '
							<tr class="', $use_bg2 ? 'windowbg2' : 'windowbg', '">
								<td>', $group['link'], '</td>
								<td>';
        if (!empty($group['icons'])) {
            $icons = explode('#', $group['icons']);
            if (!empty($icons[0]) && !empty($icons[1])) {
                echo str_repeat('<img src="' . $settings['images_url'] . '/membericons/' . $icons[1] . '" alt="" />', $icons[0]);
            }
        }
        echo '</td>
								<td><input type="checkbox" class="input_check" name="group', $id_group, '"', in_array($id_group, $context['role_groups']) ? ' checked="checked"' : '', ' /></td>
							</tr>';
        $use_bg2 = !$use_bg2;
    }
    echo '
						</table>
						<br />
					</div>

					<div class="tborder floatleft" style="width: 100%;">
						<div class="cat_bar">
							<h3 class="catbg sd_no_margin">
								<img src="', $settings['default_images_url'], '/simpledesk/departments.png" alt="*" />
								', $txt['shd_role_departments'], '
							</h3>
						</div>
						<p class="sd_description shd_actionloginfo">
							', $txt['shd_role_departments_desc'], '
						</p>
						<table class="shd_ticketlist" cellspacing="0" width="100%">
							<tr class="titlebg">
								<td width="50%">', $txt['shd_department_name'], '</td>
								<td width="50%">', $txt['shd_assign_dept'], '</td>
							</tr>';
    $use_bg2 = true;
    foreach ($context['role_depts'] as $id_dept => $dept) {
        echo '
							<tr class="', $use_bg2 ? 'windowbg2' : 'windowbg', '">
								<td>', $dept['dept_name'], '</td>
								<td><input type="checkbox" class="input_check" name="dept', $id_dept, '"', !empty($dept['is_role']) ? ' checked="checked"' : '', ' /></td>
							</tr>';
        $use_bg2 = !$use_bg2;
    }
    echo '
						</table>
						<br />
					</div>

					<div class="floatleft">
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
						<input type="hidden" name="role" value="', $_REQUEST['role'], '" />
						<input type="submit" value="', $txt['shd_edit_role'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit" />
						<input type="submit" value="', $txt['shd_delete_role'], '" onclick="return confirm(' . JavaScriptEscape($txt['shd_delete_role_confirm']) . ');" name="delete" class="button_submit" />
					</div>
				</form>
				<br class="clear" />';
}
Ejemplo n.º 3
0
/**
 *	Display the action log.
 *
 *	Little real work is done in this template; mostly is just iterating through the already-processed contents of the action log as done by {@link shd_admin_action_log()}.
 *
 *	@see shd_admin_action_log()
 *	@since 1.0
*/
function template_shd_action_log()
{
    global $settings, $txt, $context, $scripturl, $sort_types, $modSettings;
    // The sort stuff here is huge.
    echo '
				<div class="tborder">
					<div class="cat_bar">
						<h3 class="catbg">
							<span class="floatright smalltext">', $txt['pages'], ': ', $context['page_index'], '</span>
							<img src="', $settings['default_images_url'], '/simpledesk/log.png" class="icon" alt="*" />
							', $txt['shd_admin_actionlog_title'], '
						</h3>
					</div>
					<table class="shd_ticketlist" cellspacing="0" width="100%">
						<tr class="titlebg">
							<td width="38%" colspan="2">
								<img src="', $settings['default_images_url'], '/simpledesk/action.png" class="shd_smallicon" alt="" />
								<a href="', $scripturl, '?action=admin;area=helpdesk_info;sa=actionlog', $context['sort'] == $sort_types['action'] && !isset($_REQUEST['asc']) ? ';sort=action;asc' : ';sort=action', '">
									', $txt['shd_admin_actionlog_action'], '
								</a>
								', $context['sort'] == $sort_types['action'] ? '<img src="' . $settings['default_images_url'] . '/' . (isset($_REQUEST['asc']) ? 'simpledesk/move_up.png' : 'simpledesk/move_down.png') . '" alt="" />' : '', '
							</td>
							<td width="20%">
								<img src="', $settings['default_images_url'], '/simpledesk/time.png" class="shd_smallicon" alt="" />
								<a href="', $scripturl, '?action=admin;area=helpdesk_info;sa=actionlog', $context['sort'] == $sort_types['time'] && !isset($_REQUEST['asc']) ? ';sort=time;asc' : ';sort=time', '">
									', $txt['shd_admin_actionlog_date'], '
								</a>
								', $context['sort'] == $sort_types['time'] ? '<img src="' . $settings['default_images_url'] . '/' . (isset($_REQUEST['asc']) ? 'simpledesk/move_up.png' : 'simpledesk/move_down.png') . '" alt="" />' : '', '
							</td>
							<td width="16%">
								<img src="', $settings['default_images_url'], '/simpledesk/user.png" class="shd_smallicon" alt="" />
								<a href="', $scripturl, '?action=admin;area=helpdesk_info;sa=actionlog', $context['sort'] == $sort_types['member'] && !isset($_REQUEST['asc']) ? ';sort=member;asc' : ';sort=member', '">
									', $txt['shd_admin_actionlog_member'], '
								</a>
								', $context['sort'] == $sort_types['member'] ? '<img src="' . $settings['default_images_url'] . '/' . (isset($_REQUEST['asc']) ? 'simpledesk/move_up.png' : 'simpledesk/move_down.png') . '" alt="" />' : '', '
							</td>
							<td width="16%">
								<img src="', $settings['default_images_url'], '/simpledesk/position.png" class="shd_smallicon" alt="" />
								<a href="', $scripturl, '?action=admin;area=helpdesk_info;sa=actionlog', $context['sort'] == $sort_types['position'] && !isset($_REQUEST['asc']) ? ';sort=position;asc' : ';sort=position', '">
									', $txt['shd_admin_actionlog_position'], '
								</a>
								', $context['sort'] == $sort_types['position'] ? '<img src="' . $settings['default_images_url'] . '/' . (isset($_REQUEST['asc']) ? 'simpledesk/move_up.png' : 'simpledesk/move_down.png') . '" alt="" />' : '', '
							</td>
							<td width="10%">
								<img src="', $settings['default_images_url'], '/simpledesk/ip.png" class="shd_smallicon" alt="" />
								<a href="', $scripturl, '?action=admin;area=helpdesk_info;sa=actionlog', $context['sort'] == $sort_types['ip'] && !isset($_REQUEST['asc']) ? ';sort=ip;asc' : ';sort=ip', '">
									', $txt['shd_admin_actionlog_ip'], '
								</a>
								', $context['sort'] == $sort_types['ip'] ? '<img src="' . $settings['default_images_url'] . '/' . (isset($_REQUEST['asc']) ? 'simpledesk/move_up.png' : 'simpledesk/move_down.png') . '" alt="" />' : '', '
							</td>
							<td width="2%">&nbsp;</td>
						</tr>';
    if (empty($context['actions'])) {
        echo '
						<tr class="windowbg2">
							<td colspan="7" class="shd_noticket">', $txt['shd_admin_actionlog_none'], '</td>
						</tr>';
    } else {
        $use_bg2 = true;
        // start with windowbg2 to differentiate between that and windowbg2
        foreach ($context['actions'] as $action) {
            echo '
						<tr class="', $use_bg2 ? 'windowbg2' : 'windowbg', '">
							<td width="1%" class="shd_nowrap">
								<img src="', shd_image_url($action['action_icon']), '" alt="" class="shd_smallicon" />
							</td>
							<td class="smalltext">', $action['action_text'], '</td>
							<td>', $action['time'], '</td>
							<td>', $action['member']['link'], '</td>
							<td>', $action['member']['group'], '</td>
							<td>', !empty($action['member']['ip']) ? $action['member']['ip'] : $txt['shd_admin_actionlog_hidden'], '</td>
							<td>', $action['can_remove'] && $context['can_delete'] ? '<a href="' . $scripturl . '?action=admin;area=helpdesk_info;sa=actionlog;remove=' . $action['id'] . '"><img src="' . $settings['default_images_url'] . '/simpledesk/delete.png" alt="' . $txt['shd_delete_item'] . '" /></a>' : '', '</td>
						</tr>';
            $use_bg2 = !$use_bg2;
        }
    }
    echo '
					<tr class="titlebg">
						<td colspan="7">
							<span class="floatright smalltext">', $txt['pages'], ': ', $context['page_index'], '</span>
							<span class="smalltext shd_empty_log"><img src="', $settings['default_images_url'], '/simpledesk/delete.png" alt="X" /> <a href="', $scripturl, '?action=admin;area=helpdesk_info;sa=actionlog', $context['url_sort'], $context['url_order'], ';removeall" onclick="return confirm(', JavaScriptEscape(sprintf($txt['shd_admin_actionlog_removeall_confirm'], $context['hoursdisable'])), ');">', $txt['shd_admin_actionlog_removeall'], '</a></span>
						</td>
					</tr>
					</table>
				</div>';
}
function template_shd_profile_permissions()
{
    global $context, $txt, $settings, $scripturl;
    echo '
				<div class="tborder">
					<div class="cat_bar">
						<h3 class="catbg">
							<img src="', $settings['default_images_url'], '/simpledesk/permissions.png" class="icon" alt="*" />
							', sprintf($txt['shd_profile_permissions_header'], $context['member']['name']), '
						</h3>
					</div>';
    if (!empty($context['member']['has_all_permissions'])) {
        // Whoa, this dude's special. Tidy up and BAIL!
        echo '
					<p class="description">
						', $txt['shd_profile_permissions_all_admin'], '
					</p>
				</div>';
        return;
    }
    // Regular user: carry on, sergeant.
    echo '
					<p class="description">
						', $txt['shd_profile_permissions_description'], '
					</p>
				</div>';
    // Now hang on a moment. We need to display the list of departments, and if that's all we have, stop there.
    echo '
				<span class="upperframe"><span></span></span>
				<div class="roundframe">
					<form action="', $scripturl, '?action=profile;u=', $context['member']['id'], ';area=hd_permissions" method="post">
						', $txt['shd_profile_showdept'], ':
						<select name="permdept">
							<option value="0">', $txt['shd_profile_selectdept'], '</option>';
    foreach ($context['depts_list'] as $id => $dept) {
        echo '
							<option value="', $id, '"', $_REQUEST['permdept'] == $id ? ' selected="selected"' : '', '>', $dept, '</option>';
    }
    echo '
						</select>
						<input type="submit" class="button_submit" value="', $txt['go'], '" />
					</form>
				</div>
				<span class="lowerframe"><span></span></span>
				<br />';
    // We're done?
    if (!empty($context['dept_list_only'])) {
        return;
    }
    // Now, display the roles that are attached to this user, and display the groups that make that link.
    echo '
				<div class="tborder">
					<div class="cat_bar">
						<h3 class="catbg sd_no_margin">
							<img src="', $settings['default_images_url'], '/simpledesk/roles.png" alt="*" />
							', $txt['shd_roles'], '
						</h3>
					</div>
					<p class="description shd_actionloginfo">
						', $txt['shd_profile_roles_assigned'], '
					</p>
					<table class="shd_ticketlist" cellspacing="0" width="100%">
						<tr class="titlebg">
							<td colspan="2" width="30%">', $txt['shd_role'], '</td>
							<td>', $txt['shd_profile_role_membergroups'], '</td>
						</tr>';
    if (empty($context['member_roles'])) {
        echo '
						<tr class="windowbg">
							<td colspan="3" class="centertext">', $txt['shd_profile_no_roles'], '</td>
						</tr>';
    } else {
        $use_bg2 = true;
        foreach ($context['member_roles'] as $role) {
            echo '
						<tr class="', $use_bg2 ? 'windowbg2' : 'windowbg', '">
							<td>', !empty($context['shd_permissions']['roles'][$role['template']]['icon']) ? '<img src="' . $settings['default_images_url'] . '/simpledesk/' . $context['shd_permissions']['roles'][$role['template']]['icon'] . '" alt="" />' : '', '</td>
							<td>', $role['name'], '</td>
							<td>';
            $done_group = false;
            foreach ($role['groups'] as $group) {
                if ($done_group) {
                    echo ', ';
                }
                echo $context['membergroups'][$group]['link'];
                $done_group = true;
            }
            echo '</td>
						</tr>';
            $use_bg2 = !$use_bg2;
        }
    }
    echo '
					</table>
				</div>';
    // Now display their permissions!
    if (!empty($context['member_permissions']['allowed'])) {
        echo '
				<br />
				<div class="tborder">
					<div class="cat_bar">
						<h3 class="catbg sd_no_margin">
							<img src="', $settings['default_images_url'], '/simpledesk/perm_yes.png" alt="*" />
							', $txt['shd_profile_granted'], '
						</h3>
					</div>
					<p class="description shd_actionloginfo">
						', $txt['shd_profile_granted_desc'], '
					</p>
					<table class="shd_ticketlist" cellspacing="0" width="100%">
						<tr class="titlebg">
							<td colspan="2" width="60%">', $txt['shd_permissions'], '</td>
							<td>', $txt['shd_roles'], '</td>
						</tr>';
        // Right, we're going to go by what's in the master list first.
        $use_bg2 = true;
        $last_permission_cat = '';
        foreach ($context['shd_permissions']['permission_list'] as $permission => $details) {
            list($ownany, $category, $icon) = $details;
            if (empty($icon)) {
                continue;
            }
            // don't display it here at all if it's a denied permission or no icon (which means, access to helpdesk / is staff / admin helpdesk permissions are excluded here)
            // Well, are we displaying it?
            if ($ownany) {
                if (!empty($context['member_permissions']['denied'][$permission . '_any']) || empty($context['member_permissions']['allowed'][$permission . '_any']) && empty($context['member_permissions']['allowed'][$permission . '_own'])) {
                    continue;
                }
                // deny hits both _any and _own when being saved
            } else {
                if (!empty($context['member_permissions']['denied'][$permission]) || empty($context['member_permissions']['allowed'][$permission])) {
                    continue;
                }
            }
            if ($category != $last_permission_cat) {
                $thisicon = '';
                foreach ($context['shd_permissions']['group_display'] as $group => $permgroups) {
                    if (!isset($permgroups[$category])) {
                        continue;
                    } else {
                        $thisicon = $permgroups[$category];
                    }
                }
                echo '
						<tr class="catbg">
							<td colspan="3">', empty($thisicon) ? '' : '<img src="' . shd_image_url($thisicon) . '" alt="" />', ' ', $txt['shd_permgroup_' . $category], '</td>
						</tr>';
                $last_permission_cat = $category;
            }
            echo '
						<tr class="', $use_bg2 ? 'windowbg2' : 'windowbg', '">
							<td><img src="', shd_image_url($icon), '" alt="" /></td>';
            if ($ownany) {
                echo '
							<td>', $txt['permissionname_' . $permission], ' - ';
                if (!empty($context['member_permissions']['allowed'][$permission . '_any'])) {
                    $roles = $context['member_permissions']['allowed'][$permission . '_any'];
                    echo $txt['permissionname_' . $permission . '_any'];
                } elseif (!empty($context['member_permissions']['allowed'][$permission . '_own'])) {
                    $roles = $context['member_permissions']['allowed'][$permission . '_own'];
                    echo $txt['permissionname_' . $permission . '_own'];
                }
                echo '</td>';
            } else {
                $roles = $context['member_permissions']['allowed'][$permission];
                echo '
							<td>', $txt['permissionname_' . $permission], '</td>';
            }
            echo '
							<td>';
            $done_first = false;
            foreach ($roles as $role) {
                if ($done_first) {
                    echo ', ';
                }
                echo '<span class="shd_nowrap"><img src="', $settings['default_images_url'], '/simpledesk/', $context['shd_permissions']['roles'][$context['member_roles'][$role]['template']]['icon'], '" alt="" />&nbsp;', $context['member_roles'][$role]['name'], '</span>';
                $done_first = true;
            }
            echo '
							</td>
						</tr>';
            $use_bg2 = !$use_bg2;
        }
        echo '
					</table>
				</div>';
    }
    // Display of denied permissions goes here.
}
Ejemplo n.º 5
0
/**
 *	Display the notice of email.
 *
 *	@todo Finish documenting
 *	@since 2.0
*/
function shd_notify_popup()
{
    global $txt, $context, $settings, $modSettings, $smcFunc, $user_profile, $user_info, $scripturl;
    // First, verify we got a log entry, that the log entry is right, and it points to a ticket we can actually see.
    $_GET['log'] = isset($_GET['log']) ? (int) $_GET['log'] : 0;
    $email_type = isset($_GET['template']) ? preg_replace('~[^a-z_]~', '', $_GET['template']) : '';
    if (empty($modSettings['shd_display_ticket_logs']) || empty($_GET['log']) || empty($email_type)) {
        fatal_lang_error('no_access', false);
    }
    $query = $smcFunc['db_query']('', '
		SELECT hdla.id_member, hdla.id_ticket, hdla.id_msg, hdla.extra, IFNULL(hdtr.body, {string:empty}) AS body, IFNULL(mem.real_name, hdtr.poster_name) AS poster_name
		FROM {db_prefix}helpdesk_log_action AS hdla
			LEFT JOIN {db_prefix}helpdesk_ticket_replies AS hdtr ON (hdla.id_msg = hdtr.id_msg)
			LEFT JOIN {db_prefix}members AS mem ON (hdtr.id_member = mem.id_member)
		WHERE id_action = {int:log}
			AND action = {string:notify}', array('log' => $_GET['log'], 'notify' => 'notify', 'empty' => ''));
    if ($smcFunc['db_num_rows']($query) == 0) {
        $smcFunc['db_free_result']($query);
        fatal_lang_error('no_access');
    }
    $row = $smcFunc['db_fetch_assoc']($query);
    $smcFunc['db_free_result']($query);
    $row['extra'] = unserialize($row['extra']);
    // Just check we did actually log an email of that type.
    if (empty($row['extra']['emails'][$_GET['template']])) {
        fatal_lang_error('no_access', false);
    }
    $ticketinfo = shd_load_ticket($row['id_ticket']);
    // OK, if we're here, we can see the ticket. Can we actually see the email log at this point?
    if (!shd_allowed_to('shd_view_ticket_logs_any', $ticketinfo['dept']) && (!shd_allowed_to('shd_view_ticket_logs_own', $ticketinfo['dept']) || !$ticketinfo['is_own'])) {
        fatal_lang_error('no_access', false);
    }
    // We're reusing the Help template, need its language file.
    loadLanguage('Help');
    shd_load_language('sd_language/SimpleDeskAdmin');
    shd_load_language('sd_language/SimpleDeskLogAction');
    shd_load_language('sd_language/SimpleDeskNotifications');
    // Set the page up
    loadTemplate('Help');
    $context['page_title'] = $context['forum_name'] . ' - ' . $txt['shd_log_notifications'];
    $context['template_layers'] = array();
    $context['sub_template'] = 'popup';
    $users = array();
    // First, get the list of users, and load their username etc if we haven't already attempted it before.
    if (isset($row['extra']['emails'][$email_type]['u'])) {
        $users = array_merge($users, explode(',', $row['extra']['emails'][$email_type]['u']));
    }
    if (!empty($users)) {
        $users = array_unique($users);
        if (!empty($users)) {
            loadMemberData($users, false, 'minimal');
        }
    }
    // Now we have all the usernames for this instance, let's go and build this entry.
    $context['help_text'] = $txt['shd_log_notify_to'] . '<br />';
    $new_content = '';
    if (!empty($users)) {
        $first = true;
        foreach ($users as $user) {
            if (empty($user_profile[$user])) {
                continue;
            }
            $new_content .= ($first ? '<img src="' . shd_image_url('user.png') . '" alt="" /> ' : ', ') . shd_profile_link($user_profile[$user]['real_name'], $user);
            $first = false;
        }
    }
    if (!empty($row['extra']['emails'][$email_type]['e'])) {
        $emails = explode(',', $row['extra']['emails'][$email_type]['e']);
        // Admins can see the actual emails.
        if (shd_allowed_to('admin_helpdesk', 0) || $user_info['is_admin']) {
            foreach ($emails as $key => $value) {
                $emails[$key] = '<a href="mailto:' . $value . '">' . $value . '</a>';
            }
            $new_content .= '<img src="' . shd_image_url('log_notify.png') . '" alt="" /> ' . implode(', ', $emails);
        } else {
            $new_content .= '<img src="' . shd_image_url('log_notify.png') . '" alt="" /> ' . (count($emails) == 1 ? $txt['shd_log_notify_hiddenemail_1'] : sprintf($txt['shd_log_notify_hiddenemail'], count($emails)));
        }
    }
    if (!empty($new_content)) {
        $context['help_text'] .= $new_content;
    }
    $context['help_text'] .= '<hr />';
    // So the general prep is done. Now let's rebuild the email contents.
    if (empty($row['extra']['withbody']) || empty($row['body'])) {
        $body = '';
    } else {
        $body = trim(un_htmlspecialchars(strip_tags(strtr(shd_format_text($row['body'], false), array('<br />' => "\n", '</div>' => "\n", '</li>' => "\n", '&#91;' => '[', '&#93;' => ']')))));
    }
    $replacements = array("\n" => '<br />', '{ticket_id}' => str_pad($row['id_ticket'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT), '{subject}' => empty($row['extra']['subject']) ? $txt['no_subject'] : $row['extra']['subject'], '{ticketlink}' => $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $row['id_ticket'] . (empty($row['id_msg']) ? '.0' : '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']), '{body}' => $body, '{poster_name}' => $row['poster_name']);
    $email_subject = str_replace(array_keys($replacements), array_values($replacements), $txt['template_subject_notify_' . $email_type]);
    $email_body = str_replace(array_keys($replacements), array_values($replacements), $txt['template_' . (empty($row['extra']['withbody']) || empty($row['body']) ? 'body' : 'bodyfull') . '_notify_' . $email_type]);
    $context['help_text'] .= '<strong>' . $txt['subject'] . ':</strong> ' . $email_subject . '<br /><br />' . $email_body;
}