Gollem::renameItem PHP 메소드

renameItem() 공개 정적인 메소드

Rename files using the current Gollem session settings.
public static renameItem ( string $oldDir, string $old, string $newDir, $new )
$oldDir string Old directory name.
$old string Old file name.
$newDir string New directory name.
    public static function renameItem($oldDir, $old, $newDir, $new)
    {
        try {
            $GLOBALS['injector']->getInstance('Gollem_Vfs')->rename($oldDir, $old, $newDir, $new);
        } catch (Horde_Vfs_Exception $e) {
            throw new Gollem_Exception($e);
        }
        $shares = $GLOBALS['injector']->getInstance('Gollem_Shares');
        $backend = $GLOBALS['session']->get('gollem', 'backend_key');
        try {
            $share = $shares->getShare($backend . '|' . $oldDir . '/' . $old);
            $shares->renameShare($share, $backend . '|' . $newDir . '/' . $new);
            $share->set('name', $new, true);
        } catch (Horde_Exception_NotFound $e) {
        } catch (Horde_Share_Exception $e) {
            throw new Gollem_Exception($e);
        }
    }

Usage Example

예제 #1
0
파일: manager.php 프로젝트: horde/horde
         try {
             Gollem::createFolder($old_dir, $vars->new_folder);
             $notification->push(_("New folder created: ") . $vars->new_folder, 'horde.success');
         } catch (Gollem_Exception $e) {
             $notification->push($e, 'horde.error');
         }
     }
     break;
 case 'rename_items':
     if ($edit_perms && isset($vars->new_names) && isset($vars->old_names)) {
         $new = explode('|', $vars->new_names);
         $old = explode('|', $vars->old_names);
         if (count($new) == count($old)) {
             for ($i = 0, $iMax = count($new); $i < $iMax; ++$i) {
                 try {
                     Gollem::renameItem($old_dir, $old[$i], $old_dir, $new[$i]);
                     $notification->push(sprintf(_("\"%s\" renamed to \"%s\""), $old[$i], $new[$i]), 'horde.success');
                 } catch (Gollem_Exception $e) {
                     $notification->push($e, 'horde.error');
                 }
             }
             Gollem::expireCache($old_dir);
         }
     }
     break;
 case 'chmod_modify':
 case 'delete_items':
     if ($delete_perms && is_array($vars->items) && count($vars->items)) {
         foreach ($vars->items as $item) {
             if ($vars->actionID == 'chmod_modify' && $vars->chmod) {
                 try {