Index: branches/unlabeled/unlabeled-1.64.2/kernel/units/general/cat_event_handler.php =================================================================== diff -u -r5833 -r5858 --- branches/unlabeled/unlabeled-1.64.2/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5833) +++ branches/unlabeled/unlabeled-1.64.2/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5858) @@ -45,6 +45,41 @@ $this->Application->StoreVar('m_cat_id', $root_category); } + if ($event->Name == 'OnEdit' || $event->Name == 'OnSave') { + // check each id from selected individually and only if all are allowed proceed next + if ($event->Name == 'OnEdit') { + $selected_ids = implode(',', $this->StoreSelectedIDs($event)); + } + else { + $selected_ids = $this->Application->RecallVar($event->getPrefixSpecial().'_selected_ids'); + } + + $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); + $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); + $sql = 'SELECT '.$id_field.', CreatedById, ci.CategoryId + FROM '.$table_name.' item_table + LEFT JOIN '.$this->Application->getUnitOption('ci', 'TableName').' ci ON ci.ItemResourceId = item_table.ResourceId + WHERE '.$id_field.' IN ('.$selected_ids.') AND (ci.PrimaryCat = 1)'; + $items = $this->Conn->Query($sql, $id_field); + + $perm_value = true; + $perm_helper =& $this->Application->recallObject('PermissionsHelper'); + foreach ($items as $item_id => $item_data) { + + if ($perm_helper->ModifyCheckPermission($item_data['CreatedById'], $item_data['CategoryId'], $event->Prefix) == 0) { + // one of items selected has no permission + $perm_value = false; + break; + } + } + + if (!$perm_value) { + $event->status = erPERM_FAIL; + } + + return $perm_value; + } + return parent::CheckPermission($event); } @@ -1679,6 +1714,63 @@ $object->SetDBField($cached_field, $this->Conn->GetOne($sql)); } } + + /** + * Saves item beeing edited into temp table + * + * @param kEvent $event + */ + function OnPreSave(&$event) + { + parent::OnPreSave($event); + $use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing'); + if ($event->status == erSUCCESS && $use_pending_editing) { + // decision: clone or not clone + + $object =& $event->getObject(); + if ($object->GetID() == 0 || $object->GetDBField('OrgId') > 0) { + // new items or cloned items shouldn't be cloned again + return true; + } + $perm_helper =& $this->Application->recallObject('PermissionsHelper'); + if ($perm_helper->ModifyCheckPermission($object->GetDBField('CreatedById'), $object->GetDBField('CategoryId'), $event->Prefix) == 2) { + + // 1. clone original item + $temp_handler =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); + $cloned_ids = $temp_handler->CloneItems($event->Prefix, $event->Special, Array($object->GetID()), null, null, null, true); + + // 2. put cloned id to OrgId field of item being cloned + $sql = 'UPDATE '.$object->TableName.' + SET OrgId = '.$object->GetID().' + WHERE '.$object->IDField.' = '.$cloned_ids[0]; + $this->Conn->Query($sql); + + // 3. substitute id of item being cloned with clone id + $this->Application->SetVar($event->getPrefixSpecial().'_id', $cloned_ids[0]); + $selected_ids = explode(',', $this->Application->RecallVar($event->getPrefixSpecial().'_selected_ids')); + $selected_ids[ array_search($object->GetID(), $selected_ids) ] = $cloned_ids[0]; + $this->Application->StoreVar($event->getPrefixSpecial().'_selected_ids', implode(',', $selected_ids)); + + // 4. delete original item from temp table + $temp_handler->DeleteItems($event->Prefix, $event->Special, Array($object->GetID())); + } + } + } + + /** + * Sets default expiration based on module setting + * + * @param kEvent $event + */ + function OnPreCreate(&$event) + { + parent::OnPreCreate($event); + + if ($event->status == erSUCCESS) { + $object =& $event->getObject(); + $object->SetDBField('CreatedById', $this->Application->GetVar('u_id')); + } + } } Index: branches/unlabeled/unlabeled-1.64.2/core/units/general/cat_event_handler.php =================================================================== diff -u -r5833 -r5858 --- branches/unlabeled/unlabeled-1.64.2/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5833) +++ branches/unlabeled/unlabeled-1.64.2/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5858) @@ -45,6 +45,41 @@ $this->Application->StoreVar('m_cat_id', $root_category); } + if ($event->Name == 'OnEdit' || $event->Name == 'OnSave') { + // check each id from selected individually and only if all are allowed proceed next + if ($event->Name == 'OnEdit') { + $selected_ids = implode(',', $this->StoreSelectedIDs($event)); + } + else { + $selected_ids = $this->Application->RecallVar($event->getPrefixSpecial().'_selected_ids'); + } + + $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); + $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); + $sql = 'SELECT '.$id_field.', CreatedById, ci.CategoryId + FROM '.$table_name.' item_table + LEFT JOIN '.$this->Application->getUnitOption('ci', 'TableName').' ci ON ci.ItemResourceId = item_table.ResourceId + WHERE '.$id_field.' IN ('.$selected_ids.') AND (ci.PrimaryCat = 1)'; + $items = $this->Conn->Query($sql, $id_field); + + $perm_value = true; + $perm_helper =& $this->Application->recallObject('PermissionsHelper'); + foreach ($items as $item_id => $item_data) { + + if ($perm_helper->ModifyCheckPermission($item_data['CreatedById'], $item_data['CategoryId'], $event->Prefix) == 0) { + // one of items selected has no permission + $perm_value = false; + break; + } + } + + if (!$perm_value) { + $event->status = erPERM_FAIL; + } + + return $perm_value; + } + return parent::CheckPermission($event); } @@ -1679,6 +1714,63 @@ $object->SetDBField($cached_field, $this->Conn->GetOne($sql)); } } + + /** + * Saves item beeing edited into temp table + * + * @param kEvent $event + */ + function OnPreSave(&$event) + { + parent::OnPreSave($event); + $use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing'); + if ($event->status == erSUCCESS && $use_pending_editing) { + // decision: clone or not clone + + $object =& $event->getObject(); + if ($object->GetID() == 0 || $object->GetDBField('OrgId') > 0) { + // new items or cloned items shouldn't be cloned again + return true; + } + $perm_helper =& $this->Application->recallObject('PermissionsHelper'); + if ($perm_helper->ModifyCheckPermission($object->GetDBField('CreatedById'), $object->GetDBField('CategoryId'), $event->Prefix) == 2) { + + // 1. clone original item + $temp_handler =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); + $cloned_ids = $temp_handler->CloneItems($event->Prefix, $event->Special, Array($object->GetID()), null, null, null, true); + + // 2. put cloned id to OrgId field of item being cloned + $sql = 'UPDATE '.$object->TableName.' + SET OrgId = '.$object->GetID().' + WHERE '.$object->IDField.' = '.$cloned_ids[0]; + $this->Conn->Query($sql); + + // 3. substitute id of item being cloned with clone id + $this->Application->SetVar($event->getPrefixSpecial().'_id', $cloned_ids[0]); + $selected_ids = explode(',', $this->Application->RecallVar($event->getPrefixSpecial().'_selected_ids')); + $selected_ids[ array_search($object->GetID(), $selected_ids) ] = $cloned_ids[0]; + $this->Application->StoreVar($event->getPrefixSpecial().'_selected_ids', implode(',', $selected_ids)); + + // 4. delete original item from temp table + $temp_handler->DeleteItems($event->Prefix, $event->Special, Array($object->GetID())); + } + } + } + + /** + * Sets default expiration based on module setting + * + * @param kEvent $event + */ + function OnPreCreate(&$event) + { + parent::OnPreCreate($event); + + if ($event->status == erSUCCESS) { + $object =& $event->getObject(); + $object->SetDBField('CreatedById', $this->Application->GetVar('u_id')); + } + } } Index: branches/unlabeled/unlabeled-1.11.2/kernel/units/general/cat_tag_processor.php =================================================================== diff -u -r5802 -r5858 --- branches/unlabeled/unlabeled-1.11.2/kernel/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 5802) +++ branches/unlabeled/unlabeled-1.11.2/kernel/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 5858) @@ -2,6 +2,19 @@ class kCatDBTagProcessor extends kDBTagProcessor { + /** + * Permission Helper + * + * @var kPermissionsHelper + */ + var $PermHelper = null; + + function kCatDBTagProcessor() + { + parent::kDBTagProcessor(); + $this->PermHelper = $this->Application->recallObject('PermissionsHelper'); + } + function ItemIcon($params) { $object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params); @@ -190,6 +203,20 @@ } return $category_path; } + + /** + * Allows to determine if original value should be shown + * + * @param Array $params + * @return bool + */ + function DisplayOriginal($params) + { + // original id found & greather then zero + show original + $display_original = isset($params['display_original']) && $params['display_original']; + return $display_original && $this->Application->GetVar($this->Prefix.'.original_id'); + } + } ?> \ No newline at end of file Index: branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php =================================================================== diff -u -r5856 -r5858 --- branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 5856) +++ branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 5858) @@ -65,7 +65,6 @@ } } - $section = $event->getSection(); if (!preg_match('/^CATEGORY:(.*)/', $section)) { // only if not category item events @@ -114,14 +113,14 @@ 'OnMassMoveUp' => Array('self' => 'advanced:move_up|add|edit', 'subitem' => 'advanced:move_up|add|edit'), 'OnMassMoveDown' => Array('self' => 'advanced:move_down|add|edit', 'subitem' => 'advanced:move_down|add|edit'), - 'OnPreCreate' => Array('self' => 'add'), - 'OnEdit' => Array('self' => 'edit'), + 'OnPreCreate' => Array('self' => 'add|add.pending'), + 'OnEdit' => Array('self' => 'edit|edit.pending'), // theese event do not harm, but just in case check them too :) - 'OnCancelEdit' => Array('self' => 'add|edit'), + 'OnCancelEdit' => Array('self' => 'add|add.pending|edit|edit.pending'), 'OnCancel' => Array('self' => 'add|edit', 'subitem' => 'add|edit'), 'OnSetSorting' => Array('self' => 'view', 'subitem' => 'view'), @@ -229,6 +228,9 @@ // this smells... needs to be refactored $first_id = getArrayValue($ret,0); if (($first_id === false) && ($event->getEventParam('raise_warnings') == 1)) { + if ($this->Application->isDebugMode()) { + $this->Application->Debugger->appendTrace(); + } trigger_error('Requested ID for prefix '.$event->getPrefixSpecial().' not passed',E_USER_NOTICE); } $this->Application->SetVar($event->getPrefixSpecial(true).'_id', $first_id); @@ -991,7 +993,12 @@ $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { - $temp->SaveEdit($event->getEventParam('master_ids') ? $event->getEventParam('master_ids') : Array()); + $live_ids = $temp->SaveEdit($event->getEventParam('master_ids') ? $event->getEventParam('master_ids') : Array()); + if ($live_ids) { + // ensure, that newly created item ids are avalable as if they were selected from grid + // NOTE: only works if main item has subitems !!! + $this->Application->StoreVar($event->getPrefixSpecial().'_selected_ids', implode(',', $live_ids)); + } } $this->clearSelectedIDs($event); @@ -1028,6 +1035,7 @@ */ function isNewItemCreate(&$event) { + $event->setEventParam('raise_warnings', 0); $item_id = $this->getPassedID($event); return ($item_id == '') ? true : false; } Index: branches/unlabeled/unlabeled-1.13.2/kernel/units/config_search/config_search_event_handler.php =================================================================== diff -u -r4760 -r5858 --- branches/unlabeled/unlabeled-1.13.2/kernel/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 4760) +++ branches/unlabeled/unlabeled-1.13.2/kernel/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 5858) @@ -60,7 +60,7 @@ } /** - * Enter description here... + * [HOOK] Enter description here... * * @param kEvent $event */ @@ -75,12 +75,11 @@ $object =& $event->getObject( Array('skip_autoload' => true) ); $custom_id = $custom_field->GetID(); - if ($custom_id) { + if ($object->GetDBField('CustomFieldId') != $custom_id) { $object->Load($custom_id, 'CustomFieldId'); - $object->SetDBField('CustomFieldId', $custom_id); // for cloning only } - - $cf_search = Array(); + + $cf_search = Array(); $cf_search['DisplayOrder'] = $custom_field->GetDBField('DisplayOrder'); $cf_search['ElementType'] = $custom_field->GetDBField('ElementType'); $cf_search['DisplayName'] = $custom_field->GetDBField('FieldLabel'); @@ -96,6 +95,7 @@ $cf_search['ModuleName'] = $this->Conn->GetOne($sql); $object->SetFieldsFromHash($cf_search); + $object->SetDBField('CustomFieldId', $custom_id); $result = $object->isLoaded() ? $object->Update() : $object->Create(); } Index: branches/unlabeled/unlabeled-1.11.2/core/units/general/cat_tag_processor.php =================================================================== diff -u -r5802 -r5858 --- branches/unlabeled/unlabeled-1.11.2/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 5802) +++ branches/unlabeled/unlabeled-1.11.2/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 5858) @@ -2,6 +2,19 @@ class kCatDBTagProcessor extends kDBTagProcessor { + /** + * Permission Helper + * + * @var kPermissionsHelper + */ + var $PermHelper = null; + + function kCatDBTagProcessor() + { + parent::kDBTagProcessor(); + $this->PermHelper = $this->Application->recallObject('PermissionsHelper'); + } + function ItemIcon($params) { $object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params); @@ -190,6 +203,20 @@ } return $category_path; } + + /** + * Allows to determine if original value should be shown + * + * @param Array $params + * @return bool + */ + function DisplayOriginal($params) + { + // original id found & greather then zero + show original + $display_original = isset($params['display_original']) && $params['display_original']; + return $display_original && $this->Application->GetVar($this->Prefix.'.original_id'); + } + } ?> \ No newline at end of file Index: branches/unlabeled/unlabeled-1.17.2/core/units/general/helpers/permissions_helper.php =================================================================== diff -u -r5516 -r5858 --- branches/unlabeled/unlabeled-1.17.2/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 5516) +++ branches/unlabeled/unlabeled-1.17.2/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 5858) @@ -130,7 +130,7 @@ function CheckEventCategoryPermission(&$event, $event_perm_mapping) { // mapping between specific permissions and common permissions - $perm_mapping = Array('add' => 'ADD', 'edit' => 'MODIFY', 'delete' => 'DELETE', 'view' => 'VIEW'); + $perm_mapping = Array('add' => 'ADD', 'add.pending' => 'ADD.PENDING', 'edit' => 'MODIFY', 'edit.pending' => 'MODIFY.PENDING', 'delete' => 'DELETE', 'view' => 'VIEW'); $top_prefix = $event->getEventParam('top_prefix'); $event_handler =& $this->Application->recallObject($event->Prefix.'_EventHandler'); @@ -142,8 +142,6 @@ $id = $event_handler->getPassedID($event); } - $item_prefix = $this->Application->getUnitOption($top_prefix, 'PermItemPrefix'); - // 1. get primary category of category item $id_field = $this->Application->getUnitOption($top_prefix, 'IDField'); $table_name = $this->Application->getUnitOption($top_prefix, 'TableName'); @@ -155,19 +153,26 @@ } else { // item being edited -> check by it's primary category permissions - $sql = 'SELECT ci.CategoryId + $sql = 'SELECT ci.CategoryId, main_table.CreatedById FROM '.$table_name.' main_table LEFT JOIN '.$ci_table.' ci ON ci.ItemResourceId = main_table.ResourceId WHERE (main_table.'.$id_field.' = '.$id.') AND (ci.PrimaryCat = 1)'; - $category_id = $this->Conn->GetOne($sql); + $item_info = $this->Conn->GetRow($sql); + $category_id = $item_info['CategoryId']; + $owner_id = $item_info['CreatedById']; } - if ((substr($event->Name, 0, 9) == 'OnPreSave') || ($event->Name == 'OnSave')) { + $item_prefix = $this->Application->getUnitOption($top_prefix, 'PermItemPrefix'); + + if (substr($event->Name, 0, 9) == 'OnPreSave') { if ($event_handler->isNewItemCreate($event)) { - return $this->CheckPermission($item_prefix.'.ADD', 0, $category_id); + return $this->CheckPermission($item_prefix.'.ADD', 0, $category_id) || + $this->CheckPermission($item_prefix.'.ADD.PENDING', 0, $category_id); } else { - return $this->CheckPermission($item_prefix.'.ADD', 0, $category_id) || $this->CheckPermission($item_prefix.'.MODIFY', 0, $category_id); + return $this->CheckPermission($item_prefix.'.ADD', 0, $category_id) || + $this->CheckPermission($item_prefix.'.ADD.PENDING', 0, $category_id) || + $this->ModifyCheckPermission($owner_id, $category_id, $top_prefix); } } @@ -349,9 +354,7 @@ FROM '.$this->Application->getUnitOption('c', 'TableName').' WHERE CategoryId = '.$cat_id; $cat_hierarchy = $this->Conn->GetOne($sql); - $cat_hierarchy = explode('|', $cat_hierarchy); - array_shift($cat_hierarchy); - array_pop($cat_hierarchy); + $cat_hierarchy = explode('|', substr($cat_hierarchy, 1, -1)); $cat_hierarchy = array_reverse($cat_hierarchy); array_push($cat_hierarchy, 0); } @@ -372,6 +375,40 @@ $this->Application->setCache('permissions', $cache_key, $perm_value); return $perm_value; } + + /** + * Allows to check MODIFY & OWNER.MODFY +/- PENDING permission combinations on item + * + * @param int $owner_id user_id, that is owner of the item + * @param int $category_id primary category of item + * @param string $prefix prefix of item + * @return int {0 - no MODIFY permission, 1 - has MODIFY permission, 2 - has MODIFY.PENDING permission} + */ + function ModifyCheckPermission($owner_id, $category_id, $prefix) + { + $perm_prefix = $this->Application->getUnitOption($prefix, 'PermItemPrefix'); + + $live_modify = $this->CheckPermission($perm_prefix.'.MODIFY', ptCATEGORY, $category_id); + if ($live_modify) { + return 1; + } + else if ($this->CheckPermission($perm_prefix.'.MODIFY.PENDING', ptCATEGORY, $category_id)) { + return 2; + } + + if ($owner_id == $this->Application->GetVar('u_id')) { + // user is item's OWNER -> check this permissions first + $live_modify = $this->CheckPermission($perm_prefix.'.OWNER.MODIFY', ptCATEGORY, $category_id); + if ($live_modify) { + return 1; + } + else if ($this->CheckPermission($perm_prefix.'.OWNER.MODIFY.PENDING', ptCATEGORY, $category_id)) { + return 2; + } + } + + return 0; + } } ?> \ No newline at end of file Index: branches/unlabeled/unlabeled-1.32.2/core/units/general/cat_dbitem.php =================================================================== diff -u -r5820 -r5858 --- branches/unlabeled/unlabeled-1.32.2/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 5820) +++ branches/unlabeled/unlabeled-1.32.2/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 5858) @@ -29,7 +29,7 @@ $this->SetDBField('ResourceId', $this->Application->NextResourceId()); $this->SetDBField('Modified', adodb_mktime() ); - if ($this->mode != 't') { + if ($this->mode != 't' && !$this->Application->IsAdmin()) { $this->SetDBField('CreatedById', $this->Application->GetVar('u_id')); } @@ -39,18 +39,15 @@ } $ret = parent::Create(); - if($ret) - { - if ( $this->Application->IsTempTable($this->TableName) ) { - $table = $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems'); - } - else { - $table = TABLE_PREFIX.'CategoryItems'; - } - $cat_id = $this->Application->GetVar('m_cat_id'); - $query = 'INSERT INTO '.$table.' (CategoryId,ItemResourceId,PrimaryCat,ItemPrefix,Filename) - VALUES ('.$cat_id.','.$this->GetField('ResourceId').',1,'.$this->Conn->qstr($this->Prefix).','.$this->Conn->qstr($this->GetDBField('Filename')).')'; - $this->Conn->Query($query); + if ($ret) { + $fields_hash = Array( + 'CategoryId' => $this->Application->GetVar('m_cat_id'), + 'ItemResourceId' => $this->GetField('ResourceId'), + 'PrimaryCat' => 1, + 'ItemPrefix' => $this->Prefix, + 'Filename' => $this->GetDBField('Filename'), + ); + $this->Conn->doInsert($fields_hash, $this->CategoryItemsTable()); } return $ret; } @@ -69,15 +66,33 @@ $ret = parent::Update($id, $system_update); if ($ret) { - $table = $this->Application->IsTempTable($this->TableName) ? $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems') : TABLE_PREFIX.'CategoryItems'; $filename = $this->useFilenames ? $this->GetDBField('Filename') : ''; - $this->Conn->Query('UPDATE '.$table.' SET Filename = '.$this->Conn->qstr($filename).' WHERE ItemResourceId = '.$this->GetDBField('ResourceId')); + $sql = 'UPDATE '.$this->CategoryItemsTable().' + SET Filename = '.$this->Conn->qstr($filename).' + WHERE ItemResourceId = '.$this->GetDBField('ResourceId'); + $this->Conn->Query($sql); } unset($this->VirtualFields['ResourceId']); return $ret; } + /** + * Returns CategoryItems table based on current item mode (temp/live) + * + * @return string + */ + function CategoryItemsTable() + { + $table = TABLE_PREFIX.'CategoryItems'; + if ($this->Application->IsTempTable($this->TableName)) { + $table = $this->Application->GetTempName($table); + } + + return $table; + } + + function checkFilename() { if( !$this->GetDBField('AutomaticFilename') ) @@ -147,7 +162,7 @@ } // We need to delete CategoryItems record when deleting product - function Delete($id=null) + function Delete($id = null) { if( isset($id) ) { $this->setID($id); @@ -156,7 +171,8 @@ $ret = parent::Delete(); if ($ret) { - $query = 'DELETE FROM '.TABLE_PREFIX.'CategoryItems WHERE ItemResourceId = '.$this->GetDBField('ResourceId'); + $query = ' DELETE FROM '.$this->CategoryItemsTable().' + WHERE ItemResourceId = '.$this->GetDBField('ResourceId'); $this->Conn->Query($query); } Index: branches/unlabeled/unlabeled-1.13.2/core/units/config_search/config_search_event_handler.php =================================================================== diff -u -r4760 -r5858 --- branches/unlabeled/unlabeled-1.13.2/core/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 4760) +++ branches/unlabeled/unlabeled-1.13.2/core/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 5858) @@ -60,7 +60,7 @@ } /** - * Enter description here... + * [HOOK] Enter description here... * * @param kEvent $event */ @@ -75,12 +75,11 @@ $object =& $event->getObject( Array('skip_autoload' => true) ); $custom_id = $custom_field->GetID(); - if ($custom_id) { + if ($object->GetDBField('CustomFieldId') != $custom_id) { $object->Load($custom_id, 'CustomFieldId'); - $object->SetDBField('CustomFieldId', $custom_id); // for cloning only } - - $cf_search = Array(); + + $cf_search = Array(); $cf_search['DisplayOrder'] = $custom_field->GetDBField('DisplayOrder'); $cf_search['ElementType'] = $custom_field->GetDBField('ElementType'); $cf_search['DisplayName'] = $custom_field->GetDBField('FieldLabel'); @@ -96,6 +95,7 @@ $cf_search['ModuleName'] = $this->Conn->GetOne($sql); $object->SetFieldsFromHash($cf_search); + $object->SetDBField('CustomFieldId', $custom_id); $result = $object->isLoaded() ? $object->Update() : $object->Create(); } Index: branches/unlabeled/unlabeled-1.4.2/kernel/units/stylesheets/stylesheets_event_handler.php =================================================================== diff -u -r5560 -r5858 --- branches/unlabeled/unlabeled-1.4.2/kernel/units/stylesheets/stylesheets_event_handler.php (.../stylesheets_event_handler.php) (revision 5560) +++ branches/unlabeled/unlabeled-1.4.2/kernel/units/stylesheets/stylesheets_event_handler.php (.../stylesheets_event_handler.php) (revision 5858) @@ -4,7 +4,7 @@ { /** - * Compile stylesheet file based on theme definitions + * [HOOK] Compile stylesheet file based on theme definitions * * @param kEvent $event */ Index: branches/unlabeled/unlabeled-1.17.2/kernel/units/general/helpers/permissions_helper.php =================================================================== diff -u -r5516 -r5858 --- branches/unlabeled/unlabeled-1.17.2/kernel/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 5516) +++ branches/unlabeled/unlabeled-1.17.2/kernel/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 5858) @@ -130,7 +130,7 @@ function CheckEventCategoryPermission(&$event, $event_perm_mapping) { // mapping between specific permissions and common permissions - $perm_mapping = Array('add' => 'ADD', 'edit' => 'MODIFY', 'delete' => 'DELETE', 'view' => 'VIEW'); + $perm_mapping = Array('add' => 'ADD', 'add.pending' => 'ADD.PENDING', 'edit' => 'MODIFY', 'edit.pending' => 'MODIFY.PENDING', 'delete' => 'DELETE', 'view' => 'VIEW'); $top_prefix = $event->getEventParam('top_prefix'); $event_handler =& $this->Application->recallObject($event->Prefix.'_EventHandler'); @@ -142,8 +142,6 @@ $id = $event_handler->getPassedID($event); } - $item_prefix = $this->Application->getUnitOption($top_prefix, 'PermItemPrefix'); - // 1. get primary category of category item $id_field = $this->Application->getUnitOption($top_prefix, 'IDField'); $table_name = $this->Application->getUnitOption($top_prefix, 'TableName'); @@ -155,19 +153,26 @@ } else { // item being edited -> check by it's primary category permissions - $sql = 'SELECT ci.CategoryId + $sql = 'SELECT ci.CategoryId, main_table.CreatedById FROM '.$table_name.' main_table LEFT JOIN '.$ci_table.' ci ON ci.ItemResourceId = main_table.ResourceId WHERE (main_table.'.$id_field.' = '.$id.') AND (ci.PrimaryCat = 1)'; - $category_id = $this->Conn->GetOne($sql); + $item_info = $this->Conn->GetRow($sql); + $category_id = $item_info['CategoryId']; + $owner_id = $item_info['CreatedById']; } - if ((substr($event->Name, 0, 9) == 'OnPreSave') || ($event->Name == 'OnSave')) { + $item_prefix = $this->Application->getUnitOption($top_prefix, 'PermItemPrefix'); + + if (substr($event->Name, 0, 9) == 'OnPreSave') { if ($event_handler->isNewItemCreate($event)) { - return $this->CheckPermission($item_prefix.'.ADD', 0, $category_id); + return $this->CheckPermission($item_prefix.'.ADD', 0, $category_id) || + $this->CheckPermission($item_prefix.'.ADD.PENDING', 0, $category_id); } else { - return $this->CheckPermission($item_prefix.'.ADD', 0, $category_id) || $this->CheckPermission($item_prefix.'.MODIFY', 0, $category_id); + return $this->CheckPermission($item_prefix.'.ADD', 0, $category_id) || + $this->CheckPermission($item_prefix.'.ADD.PENDING', 0, $category_id) || + $this->ModifyCheckPermission($owner_id, $category_id, $top_prefix); } } @@ -349,9 +354,7 @@ FROM '.$this->Application->getUnitOption('c', 'TableName').' WHERE CategoryId = '.$cat_id; $cat_hierarchy = $this->Conn->GetOne($sql); - $cat_hierarchy = explode('|', $cat_hierarchy); - array_shift($cat_hierarchy); - array_pop($cat_hierarchy); + $cat_hierarchy = explode('|', substr($cat_hierarchy, 1, -1)); $cat_hierarchy = array_reverse($cat_hierarchy); array_push($cat_hierarchy, 0); } @@ -372,6 +375,40 @@ $this->Application->setCache('permissions', $cache_key, $perm_value); return $perm_value; } + + /** + * Allows to check MODIFY & OWNER.MODFY +/- PENDING permission combinations on item + * + * @param int $owner_id user_id, that is owner of the item + * @param int $category_id primary category of item + * @param string $prefix prefix of item + * @return int {0 - no MODIFY permission, 1 - has MODIFY permission, 2 - has MODIFY.PENDING permission} + */ + function ModifyCheckPermission($owner_id, $category_id, $prefix) + { + $perm_prefix = $this->Application->getUnitOption($prefix, 'PermItemPrefix'); + + $live_modify = $this->CheckPermission($perm_prefix.'.MODIFY', ptCATEGORY, $category_id); + if ($live_modify) { + return 1; + } + else if ($this->CheckPermission($perm_prefix.'.MODIFY.PENDING', ptCATEGORY, $category_id)) { + return 2; + } + + if ($owner_id == $this->Application->GetVar('u_id')) { + // user is item's OWNER -> check this permissions first + $live_modify = $this->CheckPermission($perm_prefix.'.OWNER.MODIFY', ptCATEGORY, $category_id); + if ($live_modify) { + return 1; + } + else if ($this->CheckPermission($perm_prefix.'.OWNER.MODIFY.PENDING', ptCATEGORY, $category_id)) { + return 2; + } + } + + return 0; + } } ?> \ No newline at end of file Index: branches/unlabeled/unlabeled-1.18.2/core/kernel/db/dblist.php =================================================================== diff -u -r5845 -r5858 --- branches/unlabeled/unlabeled-1.18.2/core/kernel/db/dblist.php (.../dblist.php) (revision 5845) +++ branches/unlabeled/unlabeled-1.18.2/core/kernel/db/dblist.php (.../dblist.php) (revision 5858) @@ -417,8 +417,8 @@ if (!empty($group)) $q .= ' GROUP BY ' . $group; if (!empty($having)) $q .= ' HAVING ' . $having; if ( !$for_counting && !empty($order) ) $q .= ' ORDER BY ' . $order; - - return str_replace('%1$s',$this->TableName,$q); + + return $this->replaceModePrefix( str_replace('%1$s', $this->TableName, $q) ); } /** Index: branches/unlabeled/unlabeled-1.32.2/kernel/units/general/cat_dbitem.php =================================================================== diff -u -r5820 -r5858 --- branches/unlabeled/unlabeled-1.32.2/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 5820) +++ branches/unlabeled/unlabeled-1.32.2/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 5858) @@ -29,7 +29,7 @@ $this->SetDBField('ResourceId', $this->Application->NextResourceId()); $this->SetDBField('Modified', adodb_mktime() ); - if ($this->mode != 't') { + if ($this->mode != 't' && !$this->Application->IsAdmin()) { $this->SetDBField('CreatedById', $this->Application->GetVar('u_id')); } @@ -39,18 +39,15 @@ } $ret = parent::Create(); - if($ret) - { - if ( $this->Application->IsTempTable($this->TableName) ) { - $table = $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems'); - } - else { - $table = TABLE_PREFIX.'CategoryItems'; - } - $cat_id = $this->Application->GetVar('m_cat_id'); - $query = 'INSERT INTO '.$table.' (CategoryId,ItemResourceId,PrimaryCat,ItemPrefix,Filename) - VALUES ('.$cat_id.','.$this->GetField('ResourceId').',1,'.$this->Conn->qstr($this->Prefix).','.$this->Conn->qstr($this->GetDBField('Filename')).')'; - $this->Conn->Query($query); + if ($ret) { + $fields_hash = Array( + 'CategoryId' => $this->Application->GetVar('m_cat_id'), + 'ItemResourceId' => $this->GetField('ResourceId'), + 'PrimaryCat' => 1, + 'ItemPrefix' => $this->Prefix, + 'Filename' => $this->GetDBField('Filename'), + ); + $this->Conn->doInsert($fields_hash, $this->CategoryItemsTable()); } return $ret; } @@ -69,15 +66,33 @@ $ret = parent::Update($id, $system_update); if ($ret) { - $table = $this->Application->IsTempTable($this->TableName) ? $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems') : TABLE_PREFIX.'CategoryItems'; $filename = $this->useFilenames ? $this->GetDBField('Filename') : ''; - $this->Conn->Query('UPDATE '.$table.' SET Filename = '.$this->Conn->qstr($filename).' WHERE ItemResourceId = '.$this->GetDBField('ResourceId')); + $sql = 'UPDATE '.$this->CategoryItemsTable().' + SET Filename = '.$this->Conn->qstr($filename).' + WHERE ItemResourceId = '.$this->GetDBField('ResourceId'); + $this->Conn->Query($sql); } unset($this->VirtualFields['ResourceId']); return $ret; } + /** + * Returns CategoryItems table based on current item mode (temp/live) + * + * @return string + */ + function CategoryItemsTable() + { + $table = TABLE_PREFIX.'CategoryItems'; + if ($this->Application->IsTempTable($this->TableName)) { + $table = $this->Application->GetTempName($table); + } + + return $table; + } + + function checkFilename() { if( !$this->GetDBField('AutomaticFilename') ) @@ -147,7 +162,7 @@ } // We need to delete CategoryItems record when deleting product - function Delete($id=null) + function Delete($id = null) { if( isset($id) ) { $this->setID($id); @@ -156,7 +171,8 @@ $ret = parent::Delete(); if ($ret) { - $query = 'DELETE FROM '.TABLE_PREFIX.'CategoryItems WHERE ItemResourceId = '.$this->GetDBField('ResourceId'); + $query = ' DELETE FROM '.$this->CategoryItemsTable().' + WHERE ItemResourceId = '.$this->GetDBField('ResourceId'); $this->Conn->Query($query); } Index: branches/unlabeled/unlabeled-1.7.2/core/admin_templates/stylesheets/stylesheets_list.tpl =================================================================== diff -u -r5290 -r5858 --- branches/unlabeled/unlabeled-1.7.2/core/admin_templates/stylesheets/stylesheets_list.tpl (.../stylesheets_list.tpl) (revision 5290) +++ branches/unlabeled/unlabeled-1.7.2/core/admin_templates/stylesheets/stylesheets_list.tpl (.../stylesheets_list.tpl) (revision 5858) @@ -63,7 +63,7 @@ - + Index: branches/unlabeled/unlabeled-1.27.2/kernel/admin_templates/incs/catalog.js =================================================================== diff -u -r5751 -r5858 --- branches/unlabeled/unlabeled-1.27.2/kernel/admin_templates/incs/catalog.js (.../catalog.js) (revision 5751) +++ branches/unlabeled/unlabeled-1.27.2/kernel/admin_templates/incs/catalog.js (.../catalog.js) (revision 5858) @@ -258,6 +258,16 @@ } Catalog.prototype.ShowDependentButtons = function($prefix) { + /*var $tab_id = this.queryTabRegistry('prefix', $prefix, 'tab_id') + if (!document.getElementById($tab_id + '_form')) { + // tab form not found => no permission to view -> no permission to do any actions + alert('no form: ['+$tab_id + '_form'+']'); + return ; + } + else { + alert('has form: ['+$tab_id + '_form'+']'); + }*/ + var $dep_buttons = this.queryTabRegistry('prefix', $prefix, 'dep_buttons'); var $i = 0; while ($i < $dep_buttons.length) { Index: branches/unlabeled/unlabeled-1.4.2/core/units/stylesheets/stylesheets_event_handler.php =================================================================== diff -u -r5560 -r5858 --- branches/unlabeled/unlabeled-1.4.2/core/units/stylesheets/stylesheets_event_handler.php (.../stylesheets_event_handler.php) (revision 5560) +++ branches/unlabeled/unlabeled-1.4.2/core/units/stylesheets/stylesheets_event_handler.php (.../stylesheets_event_handler.php) (revision 5858) @@ -4,7 +4,7 @@ { /** - * Compile stylesheet file based on theme definitions + * [HOOK] Compile stylesheet file based on theme definitions * * @param kEvent $event */ Index: branches/unlabeled/unlabeled-1.7.2/kernel/admin_templates/stylesheets/stylesheets_list.tpl =================================================================== diff -u -r5290 -r5858 --- branches/unlabeled/unlabeled-1.7.2/kernel/admin_templates/stylesheets/stylesheets_list.tpl (.../stylesheets_list.tpl) (revision 5290) +++ branches/unlabeled/unlabeled-1.7.2/kernel/admin_templates/stylesheets/stylesheets_list.tpl (.../stylesheets_list.tpl) (revision 5858) @@ -63,7 +63,7 @@ - + Index: branches/unlabeled/unlabeled-1.62.2/core/kernel/db/db_tag_processor.php =================================================================== diff -u -r5856 -r5858 --- branches/unlabeled/unlabeled-1.62.2/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 5856) +++ branches/unlabeled/unlabeled-1.62.2/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 5858) @@ -9,7 +9,7 @@ * @access public */ var $Conn; - + function kDBTagProcessor() { parent::kBase(); @@ -1556,19 +1556,10 @@ } } - /** - * Allows to determine if original value should be shown - * - * @param Array $params - * @return bool - */ function DisplayOriginal($params) { - // original id found & greather then zero + show original - $display_original = isset($params['display_original']) && $params['display_original']; - return $display_original && $this->Application->GetVar($this->Prefix.'.original_id'); + return false; } - } ?> \ No newline at end of file Index: branches/unlabeled/unlabeled-1.8.2/core/units/config_search/config_search_config.php =================================================================== diff -u -r4944 -r5858 --- branches/unlabeled/unlabeled-1.8.2/core/units/config_search/config_search_config.php (.../config_search_config.php) (revision 4944) +++ branches/unlabeled/unlabeled-1.8.2/core/units/config_search/config_search_config.php (.../config_search_config.php) (revision 5858) @@ -68,25 +68,25 @@ 'Fields' => Array( - 'TableName' => Array('type' => 'string','not_null' => '1', 'required' => 1, 'default' => ''), - 'FieldName' => Array('type' => 'string','not_null' => '1', 'required' => 1, 'default' => ''), - 'SimpleSearch' => Array('type' => 'int','not_null' => '1','default' => '1'), - 'AdvancedSearch' => Array('type' => 'int','not_null' => '1','default' => '1'), - 'Description' => Array('type' => 'string','default' => ''), - 'DisplayName' => Array('type' => 'string', 'required' => 1, 'default' => ''), - 'ModuleName' => Array('type' => 'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>''), 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Modules WHERE Loaded = 1 ORDER BY LoadOrder', 'option_key_field'=>'Name', 'option_title_field'=>'Name', 'not_null' => '1','default' => 'In-Portal'), - 'ConfigHeader' => Array('type' => 'string', 'required' => 1, 'default' => ''), - 'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'), - 'SearchConfigId' => Array('type' => 'int','not_null' => '1','default' => ''), - 'Priority' => Array('type' => 'int','not_null' => '1','default' => '0'), - 'FieldType' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('text' => 'text', 'range' => 'range', 'boolean' => 'boolean', 'date' => 'date'), 'not_null' => '1', 'required' => 1, 'default' => 'text'), - 'ForeignField' => Array('type' => 'string','default' => null), - 'JoinClause' => Array('type' => 'string','default' => null), - 'IsWhere' => Array('type' => 'string','default' => null), - 'IsNotWhere' => Array('type' => 'string','default' => null), - 'ContainsWhere' => Array('type' => 'string','default' => null), - 'NotContainsWhere' => Array('type' => 'string','default' => null), - 'CustomFieldId' => Array('type' => 'int', 'default' => null), + 'TableName' => Array('type' => 'string','not_null' => '1', 'required' => 1, 'default' => ''), + 'FieldName' => Array('type' => 'string','not_null' => '1', 'required' => 1, 'default' => ''), + 'SimpleSearch' => Array('type' => 'int','not_null' => '1','default' => '1'), + 'AdvancedSearch' => Array('type' => 'int','not_null' => '1','default' => '1'), + 'Description' => Array('type' => 'string','default' => ''), + 'DisplayName' => Array('type' => 'string', 'required' => 1, 'default' => ''), + 'ModuleName' => Array('type' => 'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>''), 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Modules WHERE Loaded = 1 ORDER BY LoadOrder', 'option_key_field'=>'Name', 'option_title_field'=>'Name', 'not_null' => '1','default' => 'In-Portal'), + 'ConfigHeader' => Array('type' => 'string', 'required' => 1, 'default' => ''), + 'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'), + 'SearchConfigId' => Array('type' => 'int','not_null' => '1','default' => ''), + 'Priority' => Array('type' => 'int','not_null' => '1','default' => '0'), + 'FieldType' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('text' => 'text', 'range' => 'range', 'boolean' => 'boolean', 'date' => 'date'), 'not_null' => '1', 'required' => 1, 'default' => 'text'), + 'ForeignField' => Array('type' => 'string','default' => null), + 'JoinClause' => Array('type' => 'string','default' => null), + 'IsWhere' => Array('type' => 'string','default' => null), + 'IsNotWhere' => Array('type' => 'string','default' => null), + 'ContainsWhere' => Array('type' => 'string','default' => null), + 'NotContainsWhere' => Array('type' => 'string','default' => null), + 'CustomFieldId' => Array('type' => 'int', 'default' => null), ), 'VirtualFields' => Array( Index: branches/unlabeled/unlabeled-1.7.2/kernel/constants.php =================================================================== diff -u -r5637 -r5858 --- branches/unlabeled/unlabeled-1.7.2/kernel/constants.php (.../constants.php) (revision 5637) +++ branches/unlabeled/unlabeled-1.7.2/kernel/constants.php (.../constants.php) (revision 5858) @@ -23,6 +23,10 @@ define('erFATAL', -2); // event experienced FATAL error - no hooks should continue! define('erPERM_FAIL', -3); // event failed on internal permission checking (user has not permission) + // permission types + define('ptCATEGORY', 0); + define('ptSYSTEM', 1); + $application =& kApplication::Instance(); $spacer_url = $application->BaseURL().'kernel/admin_templates/img/spacer.gif'; define('SPACER_URL', $spacer_url); Index: branches/unlabeled/unlabeled-1.8.2/kernel/units/config_search/config_search_config.php =================================================================== diff -u -r4944 -r5858 --- branches/unlabeled/unlabeled-1.8.2/kernel/units/config_search/config_search_config.php (.../config_search_config.php) (revision 4944) +++ branches/unlabeled/unlabeled-1.8.2/kernel/units/config_search/config_search_config.php (.../config_search_config.php) (revision 5858) @@ -68,25 +68,25 @@ 'Fields' => Array( - 'TableName' => Array('type' => 'string','not_null' => '1', 'required' => 1, 'default' => ''), - 'FieldName' => Array('type' => 'string','not_null' => '1', 'required' => 1, 'default' => ''), - 'SimpleSearch' => Array('type' => 'int','not_null' => '1','default' => '1'), - 'AdvancedSearch' => Array('type' => 'int','not_null' => '1','default' => '1'), - 'Description' => Array('type' => 'string','default' => ''), - 'DisplayName' => Array('type' => 'string', 'required' => 1, 'default' => ''), - 'ModuleName' => Array('type' => 'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>''), 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Modules WHERE Loaded = 1 ORDER BY LoadOrder', 'option_key_field'=>'Name', 'option_title_field'=>'Name', 'not_null' => '1','default' => 'In-Portal'), - 'ConfigHeader' => Array('type' => 'string', 'required' => 1, 'default' => ''), - 'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'), - 'SearchConfigId' => Array('type' => 'int','not_null' => '1','default' => ''), - 'Priority' => Array('type' => 'int','not_null' => '1','default' => '0'), - 'FieldType' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('text' => 'text', 'range' => 'range', 'boolean' => 'boolean', 'date' => 'date'), 'not_null' => '1', 'required' => 1, 'default' => 'text'), - 'ForeignField' => Array('type' => 'string','default' => null), - 'JoinClause' => Array('type' => 'string','default' => null), - 'IsWhere' => Array('type' => 'string','default' => null), - 'IsNotWhere' => Array('type' => 'string','default' => null), - 'ContainsWhere' => Array('type' => 'string','default' => null), - 'NotContainsWhere' => Array('type' => 'string','default' => null), - 'CustomFieldId' => Array('type' => 'int', 'default' => null), + 'TableName' => Array('type' => 'string','not_null' => '1', 'required' => 1, 'default' => ''), + 'FieldName' => Array('type' => 'string','not_null' => '1', 'required' => 1, 'default' => ''), + 'SimpleSearch' => Array('type' => 'int','not_null' => '1','default' => '1'), + 'AdvancedSearch' => Array('type' => 'int','not_null' => '1','default' => '1'), + 'Description' => Array('type' => 'string','default' => ''), + 'DisplayName' => Array('type' => 'string', 'required' => 1, 'default' => ''), + 'ModuleName' => Array('type' => 'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>''), 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Modules WHERE Loaded = 1 ORDER BY LoadOrder', 'option_key_field'=>'Name', 'option_title_field'=>'Name', 'not_null' => '1','default' => 'In-Portal'), + 'ConfigHeader' => Array('type' => 'string', 'required' => 1, 'default' => ''), + 'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'), + 'SearchConfigId' => Array('type' => 'int','not_null' => '1','default' => ''), + 'Priority' => Array('type' => 'int','not_null' => '1','default' => '0'), + 'FieldType' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('text' => 'text', 'range' => 'range', 'boolean' => 'boolean', 'date' => 'date'), 'not_null' => '1', 'required' => 1, 'default' => 'text'), + 'ForeignField' => Array('type' => 'string','default' => null), + 'JoinClause' => Array('type' => 'string','default' => null), + 'IsWhere' => Array('type' => 'string','default' => null), + 'IsNotWhere' => Array('type' => 'string','default' => null), + 'ContainsWhere' => Array('type' => 'string','default' => null), + 'NotContainsWhere' => Array('type' => 'string','default' => null), + 'CustomFieldId' => Array('type' => 'int', 'default' => null), ), 'VirtualFields' => Array( Index: branches/unlabeled/unlabeled-1.2.2/kernel/units/custom_fields/custom_fields_tag_processor.php =================================================================== diff -u -r5856 -r5858 --- branches/unlabeled/unlabeled-1.2.2/kernel/units/custom_fields/custom_fields_tag_processor.php (.../custom_fields_tag_processor.php) (revision 5856) +++ branches/unlabeled/unlabeled-1.2.2/kernel/units/custom_fields/custom_fields_tag_processor.php (.../custom_fields_tag_processor.php) (revision 5858) @@ -45,6 +45,7 @@ function setParamValue(&$params, $param_name) { + // $deep_level if GetParam = 1 used in case if PrintList is called during parsing "grid" block (=> +1 to deep_level) if (!isset($params[$param_name])) { $params[$param_name] = $this->Application->Parser->GetParam($param_name, 1); } @@ -76,13 +77,13 @@ $block_params['pass_params'] = 'true'; $prev_heading = ''; + $display_original = false; $source_prefix = getArrayValue($params, 'SourcePrefix'); if ($source_prefix) { $source_object =& $this->Application->recallObject($source_prefix); + $display_original = $this->Application->ProcessParsedTag($source_prefix, 'DisplayOriginal', Array('display_original' => $this->setParamValue($params, 'display_original'))); } - // $deep_level if GetParam = 1 used in case if PrintList is called during parsing "grid" block (=> +1 to deep_level) - $display_original = $this->setParamValue($params, 'display_original'); if ($display_original) { $block_params['display_original'] = $display_original; $block_params['original_title'] = $this->setParamValue($params, 'original_title'); Index: branches/unlabeled/unlabeled-1.27.2/core/admin_templates/js/catalog.js =================================================================== diff -u -r5751 -r5858 --- branches/unlabeled/unlabeled-1.27.2/core/admin_templates/js/catalog.js (.../catalog.js) (revision 5751) +++ branches/unlabeled/unlabeled-1.27.2/core/admin_templates/js/catalog.js (.../catalog.js) (revision 5858) @@ -258,6 +258,16 @@ } Catalog.prototype.ShowDependentButtons = function($prefix) { + /*var $tab_id = this.queryTabRegistry('prefix', $prefix, 'tab_id') + if (!document.getElementById($tab_id + '_form')) { + // tab form not found => no permission to view -> no permission to do any actions + alert('no form: ['+$tab_id + '_form'+']'); + return ; + } + else { + alert('has form: ['+$tab_id + '_form'+']'); + }*/ + var $dep_buttons = this.queryTabRegistry('prefix', $prefix, 'dep_buttons'); var $i = 0; while ($i < $dep_buttons.length) { Index: branches/unlabeled/unlabeled-1.2.2/core/units/custom_fields/custom_fields_tag_processor.php =================================================================== diff -u -r5856 -r5858 --- branches/unlabeled/unlabeled-1.2.2/core/units/custom_fields/custom_fields_tag_processor.php (.../custom_fields_tag_processor.php) (revision 5856) +++ branches/unlabeled/unlabeled-1.2.2/core/units/custom_fields/custom_fields_tag_processor.php (.../custom_fields_tag_processor.php) (revision 5858) @@ -45,6 +45,7 @@ function setParamValue(&$params, $param_name) { + // $deep_level if GetParam = 1 used in case if PrintList is called during parsing "grid" block (=> +1 to deep_level) if (!isset($params[$param_name])) { $params[$param_name] = $this->Application->Parser->GetParam($param_name, 1); } @@ -76,13 +77,13 @@ $block_params['pass_params'] = 'true'; $prev_heading = ''; + $display_original = false; $source_prefix = getArrayValue($params, 'SourcePrefix'); if ($source_prefix) { $source_object =& $this->Application->recallObject($source_prefix); + $display_original = $this->Application->ProcessParsedTag($source_prefix, 'DisplayOriginal', Array('display_original' => $this->setParamValue($params, 'display_original'))); } - // $deep_level if GetParam = 1 used in case if PrintList is called during parsing "grid" block (=> +1 to deep_level) - $display_original = $this->setParamValue($params, 'display_original'); if ($display_original) { $block_params['display_original'] = $display_original; $block_params['original_title'] = $this->setParamValue($params, 'original_title'); Index: branches/unlabeled/unlabeled-1.25.2/core/kernel/utility/temp_handler.php =================================================================== diff -u -r5774 -r5858 --- branches/unlabeled/unlabeled-1.25.2/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 5774) +++ branches/unlabeled/unlabeled-1.25.2/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 5858) @@ -188,7 +188,7 @@ $tables['SubTables'][] = $tmp; } - function CloneItems($prefix, $special, $ids, $master=null, $foreign_key=null, $parent_prefix = null) + function CloneItems($prefix, $special, $ids, $master = null, $foreign_key = null, $parent_prefix = null, $skip_filenames = false) { if (!isset($master)) $master = $this->Tables; @@ -213,7 +213,13 @@ $object->Load($id); $original_values = $object->FieldValues; - $object->NameCopy($master, $foreign_key); + if (!$skip_filenames) { + $object->NameCopy($master, $foreign_key); + } + elseif ($master['TableName'] == $this->MasterTable) { + // kCatDBItem class only has this attribute + $object->useFilenames = false; + } if (isset($foreign_key)) { $master_foreign_key_field = is_array($master['ForeignKey']) ? $master['ForeignKey'][$parent_prefix] : $master['ForeignKey']; @@ -232,7 +238,9 @@ // remember original => clone mapping for dual ForeignKey updating $this->AlreadyProcessed[$master['TableName']][$id] = $object->GetId(); } - if($object->mode == 't') $object->setTempID(); + if ($object->mode == 't') { + $object->setTempID(); + } if ($mode == 'create') { $this->RaiseEvent('OnAfterClone', $master['Prefix'], $special, Array($object->GetId()), $foreign_key, array('original_id' => $id) ); $this->saveID($master['Prefix'], $special, $object->GetID()); @@ -421,6 +429,7 @@ $live_foreign_key = $this->Conn->GetCol($query); if (isset($temp_id)) { + // if id < 0, then it is 0 by now => substitute it (in progress, by Alex) $query = 'SELECT '.$parent_key_field.' FROM '.$this->GetTempName($master['TableName']).' WHERE '.$master['IdField'].' IN ('.join(',', $temp_id).')'; $temp_foreign_key = $this->Conn->GetCol($query); @@ -493,6 +502,7 @@ $this->Conn->Query($query); $insert_id = $id_to_copy == 0 ? $this->Conn->getInsertID() : $id_to_copy; + $this->saveID($master['Prefix'], '', $insert_id); $this->RaiseEvent( 'OnAfterCopyToLive', $master['Prefix'], '', Array($insert_id), null, array('temp_id' => $id) ); $this->UpdateForeignKeys($master, $insert_id, $id); @@ -550,6 +560,12 @@ } }*/ $this->DropTempTable($master['TableName']); + + if (!isset($this->savedIDs[ $master['Prefix'] ])) { + $this->savedIDs[ $master['Prefix'] ] = Array(); + } + + return $this->savedIDs[ $master['Prefix'] ]; } function UpdateForeignKeys($master, $live_id, $temp_id) { @@ -641,7 +657,7 @@ function SaveEdit($master_ids = Array()) { - $this->DoCopyTempToOriginal($this->Tables, null, $master_ids); + return $this->DoCopyTempToOriginal($this->Tables, null, $master_ids); } function CancelEdit($master=null) Index: branches/unlabeled/unlabeled-1.11.2/core/kernel/processors/tag_processor.php =================================================================== diff -u -r5741 -r5858 --- branches/unlabeled/unlabeled-1.11.2/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 5741) +++ branches/unlabeled/unlabeled-1.11.2/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 5858) @@ -48,16 +48,21 @@ if ($this->Application->isDebugMode() && constOn('DBG_SHOW_TAGS')) { $this->Application->Debugger->appendHTML('Processing PreParsed Tag '.$Method.' in '.$this->Prefix); } - - //echo htmlspecialchars($tag->GetFullTag()).'
'; // pass_params for non ParseBlock tags :) if (isset($params['pass_params']) && $params['pass_params']) { $params = array_merge_recursive2($this->Application->Parser->Params, $params); unset($params['pass_params']); } + $backup_prefix = $this->Prefix; + $backup_special = $this->Special; + $ret = $this->$Method($params); + + $this->Prefix = $backup_prefix; + $this->Special = $backup_special; + if (isset($params['js_escape']) && $params['js_escape']) { $ret = str_replace('\'', ''', $ret); $ret = addslashes($ret); Index: branches/unlabeled/unlabeled-1.26.2/core/kernel/db/dbitem.php =================================================================== diff -u -r5731 -r5858 --- branches/unlabeled/unlabeled-1.26.2/core/kernel/db/dbitem.php (.../dbitem.php) (revision 5731) +++ branches/unlabeled/unlabeled-1.26.2/core/kernel/db/dbitem.php (.../dbitem.php) (revision 5858) @@ -914,7 +914,16 @@ foreach ($this->customFields as $custom_id => $custom_name) { $cdata->SetDBField($ml_formatter->LangFieldName('cust_'.$custom_id), $this->GetDBField('cust_'.$custom_name)); } - return $cdata->isLoaded() ? $cdata->Update() : $cdata->Create(); + + if ($cdata->isLoaded()) { + $ret = $cdata->Update(); + } + else { + $ret = $cdata->Create(); + if ($cdata->mode == 't') $cdata->setTempID(); + } + + return $ret; } }