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


PHP CFile::delete方法代码示例

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


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

示例1: delete

 /**
  * @see parent::delete()
  */
 function delete()
 {
     // Suppression du fichier correspondant
     if ($this->file_id) {
         $this->loadFile();
         if ($this->_ref_file->file_id) {
             $this->_ref_file->delete();
         }
     }
     //suppression de la doc
     return parent::delete();
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:15,代码来源:CDocGedSuivi.class.php

示例2: deleteUnnecessaryFiles

 /**
  * Deletes unnecessary files, which don't relate to version or object.
  *
  * @param int $portion Count of files which we want to delete. Default value is 10.
  * @return string
  */
 public static function deleteUnnecessaryFiles($portion = 10)
 {
     $query = new Query(FileTable::getEntity());
     $query->addSelect('ID')->addFilter('=EXTERNAL_ID', 'unnecessary')->addFilter('=MODULE_ID', Driver::INTERNAL_MODULE_ID)->setLimit($portion);
     $workLoad = false;
     $dbResult = $query->exec();
     while ($row = $dbResult->fetch()) {
         $workLoad = true;
         \CFile::delete($row['ID']);
     }
     if (!$workLoad) {
         return '';
     }
     return static::className() . '::deleteUnnecessaryFiles();';
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:21,代码来源:cleaner.php

示例3: delete

 public function delete(CAppUI $AppUI = null)
 {
     global $AppUI;
     $perms = $AppUI->acl();
     $result = false;
     $this->_error = array();
     /*
      * TODO: This should probably use the canDelete method from above too to
      *   not only check permissions but to check dependencies... luckily the
      *   previous version didn't check it either, so we're no worse off.
      */
     if ($perms->checkModuleItem('projects', 'delete', $this->project_id)) {
         $q = $this->_query;
         $q->addTable('tasks');
         $q->addQuery('task_id');
         $q->addWhere('task_project = ' . (int) $this->project_id);
         $tasks_to_delete = $q->loadColumn();
         $q->clear();
         foreach ($tasks_to_delete as $task_id) {
             $q->setDelete('user_tasks');
             $q->addWhere('task_id =' . $task_id);
             $q->exec();
             $q->clear();
             $q->setDelete('task_dependencies');
             $q->addWhere('dependencies_req_task_id =' . (int) $task_id);
             $q->exec();
             $q->clear();
         }
         $q->setDelete('tasks');
         $q->addWhere('task_project =' . (int) $this->project_id);
         $q->exec();
         $q->clear();
         $q->addTable('files');
         $q->addQuery('file_id');
         $q->addWhere('file_project = ' . (int) $this->project_id);
         $files_to_delete = $q->loadColumn();
         $q->clear();
         foreach ($files_to_delete as $file_id) {
             $file = new CFile();
             $file->load($file_id);
             $file->delete($AppUI);
         }
         $q->setDelete('events');
         $q->addWhere('event_project =' . (int) $this->project_id);
         $q->exec();
         $q->clear();
         // remove the project-contacts and project-departments map
         $q->setDelete('project_contacts');
         $q->addWhere('project_id =' . (int) $this->project_id);
         $q->exec();
         $q->clear();
         $q->setDelete('project_departments');
         $q->addWhere('project_id =' . (int) $this->project_id);
         $q->exec();
         $q->clear();
         $q->setDelete('tasks');
         $q->addWhere('task_represents_project =' . (int) $this->project_id);
         $q->clear();
         if ($msg = parent::delete()) {
             return $msg;
         }
         return true;
     }
     return $result;
 }
开发者ID:viniciusbudines,项目名称:sisnuss,代码行数:65,代码来源:projects.class.php

示例4: processActionCommit

 protected function processActionCommit()
 {
     $this->checkRequiredPostParams(array('editSessionId'));
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $this->checkUpdatePermissions();
     $currentSession = $this->getEditSessionByCurrentUser((int) $this->request->getPost('editSessionId'));
     if (!$currentSession) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_FIND_EDIT_SESSION'), self::ERROR_COULD_NOT_FIND_EDIT_SESSION)));
         $this->sendJsonErrorResponse();
     }
     $tmpFile = \CTempFile::getFileName(uniqid('_wd'));
     checkDirPath($tmpFile);
     $fileData = new FileData();
     $fileData->setId($currentSession->getServiceFileId());
     $fileData->setSrc($tmpFile);
     $newNameFileAfterConvert = null;
     if ($this->documentHandler->isNeedConvertExtension($this->file->getExtension())) {
         $newNameFileAfterConvert = getFileNameWithoutExtension($this->file->getName()) . '.' . $this->documentHandler->getConvertExtension($this->file->getExtension());
         $fileData->setMimeType(TypeFile::getMimeTypeByFilename($newNameFileAfterConvert));
     } else {
         $fileData->setMimeType(TypeFile::getMimeTypeByFilename($this->file->getName()));
     }
     $fileData = $this->documentHandler->downloadFile($fileData);
     if (!$fileData) {
         if ($this->documentHandler->isRequiredAuthorization()) {
             $this->sendNeedAuth();
         }
         $this->errorCollection->add($this->documentHandler->getErrors());
         $this->sendJsonErrorResponse();
     }
     $this->deleteEditSession($currentSession);
     $oldName = $this->file->getName();
     //rename in cloud service
     $renameInCloud = $fileData->getName() && $fileData->getName() != $this->file->getName();
     if ($newNameFileAfterConvert || $renameInCloud) {
         if ($newNameFileAfterConvert && $renameInCloud) {
             $newNameFileAfterConvert = getFileNameWithoutExtension($fileData->getName()) . '.' . getFileExtension($newNameFileAfterConvert);
         }
         $this->file->rename($newNameFileAfterConvert);
     }
     $fileArray = \CFile::makeFileArray($tmpFile);
     $fileArray['name'] = $this->file->getName();
     $fileArray['type'] = $fileData->getMimeType();
     $fileArray['MODULE_ID'] = Driver::INTERNAL_MODULE_ID;
     /** @noinspection PhpDynamicAsStaticMethodCallInspection */
     $fileId = \CFile::saveFile($fileArray, Driver::INTERNAL_MODULE_ID);
     if (!$fileId) {
         \CFile::delete($fileId);
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_SAVE_FILE'), self::ERROR_COULD_NOT_SAVE_FILE)));
         $this->sendJsonErrorResponse();
     }
     $versionModel = $this->file->addVersion(array('ID' => $fileId, 'FILE_SIZE' => $fileArray['size']), $this->getUser()->getId(), true);
     if (!$versionModel) {
         \CFile::delete($fileId);
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_ADD_VERSION'), self::ERROR_COULD_NOT_ADD_VERSION)));
         $this->errorCollection->add($this->file->getErrors());
         $this->sendJsonErrorResponse();
     }
     if ($this->isLastEditSessionForFile()) {
         $this->deleteFile($currentSession, $fileData);
     }
     $this->sendJsonSuccessResponse(array('objectId' => $this->file->getId(), 'newName' => $this->file->getName(), 'oldName' => $oldName));
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:65,代码来源:documentcontroller.php

示例5: maybeUpdateThirdParty


//.........这里部分代码省略.........
         if (CFile::exists($lastUpdateTimeFp)) {
             $lastUpdateTime = new CTime(CString::toInt(CFile::read($lastUpdateTimeFp)));
             $currTime = CTime::now();
             if ($lastUpdateTime->isBefore($currTime)) {
                 $numDaysSinceLastUpdate = $currTime->diffInDays($lastUpdateTime);
                 if ($numDaysSinceLastUpdate < $minTimeBetweenDoUpdatesDays) {
                     // It is too early for updates yet.
                     return false;
                 }
             } else {
                 assert('false', vs(isset($this), get_defined_vars()));
             }
         }
         $date = CShell::currentDate();
         CShell::say("Started on {$date}.");
         if (isset($numDaysSinceLastUpdate)) {
             CShell::say("It has been {$numDaysSinceLastUpdate} day(s) since last successful update.");
         }
         $concurrLockFp = CFilePath::add($thirdPartyDp, self::$ms_thirdPartyConcurrLockFn);
         // Try locking the operation.
         if (!self::setLock($concurrLockFp, false)) {
             assert('false', vs(isset($this), get_defined_vars()));
             CShell::onError(false, "Could not obtain a lock on the operation.");
             CShell::writeToLog("\n");
             return false;
         }
         $phpConfigNeedsReload = false;
         $totalNumComponents = CMap::length($components);
         $numComponentsUpdated = 0;
         // The Browser Capabilities Project (BrowsCap).
         if (CMap::hasKey($components, "browsCap")) {
             $browsCap = $components["browsCap"];
             $skip = $browsCap["skip"];
             if (!$skip) {
                 CShell::say("Updating the Browser Capabilities Project (BrowsCap) ...");
                 $lookupFileUrl = $browsCap["lookupFileUrl"];
                 assert('!CString::isEmpty($lookupFileUrl)', vs(isset($this), get_defined_vars()));
                 // Component-related constants.
                 static $s_configOptName = "browscap";
                 static $s_lookupFileDownloadTimeoutSeconds = 120;
                 if (self::hasConfigOption($s_configOptName)) {
                     $browsCapLookupFp = CString::trim(self::configOption($s_configOptName));
                     if (!CString::isEmpty($browsCapLookupFp)) {
                         $browsCapDp = CFilePath::directory($browsCapLookupFp);
                         CShell::say("Downloading a BrowsCap lookup file from '{$lookupFileUrl}' ...");
                         $temporaryFp = CFile::createTemporary($browsCapDp);
                         $downloadRes = CInetRequest::downloadFile($lookupFileUrl, $temporaryFp, $s_lookupFileDownloadTimeoutSeconds);
                         if ($downloadRes) {
                             // After the file is downloaded into a temporary one, move it to the destination,
                             // safely replacing the existing file, if any.
                             CFile::move($temporaryFp, $browsCapLookupFp);
                             $numComponentsUpdated++;
                             $phpConfigNeedsReload = true;
                             $downloadedFileSizeKB = CUUnit::convertStoragef((double) CFile::size($browsCapLookupFp), CUUnit::BYTE, CUUnit::KILOBYTE);
                             $downloadedFileSizeKB = CMathf::round($downloadedFileSizeKB, 2);
                             CShell::say("Done. The downloaded file is {$downloadedFileSizeKB} KB in size.");
                         } else {
                             CShell::onError(false, "Could not download a BrowsCap lookup file from '{$lookupFileUrl}'.");
                         }
                         // Just in case, check for any temporary files that could have been left by any previous
                         // operations in the directory.
                         $leftoverFiles = CFile::findFiles(CFilePath::add($browsCapDp, CFile::DEFAULT_TEMPORARY_FILE_PREFIX . "*"));
                         if (!CArray::isEmpty($leftoverFiles)) {
                             // Cleanup the directory from the temporary files.
                             $len = CArray::length($leftoverFiles);
                             for ($i = 0; $i < $len; $i++) {
                                 CFile::delete($leftoverFiles[$i]);
                             }
                         }
                     } else {
                         CShell::onError(false, "Could not read the value of '{$s_configOptName}' option " . "in the PHP CLI configuration file.");
                     }
                 } else {
                     CShell::onError(false, "Could not find '{$s_configOptName}' option in the PHP CLI configuration file.");
                 }
             } else {
                 CShell::say("Skipping the Browser Capabilities Project (BrowsCap).");
             }
         }
         // All the components have been processed. Unlock the operation.
         self::unsetLock($concurrLockFp);
         $date = CShell::currentDate();
         if ($numComponentsUpdated != 0) {
             // One or more third-party components have been updated. Put a time stamp on the directory where the
             // components are located.
             CFile::write($lastUpdateTimeFp, CString::fromInt(CTime::currentUTime()));
             if ($numComponentsUpdated == $totalNumComponents) {
                 CShell::speak("Success. All {$totalNumComponents} third-party component(s)");
             } else {
                 CShell::speak("Partial success. {$numComponentsUpdated} out of {$totalNumComponents} third-party component(s)");
             }
             CShell::say("have been updated. Completed on {$date}.");
         } else {
             CShell::say("No third-party components have been updated. Completed on {$date}.");
         }
         return $phpConfigNeedsReload;
     } else {
         return false;
     }
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:101,代码来源:CSystem.php

示例6: hook_postDelete

 protected function hook_postDelete()
 {
     $q = $this->_getQuery();
     $q->addTable('tasks');
     $q->addQuery('task_id');
     $q->addWhere('task_project = ' . $this->_old_key);
     $tasks_to_delete = $q->loadColumn();
     $q->clear();
     $task = new w2p_Actions_BulkTasks();
     $task->overrideDatabase($this->_query);
     foreach ($tasks_to_delete as $task_id) {
         $task->task_id = $task_id;
         $task->delete();
     }
     $q->clear();
     $q->addTable('files');
     $q->addQuery('file_id');
     $q->addWhere('file_project = ' . $this->_old_key);
     $files_to_delete = $q->loadColumn();
     $q->clear();
     $file = new CFile();
     $file->overrideDatabase($this->_query);
     foreach ($files_to_delete as $file_id) {
         $file->file_id = $file_id;
         $file->delete();
     }
     $q->clear();
     $q->addTable('events');
     $q->addQuery('event_id');
     $q->addWhere('event_project = ' . $this->_old_key);
     $events_to_delete = $q->loadColumn();
     $q->clear();
     $event = new CEvent();
     $event->overrideDatabase($this->_query);
     foreach ($events_to_delete as $event_id) {
         $event->event_id = $event_id;
         $event->delete();
     }
     $q->clear();
     // remove the project-contacts and project-departments map
     $q->setDelete('project_contacts');
     $q->addWhere('project_id =' . $this->_old_key);
     $q->exec();
     $q->clear();
     $q->setDelete('project_departments');
     $q->addWhere('project_id =' . $this->_old_key);
     $q->exec();
     $q->clear();
     $q->setDelete('tasks');
     $q->addWhere('task_represents_project =' . $this->_old_key);
     parent::hook_preDelete();
 }
开发者ID:victorrod,项目名称:web2project,代码行数:52,代码来源:projects.class.php

示例7: delete

 public static function delete($primary)
 {
     // get old data
     $oldData = static::getByPrimary($primary)->fetch();
     // remove row
     $result = parent::delete($primary);
     // remove files
     $entityName = static::getEntity()->getName();
     $hlblock = HighloadBlockTable::getList(array('select' => array('ID'), 'filter' => array('=NAME' => $entityName)))->fetch();
     // add other fields
     $fields = $GLOBALS['USER_FIELD_MANAGER']->getUserFields('HLBLOCK_' . $hlblock['ID']);
     foreach ($oldData as $k => $v) {
         $arUserField = $fields[$k];
         if ($arUserField["USER_TYPE"]["BASE_TYPE"] == "file") {
             if (is_array($oldData[$k])) {
                 foreach ($oldData[$k] as $value) {
                     \CFile::delete($value);
                 }
             } else {
                 \CFile::delete($oldData[$k]);
             }
         }
     }
     return $result;
 }
开发者ID:spas-viktor,项目名称:books,代码行数:25,代码来源:highloadblock.php

示例8: finalize

 protected function finalize()
 {
     if ($this->m_done) {
         return;
     }
     if (is_resource($this->m_curl)) {
         curl_close($this->m_curl);
     }
     if (isset($this->m_downloadFile)) {
         $this->m_downloadFile->done();
     }
     if (isset($this->m_uploadFile)) {
         $this->m_uploadFile->done();
     }
     if (isset($this->m_fileUploadTempFp) && CFile::exists($this->m_fileUploadTempFp)) {
         CFile::delete($this->m_fileUploadTempFp);
     }
     $this->m_done = true;
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:19,代码来源:CInetRequest.php

示例9: updateDocument


//.........这里部分代码省略.........
         $data['letters_doc_frm_user2_status_date_data'] = null;
     }
     if (!$data['letters_doc_frm_user1_status_date_data']) {
         $data['letters_doc_frm_user1_status_date_data'] = null;
     }
     if (!$data['letters_doc_frm_user3_status_data']) {
         $data['letters_doc_frm_user3_status_data'] = null;
     }
     if (!$data['letters_doc_frm_user2_status_data']) {
         $data['letters_doc_frm_user2_status_data'] = null;
     }
     if (!$data['letters_doc_frm_user1_status_data']) {
         $data['letters_doc_frm_user1_status_data'] = null;
     }
     if (!$data['letters_doc_frm_parent_db_id'] || $data['letters_doc_frm_parent_db_id'] == 'null') {
         $data['letters_doc_frm_parent_db_id'] = null;
     }
     if (!$data['letters_doc_frm_group'] || $data['letters_doc_frm_group'] == 'null') {
         $data['letters_doc_frm_group'] = null;
     }
     if (!$data['letters_doc_frm_group_db_id'] || $data['letters_doc_frm_group_db_id'] == 'null') {
         $data['letters_doc_frm_group_db_id'] = null;
     }
     if (!$data['letters_doc_frm_group_db_id'] && !empty($data['letters_doc_frm_group'])) {
         $data['letters_doc_frm_group_db_id'] = letters::checkCreateGroup($data['letters_doc_frm_group']);
     }
     if ($data['letters_doc_frm_user_1_section'] == '1') {
         $data['letters_doc_frm_user_1_section'] = true;
     } else {
         $data['letters_doc_frm_user_1_section'] = false;
     }
     if ($data['letters_doc_frm_user_2_section'] == '1') {
         $data['letters_doc_frm_user_2_section'] = true;
     } else {
         $data['letters_doc_frm_user_2_section'] = false;
     }
     if ($data['letters_doc_frm_user_3_section'] == '1') {
         $data['letters_doc_frm_user_3_section'] = true;
     } else {
         $data['letters_doc_frm_user_3_section'] = false;
     }
     if ($data['letters_doc_frm_withoutourdoc'] == '1') {
         $data['letters_doc_frm_withoutourdoc'] = true;
     } else {
         $data['letters_doc_frm_withoutourdoc'] = false;
     }
     $doc = self::getDocument($id);
     $doc_data['title'] = $data['letters_doc_frm_title'];
     $doc_data['user_1'] = $data['letters_doc_frm_user_1_db_id'];
     $doc_data['user_2'] = $data['letters_doc_frm_user_2_db_id'];
     $doc_data['user_3'] = $data['letters_doc_frm_user_3_db_id'];
     $doc_data['group_id'] = $data['letters_doc_frm_group_db_id'];
     $doc_data['parent'] = $data['letters_doc_frm_parent_db_id'];
     $doc_data['user_status_1'] = $data['letters_doc_frm_user1_status_data'];
     $doc_data['user_status_2'] = $data['letters_doc_frm_user2_status_data'];
     $doc_data['user_status_3'] = $data['letters_doc_frm_user3_status_data'];
     $doc_data['user_status_date_1'] = $data['letters_doc_frm_user1_status_date_data'];
     $doc_data['user_status_date_2'] = $data['letters_doc_frm_user2_status_date_data'];
     $doc_data['user_status_date_3'] = $data['letters_doc_frm_user3_status_date_data'];
     $doc_data['is_user_1_company'] = $data['letters_doc_frm_user_1_section'] ? 't' : 'f';
     $doc_data['is_user_2_company'] = $data['letters_doc_frm_user_2_section'] ? 't' : 'f';
     $doc_data['is_user_3_company'] = $data['letters_doc_frm_user_3_section'] ? 't' : 'f';
     $doc_data['withoutourdoc'] = $data['withoutourdoc'] ? 't' : 'f';
     if (isset($data['letters_doc_frm_comment']) && $data['letters_doc_frm_comment']) {
         $doc_data['comment'] = $data['letters_doc_frm_comment'];
     } else {
         $data['letters_doc_frm_comment'] = $doc['comment'];
     }
     if ($doc_data['user_status_1'] != $doc['user_status_1'] || $doc_data['user_status_2'] != $doc['user_status_2'] || $doc_data['user_status_3'] != $doc['user_status_3']) {
         letters::updateDateStatusChange($id);
     }
     letters::saveHistory($id, $doc_data);
     $sql = "UPDATE letters SET\n                                     date_add = " . ($data['letters_doc_frm_dateadd_eng_format'] ? "'{$data['letters_doc_frm_dateadd_eng_format']}'" : "NOW()") . ",\n                                     title = ?,\n                                     user_1 = ?,\n                                     user_2 = ?,\n                                     user_3 = ?,\n                                     group_id = ?,\n                                     parent = ?,\n                                     user_status_1 = ?, \n                                     user_status_2 = ?, \n                                     user_status_3 = ?, \n                                     user_status_date_1 = ?, \n                                     user_status_date_2 = ?, \n                                     user_status_date_3 = ?,\n                                     is_user_1_company = ?,  \n                                     is_user_2_company = ?, \n                                     is_user_3_company = ?, \n                                     withoutourdoc = ?,\n                                     comment = ?\n                WHERE id = ?i;";
     $DB->query($sql, $data['letters_doc_frm_title'], $data['letters_doc_frm_user_1_db_id'], $data['letters_doc_frm_user_2_db_id'], $data['letters_doc_frm_user_3_db_id'], $data['letters_doc_frm_group_db_id'], $data['letters_doc_frm_parent_db_id'], $data['letters_doc_frm_user1_status_data'], $data['letters_doc_frm_user2_status_data'], $data['letters_doc_frm_user3_status_data'], $data['letters_doc_frm_user1_status_date_data'], $data['letters_doc_frm_user2_status_date_data'], $data['letters_doc_frm_user3_status_date_data'], $data['letters_doc_frm_user_1_section'], $data['letters_doc_frm_user_2_section'], $data['letters_doc_frm_user_3_section'], $data['letters_doc_frm_withoutourdoc'], $data['letters_doc_frm_comment'], $id);
     $sql = "UPDATE letters SET is_out=false WHERE (user_status_1 IS DISTINCT FROM 1 AND user_status_2 IS DISTINCT FROM 1 AND user_status_3 IS DISTINCT FROM 1) AND id=?i";
     $DB->query($sql, $id);
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/attachedfiles.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/CFile.php";
     $attachedfiles = new attachedfiles($data['attachedfiles_session']);
     $attachedfiles_files = $attachedfiles->getFiles();
     if ($attachedfiles_files) {
         foreach ($attachedfiles_files as $attachedfiles_file) {
             $cFile = new CFile();
             $cFile->table = 'file';
             $cFile->GetInfoById($attachedfiles_file['id']);
             if ($cFile->id != $doc['file_id']) {
                 $ext = $cFile->getext();
                 $tmp_dir = "letters/";
                 $tmp_name = $cFile->secure_tmpname($tmp_dir, '.' . $ext);
                 $tmp_name = substr_replace($tmp_name, "", 0, strlen($tmp_dir));
                 $cFile->_remoteCopy($tmp_dir . $tmp_name, true);
                 $sql = "UPDATE letters SET file_id = ?i WHERE id = ?i";
                 $DB->query($sql, $cFile->id, intval($id));
                 $cFile->delete($doc['file_id']);
             }
         }
     }
     $attachedfiles->clear();
     return $id;
 }
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:101,代码来源:letters.php

