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


PHP CFile::CopyFile方法代码示例

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


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

示例1: Copy

 public static function Copy($ID)
 {
     global $DB;
     $err_mess = CVote::err_mess() . "<br>Function: Copy<br>Line: ";
     $ID = intval($ID);
     if ($ID <= 0) {
         return false;
     }
     $rCurrentVote = CVote::GetByID($ID);
     if (!($arCurrentVote = $rCurrentVote->Fetch())) {
         return false;
     }
     unset($arCurrentVote["ID"]);
     $arCurrentVote['ACTIVE'] = "N";
     $newImageId = false;
     if (intval($arCurrentVote['IMAGE_ID'] > 0)) {
         $imageId = $arCurrentVote['IMAGE_ID'];
         $newImageId = CFile::CopyFile($imageId);
         $arCurrentVote["IMAGE_ID"] = NULL;
     }
     $newID = CVote::Add($arCurrentVote);
     if ($newID === false) {
         return false;
     }
     $DB->Update("b_vote", array("COUNTER" => "0"), "WHERE ID=" . $newID, $err_mess . __LINE__);
     if ($newImageId) {
         $DB->Update("b_vote", array("IMAGE_ID" => $newImageId), "WHERE ID=" . $newID, $err_mess . __LINE__);
     }
     $state = true;
     $rQuestions = CVoteQuestion::GetList($ID, $by, $order, array(), $is_filtered);
     while ($arQuestion = $rQuestions->Fetch()) {
         $state = $state && CVoteQuestion::Copy($arQuestion['ID'], $newID) !== false;
     }
     if ($state == true) {
         return $newID;
     } else {
         return $state;
     }
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:39,代码来源:vote.php

示例2: Copy

 function Copy($ID, $CHECK_RIGHTS = "Y")
 {
     global $DB, $APPLICATION, $strError;
     $err_mess = CAllForm::err_mess() . "<br>Function: Copy<br>Line: ";
     $ID = intval($ID);
     if ($CHECK_RIGHTS != "Y" || CForm::IsAdmin()) {
         $rsForm = CForm::GetByID($ID);
         $arForm = $rsForm->Fetch();
         if (!is_set($arForm, "FORM_TEMPLATE")) {
             $arForm["FORM_TEMPLATE"] = CForm::GetFormTemplateByID($ID);
         }
         // символьный код формы
         while (true) {
             $SID = $arForm["SID"];
             if (strlen($SID) > 25) {
                 $SID = substr($SID, 0, 25);
             }
             $SID .= "_" . RandString(5);
             $strSql = "SELECT 'x' FROM b_form WHERE SID='" . $DB->ForSql($SID, 50) . "'";
             $z = $DB->Query($strSql, false, $err_mess . __LINE__);
             if (!($zr = $z->Fetch())) {
                 break;
             }
         }
         $arFields = array("NAME" => $arForm["NAME"], "SID" => $SID, "C_SORT" => $arForm["C_SORT"], "FIRST_SITE_ID" => $arForm["FIRST_SITE_ID"], "BUTTON" => $arForm["BUTTON"], "USE_CAPTCHA" => $arForm["USE_CAPTCHA"], "DESCRIPTION" => $arForm["DESCRIPTION"], "DESCRIPTION_TYPE" => $arForm["DESCRIPTION_TYPE"], "SHOW_TEMPLATE" => $arForm["SHOW_TEMPLATE"], "FORM_TEMPLATE" => $arForm["FORM_TEMPLATE"], "USE_DEFAULT_TEMPLATE" => $arForm["USE_DEFAULT_TEMPLATE"], "SHOW_RESULT_TEMPLATE" => $arForm["SHOW_RESULT_TEMPLATE"], "PRINT_RESULT_TEMPLATE" => $arForm["PRINT_RESULT_TEMPLATE"], "EDIT_RESULT_TEMPLATE" => $arForm["EDIT_RESULT_TEMPLATE"], "FILTER_RESULT_TEMPLATE" => $arForm["FILTER_RESULT_TEMPLATE"], "TABLE_RESULT_TEMPLATE" => $arForm["TABLE_RESULT_TEMPLATE"], "STAT_EVENT1" => $arForm["STAT_EVENT1"], "STAT_EVENT2" => $SID, "STAT_EVENT3" => $arForm["STAT_EVENT3"], "arSITE" => CForm::GetSiteArray($ID));
         // пункты меню
         $z = CForm::GetMenuList(array("FORM_ID" => $ID), "N");
         while ($zr = $z->Fetch()) {
             $arFields["arMENU"][$zr["LID"]] = $zr["MENU"];
         }
         // права групп
         $w = CGroup::GetList($v1 = "dropdown", $v2 = "asc", array("ADMIN" => "N"), $v3);
         $arGroups = array();
         while ($wr = $w->Fetch()) {
             $arGroups[] = $wr["ID"];
         }
         if (is_array($arGroups)) {
             foreach ($arGroups as $gid) {
                 $arFields["arGROUP"][$gid] = CForm::GetPermission($ID, array($gid), "Y");
             }
         }
         // картинка
         if (intval($arForm["IMAGE_ID"]) > 0) {
             $arIMAGE = CFile::MakeFileArray(CFile::CopyFile($arForm["IMAGE_ID"]));
             $arIMAGE["MODULE_ID"] = "form";
             $arFields["arIMAGE"] = $arIMAGE;
         }
         $NEW_ID = CForm::Set($arFields, 0);
         if (intval($NEW_ID) > 0) {
             // статусы
             $rsStatus = CFormStatus::GetList($ID, $by, $order, array(), $is_filtered);
             while ($arStatus = $rsStatus->Fetch()) {
                 CFormStatus::Copy($arStatus["ID"], "N", $NEW_ID);
             }
             // вопросы/пол¤
             $rsField = CFormField::GetList($ID, "ALL", $by, $order, array(), $is_filtered);
             while ($arField = $rsField->Fetch()) {
                 CFormField::Copy($arField["ID"], "N", $NEW_ID);
             }
         }
         return $NEW_ID;
     } else {
         $strError .= GetMessage("FORM_ERROR_ACCESS_DENIED") . "<br>";
     }
     return false;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:66,代码来源:form_callform.php

示例3: SplitTicket

 function SplitTicket($arParam)
 {
     global $DB;
     $err_mess = CAllTicket::err_mess() . "<br>Function: SplitTicket<br>Line: ";
     $intLastTicketID = IntVal($arParam['SOURCE_TICKET_ID']);
     $stLastTicketTitle = htmlspecialcharsEx($arParam['SOURCE_TICKET_TITLE']);
     $intSplitMesageID = IntVal($arParam['SOURCE_MESSAGE_NUM']);
     $stSplitMesageDate = MakeTimeStamp($arParam['SOURCE_MESSAGE_DATE'], "DD.MM.YYYY HH:MI:SS") ? $arParam['SOURCE_MESSAGE_DATE'] : '';
     // add to the previous post about ticket allocation of posts in a separate branch
     $arFields = array("MESSAGE_CREATED_USER_ID" => $arParam['SPLIT_MESSAGE_USER_ID'], "MESSAGE_CREATED_MODULE_NAME" => "support", "MESSAGE_CREATED_GUEST_ID" => "null", "MESSAGE_SOURCE_ID" => $arParam['SOURCE_MESSAGE_ID'], "MESSAGE" => GetMessage("SUP_SPLIT_MESSAGE_USER_1", array("#MESSAGE_DATE#" => $stSplitMesageDate, "#TITLE#" => '# ' . $arParam['SPLIT_TICKET_ID'] . ' "' . $arParam['SPLIT_TICKET_TITLE'] . '"')), "LOG" => "N", "HIDDEN" => "N", "NOT_CHANGE_STATUS" => "Y", "MESSAGE_AUTHOR_USER_ID" => $arParam['SPLIT_MESSAGE_USER_ID']);
     CTicket::AddMessage($intLastTicketID, $arFields, $arFiles = array(), "N");
     // add to the previous post about ticket allocation of posts in a separate branch (support log)
     $arFields_log = array("MESSAGE_CREATED_USER_ID" => $arParam['SPLIT_MESSAGE_USER_ID'], "MESSAGE_CREATED_MODULE_NAME" => "support", "MESSAGE_CREATED_GUEST_ID" => "null", "MESSAGE_SOURCE_ID" => $arParam['SOURCE_MESSAGE_ID'], "MESSAGE" => GetMessage("SUP_SPLIT_MESSAGE_LOG_1", array("#MESSAGE_ID#" => $intSplitMesageID, "#TITLE#" => '<a href="ticket_edit.php?ID=' . $arParam['SPLIT_TICKET_ID'] . '&lang=' . LANGUAGE_ID . '"> # ' . $arParam['SPLIT_TICKET_ID'] . ' "' . $arParam['SPLIT_TICKET_TITLE'] . '"</a>')), "LOG" => "Y");
     CTicket::AddMessage($intLastTicketID, $arFields_log, $arFiles_log = array(), "N");
     // add a new ticket allocation message posted in a separate branch
     $arFields = array("MESSAGE_CREATED_USER_ID" => $arParam['SPLIT_MESSAGE_USER_ID'], "MESSAGE_CREATED_MODULE_NAME" => "support", "MESSAGE_CREATED_GUEST_ID" => "null", "MESSAGE_SOURCE_ID" => $arParam['SOURCE_MESSAGE_ID'], "MESSAGE" => GetMessage("SUP_SPLIT_MESSAGE_USER_2", array("#MESSAGE_DATE#" => $stSplitMesageDate, "#TITLE#" => '# ' . $intLastTicketID . ' "' . $stLastTicketTitle . '"')), "LOG" => "N", "HIDDEN" => "N", "NOT_CHANGE_STATUS" => "Y", "MESSAGE_AUTHOR_USER_ID" => $arParam['SPLIT_MESSAGE_USER_ID']);
     CTicket::AddMessage($arParam['SPLIT_TICKET_ID'], $arFields, $arFiles = array(), "N");
     // add a new ticket allocation message posted in a separate branch (support log)
     $arFields_log = array("MESSAGE_CREATED_USER_ID" => $arParam['SPLIT_MESSAGE_USER_ID'], "MESSAGE_CREATED_MODULE_NAME" => "support", "MESSAGE_CREATED_GUEST_ID" => "null", "MESSAGE_SOURCE_ID" => $arParam['SOURCE_MESSAGE_ID'], "MESSAGE" => GetMessage("SUP_SPLIT_MESSAGE_LOG_2", array("#MESSAGE_ID#" => $intSplitMesageID, "#TITLE#" => '<a href="ticket_edit.php?ID=' . $intLastTicketID . '&lang=' . LANGUAGE_ID . '"> # ' . $intLastTicketID . ' "' . $stLastTicketTitle . '"</a>')), "LOG" => "Y");
     CTicket::AddMessage($arParam['SPLIT_TICKET_ID'], $arFields_log, $arFiles_log = array(), "N");
     // If the message that we want to separate, there are attached files, copy them
     if (isset($arParam['SPLIT_ATTACH_FILE'])) {
         $res = CTicket::GetMessageList($by = 'ID', $order = 'ASC', array('TICKET_ID' => $arParam['SPLIT_TICKET_ID']), $is_filtered = false);
         $MESSAGE = $res->Fetch();
         foreach ($arParam['SPLIT_ATTACH_FILE'] as $key => $iAttachFile) {
             $fid = CFile::CopyFile(intval($iAttachFile));
             if ($fid > 0) {
                 $arFields_fi = array("HASH" => "'" . $DB->ForSql(md5(uniqid(mt_rand(), true) . time()), 255) . "'", "MESSAGE_ID" => $MESSAGE['ID'], "FILE_ID" => $fid, "TICKET_ID" => $arParam['SPLIT_TICKET_ID'], "EXTENSION_SUFFIX" => "null");
                 $DB->Insert("b_ticket_message_2_file", $arFields_fi, $err_mess . __LINE__);
             }
         }
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:33,代码来源:support.php

示例4: Copy


//.........这里部分代码省略.........
  * name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/form/classes/cformfield/copy.php
  * @author Bitrix
  */
 public static function Copy($ID, $CHECK_RIGHTS = "Y", $NEW_FORM_ID = false)
 {
     global $DB, $strError;
     $err_mess = CAllFormField::err_mess() . "<br>Function: Copy<br>Line: ";
     $ID = intval($ID);
     $NEW_FORM_ID = intval($NEW_FORM_ID);
     $rsField = CFormField::GetByID($ID);
     if ($arField = $rsField->Fetch()) {
         $RIGHT_OK = "N";
         if ($CHECK_RIGHTS != "Y" || CForm::IsAdmin()) {
             $RIGHT_OK = "Y";
         } else {
             $F_RIGHT = CForm::GetPermission($arField["FORM_ID"]);
             // если имеем право на просмотр параметров формы
             if ($F_RIGHT >= 25) {
                 // если задана новая форма
                 if ($NEW_FORM_ID > 0) {
                     $NEW_F_RIGHT = CForm::GetPermission($NEW_FORM_ID);
                     // если имеем полный доступ на новую форму
                     if ($NEW_F_RIGHT >= 30) {
                         $RIGHT_OK = "Y";
                     }
                 } elseif ($F_RIGHT >= 30) {
                     $RIGHT_OK = "Y";
                 }
             }
         }
         // если права проверили то
         if ($RIGHT_OK == "Y") {
             // символьный код поля
             if (!$NEW_FORM_ID) {
                 while (true) {
                     // change: SID изменяем только если для старой формы. Требование уникальности снято.
                     $SID = $arField["SID"];
                     if (strlen($SID) > 44) {
                         $SID = substr($SID, 0, 44);
                     }
                     $SID .= "_" . RandString(5);
                     $strSql = "SELECT 'x' FROM b_form WHERE SID='" . $DB->ForSql($SID, 50) . "'";
                     $z = $DB->Query($strSql, false, $err_mess . __LINE__);
                     if (!($zr = $z->Fetch())) {
                         $strSql = "SELECT 'x' FROM b_form_field WHERE SID='" . $DB->ForSql($SID, 50) . "' AND FORM_ID='" . $arField["FORM_ID"] . "'";
                         $t = $DB->Query($strSql, false, $err_mess . __LINE__);
                         if (!($tr = $t->Fetch())) {
                             break;
                         }
                     }
                 }
             } else {
                 $SID = $arField["SID"];
             }
             // копируем
             $arFields = array("FORM_ID" => $NEW_FORM_ID > 0 ? $NEW_FORM_ID : $arField["FORM_ID"], "ACTIVE" => $arField["ACTIVE"], "TITLE" => $arField["TITLE"], "TITLE_TYPE" => $arField["TITLE_TYPE"], "SID" => $SID, "C_SORT" => $arField["C_SORT"], "ADDITIONAL" => $arField["ADDITIONAL"], "REQUIRED" => $arField["REQUIRED"], "IN_FILTER" => $arField["IN_FILTER"], "IN_RESULTS_TABLE" => $arField["IN_RESULTS_TABLE"], "IN_EXCEL_TABLE" => $arField["IN_EXCEL_TABLE"], "FIELD_TYPE" => $arField["FIELD_TYPE"], "COMMENTS" => $arField["COMMENTS"], "FILTER_TITLE" => $arField["FILTER_TITLE"], "RESULTS_TABLE_TITLE" => $arField["RESULTS_TABLE_TITLE"]);
             // картинка
             if (intval($arField["IMAGE_ID"]) > 0) {
                 $arIMAGE = CFile::MakeFileArray(CFile::CopyFile($arField["IMAGE_ID"]));
                 $arIMAGE["MODULE_ID"] = "form";
                 $arFields["arIMAGE"] = $arIMAGE;
             }
             // фильтр
             $z = CFormField::GetFilterList($arField["FORM_ID"], array("FIELD_ID" => $ID, "FIELD_ID_EXACT_MATCH" => "Y"));
             while ($zr = $z->Fetch()) {
                 if ($arField["ADDITIONAL"] != "Y") {
                     $arFields["arFILTER_" . $zr["PARAMETER_NAME"]][] = $zr["FILTER_TYPE"];
                 } elseif ($zr["PARAMETER_NAME"] == "USER") {
                     $arFields["arFILTER_FIELD"][] = $zr["FILTER_TYPE"];
                 }
             }
             //echo "<pre>"; print_r($arFields); echo "</pre>";
             $NEW_ID = CFormField::Set($arFields);
             if (intval($NEW_ID) > 0) {
                 if ($arField["ADDITIONAL"] != "Y") {
                     // ответы
                     $rsAnswer = CFormAnswer::GetList($ID, $by = 'ID', $order = 'ASC', array(), $is_filtered);
                     while ($arAnswer = $rsAnswer->Fetch()) {
                         CFormAnswer::Copy($arAnswer["ID"], $NEW_ID);
                     }
                     // валидаторы
                     $dbValidators = CFormValidator::GetList($ID);
                     while ($arVal = $dbValidators->Fetch()) {
                         CFormValidator::Set($arField['FORM_ID'], $NEW_ID, $arVal['NAME'], $arVal['PARAMS'], $arVal['C_SORT']);
                     }
                 }
             }
             return $NEW_ID;
         } else {
             $strError .= GetMessage("FORM_ERROR_ACCESS_DENIED") . "<br>";
         }
     } else {
         $strError .= GetMessage("FORM_ERROR_FIELD_NOT_FOUND") . "<br>";
     }
     return false;
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:101,代码来源:form_callformfield.php

示例5: CAdminMessage

     $arFields["AUTHOR_ID"] = $GLOBALS["USER"]->GetId();
     $result = $ID = CVote::Add($arFields);
 } else {
     $result = CVote::Update($ID, $arFields);
 }
 if (!$result) {
     $e = $APPLICATION->GetException();
     $message = new CAdminMessage(GetMessage("VOTE_GOT_ERROR"), $e);
     $bVarsFromForm = true;
 } else {
     if (isset($_REQUEST['COPYID']) && ($oldID = intval($_REQUEST['COPYID'])) > 0 && ($rCurrentVote = CVote::GetByID($oldID)) && ($arCurrentVote = $rCurrentVote->Fetch())) {
         global $DB;
         $newImageId = false;
         if (intval($arCurrentVote['IMAGE_ID']) > 0 && empty($arIMAGE_ID['name']) && $arIMAGE_ID['del'] != 'Y') {
             $imageId = $arCurrentVote['IMAGE_ID'];
             $newImageId = CFile::CopyFile($imageId);
             $arCurrentVote["IMAGE_ID"] = NULL;
         }
         $newID = $ID;
         if ($newID === false) {
             return false;
         }
         $DB->Update("b_vote", array("COUNTER" => "0"), "WHERE ID=" . $newID, $err_mess . __LINE__);
         if ($newImageId) {
             $DB->Update("b_vote", array("IMAGE_ID" => $newImageId), "WHERE ID=" . $newID, $err_mess . __LINE__);
         }
         $state = true;
         $rQuestions = CVoteQuestion::GetList($oldID, $by, $order, array(), $is_filtered);
         while ($arQuestion = $rQuestions->Fetch()) {
             $state = $state && CVoteQuestion::Copy($arQuestion['ID'], $newID) !== false;
         }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:vote_edit.php

示例6: PrepareFileForHistory

 public static function PrepareFileForHistory($documentId, $arFileId, $historyIndex)
 {
     $dest = self::GenerateFilePath($documentId);
     $fileParameterIsArray = true;
     if (!is_array($arFileId)) {
         $arFileId = array($arFileId);
         $fileParameterIsArray = false;
     }
     $result = array();
     foreach ($arFileId as $fileId) {
         if ($ar = CFile::GetFileArray($fileId)) {
             $newFilePath = CFile::CopyFile($fileId, false, $dest . "/" . $historyIndex . "/" . $ar["FILE_NAME"]);
             if ($newFilePath) {
                 $result[] = $newFilePath;
             }
         }
     }
     if (!$fileParameterIsArray) {
         if (count($result) > 0) {
             $result = $result[0];
         } else {
             $result = "";
         }
     }
     return $result;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:26,代码来源:historyservice.php

示例7: elseif

     }
 } elseif (intval($_GET["COPY"]) > 0) {
     $rsCopy = CTasks::GetByID(intval($_GET["COPY"]));
     if ($arCopy = $rsCopy->GetNext()) {
         if (isset($arCopy["~DESCRIPTION_IN_BBCODE"])) {
             $arCopy["DESCRIPTION_IN_BBCODE"] = $arCopy["~DESCRIPTION_IN_BBCODE"];
         }
         $arCopy["DESCRIPTION"] = $arCopy["~DESCRIPTION"];
         $arCopy["CREATED_BY_NAME"] = $arCopy["~CREATED_BY_NAME"];
         $arCopy["CREATED_BY_LAST_NAME"] = $arCopy["~CREATED_BY_LAST_NAME"];
         $arCopy["CREATED_BY_SECOND_NAME"] = $arCopy["~CREATED_BY_SECOND_NAME"];
         $arCopy["CREATED_BY_LOGIN"] = $arCopy["~CREATED_BY_LOGIN"];
         $arCopy["MULTITASK"] = "N";
         if (sizeof($arCopy["FILES"])) {
             foreach ($arCopy["FILES"] as $key => $file) {
                 $newFile = CFile::CopyFile($file);
                 $arCopy["FILES"][$key] = $newFile;
             }
         }
         $arCopy['CHECKLIST_ITEMS'] = array();
         try {
             $oTask = new CTaskItem((int) $_GET["COPY"], $loggedInUserId);
             list($arChecklistItems, $arMetaData) = CTaskCheckListItem::fetchList($oTask, array('SORT_INDEX' => 'ASC'));
             unset($arMetaData);
             foreach ($arChecklistItems as $oChecklistItem) {
                 $checklistItemId = -1 * $oChecklistItem->getId();
                 $arCopy['CHECKLIST_ITEMS'][$checklistItemId] = $oChecklistItem->getData();
                 $arCopy['CHECKLIST_ITEMS'][$checklistItemId]['ID'] = $checklistItemId;
                 $arCopy['CHECKLIST_ITEMS'][$checklistItemId]['~ID'] = $checklistItemId;
                 $arCopy['CHECKLIST_ITEMS'][$checklistItemId]['META:CAN_MODIFY'] = $oChecklistItem->isActionAllowed(CTaskCheckListItem::ACTION_MODIFY);
                 $arCopy['CHECKLIST_ITEMS'][$checklistItemId]['META:CAN_REMOVE'] = $oChecklistItem->isActionAllowed(CTaskCheckListItem::ACTION_REMOVE);
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php


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