0013384: repair revision history
authorPaul Mehrer <p.mehrer@metaways.de>
Wed, 9 Aug 2017 15:21:01 +0000 (17:21 +0200)
committerMichael Spahn <m.spahn@metaways.de>
Fri, 11 Aug 2017 09:19:06 +0000 (11:19 +0200)
* Tinebase_Tree_FileObject - adjust system note generation
* fix note regexp in activities panel
* fix path download when path contains quotes

https://forge.tine20.org/view.php?id=13384

Change-Id: I5e31afe3895f3170a75d71537df617c556536274
Reviewed-on: http://gerrit.tine20.com/customers/5438
Tested-by: Philipp Schüle <p.schuele@metaways.de>
Reviewed-by: Michael Spahn <m.spahn@metaways.de>
tine20/Filemanager/js/Filemanager.js
tine20/Filemanager/js/Model.js
tine20/Tinebase/Tree/FileObject.php
tine20/Tinebase/js/widgets/ActivitiesPanel.js

index b49a8c7..bc4d2e1 100644 (file)
@@ -116,3 +116,18 @@ Tine.Filemanager.downloadFile = function(path, revision, appName) {
         }
     }).start();
 };
+
+
+/**
+ * download file into browser with base64 (btoa) encoded path
+ *
+ * @param {String} encodedpath
+ * @param revision
+ * @param appName
+ * @returns {Ext.ux.file.Download}
+ *
+ * @refactor: we should only need one downloadFile fn
+ */
+Tine.Filemanager.downloadFileByEncodedPath = function(encodedpath, revision, appName) {
+    return Tine.Filemanager.downloadFile(atob(encodedpath), revision, appName);
+};
index 368e0d3..1c24441 100644 (file)
@@ -93,9 +93,11 @@ Tine.widgets.grid.RendererManager.register('Tinebase', 'Tree_Node', 'revision',
     var revisionString = Tine.Tinebase.appMgr.get('Filemanager').i18n._('Revision') + " " + revision,
         availableRevisions = record.get('available_revisions');
 
-    return Ext.isArray(availableRevisions) && availableRevisions.indexOf(String(revision)) >= 0 ?
-        '<a href="#"; onclick="Tine.Filemanager.downloadFile(\'' + record.get('path')+ '\',' + revision + '); return false;">' + revisionString + '</a>' :
-        revisionString;
+    // NOTE we have to encode the path here because it might contain quotes or other bad chars
+    return (Ext.isArray(availableRevisions) && availableRevisions.indexOf(String(revision)) >= 0)
+        ? '<a href="#"; onclick="Tine.Filemanager.downloadFileByEncodedPath(\'' + btoa(record.get('path')) + '\',' + revision
+            + '); return false;">' + revisionString + '</a>'
+        : revisionString;
 });
 
 
index 231b384..a26320f 100644 (file)
@@ -339,7 +339,11 @@ class Tinebase_Tree_FileObject extends Tinebase_Backend_Sql_Abstract
 
         $currentMods = $this->_writeModLog($newRecord, $oldRecord);
         if (null !== $currentMods && $currentMods->count() > 0) {
-            Tinebase_Notes::getInstance()->addSystemNote($newRecord, Tinebase_Core::getUser(), Tinebase_Model_Note::SYSTEM_NOTE_NAME_CHANGED, $currentMods);
+            foreach (Tinebase_FileSystem::getInstance()->_getTreeNodeBackend()->getObjectUsage($newRecord->getId()) as
+                    $node) {
+                Tinebase_Notes::getInstance()->addSystemNote($node->getId(), Tinebase_Core::getUser(),
+                    Tinebase_Model_Note::SYSTEM_NOTE_NAME_CHANGED, $currentMods, 'Sql', 'Tinebase_Model_Tree_Node');
+            }
         }
 
         Tinebase_Model_Tree_FileObject::setReplicable($oldIsReplicable);
index 12b9496..88bffc3 100644 (file)
@@ -130,7 +130,7 @@ Tine.widgets.activities.ActivitiesTabPanel = Ext.extend(Ext.Panel, {
             Ext.each(recordClass.getFieldDefinitions(), function(field) {
                 var _ = window.lodash,
                     i18nLabel = field.label ? i18n._hidden(field.label) : field.name,
-                    regexp = new RegExp(' (' + _.escapeRegExp(field.name) +'|' + _.escapeRegExp(i18nLabel) + ') \\((.*) (->) ([^)]*)\\)'),
+                    regexp = new RegExp(' (' + _.escapeRegExp(field.name) +'|' + _.escapeRegExp(i18nLabel) + ') \\((.*?) (->) ([^)]*)\\)'),
                     struct = regexp.exec(note),
                     label = struct && struct.length == 5 ? struct[1] : null,
                     oldValue = label ? struct[2] : null,