Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Add a hook on node.change to move bookmarks metadata, should fix #870
Browse files Browse the repository at this point in the history
We should refactor all the bookmarks management into a proper plugin. At the moment, moving to recycle is not considered deleted.
  • Loading branch information
cdujeu committed Mar 19, 2015
1 parent 8203f48 commit 34e8624
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions core/src/plugins/gui.ajax/class.AJXP_ClientDriver.php
Expand Up @@ -352,6 +352,26 @@ public function nodeBookmarkMetadata(&$ajxpNode)
}
}

/**
* @param AJXP_Node $fromNode
* @param AJXP_Node $toNode
* @param bool $copy
*/
public function nodeChangeBookmarkMetadata($fromNode=null, $toNode=null, $copy=false){
if($copy || $fromNode == null) return;
$user = AuthService::getLoggedUser();
if($user == null) return;
if (!isSet(self::$loadedBookmarks)) {
self::$loadedBookmarks = $user->getBookmarks();
}
if($toNode == null) {
$fromNode->removeMetadata("ajxp_bookmarked", true, AJXP_METADATA_SCOPE_REPOSITORY, true);
} else {
$toNode->copyOrMoveMetadataFromNode($fromNode, "ajxp_bookmarked", "move", true, AJXP_METADATA_SCOPE_REPOSITORY, true);
}
AJXP_Controller::applyHook("msg.instant", array("<reload_bookmarks/>", $fromNode->getRepositoryId()));
}

public static function filterXml(&$value)
{
$instance = AJXP_PluginsService::getInstance()->findPlugin("gui", "ajax");
Expand Down
3 changes: 2 additions & 1 deletion core/src/plugins/gui.ajax/manifest.xml
Expand Up @@ -176,7 +176,8 @@
</action>
</actions>
<hooks>
<serverCallback hookName="node.info" methodName="nodeBookmarkMetadata"></serverCallback>
<serverCallback hookName="node.info" methodName="nodeBookmarkMetadata"/>
<serverCallback hookName="node.change" methodName="nodeChangeBookmarkMetadata"/>
</hooks>
<external_file filename="plugins/gui.ajax/ajxpclient_actions.xml" include="actions/*" exclude=""/>
<client_configs uuidAttr="name">
Expand Down

0 comments on commit 34e8624

Please sign in to comment.