示例10: checkWysiwygInlineImages

 /**
  * @deprecated В настоящий момент не используется на сайте
  * 
  * При создании и изменении текста поста в сообществе проверяет, на все ли загруженые при наборе текста в визивиге
  * изображения есть ссылки в тексте комментария, если не на все, удаляет лишние.
  * При создании комментария обновляет cid (ID Сообщения сообщества) записи в commune_attaches
  * @param int    $messageId - номер записи в commune_messages 
  * @param string $text      - текст комментария
  * @param bool   $edit      - true когда редактируется 
  * */
 function checkWysiwygInlineImages($messageId, $text, $edit = false)
 {
     session_start();
     $filesIds = $_SESSION['wysiwyg_inline_files'];
     //получить id вставленных при наборе текста файлов
     global $DB;
     //получаем все теги img из соообщения
     if ($text == '') {
         return;
     }
     $text = str_replace("<cut>", "", $text);
     // Не любит cut сволочь
     $dom = new DOMDocument();
     $dom->validateOnParse = false;
     libxml_use_internal_errors(true);
     $dom->loadHTML($text);
     libxml_use_internal_errors(false);
     $images = $dom->getElementsByTagName('img');
     $w_files = array();
     //файлы, ссылки на которые есть в wisywyg
     for ($i = 0; $i < $images->length; $i++) {
         $filePath = $images->item($i)->getAttribute('src');
         $filePath = str_replace(WDCPREFIX . "/", "", $filePath);
         $file = new CFile($filePath, "file_commune");
         if ($file->id) {
             $w_files[$file->id] = $file->id;
         }
     }
     if ($cid) {
         //если комментарий редактируется, добавим к идентификаторам вновь вставленных в визивиг файлов идентификаторв ранее вставленных
         $rows = $DB->rows("SELECT fid FROM commune_attach\n    \t    \t\t\tWHERE cid = {$cid} AND inline = TRUE");
         foreach ($rows as $row) {
             $filesIds[$row['fid']] = $row['fid'];
         }
     }
     //удалить из $filesIds те, ссылок на которые нет в тексте визивига
     foreach ($filesIds as $id) {
         if (!$w_files[$id]) {
             $cfile = new CFile($id, "file_commune");
             if ($cfile->id) {
                 $cfile->delete($id);
             }
             unset($filesIds[$id]);
         }
     }
     $ids = join(',', $filesIds);
     if (count($filesIds)) {
         $cmd = "UPDATE commune_attach \n\t    \t    SET cid = {$messageId},\n\t    \t         temp = FALSE\n\t            WHERE fid IN ( {$ids} )";
         $DB->query($cmd);
     }
     $_SESSION['wysiwyg_inline_files'] = array();
 }
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:62,代码来源:commune.php

