예제 #1
0
 /**
  * Constructor performs initializations actions
  */
 public function __construct()
 {
     //initialize service
     $this->service = tao_models_classes_TaoService::singleton();
     $this->userService = \tao_models_classes_UserService::singleton();
     $this->defaultData();
 }
 /**
  * @return array
  */
 private function getClassProperties()
 {
     $classUri = tao_helpers_Uri::decode($_POST['classUri']);
     $clazz = new core_kernel_classes_Class($classUri);
     $topLevelClass = new core_kernel_classes_Class(CLASS_GENERIS_RESOURCE);
     $classProperties = tao_models_classes_TaoService::singleton()->getClazzProperties($clazz, $topLevelClass);
     return $classProperties;
 }
 /**
  * Binds an UploadFileDescription with the target instance.
  *
  * @access protected
  * @author Jerome Bogaerts <*****@*****.**>
  * @param  Property property The property to bind the data.
  * @param  UploadFileDescription desc the upload file description.
  * @return void
  */
 protected function bindUploadFileDescription(core_kernel_classes_Property $property, tao_helpers_form_data_UploadFileDescription $desc)
 {
     $instance = $this->getTargetInstance();
     // Delete old files.
     foreach ($instance->getPropertyValues($property) as $oF) {
         $oldFile = new core_kernel_versioning_File($oF);
         $oldFile->delete(true);
     }
     $name = $desc->getName();
     $size = $desc->getSize();
     if (!empty($name) && !empty($size)) {
         // Move the file at the right place.
         $source = $desc->getTmpPath();
         $repository = tao_models_classes_TaoService::singleton()->getUploadFileSource();
         $file = $repository->spawnFile($source, $desc->getName());
         tao_helpers_File::remove($source);
         $instance->setPropertyValue($property, $file->getUri());
         // Update the UploadFileDescription with the stored file.
         $desc->setFile($file);
     }
 }
예제 #4
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
 *               2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
 *               2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
 * 
 */
/*
 * This post-installation script creates a new local file source for file uploaded
 * by end-users through the TAO GUI.
 */
$dataPath = FILES_PATH . 'tao' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR;
if (file_exists($dataPath)) {
    helpers_File::emptyDirectory($dataPath);
}
$source = tao_models_classes_FileSourceService::singleton()->addLocalSource('fileUploadDirectory', $dataPath);
tao_models_classes_TaoService::singleton()->setUploadFileSource($source);
// add .htaccess to prevent php code execution
if (file_exists($dataPath) && is_dir($dataPath)) {
    $accessFile = $dataPath . '.htaccess';
    if (!is_writable($dataPath) || file_exists($accessFile && !is_writable($accessFile))) {
        throw new tao_install_utils_Exception("Unable to write .htaccess file into : {$accessFile}.");
    }
    file_put_contents($accessFile, "php_flag engine off\n");
}
예제 #5
0
 /**
  * initialize the services
  * @return
  */
 public function __construct()
 {
     parent::__construct();
     $this->service = tao_models_classes_TaoService::singleton();
 }
예제 #6
0
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
 *               2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
 *               2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
 * 
 */
use oat\oatbox\service\ServiceManager;
use oat\oatbox\filesystem\FileSystemService;
/*
 * This post-installation script creates a new local file source for file uploaded
 * by end-users through the TAO GUI.
 */
$dataPath = FILES_PATH . 'tao' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR;
if (file_exists($dataPath)) {
    helpers_File::emptyDirectory($dataPath);
}
$serviceManager = ServiceManager::getServiceManager();
$fsService = $serviceManager->get(FileSystemService::SERVICE_ID);
$source = $fsService->createFileSystem('fileUploadDirectory', 'tao/upload');
$serviceManager->register(FileSystemService::SERVICE_ID, $fsService);
tao_models_classes_TaoService::singleton()->setUploadFileSourceId('fileUploadDirectory');
// add .htaccess to prevent php code execution
if (file_exists($dataPath) && is_dir($dataPath)) {
    $accessFile = $dataPath . '.htaccess';
    if (!is_writable($dataPath) || file_exists($accessFile && !is_writable($accessFile))) {
        throw new tao_install_utils_Exception("Unable to write .htaccess file into : {$accessFile}.");
    }
    file_put_contents($accessFile, "php_flag engine off\n");
}
예제 #7
0
 /**
  * @return array
  */
 protected function getClassProperties($clazz)
 {
     $topLevelClass = new \core_kernel_classes_Class(CLASS_GENERIS_RESOURCE);
     $classProperties = \tao_models_classes_TaoService::singleton()->getClazzProperties($clazz, $topLevelClass);
     return $classProperties;
 }
 /**
  * Binds an UploadFileDescription with the target instance.
  *
  * @access protected
  * @author Jerome Bogaerts <*****@*****.**>
  * @param  core_kernel_classes_Property $property The property to bind the data.
  * @param  tao_helpers_form_data_UploadFileDescription $desc the upload file description.
  * @return void
  */
 protected function bindUploadFileDescription(core_kernel_classes_Property $property, tao_helpers_form_data_UploadFileDescription $desc)
 {
     $instance = $this->getTargetInstance();
     // If form has delete action, remove file
     if ($desc->getAction() == tao_helpers_form_data_UploadFileDescription::FORM_ACTION_DELETE) {
         $this->removeFile($property);
     } elseif ($desc->getAction() == tao_helpers_form_data_UploadFileDescription::FORM_ACTION_ADD) {
         $name = $desc->getName();
         $size = $desc->getSize();
         if (!empty($name) && !empty($size)) {
             // Remove old
             $this->removeFile($property);
             // Move the file at the right place.
             $source = $desc->getTmpPath();
             $serial = tao_models_classes_TaoService::singleton()->storeUploadedFile($source, $name);
             tao_helpers_File::remove($source);
             // Create association between item & file, database side
             $instance->editPropertyValues($property, $serial);
             // Update the UploadFileDescription with the stored file.
             $desc->setFile($serial);
         }
     }
 }
예제 #9
0
 /**
  * Short description of method __construct
  *
  * @access public
  * @author Sam, <*****@*****.**>
  * @param array $attributes
  * @return mixed
  */
 public function __construct($attributes = array())
 {
     // override the tool options !
     $attributes['toolName'] = PRODUCT_NAME;
     $attributes['toolVersion'] = \tao_models_classes_TaoService::singleton()->getPlatformVersion();
     // create container
     $this->body = new ContainerItemBody('', $this);
     parent::__construct($attributes);
 }