Index: trunk/kernel/include/parseditem.php
===================================================================
diff -u -N -r3736 -r3907
--- trunk/kernel/include/parseditem.php (.../parseditem.php) (revision 3736)
+++ trunk/kernel/include/parseditem.php (.../parseditem.php) (revision 3907)
@@ -666,6 +666,21 @@
var $QueryDone = false;
var $LastQuerySQL = '';
+
+ /**
+ * Application object
+ *
+ * @var kApplication
+ */
+ var $Application = null;
+
+ /**
+ * Connection to database
+ *
+ * @var kDBConnection
+ */
+ var $Conn = null;
+
function SetTable($action, $table_name = null) // new by Alex
{
// $action = {'live', 'restore','edit'}
@@ -695,11 +710,16 @@
function clsItemCollection()
{
-
- $this->adodbConnection = &GetADODBConnection();
-
- $this->Clear();
- $this->BasePermission="";
+ if (class_exists('kApplication')) {
+ // just in case when aplication is not found
+ $this->Application =& kApplication::Instance();
+ $this->Conn =& $this->Application->GetADODBConnection();
+ }
+
+ $this->adodbConnection =& GetADODBConnection();
+
+ $this->Clear();
+ $this->BasePermission = '';
}
function GetIDField() // new by Alex
Index: trunk/kernel/include/portaluser.php
===================================================================
diff -u -N -r3895 -r3907
--- trunk/kernel/include/portaluser.php (.../portaluser.php) (revision 3895)
+++ trunk/kernel/include/portaluser.php (.../portaluser.php) (revision 3907)
@@ -924,8 +924,7 @@
$fields_hash['IsBanned'] = 0;
}
- if (getArrayValue($fields_hash['Password'])) {
- $user->Set('Password', $fields_hash['Password']);
+ if (isset($fields_hash['Password']) && !$fields_hash['Password']) {
unset($fields_hash['Password']);
}
@@ -1083,29 +1082,38 @@
$edit_table = $objSession->GetEditTable($this->SourceTable);
$sql = "SELECT * FROM $edit_table";
$rs = $this->adodbConnection->Execute($sql);
+ $user_dummy =& $this->Application->recallObject('u.-item', null, Array('skip_autoload' => true));
- //echo $sql."
";
$item_ids = Array();
- while($rs && !$rs->EOF)
- {
+ while ($rs && !$rs->EOF) {
$data = $rs->fields;
$c = new $this->classname;
$c->SetFromArray($data);
$c->idfield = $idfield;
$c->Dirty();
- if($c->Get($idfield)<1)
- {
- $old_id = $c->Get($idfield);
- $c->UnsetIdField();
- $c->Create();
- $sql = "UPDATE ".GetTablePrefix()."UserGroup SET PortalUserId=".$c->Get("PortalUserId");
- $sql .=" WHERE PortalUserId=0";
- $this->adodbConnection->Execute($sql);
+ $user_dummy->SetDBFieldsFromHash($data);
+
+ if ($c->Get($idfield) < 1) {
+ $old_id = $c->Get($idfield);
+ $c->UnsetIdField();
+ $c->Create();
+ $sql = "UPDATE ".GetTablePrefix()."UserGroup SET PortalUserId=".$c->Get("PortalUserId");
+ $sql .=" WHERE PortalUserId=0";
+ $this->adodbConnection->Execute($sql);
+ $event_name = 'OnAfterItemCreate';
}
- else
- {
- $c->Update();
+ else {
+ $c->Update();
+ $event_name = 'OnAfterItemUpdate';
}
+ $user_dummy->setID($c->UniqueId());
+
+ // process after hooks: begin
+ $event = new kEvent('u.-item:'.$event_name);
+ $event->setEventParam('id', $user_dummy->GetID() );
+ $this->Application->HandleEvent($event);
+ // process after hooks: end
+
$item_ids[] = $c->UniqueId();
unset($c);
Index: trunk/core/units/users/users_config.php
===================================================================
diff -u -N -r3840 -r3907
--- trunk/core/units/users/users_config.php (.../users_config.php) (revision 3840)
+++ trunk/core/units/users/users_config.php (.../users_config.php) (revision 3907)
@@ -69,10 +69,13 @@
'Password' => Array('type' => 'string', 'formatter' => 'kPasswordFormatter', 'encryption_method' => 'md5', 'verify_field' => 'VerifyPassword', 'skip_empty' => 1, 'default' => md5('') ),
'FirstName' => Array('type' => 'string','default' => ''),
'LastName' => Array('type' => 'string','default' => ''),
+ 'Company' => Array('type' => 'string','not_null' => '1','default' => ''),
'Email' => Array('type' => 'string', 'formatter'=>'kFormatter', 'regexp'=>'/^[_a-zA-Z0-9-\.]+@[a-zA-Z0-9-\.]+\.[a-z]{2,4}$/', 'unique'=>Array('Email'), 'not_null' => '1', 'required'=>1, 'default' => '', 'error_msgs' => Array('invalid_format'=>'!la_invalid_email!', 'unique'=>'!lu_email_already_exist!') ),
'CreatedOn' => Array('type'=>'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#', 'not_null' => '1' ),
'Phone' => Array('type' => 'string','default' => ''),
+ 'Fax' => Array('type' => 'string','not_null' => '1','default' => ''),
'Street' => Array('type' => 'string','default' => ''),
+ 'Street2' => Array('type' => 'string', 'not_null' => '1', 'default' => ''),
'City' => Array('type' => 'string','default' => ''),
'State' => Array('formatter'=>'kOptionsFormatter',
'options' => Array(),
Index: trunk/core/units/users/users_item.php
===================================================================
diff -u -N -r3834 -r3907
--- trunk/core/units/users/users_item.php (.../users_item.php) (revision 3834)
+++ trunk/core/units/users/users_item.php (.../users_item.php) (revision 3907)
@@ -229,6 +229,23 @@
return $ret;
}
+ function setName($full_name)
+ {
+ $full_name = explode(' ', $full_name);
+
+ if (count($full_name) > 2) {
+ $last_name = array_pop($full_name);
+ $first_name = implode(' ', $full_name);
+ }
+ else {
+ $last_name = $full_name[1];
+ $first_name = $full_name[0];
+ }
+
+ $this->SetDBField('FirstName', $first_name);
+ $this->SetDBField('LastName', $last_name);
+ }
+
}
?>
\ No newline at end of file
Index: trunk/kernel/units/users/users_config.php
===================================================================
diff -u -N -r3840 -r3907
--- trunk/kernel/units/users/users_config.php (.../users_config.php) (revision 3840)
+++ trunk/kernel/units/users/users_config.php (.../users_config.php) (revision 3907)
@@ -69,10 +69,13 @@
'Password' => Array('type' => 'string', 'formatter' => 'kPasswordFormatter', 'encryption_method' => 'md5', 'verify_field' => 'VerifyPassword', 'skip_empty' => 1, 'default' => md5('') ),
'FirstName' => Array('type' => 'string','default' => ''),
'LastName' => Array('type' => 'string','default' => ''),
+ 'Company' => Array('type' => 'string','not_null' => '1','default' => ''),
'Email' => Array('type' => 'string', 'formatter'=>'kFormatter', 'regexp'=>'/^[_a-zA-Z0-9-\.]+@[a-zA-Z0-9-\.]+\.[a-z]{2,4}$/', 'unique'=>Array('Email'), 'not_null' => '1', 'required'=>1, 'default' => '', 'error_msgs' => Array('invalid_format'=>'!la_invalid_email!', 'unique'=>'!lu_email_already_exist!') ),
'CreatedOn' => Array('type'=>'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#', 'not_null' => '1' ),
'Phone' => Array('type' => 'string','default' => ''),
+ 'Fax' => Array('type' => 'string','not_null' => '1','default' => ''),
'Street' => Array('type' => 'string','default' => ''),
+ 'Street2' => Array('type' => 'string', 'not_null' => '1', 'default' => ''),
'City' => Array('type' => 'string','default' => ''),
'State' => Array('formatter'=>'kOptionsFormatter',
'options' => Array(),
Index: trunk/kernel/units/users/users_item.php
===================================================================
diff -u -N -r3834 -r3907
--- trunk/kernel/units/users/users_item.php (.../users_item.php) (revision 3834)
+++ trunk/kernel/units/users/users_item.php (.../users_item.php) (revision 3907)
@@ -229,6 +229,23 @@
return $ret;
}
+ function setName($full_name)
+ {
+ $full_name = explode(' ', $full_name);
+
+ if (count($full_name) > 2) {
+ $last_name = array_pop($full_name);
+ $first_name = implode(' ', $full_name);
+ }
+ else {
+ $last_name = $full_name[1];
+ $first_name = $full_name[0];
+ }
+
+ $this->SetDBField('FirstName', $first_name);
+ $this->SetDBField('LastName', $last_name);
+ }
+
}
?>
\ No newline at end of file
Index: trunk/admin/include/mainscript.php
===================================================================
diff -u -N -r3736 -r3907
--- trunk/admin/include/mainscript.php (.../mainscript.php) (revision 3736)
+++ trunk/admin/include/mainscript.php (.../mainscript.php) (revision 3907)
@@ -66,6 +66,9 @@
$ampm = is12HourMode() ? 'true' : 'false';
+$processable_formats = Array('m/d/y', 'm/d/Y');
+
+$skip_date_validation = in_array(GetDateFormat(), $processable_formats) ? 'false' : 'true';
$SiteName = addslashes( strip_tags( $GLOBALS['objConfig']->Get('Site_Name') ) );
require_once($pathtoroot.$admin."/lv/js/js_lang.php");
@@ -106,6 +109,7 @@
var lang_MoveUp = "$lang_MoveUp";
var lang_MoveDn = "$lang_MoveDn";
var ampm = $ampm;
+var skip_date_validation = $skip_date_validation;
var listview_clear=1;
var CalDateFormat = "$Cal";
@@ -302,7 +306,10 @@
function ValidDate(date_str)
{
var valid = true;
-
+ if (skip_date_validation) {
+ return valid;
+ }
+
if( trim(date_str) == '' ) return true; // is valid in case if not entered
parts = date_str.split(/\s*\D\s*/);
Index: trunk/core/kernel/event_manager.php
===================================================================
diff -u -N -r3905 -r3907
--- trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 3905)
+++ trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 3907)
@@ -70,6 +70,9 @@
*/
var $afterHooks = Array();
+
+ var $recursionStack = Array();
+
function kEventManager()
{
parent::kBase();
@@ -153,13 +156,41 @@
}
/**
+ * Check if event is called twice, that causes recursion
+ *
+ * @param kEvent $event
+ */
+ function isRecursion(&$event)
+ {
+ $event_key = $event->getPrefixSpecial().':'.$event->Name;
+ return in_array($event_key, $this->recursionStack) ? true : false;
+ }
+
+ function pushEvent(&$event)
+ {
+ $event_key = $event->getPrefixSpecial().':'.$event->Name;
+ array_push($this->recursionStack, $event_key);
+ }
+
+ function popEvent()
+ {
+ array_pop($this->recursionStack);
+ }
+
+ /**
* Allows to process any type of event
*
* @param kEvent $event
* @access public
*/
function HandleEvent(&$event)
{
+ if ($this->isRecursion($event)) {
+ return true;
+ }
+
+ $this->pushEvent($event);
+
if( !$this->Application->prefixRegistred($event->Prefix) )
{
trigger_error('Prefix '.$event->Prefix.' not registred (requested event '.$event->Name.')', E_USER_NOTICE);
@@ -179,6 +210,8 @@
$this->processHooks($event, hAFTER);
}
+ $this->popEvent();
+
return true;
}
@@ -346,6 +379,11 @@
if ($hooks) {
foreach ($hooks as $hook) {
+ if ($hook['DoSpecial'] == '*') {
+ // use same special as master event
+ $hook['DoSpecial'] = $event->Special;
+ }
+
$prefix_special = rtrim($hook['DoPrefix'].'_'.$hook['DoSpecial'], '_');
if ( $hook['Conditional'] && !$this->Application->GetVar($prefix_special) ) {
continue;
Index: trunk/kernel/include/itemdb.php
===================================================================
diff -u -N -r3576 -r3907
--- trunk/kernel/include/itemdb.php (.../itemdb.php) (revision 3576)
+++ trunk/kernel/include/itemdb.php (.../itemdb.php) (revision 3907)
@@ -4,24 +4,44 @@
class clsItemDB
{
- var $Formatters = Array(); // by Alex
- var $m_dirtyFieldsMap = array();
- var $Data = array();
- var $adodbConnection;
- var $tablename;
- var $BasePermission;
- var $id_field;
- var $NoResourceId;
- var $debuglevel;
-
- var $SelectSQL = 'SELECT * FROM %s WHERE %s';
+ var $Formatters = Array(); // by Alex
+ var $m_dirtyFieldsMap = array();
+ var $Data = array();
+ var $adodbConnection;
+ var $tablename;
+ var $BasePermission;
+ var $id_field;
+ var $NoResourceId;
+ var $debuglevel;
+
+ var $SelectSQL = 'SELECT * FROM %s WHERE %s';
+ /**
+ * Application object
+ *
+ * @var kApplication
+ */
+ var $Application = null;
+
+ /**
+ * Connection to database
+ *
+ * @var kDBConnection
+ */
+ var $Conn = null;
+
function clsItemDB()
{
- $this->adodbConnection = &GetADODBConnection();
- $this->tablename="";
- $this->NoResourceId=0;
- $this->debuglevel=0;
+ if (class_exists('kApplication')) {
+ // just in case when aplication is not found
+ $this->Application =& kApplication::Instance();
+ $this->Conn =& $this->Application->GetADODBConnection();
+ }
+
+ $this->adodbConnection = &GetADODBConnection();
+ $this->tablename="";
+ $this->NoResourceId=0;
+ $this->debuglevel=0;
}
// ============================================================================================
@@ -292,6 +312,8 @@
{
global $Errors, $objSession;
+ if( !$this->raiseEvent('OnBeforeItemUpdate') ) return false;
+
if( count($this->m_dirtyFieldsMap) == 0 ) return true;
$this->SetModified($UpdatedBy, $modificationDate);
@@ -324,6 +346,9 @@
}
if( $objSession->GetVariable('HasChanges') == 2 ) $objSession->SetVariable('HasChanges', 1);
+
+ $this->raiseEvent('OnAfterItemUpdate');
+
return true;
}
@@ -416,7 +441,9 @@
function Create()
{
global $Errors, $objSession;
-
+
+ if( !$this->raiseEvent('OnBeforeItemCreate') ) return false;
+
if($this->debuglevel) echo "Creating Item: ".get_class($this)."
";
if($this->NoResourceId!=1 && (int)$this->Get("ResourceId")==0)
{
@@ -443,6 +470,8 @@
$objSession->SetVariable("HasChanges", 1);
} */
+ $this->raiseEvent('OnAfterItemCreate');
+
return true;
}
@@ -634,7 +663,22 @@
$rs = $db->Execute( sprintf($sql, strtolower($table) ) );
return ($rs->RecordCount() == 1) ? 1 : 0;
- }
+ }
+
+ function raiseEvent($name, $id = null)
+ {
+ return true;
+
+ /*if (!getArrayValue($GLOBALS, '_CopyFromEditTable')) {
+ return true;
+ }
+
+ if( !isset($id) ) $id = $this->GetID();
+ $event = new kEvent( Array('name'=>$name,'prefix'=>$this->Prefix,'special'=>$this->Special) );
+ $event->setEventParam('id', $id);
+ $this->Application->HandleEvent($event);
+ return $event->status == erSUCCESS ? true : false;*/
+ }
}
?>
Index: trunk/admin/head.php
===================================================================
diff -u -N -r3846 -r3907
--- trunk/admin/head.php (.../head.php) (revision 3846)
+++ trunk/admin/head.php (.../head.php) (revision 3907)
@@ -128,7 +128,7 @@
http_request.open('GET', '', true);
http_request.send(null);
- setTimeout('checkServer()', 60000);
+ setTimeout('checkServer()', 5 * 60000); // one time in 5 minutes
}
checkServer();