示例11: checkWysiwygInlineImages

 /**
  * При создании и изменении текста комментария проверяет, на все ли загруженые при наборе текста в визивиге
  * изображения есть ссылки в тексте комментария, если не на все, удаляет лишние.
  * При создании комментария обновляет cid (ID Сообщения сообщества) записи в commune_attaches
  * @param $messageId - номер записи в commune_messages 
  * @param $text      - текст комментария 
  * @param $cid       - идентификатор комментария в commune_messages
  * */
 function checkWysiwygInlineImages($messageId, $text, $cid)
 {
     session_start();
     $filesIds = $_SESSION['wysiwyg_inline_files'];
     //получить id вставленных при наборе текста файлов
     global $DB;
     $model = $this->model();
     //если в таблице есть поля для хранения флага временного файла и флага файла в визивиге
     if ($model['attaches']['fields']['temp'] && $model['attaches']['fields']['inline']) {
         //получаем все теги img из соообщения
         $text = str_replace("<cut>", "", $text);
         // DOM не любит этот тег
         $dom = new DOMDocument();
         $dom->validateOnParse = false;
         $dom->loadHTML($text);
         $images = $dom->getElementsByTagName('img');
         $w_files = array();
         //файлы, ссылки на которые есть в wisywyg
         for ($i = 0; $i < $images->length; $i++) {
             $filePath = $images->item($i)->getAttribute('src');
             $filePath = str_replace(WDCPREFIX . "/", "", $filePath);
             $file = new CFile($filePath, $model['attaches']['file_table']);
             if ($file->id) {
                 $w_files[$file->id] = $file->id;
             }
         }
         if ($cid) {
             //если комментарий редактируется, добавим к идентификаторам вновь вставленных в визивиг файлов идентификаторв ранее вставленных
             $cmd = "SELECT {$model['attaches']['fields']['file']} FROM {$model['attaches']['table']}\n    \t        \t\t\tWHERE {$model['attaches']['fields']['comment']} = {$cid} AND {$model['attaches']['fields']['inline']} = TRUE";
             $rows = $DB->rows($cmd);
             foreach ($rows as $row) {
                 $filesIds[$row[$model['attaches']['fields']['file']]] = $row[$model['attaches']['fields']['file']];
             }
         }
         if (!$filesIds) {
             return;
         }
         //удалить из $filesIds те, ссылок на которые нет в тексте визивига
         foreach ($filesIds as $id) {
             if (!$w_files[$id]) {
                 $cfile = new CFile($id, $model['attaches']['file_table']);
                 if ($cfile->id) {
                     $cfile->delete($id);
                 }
                 unset($filesIds[$id]);
             }
         }
         $ids = join(',', $filesIds);
         if (count($filesIds)) {
             $cmd = "UPDATE {$model['attaches']['table']} \n\t    \t    SET {$model['attaches']['fields']['comment']} = {$messageId},\n\t    \t         temp = FALSE\n\t            WHERE {$model['attaches']['fields']['file']} IN ( {$ids} )";
             $DB->query($cmd);
         }
     }
     $_SESSION['wysiwyg_inline_files'] = array();
 }
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:63,代码来源:Comments.php

