Index: trunk/core/kernel/startup.php
===================================================================
diff -u -r7391 -r7855
--- trunk/core/kernel/startup.php (.../startup.php) (revision 7391)
+++ trunk/core/kernel/startup.php (.../startup.php) (revision 7855)
@@ -31,8 +31,8 @@
$vars = parse_portal_ini(FULL_PATH.'/config.php');
- define('APPLICATION_CLASS', isset($vars['ApplicationClass']) ? $vars['ApplicationClass'] : 'kApplication');
- define('APPLICATION_PATH', isset($vars['ApplicationPath']) ? $vars['ApplicationPath'] : '/core/kernel/application.php');
+ safeDefine('APPLICATION_CLASS', isset($vars['ApplicationClass']) ? $vars['ApplicationClass'] : 'kApplication');
+ safeDefine('APPLICATION_PATH', isset($vars['ApplicationPath']) ? $vars['ApplicationPath'] : '/core/kernel/application.php');
if (isset($vars['WriteablePath'])) {
define('WRITEABLE', FULL_PATH.$vars['WriteablePath']);
@@ -85,8 +85,8 @@
include_once(KERNEL_PATH.'/utility/debugger.php');
$debugger_end = getmicrotime();
if (isset($debugger) && constOn('DBG_PROFILE_INCLUDES')) {
-// $debugger->profileStart('inc_globals', KERNEL_PATH.'/globals.php', $globals_start);
-// $debugger->profileFinish('inc_globals', KERNEL_PATH.'/globals.php', $globals_end);
+ $debugger->profileStart('inc_globals', KERNEL_PATH.'/globals.php', $globals_start);
+ $debugger->profileFinish('inc_globals', KERNEL_PATH.'/globals.php', $globals_end);
$debugger->profilerAddTotal('includes', 'inc_globals');
$debugger->profileStart('inc_debugger', KERNEL_PATH.'/utility/debugger.php', $debugger_start);
Index: trunk/core/admin_templates/regional/languages_list.tpl
===================================================================
diff -u -r7635 -r7855
--- trunk/core/admin_templates/regional/languages_list.tpl (.../languages_list.tpl) (revision 7635)
+++ trunk/core/admin_templates/regional/languages_list.tpl (.../languages_list.tpl) (revision 7855)
@@ -1,6 +1,6 @@
-
+
Index: trunk/core/kernel/db/dbitem.php
===================================================================
diff -u -r7635 -r7855
--- trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 7635)
+++ trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 7855)
@@ -323,7 +323,7 @@
{
$skip = false;
$skip = $skip || ( isset($this->VirtualFields[$field_name]) ); //skipping 'virtual' field
- $skip = $skip || ( !getArrayValue($this->FieldValues, $field_name) && getArrayValue($this->Fields[$field_name], 'skip_empty') ); //skipping 'virtual' field
+ $skip = $skip || ( !getArrayValue($this->FieldValues, $field_name) && getArrayValue($this->Fields[$field_name], 'skip_empty') ); //skipping marked field with 'skip_empty'
// $skip = $skip || ($field_name == $this->IDField && !$force_id); //skipping Primary Key
// $table_name = preg_replace("/^(.*)\./", "$1", $field_name);
@@ -538,8 +538,14 @@
array_push($unique_fields,$field);
foreach($unique_fields as $unique_field)
{
- $where[] = '`'.$unique_field.'` = '.$this->Conn->qstr( $this->GetDBField($unique_field) );
+ // if field is not empty or if it is required - we add where condition
+ if ($this->GetDBField($unique_field) != '' || $this->Fields[$unique_field]['required']) {
+ $where[] = '`'.$unique_field.'` = '.$this->Conn->qstr( $this->GetDBField($unique_field) );
+ }
}
+ // This can ONLY happen if all unique fields are empty and not required.
+ // In such case we return true, because if unique field is not required there may be numerous empty values
+ if (!$where) return true;
$sql = 'SELECT COUNT(*) FROM %s WHERE ('.implode(') AND (',$where).') AND ('.$this->IDField.' <> '.(int)$this->ID.')';
@@ -669,38 +675,43 @@
$fields_sql = '';
$values_sql = '';
- foreach ($this->FieldValues as $field_name => $field_value)
- {
+ foreach ($this->FieldValues as $field_name => $field_value) {
if ($this->SkipField($field_name, $force_id)) continue;
- $fields_sql .= sprintf('`%s`, ',$field_name); //Adding field name to fields block of Insert statement
- //Adding field' value to Values block of Insert statement, escaping it with ADODB' qstr
- if (is_null( $this->FieldValues[$field_name] ))
- {
- if (isset($this->Fields[$field_name]['not_null']) && $this->Fields[$field_name]['not_null'])
- {
- $values_sql .= $this->Conn->qstr($this->Fields[$field_name]['default']).', ';
- }
- else
- {
- $values_sql .= 'NULL, ';
- }
- }
- else
- {
- $values_sql .= sprintf('%s, ',$this->Conn->qstr($this->FieldValues[$field_name], 0));
- }
+ //Adding field' value to Values block of Insert statement, escaping it with qstr
+ if (is_null( $this->FieldValues[$field_name] )) {
+ if (isset($this->Fields[$field_name]['not_null']) && $this->Fields[$field_name]['not_null']) {
+ $values_sql .= $this->Conn->qstr($this->Fields[$field_name]['default'], 0);
+ }
+ else {
+ $values_sql .= 'NULL';
+ }
+ }
+ else {
+ if ($field_name == $this->IDField && $this->FieldValues[$field_name] == 0) {
+ $values_sql .= 'DEFAULT';
+ }
+ else {
+ $values_sql .= $this->Conn->qstr($this->FieldValues[$field_name], 0);
+ }
+ }
+
+ $fields_sql .= '`'.$field_name.'`, '; //Adding field name to fields block of Insert statement
+ $values_sql .= ', ';
}
//Cutting last commas and spaces
$fields_sql = ereg_replace(", $", '', $fields_sql);
$values_sql = ereg_replace(", $", '', $values_sql);
$sql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->TableName, $fields_sql, $values_sql); //Formatting query
//Executing the query and checking the result
- if($this->Conn->ChangeQuery($sql) === false) return false;
+ if ($this->Conn->ChangeQuery($sql) === false) return false;
$insert_id = $this->Conn->getInsertID();
- if($insert_id == 0) $insert_id = $this->FieldValues[$this->IDField];
+ if ($insert_id == 0) {
+ // insert into temp table (id is not auto-increment field)
+ $insert_id = $this->FieldValues[$this->IDField];
+ }
$this->setID($insert_id);
if (!$system_create){
Index: trunk/core/units/groups/groups_config.php
===================================================================
diff -u -r7702 -r7855
--- trunk/core/units/groups/groups_config.php (.../groups_config.php) (revision 7702)
+++ trunk/core/units/groups/groups_config.php (.../groups_config.php) (revision 7855)
@@ -71,7 +71,7 @@
),
'Fields' => Array (
- 'GroupId' => Array(),
+ 'GroupId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'Name' => Array('type' => 'string', 'not_null' => '1', 'required' => 1, 'default' => ''),
'Description' => Array('type' => 'string','default' => ''),
'CreatedOn' => Array('type' => 'double', 'formatter' => 'kDateFormatter', 'not_null' => '1','default' => '#NOW#'),
Index: trunk/core/units/categories/categories_config.php
===================================================================
diff -u -r7702 -r7855
--- trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 7702)
+++ trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 7855)
@@ -220,7 +220,7 @@
'Fields' => Array
(
- 'CategoryId' => Array('type' => 'int','not_null' => 1,'default' => ''),
+ 'CategoryId' => Array('type' => 'int','not_null' => 1,'default' => 0),
'Type' => Array('type' => 'int','not_null' => 1,'default' => 0),
'ParentId' => Array('type' => 'int','not_null' => 1,'default' => 0),
'Name' => Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'required' => 1, 'default' => ''),
@@ -230,10 +230,9 @@
'CreatedOn' => Array('formatter' => 'kDateFormatter', 'default'=>'#NOW#', 'required' => 1, 'not_null' => 1),
'EditorsPick' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'Status' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Active', 2 => 'la_Pending', 0 => 'la_Disabled' ), 'use_phrases' => 1, 'not_null' => 1,'default' => 2),
- 'Pop' => Array('type' => 'int', 'default' => ''),
- 'Priority' => Array('type' => 'int', 'not_null' => 1, 'default' => ''),
+ 'Priority' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'MetaKeywords' => Array('type' => 'string', 'default' => ''),
- 'CachedDescendantCatsQty' => Array('type' => 'int', 'default' => ''),
+ 'CachedDescendantCatsQty' => Array('type' => 'int', 'default' => 0),
'CachedNavbar' => Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'default' => ''),
'CreatedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1,'default' => '0'),
'ResourceId' => Array('type' => 'int', 'default' => ''),
Index: trunk/core/units/admin/admin_events_handler.php
===================================================================
diff -u -r7391 -r7855
--- trunk/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 7391)
+++ trunk/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 7855)
@@ -29,7 +29,7 @@
function OnResetConfigsCache(&$event)
{
- $this->Conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_files" OR VarName = "configs_parsed"');
+ $this->Conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_files" OR VarName = "configs_parsed" OR VarName = "sections_parsed"');
}
/**
@@ -76,7 +76,7 @@
*/
function OnStartup(&$event)
{
-
+
}
/**
Index: trunk/core/units/languages/languages_event_handler.php
===================================================================
diff -u -r7635 -r7855
--- trunk/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 7635)
+++ trunk/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 7855)
@@ -220,6 +220,7 @@
{
$modules = getArrayValue($field_values,'Module');
$lang_xml =& $this->Application->recallObject('LangXML');
+ /* @var $lang_xml LangXML_Parser */
$lang_xml->Parse($filename, $field_values['PhraseType'], $modules, $field_values['ImportOverwrite']);
$event->redirect = true;
Index: trunk/core/admin_templates/config/config_universal.tpl
===================================================================
diff -u -r7635 -r7855
--- trunk/core/admin_templates/config/config_universal.tpl (.../config_universal.tpl) (revision 7635)
+++ trunk/core/admin_templates/config/config_universal.tpl (.../config_universal.tpl) (revision 7855)
@@ -3,7 +3,7 @@
-
+
@@ -46,7 +46,7 @@
View In:
|
|
- |