1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8class Services_File_Utilities 9{ 10 function checkTargetGallery($galleryId) 11 { 12 global $prefs; 13 14 if (! $gal_info = $this->getGallery($galleryId)) { 15 throw new Services_Exception(tr('Requested gallery does not exist.'), 404); 16 } 17 18 $canUpload = TikiLib::lib('filegal')->can_upload_to($gal_info); 19 20 if (! $canUpload) { 21 throw new Services_Exception(tr('Permission denied.'), 403); 22 } 23 24 return $gal_info; 25 } 26 27 function getGallery($galleryId) 28 { 29 $filegallib = TikiLib::lib('filegal'); 30 return $filegallib->get_file_gallery_info($galleryId); 31 } 32 33 function uploadFile($gal_info, $name, $size, $type, $data, $asuser = null, $image_x = null, $image_y = null, $description = '', $created = '', $title = '') 34 { 35 $filegallib = TikiLib::lib('filegal'); 36 return $filegallib->upload_single_file($gal_info, $name, $size, $type, $data, $asuser, $image_x, $image_y, $description, $created, $title); 37 } 38 39 function updateFile($gal_info, $name, $size, $type, $data, $fileId, $asuser = null, $title = '') 40 { 41 $filegallib = TikiLib::lib('filegal'); 42 return $filegallib->update_single_file($gal_info, $name, $size, $type, $data, $fileId, $asuser, $title); 43 } 44} 45