Index: branches/5.2.x/core/units/users/users_event_handler.php =================================================================== diff -u -N -r14434 -r14437 --- branches/5.2.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 14434) +++ branches/5.2.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 14437) @@ -1,6 +1,6 @@ Array('self' => 'view'), // because setting to logged in user only 'OnUpdateRootPassword' => Array('self' => true), - 'OnUpdatePassword' => Array('self' => true), + 'OnUpdatePassword' => Array('self' => true), + 'OnSaveSelected' => Array ('self' => 'view'), // front 'OnRefreshForm' => Array('self' => true), @@ -59,12 +60,12 @@ $object =& $event->getObject(); /* @var $object kDBList */ - if ($event->Special == 'admins') { - $object->addFilter('primary_filter', 'ug.GroupId = 11'); + if ($event->Special == 'regular') { + $object->addFilter('primary_filter', '%1$s.UserType = ' . UserType::USER); } - if ($event->Special == 'regular') { - $object->addFilter('primary_filter', 'ug.GroupId <> 11 OR ug.GroupId IS NULL'); + if ($event->Special == 'admins') { + $object->addFilter('primary_filter', '%1$s.UserType = ' . UserType::ADMIN); } if (!$this->Application->isAdminUser) { @@ -77,16 +78,16 @@ if ($event->Special == 'group') { $group_id = $this->Application->GetVar('g_id'); + if ($group_id !== false) { // show only users, that user doesn't belong to current group - $table_name = $this->Application->GetTempName(TABLE_PREFIX.'UserGroup', 'prefix:g'); $sql = 'SELECT PortalUserId - FROM ' . $table_name . ' + FROM ' . $this->Application->GetTempName(TABLE_PREFIX.'UserGroup', 'prefix:g') . ' WHERE GroupId = ' . (int)$group_id; $user_ids = $this->Conn->GetCol($sql); -// array_push($user_ids); // Guest & Everyone groups are set dynamically + if ($user_ids) { - $object->addFilter('already_member_filter', '%1$s.PortalUserId NOT IN ('.implode(',', $user_ids).')'); + $object->addFilter('already_member_filter', '%1$s.PortalUserId NOT IN (' . implode(',', $user_ids) . ')'); } } } @@ -298,46 +299,24 @@ { $this->saveUserImages($event); - if ($this->Application->GetVar('skip_set_primary')) return; - $is_subscriber = $this->Application->GetVar('IsSubscriber'); - if(!$is_subscriber) - { - $object =& $event->getObject(); + $object =& $event->getObject(); + /* @var $object kDBItem */ - $ug_table = TABLE_PREFIX.'UserGroup'; - if ($object->IsTempTable()) { - $ug_table = $this->Application->GetTempName($ug_table, 'prefix:'.$event->Prefix); - } + $primary_group_id = $object->GetDBField('PrimaryGroupId'); - $sql = 'UPDATE '.$ug_table.' - SET PrimaryGroup = 0 - WHERE PortalUserId = '.$object->GetDBField('PortalUserId'); - $this->Conn->Query($sql); + if ($primary_group_id) { + $ug_table = TABLE_PREFIX . 'UserGroup'; - // set primary group to user - if ($this->Application->isAdminUser && $this->Application->GetVar('user_group')) { - // while in admin you can set any group for new users - $group_id = $this->Application->GetVar('user_group'); + if ( $object->IsTempTable() ) { + $ug_table = $this->Application->GetTempName($ug_table, 'prefix:' . $event->Prefix); } - else { - $group_id = $object->GetDBField('UserGroup'); - if ($group_id) { - // check, that group is allowed for Front-End - $sql = 'SELECT GroupId - FROM ' . TABLE_PREFIX . 'PortalGroup - WHERE GroupId = ' . (int)$group_id . ' AND FrontRegistration = 1'; - $group_id = $this->Conn->GetOne($sql); - } + $fields_hash = Array ( + 'PortalUserId' => $object->GetID(), + 'GroupId' => $primary_group_id, + ); - if (!$group_id) { - // when group not selected -> use default group - $group_id = $this->Application->ConfigValue('User_NewGroup'); - } - } - - $sql = 'REPLACE INTO '.$ug_table.'(PortalUserId,GroupId,PrimaryGroup) VALUES (%s,%s,1)'; - $this->Conn->Query( sprintf($sql, $object->GetID(), $group_id) ); + $this->Conn->doInsert($fields_hash, $ug_table, 'REPLACE'); } } @@ -369,31 +348,30 @@ { $ret = false; $object =& $event->getObject( Array('skip_autoload' => true) ); + $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); - if($items_info) - { + + if ($items_info) { list($id, $field_values) = each($items_info); $user_email = isset($field_values['Email']) ? $field_values['Email'] : false; - if($user_email) - { + + if ($user_email) { // check if is subscriber $verify_user =& $this->Application->recallObject('u.verify', null, Array('skip_autoload' => true) ); $verify_user->Load($user_email, 'Email'); - if( $verify_user->isLoaded() && $verify_user->isSubscriberOnly() ) - { + + if ( $verify_user->isLoaded() && $verify_user->isSubscriberOnly() ) { $items_info = Array( $verify_user->GetDBField('PortalUserId') => $field_values ); $this->Application->SetVar($event->getPrefixSpecial(true), $items_info); $ret = true; } } } - if( isset($event->MasterEvent) ) - { + if ( isset($event->MasterEvent) ) { $event->MasterEvent->setEventParam('is_subscriber_only', $ret); } - else - { + else { $event->setEventParam('is_subscriber_only', $ret); } } @@ -443,18 +421,20 @@ $this->setUserStatus($event); } - if (!$this->isSubscriberOnly($event)) { + if ( !$this->isSubscriberOnly($event) ) { $object =& $event->getObject( Array('skip_autoload' => true) ); /* @var $object kDBItem */ - if ($this->Application->ConfigValue('User_Password_Auto')) { - $pass = kUtil::generatePassword(rand(5,8)); + + if ( $this->Application->ConfigValue('User_Password_Auto') ) { + $pass = kUtil::generatePassword( rand(5, 8) ); $object->SetField('Password', $pass); $object->SetField('VerifyPassword', $pass); - $this->Application->SetVar('user_password',$pass); + $this->Application->SetVar('user_password', $pass); } + parent::OnCreate($event); - $this->Application->SetVar('u.current_id', $object->getID() ); // for affil:OnRegisterAffiliate after hook + $this->Application->SetVar('u.current_id', $object->getID()); // for affil:OnRegisterAffiliate after hook $this->setNextTemplate($event); @@ -512,7 +492,7 @@ $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); /* @var $cs_helper kCountryStatesHelper */ - if (!$this->isSubscriberOnly($event, true)) { + if ( !$this->isSubscriberOnly($event, true) ) { $cs_helper->CheckStateField($event, 'State', 'Country'); } else { @@ -531,6 +511,7 @@ } $object->setLogin(); + $this->setUserGroup($object); $user_helper =& $this->Application->recallObject('UserHelper'); /* @var $user_helper UserHelper */ @@ -542,17 +523,51 @@ } /** + * Sets primary group of the user + * + * @param kDBItem $object + */ + protected function setUserGroup(&$object) + { + if ($object->Special == 'subscriber') { + $object->SetDBField('PrimaryGroupId', $this->Application->ConfigValue('User_SubscriberGroup')); + + return ; + } + + // set primary group to user + if ( !$this->Application->isAdminUser ) { + $group_id = $object->GetDBField('PrimaryGroupId'); + + if ($group_id) { + // check, that group is allowed for Front-End + $sql = 'SELECT GroupId + FROM ' . TABLE_PREFIX . 'PortalGroup + WHERE GroupId = ' . (int)$group_id . ' AND FrontRegistration = 1'; + $group_id = $this->Conn->GetOne($sql); + } + + if (!$group_id) { + // when group not selected OR not allowed -> use default group + $object->SetDBField('PrimaryGroupId', $this->Application->ConfigValue('User_NewGroup')); + } + } + } + + /** * Set's new unique resource id to user * * @param kEvent $event */ function OnAfterItemValidate(&$event) { $object =& $event->getObject(); + /* @var $object kDBItem */ + $resource_id = $object->GetDBField('ResourceId'); - if (!$resource_id) - { - $object->SetDBField('ResourceId', $this->Application->NextResourceId() ); + + if (!$resource_id) { + $object->SetDBField('ResourceId', $this->Application->NextResourceId()); } } @@ -654,21 +669,24 @@ function OnSubscribeQuery(&$event) { $user_email = $this->Application->GetVar('subscriber_email'); - if (preg_match('/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i', $user_email)) { - $object =& $this->Application->recallObject($this->Prefix.'.subscriber', null, Array('skip_autoload' => true)); + if ( preg_match('/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i', $user_email) ) { + $object =& $this->Application->recallObject($this->Prefix . '.subscriber', null, Array('skip_autoload' => true)); /* @var $object UsersItem */ - $this->Application->StoreVar('SubscriberEmail', $user_email); - $object->Load($user_email, 'Email'); - if ($object->isLoaded()) { - $group_info = $this->GetGroupInfo($object->GetID()); - $event->redirect = $this->Application->GetVar($group_info ? 'unsubscribe_template' : 'subscribe_template'); + $event->SetRedirectParam('subscriber_email', $user_email); + + if ( $object->isLoaded() ) { + if ( $this->isSubscribed($object) ) { + $event->redirect = $this->Application->GetVar('unsubscribe_template'); + } + else { + $event->redirect = $this->Application->GetVar('subscribe_template'); + } } else { $event->redirect = $this->Application->GetVar('subscribe_template'); - $this->Application->StoreVar('SubscriberEmail', $user_email); } } else { @@ -688,93 +706,104 @@ */ function OnSubscribeUser(&$event) { - $object = &$this->Application->recallObject($this->Prefix.'.subscriber', null, Array('skip_autoload' => true)); + $object = &$this->Application->recallObject($this->Prefix . '.subscriber', null, Array('skip_autoload' => true)); /* @var $object UsersItem */ - $user_email = $this->Application->RecallVar('SubscriberEmail'); - if (preg_match('/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i', $user_email)) { + $user_email = $this->Application->GetVar('subscriber_email'); + + if ( preg_match('/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i', $user_email) ) { $this->RemoveRequiredFields($object); $object->Load($user_email, 'Email'); - if ($object->isLoaded()) { - $group_info = $this->GetGroupInfo($object->GetID()); + if ( $object->isLoaded() ) { + if ( $this->isSubscribed($object) ) { + if ( $event->getEventParam('no_unsubscribe') ) { + // for customization code from FormsEventHandler + return ; + } - if ($group_info){ - if ($event->getEventParam('no_unsubscribe')) return; - - if ($group_info['PrimaryGroup']){ + if ( $object->isSubscriberOnly() ) { $this->Application->SetVar($object->getPrefixSpecial(true) . '_id', $object->GetID()); $delete_event = new kEvent($object->getPrefixSpecial() . ':OnDelete'); $this->Application->HandleEvent($delete_event); } else { - $this->RemoveSubscriberGroup($object->GetID()); + $this->RemoveSubscriberGroup( $object->GetID() ); } $event->redirect = $this->Application->GetVar('unsubscribe_ok_template'); } else { - $this->AddSubscriberGroup($object->GetID(), 0); + $this->AddSubscriberGroup($object); $event->redirect = $this->Application->GetVar('subscribe_ok_template'); } } else { - $object->SetField('Email', $user_email); - $object->SetField('Login', $user_email); - $object->SetDBField('dob', 1); - $object->SetDBField('dob_date', 1); - $object->SetDBField('dob_time', 1); + $object->SetDBField('Email', $user_email); + $object->SetDBField('Login', $user_email); $object->SetDBField('Status', STATUS_ACTIVE); // make user subscriber Active by default - $ip = getenv('HTTP_X_FORWARDED_FOR')?getenv('HTTP_X_FORWARDED_FOR'):getenv('REMOTE_ADDR'); - $object->SetDBField('ip', $ip); + $object->SetDBField('ip', $_SERVER['REMOTE_ADDR']); - $this->Application->SetVar('IsSubscriber', 1); - - if ($object->Create()) { - $this->AddSubscriberGroup($object->GetID(), 1); + if ( $object->Create() ) { + $this->AddSubscriberGroup($object); $event->redirect = $this->Application->GetVar('subscribe_ok_template'); } - - $this->Application->SetVar('IsSubscriber', 0); } } } - function AddSubscriberGroup($user_id, $is_primary) + /** + * Adding user to subscribers group + * + * @param UsersItem $object + */ + function AddSubscriberGroup(&$object) { - $group_id = $this->Application->ConfigValue('User_SubscriberGroup'); - $sql = 'INSERT INTO ' . TABLE_PREFIX . 'UserGroup - (PortalUserId, GroupId, PrimaryGroup) VALUES (%s, %s, ' . $is_primary . ')'; - $this->Conn->Query( sprintf($sql, $user_id, $group_id) ); + if ( !$object->isSubscriberOnly() ) { + $fields_hash = Array ( + 'PortalUserId' => $object->GetID(), + 'GroupId' => $this->Application->ConfigValue('User_SubscriberGroup'), + ); + $this->Conn->doInsert($fields_hash, TABLE_PREFIX . 'UserGroup'); + } + $this->Application->EmailEventAdmin('USER.SUBSCRIBE'); - $this->Application->EmailEventUser('USER.SUBSCRIBE', $user_id); + $this->Application->EmailEventUser('USER.SUBSCRIBE', $object->GetID()); } + /** + * Removing user from subscribers group + * + * @param int $user_id + */ function RemoveSubscriberGroup($user_id) { $group_id = $this->Application->ConfigValue('User_SubscriberGroup'); + $sql = 'DELETE FROM ' . TABLE_PREFIX . 'UserGroup - WHERE PortalUserId = ' . $user_id . ' - AND GroupId = ' . $this->Application->ConfigValue('User_SubscriberGroup'); + WHERE PortalUserId = ' . $user_id . ' AND GroupId = ' . $group_id; $this->Conn->Query($sql); $this->Application->EmailEventAdmin('USER.UNSUBSCRIBE'); $this->Application->EmailEventUser('USER.UNSUBSCRIBE', $user_id); } /** - * Allows to detect user subscription status (subscribed or not) + * Checks user subscription status * - * @param int $user_id + * @param kDBItem $object * @return bool */ - function GetGroupInfo($user_id) + function isSubscribed(&$object) { - $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'UserGroup - WHERE (PortalUserId = ' . $user_id . ') - AND (GroupId = ' . $this->Application->ConfigValue('User_SubscriberGroup') . ')'; - return $this->Conn->GetRow($sql); + $group_id = $this->Application->ConfigValue('User_SubscriberGroup'); + + $sql = 'SELECT GroupId + FROM ' . TABLE_PREFIX . 'UserGroup + WHERE (PortalUserId = ' . $object->GetID() . ') AND (GroupId = ' . $group_id . ')'; + + return $this->Conn->GetOne($sql); } function OnForgotPassword(&$event) @@ -1384,17 +1413,16 @@ $first_country = $this->Application->ConfigValue('User_Default_Registration_Country'); } + $fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); + if ($first_country) { // update user country dropdown sql - $fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); $fields['Country']['options_sql'] = preg_replace('/ORDER BY (.*)/', 'ORDER BY IF (CountryStateId = '.$first_country.', 1, 0) DESC, \\1', $fields['Country']['options_sql']); - $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); } // 2. set default user registration group - $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields'); - $virtual_fields['UserGroup']['default'] = $this->Application->ConfigValue('User_NewGroup'); - $this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields); + $fields['PrimaryGroupId']['default'] = $this->Application->ConfigValue('User_NewGroup'); + $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); // 3. allow avatar upload on Front-End $file_helper =& $this->Application->recallObject('FileHelper'); @@ -1441,13 +1469,11 @@ return; } - $event->status=kEvent::erSUCCESS; - $ids = $this->StoreSelectedIDs($event); - - $this->Application->SetVar('skip_set_primary', 1); // otherwise it will default primary group, search for skip_set_primary above $temp_handler =& $this->Application->recallObject($event->Prefix.'_TempHandler', 'kTempTablesHandler'); /* @var $temp_handler kTempTablesHandler */ - $cloned_users = $temp_handler->CloneItems($event->Prefix, '', $ids); + + $ids = $this->StoreSelectedIDs($event); + $temp_handler->CloneItems($event->Prefix, '', $ids); $this->clearSelectedIDs($event); } @@ -1460,30 +1486,15 @@ { $object =& $event->getObject(); /* @var $object kDBItem */ - $object->setRequired('Password', 0); - $object->setRequired('VerifyPassword', 0); - $object->SetDBField('Password', rand(100000000, 999999999)); - $object->SetDBField('CreatedOn', adodb_mktime()); - $object->SetDBField('ResourceId', false); // this will reset it - // change email cause it should be unique - $object->NameCopy(array(), $object->GetID(), 'Email', 'copy%1$s.%2$s'); + $password = kUtil::generatePassword(); + $object->SetField('Password', $password); + $object->SetField('VerifyPassword', $password); - $object->UpdateFormattersSubFields(); - } + $object->SetDBField('ResourceId', 0); // this will reset it - /** - * Copy user groups after copying user - * - * @param kEvent $event - */ - function OnAfterClone(&$event) - { - $id = $event->getEventParam('id'); - $original_id = $event->getEventParam('original_id'); - - $sql = 'INSERT '.TABLE_PREFIX."UserGroup SELECT $id, GroupId, MembershipExpires, PrimaryGroup, 0 FROM ".TABLE_PREFIX."UserGroup WHERE PortalUserId = $original_id"; - $this->Conn->Query($sql); + // change email because it should be unique + $object->NameCopy(Array (), $object->GetID(), 'Email', 'copy%1$s.%2$s'); } /** @@ -1496,11 +1507,11 @@ $this->StoreSelectedIDs($event); // remove current ID, otherwise group selector will use it in filters - $this->Application->DeleteVar($event->getPrefixSpecial(true).'_id'); + $this->Application->DeleteVar($event->getPrefixSpecial(true) . '_id'); } /** - * Adds selected link to listing + * Sets primary group of selected users * * @param kEvent $event */ @@ -1524,34 +1535,27 @@ $table_name = $this->Application->getUnitOption('ug', 'TableName'); + // 1. mark group as primary + $sql = 'UPDATE ' . TABLE_PREFIX . 'PortalUser + SET PrimaryGroupId = ' . $primary_group_id . ' + WHERE PortalUserId IN (' . implode(',', $user_ids) . ')'; + $this->Conn->Query($sql); + $sql = 'SELECT PortalUserId - FROM '.$table_name.' - WHERE (GroupId = '.$primary_group_id.') AND (PortalUserId IN ('.implode(',', $user_ids).'))'; + FROM ' . $table_name . ' + WHERE (GroupId = ' . $primary_group_id . ') AND (PortalUserId IN (' . implode(',', $user_ids) . '))'; $existing_members = $this->Conn->GetCol($sql); - // 1. reset primary group mark - $sql = 'UPDATE '.$table_name.' - SET PrimaryGroup = 0 - WHERE PortalUserId IN ('.implode(',', $user_ids).')'; - $this->Conn->Query($sql); + // 2. add new members to a group + $new_members = array_diff($user_ids, $existing_members); - foreach ($user_ids as $user_id) { - if (in_array($user_id, $existing_members)) { - // 2. already member of that group -> just make primary - $sql = 'UPDATE '.$table_name.' - SET PrimaryGroup = 1 - WHERE (PortalUserId = '.$user_id.') AND (GroupId = '.$primary_group_id.')'; - $this->Conn->Query($sql); - } - else { - // 3. not member of that group -> make member & make primary - $fields_hash = Array ( - 'GroupId' => $primary_group_id, - 'PortalUserId' => $user_id, - 'PrimaryGroup' => 1, - ); - $this->Conn->doInsert($fields_hash, $table_name); - } + foreach ($new_members as $user_id) { + $fields_hash = Array ( + 'GroupId' => $primary_group_id, + 'PortalUserId' => $user_id, + ); + + $this->Conn->doInsert($fields_hash, $table_name); } } @@ -1608,6 +1612,19 @@ parent::OnPreCreate($event); if ($event->status == kEvent::erSUCCESS) { + $user_type = $this->Application->GetVar('user_type'); + + if ($user_type) { + $object =& $event->getObject(); + /* @var $object kDBItem */ + + $object->SetDBField('UserType', $user_type); + + if ( $user_type == UserType::ADMIN ) { + $object->SetDBField('PrimaryGroupId', $this->Application->ConfigValue('User_AdminGroup')); + } + } + $this->_makePasswordRequired($event); } } Index: branches/5.2.x/core/install/install_schema.sql =================================================================== diff -u -N -r14244 -r14437 --- branches/5.2.x/core/install/install_schema.sql (.../install_schema.sql) (revision 14244) +++ branches/5.2.x/core/install/install_schema.sql (.../install_schema.sql) (revision 14437) @@ -265,6 +265,8 @@ MinPwResetDelay int(11) NOT NULL DEFAULT '1800', AdminLanguage int(11) DEFAULT NULL, DisplayToPublic text, + UserType tinyint(4) NOT NULL, + PrimaryGroupId int(11) DEFAULT NULL, PRIMARY KEY (PortalUserId), UNIQUE KEY ResourceId (ResourceId), UNIQUE KEY Login (Login), @@ -273,7 +275,8 @@ KEY Modified (Modified), KEY dob (dob), KEY IsBanned (IsBanned), - KEY AdminLanguage (AdminLanguage) + KEY AdminLanguage (AdminLanguage), + KEY UserType (UserType) ); CREATE TABLE PortalUserCustomData ( @@ -328,14 +331,12 @@ ); CREATE TABLE UserGroup ( - PortalUserId int(11) NOT NULL default '0', - GroupId int(11) NOT NULL default '0', - MembershipExpires int(10) unsigned default NULL, - PrimaryGroup tinyint(4) NOT NULL default '1', - ExpirationReminderSent tinyint(4) NOT NULL default '0', - PRIMARY KEY (PortalUserId,GroupId), + PortalUserId int(11) NOT NULL DEFAULT '0', + GroupId int(11) NOT NULL DEFAULT '0', + MembershipExpires int(10) unsigned DEFAULT NULL, + ExpirationReminderSent tinyint(4) NOT NULL DEFAULT '0', + PRIMARY KEY (PortalUserId,GroupId), KEY GroupId (GroupId), - KEY PrimaryGroup (PrimaryGroup), KEY MembershipExpires (MembershipExpires), KEY ExpirationReminderSent (ExpirationReminderSent) ); Index: branches/5.2.x/core/units/users/users_item.php =================================================================== diff -u -N -r14432 -r14437 --- branches/5.2.x/core/units/users/users_item.php (.../users_item.php) (revision 14432) +++ branches/5.2.x/core/units/users/users_item.php (.../users_item.php) (revision 14437) @@ -1,6 +1,6 @@ GetID() . ') AND ( (MembershipExpires IS NULL) OR ( MembershipExpires >= UNIX_TIMESTAMP() ) ) - ORDER BY PrimaryGroup DESC'; + ORDER BY IF(GroupId = ' . $this->GetDBField('PrimaryGroupId') . ', 1, 0) DESC'; return $this->Conn->GetCol($sql); } @@ -69,15 +69,14 @@ } } + /** + * Checks that user is subscriber only + * + * @return bool + */ function isSubscriberOnly() { - $subscribers_group_id = $this->Application->ConfigValue('User_SubscriberGroup'); - $sql = 'SELECT PortalUserId - FROM '.TABLE_PREFIX.'UserGroup - WHERE GroupId = '.$subscribers_group_id.' AND - PortalUserId = '.$this->GetDBField('PortalUserId').' AND - PrimaryGroup = 1'; - return $this->Conn->GetOne($sql) == $this->GetDBField('PortalUserId'); + return $this->GetDBField('PrimaryGroupId') == $this->Application->ConfigValue('User_SubscriberGroup'); } function Create($force_id=false, $system_create=false) Index: branches/5.2.x/core/admin_templates/users/admins_edit.tpl =================================================================== diff -u -N -r14244 -r14437 --- branches/5.2.x/core/admin_templates/users/admins_edit.tpl (.../admins_edit.tpl) (revision 14244) +++ branches/5.2.x/core/admin_templates/users/admins_edit.tpl (.../admins_edit.tpl) (revision 14437) @@ -60,7 +60,9 @@ - + + +
Index: branches/5.2.x/admin/system_presets/simple/user_groups_g-ug.php =================================================================== diff -u -N -r14244 -r14437 --- branches/5.2.x/admin/system_presets/simple/user_groups_g-ug.php (.../user_groups_g-ug.php) (revision 14244) +++ branches/5.2.x/admin/system_presets/simple/user_groups_g-ug.php (.../user_groups_g-ug.php) (revision 14437) @@ -19,7 +19,7 @@ // fields to hide $hidden_fields = Array ( - /* 'PortalUserId', 'GroupId', 'MembershipExpires', 'PrimaryGroup', 'ExpirationReminderSent', */ + /* 'PortalUserId', 'GroupId', 'MembershipExpires', 'ExpirationReminderSent', */ ); // virtual fields to hide @@ -29,7 +29,7 @@ // fields to make required $required_fields = Array ( -/* 'PortalUserId', 'GroupId', 'MembershipExpires', 'PrimaryGroup', 'ExpirationReminderSent', */ +/* 'PortalUserId', 'GroupId', 'MembershipExpires', 'ExpirationReminderSent', */ ); // virtual fields to make required Index: branches/5.2.x/core/install/english.lang =================================================================== diff -u -N -r14244 -r14437 --- branches/5.2.x/core/install/english.lang (.../english.lang) (revision 14244) +++ branches/5.2.x/core/install/english.lang (.../english.lang) (revision 14437) @@ -1499,8 +1499,9 @@ VW5jaGFuZ2Vk VW5pY29kZQ== VXBkYXRpbmcgQ29uZmlndXJhdGlvbg== - VXBsb2Fk + VXBsb2Fk VXNlIENyb24gdG8gcnVuIEFnZW50cw== + QXNzaWduIGFkbWluaXN0cmF0b3JzIHRvIGdyb3Vw QWxsb3cgbmV3IHVzZXIgcmVnaXN0cmF0aW9u QXNzaWduIEFsbCBVc2VycyBUbyBHcm91cA== QXNzaWduIHVzZXJzIG5vdCBsb2dnZWQgaW4gdG8gZ3JvdXA= Index: branches/5.2.x/core/install/install_data.sql =================================================================== diff -u -N -r14244 -r14437 --- branches/5.2.x/core/install/install_data.sql (.../install_data.sql) (revision 14244) +++ branches/5.2.x/core/install/install_data.sql (.../install_data.sql) (revision 14437) @@ -109,9 +109,10 @@ INSERT INTO ConfigurationValues VALUES(DEFAULT, 'User_LoggedInGroup', '15', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_users_assign_all_to', 'select', NULL, '0=lu_none||SELECT GroupId as OptionValue, Name as OptionName FROM PortalGroup WHERE Enabled=1 AND Personal=0', 10.09, 0, 1, NULL); INSERT INTO ConfigurationValues VALUES(DEFAULT, 'User_GuestGroup', '14', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_users_guest_group', 'select', NULL, '0=lu_none||SELECT GroupId as OptionValue, Name as OptionName FROM PortalGroup WHERE Enabled=1 AND Personal=0', 10.1, 0, 1, NULL); INSERT INTO ConfigurationValues VALUES(DEFAULT, 'User_SubscriberGroup', '12', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_users_subscriber_group', 'select', NULL, '0=lu_none||SELECT GroupId as OptionValue, Name as OptionName FROM PortalGroup WHERE Enabled=1 AND Personal=0', 10.11, 0, 1, NULL); -INSERT INTO ConfigurationValues VALUES(DEFAULT, 'User_Default_Registration_Country', '', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_config_DefaultRegistrationCountry', 'select', NULL, '=+||SELECT l%3$s_Name AS OptionName, CountryStateId AS OptionValue FROM CountryStates WHERE Type = 1 ORDER BY OptionName', 10.12, 0, 0, NULL); -INSERT INTO ConfigurationValues VALUES(DEFAULT, 'AllowSelectGroupOnFront', '0', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_config_AllowSelectGroupOnFront', 'checkbox', NULL, NULL, 10.13, 0, 0, NULL); -INSERT INTO ConfigurationValues VALUES(DEFAULT, 'DefaultSettingsUserId', '-1', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_prompt_DefaultUserId', 'text', NULL, NULL, 10.14, 0, 0, NULL); +INSERT INTO ConfigurationValues VALUES(DEFAULT, 'User_AdminGroup', '11', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_users_admin_group', 'select', NULL, '0=lu_none||SELECT GroupId as OptionValue, Name as OptionName FROM PortalGroup WHERE Enabled=1 AND Personal=0', 10.12, 0, 1, NULL); +INSERT INTO ConfigurationValues VALUES(DEFAULT, 'User_Default_Registration_Country', '', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_config_DefaultRegistrationCountry', 'select', NULL, '=+||SELECT l%3$s_Name AS OptionName, CountryStateId AS OptionValue FROM CountryStates WHERE Type = 1 ORDER BY OptionName', 10.13, 0, 0, NULL); +INSERT INTO ConfigurationValues VALUES(DEFAULT, 'AllowSelectGroupOnFront', '0', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_config_AllowSelectGroupOnFront', 'checkbox', NULL, NULL, 10.14, 0, 0, NULL); +INSERT INTO ConfigurationValues VALUES(DEFAULT, 'DefaultSettingsUserId', '-1', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_prompt_DefaultUserId', 'text', NULL, NULL, 10.15, 0, 0, NULL); INSERT INTO ConfigurationValues VALUES(DEFAULT, 'User_Votes_Deny', '5', 'In-Portal:Users', 'in-portal:configure_users', 'la_Text_Restrictions', 'la_users_votes_deny', 'text', '', '', 20.01, 0, 1, NULL); INSERT INTO ConfigurationValues VALUES(DEFAULT, 'User_Review_Deny', '5', 'In-Portal:Users', 'in-portal:configure_users', 'la_Text_Restrictions', 'la_users_review_deny', 'text', '', '', 20.02, 0, 1, NULL); INSERT INTO ConfigurationValues VALUES(DEFAULT, 'u_MaxImageCount', '5', 'In-Portal:Users', 'in-portal:configure_users', 'la_section_ImageSettings', 'la_config_MaxImageCount', 'text', '', '', 30.01, 0, 0, NULL); Index: branches/5.2.x/core/units/helpers/user_helper.php =================================================================== diff -u -N -r14432 -r14437 --- branches/5.2.x/core/units/helpers/user_helper.php (.../user_helper.php) (revision 14432) +++ branches/5.2.x/core/units/helpers/user_helper.php (.../user_helper.php) (revision 14437) @@ -1,6 +1,6 @@ GetDBField('UserType') == UserType::USER ) { + array_push($groups, $this->Application->ConfigValue('User_NewGroup') ); + } + elseif ( $object->GetDBField('UserType') == UserType::ADMIN ) { + array_push($groups, $this->Application->ConfigValue('User_AdminGroup') ); + } + // store groups, because kApplication::CheckPermission will use them! array_push($groups, $this->Application->ConfigValue('User_LoggedInGroup') ); $this->Application->StoreVar( 'UserGroups', implode(',', $groups) ); Index: branches/5.2.x/core/admin_templates/users/users_list.tpl =================================================================== diff -u -N -r14244 -r14437 --- branches/5.2.x/core/admin_templates/users/users_list.tpl (.../users_list.tpl) (revision 14244) +++ branches/5.2.x/core/admin_templates/users/users_list.tpl (.../users_list.tpl) (revision 14437) @@ -30,7 +30,7 @@ /*a_toolbar.AddButton ( new ToolBarButton( - 'primary_user_group', + 'setprimary', '::', function() { openSelector('u.regular', '', 'PrimaryGroupId', '800x600', 'OnSaveSelected'); @@ -93,6 +93,6 @@ \ No newline at end of file Index: branches/5.2.x/core/kernel/constants.php =================================================================== diff -u -N -r14428 -r14437 --- branches/5.2.x/core/kernel/constants.php (.../constants.php) (revision 14428) +++ branches/5.2.x/core/kernel/constants.php (.../constants.php) (revision 14437) @@ -1,6 +1,6 @@ Array( 'UserName' => 'CONCAT(u.LastName, \' \', u.FirstName)', 'UserLogin' => 'u.Login', + 'PrimaryGroup' => 'IF(u.PrimaryGroupId = %1$s.GroupId, 1, 0)', ), ), 'VirtualFields' => Array ( @@ -83,33 +84,37 @@ 'TitleField' => 'GroupName', 'TableName' => TABLE_PREFIX.'UserGroup', - 'ListSQLs' => Array( ''=>' SELECT %1$s.* %2$s FROM %1$s - LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON %1$s.GroupId = g.GroupId'), + 'ListSQLs' => Array( ''=>' SELECT %1$s.* %2$s + FROM %1$s + LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON %1$s.GroupId = g.GroupId + LEFT JOIN '.TABLE_PREFIX.'%3$sPortalUser u ON %1$s.PortalUserId = u.PortalUserId'), - 'ItemSQLs' => Array( ''=>' SELECT %1$s.* %2$s FROM %1$s - LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON %1$s.GroupId = g.GroupId'), - 'AutoDelete' => true, 'AutoClone' => false, 'CalculatedFields' => Array ( '' => Array( 'GroupName' => 'g.Name', 'GroupDescription' => 'g.Description', + 'PrimaryGroup' => 'IF(u.PrimaryGroupId = %1$s.GroupId, 1, 0)', ), ), 'Fields' => Array( 'PortalUserId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0), 'GroupId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0), 'MembershipExpires' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => null), - 'PrimaryGroup' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 1), 'ExpirationReminderSent' => Array('type' => 'int', 'not_null' => 1, 'default' => 0), ), 'VirtualFields' => Array ( 'GroupName' => Array('type' => 'string', 'default' => ''), 'GroupDescription' => Array('type' => 'string', 'default' => ''), + 'PrimaryGroup' => Array( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, + 'not_null' => 1, 'default' => 1 + ), ), Index: branches/5.2.x/core/units/users/users_config.php =================================================================== diff -u -N -r14244 -r14437 --- branches/5.2.x/core/units/users/users_config.php (.../users_config.php) (revision 14244) +++ branches/5.2.x/core/units/users/users_config.php (.../users_config.php) (revision 14437) @@ -1,6 +1,6 @@ Array ( 'prefixes' => Array ('u_List'), 'format' => "!la_title_Users!", - 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'approve', 'decline', 'e-mail', 'export', 'view', 'dbl-click'), + 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'setprimary', 'approve', 'decline', 'e-mail', 'export', 'view', 'dbl-click'), ), 'users_edit' => Array ( @@ -286,20 +286,17 @@ 'TableName' => TABLE_PREFIX.'PortalUser', 'ListSQLs' => Array( '' => ' SELECT %1$s.* %2$s FROM %1$s - LEFT JOIN '.TABLE_PREFIX.'UserGroup ug ON %1$s.PortalUserId = ug.PortalUserId AND ug.PrimaryGroup = 1 - LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON ug.GroupId = g.GroupId + LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON %1$s.PrimaryGroupId = g.GroupId LEFT JOIN '.TABLE_PREFIX.'%3$sPortalUserCustomData cust ON %1$s.ResourceId = cust.ResourceId', 'online' => ' SELECT %1$s.* %2$s FROM %1$s LEFT JOIN '.TABLE_PREFIX.'UserSession s ON s.PortalUserId = %1$s.PortalUserId - LEFT JOIN '.TABLE_PREFIX.'UserGroup ug ON %1$s.PortalUserId = ug.PortalUserId AND ug.PrimaryGroup = 1 - LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON ug.GroupId = g.GroupId + LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON %1$s.PrimaryGroupId = g.GroupId LEFT JOIN '.TABLE_PREFIX.'%3$sPortalUserCustomData cust ON %1$s.ResourceId = cust.ResourceId', ), 'ItemSQLs' => Array( '' => ' SELECT %1$s.* %2$s FROM %1$s - LEFT JOIN '.TABLE_PREFIX.'UserGroup ug ON %1$s.PortalUserId = ug.PortalUserId AND ug.PrimaryGroup = 1 - LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON ug.GroupId = g.GroupId + LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON %1$s.PrimaryGroupId = g.GroupId LEFT JOIN '.TABLE_PREFIX.'%3$sPortalUserCustomData cust ON %1$s.ResourceId = cust.ResourceId', ), @@ -401,6 +398,16 @@ ), 'use_phrases' => 1, 'multiple' => 1, 'default' => NULL ), + 'UserType' => Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_opt_UserTypeUser', 1 => 'la_opt_UserTypeAdmin'), 'use_phrases' => 1, + 'not_null' => 1, 'default' => 0 + ), + 'PrimaryGroupId' => Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %1$s FROM ' . TABLE_PREFIX . 'PortalGroup WHERE Enabled = 1 AND FrontRegistration = 1', 'option_key_field' => 'GroupId', 'option_title_field' => 'Name', + 'default' => NULL + ), ), 'VirtualFields' => Array( @@ -410,11 +417,6 @@ 'RootPassword' => Array('type' => 'string', 'formatter' => 'kPasswordFormatter', 'encryption_method' => 'md5', 'verify_field' => 'VerifyRootPassword', 'skip_empty' => 1, 'default' => md5('') ), 'FullName' => Array ('type' => 'string', 'default' => ''), - 'UserGroup' => Array ( - 'type' => 'int', - 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %1$s FROM ' . TABLE_PREFIX . 'PortalGroup WHERE Enabled = 1 AND FrontRegistration = 1', 'option_key_field' => 'GroupId', 'option_title_field' => 'Name', - 'default' => 0, - ), ), 'Grids' => Array( Index: branches/5.2.x/core/install/upgrades.sql =================================================================== diff -u -N -r14244 -r14437 --- branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 14244) +++ branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 14437) @@ -1993,4 +1993,23 @@ SET l<%PRIMARY_LANGUAGE%>_Translation = 'Use Cron to run Agents' WHERE PhraseKey = 'LA_USECRONFORREGULAREVENT' AND l<%PRIMARY_LANGUAGE%>_Translation = 'Use Cron for Running Regular Events'; -# ===== v 5.1.1 ===== \ No newline at end of file +# ===== v 5.1.1 ===== + +# ===== v 5.2.0-B1 ===== +ALTER TABLE PortalUser + ADD UserType TINYINT NOT NULL, + ADD PrimaryGroupId INT NULL, + ADD INDEX (UserType); + +UPDATE PortalUser u +SET u.PrimaryGroupId = (SELECT ug.GroupId FROM <%TABLE_PREFIX%>UserGroup ug WHERE ug.PortalUserId = u.PortalUserId AND ug.PrimaryGroup = 1); + +UPDATE PortalUser u SET u.UserType = IF(u.PrimaryGroupId = 11, 1, 0); + +ALTER TABLE UserGroup DROP PrimaryGroup; + +UPDATE ConfigurationValues +SET DisplayOrder = DisplayOrder + 0.01 +WHERE `ModuleOwner` = 'In-Portal:Users' AND `Section` = 'in-portal:configure_users' AND DisplayOrder BETWEEN 10.12 AND 20.00; + +INSERT INTO ConfigurationValues VALUES(DEFAULT, 'User_AdminGroup', '11', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_users_admin_group', 'select', NULL, '0=lu_none||SELECT GroupId as OptionValue, Name as OptionName FROM PortalGroup WHERE Enabled=1 AND Personal=0', 10.12, 0, 1, NULL); \ No newline at end of file Index: branches/5.2.x/core/units/user_groups/user_groups_eh.php =================================================================== diff -u -N -r14244 -r14437 --- branches/5.2.x/core/units/user_groups/user_groups_eh.php (.../user_groups_eh.php) (revision 14244) +++ branches/5.2.x/core/units/user_groups/user_groups_eh.php (.../user_groups_eh.php) (revision 14437) @@ -1,6 +1,6 @@ Prefix == 'u-ug') { - $new_groups = $this->Application->GetVar('g'); - if (!$new_groups) { - return ; - } + $new_groups = $this->Application->GetVar('g'); + if (!$new_groups) { + return ; + } - $new_groups = array_keys($new_groups); + $new_groups = array_keys($new_groups); - // don't insert duplicate group membership record - $user_id = $this->Application->GetVar('u_id'); - $table_name = $this->Application->GetTempName(TABLE_PREFIX.'UserGroup', 'prefix:u'); - $sql = 'SELECT GroupId - FROM '.$table_name.' - WHERE PortalUserId = '.(int)$user_id; - $old_groups = $this->Conn->GetCol($sql); + // don't insert duplicate group membership record + $user_id = $this->Application->GetVar('u_id'); + $table_name = $this->Application->GetTempName(TABLE_PREFIX.'UserGroup', 'prefix:u'); - $new_groups = array_diff($new_groups, $old_groups); - if ($new_groups) { - foreach ($new_groups as $new_group) { - $fields_hash = Array ( - 'GroupId' => $new_group, - 'PortalUserId' => $user_id, - 'PrimaryGroup' => 0, - ); - $this->Conn->doInsert($fields_hash, $table_name); + $sql = 'SELECT GroupId + FROM '.$table_name.' + WHERE PortalUserId = '.(int)$user_id; + $old_groups = $this->Conn->GetCol($sql); + + $new_groups = array_diff($new_groups, $old_groups); + + if ($new_groups) { + foreach ($new_groups as $new_group) { + $fields_hash = Array ( + 'GroupId' => $new_group, + 'PortalUserId' => $user_id, + ); + $this->Conn->doInsert($fields_hash, $table_name); + } } } - } - if ($event->Prefix == 'g-ug') { + elseif ($event->Prefix == 'g-ug') { $new_users = $this->Application->GetVar('u'); + if (!$new_users) { return ; } @@ -62,18 +64,19 @@ // don't insert duplicate group membership record $group_id = $this->Application->GetVar('g_id'); $table_name = $this->Application->GetTempName(TABLE_PREFIX.'UserGroup', 'prefix:g'); + $sql = 'SELECT PortalUserId FROM ' . $table_name . ' WHERE GroupId = ' . (int)$group_id; $old_users = $this->Conn->GetCol($sql); $new_users = array_diff($new_users, $old_users); + if ($new_users) { foreach ($new_users as $new_user) { $fields_hash = Array ( 'GroupId' => $group_id, 'PortalUserId' => $new_user, - 'PrimaryGroup' => 0, ); $this->Conn->doInsert($fields_hash, $table_name); } @@ -92,20 +95,13 @@ function OnSetPrimary(&$event) { $ids = $this->StoreSelectedIDs($event); + if ($ids) { - $id = array_shift($ids); - $object =& $event->getObject( Array('skip_autoload' => true) ); - $user_id = $this->Application->GetVar('u_id'); + $user =& $this->Application->recallObject('u'); + /* @var $user kDBItem */ - $sql = 'UPDATE ' . $object->TableName . ' - SET PrimaryGroup = 0 - WHERE PortalUserId = ' . (int)$user_id; - $this->Conn->Query($sql); - - $sql = 'UPDATE ' . $object->TableName . ' - SET PrimaryGroup = 1 - WHERE ' . $object->IDField . ' = ' . $id . ' AND PortalUserId = ' . (int)$user_id; - $this->Conn->Query($sql); + $user->SetDBField('PrimaryGroupId', array_shift($ids)); + $user->Update(); } $this->clearSelectedIDs($event); @@ -120,26 +116,36 @@ { if ($event->Name == 'OnMassDelete' && $type == 'before') { $ids = $event->getEventParam('ids'); + if ($ids) { $object =& $event->getObject( Array('skip_autoload' => true) ); if ($event->Prefix == 'u-ug') { - $user_id = $this->Application->GetVar('u_id'); - $sql = 'SELECT '.$object->IDField.' - FROM '.$object->TableName.' - WHERE '.$object->IDField.' IN ('.implode(',', $ids).') AND PortalUserId = '.(int)$user_id.' AND PrimaryGroup = 0'; - $ids = $this->Conn->GetCol($sql); + // allow deleting non-primary group of current user ($ids - groups) + $sql = 'SELECT PrimaryGroupId + FROM ' . $this->Application->GetTempName(TABLE_PREFIX . 'PortalUser', 'prefix:u') . ' + WHERE PortalUserId = ' . (int)$this->Application->GetVar('u_id'); + $primary_group_id = (int)$this->Conn->GetOne($sql); + + $index = array_search($primary_group_id, $ids); + + if ($index !== false) { + unset($ids[$index]); + $event->setEventParam('ids', $ids); + } } elseif ($event->Prefix == 'g-ug') { - $group_id = $this->Application->GetVar('g_id'); - $sql = 'SELECT '.$object->IDField.' - FROM '.$object->TableName.' - WHERE '.$object->IDField.' IN ('.implode(',', $ids).') AND GroupId = '.(int)$group_id.' AND PrimaryGroup = 0'; - $ids = $this->Conn->GetCol($sql); + // allow deleting users from group record, then it's not their primary group ($ids - users) + $group_id = (int)$this->Application->GetVar('g_id'); + + $sql = 'SELECT PortalUserId + FROM ' . TABLE_PREFIX . 'PortalUser' . ' + WHERE PortalUserId IN (' . implode(',', $ids) . ') AND PrimaryGroupId = ' . $group_id; + $exclude_users = $this->Conn->GetCol($sql); + + $event->setEventParam('ids', array_diff($ids, $exclude_users)); } - $event->setEventParam('ids', $ids); } } } - } \ No newline at end of file Index: branches/5.2.x/admin/system_presets/simple/user_groups_u-ug.php =================================================================== diff -u -N -r14244 -r14437 --- branches/5.2.x/admin/system_presets/simple/user_groups_u-ug.php (.../user_groups_u-ug.php) (revision 14244) +++ branches/5.2.x/admin/system_presets/simple/user_groups_u-ug.php (.../user_groups_u-ug.php) (revision 14437) @@ -19,7 +19,7 @@ // fields to hide $hidden_fields = Array ( - /* 'PortalUserId', 'GroupId', 'MembershipExpires', 'PrimaryGroup', 'ExpirationReminderSent', */ + /* 'PortalUserId', 'GroupId', 'MembershipExpires', 'ExpirationReminderSent', */ ); // virtual fields to hide @@ -29,7 +29,7 @@ // fields to make required $required_fields = Array ( - /* 'PortalUserId', 'GroupId', 'MembershipExpires', 'PrimaryGroup', 'ExpirationReminderSent', */ + /* 'PortalUserId', 'GroupId', 'MembershipExpires', 'ExpirationReminderSent', */ ); // virtual fields to make required Index: branches/5.2.x/core/kernel/utility/event.php =================================================================== diff -u -N -r14244 -r14437 --- branches/5.2.x/core/kernel/utility/event.php (.../event.php) (revision 14244) +++ branches/5.2.x/core/kernel/utility/event.php (.../event.php) (revision 14437) @@ -1,6 +1,6 @@ use from current event - $name = $this->getPrefixSpecial() . ':' . $name; - } + if ( strpos($name, ':') === false ) { + // PrefixSpecial not specified -> use from current event + $name = $this->getPrefixSpecial() . ':' . $name; + } - $child_event = new kEvent($name); - $child_event->copyFrom($this, true); + $child_event = new kEvent($name); + $child_event->copyFrom($this, true); - $this->Application->HandleEvent($child_event); - $this->copyFrom($child_event); + $this->Application->HandleEvent($child_event); + $this->copyFrom($child_event); $this->specificParams = $child_event->specificParams; } Index: branches/5.2.x/core/admin_templates/users/admins_list.tpl =================================================================== diff -u -N -r14244 -r14437 --- branches/5.2.x/core/admin_templates/users/admins_list.tpl (.../admins_list.tpl) (revision 14244) +++ branches/5.2.x/core/admin_templates/users/admins_list.tpl (.../admins_list.tpl) (revision 14437) @@ -10,21 +10,22 @@ //do not rename - this function is used in default grid for double click! function edit() { - set_hidden_field('remove_specials[u.admins]', 1); + Application.SetVar('remove_specials[u.admins]', 1); std_edit_item('u.admins', 'users/admins_edit'); } var a_toolbar = new ToolBar(); a_toolbar.AddButton( new ToolBarButton('new_item', '', function() { - set_hidden_field('remove_specials[u.admins]', 1); + Application.SetVar('user_type', 1); + Application.SetVar('remove_specials[u.admins]', 1); std_precreate_item('u.admins', 'users/admins_edit') } ) ); a_toolbar.AddButton( new ToolBarButton('edit', '::', edit) ); a_toolbar.AddButton( new ToolBarButton('delete', '', function() { - set_hidden_field('remove_specials[u.admins]', 1); + Application.SetVar('remove_specials[u.admins]', 1); std_delete_items('u.admins') } ) ); @@ -33,7 +34,7 @@ a_toolbar.AddButton( new ToolBarButton('clone', '::', function() { - set_hidden_field('remove_specials[u.admins]', 1); + Application.SetVar('remove_specials[u.admins]', 1); submit_event('u.admins', 'OnMassCloneUsers'); } ) ); @@ -42,7 +43,7 @@ a_toolbar.AddButton( new ToolBarButton('refresh', '::', function() { - set_hidden_field('remove_specials[u.admins]', 1); + Application.SetVar('remove_specials[u.admins]', 1); submit_event('u.admins', 'OnMassResetSettings'); } ) );