PageRenderTime 105ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/clouds/admin/clouds_storage_list.php

https://gitlab.com/alexprowars/bitrix
PHP | 660 lines | 590 code | 57 blank | 13 comment | 70 complexity | 1a528eefdbffad272a6d293559bddb8e MD5 | raw file
  1. <?
  2. define("ADMIN_MODULE_NAME", "clouds");
  3. /*.require_module 'standard';.*/
  4. /*.require_module 'pcre';.*/
  5. /*.require_module 'bitrix_main_include_prolog_admin_before';.*/
  6. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
  7. if(!$USER->CanDoOperation("clouds_config"))
  8. $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
  9. /*.require_module 'bitrix_clouds_include';.*/
  10. if(!CModule::IncludeModule('clouds'))
  11. $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
  12. IncludeModuleLangFile(__FILE__);
  13. $io = CBXVirtualIo::GetInstance();
  14. $sTableID = "tbl_clouds_storage_list";
  15. $oSort = new CAdminSorting($sTableID, "ID", "ASC");
  16. $lAdmin = new CAdminList($sTableID, $oSort);
  17. $bOnTheMove = isset($_GET["themove"]);
  18. $upload_dir = $_SERVER["DOCUMENT_ROOT"]."/".COption::GetOptionString("main", "upload_dir", "upload");
  19. $bHasLocalStorage = file_exists($upload_dir) && (is_dir($upload_dir) || is_link($upload_dir)) && is_writable($upload_dir);
  20. $arID = $lAdmin->GroupAction();
  21. $action = isset($_REQUEST["action"]) && is_string($_REQUEST["action"])? "$_REQUEST[action]": "";
  22. if(is_array($arID))
  23. {
  24. foreach($arID as $ID)
  25. {
  26. if($ID == '' || intval($ID) <= 0)
  27. continue;
  28. switch($action)
  29. {
  30. case "delete":
  31. $ob = new CCloudStorageBucket(intval($ID));
  32. if(!$ob->Delete())
  33. {
  34. $e = $APPLICATION->GetException();
  35. $lAdmin->AddUpdateError($e->GetString(), $ID);
  36. }
  37. break;
  38. case "deactivate":
  39. $ob = new CCloudStorageBucket(intval($ID));
  40. if($ob->ACTIVE === "Y")
  41. $ob->Update(array("ACTIVE"=>"N"));
  42. break;
  43. case "activate":
  44. $ob = new CCloudStorageBucket(intval($ID));
  45. if($ob->ACTIVE === "N")
  46. $ob->Update(array("ACTIVE"=>"Y"));
  47. break;
  48. case "download":
  49. $ob = new CCloudStorageBucket(intval($ID));
  50. if($ob->Init() && $ob->ACTIVE === "Y")
  51. {
  52. if(isset($_SESSION["last_file_id"]))
  53. $last_file_id = intval($_SESSION["last_file_id"]);
  54. else
  55. $last_file_id = 0;
  56. if(isset($_SESSION["last_file_pos"]))
  57. $last_file_pos = doubleval($_SESSION["last_file_pos"]);
  58. else
  59. $last_file_pos = 0;
  60. $rsNextFile = $DB->Query("
  61. SELECT MIN(b_file.ID) ID, COUNT(1) CNT, SUM(b_file.FILE_SIZE) FILE_SIZE
  62. FROM b_file
  63. LEFT JOIN b_file_duplicate on b_file_duplicate.DUPLICATE_ID = b_file.ID
  64. WHERE b_file.ID > ".intval($last_file_id)."
  65. AND b_file.HANDLER_ID = '".$DB->ForSQL($ob->ID)."'
  66. AND b_file_duplicate.DUPLICATE_ID is null
  67. ");
  68. $lAdmin->BeginPrologContent();
  69. if(
  70. is_array($ar = $rsNextFile->Fetch())
  71. && (intval($ar["ID"]) > 0)
  72. )
  73. {
  74. $bNextFile = true;
  75. $bFileMoved = false;
  76. $maxPartSize = 1024*1024; //1M
  77. $arFile = CFile::GetFileArray($ar["ID"]);
  78. $filePath = preg_replace("#[\\\\\\/]+#", "/", "/".$arFile["SUBDIR"]."/".$arFile["FILE_NAME"]);
  79. $absPath = preg_replace("#[\\\\\\/]+#", "/", $_SERVER["DOCUMENT_ROOT"]."/".COption::GetOptionString("main", "upload_dir", "upload").$filePath);
  80. $absPath = $io->GetPhysicalName($absPath);
  81. $absTempPath = $absPath."~";
  82. if(!file_exists($absPath))
  83. {
  84. CheckDirPath($absTempPath);
  85. $obRequest = new CHTTP;
  86. $obRequest->follow_redirect = true;
  87. $obRequest->fp = fopen($absTempPath, "ab");
  88. if(is_resource($obRequest->fp))
  89. {
  90. if($arFile["FILE_SIZE"] > $maxPartSize)
  91. {
  92. $obRequest->additional_headers["Range"] = sprintf("bytes=%u-%u", $last_file_pos, ($last_file_pos+$maxPartSize > $arFile["FILE_SIZE"]? $arFile["FILE_SIZE"]: $last_file_pos+$maxPartSize)-1);
  93. }
  94. $res = $obRequest->HTTPQuery('GET', $ob->GetFileSRC($arFile));
  95. fclose($obRequest->fp);
  96. unset($obRequest->fp);
  97. if($res && ($obRequest->status == 200 || $obRequest->status == 206))
  98. {
  99. $bFileMoved = true;
  100. if($arFile["FILE_SIZE"] > $maxPartSize)
  101. {
  102. $last_file_pos += $maxPartSize;
  103. $_SESSION["last_file_pos"] = $last_file_pos;
  104. $bNextFile = false;
  105. }
  106. else
  107. {
  108. $last_file_pos = $arFile["FILE_SIZE"];
  109. }
  110. if(
  111. array_key_exists("Content-Range", $obRequest->headers)
  112. && preg_match("/(\\d+)-(\\d+)\\/(\\d+)\$/", $obRequest->headers["Content-Range"], $match)
  113. )
  114. $FILE_SIZE = $match[3];
  115. elseif(
  116. array_key_exists("Content-Length", $obRequest->headers)
  117. && preg_match("/^(\\d+)\$/", $obRequest->headers["Content-Length"], $match)
  118. && $match[1] > $maxPartSize
  119. )
  120. $FILE_SIZE = 0; //Chunk download not supported
  121. else
  122. $FILE_SIZE = $arFile["FILE_SIZE"];
  123. if($last_file_pos > $FILE_SIZE)
  124. {
  125. $last_file_pos = $arFile["FILE_SIZE"];
  126. $bFileMoved = true;
  127. $bNextFile = true;
  128. }
  129. }
  130. else
  131. {
  132. //An error occured
  133. @unlink($absTempPath);
  134. $bFileMoved = false;
  135. }
  136. }
  137. }
  138. if($bNextFile)
  139. {
  140. $_SESSION["last_file_id"] = $ar["ID"];
  141. $_SESSION["last_file_pos"] = 0.0;
  142. if($bFileMoved)
  143. {
  144. rename($absTempPath, $absPath);
  145. $ob->DeleteFile($filePath);
  146. $filesToUpdate = array(intval($arFile["ID"]));
  147. //Find duplicates of the file
  148. $duplicates = \Bitrix\Main\File\Internal\FileDuplicateTable::query()
  149. ->addSelect("DUPLICATE_ID")
  150. ->where("ORIGINAL_ID", $arFile["ID"])
  151. ->fetchAll();
  152. foreach ($duplicates as $dupFile)
  153. {
  154. $filesToUpdate[] = intval($dupFile["DUPLICATE_ID"]);
  155. }
  156. //Mark them as moved
  157. $updateResult = $DB->Query("
  158. UPDATE b_file
  159. SET HANDLER_ID = null
  160. WHERE ID in (".implode(",", $filesToUpdate).")
  161. ");
  162. $updateCount = $updateResult->AffectedRowsCount();
  163. //Clean cache
  164. foreach ($filesToUpdate as $updatedFileId)
  165. {
  166. CFile::CleanCache($updatedFileId);
  167. }
  168. $ob->DecFileCounter((float)$arFile["FILE_SIZE"]);
  169. $ob->Update(array("LAST_FILE_ID" => 0));
  170. }
  171. }
  172. CAdminMessage::ShowMessage(array(
  173. "TYPE"=>"PROGRESS",
  174. "MESSAGE"=>GetMessage("CLO_STORAGE_LIST_DOWNLOAD_IN_PROGRESS"),
  175. "DETAILS"=>GetMessage("CLO_STORAGE_LIST_DOWNLOAD_PROGRESS", array(
  176. "#remain#" => $ar["CNT"] - $bNextFile,
  177. "#bytes#" => CFile::FormatSize($ar["FILE_SIZE"] - $last_file_pos),
  178. )),
  179. "HTML"=>true,
  180. "BUTTONS" => array(
  181. array(
  182. "VALUE" => GetMessage("CLO_STORAGE_LIST_STOP"),
  183. "ONCLICK" => 'window.location = \'/bitrix/admin/clouds_storage_list.php?lang='.LANGUAGE_ID.'\'',
  184. ),
  185. ),
  186. ));
  187. $bOnTheMove = true;
  188. echo '<script>' . $lAdmin->ActionDoGroup($ID, "download", "themove=y") . '</script>';
  189. }
  190. else
  191. {
  192. unset($_SESSION["last_file_id"]);
  193. unset($_SESSION["last_file_pos"]);
  194. CAdminMessage::ShowMessage(array(
  195. "MESSAGE"=>GetMessage("CLO_STORAGE_LIST_DOWNLOAD_DONE"),
  196. "TYPE"=>"OK",
  197. "HTML"=>true,
  198. ));
  199. $bOnTheMove = false;
  200. }
  201. $lAdmin->EndPrologContent();
  202. }
  203. break;
  204. case "move":
  205. $message = /*.(CAdminMessage).*/null;
  206. $ob = new CCloudStorageBucket(intval($ID));
  207. if($ob->ACTIVE === "Y" && $ob->READ_ONLY === "N")
  208. {
  209. $_done = 0;
  210. $_size = 0.0;
  211. $_skip = 0;
  212. if(intval($ob->LAST_FILE_ID) > 0)
  213. {
  214. if(isset($_SESSION["arMoveStat_done"]))
  215. $_done = intval($_SESSION["arMoveStat_done"]);
  216. if(isset($_SESSION["arMoveStat_size"]))
  217. $_size = doubleval($_SESSION["arMoveStat_size"]);
  218. if(isset($_SESSION["arMoveStat_skip"]))
  219. $_skip = intval($_SESSION["arMoveStat_skip"]);
  220. }
  221. $files_per_step = 50;
  222. $rsNextFile = $DB->Query($DB->TopSQL("
  223. SELECT *
  224. FROM b_file
  225. WHERE ID > ".intval($ob->LAST_FILE_ID)."
  226. AND (HANDLER_ID IS NULL OR HANDLER_ID <> '".$DB->ForSQL($ob->ID)."')
  227. ORDER BY ID ASC
  228. ", $files_per_step));
  229. $file_skip_reason = array();
  230. $counter = 0;
  231. $bWasMoved = false;
  232. $moveResult = CCloudStorage::FILE_SKIPPED;
  233. while(
  234. $moveResult == CCloudStorage::FILE_PARTLY_UPLOADED
  235. || is_array($arFile = $rsNextFile->Fetch())
  236. )
  237. {
  238. //Check if file is a duplicate then skip it
  239. $original = \Bitrix\Main\File\Internal\FileDuplicateTable::query()
  240. ->addSelect("DUPLICATE_ID")
  241. ->where("DUPLICATE_ID", $arFile["ID"])
  242. ->fetch();
  243. if ($original)
  244. {
  245. $ob->Update(array("LAST_FILE_ID" => $arFile["ID"]));
  246. $counter++;
  247. continue;
  248. }
  249. CCloudStorage::FixFileContentType($arFile);
  250. $moveResult = CCloudStorage::MoveFile($arFile, $ob);
  251. $file_skip_reason[$arFile["ID"]] = CCloudStorage::$file_skip_reason;
  252. if($moveResult == CCloudStorage::FILE_MOVED)
  253. {
  254. $filesToUpdate = array(intval($arFile["ID"]));
  255. //Find duplicates of the file
  256. $duplicates = \Bitrix\Main\File\Internal\FileDuplicateTable::query()
  257. ->addSelect("DUPLICATE_ID")
  258. ->where("ORIGINAL_ID", $arFile["ID"])
  259. ->fetchAll();
  260. foreach ($duplicates as $dupFile)
  261. {
  262. $filesToUpdate[] = intval($dupFile["DUPLICATE_ID"]);
  263. }
  264. //Mark them as moved
  265. $updateResult = $DB->Query("
  266. UPDATE b_file
  267. SET HANDLER_ID = '".$DB->ForSQL($ob->ID)."'
  268. WHERE ID in (".implode(",", $filesToUpdate).")
  269. and (HANDLER_ID is null or HANDLER_ID <> '".$DB->ForSQL($ob->ID)."')
  270. ");
  271. $updateCount = $updateResult->AffectedRowsCount();
  272. //Clean cache
  273. foreach ($filesToUpdate as $updatedFileId)
  274. {
  275. CFile::CleanCache($updatedFileId);
  276. }
  277. $_done += $updateCount;
  278. $_size += doubleval($arFile["FILE_SIZE"]) * $updateCount;
  279. $bWasMoved = true;
  280. $ob->Update(array("LAST_FILE_ID" => $arFile["ID"]));
  281. $counter++;
  282. }
  283. elseif($moveResult == CCloudStorage::FILE_SKIPPED)
  284. {
  285. $e = $APPLICATION->GetException();
  286. if(is_object($e))
  287. {
  288. $message = new CAdminMessage(GetMessage("CLO_STORAGE_LIST_MOVE_FILE_ERROR"), $e);
  289. break;
  290. }
  291. else
  292. {
  293. $_skip += 1;
  294. $ob->Update(array("LAST_FILE_ID" => $arFile["ID"]));
  295. $counter++;
  296. }
  297. }
  298. else//if($moveResult == CCloudStorage::FILE_PARTLY_UPLOADED)
  299. {
  300. $bWasMoved = true;
  301. }
  302. if($bWasMoved)
  303. {
  304. usleep(300);
  305. break;
  306. }
  307. }
  308. $lAdmin->BeginPrologContent();
  309. if(is_object($message))
  310. {
  311. echo $message->Show();
  312. }
  313. elseif($counter < $files_per_step && !$bWasMoved)
  314. {
  315. CAdminMessage::ShowMessage(array(
  316. "MESSAGE"=>GetMessage("CLO_STORAGE_LIST_MOVE_DONE"),
  317. "DETAILS"=>GetMessage("CLO_STORAGE_LIST_MOVE_PROGRESS", array(
  318. "#bytes#" => CFile::FormatSize($_size),
  319. "#total#" => $_done + $_skip,
  320. "#moved#" => $_done,
  321. "#skiped#" => $_skip,
  322. )),
  323. "HTML"=>true,
  324. "TYPE"=>"OK",
  325. ));
  326. $bOnTheMove = false;
  327. $ob->Update(array("LAST_FILE_ID" => false));
  328. }
  329. else
  330. {
  331. CAdminMessage::ShowMessage(array(
  332. "TYPE"=>"PROGRESS",
  333. "MESSAGE"=>GetMessage("CLO_STORAGE_LIST_MOVE_IN_PROGRESS"),
  334. "DETAILS"=>GetMessage("CLO_STORAGE_LIST_MOVE_PROGRESS", array(
  335. "#bytes#" => CFile::FormatSize($_size + CCloudStorage::$part_count*CCloudStorage::$part_size),
  336. "#total#" => $_done + $_skip,
  337. "#moved#" => $_done,
  338. "#skiped#" => $_skip,
  339. )),
  340. "HTML"=>true,
  341. "BUTTONS" => array(
  342. array(
  343. "VALUE" => GetMessage("CLO_STORAGE_LIST_STOP"),
  344. "ONCLICK" => 'window.location = \'/bitrix/admin/clouds_storage_list.php?lang='.LANGUAGE_ID.'\'',
  345. ),
  346. ),
  347. ));
  348. $bOnTheMove = true;
  349. echo '<script>' . $lAdmin->ActionDoGroup($ID, "move", "themove=y") . '</script>';
  350. }
  351. //File skip reasons debug infirmation:
  352. echo "\n<!--\nFile skip reasons:\n".print_r($file_skip_reason, true)."-->\n";
  353. $lAdmin->EndPrologContent();
  354. $_SESSION["arMoveStat_done"] = $_done;
  355. $_SESSION["arMoveStat_size"] = $_size;
  356. $_SESSION["arMoveStat_skip"] = $_skip;
  357. }
  358. break;
  359. case "estimate_duplicates":
  360. $ob = new CCloudStorageBucket(intval($ID), false);
  361. if($ob->ACTIVE === "Y" && $ob->READ_ONLY === "N" && $ob->Init())
  362. {
  363. $pageSize = 1000;
  364. $hasFinished = null;
  365. $lastKey = (string)$_REQUEST['lastKey'];
  366. $result = $ob->ListFiles('/', true, $pageSize, $lastKey);
  367. $isOk = is_array($result);
  368. if (is_array($result))
  369. {
  370. \Bitrix\Clouds\FileHashTable::syncList($ob->ID, '/', $result, $lastKey);
  371. $hasFinished = (count($result["file"]) < $pageSize);
  372. $lastKey = $result['last_key'];
  373. if ($hasFinished)
  374. {
  375. \Bitrix\Clouds\FileHashTable::syncEnd($ob->ID, '/', $lastKey);
  376. }
  377. }
  378. $lAdmin->BeginPrologContent();
  379. $message = new CAdminMessage(array(
  380. "TYPE" => "OK",
  381. "MESSAGE" => GetMessage('CLO_STORAGE_LIST_LISTING'),
  382. "DETAILS" => $lastKey,
  383. ));
  384. echo $message->Show();
  385. if (!$hasFinished)
  386. {
  387. echo '<script>ShowWaitWindow();' . $lAdmin->ActionDoGroup($ob->ID, "estimate_duplicates", "lastKey=" . urlencode($lastKey)) . '</script>';
  388. }
  389. else
  390. {
  391. echo '<script>ShowWaitWindow();' . $lAdmin->ActionDoGroup($ob->ID, "fill_file_hash", "lastKey=0") . '</script>';
  392. }
  393. $lAdmin->EndPrologContent();
  394. }
  395. break;
  396. case "fill_file_hash":
  397. $ob = new CCloudStorageBucket(intval($ID), false);
  398. if($ob->ACTIVE === "Y" && $ob->READ_ONLY === "N" && $ob->Init())
  399. {
  400. $pageSize = 10000;
  401. $lastKey = (int)$_REQUEST['lastKey'];
  402. $fileIds = \Bitrix\Clouds\FileHashTable::copyToFileHash($lastKey, $pageSize);
  403. $hasFinished = $fileIds['FILE_ID_CNT'] < $pageSize;
  404. if (!$hasFinished)
  405. {
  406. $lastKey = $fileIds['FILE_ID_MAX'];
  407. }
  408. $lAdmin->BeginPrologContent();
  409. if (!$hasFinished)
  410. {
  411. $message = new CAdminMessage(array(
  412. "TYPE" => "OK",
  413. "MESSAGE" => GetMessage('CLO_STORAGE_LIST_COPY'),
  414. "DETAILS" => $lastKey,
  415. ));
  416. echo $message->Show();
  417. echo '<script>ShowWaitWindow();' . $lAdmin->ActionDoGroup($ob->ID, "fill_file_hash", "lastKey=" . urlencode($lastKey)) . '</script>';
  418. }
  419. else
  420. {
  421. $stat = \Bitrix\Clouds\FileHashTable::getDuplicatesStat($ob->ID);
  422. $message = new CAdminMessage(array(
  423. "TYPE" => "OK",
  424. "MESSAGE" => GetMessage('CLO_STORAGE_LIST_DUPLICATES_RESULT'),
  425. "DETAILS"=>GetMessage("CLO_STORAGE_LIST_DUPLICATES_INFO", array(
  426. "#count#" => intval($stat['DUP_COUNT']),
  427. "#size#" => CFile::FormatSize($stat['DUP_SIZE']),
  428. "#list_link#" => "clouds_duplicates_list.php?lang=".LANGUAGE_ID."&bucket=".$ob->ID,
  429. )),
  430. "HTML"=>true,
  431. ));
  432. echo $message->Show();
  433. echo '<script>CloseWaitWindow();</script>';
  434. }
  435. $lAdmin->EndPrologContent();
  436. }
  437. break;
  438. default:
  439. break;
  440. }
  441. }
  442. }
  443. $arHeaders = array(
  444. array(
  445. "id" => "SORT",
  446. "content" => GetMessage("CLO_STORAGE_LIST_SORT"),
  447. "align" => "right",
  448. "default" => true,
  449. ),
  450. array(
  451. "id" => "ID",
  452. "content" => GetMessage("CLO_STORAGE_LIST_ID"),
  453. "align" => "right",
  454. "default" => true,
  455. ),
  456. array(
  457. "id" => "ACTIVE",
  458. "content" => GetMessage("CLO_STORAGE_LIST_ACTIVE"),
  459. "align" => "center",
  460. "default" => true,
  461. ),
  462. array(
  463. "id" => "FILE_COUNT",
  464. "content" => GetMessage("CLO_STORAGE_LIST_FILE_COUNT"),
  465. "align" => "right",
  466. "default" => true,
  467. ),
  468. array(
  469. "id" => "FILE_SIZE",
  470. "content" => GetMessage("CLO_STORAGE_LIST_FILE_SIZE"),
  471. "align" => "right",
  472. "default" => true,
  473. ),
  474. array(
  475. "id" => "READ_ONLY",
  476. "content" => GetMessage("CLO_STORAGE_LIST_MODE"),
  477. "align" => "center",
  478. "default" => true,
  479. ),
  480. array(
  481. "id" => "SERVICE",
  482. "content" => GetMessage("CLO_STORAGE_LIST_SERVICE"),
  483. "default" => true,
  484. ),
  485. array(
  486. "id" => "BUCKET",
  487. "content" => GetMessage("CLO_STORAGE_LIST_BUCKET"),
  488. "align" => "center",
  489. "default" => true,
  490. ),
  491. );
  492. $lAdmin->AddHeaders($arHeaders);
  493. $rsData = CCloudStorageBucket::GetList(array("SORT"=>"DESC", "ID"=>"ASC"));
  494. $rsData = new CAdminResult($rsData, $sTableID);
  495. while(is_array($arRes = $rsData->Fetch()))
  496. {
  497. $row =& $lAdmin->AddRow($arRes["ID"], $arRes);
  498. $row->AddViewField("ID", '<a href="clouds_storage_edit.php?lang='.LANGUAGE_ID.'&ID='.$arRes["ID"].'">'.$arRes["ID"].'</a>');
  499. if($arRes["ACTIVE"] === "Y")
  500. $html = '<div class="lamp-green"></div>';
  501. else
  502. $html = '<div class="lamp-red"></div>';
  503. $row->AddViewField("ACTIVE", $html);
  504. $row->AddViewField("READ_ONLY", $arRes["READ_ONLY"]==="Y"? GetMessage("CLO_STORAGE_LIST_READ_ONLY"): GetMessage("CLO_STORAGE_LIST_READ_WRITE"));
  505. $row->AddViewField("SERVICE", CCloudStorage::GetServiceDescription($arRes["SERVICE_ID"]));
  506. $row->AddViewField("FILE_SIZE", CFile::FormatSize($arRes["FILE_SIZE"]));
  507. $arActions = array(
  508. array(
  509. "ICON" => "edit",
  510. "DEFAULT" => true,
  511. "TEXT" => GetMessage("CLO_STORAGE_LIST_EDIT"),
  512. "ACTION" => $lAdmin->ActionRedirect('clouds_storage_edit.php?lang='.LANGUAGE_ID.'&ID='.$arRes["ID"])
  513. )
  514. );
  515. $arActions[] = array("SEPARATOR"=>"Y");
  516. if($arRes["ACTIVE"] === "Y")
  517. {
  518. if($arRes["READ_ONLY"] !== "Y")
  519. {
  520. if(intval($arRes["LAST_FILE_ID"]) > 0)
  521. {
  522. $arActions[] = array(
  523. "TEXT"=>GetMessage("CLO_STORAGE_LIST_CONT_MOVE_FILES"),
  524. "ACTION"=>$lAdmin->ActionDoGroup($arRes["ID"], "move")
  525. );
  526. }
  527. else
  528. {
  529. $arActions[] = array(
  530. "TEXT"=>GetMessage("CLO_STORAGE_LIST_START_MOVE_FILES"),
  531. "ACTION"=>$lAdmin->ActionDoGroup($arRes["ID"], "move")
  532. );
  533. }
  534. }
  535. if($bHasLocalStorage)
  536. {
  537. $arActions[] = array(
  538. "TEXT"=>GetMessage("CLO_STORAGE_LIST_MOVE_LOCAL"),
  539. "ACTION"=>"if(confirm('".GetMessage("CLO_STORAGE_LIST_MOVE_LOCAL_CONF")."')) ".$lAdmin->ActionDoGroup($arRes["ID"], "download")
  540. );
  541. }
  542. $arActions[] = array(
  543. "TEXT"=>GetMessage("CLO_STORAGE_ESTIMATE_DUPLICATES"),
  544. "ACTION"=>$lAdmin->ActionDoGroup($arRes["ID"], "estimate_duplicates")
  545. );
  546. $arActions[] = array(
  547. "TEXT"=>GetMessage("CLO_STORAGE_LIST_DEACTIVATE"),
  548. "ACTION"=>"if(confirm('".GetMessage("CLO_STORAGE_LIST_DEACTIVATE_CONF")."')) ".$lAdmin->ActionDoGroup($arRes["ID"], "deactivate")
  549. );
  550. }
  551. else
  552. {
  553. $arActions[] = array(
  554. "TEXT"=>GetMessage("CLO_STORAGE_LIST_ACTIVATE"),
  555. "ACTION"=>$lAdmin->ActionDoGroup($arRes["ID"], "activate")
  556. );
  557. }
  558. if(intval($arRes["B_FILE_COUNT"]) > 0)
  559. {
  560. $arActions[] = array(
  561. "ICON"=>"delete",
  562. "TEXT"=>GetMessage("CLO_STORAGE_LIST_DELETE"),
  563. "ACTION"=>"alert('".GetMessage("CLO_STORAGE_LIST_CANNOT_DELETE")."')"
  564. );
  565. }
  566. else
  567. {
  568. $arActions[] = array(
  569. "ICON"=>"delete",
  570. "TEXT"=>GetMessage("CLO_STORAGE_LIST_DELETE"),
  571. "ACTION"=>"if(confirm('".GetMessage("CLO_STORAGE_LIST_DELETE_CONF")."')) ".$lAdmin->ActionDoGroup($arRes["ID"], "delete")
  572. );
  573. }
  574. if(!empty($arActions) && !$bOnTheMove)
  575. $row->AddActions($arActions);
  576. }
  577. $arFooter = array(
  578. array(
  579. "title" => GetMessage("MAIN_ADMIN_LIST_SELECTED"),
  580. "value" => $rsData->SelectedRowsCount(),
  581. ),
  582. array(
  583. "counter" => true,
  584. "title" => GetMessage("MAIN_ADMIN_LIST_CHECKED"),
  585. "value" => 0,
  586. ),
  587. );
  588. $lAdmin->AddFooter($arFooter);
  589. $aContext = array(
  590. array(
  591. "TEXT" => GetMessage("CLO_STORAGE_LIST_ADD"),
  592. "LINK" => "/bitrix/admin/clouds_storage_edit.php?lang=".LANGUAGE_ID,
  593. "TITLE" => GetMessage("CLO_STORAGE_LIST_ADD_TITLE"),
  594. "ICON" => "btn_new",
  595. ),
  596. );
  597. $lAdmin->AddAdminContextMenu($aContext, /*$bShowExcel=*/false);
  598. $lAdmin->CheckListMode();
  599. $APPLICATION->SetTitle(GetMessage("CLO_STORAGE_LIST_TITLE"));
  600. require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");
  601. $lAdmin->DisplayList();
  602. require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php");
  603. ?>