示例12: Delete

 function Delete($id)
 {
     global $DB;
     $id = IntVal($id);
     $res = $DB->query('SELECT FILE_ID FROM b_mail_msg_attachment WHERE MESSAGE_ID = ' . $id);
     while ($file = $res->fetch()) {
         if ($file['FILE_ID']) {
             CFile::delete($file['FILE_ID']);
         }
     }
     $strSql = "DELETE FROM b_mail_msg_attachment WHERE ID=" . $id;
     $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
 }
开发者ID:Satariall,项目名称:izurit,代码行数:13,代码来源:mail.php

示例13: sclear

 /**
  * Очищает текущую сессию от загруженных в нее файлов
  * 
  * @global object $DB
  * @param string $resource        Сессия загрзчика
  * @return boolean
  */
 static function sclear($resource)
 {
     global $DB;
     $sql = "SELECT file_id FROM attachedfiles WHERE session = ?  AND status IN (?l)";
     $files = $DB->rows($sql, $resource, array(uploader::STATUS_CREATE, uploader::STATUS_REMOVE));
     if ($files) {
         foreach ($files as $file) {
             $cFile = new CFile($file['file_id']);
             if ($cFile->id) {
                 $cFile->delete($file['file_id']);
             }
         }
     }
     return $DB->query("DELETE FROM attachedfiles WHERE session = ?", $resource);
 }
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:22,代码来源:uploader.php

