<?php
//=======================================
//###################################
// Kayako Infotech Ltd. - SWIFT Framework
//
// Source Copyright 2001-2008 Kayako Infotech Ltd.
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                   www.kayako.com
//###################################
//=======================================

if (!defined("INSWIFT")) {
	trigger_error("Unable to process " . htmlentities($_SERVER['PHP_SELF']), E_USER_ERROR);
}

/**
* ###############################################
* HOW TO ADD YOUR OWN SECTION TO SWIFT
* ====================================================
* 1) If you wish to restrict your widgets to certain modules then use the $module->isRegistered function as used below
* 2) If you wish to simply create a link to another page then use the following code. Placement of this code decides the order of display of the icons, thus if you place the code at the very end then the icons you add will be displayed at the last order.
*
* EXAMPLE:
*	$_widgets[MODULE_NEWS]["icon"] = $_SWIFT["themepath"]."news.gif";
*	$_widgets[MODULE_NEWS]["title"] = $_SWIFT["language"]["news"];
*	$_widgets[MODULE_NEWS]["description"] = $_SWIFT["language"]["desc_news"];
*	$_widgets[MODULE_NEWS]["link"] = "index.php?_m=news&_a=view";
*
* icon - Full path to icon image, use the $_SWIFT["themepath"] variable if the icon is under themes/client_default
* title - Title of the widget
* description - Brief description of the section
* link - Full link to the section
* ###############################################
*/

$_widgets = array();
$index = 0;
if (empty($_SWIFT["user"]["userid"]) && $_SWIFT["loginapimodule"] == LOGINAPI_DEFAULT && $_SWIFT["user"]["permissions"]["perm_canviewregister"] != "0")
{
	// ======= REGISTER =======
	$_widgets[$index]["icon"] = $_SWIFT["themepath"]."register.gif";
	$_widgets[$index]["title"] = $_SWIFT["language"]["registerlogin"];
	$_widgets[$index]["description"] = $_SWIFT["language"]["desc_register"];
	$_widgets[$index]["link"] = "index.php?_m=core&_a=register";
	$index++;
}

if (!empty($_SWIFT["user"]["userid"]) && $module->isRegistered(MODULE_TICKETS)) {
	// ======= VIEW CURRENT SUPPORT TICKETS =======
	$_widgets[$index]["icon"] = $_SWIFT["themepath"]."viewtickets.gif";
	$_widgets[$index]["title"] = $_SWIFT["language"]["viewtickets"];
	$_widgets[$index]["description"] = $_SWIFT["language"]["desc_viewtickets"];
	$_widgets[$index]["link"] = iif(defined("ISMODERNBILL"), "user.php?op=menu&tile=mysupport&_m=tickets&_a=viewlist", "index.php?_m=tickets&_a=viewlist");
	$index++;
}

// ======= TICKETS =======
if ($module->isRegistered(MODULE_TICKETS) && $_SWIFT["user"]["permissions"]["perm_canviewsubmitticket"] != "0")
{
	$_widgets[$index]["icon"] = $_SWIFT["themepath"]."submitticket.gif";
	$_widgets[$index]["title"] = $_SWIFT["language"]["submitticket"];
	$_widgets[$index]["description"] = $_SWIFT["language"]["desc_submitticket"];
	$_widgets[$index]["link"] = iif(defined("ISMODERNBILL"), "user.php?op=menu&tile=getsupport_tab&_m=tickets&_a=submit", "index.php?_m=tickets&_a=submit");
	$index++;
}

