Example #1
0
/**
 * Import or delete templates.
 * When upgrading MySupport we want to be able to keep edited versions of templates. This function allows us to only delete the master copies when deactivating, whilst deleting everything when uninstalling.
 * Basically so that when you upgrade you'd deactivate, it'd delete the master copies, and reactivating would import the new master copies, so your edits would be saved. Same as normal MyBB templates work except it's not done with an upgrade script.
 * Then the edited copies would sit hidden in the database ready for when you activate again.
 *
 * @param int Importing/deleting - 1/0
 * @param bool If $type == 0, are we fully deleting them (uninstalling) or just removing the master copies (deactivating).
**/
function mysupport_do_templates($type, $master_only = false)
{
    global $db;
    require_once MYBB_ROOT . 'inc/adminfunctions_templates.php';
    if ($type == 1) {
        $template_group = array("prefix" => "mysupport", "title" => "<lang:mysupport>");
        $db->insert_query("templategroups", $template_group);
        $templates = array();
        $templates[] = array("title" => "mysupport_form", "template" => "<form action=\"showthread.php\" method=\"post\" style=\"display: inline;\">\r\n\t<input type=\"hidden\" name=\"tid\" value=\"{\$tid}\" />\r\n\t<input type=\"hidden\" name=\"action\" value=\"mysupport\" />\r\n\t<input type=\"hidden\" name=\"via_form\" value=\"1\" />\r\n\t<input type=\"hidden\" name=\"my_post_key\" value=\"{\$mybb->post_code}\" />\r\n\t{\$status_list}\r\n\t{\$assigned_list}\r\n\t{\$priorities_list}\r\n\t{\$categories_list}\r\n\t{\$on_hold}\r\n\t{\$is_support_thread}\r\n\t{\$gobutton}\r\n</form><br />");
        $templates[] = array("title" => "mysupport_form_ajax", "template" => "<div class=\"mysupport_showthread_more_box\">\r\n<form action=\"showthread.php\" method=\"post\" style=\"display: inline;\">\r\n\t<input type=\"hidden\" name=\"tid\" value=\"{\$tid}\" />\r\n\t<input type=\"hidden\" name=\"action\" value=\"mysupport\" />\r\n\t<input type=\"hidden\" name=\"via_form\" value=\"1\" />\r\n\t<input type=\"hidden\" name=\"my_post_key\" value=\"{\$mybb->post_code}\" />\r\n\t<table border=\"0\" cellspacing=\"{\$theme['borderwidth']}\" cellpadding=\"{\$theme['tablespace']}\" class=\"tborder\" style=\"width: 250px;\">\r\n\t\t<tr>\r\n\t\t\t<td class=\"thead\" align=\"center\">\r\n\t\t\t\t<strong>{\$lang->mysupport_additional_options}</strong>\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t{\$status_list}\r\n\t\t{\$assigned_list}\r\n\t\t{\$priorities_list}\r\n\t\t{\$categories_list}\r\n\t\t{\$on_hold}\r\n\t\t{\$is_support_thread}\r\n\t\t<tr>\r\n\t\t\t<td class=\"tfoot\" align=\"center\">\r\n\t\t\t\t<input type=\"submit\" value=\"{\$lang->update}\" /> <input type=\"button\" value=\"{\$lang->close_options}\" onclick=\"mysupport_close_more_box();\" />\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t</table>\r\n</form>\r\n</div>\r\n<br />");
        $templates[] = array("title" => "mysupport_tab", "template" => "<div class=\"mysupport_tab {\$class}\"><a href=\"{\$url}\"{\$onclick}>{\$text}</a></div>");
        $templates[] = array("title" => "mysupport_bestanswer", "template" => " <a href=\"{\$mybb->settings['bburl']}/showthread.php?action=bestanswer&amp;pid={\$post['pid']}&amp;my_post_key={\$mybb->post_code}\"><img src=\"{\$mybb->settings['bburl']}/{\$theme['imgdir']}/{\$bestanswer_img}.gif\" alt=\"{\$bestanswer_alt}\" title=\"{\$bestanswer_title}\" /> {\$bestanswer_desc}</a>");
        $templates[] = array("title" => "mysupport_status_image", "template" => "<img src=\"{\$mybb->settings['bburl']}/{\$theme['imgdir']}/mysupport_{\$status_img}.png\" alt=\"{\$status_title}\" title=\"{\$status_title}\" /> ");
        $templates[] = array("title" => "mysupport_status_text", "template" => "<span class=\"mysupport_status_{\$status_class}\" title=\"{\$status_title}\">[{\$status_text}]</span> ");
        $templates[] = array("title" => "mysupport_notice", "template" => "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" class=\"tborder\">\r\n\t<tr>\r\n\t\t<td class=\"trow1\" align=\"right\"><a href=\"{\$mybb->settings['bburl']}/{\$notice_url}\"><span class=\"smalltext\">{\$notice_text}</span></a></td>\r\n\t</tr>\r\n</table><br />");
        $templates[] = array("title" => "mysupport_threadlist_thread", "template" => "<tr{\$priority_class}>\r\n\t<td class=\"{\$bgcolor}\" width=\"30%\">\r\n\t\t<div>\r\n\t\t\t<span><a href=\"{\$thread['threadlink']}\">{\$thread['subject']}</a></span>\r\n\t\t\t<div class=\"author smalltext\">{\$thread['profilelink']}</div>\r\n\t\t</div>\r\n\t</td>\r\n\t<td class=\"{\$bgcolor}\" width=\"25%\">{\$thread['forumlink']} <a href=\"{\$mybb->settings['bburl']}/{\$view_all_forum_link}\"><img src=\"{\$mybb->settings['bburl']}/{\$theme['imgdir']}/mysupport_arrow_right.gif\" alt=\"{\$view_all_forum_text}\" title=\"{\$view_all_forum_text}\" /></a></td>\r\n\t<td class=\"{\$bgcolor}\" width=\"25%\">{\$status_time}</td>\r\n\t<td class=\"{\$bgcolor}\" width=\"20%\" style=\"white-space: nowrap; text-align: right;\">\r\n\t\t<span class=\"lastpost smalltext\">{\$lastpostdate} {\$lastposttime}<br />\r\n\t\t<a href=\"{\$thread['lastpostlink']}\">{\$lang->thread_list_lastpost}</a>: {\$lastposterlink}</span>\r\n\t</td>\r\n</tr>");
        $templates[] = array("title" => "mysupport_threadlist", "template" => "<html>\r\n<head>\r\n<title>{\$mybb->settings['bbname']} - {\$thread_list_title}</title>\r\n{\$headerinclude}\r\n</head>\r\n<body>\r\n\t{\$header}\r\n\t<table width=\"100%\" border=\"0\" align=\"center\">\r\n\t\t<tr>\r\n\t\t\t{\$navigation}\r\n\t\t\t<td valign=\"top\">\r\n\t\t\t\t{\$stats}\r\n\t\t\t\t{\$threads_list}\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t</table>\r\n\t{\$footer}\r\n</body>\r\n</html>");
        $templates[] = array("title" => "mysupport_threadlist_list", "template" => "{\$mysupport_priority_classes}\r\n<table border=\"0\" cellspacing=\"{\$theme['borderwidth']}\" cellpadding=\"{\$theme['tablespace']}\" class=\"tborder\">\r\n\t<tr>\r\n\t\t<td class=\"thead\" width=\"100%\" colspan=\"4\"><strong>{\$thread_list_heading}</strong><div class=\"float_right\">{\$threadlist_filter_form}</div></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class=\"tcat\" width=\"30%\"><strong>{\$lang->thread_list_threadauthor}</strong></td>\r\n\t\t<td class=\"tcat\" width=\"25%\"><strong>{\$lang->forum}</strong></td>\r\n\t\t<td class=\"tcat\" width=\"25%\"><strong>{\$status_heading}</strong></td>\r\n\t\t<td class=\"tcat\" width=\"20%\" ><strong>{\$lang->thread_list_lastpost}:</strong></td>\r\n\t</tr>\r\n\t{\$threads}\r\n\t{\$view_all}\r\n</table>");
        $templates[] = array("title" => "mysupport_threadlist_footer", "template" => "<tr>\r\n\t<td class=\"tfoot\" colspan=\"4\"><a href=\"{\$mybb->settings['bburl']}/{\$view_all_url}\"><strong>{\$view_all}</strong></a></td>\r\n</tr>");
        $templates[] = array("title" => "mysupport_nav_option", "template" => "<tr><td class=\"trow1 smalltext\"><a href=\"{\$mybb->settings['bburl']}/{\$nav_link}\" class=\"{\$class1} {\$class2}\">{\$nav_text}</a></td></tr>");
        $templates[] = array("title" => "mysupport_threadlist_stats", "template" => "<table border=\"0\" cellspacing=\"{\$theme['borderwidth']}\" cellpadding=\"{\$theme['tablespace']}\" class=\"tborder\">\r\n\t<tr>\r\n\t\t<td class=\"thead\" width=\"100%\"><strong>{\$title_text}</strong></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class=\"trow1\" width=\"100%\">{\$overview_text}</td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class=\"trow2\" width=\"100%\">\r\n\t\t\t<table border=\"0\" cellspacing=\"{\$theme['borderwidth']}\" cellpadding=\"{\$theme['tablespace']}\" class=\"tborder\">\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t{\$solved_row}\r\n\t\t\t\t\t{\$notsolved_row}\r\n\t\t\t\t\t{\$technical_row}\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t</td>\r\n\t</tr>\r\n</table><br />");
        $templates[] = array("title" => "mysupport_jumpto_bestanswer", "template" => "<a href=\"{\$mybb->settings['bburl']}/{\$jumpto_bestanswer_url}\"><img src=\"{\$mybb->settings['bburl']}/{\$theme['imgdir']}/{\$bestanswer_image}\" alt=\"{\$lang->jump_to_bestanswer}\" title=\"{\$lang->jump_to_bestanswer}\" /></a>");
        $templates[] = array("title" => "mysupport_assigned", "template" => "<img src=\"{\$mybb->settings['bburl']}/{\$theme['imgdir']}/mysupport_assigned.png\" alt=\"{\$lang->assigned}\" title=\"{\$lang->assigned}\" />");
        $templates[] = array("title" => "mysupport_assigned_toyou", "template" => "<a href=\"{\$mybb->settings['bburl']}/usercp.php?action=assignedthreads\" target=\"_blank\"><img src=\"{\$mybb->settings['bburl']}/{\$theme['imgdir']}/mysupport_assigned_toyou.png\" alt=\"{\$lang->assigned_toyou}\" title=\"{\$lang->assigned_toyou}\" /></a>");
        $templates[] = array("title" => "mysupport_deny_support_post", "template" => "<img src=\"{\$mybb->settings['bburl']}/{\$theme['imgdir']}/mysupport_no_support.gif\" alt=\"{\$denied_text_desc}\" title=\"{\$denied_text_desc}\" /> {\$denied_text}");
        $templates[] = array("title" => "mysupport_deny_support_post_linked", "template" => "<a href=\"{\$mybb->settings['bburl']}/modcp.php?action=supportdenial&amp;do=denysupport&amp;uid={\$post['uid']}&amp;tid={\$post['tid']}\" title=\"{\$denied_text_desc}\"><img src=\"{\$mybb->settings['bburl']}/{\$theme['imgdir']}/mysupport_no_support.gif\" alt=\"{\$denied_text_desc}\" title=\"{\$denied_text_desc}\" /> {\$denied_text}</a>");
        $templates[] = array("title" => "mysupport_deny_support", "template" => "<html>\r\n<head>\r\n<title>{\$lang->support_denial}</title>\r\n{\$headerinclude}\r\n</head>\r\n<body>\r\n\t{\$header}\r\n\t<table width=\"100%\" border=\"0\" align=\"center\">\r\n\t\t<tr>\r\n\t\t\t{\$modcp_nav}\r\n\t\t\t<td valign=\"top\">\r\n\t\t\t\t{\$deny_support}\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t</table>\r\n\t{\$footer}\r\n</body>\r\n</html>");
        $templates[] = array("title" => "mysupport_deny_support_deny", "template" => "<form method=\"post\" action=\"modcp.php\">\r\n\t<table border=\"0\" cellspacing=\"{\$theme['borderwidth']}\" cellpadding=\"{\$theme['tablespace']}\" class=\"tborder\">\r\n\t\t<tr>\r\n\t\t\t<td class=\"thead\"><strong>{\$deny_support_to}</strong></td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td class=\"trow1\" align=\"center\">{\$lang->deny_support_desc}</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td class=\"trow1\" align=\"center\">\r\n\t\t\t\t<label for=\"username\">{\$lang->username}</label> <input type=\"text\" name=\"username\" id=\"username\" value=\"{\$username}\" />\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td class=\"trow2\" width=\"80%\" align=\"center\">\r\n\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"supportdenial\" />\r\n\t\t\t\t<input type=\"hidden\" name=\"do\" value=\"do_denysupport\" />\r\n\t\t\t\t<input type=\"hidden\" name=\"my_post_key\" value=\"{\$mybb->post_code}\" />\r\n\t\t\t\t<input type=\"hidden\" name=\"tid\" value=\"{\$tid}\" />\r\n\t\t\t\t{\$deniedreasons}\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td class=\"trow2\" width=\"80%\" align=\"center\">\r\n\t\t\t\t<input type=\"submit\" value=\"{\$lang->deny_support}\" />\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t</table>\r\n</form>");
        $templates[] = array("title" => "mysupport_deny_support_list", "template" => "<table border=\"0\" cellspacing=\"{\$theme['borderwidth']}\" cellpadding=\"{\$theme['tablespace']}\" class=\"tborder\">\r\n\t<tr>\r\n\t\t<td class=\"thead\" colspan=\"5\">\r\n\t\t\t<div class=\"float_right\"><a href=\"modcp.php?action=supportdenial&amp;do=denysupport\">{\$lang->deny_support}</a></div>\r\n\t\t\t<strong>{\$lang->users_denied_support}</strong>\r\n\t\t</td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class=\"tcat\" align=\"center\" width=\"20%\"><strong>{\$lang->username}</strong></td>\r\n\t\t<td class=\"tcat\" align=\"center\" width=\"30%\"><strong>{\$lang->support_denial_reason}</strong></td>\r\n\t\t<td class=\"tcat\" align=\"center\" width=\"20%\"><strong>{\$lang->support_denial_user}</strong></td>\r\n\t\t<td class=\"tcat\" colspan=\"2\" align=\"center\" width=\"30%\"><strong>{\$lang->controls}</strong></td>\r\n\t</tr>\r\n\t{\$denied_users}\r\n</table>");
        $templates[] = array("title" => "mysupport_deny_support_list_user", "template" => "<tr>\r\n\t<td class=\"{\$bgcolor}\" align=\"center\" width=\"20%\">{\$support_denied_user}</td>\r\n\t<td class=\"{\$bgcolor}\" align=\"center\" width=\"30%\">{\$support_denial_reason}</td>\r\n\t<td class=\"{\$bgcolor}\" align=\"center\" width=\"20%\">{\$support_denier_user}</td>\r\n\t<td class=\"{\$bgcolor}\" align=\"center\" width=\"15%\"><a href=\"{\$mybb->settings['bburl']}/modcp.php?action=supportdenial&amp;do=denysupport&amp;uid={\$denieduser['support_denied_uid']}\">{\$lang->edit}</a></td>\r\n\t<td class=\"{\$bgcolor}\" align=\"center\" width=\"15%\"><a href=\"{\$mybb->settings['bburl']}/modcp.php?action=supportdenial&amp;do=do_denysupport&amp;uid={\$denieduser['support_denied_uid']}&amp;deniedsupportreason=-1&amp;my_post_key={\$mybb->post_code}\">{\$lang->revoke}</a></td>\r\n</tr>");
        $templates[] = array("title" => "mysupport_usercp_options", "template" => "<fieldset class=\"trow2\">\r\n\t<legend><strong>{\$lang->mysupport_options}</strong></legend>\r\n\t<table cellspacing=\"0\" cellpadding=\"2\">\r\n\t\t<tr>\r\n\t\t\t<td valign=\"top\" width=\"1\">\r\n\t\t\t\t<input type=\"checkbox\" class=\"checkbox\" name=\"mysupportdisplayastext\" id=\"mysupportdisplayastext\" value=\"1\" {\$mysupportdisplayastextcheck} />\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t<span class=\"smalltext\"><label for=\"mysupportdisplayastext\">{\$lang->mysupport_show_as_text}</label></span>\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t</table>\r\n</fieldset>\r\n<br />");
        $templates[] = array("title" => "mysupport_inline_thread_moderation", "template" => "<optgroup label=\"{\$lang->mysupport}\">\r\n\t<option disabled=\"disabled\">{\$lang->markas}</option>\r\n\t{\$mysupport_solved}\r\n\t{\$mysupport_solved_and_close}\r\n\t{\$mysupport_technical}\r\n\t{\$mysupport_not_technical}\r\n\t{\$mysupport_not_solved}\r\n\t<option disabled=\"disabled\">{\$lang->hold_status}</option>\r\n\t{\$mysupport_onhold}\r\n\t{\$mysupport_offhold}\r\n\t<option disabled=\"disabled\">{\$lang->assign_to}</option>\r\n\t{\$mysupport_assign}\r\n\t<option value=\"mysupport_assign_0\">-- {\$lang->assign_to_nobody}</option>\r\n\t<option disabled=\"disabled\">{\$lang->priority}</option>\r\n\t{\$mysupport_priorities}\r\n\t<option value=\"mysupport_priority_0\">-- {\$lang->priority_none}</option>\r\n\t<option disabled=\"disabled\">{\$lang->category}</option>\r\n\t{\$mysupport_categories}\r\n\t<option value=\"mysupport_category_0\">-- {\$lang->category_none}</option>\r\n</optgroup>");
        $templates[] = array("title" => "mysupport_member_profile", "template" => "<br />\r\n<table border=\"0\" cellspacing=\"{\$theme['borderwidth']}\" cellpadding=\"{\$theme['tablespace']}\" class=\"tborder\">\r\n\t<tr>\r\n\t\t<td colspan=\"2\" class=\"thead\"><strong>{\$lang->mysupport}</strong></td>\r\n\t</tr>\r\n\t{\$bestanswers}\r\n\t{\$denied_text}\r\n</table>");
        foreach ($templates as $template) {
            $insert = array("title" => $db->escape_string($template['title']), "template" => $db->escape_string($template['template']), "sid" => "-2", "version" => "1600", "status" => "", "dateline" => TIME_NOW);
            $db->insert_query("templates", $insert);
        }
    } else {
        $db->delete_query("templategroups", "prefix = 'mysupport'");
        $where_sql = "";
        if ($master_only) {
            $where_sql = " AND sid = '-2'";
        }
        $templates = mysupport_templates();
        $templates = "'" . implode("','", array_map($db->escape_string, $templates)) . "'";
        // have to use $db->escape_string above instead of around $templates directly because otherwise it escapes the ' around the names, which are important
        $db->delete_query("templates", "title IN ({$templates}){$where_sql}");
    }
}
Example #2
0
$plugins->add_hook("newthread_do_newthread_end", "mysupport_set_is_support_thread");
$plugins->add_hook("newthread_start", "mysupport_newthread");
$plugins->add_hook("newthread_start", "mysupport_thread_info");
$plugins->add_hook("postbit", "mysupport_postbit");
$plugins->add_hook("search_results_start", "mysupport_forumdisplay_searchresults");
$plugins->add_hook("search_results_thread", "mysupport_threadlist_thread");
$plugins->add_hook("showthread_start", "mysupport_bump_thread_notice");
$plugins->add_hook("showthread_start", "mysupport_showthread");
$plugins->add_hook("usercp_menu_built", "mysupport_navoption", -10);
$plugins->add_hook("usercp_start", "mysupport_thread_list");
$plugins->add_hook("usercp_start", "mysupport_usercp_options");
global $templatelist;
if (isset($templatelist)) {
    $templatelist .= ',';
}
$mysupport_templates = mysupport_templates();
$mysupport_templates = implode(",", $mysupport_templates);
$templatelist .= $mysupport_templates;
/**
 * These are just here for when I'm debugging or updating templates, to run some code at runtime which is usually called in the upgrade function
**/
if (!defined("IN_ADMINCP")) {
    require_once MYBB_ROOT . "inc/plugins/mysupport/mysupport.php";
    /*if(!defined("MYBB_ADMIN_DIR"))
    	{
    		define("MYBB_ADMIN_DIR", MYBB_ROOT."/admin/");
    	}*/
    //mysupport_do_templates(0, true);
    //mysupport_do_templates(1);
    //mysupport_template_edits(0);
    //mysupport_template_edits(1);