Index: trunk/globals.php
===================================================================
diff -u -r5514 -r6093
--- trunk/globals.php (.../globals.php) (revision 5514)
+++ trunk/globals.php (.../globals.php) (revision 6093)
@@ -103,7 +103,7 @@
$application =& kApplication::Instance();
return $application->GetADODBConnection();
}
-
+
if( !isset($DB) && strlen($g_DBType) > 0 )
{
$DB = ADONewConnection($g_DBType);
@@ -537,28 +537,28 @@
function ExtractDatePart($part, $datestamp)
{
if ($datestamp <= 0) return '';
-
+
$formats = Array( 'month' => 'm', 'day' => 'd', 'year' => 'Y',
'time_24hr' => 'H:i', 'time_12hr' => 'g:i a', 'time' => GetTimeFormat(), 'date' => GetDateFormat() );
-
+
$format = isset($formats[$part]) ? $formats[$part] : $part;
return adodb_date($format, $datestamp);
}
function GetLocalTime($TimeStamp, $TargetZone = null)
{
global $objConfig;
-
+
if ($TargetZone == null) {
$TargetZone = $objConfig->Get('Config_Site_Time');
}
-
+
$server = $objConfig->Get('Config_Server_Time');
if ($TargetZone != $server) {
$offset = ($server - $TargetZone) * -1;
$TimeStamp = $TimeStamp + (3600 * $offset);
}
-
+
return $TimeStamp;
}
@@ -873,11 +873,11 @@
if ($LangId == 0) {
$LangId = $objSession->Get('Language');
}
-
+
if ($LangId == 0) {
$LangId = $objLanguages->GetPrimary();
}
-
+
return $objLanguageCache->GetTranslation($phrase,$LangId);
}
@@ -1171,14 +1171,14 @@
function GetDateFormat($LangId = 0, $is_input = false)
{
global $objLanguages;
-
+
if (!$LangId) {
$LangId = $objLanguages->GetPrimary();
}
-
+
$l = $objLanguages->GetItem($LangId);
$fmt = is_object($l) ? $l->Get(($is_input ? 'Input' : '').'DateFormat') : 'm-d-Y';
-
+
if (getArrayValue($GLOBALS, 'FrontEnd')) {
return $fmt;
}
@@ -1193,7 +1193,7 @@
$LangId = $objLanguages->GetPrimary();
}
$l = $objLanguages->GetItem($LangId);
-
+
$fmt = is_object($l) ? $l->Get(($is_input ? 'Input' : '').'TimeFormat') : 'H:i:s';
return $fmt;
}
@@ -1567,13 +1567,13 @@
static $import_scripts = Array();
if( count($import_scripts) == 0 )
{
-
+
$sql = 'SELECT imp.* , m.LoadOrder
FROM '.TABLE_PREFIX.'ImportScripts imp
LEFT JOIN '.TABLE_PREFIX.'Modules m ON m.Name = imp.is_Module
WHERE m.Loaded = 1
ORDER BY m.LoadOrder';
-
+
$db =& GetADODBConnection();
$rs = $db->Execute($sql);
if ($rs && $rs->RecordCount() > 0) {
@@ -1615,10 +1615,10 @@
$main =& $GLOBALS[$prefix.'_var_list'];
$update =& $GLOBALS[$prefix.'_var_list_update'];
//echo "VAR: [$main]; VAR_UPDATE: [$update]
";
-
+
// if update var count is zero, then do nothing
if( !is_array($update) || count($update) == 0 ) return '';
-
+
// ensure that we have no empty values in enviroment variable
foreach($update as $vl_key => $vl_value) {
if(!$vl_value) $update[$vl_key] = '0'; // unset($update[$vl_key]);
@@ -1627,7 +1627,7 @@
foreach($main as $vl_key => $vl_value) {
if(!$vl_value) $main[$vl_key] = '0'; // unset($main[$vl_key]);
}
-
+
$ret = Array();
foreach($var_list as $var_name) {
$value = GetEnvVar($prefix, $var_name);
@@ -1640,25 +1640,25 @@
foreach ($keys as $key) {
unset($update[$key]);
}
-
+
return ':'.$prefix.implode('-',$ret);
}
// functions for dealign with enviroment variable construction
function GenerateModuleEnv_NEW($prefix, $var_list)
-{
+{
// globalize module varible arrays
$main =& $GLOBALS[$prefix.'_var_list'];
$update =& $GLOBALS[$prefix.'_var_list_update'];
//echo "VAR: [$main]; VAR_UPDATE: [$update]
";
-
+
if ( isset($update) && $update )
{
// ensure that we have no empty values in enviroment variable
foreach($update as $vl_key => $vl_value) {
if(!$vl_value) $update[$vl_key] = '0'; // unset($update[$vl_key]);
}
-
+
$app =& kApplication::Instance();
$passed = $app->GetVar('prefixes_passed');
$passed[] = $prefix;
@@ -1668,13 +1668,13 @@
{
return Array();
}
-
+
if ($main) {
foreach($main as $vl_key => $vl_value) {
if(!$vl_value) $main[$vl_key] = '0'; // unset($main[$vl_key]);
}
}
-
+
$ret = Array();
foreach($var_list as $src_name => $dst_name) {
$ret[$dst_name] = GetEnvVar($prefix, $src_name);
@@ -1701,7 +1701,7 @@
if ($submit_value !== false) {
return $submit_value;
}
-
+
return isset($update[$name]) ? $update[$name] : ( isset($main[$name]) ? $main[$name] : '');
}
@@ -1939,7 +1939,7 @@
header('Location: '.$adminURL.'/index.php?'.$redirect_params);
exit;
}
-
+
/**
* Builds up K4 url from data supplied by in-portal
*
@@ -1960,7 +1960,7 @@
$app =& kApplication::Instance();
return $app->HREF($t, '', $url_params, $index_file);
}
-
+
/**
* Set url params based on tag params & mapping hash passed
*
@@ -1975,11 +1975,11 @@
if( getArrayValue($tag_attribs, $tag_param) ) $url_params[$url_param] = $tag_attribs[$tag_param];
}
}
-
+
function ExtractParams($params_str, $separator = '&')
{
if(!$params_str) return Array();
-
+
$ret = Array();
$parts = explode($separator, trim($params_str, $separator) );
foreach ($parts as $part)
@@ -1989,7 +1989,7 @@
}
return $ret;
}
-
+
function &recallObject($var_name, $class_name)
{
if (!isset($GLOBALS[$var_name]) || !is_object($GLOBALS[$var_name]))
@@ -1998,7 +1998,7 @@
}
return $GLOBALS[$var_name];
}
-
+
/**
* Returns true in case of AM/PM time
*
@@ -2008,7 +2008,7 @@
{
return preg_match('/(a|A)/', GetTimeFormat() );
}
-
+
/**
* Saves custom fields for old in-portal items
*
@@ -2020,24 +2020,31 @@
{
$objCustomEdit = new clsCustomDataList();
$CustomFields = new clsCustomFieldList($item_type);
-
+
$data_changed = false;
for ($i = 0; $i < $CustomFields->NumItems(); $i++) {
$objField =& $CustomFields->GetItemRefByIndex($i);
$field_name = $objField->Get('FieldName');
+ $element_type = $objField->Get('ElementType');
$value = getCustomValue($field_name);
+
+ if ($element_type == 'checkbox' && $value === false) {
+ // unchecked checkboxes are not submitted
+ $value = 0;
+ }
+
if ($value !== false) {
$objCustomEdit->SetFieldValue($objField->Get('CustomFieldId'), $resource_id, $value);
$data_changed = true;
}
}
-
+
if ($data_changed) {
$objCustomEdit->SaveData($prefix, $resource_id);
}
}
-
+
/**
* Returns custom field value from submit
*
@@ -2055,30 +2062,30 @@
return GetVar($field_name);
}
- function checkActionPermission($action_mapping, $action)
+ function checkActionPermission($action_mapping, $action, $system = 0)
{
$application =& kApplication::Instance();
-
+
if (!isset($action_mapping[$action])) {
// if no permission mapping defined, then action is allowed in any case
return true;
}
-
+
$perm_status = false;
- $action_mapping = explode('|', $action_mapping[$action]);
+ $action_mapping = explode('|', $action_mapping[$action]);
foreach ($action_mapping as $perm_name) {
- $perm_status = $application->CheckPermission($perm_name, 0);
+ $perm_status = $application->CheckPermission($perm_name, $system);
if ($perm_status) {
break;
}
}
-
+
if (!$perm_status) {
$application->Redirect($application->IsAdmin() ? 'no_permission' : $application->ConfigValue('NoPermissionTemplate'), null, '', 'index.php');
}
return true;
}
-
+
function checkViewPermission($section_name, $system = 1)
{
$application =& kApplication::Instance();