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


PHP CFile::Delete方法代码示例

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


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

示例1: DeleteMessage

 function DeleteMessage($ID, $checkRights = "Y")
 {
     $err_mess = CTicket::err_mess() . "<br>Function: DeleteMessage<br>Line: ";
     global $DB;
     $ID = intval($ID);
     if ($ID <= 0) {
         return;
     }
     $bAdmin = "N";
     if ($checkRights == "Y") {
         $bAdmin = CTicket::IsAdmin() ? "Y" : "N";
     } else {
         $bAdmin = "Y";
     }
     if ($bAdmin == "Y") {
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tF.ID FILE_ID,\n\t\t\t\t\tM.TICKET_ID\n\t\t\t\tFROM\n\t\t\t\t\tb_ticket_message M\n\t\t\t\tLEFT JOIN b_ticket_message_2_file MF ON (MF.MESSAGE_ID = M.ID)\n\t\t\t\tLEFT JOIN b_file F ON (F.ID = MF.FILE_ID)\n\t\t\t\tWHERE\n\t\t\t\t\tM.ID='{$ID}'\n\t\t\t\t";
         $z = $DB->Query($strSql, false, $err_mess . __LINE__);
         while ($zr = $z->Fetch()) {
             $ticketID = $zr["TICKET_ID"];
             if (intval($zr["FILE_ID"]) > 0) {
                 CFile::Delete($zr["FILE_ID"]);
             }
         }
         $DB->Query("DELETE FROM b_ticket_search WHERE MESSAGE_ID = '{$ID}'", false, $err_mess . __LINE__);
         $z = $DB->Query("DELETE FROM b_ticket_message WHERE ID='{$ID}'", false, $err_mess . __LINE__);
         if (intval($z->AffectedRowsCount()) > 0) {
             CTicket::UpdateLastParams($ticketID);
             CTicket::UpdateLastParams2($ticketID, CTicket::DELETE);
         }
     }
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:support.php

示例2: __MPF_ImageResizeHandler

 function __MPF_ImageResizeHandler(&$arCustomFile, $params = array(), $result = array())
 {
     static $arParams = array();
     if (!empty($params)) {
         $arParams = $params;
     }
     static $arResult = array();
     if (!empty($result)) {
         $arResult = $result;
     }
     $fileIdForDelete = 0;
     $arFields = array();
     foreach (array("MELODY_WELCOME", "MELODY_WAIT", "MELODY_HOLD", "MELODY_VOICEMAIL") as $controlID => $inputName) {
         if ($_REQUEST["controlID"] == "voximplant" . $controlID) {
             $fileIdForDelete = $arResult["ITEM"][$inputName];
             $arFields = array($inputName => $arCustomFile["fileID"]);
             break;
         }
     }
     if (!empty($arFields)) {
         $arFile = CFile::GetFileArray($arCustomFile['fileID']);
         $arCustomFile["fileURL"] = CHTTP::URN2URI($arFile["SRC"]);
         Bitrix\Voximplant\ConfigTable::update($arParams["ID"], $arFields);
         CFile::Delete($fileIdForDelete);
     }
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:26,代码来源:result_modifier.php

示例3: UnInstallDB

 function UnInstallDB($arParams = array())
 {
     global $DB, $APPLICATION;
     $errors = false;
     if (array_key_exists("savedata", $arParams) && $arParams["savedata"] != "Y") {
         $errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/support/install/db/' . strtolower($DB->type) . '/uninstall.sql');
         if (!is_array($errors)) {
             @set_time_limit(600);
             COption::RemoveOption('support');
             $db_res = $DB->Query("SELECT ID FROM b_file WHERE MODULE_ID = 'support'");
             while ($arRes = $db_res->Fetch()) {
                 CFile::Delete($arRes['ID']);
             }
             if ($arParams['admin'] == 'Y') {
                 $this->UnInstallEvents();
             }
         }
     }
     if (is_array($errors)) {
         $APPLICATION->ThrowException(implode(' ', $errors));
         return false;
     }
     CAgent::RemoveModuleAgents('support');
     UnRegisterModuleDependences('mail', 'OnGetFilterList', 'support', 'CSupportEMail', 'OnGetFilterList');
     UnRegisterModule('support');
     return true;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:27,代码来源:index.php

示例4: UnInstallDB

 function UnInstallDB($arParams = array())
 {
     global $DB, $DBType, $APPLICATION;
     $this->errors = false;
     if (!array_key_exists("savedata", $arParams) || $arParams["savedata"] != "Y") {
         $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/install/db/" . strtolower($DB->type) . "/uninstall.sql");
     }
     //delete agents
     CAgent::RemoveModuleAgents("vote");
     $db_res = $DB->Query("SELECT ID FROM b_file WHERE MODULE_ID = 'vote'");
     while ($arRes = $db_res->Fetch()) {
         CFile::Delete($arRes["ID"]);
     }
     // Events
     include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/install/events/del_events.php";
     UnRegisterModuleDependences("im", "OnGetNotifySchema", "vote", "CVoteNotifySchema", "OnGetNotifySchema");
     UnRegisterModuleDependences("main", "OnUserLogin", "vote", "CVoteUser", "OnUserLogin", 200);
     UnRegisterModuleDependences("main", "OnUserTypeBuildList", "vote", "CUserTypeVote", "GetUserTypeDescription", 200);
     UnRegisterModuleDependences("main", "OnBeforeProlog", "main", "", "", "/modules/vote/keepvoting.php");
     UnRegisterModule("vote");
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode("<br>", $this->errors));
         return false;
     }
     return true;
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:26,代码来源:index.php

示例5: DeleteFile

 function DeleteFile($ID, $file_id = false)
 {
     global $DB;
     $rsFile = CPosting::GetFileList($ID, $file_id);
     while ($arFile = $rsFile->Fetch()) {
         $rs = $DB->Query("DELETE FROM b_posting_file where POSTING_ID=" . intval($ID) . " AND FILE_ID=" . intval($arFile["ID"]), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         CFile::Delete(intval($arFile["ID"]));
     }
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:9,代码来源:posting.php

示例6: Del

 /**
  * Удалить отзыв
  *
  * @param  int $msg ID отзыва
  * @param  int $admin Является ли пользователь администратором 1 - да, 0 - нет (типа is_admin из stdf)
  * @return array сообщение об ошибке
  */
 function Del($msg, $admin = 0)
 {
     if (!$admin) {
         return 0;
     }
     if ($ret = $GLOBALS['DB']->val("DELETE FROM sopinions WHERE (id = ?) RETURNING logo", $msg)) {
         $file = new CFile();
         $file->Delete(0, "about/opinions/", $ret);
     }
     return $DB->error;
 }
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:18,代码来源:sopinions.php

示例7: editDoc

 /**
  * Редактировать документ.
  * 
  * @param array $doc     новые данные по документу.
  * @param array $old_doc старые данные по документу.
  *
  * @return bool успешно?
  */
 public function editDoc($doc, $old_doc)
 {
     $sql_data = $doc;
     $sql_data['name'] = pg_escape_string(change_q_x($sql_data['name']));
     $act_time = self::$docs_ss[$sql_data['status']][1];
     $file_set = $doc['file_id'] ? ", file_id = {$doc['file_id']}" : '';
     $sql_data['stage_id'] = $sql_data['stage_id'] ? (int) $sql_data['stage_id'] : 'NULL';
     $sql = "\n          UPDATE sbr_docs\n             SET name = '{$sql_data['name']}',\n                 status = {$sql_data['status']},\n                 access_role = {$sql_data['access_role']},\n                 stage_id = {$sql_data['stage_id']},\n                 {$act_time} = COALESCE({$act_time}, now()),\n                 type = {$sql_data['type']}\n                 {$file_set}\n           WHERE id = {$sql_data['id']}\n        ";
     $ok = $this->_eventQuery($sql);
     if ($ok && $file_set) {
         $cfile = new CFile();
         $cfile->Delete(0, $old_doc['file_path'], $old_doc['file_name']);
     }
     return $ok;
 }
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:23,代码来源:sbr_adm.php

示例8: deleteFiles

function deleteFiles($order_id, $types)
{
    $types = !is_array($types) ? array($types) : $types;
    $rows = CFile::selectFilesBySrc('file_reserves_order', $order_id);
    if (!$rows) {
        return 0;
    }
    foreach ($rows as $row) {
        if (!in_array($row['doc_type'], $types)) {
            continue;
        }
        $file = new CFile();
        $file->Delete($row['id']);
    }
}
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:15,代码来源:docs_update.php

示例9: removeBillInvoice

/**
 * Удаление файла счета пользователя
 * 
 * @param type $invoice_id
 * @return \xajaxResponse
 */
function removeBillInvoice($invoice_id)
{
    $objResponse =& new xajaxResponse();
    $uid = get_uid(false);
    if ($uid <= 0) {
        return $objResponse;
    }
    require_once ABS_PATH . '/bill/models/BillInvoicesModel.php';
    $billInvoicesModel = new BillInvoicesModel();
    $file_id = $billInvoicesModel->getInvoiceFileId($invoice_id, $uid);
    if ($file_id) {
        $file = new CFile();
        $file->Delete($file_id);
        $objResponse->script("\n            \$('bill_invoice_remove').addClass('b-layout_hide').empty();\n            \$('bill_invoice_create').removeClass('b-layout_hide');\n        ");
    }
    return $objResponse;
}
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:23,代码来源:bill.server.php

示例10: UnInstallDB

 function UnInstallDB($arParams = array())
 {
     global $DB, $DBType, $APPLICATION;
     $this->errors = false;
     if (!array_key_exists("save_tables", $arParams) || $arParams["save_tables"] != "Y") {
         $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/subscribe/install/db/" . $DBType . "/uninstall.sql");
         $strSql = "SELECT ID FROM b_file WHERE MODULE_ID='subscribe'";
         $rsFile = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($arFile = $rsFile->Fetch()) {
             CFile::Delete($arFile["ID"]);
         }
     }
     UnRegisterModuleDependences("main", "OnBeforeLangDelete", "subscribe", "CRubric", "OnBeforeLangDelete");
     UnRegisterModuleDependences("main", "OnUserDelete", "subscribe", "CSubscription", "OnUserDelete");
     UnRegisterModuleDependences("main", "OnGroupDelete", "subscribe", "CPosting", "OnGroupDelete");
     UnRegisterModuleDependences("main", "OnUserLogout", "subscribe", "CSubscription", "OnUserLogout");
     UnRegisterModule("subscribe");
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode("<br>", $this->errors));
         return false;
     }
     return true;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:23,代码来源:index.php

示例11: clearOldSessions

 /**
  * Очистка старых сессий и удалении загруженных, но не использованых файлов.
  */
 public function clearOldSessions()
 {
     global $DB;
     $file_ids = array();
     $date = date('Y-m-d H:i:s', time() - 5 * 60 * 60);
     $cfile = new CFile();
     $cFile->table = 'file';
     $sql = 'SELECT * FROM attachedfiles WHERE date < ?';
     $res = $DB->query($sql, $date);
     while ($session = pg_fetch_assoc($res)) {
         if ($session['status'] == 1 || $session['status'] == 2) {
             $cfile->Delete($session['file_id']);
         }
     }
     $sql = 'DELETE FROM attachedfiles WHERE date < ?';
     $DB->query($sql, $date);
 }
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:20,代码来源:attachedfiles.php

示例12: delArticle

 /**
  * Удаляет статью.
  *
  * @param integer $msg   идентификатор стаьи
  * @param integer $admin можно ли удалять статью
  *
  * @return char сообщение об ошибке
  */
 public function delArticle($id, $send_warn = '')
 {
     global $DB;
     $sql = 'DELETE FROM articles_new WHERE id=? RETURNING logo, user_id, title';
     $ret = $DB->row($sql, $id);
     if ($ret) {
         $file = new CFile();
         $file->Delete($ret['logo']);
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/smail.php';
         $smail = new smail();
         $smail->delArticleSendReason($ret['user_id'], $ret['title'], $send_warn);
     }
     return $DB->error;
 }
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:22,代码来源:articles.php

示例13: Delete

 public static final function Delete($lesson_id)
 {
     global $USER_FIELD_MANAGER;
     list($lesson_id, $simulate, $check_permissions, $user_id) = self::_funcDelete_ParseOptions($lesson_id);
     if ($check_permissions) {
         $oAccess = CLearnAccess::GetInstance($user_id);
         if (!$oAccess->IsLessonAccessible($lesson_id, CLearnAccess::OP_LESSON_REMOVE)) {
             throw new LearnException('EA_ACCESS_DENIED', LearnException::EXC_ERR_ALL_ACCESS_DENIED);
         }
     }
     // Parents and childs of the lesson
     $arNeighboursEdges = self::ListImmediateNeighbours($lesson_id);
     // precache rights for lesson
     if ($check_permissions) {
         $IsLessonAccessibleFor_OP_LESSON_UNLINK_DESCENDANTS = $oAccess->IsLessonAccessible($lesson_id, CLearnAccess::OP_LESSON_UNLINK_DESCENDANTS);
         $IsLessonAccessibleFor_OP_LESSON_UNLINK_FROM_PARENTS = $oAccess->IsLessonAccessible($lesson_id, CLearnAccess::OP_LESSON_UNLINK_FROM_PARENTS);
     }
     foreach (GetModuleEvents('learning', 'OnBeforeLessonDelete', true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($lesson_id));
     }
     foreach ($arNeighboursEdges as $arEdge) {
         $child_lesson_id = (int) $arEdge['CHILD_LESSON'];
         $parent_lesson_id = (int) $arEdge['PARENT_LESSON'];
         if ($check_permissions) {
             $IsLessonAccessible = false;
             if ($child_lesson_id === $lesson_id) {
                 // if we will be remove edge to parent - use precached rights for OP_LESSON_UNLINK_FROM_PARENTS
                 $IsLessonAccessible = $IsLessonAccessibleFor_OP_LESSON_UNLINK_FROM_PARENTS && $oAccess->IsLessonAccessible($parent_lesson_id, CLearnAccess::OP_LESSON_UNLINK_DESCENDANTS);
             } elseif ($parent_lesson_id === $lesson_id) {
                 // if we will be remove edge to child - use precached rights for OP_LESSON_UNLINK_DESCENDANTS
                 $IsLessonAccessible = $IsLessonAccessibleFor_OP_LESSON_UNLINK_DESCENDANTS && $oAccess->IsLessonAccessible($child_lesson_id, CLearnAccess::OP_LESSON_UNLINK_FROM_PARENTS);
             } else {
                 throw new LearnException('EA_FATAL: $lesson_id (' . $lesson_id . ') not equal to one of: $child_lesson_id (' . $child_lesson_id . '), $parent_lesson_id (' . $parent_lesson_id . ')', LearnException::EXC_ERR_ALL_LOGIC | LearnException::EXC_ERR_ALL_GIVEUP);
             }
             if (!$IsLessonAccessible) {
                 throw new LearnException('EA_ACCESS_DENIED', LearnException::EXC_ERR_ALL_ACCESS_DENIED);
             }
             if ($simulate === false) {
                 self::RelationRemove($parent_lesson_id, $child_lesson_id);
             }
         }
     }
     $linkedCourseId = self::GetLinkedCourse($lesson_id);
     // If lesson is course, remove course
     if ($linkedCourseId !== false) {
         global $DB;
         if ($simulate === false) {
             if (!$DB->Query("DELETE FROM b_learn_course_site WHERE COURSE_ID = " . (int) $linkedCourseId, true)) {
                 throw new LearnException('EA_SQLERROR', LearnException::EXC_ERR_ALL_GIVEUP);
             }
             $rc = self::CourseBecomeLesson($linkedCourseId);
             // if course cannot be converted to lesson - don't remove lesson
             if ($rc === false) {
                 throw new LearnException('EA_OTHER: lesson is unremovable because linked course is in use.', LearnException::EXC_ERR_LL_UNREMOVABLE_CL);
             }
             // reload cache of LINKED_LESSON_ID -> COURSE_ID
             self::GetCourseToLessonMap_ReloadCache();
             if (CModule::IncludeModule("search")) {
                 CSearch::DeleteIndex("learning", false, "C" . $linkedCourseId);
                 CSearch::DeleteIndex("learning", "C" . $linkedCourseId);
             }
         }
     }
     // And remove lesson
     if ($simulate === false) {
         global $DB;
         $r = $DB->Query("SELECT PREVIEW_PICTURE, DETAIL_PICTURE \n\t\t\t\tFROM b_learn_lesson \n\t\t\t\tWHERE ID = " . (int) $lesson_id, true);
         if ($r === false) {
             throw new LearnException('EA_SQLERROR', LearnException::EXC_ERR_ALL_GIVEUP);
         }
         $arRes = $r->Fetch();
         if (!$arRes) {
             throw new LearnException('EA_SQLERROR', LearnException::EXC_ERR_ALL_GIVEUP);
         }
         CFile::Delete($arRes['PREVIEW_PICTURE']);
         CFile::Delete($arRes['DETAIL_PICTURE']);
         // Remove questions
         $q = CLQuestion::GetList(array(), array('LESSON_ID' => $lesson_id));
         while ($arQ = $q->Fetch()) {
             if (!CLQuestion::Delete($arQ['ID'])) {
                 throw new LearnException('EA_QUESTION_NOT_REMOVED', LearnException::EXC_ERR_ALL_GIVEUP);
             }
         }
         CLearnGraphNode::Remove($lesson_id);
         $USER_FIELD_MANAGER->delete('LEARNING_LESSONS', $lesson_id);
         CLearnCacheOfLessonTreeComponent::MarkAsDirty();
         CEventLog::add(array('AUDIT_TYPE_ID' => 'LEARNING_REMOVE_ITEM', 'MODULE_ID' => 'learning', 'ITEM_ID' => 'L #' . $lesson_id, 'DESCRIPTION' => 'lesson removed'));
         if (CModule::IncludeModule('search')) {
             CSearch::DeleteIndex('learning', false, 'L' . $lesson_id);
             CSearch::DeleteIndex('learning', 'L' . $lesson_id);
         }
     }
     if ($simulate === false) {
         foreach (GetModuleEvents('learning', 'OnAfterLessonDelete', true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($lesson_id));
         }
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:98,代码来源:clearnlesson.php

示例14: Delete

 function Delete($ID, $CHECK_RIGHTS = "Y")
 {
     global $DB, $strError;
     $err_mess = CAllForm::err_mess() . "<br>Function: Delete<br>Line: ";
     $ID = intval($ID);
     if ($CHECK_RIGHTS != "Y" || CForm::IsAdmin()) {
         // delete form results
         if (CForm::Reset($ID, "N")) {
             // delete temporary template
             $tmp_filename = $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/tmp/form/form_" . $ID . ".php";
             if (file_exists($tmp_filename)) {
                 @unlink($tmp_filename);
             }
             // delete form statuses
             $rsStatuses = CFormStatus::GetList($ID, $by, $order, $arFilter, $is_filtered);
             while ($arStatus = $rsStatuses->Fetch()) {
                 CFormStatus::Delete($arStatus["ID"], "N");
             }
             // delete from fields & questions
             $rsFields = CFormField::GetList($ID, "ALL", $by, $order, array(), $is_filtered);
             while ($arField = $rsFields->Fetch()) {
                 CFormField::Delete($arField["ID"], "N");
             }
             // delete form image
             $strSql = "SELECT IMAGE_ID FROM b_form WHERE ID='{$ID}' and IMAGE_ID>0";
             $z = $DB->Query($strSql, false, $err_mess . __LINE__);
             while ($zr = $z->Fetch()) {
                 CFile::Delete($zr["IMAGE_ID"]);
             }
             // delete mail event type and mail templates, assigned to the current form
             $q = CForm::GetByID($ID);
             $qr = $q->Fetch();
             if (strlen(trim($qr["MAIL_EVENT_TYPE"])) > 0) {
                 // delete mail templates
                 $em = new CEventMessage();
                 $e = $em->GetList($by = "id", $order = "desc", array("EVENT_NAME" => $qr["MAIL_EVENT_TYPE"], "EVENT_NAME_EXACT_MATCH" => "Y"));
                 while ($er = $e->Fetch()) {
                     $em->Delete($er["ID"]);
                 }
                 // delete mail event type
                 $et = new CEventType();
                 $et->Delete($qr["MAIL_EVENT_TYPE"]);
             }
             // delete site assignment
             $DB->Query("DELETE FROM b_form_2_site WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__);
             // delete mail templates assignment
             $DB->Query("DELETE FROM b_form_2_mail_template WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__);
             // delete form menu
             $DB->Query("DELETE FROM b_form_menu WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__);
             // delete from rights
             $DB->Query("DELETE FROM b_form_2_group WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__);
             // and finally delete form
             $DB->Query("DELETE FROM b_form WHERE ID='{$ID}'", false, $err_mess . __LINE__);
             return true;
         }
     } else {
         $strError .= GetMessage("FORM_ERROR_ACCESS_DENIED") . "<br>";
     }
     return false;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:60,代码来源:form_callform.php

示例15: DeleteFile

 function DeleteFile($FILE_ID, $ELEMENT_ID, $TYPE = false, $PARENT_ID = -1, $IBLOCK_ID = false, $bCheckOnly = false)
 {
     global $DB;
     $FILE_ID = intval($FILE_ID);
     if ($FILE_ID <= 0) {
         return;
     }
     if ($ELEMENT_ID !== false) {
         //ELEMENT_ID may be false when we are going to check for a valid file from CheckFields
         $ELEMENT_ID = intval($ELEMENT_ID);
         if ($ELEMENT_ID <= 0) {
             return;
         }
     }
     $IBLOCK_ID = intval($IBLOCK_ID);
     if ($IBLOCK_ID <= 0 || $PARENT_ID === -1) {
         if ($ELEMENT_ID === false) {
             return;
         }
         //This is an error in API call
         $rsElement = $DB->Query("SELECT IBLOCK_ID, WF_PARENT_ELEMENT_ID from b_iblock_element WHERE ID = " . $ELEMENT_ID);
         $arElement = $rsElement->Fetch();
         if (!$arElement) {
             return;
         }
         $IBLOCK_ID = $arElement["IBLOCK_ID"];
         $PARENT_ID = $arElement["WF_PARENT_ELEMENT_ID"];
     }
     if ($TYPE === false) {
         $CNT = CIBlockElement::DeleteFile($FILE_ID, $ELEMENT_ID, "PREVIEW", $PARENT_ID, $IBLOCK_ID);
         $CNT += CIBlockElement::DeleteFile($FILE_ID, $ELEMENT_ID, "DETAIL", $PARENT_ID, $IBLOCK_ID);
         $CNT += CIBlockElement::DeleteFile($FILE_ID, $ELEMENT_ID, "PROPERTY", $PARENT_ID, $IBLOCK_ID);
         return $CNT;
     }
     $VERSION = CIBlockElement::GetIBVersion($IBLOCK_ID);
     $arProps = array();
     if ($TYPE === "PROPERTY" && $VERSION == 2) {
         $strSQL = "\n\t\t\t\tSELECT P.ID\n\t\t\t\tFROM\n\t\t\t\tb_iblock_property P\n\t\t\t\tWHERE P.IBLOCK_ID = " . $IBLOCK_ID . "\n\t\t\t\tAND P.PROPERTY_TYPE = 'F'\n\t\t\t\tAND P.MULTIPLE = 'N'\n\t\t\t";
         $rs = $DB->Query($strSQL);
         while ($ar = $rs->Fetch()) {
             $arProps[] = " V.PROPERTY_" . intval($ar["ID"]) . " = " . $FILE_ID;
         }
     }
     if ($ELEMENT_ID === false) {
         //It is new historical record so we'' check original
         //and all over history already there
         $arWhere = array("E.ID=" . intval($PARENT_ID), "E.WF_PARENT_ELEMENT_ID=" . intval($PARENT_ID));
     } elseif (intval($PARENT_ID)) {
         //It's an historical record so we will check original
         // and all history except deleted one
         $arWhere = array("E.ID=" . intval($PARENT_ID), "E.WF_PARENT_ELEMENT_ID=" . intval($PARENT_ID) . " AND E.ID <> " . $ELEMENT_ID);
     } else {
         //It is an original so we have to check only history
         //all history copies
         $arWhere = array("E.WF_PARENT_ELEMENT_ID=" . $ELEMENT_ID);
     }
     $CNT = 0;
     foreach ($arWhere as $strWhere) {
         if ($TYPE === "PREVIEW") {
             $strSQL = "\n\t\t\t\t\tSELECT COUNT(1) CNT\n\t\t\t\t\tfrom b_iblock_element E\n\t\t\t\t\tWHERE " . $strWhere . "\n\t\t\t\t\tAND PREVIEW_PICTURE = " . $FILE_ID . "\n\t\t\t\t";
         } elseif ($TYPE === "DETAIL") {
             $strSQL = "\n\t\t\t\t\tSELECT COUNT(1) CNT\n\t\t\t\t\tfrom b_iblock_element E\n\t\t\t\t\tWHERE " . $strWhere . "\n\t\t\t\t\tAND DETAIL_PICTURE = " . $FILE_ID . "\n\t\t\t\t";
         } elseif ($TYPE === "PROPERTY") {
             if ($VERSION == 2) {
                 $strSQL = "\n\t\t\t\t\t\tSELECT COUNT(1) CNT\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tb_iblock_element E\n\t\t\t\t\t\t\t,b_iblock_property P\n\t\t\t\t\t\t\t,b_iblock_element_prop_m" . $IBLOCK_ID . " V\n\t\t\t\t\t\tWHERE " . $strWhere . "\n\t\t\t\t\t\tAND E.IBLOCK_ID = " . $IBLOCK_ID . "\n\t\t\t\t\t\tAND P.IBLOCK_ID = E.IBLOCK_ID\n\t\t\t\t\t\tAND P.PROPERTY_TYPE = 'F'\n\t\t\t\t\t\tAND V.IBLOCK_ELEMENT_ID = E.ID\n\t\t\t\t\t\tAND V.IBLOCK_PROPERTY_ID = P.ID\n\t\t\t\t\t\tAND V.VALUE_NUM = " . $FILE_ID . "\n\t\t\t\t\t";
             } else {
                 $strSQL = "\n\t\t\t\t\t\tSELECT COUNT(1) CNT\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tb_iblock_element E\n\t\t\t\t\t\t\t,b_iblock_property P\n\t\t\t\t\t\t\t,b_iblock_element_property V\n\t\t\t\t\t\tWHERE " . $strWhere . "\n\t\t\t\t\t\tAND E.IBLOCK_ID = " . $IBLOCK_ID . "\n\t\t\t\t\t\tAND P.IBLOCK_ID = E.IBLOCK_ID\n\t\t\t\t\t\tAND P.PROPERTY_TYPE = 'F'\n\t\t\t\t\t\tAND V.IBLOCK_ELEMENT_ID = E.ID\n\t\t\t\t\t\tAND V.IBLOCK_PROPERTY_ID = P.ID\n\t\t\t\t\t\tAND V.VALUE_NUM = " . $FILE_ID . "\n\t\t\t\t\t";
             }
         }
         $rs = $DB->Query($strSQL);
         $ar = $rs->Fetch();
         $CNT += intval($ar["CNT"]);
         if ($CNT > 0) {
             return $CNT;
         }
         //Check VERSION 2 SINGLE PROPERTIES
         if (count($arProps) > 0) {
             //This SQL potentially wrong
             //in case when file may be saved in
             //different properties
             $strSQL = "\n\t\t\t\t\tSELECT COUNT(1) CNT\n\t\t\t\t\tFROM\n\t\t\t\t\t\tb_iblock_element E\n\t\t\t\t\t\t,b_iblock_property P\n\t\t\t\t\t\t,b_iblock_element_prop_s" . $IBLOCK_ID . " V\n\t\t\t\t\tWHERE " . $strWhere . "\n\t\t\t\t\tAND E.IBLOCK_ID = " . $IBLOCK_ID . "\n\t\t\t\t\tAND P.IBLOCK_ID = E.IBLOCK_ID\n\t\t\t\t\tAND P.PROPERTY_TYPE = 'F'\n\t\t\t\t\tAND V.IBLOCK_ELEMENT_ID = E.ID\n\t\t\t\t\tAND (" . implode(" OR ", $arProps) . ")\n\t\t\t\t";
             $rs = $DB->Query($strSQL);
             $ar = $rs->Fetch();
             $CNT += intval($ar["CNT"]);
             if ($CNT > 0) {
                 return $CNT;
             }
         }
     }
     if ($bCheckOnly) {
         return $CNT;
     } elseif ($CNT === 0) {
         CFile::Delete($FILE_ID);
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:95,代码来源:iblockelement.php


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