當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。