Index: branches/RC/core/units/general/cat_event_handler.php =================================================================== diff -u -N -r11751 -r11821 --- branches/RC/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 11751) +++ branches/RC/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 11821) @@ -17,6 +17,7 @@ 'OnResetSettings' => Array ('self' => 'add|edit|advanced:import'), 'OnBeforeDeleteOriginal' => Array ('self' => 'edit|advanced:approve'), + 'OnCopy' => Array ('self' => true), 'OnDownloadFile' => Array ('self' => 'view'), 'OnCancelAction' => Array ('self' => true), 'OnItemBuild' => Array ('self' => true), @@ -81,7 +82,7 @@ else { // leave only items, that can be edited $ids = Array (); - $check_method = ($event->Name == 'OnMassDelete') ? 'DeleteCheckPermission' : 'ModifyCheckPermission'; + $check_method = in_array($event->Name, Array ('OnMassDelete', 'OnCut')) ? 'DeleteCheckPermission' : 'ModifyCheckPermission'; foreach ($items as $item_id => $item_data) { if ($perm_helper->$check_method($item_data['CreatedById'], $item_data['CategoryId'], $event->Prefix) > 0) { $ids[] = $item_id; @@ -125,7 +126,8 @@ { return Array ( 'OnEdit', 'OnSave', 'OnMassDelete', 'OnMassApprove', - 'OnMassDecline', 'OnMassMoveUp', 'OnMassMoveDown' + 'OnMassDecline', 'OnMassMoveUp', 'OnMassMoveDown', + 'OnCut', ); } @@ -197,6 +199,7 @@ $this->Application->RemoveVar('clipboard'); $clipboard_helper =& $this->Application->recallObject('ClipboardHelper'); $clipboard_helper->setClipboard($event, 'copy', $this->StoreSelectedIDs($event)); + $this->clearSelectedIDs($event); } /** @@ -209,16 +212,37 @@ $this->Application->RemoveVar('clipboard'); $clipboard_helper =& $this->Application->recallObject('ClipboardHelper'); $clipboard_helper->setClipboard($event, 'cut', $this->StoreSelectedIDs($event)); + $this->clearSelectedIDs($event); } /** + * Checks permission for OnPaste event + * + * @param kEvent $event + * @return bool + */ + function _checkPastePermission(&$event) + { + $perm_helper =& $this->Application->recallObject('PermissionsHelper'); + /* @var $perm_helper kPermissionsHelper */ + + $category_id = $this->Application->GetVar('m_cat_id'); + if ($perm_helper->AddCheckPermission($category_id, $event->Prefix) == 0) { + // no items left for editing -> no permission + return $perm_helper->finalizePermissionCheck($event, false); + } + + return true; + } + + /** * Performs category item paste * * @param kEvent $event */ function OnPaste(&$event) { - if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { + if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) || !$this->_checkPastePermission($event)) { return; } @@ -230,7 +254,9 @@ if ($clipboard_data['copy']) { $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); - $this->Application->SetVar('ResetCatBeforeClone', 1); + /* @var $temp kTempTablesHandler */ + + $this->Application->SetVar('ResetCatBeforeClone', 1); // used in "kCatDBEventHandler::OnBeforeClone" $temp->CloneItems($event->Prefix, $event->Special, $clipboard_data['copy']); }