// ======= KNOWLEDGEBASE =======
if ($module->isRegistered(MODULE_KNOWLEDGEBASE) && $_SWIFT["settings"]["kb_enableclient"] == 1 && $_SWIFT["user"]["permissions"]["perm_canviewknowledgebase"] != "0")
{
	$_widgets[$index]["icon"] = $_SWIFT["themepath"]."knowledgebase.gif";
	$_widgets[$index]["title"] = $_SWIFT["language"]["knowledgebase"];
	$_widgets[$index]["description"] = $_SWIFT["language"]["desc_knowledgebase"];
	$_widgets[$index]["link"] = iif(defined("ISMODERNBILL"), "user.php?op=menu&tile=faq&_m=knowledgebase&_a=view", "index.php?_m=knowledgebase&_a=view");

	$template->assign("cansearch", true);
	$template->assign("kbcansearch", true);

	$index++;
}

// ======= TROUBLESHOOTER =======
if ($module->isRegistered(MODULE_TROUBLESHOOTER) && $_SWIFT["settings"]["tr_enableclient"] == 1 && $_SWIFT["user"]["permissions"]["perm_canviewtroubleshooter"] != "0")
{
	$_widgets[$index]["icon"] = $_SWIFT["themepath"]."troubleshooter.gif";
	$_widgets[$index]["title"] = $_SWIFT["language"]["troubleshooter"];
	$_widgets[$index]["description"] = $_SWIFT["language"]["desc_troubleshooter"];
	$_widgets[$index]["link"] = "index.php?_m=troubleshooter&_a=view";

	$template->assign("cansearch", true);
	$template->assign("trcansearch", true);

	$index++;
}

// ======= NEWS =======
if ($module->isRegistered(MODULE_NEWS) && $_SWIFT["settings"]["nw_enableclient"] == 1 && $_SWIFT["user"]["permissions"]["perm_canviewnews"] != "0")
{
	$_widgets[$index]["icon"] = $_SWIFT["themepath"]."news.gif";
	$_widgets[$index]["title"] = $_SWIFT["language"]["news"];
	$_widgets[$index]["description"] = $_SWIFT["language"]["desc_news"];
	$_widgets[$index]["link"] = iif(defined("ISMODERNBILL"), "user.php?op=menu&tile=mynews_tab&_m=news&_a=view", "index.php?_m=news&_a=view");
	$index++;
}

// ======= DOWNLOADS =======
if ($module->isRegistered(MODULE_DOWNLOADS) && $_SWIFT["settings"]["dl_enableclient"] == 1 && $_SWIFT["user"]["permissions"]["perm_canviewdownloads"] != "0")
{
	$_widgets[$index]["icon"] = $_SWIFT["themepath"]."downloads.gif";
	$_widgets[$index]["title"] = $_SWIFT["language"]["downloads"];
	$_widgets[$index]["description"] = $_SWIFT["language"]["desc_downloads"];
	$_widgets[$index]["link"] = "index.php?_m=downloads&_a=view";

	$template->assign("cansearch", true);
	$template->assign("dlcansearch", true);

	$index++;
}


// ======= Purchaser =======
if ($module->isRegistered(MODULE_PURCHASE) && empty($_SWIFT["user"]["userid"]) && $_SWIFT["loginapimodule"] == LOGINAPI_TICKETPURCHASER)
{
	$_widgets[$index]["icon"] = $_SWIFT["themepath"]."register.gif";
	$_widgets[$index]["title"] = $_SWIFT["language"]["registerlogin"];
	$_widgets[$index]["description"] = $_SWIFT["language"]["desc_register"];
	$_widgets[$index]["link"] = "index.php?_m=purchase&_a=signup";
	$index++;
}

if ($module->isRegistered(MODULE_PURCHASE) && !empty($_SWIFT["user"]["userid"]) && $_SWIFT["loginapimodule"] == LOGINAPI_TICKETPURCHASER)
{
	$_widgets[$index]["icon"] = $_SWIFT["themepath"]."register.gif";
	$_widgets[$index]["title"] = $_SWIFT["language"]["purchase_tickets"];
	$_widgets[$index]["description"] = $_SWIFT["language"]["desc_purchase_tickets"];
	$_widgets[$index]["link"] = "index.php?_m=purchase&_a=purchase";
	$index++;
}
?>