Esempio n. 1
0
 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);
         }
     }
 }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 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"]));
     }
 }
Esempio n. 6
0
 /**
  * Удалить отзыв
  *
  * @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;
 }
Esempio n. 7
0
 /**
  * Редактировать документ.
  * 
  * @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;
 }
Esempio n. 8
0
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']);
    }
}
Esempio n. 9
0
/**
 * Удаление файла счета пользователя
 * 
 * @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;
}
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
 /**
  * Очистка старых сессий и удалении загруженных, но не использованых файлов.
  */
 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);
 }
Esempio n. 12
0
 /**
  * Удаляет статью.
  *
  * @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;
 }
Esempio n. 13
0
 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));
         }
     }
 }
Esempio n. 14
0
 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;
 }
Esempio n. 15
0
 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);
     }
 }
Esempio n. 16
0
 function Delete($ID)
 {
     global $DB;
     $ID = IntVal($ID);
     $arPost = CBlogPost::GetByID($ID);
     if ($arPost) {
         $db_events = GetModuleEvents("blog", "OnBeforePostDelete");
         while ($arEvent = $db_events->Fetch()) {
             if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
                 return false;
             }
         }
         $dbResult = CBlogComment::GetList(array(), array("POST_ID" => $ID), false, false, array("ID"));
         while ($arResult = $dbResult->Fetch()) {
             if (!CBlogComment::Delete($arResult["ID"])) {
                 return False;
             }
         }
         $dbResult = CBlogUserGroupPerms::GetList(array(), array("POST_ID" => $ID, "BLOG_ID" => $arPost["BLOG_ID"]), false, false, array("ID"));
         while ($arResult = $dbResult->Fetch()) {
             if (!CBlogUserGroupPerms::Delete($arResult["ID"])) {
                 return False;
             }
         }
         $dbResult = CBlogTrackback::GetList(array(), array("POST_ID" => $ID, "BLOG_ID" => $arPost["BLOG_ID"]), false, false, array("ID"));
         while ($arResult = $dbResult->Fetch()) {
             if (!CBlogTrackback::Delete($arResult["ID"])) {
                 return False;
             }
         }
         $dbResult = CBlogPostCategory::GetList(array(), array("POST_ID" => $ID, "BLOG_ID" => $arPost["BLOG_ID"]), false, false, array("ID"));
         while ($arResult = $dbResult->Fetch()) {
             if (!CBlogPostCategory::Delete($arResult["ID"])) {
                 return False;
             }
         }
         $strSql = "SELECT F.ID " . "FROM b_blog_post P, b_file F " . "WHERE P.ID = " . $ID . " " . "\tAND P.ATTACH_IMG = F.ID ";
         $z = $DB->Query($strSql, false, "FILE: " . __FILE__ . " LINE:" . __LINE__);
         while ($zr = $z->Fetch()) {
             CFile::Delete($zr["ID"]);
         }
         unset($GLOBALS["BLOG_POST"]["BLOG_POST_CACHE_" . $ID]);
         $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
         $result = $DB->Query("DELETE FROM b_blog_post WHERE ID = " . $ID . "", true);
         if (IntVal($arBlog["LAST_POST_ID"]) == $ID) {
             CBlog::SetStat($arPost["BLOG_ID"]);
         }
         if ($result) {
             $res = CBlogImage::GetList(array(), array("POST_ID" => $ID, "IS_COMMENT" => "N"));
             while ($aImg = $res->Fetch()) {
                 CBlogImage::Delete($aImg['ID']);
             }
         }
         if ($result) {
             $GLOBALS["USER_FIELD_MANAGER"]->Delete("BLOG_POST", $ID);
         }
         $db_events = GetModuleEvents("blog", "OnPostDelete");
         while ($arEvent = $db_events->Fetch()) {
             ExecuteModuleEventEx($arEvent, array($ID, &$result));
         }
         if (CModule::IncludeModule("search")) {
             CSearch::Index("blog", "P" . $ID, array("TITLE" => "", "BODY" => ""));
             //CSearch::DeleteIndex("blog", false, "COMMENT", $arPost["BLOG_ID"]."|".$ID);
         }
         return $result;
     } else {
         return false;
     }
     return True;
 }
Esempio n. 17
0
 function Delete($BANNER_ID, $CHECK_RIGHTS = "Y")
 {
     $err_mess = CAdvBanner_all::err_mess() . "<br>Function: Delete<br>Line: ";
     global $DB, $strError;
     $BANNER_ID = intval($BANNER_ID);
     if ($BANNER_ID <= 0) {
         return false;
     }
     $strSql = "SELECT CONTRACT_ID, IMAGE_ID FROM b_adv_banner WHERE ID = '{$BANNER_ID}'";
     $rsBanner = $DB->Query($strSql, false, $err_mess . __LINE__);
     if ($arBanner = $rsBanner->Fetch()) {
         $ok = false;
         if ($CHECK_RIGHTS == "Y") {
             $arrPERM = CAdvContract::GetUserPermissions($arBanner["CONTRACT_ID"]);
             $arrPERM = $arrPERM[$arBanner["CONTRACT_ID"]];
             if (in_array("ADD", $arrPERM)) {
                 $ok = true;
             }
         } else {
             $ok = true;
         }
         if ($ok) {
             CFile::Delete($arBanner["IMAGE_ID"]);
             CAdvBanner::DeleteCountryLink($BANNER_ID);
             CAdvBanner::DeleteSiteLink($BANNER_ID);
             CAdvBanner::DeleteStatAdvLink($BANNER_ID);
             CAdvBanner::DeletePageLink($BANNER_ID);
             CAdvBanner::DeleteWeekdayLink($BANNER_ID);
             CAdvBanner::DeleteGroupLink($BANNER_ID);
             $strSql = "DELETE FROM b_adv_banner_2_day WHERE BANNER_ID = {$BANNER_ID}";
             $DB->Query($strSql, false, $err_mess . __LINE__);
             $strSql = "DELETE FROM b_adv_banner WHERE ID = {$BANNER_ID}";
             $DB->Query($strSql, false, $err_mess . __LINE__);
             return true;
         } else {
             $strError .= GetMessage("AD_ERROR_NOT_ENOUGH_PERMISSIONS_BANNER") . "<br>";
         }
     }
     return false;
 }
Esempio n. 18
0
 function UnInstallFiles($arParams = array())
 {
     global $DB;
     if (array_key_exists("savedata", $arParams) && $arParams["savedata"] != "Y") {
         // delete all images
         $db_res = $DB->Query("SELECT ID FROM b_file WHERE MODULE_ID = 'form'");
         while ($arRes = $db_res->Fetch()) {
             CFile::Delete($arRes["ID"]);
         }
     }
     // Delete files
     DeleteDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/form/install/admin/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/admin");
     DeleteDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/form/install/themes/.default/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/themes/.default");
     //css
     DeleteDirFilesEx("/bitrix/themes/.default/icons/form/");
     //icons
     DeleteDirFilesEx("/bitrix/images/form/");
     //images
     DeleteDirFilesEx("/bitrix/js/form/");
     //javascript
     DeleteDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/form/install/tools/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/tools/");
     // delete temporary template files - for old template system
     DeleteDirFilesEx(BX_PERSONAL_ROOT . "/tmp/form/");
     return true;
 }
Esempio n. 19
0
 /**
  * <p>Метод удаляет свойство и все его значения. Метод статический.</p>
  *
  *
  * @param int $ID  Код свойства.
  *
  * @return bool <p>В случае успешного удаления возвращается true, иначе - false. </p> <br><br>
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblockproperty/delete.php
  * @author Bitrix
  */
 public static function Delete($ID)
 {
     /** @var CMain $APPLICATION */
     global $DB, $APPLICATION;
     $ID = IntVal($ID);
     $APPLICATION->ResetException();
     foreach (GetModuleEvents("iblock", "OnBeforeIBlockPropertyDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
             $err = GetMessage("MAIN_BEFORE_DEL_ERR") . ' ' . $arEvent['TO_NAME'];
             if ($ex = $APPLICATION->GetException()) {
                 $err .= ': ' . $ex->GetString();
             }
             $APPLICATION->throwException($err);
             return false;
         }
     }
     foreach (GetModuleEvents("iblock", "OnIBlockPropertyDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     if (!CIBlockPropertyEnum::DeleteByPropertyID($ID, true)) {
         return false;
     }
     CIBlockSectionPropertyLink::DeleteByProperty($ID);
     $rsProperty = CIBlockProperty::GetByID($ID);
     $arProperty = $rsProperty->Fetch();
     if ($arProperty["VERSION"] == 2) {
         if ($arProperty["PROPERTY_TYPE"] == "F") {
             if ($arProperty["MULTIPLE"] == "Y") {
                 $strSql = "\n\t\t\t\t\t\tSELECT\tVALUE\n\t\t\t\t\t\tFROM\tb_iblock_element_prop_m" . $arProperty["IBLOCK_ID"] . "\n\t\t\t\t\t\tWHERE\tIBLOCK_PROPERTY_ID=" . $ID . "\n\t\t\t\t\t";
             } else {
                 $strSql = "\n\t\t\t\t\t\tSELECT\tPROPERTY_" . $ID . " VALUE\n\t\t\t\t\t\tFROM\tb_iblock_element_prop_s" . $arProperty["IBLOCK_ID"] . "\n\t\t\t\t\t\tWHERE\tPROPERTY_" . $ID . " is not null\n\t\t\t\t\t";
             }
             $res = $DB->Query($strSql);
             while ($arr = $res->Fetch()) {
                 CFile::Delete($arr["VALUE"]);
             }
         }
         if (!$DB->Query("DELETE FROM b_iblock_section_element WHERE ADDITIONAL_PROPERTY_ID=" . $ID, true)) {
             return false;
         }
         $strSql = "\n\t\t\t\tDELETE\n\t\t\t\tFROM b_iblock_element_prop_m" . $arProperty["IBLOCK_ID"] . "\n\t\t\t\tWHERE IBLOCK_PROPERTY_ID=" . $ID . "\n\t\t\t";
         if (!$DB->Query($strSql)) {
             return false;
         }
         $arSql = CIBlockProperty::DropColumnSQL("b_iblock_element_prop_s" . $arProperty["IBLOCK_ID"], array("PROPERTY_" . $ID, "DESCRIPTION_" . $ID));
         foreach ($arSql as $strSql) {
             if (!$DB->DDL($strSql)) {
                 return false;
             }
         }
     } else {
         $res = $DB->Query("SELECT EP.VALUE FROM b_iblock_property P, b_iblock_element_property EP WHERE P.ID=" . $ID . " AND P.ID=EP.IBLOCK_PROPERTY_ID AND P.PROPERTY_TYPE='F'");
         while ($arr = $res->Fetch()) {
             CFile::Delete($arr["VALUE"]);
         }
         if (!$DB->Query("DELETE FROM b_iblock_section_element WHERE ADDITIONAL_PROPERTY_ID=" . $ID, true)) {
             return false;
         }
         if (!$DB->Query("DELETE FROM b_iblock_element_property WHERE IBLOCK_PROPERTY_ID=" . $ID, true)) {
             return false;
         }
     }
     $seq = new CIBlockSequence($arProperty["IBLOCK_ID"], $ID);
     $seq->Drop();
     return $DB->Query("DELETE FROM b_iblock_property WHERE ID=" . $ID, true);
 }
Esempio n. 20
0
 /**
  * Удаление рассылки
  *
  * @param    integer $id идентификатор рассылки
  */
 function DeleteMail($id)
 {
     global $DB;
     $sql = "SELECT attaches,user_id FROM contacts_mails WHERE id=?i";
     $mail = $DB->row($sql, $id);
     $user = new users();
     $user->GetUser($user->GetField($mail['user_id'], $ee, 'login'));
     $m_files = preg_split("/,/", $mail['attaches']);
     if ($m_files) {
         foreach ($m_files as $a) {
             $f = new CFile();
             $f->Delete(0, $user->login . '/', $a);
         }
     }
     $sql = "DELETE FROM contacts_mails WHERE id=?i";
     $DB->query($sql, $id);
 }
Esempio n. 21
0
 function Delete($ticketID, $checkRights = "Y")
 {
     $err_mess = CAllTicket::err_mess() . "<br>Function: Delete<br>Line: ";
     global $DB, $USER;
     $ticketID = intval($ticketID);
     if ($ticketID <= 0) {
         return;
     }
     $bAdmin = "N";
     if ($checkRights == "Y") {
         $bAdmin = CTicket::IsAdmin() ? "Y" : "N";
     } else {
         $bAdmin = "Y";
     }
     if ($bAdmin == "Y") {
         if (CTicket::ExecuteEvents('OnBeforeTicketDelete', $ticketID, false) === false) {
             return false;
         }
         CTicket::ExecuteEvents('OnTicketDelete', $ticketID, false);
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tF.ID\n\t\t\t\tFROM\n\t\t\t\t\tb_ticket_message_2_file MF,\n\t\t\t\t\tb_file F\n\t\t\t\tWHERE\n\t\t\t\t\tMF.TICKET_ID = '{$ticketID}'\n\t\t\t\tand F.ID=MF.FILE_ID\n\t\t\t\t";
         $z = $DB->Query($strSql, false, $err_mess . __LINE__);
         while ($zr = $z->Fetch()) {
             CFile::Delete($zr["ID"]);
         }
         //CTicketReminder::Delete($ticketID);
         $DB->Query("DELETE FROM b_ticket_message_2_file WHERE TICKET_ID='{$ticketID}'", false, $err_mess . __LINE__);
         $DB->Query("DELETE FROM b_ticket_message WHERE TICKET_ID='{$ticketID}'", false, $err_mess . __LINE__);
         $GLOBALS["USER_FIELD_MANAGER"]->Delete("SUPPORT", $ticketID);
         $DB->Query("DELETE FROM b_ticket WHERE ID='{$ticketID}'", false, $err_mess . __LINE__);
         if (CSupportSearch::isIndexExists()) {
             CSupportSearch::reindexTicket($ticketID);
         }
     }
 }
Esempio n. 22
0
 $v1 = "v2:" . serialize(array("DESCRIPTION" => $arResult["Data"]["Description"], "FILTERABLE_FIELDS" => $arResult["Data"]["FilterableFields"], "VISIBLE_FIELDS" => $arResult["Data"]["VisibleFields"], "COMPONENT_TEMPLATES" => $arResult["Data"]["ComponentTemplates"]));
 $arFields = array("IBLOCK_TYPE_ID" => $arParams["IBLOCK_TYPE"], "LID" => SITE_ID, "NAME" => $arResult["Data"]["Name"], "ACTIVE" => 'Y', "SORT" => $arResult["Data"]["Sort"], "PICTURE" => intval($arResult["Data"]["Image"]) > 0 ? CFile::MakeFileArray($arResult["Data"]["Image"]) : false, "DESCRIPTION" => $v1, "DESCRIPTION_TYPE" => 'text', "WORKFLOW" => 'N', "BIZPROC" => 'Y', "VERSION" => 1, "ELEMENT_ADD" => $arResult["Data"]["ElementAdd"]);
 foreach ($arResult["Data"]["UserGroups"] as $v) {
     $arFields["GROUP_ID"][$v] = "R";
 }
 if ($arParams["BLOCK_ID"] <= 0) {
     $opRes = $iblockId = $ib->Add($arFields);
 } else {
     $opRes = $ib->Update($arParams["BLOCK_ID"], $arFields);
     $iblockId = $arParams["BLOCK_ID"];
 }
 if ($opRes) {
     global $CACHE_MANAGER;
     $CACHE_MANAGER->Clean("component_bizproc_wizards_templates");
     if (intval($arResult["Data"]["Image"]) > 0) {
         CFile::Delete($arResult["Data"]["Image"]);
     }
     if ($arParams["BLOCK_ID"] <= 0 && strlen($arResult["Data"]["Template"]) > 0) {
         $arVariables = false;
         if (method_exists($bpTemplateObject, "GetVariables")) {
             $arVariables = $bpTemplateObject->GetVariables();
             $ks = array_keys($arVariables);
             foreach ($ks as $k) {
                 $arVariables[$k]["Default"] = $arResult["Data"]["TemplateVariables"][$k];
             }
         }
         $arFieldsT = array("DOCUMENT_TYPE" => array("bizproc", "CBPVirtualDocument", "type_" . $iblockId), "AUTO_EXECUTE" => CBPDocumentEventType::Create, "NAME" => $arResult["Data"]["Name"], "DESCRIPTION" => $arResult["Data"]["Description"], "TEMPLATE" => $bpTemplateObject->GetTemplate(), "PARAMETERS" => $bpTemplateObject->GetParameters(), "VARIABLES" => $arVariables, "USER_ID" => $GLOBALS["USER"]->GetID(), "ACTIVE" => 'Y', "MODIFIER_USER" => new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser));
         CBPWorkflowTemplateLoader::Add($arFieldsT);
         if (method_exists($bpTemplateObject, "GetDocumentFields")) {
             $runtime = CBPRuntime::GetRuntime();
             $runtime->StartRuntime();
Esempio n. 23
0
 public static function Remove($id)
 {
     global $DB;
     if (!is_numeric($id)) {
         throw new LearnException('EA_PARAMS', LearnException::EXC_ERR_GN_REMOVE);
     }
     $lessonData = self::GetByID($id);
     if (!array_key_exists('NAME', $lessonData)) {
         throw new LearnException('EA_NOT_EXISTS', LearnException::EXC_ERR_GN_REMOVE);
     }
     // Remove pictures
     if (array_key_exists('PREVIEW_PICTURE', $lessonData) && $lessonData['PREVIEW_PICTURE'] > 0) {
         CFile::Delete($lessonData['PREVIEW_PICTURE']);
     }
     if (array_key_exists('DETAIL_PICTURE', $lessonData) && $lessonData['DETAIL_PICTURE'] > 0) {
         CFile::Delete($lessonData['DETAIL_PICTURE']);
     }
     // Remove SCORM data
     if (array_key_exists('SCORM', $lessonData) && $lessonData['SCORM'] === 'Y') {
         DeleteDirFilesEx("/" . COption::GetOptionString("main", "upload_dir", "upload") . "/learning/scorm/" . $id);
     }
     // Remove graph node
     $rc = $DB->Query("DELETE FROM b_learn_lesson\n\t\t\tWHERE ID = '" . ($id + 0) . "'", true);
     if ($rc === false) {
         throw new LearnException('EA_SQLERROR', LearnException::EXC_ERR_GN_REMOVE);
     }
     if ($rc->AffectedRowsCount() == 0) {
         throw new LearnException('EA_NOT_EXISTS', LearnException::EXC_ERR_GN_REMOVE);
     }
 }
Esempio n. 24
0
    public static function DeleteEmpty()
    {
        global $DB;
        $strSql = 'SELECT MI.*,MCI.COLLECTION_ID
			FROM b_medialib_item MI
			LEFT JOIN b_medialib_collection_item MCI ON (MI.ID=MCI.ITEM_ID)
			WHERE MCI.COLLECTION_ID is null';
        $res = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
        $strItems = "0";
        while ($arRes = $res->Fetch()) {
            $strItems .= "," . IntVal($arRes['ID']);
            if ($arRes['SOURCE_ID'] > 0) {
                // Clean from 'b_file'
                CFile::Delete(IntVal($arRes['SOURCE_ID']));
            }
        }
        // Clean from 'b_medialib_item'
        if ($strItems != "0") {
            $DB->Query("DELETE FROM b_medialib_item WHERE ID in (" . $strItems . ")", false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
        }
    }
Esempio n. 25
0
, <?php 
                echo intval($_POST["uniqueID"]);
                ?>
);
					</script>
				<?php 
            } elseif ($_POST["mode"] == "delete") {
                if ($report) {
                    $arFiles = unserialize($report["FILES"]);
                } else {
                    $arFiles = $_SESSION['report_files'];
                }
                if (is_array($arFiles)) {
                    foreach ($arFiles as $key => $file) {
                        if ($file["fileID"] == $_POST["fileID"]) {
                            CFile::Delete(intval($_POST["fileID"]));
                            unset($arFiles[$key]);
                            if (isset($_SESSION['report_files'])) {
                                unset($_SESSION['report_files'][$key]);
                                $_SESSION['report_files'] = array_values($_SESSION['report_files']);
                            }
                            if ($report) {
                                CTimeManReportFull::Update($report["ID"], array("FILES" => array_values($arFiles)));
                            }
                            break;
                        }
                    }
                }
            }
        } elseif ($action == "get_attachment") {
            $result['FILE'] = null;
/**
 * Сохранение профиля юзера
 * 
 * @param object $objResponse xajaxResponse
 * @param string $rec_id идентификатор записи
 * @param string $rec_type тип записи
 * @param array $aForm массив данных
 * @param string $sDrawFunc имя функции для выполнения после сохранения
 */
function _admEditProfileSaveForm(&$objResponse, $rec_id = '', $rec_type = '', $aForm = array(), $sDrawFunc = '')
{
    $error = '';
    $bNew = true;
    setlocale(LC_ALL, 'ru_RU.CP1251');
    switch ($aForm['p_ucolumn']) {
        case 'uname':
            $new_val = change_q(substr(trim($aForm['new_val']), 0, 21), true);
            if (!preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $new_val)) {
                $error = 'Поле заполнено некорректно';
            }
            break;
        case 'usurname':
            $new_val = change_q(substr(trim($aForm['new_val']), 0, 21), true);
            if (!preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $new_val)) {
                $error = 'Поле заполнено некорректно';
            }
            break;
        case 'pname':
            $new_val = change_q(substr(trim(stripslashes($aForm['new_val'])), 0, 100), true);
            break;
        case 'spec_text':
            $ab_text_max_length = 500;
            $new_val = stripslashes(trim($aForm['new_val']));
            $new_val = preg_replace("|[\t]+|", " ", $new_val);
            $new_val = preg_replace("|[ ]+|", " ", $new_val);
            $original_text = $new_val;
            $newlines = intval(substr_count($new_val, "\r"));
            $new_val = change_q_x_a(substr($new_val, 0, $ab_text_max_length + $newlines), false, false, "b|i|p|ul|li{1}");
            if (strlen($original_text) > $ab_text_max_length + $newlines) {
                $error = 'Допустимо максимум ' . $ab_text_max_length . ' знаков.';
            }
            break;
        case 'resume_file':
        case 'photo':
        case 'logo':
            $del_file = intval($aForm['del_file']);
            $dir = $aForm['login'];
            $dir2 = $aForm['p_ucolumn'] == 'resume_file' ? 'resume' : ($aForm['p_ucolumn'] == 'photo' ? 'foto' : 'logo');
            if ($del_file || $aForm['new_val']) {
                $new_val = $del_file ? '' : substr(change_q_new(trim(stripslashes($aForm['new_val']))), 0, 1500);
                if ($aForm['old_val']) {
                    $oCFile = new CFile();
                    $oCFile->Delete(0, 'users/' . substr($dir, 0, 2) . '/' . $dir . '/' . $dir2 . '/', $aForm['old_val']);
                    if ($aForm['p_ucolumn'] == 'photo' || $aForm['p_ucolumn'] == 'logo') {
                        $oCFile->Delete(0, 'users/' . substr($dir, 0, 2) . '/' . $dir . '/' . $dir2 . '/', 'sm_' . $aForm['old_val']);
                    }
                }
            } else {
                // админ нажал "Сохранить" не зааплоадив файл - считаем что утвердил тот что есть
                $bNew = false;
            }
            break;
        case 'resume':
            $new_val = str_replace("\r\n", "\r", $aForm['new_val']);
            if (strlen($new_val) > 4000) {
                $error = 'Допустимо максимум 4000 знаков.';
            }
            $new_val = change_q(substr(trim($new_val), 0, 4000), false, 25);
            break;
        case 'konk':
            if (strlen($aForm['new_val']) > 4000) {
                $error = 'Допустимо максимум 4000 знаков.';
            }
            $new_val = change_q(substr(trim($aForm['new_val']), 0, 4000), false, 90);
            break;
        case 'company':
            if (strlen($aForm['new_val']) > 500) {
                $error = 'Допустимо максимум 500 знаков.';
            }
            $new_val = substr(change_q_x($aForm['new_val'], false, true, null, false, false), 0, 500);
            break;
        case 'status_text':
            $new_val = addslashes(substr(stripslashes(trim($aForm['new_val'])), 0, 200));
            close_tags($new_val, 's');
            $new_val = htmlspecialchars(htmlspecialchars_decode(change_q_x(trim($new_val), true, false), ENT_QUOTES), ENT_QUOTES);
            break;
        case 'compname':
            $new_val = change_q_x($aForm['new_val'], true);
            break;
        default:
            setlocale(LC_ALL, 'en_US.UTF-8');
            return false;
            break;
    }
    setlocale(LC_ALL, 'en_US.UTF-8');
    if (!$error) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/messages.php';
        if ($bNew) {
            $sReason = _parseReason($rec_id, $aForm['adm_edit_text']);
            messages::profileModifiedNotification($rec_id, $aForm['p_ucolumn'], $aForm['p_utable'], $sReason);
            if ($sDrawFunc == 'stream0' || $sDrawFunc == 'stream1' || $sDrawFunc == 'stream2') {
                user_content::editProfile($aForm['p_change_id'], $new_val);
            }
        }
        $objResponse->script('adm_edit_content.cancel();');
        if ($sDrawFunc == 'stream0' || $sDrawFunc == 'stream1' || $sDrawFunc == 'stream2') {
            $objResponse->script('parent.adm_edit_content.cancel();');
            resolveContent($aForm['p_content_id'], $aForm['p_stream_id'], user_content::MODER_PROFILE . '_' . $aForm['p_change_id'] . '_0', 1, $rec_id, $aForm['p_content_cnt'], $aForm['p_status'], $aForm['p_is_sent'], '', $objResponse);
        } else {
            // действие после редактирования по умолчанию
            if ($bNew) {
                require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/' . $aForm['p_utable'] . '.php';
                $user = new $aForm['p_utable']();
                $user->{$aForm}['p_ucolumn'] = $new_val;
                $user->moduser_id = $_SESSION['uid'];
                $user->Update($rec_id, $res);
            }
            if ($sDrawFunc == 'suspect') {
                // шерстим все профили на наличие контактов в админке
                $objResponse->script("window.location = '/siteadmin/suspicious_contacts/?site={$aForm['p_site']}&action=resolve&sid={$aForm['p_sid']}&page={$aForm['p_page']}'");
                return 0;
            }
            $objResponse->script('window.location.reload(true)');
        }
    } else {
        $sParent = $sDrawFunc == 'stream0' || $sDrawFunc == 'stream1' || $sDrawFunc == 'stream2' ? 'parent.' : '';
        $objResponse->script("{$sParent}\$('adm_edit_err_new_val').set('html', '{$error}');");
        $objResponse->script("{$sParent}\$('div_adm_edit_err_new_val').setStyle('display', '');");
        $objResponse->script("{$sParent}adm_edit_content.disabled = false; {$sParent}adm_edit_content.button();");
    }
}
Esempio n. 27
0
 public static function Delete($ID)
 {
     global $DB;
     $err_mess = CVote::err_mess() . "<br>Function: Delete<br>Line: ";
     $ID = intval($ID);
     if ($ID <= 0) {
         return false;
     }
     /***************** Event onBeforeVoteDelete *************************/
     foreach (GetModuleEvents("vote", "onBeforeVoteDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID)) === false) {
             return false;
         }
     }
     /***************** /Event ******************************************/
     @set_time_limit(1000);
     $DB->StartTransaction();
     // delete questions
     CVoteQuestion::Delete(false, $ID);
     // delete vote images
     $strSql = "SELECT IMAGE_ID FROM b_vote 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 vote events
     $DB->Query("DELETE FROM b_vote_event WHERE VOTE_ID='{$ID}'", false, $err_mess . __LINE__);
     // delete vote
     $res = $DB->Query("DELETE FROM b_vote WHERE ID='{$ID}'", false, $err_mess . __LINE__);
     $DB->Commit();
     /***************** Event onAfterVoteDelete *************************/
     foreach (GetModuleEvents("vote", "onAfterVoteDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     /***************** /Event ******************************************/
     return $res;
 }
Esempio n. 28
0
 protected function ClearVariables()
 {
     $rootActivity = $this->GetRootActivity();
     if (is_array($rootActivity->arVariablesTypes) && count($rootActivity->arVariablesTypes) > 0 && is_array($rootActivity->arFieldTypes) && count($rootActivity->arFieldTypes) > 0) {
         foreach ($rootActivity->arVariablesTypes as $key => $value) {
             if ($rootActivity->arFieldTypes[$value["Type"]]["BaseType"] == "file") {
                 if (is_array($rootActivity->arVariables[$key])) {
                     foreach ($rootActivity->arVariables[$key] as $v) {
                         CFile::Delete($v);
                     }
                 } else {
                     CFile::Delete($rootActivity->arVariables[$key]);
                 }
             }
         }
     }
 }
Esempio n. 29
0
 /**
  * Удаление файлов указанных типов
  * @todo Удалять из очереди тоже нужно наверно
  * 
  * @param type $srcId
  * @param type $types
  * @return boolean
  */
 public function deleteFiles($srcId, $types)
 {
     $types = !is_array($types) ? array($types) : $types;
     $this->clearQueue($srcId, $types);
     $rows = CFile::selectFilesBySrc($this->file_table, $srcId);
     if (!$rows) {
         return false;
     }
     foreach ($rows as $row) {
         if (!in_array($row['doc_type'], $types)) {
             continue;
         }
         $file = new CFile();
         $file->Delete($row['id']);
     }
     return true;
 }
Esempio n. 30
0
 /**
  * Удалить Doc.
  *
  * @param mixed $docs_id Ид вопроса или строка в виде id|id2|id3...
  *
  * @return string Сообщение об ошибке
  */
 public static function Delete($id)
 {
     if (is_numeric($id)) {
         $files = docs_files::getDocsFiles($id);
         $file = new CFile();
         foreach ($files as $key => $value) {
             $file->Delete($value['file_id']);
         }
         global $DB;
         $DB->query('DELETE FROM docs WHERE id = ?i', $id);
         return $DB->error;
     } else {
         foreach (explode('|', $id) as $idx) {
             if (!(int) $idx) {
                 continue;
             }
             self::Delete((int) $idx);
         }
         return false;
     }
 }