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


PHP CustomField::store方法代码示例

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


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

示例1: store

 function store($object_id)
 {
     global $AppUI, $db, $_FILES, $m, $_POST;
     $file_uploaded = false;
     // instantiate the file object and eventually load exsiting file data
     $obj = new CFile();
     if ($_POST[$this->field_name . '_id']) {
         $obj->load($_POST[$this->field_name . '_id']);
         // create an old object for the case that
         // the file must be replaced
         if ($_POST[$this->field_name . '_id'] > 0) {
             $oldObj = new CFile();
             $oldObj->load($_POST[$this->field_name . '_id']);
         }
     }
     // if the cf lives in the projects module
     // affiliate the file to the suitable project
     if ($m == 'projects' && !empty($_POST['project_id'])) {
         $obj->file_project = $_POST['project_id'];
     }
     // todo: implement task affiliation here, too
     $upload = null;
     if (isset($_FILES[$this->field_name])) {
         $upload = $_FILES[$this->field_name];
         if ($upload['size'] > 0) {
             // store file with a unique name
             $obj->file_name = $upload['name'];
             $obj->file_type = $upload['type'];
             $obj->file_size = $upload['size'];
             $obj->file_date = str_replace("'", '', $db->DBTimeStamp(time()));
             $obj->file_real_filename = uniqid(rand());
             $obj->file_owner = $AppUI->user_id;
             $obj->file_version++;
             $obj->file_version_id = $obj->file_id;
             $res = $obj->moveTemp($upload);
             if ($res) {
                 $file_uploaded = true;
             }
             if ($msg = $obj->store()) {
                 $AppUI->setMsg($msg, UI_MSG_ERROR);
             } else {
                 // reset the cf field_name to the file_id
                 $this->setValue($obj->file_id);
             }
         }
     }
     // Delete the existing (old) file in case of file replacement
     // (through addedit not through c/o-versions)
     if ($_POST[$this->field_name . '_id'] && $upload['size'] > 0 && $file_uploaded) {
         $oldObj->deleteFile();
     }
     if ($upload['size'] > 0 && $file_uploaded) {
         return parent::store($object_id);
     } else {
         if ($upload['size'] > 1 && !$file_uploaded) {
             $AppUI->setMsg('File could not be stored!', UI_MSG_ERROR, true);
             return true;
         }
     }
 }
开发者ID:illuminate3,项目名称:dotproject,代码行数:60,代码来源:CustomFields.class.php


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