([^\<]*)\<\/a\>/i');
+ $to = array("\\r\\n' + \r\n'", "$1", "$1");
+ return preg_replace($from,$to,$str);
+} // END hesk_jsString()
+
+
+function hesk_myCategories($what='category')
+{
+ if ( ! empty($_SESSION['isadmin']) )
+ {
+ return '1';
+ }
+ else
+ {
+ return " `".hesk_dbEscape($what)."` IN ('" . implode("','", array_map('intval', $_SESSION['categories']) ) . "')";
+ }
+} // END hesk_myCategories()
+
+
+function hesk_okCategory($cat,$error=1,$user_isadmin=false,$user_cat=false)
+{
+ global $hesklang;
+
+ /* Checking for current user or someone else? */
+ if ($user_isadmin === false)
+ {
+ $user_isadmin = $_SESSION['isadmin'];
+ }
+
+ if ($user_cat === false)
+ {
+ $user_cat = $_SESSION['categories'];
+ }
+
+ /* Is admin? */
+ if ($user_isadmin)
+ {
+ return true;
+ }
+ /* Staff with access? */
+ elseif (in_array($cat,$user_cat))
+ {
+ return true;
+ }
+ /* No access */
+ else
+ {
+ if ($error)
+ {
+ hesk_error($hesklang['not_authorized_tickets']);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+} // END hesk_okCategory()
+
+
+function hesk_checkPermission($feature,$showerror=1) {
+ global $hesklang;
+
+ /* Admins have full access to all features */
+ if ($_SESSION['isadmin'])
+ {
+ return true;
+ }
+
+ /* Check other staff for permissions */
+ if (strpos($_SESSION['heskprivileges'], $feature) === false)
+ {
+ if ($showerror)
+ {
+ hesk_error($hesklang['no_permission'].'
'.$hesklang['click_login'].'');
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return true;
+ }
+
+} // END hesk_checkPermission()
diff --git a/inc/common.inc.php b/inc/common.inc.php
index 54fad097..f0548935 100644
--- a/inc/common.inc.php
+++ b/inc/common.inc.php
@@ -1853,3 +1853,55 @@ function hesk_round_to_half($num)
return $half;
}
} // END hesk_round_to_half()
+
+function hesk_dateToString($dt, $returnName=1, $returnTime=0, $returnMonth=0, $from_database=false)
+{
+ global $hesk_settings, $hesklang;
+
+ $dt = strtotime($dt);
+
+ // Adjust MySQL time if different from PHP time
+ if ($from_database)
+ {
+ if ( ! defined('MYSQL_TIME_DIFF') )
+ {
+ define('MYSQL_TIME_DIFF', time()-hesk_dbTime() );
+ }
+
+ if (MYSQL_TIME_DIFF != 0)
+ {
+ $dt += MYSQL_TIME_DIFF;
+ }
+
+ // Add HESK set time difference
+ $dt += 3600*$hesk_settings['diff_hours'] + 60*$hesk_settings['diff_minutes'];
+
+ // Daylight saving?
+ if ($hesk_settings['daylight'] && date('I', $dt))
+ {
+ $dt += 3600;
+ }
+ }
+
+ list($y,$m,$n,$d,$G,$i,$s) = explode('-', date('Y-n-j-w-G-i-s', $dt) );
+
+ $m = $hesklang['m'.$m];
+ $d = $hesklang['d'.$d];
+
+ if ($returnName)
+ {
+ return "$d, $m $n, $y";
+ }
+
+ if ($returnTime)
+ {
+ return "$d, $m $n, $y $G:$i:$s";
+ }
+
+ if ($returnMonth)
+ {
+ return "$m $y";
+ }
+
+ return "$m $n, $y";
+} // End hesk_dateToString()