示例14: delete

 /**
  * Deletes file and all connected data and entities (@see Sharing, @see Rights, etc).
  * @param int $deletedBy Id of user.
  * @return bool
  * @throws \Bitrix\Main\ArgumentNullException
  */
 public function delete($deletedBy)
 {
     $this->errorCollection->clear();
     $success = EditSessionTable::deleteByFilter(array('OBJECT_ID' => $this->id));
     if (!$success) {
         return false;
     }
     $success = ExternalLinkTable::deleteByFilter(array('OBJECT_ID' => $this->id));
     if (!$success) {
         return false;
     }
     foreach ($this->getSharingsAsReal() as $sharing) {
         $sharing->delete($deletedBy);
     }
     //with status unreplied, declined (not approved)
     $success = SharingTable::deleteByFilter(array('REAL_OBJECT_ID' => $this->id));
     if (!$success) {
         return false;
     }
     foreach ($this->getAttachedObjects() as $attached) {
         $attached->delete();
     }
     unset($attached);
     BizProcDocument::deleteWorkflowsFile($this->id);
     SimpleRightTable::deleteBatch(array('OBJECT_ID' => $this->id));
     $success = RightTable::deleteByFilter(array('OBJECT_ID' => $this->id));
     if (!$success) {
         return false;
     }
     $success = VersionTable::deleteByFilter(array('OBJECT_ID' => $this->id));
     if (!$success) {
         return false;
     }
     DeletedLog::addFile($this, $deletedBy, $this->errorCollection);
     \CFile::delete($this->fileId);
     $deleteResult = FileTable::delete($this->id);
     if (!$deleteResult->isSuccess()) {
         return false;
     }
     Driver::getInstance()->getIndexManager()->dropIndex($this);
     if (!$this->isLink()) {
         //todo potential - very hard operation.
         foreach (File::getModelList(array('filter' => array('REAL_OBJECT_ID' => $this->id, '!=REAL_OBJECT_ID' => $this->id))) as $link) {
             $link->delete($deletedBy);
         }
         unset($link);
     }
     $event = new Event(Driver::INTERNAL_MODULE_ID, "onAfterDeleteFile", array($this->getId(), $deletedBy));
     $event->send();
     return true;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:57,代码来源:file.php

示例15: finalize

 protected function finalize()
 {
     if (is_resource($this->m_multiCurl)) {
         curl_multi_close($this->m_multiCurl);
     }
     if (isset($this->m_cookiesFp) && CFile::exists($this->m_cookiesFp)) {
         CFile::delete($this->m_cookiesFp);
     }
     $this->m_done = true;
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:10,代码来源:CInetSession.php


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