[gollem] changed gollem move/copy functionality

mike.varghese at ascellatech.com mike.varghese at ascellatech.com
Thu Jul 31 15:09:26 PDT 2003


Here are some changes I made to gollem (the ones I mentioned previously)
to allow for move/copy to any folder in gollem.  Hope this works.  Email
me with any problems.  Thanks.


-Mike

Ascella Technologies Inc., http://www.ascellatech.com
-------------- next part --------------
Index: gollem/manager.php
===================================================================
RCS file: /repository/gollem/manager.php,v
retrieving revision 1.76
diff -r1.76 manager.php
129,138c129
< case 'move_file':
<     preg_match('/^\[(.+)\]:(.*)/', Horde::getFormData('targetFolder'), $dest);
<     if (empty($dest)) {
<         $target_backend_key = $backend_key;
<         $dest = Horde::getFormData('targetFolder');
<     } else {
<         $target_backend_key = $dest[1];
<         $dest = $dest[2];
<     }
< 
---
> case 'cut_items':
141a133
>         $_SESSION['gollem']['cut']['selected'] = true;
143,167c135,137
<             if ($target_backend_key == $backend_key) {
<                 $result = $vfs[$backend_key]->move(Gollem::getDir($backend_key), $item, $dest);
<                 if (!is_a($result, 'PEAR_Error')) {
<                     $notification->push(sprintf(_("%s was sucesfully moved to %s."), $item, $dest), 'horde.success');
<                 } else {
<                     $notification->push(sprintf(_("Cannot move '%s': %s"), $item, $result->getMessage()), 'horde.error');
<                 }
<             } else {
<                 $data = $vfs[$backend_key]->read(Gollem::getDir($backend_key), $item);
<                 if (!is_a($data, 'PEAR_Error')) {
<                     $result = $vfs[$target_backend_key]->writeData($dest, $item, $data, false);
<                     if (!is_a($result, 'PEAR_Error')) {
<                         $result = $vfs[$backend_key]->deleteFile(Gollem::getDir($backend_key), $item);
<                         if (!is_a($result, 'PEAR_Error')) {
<                             $notification->push(sprintf(_("%s was sucesfully moved to %s."), $item, $dest), 'horde.success');
<                         } else {
<                             $notification->push(sprintf(_("%s was succesfully copied, but not deleted: %s"), $item, $result->getMessage()), 'horde.error');
<                         }
<                     } else {
<                         $notification->push(sprintf(_("Cannot write '%s': %s"), $item, $result->getMessage()), 'horde.error');
<                     }
<                 } else {
<                     $notification->push(sprintf(_("Cannot read '%s': %s"), $item, $result->getMessage()), 'horde.error');
<                 }
<             }
---
>             $_SESSION['gollem']['cut']['names'][$item] = $item;
>             $_SESSION['gollem']['cut']['path'] = Gollem::getDir($backend_key);
>             $notification->push(sprintf(_("Item cut to clipboard: %s"), $item), 'horde.success');
169,176d138
<     }
<     break;
< 
< case 'copy_file':
<     preg_match('/^\[(.+)\]:(.*)/', Horde::getFormData('targetFolder'), $dest);
<     if (empty($dest)) {
<         $target_backend_key = $backend_key;
<         $dest = Horde::getFormData('targetFolder');
178,179c140
<         $target_backend_key = $dest[1];
<         $dest = $dest[2];
---
>         $notification->push(_("Cannot cut items onto clipboard."), 'horde.error');
180a142
>     break;
181a144
> case 'copy_items':
184a148
>         $_SESSION['gollem']['copy']['selected'] = true;
186,187c150,166
<             if ($target_backend_key == $backend_key) {
<                 $result = $vfs[$backend_key]->copy(Gollem::getDir($backend_key), $item, $dest);
---
>             $_SESSION['gollem']['copy']['names'][$item] = $item;
>             $_SESSION['gollem']['copy']['path'] = Gollem::getDir($backend_key);
>             $notification->push(sprintf(_("Item copied to clipboard: %s"), $item),'horde.success');
>         }
>     } else {
>         $notification->push(_("Cannot copy items onto clipboard."), 'horde.error');
>     }
>     break;
> 
> case 'paste_items':
>     if ($_SESSION['gollem']['cut']['selected']) {
>         $dest = Gollem::getDir($backend_key);
>         $items = $_SESSION['gollem']['cut']['names'];
>         if (is_array($items) &&
>             count($items)) {
>             foreach ($items as $item) {
>                 $result = $vfs[$backend_key]->move($_SESSION['gollem']['cut']['path'],$item, $dest);
189c168
<                     $notification->push(sprintf(_("%s was sucesfully copied to %s."), $item, $dest), 'horde.success');
---
>                     $notification->push(sprintf(_("%s was sucesfully pasted."), $item, $dest), 'horde.success');
191c170
<                     $notification->push(sprintf(_("Cannot copy '%s': %s"), $item, $result->getMessage()), 'horde.error');
---
>                     $notification->push(sprintf(_("Cannot paste '%s' (clipboard cleared): %s"), $item, $result->getMessage()), 'horde.error');
193,201c172,185
<             } else {
<                 $data = $vfs[$backend_key]->read(Gollem::getDir($backend_key), $item);
<                 if (!is_a($data, 'PEAR_Error')) {
<                     $result = $vfs[$target_backend_key]->writeData($dest, $item, $data, false);
<                     if (!is_a($result, 'PEAR_Error')) {
<                         $notification->push(sprintf(_("%s was sucesfully copied to %s."), $item, $dest), 'horde.success');
<                     } else {
<                         $notification->push(sprintf(_("Cannot write '%s': %s"), $item, $result->getMessage()), 'horde.error');
<                     }
---
>             }
>         }
>         $_SESSION['gollem']['cut']['selected'] = false;
>         $_SESSION['gollem']['cut']['names'] = array();
>         $_SESSION['gollem']['cut']['path'] = '';
>     } else {
>         $dest = Gollem::getDir($backend_key);
>         $items = $_SESSION['gollem']['copy']['names'];
>         if (is_array($items) &&
>             count($items)) {
>             foreach ($items as $item) {
>                 $result = $vfs[$backend_key]->copy($_SESSION['gollem']['copy']['path'],$item, $dest);
>                 if (!is_a($result, 'PEAR_Error')) {
>                     $notification->push(sprintf(_("%s was sucesfully pasted."), $item, $dest), 'horde.success');
203c187
<                     $notification->push(sprintf(_("Cannot read '%s': %s"), $item, $result->getMessage()), 'horde.error');
---
>                     $notification->push(sprintf(_("Cannot paste '%s' (clipboard cleared): %s"), $item, $result->getMessage()), 'horde.error');
206a191,193
>         $_SESSION['gollem']['copy']['selected'] = false;
>         $_SESSION['gollem']['copy']['names'] = array();
>         $_SESSION['gollem']['copy']['path'] = '';
208d194
< 
293a280,291
>             $on_clipboard = false;
>             $copy_path = isset($_SESSION['gollem']['copy']['path']) ?
>                          $_SESSION['gollem']['copy']['path'] : NULL;
>             $cut_path = isset($_SESSION['gollem']['cut']['path']) ?
>                         $_SESSION['gollem']['cut']['path'] : NULL;
>             if ($copy_path == Gollem::getDir($backend_key) ||
>                 $cut_path == Gollem::getDir($backend_key)) {
>                 if ((isset($_SESSION['gollem']['copy']['names'][$item['name']]) ||
>                     isset($_SESSION['gollem']['cut']['names'][$item['name']])) ) {
>                     $on_clipboard = true;
>                 }
>             }
Index: gollem/templates/manager/actions.inc
===================================================================
RCS file: /repository/gollem/templates/manager/actions.inc,v
retrieving revision 1.21
diff -r1.21 actions.inc
12,20c12
<     <td width="100%" align="right" nowrap="nowrap">
<       <?php echo Horde::link('', _("Move"), 'widget', '', $backend_key . "_Transfer('move_file', $j[$backend_key]); return false;") . _("Move") ?></a> |
<       <?php echo Horde::link('', _("Copy"), 'widget', '', $backend_key . "_Transfer('copy_file', $j[$backend_key]); return false;") . _("Copy") ?></a>
<       <select name="targetFolders<?php echo ($j[$backend_key] == 1) ? 1 : 2; ?>">
<         <?php if (!is_a($folder_options, 'PEAR_Error')) echo $folder_options ?>
<       </select>
<     </td>
< 
<     <td align="left" nowrap="nowrap">
---
>     <td align="right" nowrap="nowrap">
29a22,25
>         <?php if ((!$_SESSION['gollem']['cut']['selected']) && (!$_SESSION['gollem']['copy']['selected'])): ?>
>             <option value="cut_items"><?php echo _("Cut Items") ?></option>
>             <option value="copy_items"><?php echo _("Copy Items") ?></option>
>         <?php endif; ?>
30a27,29
>         <?php if (($_SESSION['gollem']['cut']['selected']) || ($_SESSION['gollem']['copy']['selected'])): ?>
>             <option value="paste_items"><?php echo _("Paste Items") ?></option>
>         <?php endif; ?>
Index: gollem/templates/manager/file_summaries.inc
===================================================================
RCS file: /repository/gollem/templates/manager/file_summaries.inc,v
retrieving revision 1.29
diff -r1.29 file_summaries.inc
0a1
> <?php if (!$on_clipboard) : ?>
1a3,5
> <?php else: ?>
> <tr class="deleted">
> <?php endif; ?>
2a7
>     <?php if (!$on_clipboard): ?>
3a9
>     <?php endif; ?>
18c24
<     <td nowrap="nowrap"><?php echo $link ?></td>
---
>     <td nowrap="nowrap"><?php echo $link; ?></td>
Index: gollem/templates/manager/javascript.inc
===================================================================
RCS file: /repository/gollem/templates/manager/javascript.inc,v
retrieving revision 1.14
diff -r1.14 javascript.inc
33,53d32
< function <?php echo $backend_key ?>_Transfer(actID, whichForm)
< {
<     if (<?php echo $backend_key ?>_AnySelected()) {
<         if (whichForm == 1) {
<             document.<?php echo $backend_key ?>_manager.targetFolder.value = document.<?php echo $backend_key ?>_manager.targetFolders1[document.<?php echo $backend_key ?>_manager.targetFolders1.selectedIndex].value;
<         } else {
<             document.<?php echo $backend_key ?>_manager.targetFolder.value = document.<?php echo $backend_key ?>_manager.targetFolders2[document.<?php echo $backend_key ?>_manager.targetFolders2.selectedIndex].value;
<         }
< 
<         if (document.<?php echo $backend_key ?>_manager.targetFolder.value == 'none') {
<             window.alert('Please select a target folder.');
<             return false;
<         }
< 
<         document.<?php echo $backend_key ?>_manager.actionID.value = actID;
<         document.<?php echo $backend_key ?>_manager.submit();
<      } else {
<         window.alert('You must select at least one file first.');
<      }
< }
< 
73a53,54
>     } else if (action == 'paste_items') {
>         <?php echo $backend_key ?>_pasteItems();
81a63,66
>     } else if (action == 'cut_items') {
>         <?php echo $backend_key ?>_cutItems();
>     } else if (action == 'copy_items') {
>         <?php echo $backend_key ?>_copyItems();
144a130,147
> }
> 
> function <?php echo $backend_key ?>_cutItems()
> {
>     document.<?php echo $backend_key ?>_manager.actionID.value = 'cut_items';
>     document.<?php echo $backend_key ?>_manager.submit();
> }
> 
> function <?php echo $backend_key ?>_copyItems()
> {
>     document.<?php echo $backend_key ?>_manager.actionID.value = 'copy_items';
>     document.<?php echo $backend_key ?>_manager.submit();
> }
> 
> function <?php echo $backend_key ?>_pasteItems()
> {
>     document.<?php echo $backend_key ?>_manager.actionID.value = 'paste_items';
>     document.<?php echo $backend_key ?>_manager.submit();



More information about the gollem mailing list