当前位置: 首页>>代码示例>>PHP>>正文


PHP ilObjFile::getRefId方法代码示例

本文整理汇总了PHP中ilObjFile::getRefId方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjFile::getRefId方法的具体用法?PHP ilObjFile::getRefId怎么用?PHP ilObjFile::getRefId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ilObjFile的用法示例。


在下文中一共展示了ilObjFile::getRefId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addFile

 /**
  * add an File with id.
  *
  * @param string $session_id    current session
  * @param int $target_id refid of parent in repository
  * @param string $file_xml   qti xml description of test
  *
  * @return int reference id in the tree, 0 if not successful
  */
 function addFile($sid, $target_id, $file_xml)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     global $rbacsystem, $tree, $ilLog, $ilAccess;
     if (!($target_obj =& ilObjectFactory::getInstanceByRefId($target_id, false))) {
         return $this->__raiseError('No valid target given.', 'Client');
     }
     if (ilObject::_isInTrash($target_id)) {
         return $this->__raiseError("Parent with ID {$target_id} has been deleted.", 'CLIENT_TARGET_DELETED');
     }
     // Check access
     $allowed_types = array('cat', 'grp', 'crs', 'fold', 'root');
     if (!in_array($target_obj->getType(), $allowed_types)) {
         return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"', 'Client');
     }
     if (!$ilAccess->checkAccess('create', '', $target_id, "file")) {
         return $this->__raiseError('No permission to create Files in target  ' . $target_id . '!', 'Client');
     }
     // create object, put it into the tree and use the parser to update the settings
     include_once './Modules/File/classes/class.ilFileXMLParser.php';
     include_once './Modules/File/classes/class.ilFileException.php';
     include_once './Modules/File/classes/class.ilObjFile.php';
     $file = new ilObjFile();
     try {
         $fileXMLParser = new ilFileXMLParser($file, $file_xml);
         if ($fileXMLParser->start()) {
             global $ilLog;
             $ilLog->write(__METHOD__ . ': File type: ' . $file->getFileType());
             $file->create();
             $file->createReference();
             $file->putInTree($target_id);
             $file->setPermissions($target_id);
             // we now can save the file contents since we know the obj id now.
             $fileXMLParser->setFileContents();
             #$file->update();
             return $file->getRefId();
         } else {
             return $this->__raiseError("Could not add file", "Server");
         }
     } catch (ilFileException $exception) {
         return $this->__raiseError($exception->getMessage(), $exception->getCode() == ilFileException::$ID_MISMATCH ? "Client" : "Server");
     }
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:56,代码来源:class.ilSoapFileAdministration.php

示例2: createFile

 /**	
  * Creates a dav file as a child of this object.
  *
  * @param	string		the name of the file.
  * @return	ilObjectDAV	returns the created object, or null if creation failed.
  */
 function createFile($name)
 {
     global $tree;
     // create and insert Folder in tree
     require_once 'Modules/File/classes/class.ilObjFile.php';
     $newObj = new ilObjFile(0);
     $newObj->setType($this->getILIASFileType());
     $newObj->setTitle($name);
     $newObj->setFileName($name);
     include_once "./Services/Utilities/classes/class.ilMimeTypeUtil.php";
     $mime = ilMimeTypeUtil::getMimeType("", $name, 'application/octet-stream');
     //$newObj->setFileType('application/octet-stream');
     $newObj->setFileType($mime);
     //$newObj->setDescription('');
     $newObj->create();
     $newObj->createReference();
     $newObj->setPermissions($this->getRefId());
     $newObj->putInTree($this->getRefId());
     //$newObj->createDirectory();
     require_once 'class.ilObjFileDAV.php';
     $objDAV = new ilObjFileDAV($newObj->getRefId(), $newObj);
     /*		
     $fs = $objDAV->getContentOutputStream();
     fwrite($fs,' ');
     fclose($fs);
     */
     return $objDAV;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:34,代码来源:class.ilObjectDAV.php


注:本文中的ilObjFile::getRefId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。