Index: branches/unlabeled/unlabeled-1.26.8/core/kernel/utility/temp_handler.php =================================================================== diff -u -r6437 -r7730 --- branches/unlabeled/unlabeled-1.26.8/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 6437) +++ branches/unlabeled/unlabeled-1.26.8/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 7730) @@ -370,7 +370,7 @@ if (is_array($ids)) { $ids = join(',', $ids); } - + $table_sig = $master['TableName'].(isset($master['Constrain']) ? $master['Constrain'] : ''); if ($ids != '' && !in_array($table_sig, $this->CopiedTables)) { @@ -388,12 +388,12 @@ $query = 'INSERT INTO '.$this->GetTempName($master['TableName']).' SELECT * FROM '.$master['TableName'].' - WHERE '.$key_field.' IN ('.$ids.')'; + WHERE '.$key_field.' IN ('.$ids.')'; if (isset($master['Constrain'])) $query .= ' AND '.$master['Constrain']; $this->Conn->Query($query); - + $this->CopiedTables[] = $table_sig; - + $query = 'SELECT '.$master['IdField'].' FROM '.$master['TableName'].' WHERE '.$key_field.' IN ('.$ids.')'; if (isset($master['Constrain'])) $query .= ' AND '.$master['Constrain']; Index: branches/unlabeled/unlabeled-1.1.2/kernel/units/user_groups/user_groups_dbitem.php =================================================================== diff -u --- branches/unlabeled/unlabeled-1.1.2/kernel/units/user_groups/user_groups_dbitem.php (revision 0) +++ branches/unlabeled/unlabeled-1.1.2/kernel/units/user_groups/user_groups_dbitem.php (revision 7730) @@ -0,0 +1,31 @@ +getLinkedInfo(); + if ($table_info) { + // we have parent info, then use it + $keys_hash = Array( + $this->IDField => $this->ID, + $table_info['ForeignKey'] => $table_info['ParentId'], + ); + } + return parent::GetKeyClause($method, $keys_hash); + } + + } + + +?> \ No newline at end of file Index: branches/unlabeled/unlabeled-1.1.2/kernel/units/user_groups/user_groups_eh.php =================================================================== diff -u --- branches/unlabeled/unlabeled-1.1.2/kernel/units/user_groups/user_groups_eh.php (revision 0) +++ branches/unlabeled/unlabeled-1.1.2/kernel/units/user_groups/user_groups_eh.php (revision 7730) @@ -0,0 +1,91 @@ +Application->GetVar('g'); + if (!$new_groups) { + return ; + } + + $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 = '.$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, + 'PrimaryGroup' => 0, + ); + $this->Conn->doInsert($fields_hash, $table_name); + } + } + + $event->SetRedirectParam('opener', 'u'); + } + + /** + * Sets primary group for user (in editing only) + * + * @param kEvent $event + */ + 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'); + + $sql = 'UPDATE '.$object->TableName.' + SET PrimaryGroup = 0 + WHERE PortalUserId = '.$user_id; + $this->Conn->Query($sql); + + $sql = 'UPDATE '.$object->TableName.' + SET PrimaryGroup = 1 + WHERE '.$object->IDField.' = '.$id.' AND PortalUserId = '.$user_id; + $this->Conn->Query($sql); + } + + $this->clearSelectedIDs($event); + } + + /** + * Don't allow primary group record deleting + * + * @param kEvent $event + */ + function customProcessing(&$event, $type) + { + if ($event->Name == 'OnMassDelete' && $type == 'before') { + $ids = $event->getEventParam('ids'); + if ($ids) { + $object =& $event->getObject( Array('skip_autoload' => true) ); + $user_id = $this->Application->GetVar('u_id'); + $sql = 'SELECT '.$object->IDField.' + FROM '.$object->TableName.' + WHERE '.$object->IDField.' IN ('.implode(',', $ids).') AND PortalUserId = '.$user_id.' AND PrimaryGroup = 0'; + $ids = $this->Conn->GetCol($sql); + $event->setEventParam('ids', $ids); + } + } + } + } + +?> \ No newline at end of file