PageRenderTime 26ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/catalog/admin/menu.php

https://gitlab.com/alexprowars/bitrix
PHP | 337 lines | 304 code | 32 blank | 1 comment | 58 complexity | 0293e5bf3be5554b2dbbc12315bc9282 MD5 | raw file
  1. <?
  2. use Bitrix\Main\ModuleManager,
  3. Bitrix\Main\Loader,
  4. Bitrix\Catalog;
  5. if (ModuleManager::isModuleInstalled('sale'))
  6. return false;
  7. if (!Loader::includeModule('catalog'))
  8. return false;
  9. IncludeModuleLangFile(__FILE__);
  10. $boolRead = $USER->CanDoOperation('catalog_read');
  11. $boolDiscount = $USER->CanDoOperation('catalog_discount');
  12. $boolStore = $USER->CanDoOperation('catalog_store');
  13. $boolGroup = $USER->CanDoOperation('catalog_group');
  14. $boolPrice = $USER->CanDoOperation('catalog_price');
  15. $boolVat = $USER->CanDoOperation('catalog_vat');
  16. $boolMeasure = $USER->CanDoOperation('catalog_measure');
  17. $boolExportEdit = $USER->CanDoOperation('catalog_export_edit');
  18. $boolExportExec = $USER->CanDoOperation('catalog_export_exec');
  19. $boolImportEdit = $USER->CanDoOperation('catalog_import_edit');
  20. $boolImportExec = $USER->CanDoOperation('catalog_import_exec');
  21. global $adminMenu;
  22. if (!function_exists("__get_export_profiles"))
  23. {
  24. function __get_export_profiles($strItemID)
  25. {
  26. // this code is copy CCatalogAdmin::OnBuildSaleExportMenu
  27. global $USER;
  28. global $adminMenu;
  29. if (!isset($USER) || !(($USER instanceof CUser) && ('CUser' == get_class($USER))))
  30. return array();
  31. if (empty($strItemID))
  32. return array();
  33. $boolRead = $USER->CanDoOperation('catalog_read');
  34. $boolExportEdit = $USER->CanDoOperation('catalog_export_edit');
  35. $boolExportExec = $USER->CanDoOperation('catalog_export_exec');
  36. $arProfileList = array();
  37. if (($boolRead || $boolExportEdit || $boolExportExec) && method_exists($adminMenu, "IsSectionActive"))
  38. {
  39. if ($adminMenu->IsSectionActive($strItemID))
  40. {
  41. $rsProfiles = CCatalogExport::GetList(array("NAME"=>"ASC", "ID"=>"ASC"), array("IN_MENU"=>"Y"));
  42. while ($arProfile = $rsProfiles->Fetch())
  43. {
  44. $strName = ($arProfile["NAME"] <> '' ? $arProfile["NAME"] : $arProfile["FILE_NAME"]);
  45. if ('Y' == $arProfile['DEFAULT_PROFILE'])
  46. {
  47. $arProfileList[] = array(
  48. "text" => htmlspecialcharsbx($strName),
  49. "url" => "cat_exec_exp.php?lang=".LANGUAGE_ID."&ACT_FILE=".$arProfile["FILE_NAME"]."&ACTION=EXPORT&PROFILE_ID=".$arProfile["ID"]."&".bitrix_sessid_get(),
  50. "title" => GetMessage("CAM_EXPORT_DESCR_EXPORT")." &quot;".htmlspecialcharsbx($strName)."&quot;",
  51. "readonly" => !$boolExportExec,
  52. );
  53. }
  54. else
  55. {
  56. $arProfileList[] = array(
  57. "text" => htmlspecialcharsbx($strName),
  58. "url" => "cat_export_setup.php?lang=".LANGUAGE_ID."&ACT_FILE=".$arProfile["FILE_NAME"]."&ACTION=EXPORT_EDIT&PROFILE_ID=".$arProfile["ID"]."&".bitrix_sessid_get(),
  59. "title"=>GetMessage("CAM_EXPORT_DESCR_EDIT")." &quot;".htmlspecialcharsbx($strName)."&quot;",
  60. "readonly" => !$boolExportEdit,
  61. );
  62. }
  63. }
  64. }
  65. }
  66. return $arProfileList;
  67. }
  68. }
  69. if (!function_exists("__get_import_profiles"))
  70. {
  71. function __get_import_profiles($strItemID)
  72. {
  73. global $USER;
  74. global $adminMenu;
  75. if (!isset($USER) || !(($USER instanceof CUser) && ('CUser' == get_class($USER))))
  76. return array();
  77. if (empty($strItemID))
  78. return array();
  79. $boolRead = $USER->CanDoOperation('catalog_read');
  80. $boolImportEdit = $USER->CanDoOperation('catalog_import_edit');
  81. $boolImportExec = $USER->CanDoOperation('catalog_import_exec');
  82. $arProfileList = array();
  83. if (($boolRead || $boolImportEdit || $boolImportExec) && method_exists($adminMenu, "IsSectionActive"))
  84. {
  85. if ($adminMenu->IsSectionActive($strItemID))
  86. {
  87. $rsProfiles = CCatalogImport::GetList(array("NAME"=>"ASC", "ID"=>"ASC"), array("IN_MENU"=>"Y"));
  88. while ($arProfile = $rsProfiles->Fetch())
  89. {
  90. $strName = ($arProfile["NAME"] <> '' ? $arProfile["NAME"] : $arProfile["FILE_NAME"]);
  91. if ('Y' == $arProfile['DEFAULT_PROFILE'])
  92. {
  93. $arProfileList[] = array(
  94. "text" => htmlspecialcharsbx($strName),
  95. "url" => "cat_exec_imp.php?lang=".LANGUAGE_ID."&ACT_FILE=".$arProfile["FILE_NAME"]."&ACTION=IMPORT&PROFILE_ID=".$arProfile["ID"]."&".bitrix_sessid_get(),
  96. "title" => GetMessage("CAM_IMPORT_DESCR_IMPORT")." &quot;".htmlspecialcharsbx($strName)."&quot;",
  97. "readonly" => !$boolImportExec,
  98. );
  99. }
  100. else
  101. {
  102. $arProfileList[] = array(
  103. "text" => htmlspecialcharsbx($strName),
  104. "url" => "cat_import_setup.php?lang=".LANGUAGE_ID."&ACT_FILE=".$arProfile["FILE_NAME"]."&ACTION=IMPORT_EDIT&PROFILE_ID=".$arProfile["ID"]."&".bitrix_sessid_get(),
  105. "title" => GetMessage("CAM_IMPORT_DESCR_EDIT")." &quot;".htmlspecialcharsbx($strName)."&quot;",
  106. "readonly" => !$boolImportEdit,
  107. );
  108. }
  109. }
  110. }
  111. }
  112. return $arProfileList;
  113. }
  114. }
  115. $arSubItems = array();
  116. if ($boolRead || $boolDiscount)
  117. {
  118. $dscItems = array();
  119. $dscItems[] = array(
  120. "text" => GetMessage("CM_DISCOUNTS2"),
  121. "url" => "cat_discount_admin.php?lang=".LANGUAGE_ID,
  122. "more_url" => array("cat_discount_edit.php"),
  123. "title" => GetMessage("CM_DISCOUNTS_ALT2"),
  124. "readonly" => !$boolDiscount,
  125. "items_id" => "cat_discount_admin",
  126. );
  127. $dscItems[] = array(
  128. "text" => GetMessage("CM_COUPONS"),
  129. "url" => "cat_discount_coupon.php?lang=".LANGUAGE_ID,
  130. "more_url" => array("cat_discount_coupon_edit.php"),
  131. "title" => GetMessage("CM_COUPONS_ALT"),
  132. "readonly" => !$boolDiscount,
  133. "items_id" => "cat_discount_coupon",
  134. );
  135. $arSubItems[] = array(
  136. "text" => GetMessage("CM_DISCOUNTS"),
  137. "more_url" => array("cat_discount_edit.php", "cat_discount_coupon.php", "cat_discount_coupon_edit.php"),
  138. "title" => GetMessage("CM_DISCOUNTS_ALT"),
  139. "dynamic" => false,
  140. "module_id" => "catalog",
  141. "items_id" => "mnu_catalog_discount",
  142. "readonly" => !$boolDiscount,
  143. "page_icon" => "catalog_page_icon",
  144. "items" => $dscItems,
  145. );
  146. if (Catalog\Config\Feature::isCumulativeDiscountsEnabled())
  147. {
  148. $arSubItems[] = array(
  149. "text" => GetMessage("CAT_DISCOUNT_SAVE"),
  150. "url" => "cat_discsave_admin.php?lang=".LANGUAGE_ID,
  151. "more_url" => array("cat_discsave_edit.php"),
  152. "title" => GetMessage("CAT_DISCOUNT_SAVE_DESCR"),
  153. "readonly" => !$boolDiscount,
  154. "items_id" => "cat_discsave_admin",
  155. );
  156. }
  157. }
  158. if ($boolRead || $boolStore)
  159. {
  160. if ($boolStore && Catalog\Config\State::isUsedInventoryManagement())
  161. {
  162. $arSubItems[] = array(
  163. "text" => GetMessage("CM_STORE_DOCS"),
  164. "url" => "cat_store_document_list.php?lang=".LANGUAGE_ID,
  165. "more_url" => array("cat_store_document_edit.php"),
  166. "title" => GetMessage("CM_STORE_DOCS"),
  167. "readonly" => !$boolStore,
  168. "items_id" => "cat_store_document_list",
  169. );
  170. $arSubItems[] = array(
  171. "text" => GetMessage("CM_CONTRACTORS"),
  172. "url" => "cat_contractor_list.php?lang=".LANGUAGE_ID,
  173. "more_url" => array("cat_contractor_edit.php"),
  174. "title" => GetMessage("CM_CONTRACTORS"),
  175. "readonly" => !$boolStore,
  176. "items_id" => "cat_contractor_list",
  177. );
  178. }
  179. $arSubItems[] = array(
  180. "text" => GetMessage("CM_STORE"),
  181. "url" => "cat_store_list.php?lang=".LANGUAGE_ID,
  182. "more_url" => array("cat_store_edit.php"),
  183. "title" => GetMessage("CM_STORE"),
  184. "readonly" => !$boolStore,
  185. "items_id" => "cat_store_list",
  186. );
  187. }
  188. if ($boolRead || $boolMeasure)
  189. {
  190. $arSubItems[] = array(
  191. "text" => GetMessage("MEASURE"),
  192. "url" => "cat_measure_list.php?lang=".LANGUAGE_ID,
  193. "more_url" => array("cat_measure_edit.php"),
  194. "title" => GetMessage("MEASURE_ALT"),
  195. "readonly" => !$boolMeasure,
  196. "items_id" => "cat_measure_list",
  197. );
  198. }
  199. $showPrices = $boolRead || $boolGroup;
  200. $showExtra = (Catalog\Config\Feature::isMultiPriceTypesEnabled() && ($boolRead || $boolPrice));
  201. if ($showPrices || $showExtra)
  202. {
  203. $section = array(
  204. 'text' => GetMessage('PRICES_SECTION'),
  205. 'title' => GetMessage('PRICES_SECTION_TITLE'),
  206. "url" => "cat_group_admin.php?lang=".LANGUAGE_ID,
  207. 'items_id' => 'menu_catalog_prices',
  208. 'items' => array()
  209. );
  210. if ($showPrices)
  211. {
  212. $section['items'][] = array(
  213. "text" => GetMessage("GROUP"),
  214. "title" => GetMessage("GROUP_ALT"),
  215. "url" => "cat_group_admin.php?lang=".LANGUAGE_ID,
  216. "more_url" => array("cat_group_edit.php"),
  217. "readonly" => !$boolGroup,
  218. "items_id" => "cat_group_admin",
  219. );
  220. $section['items'][] = array(
  221. 'text' => GetMessage('PRICE_ROUND'),
  222. 'title' => GetMessage('PRICE_ROUND_TITLE'),
  223. 'url' => 'cat_round_list.php?lang='.LANGUAGE_ID,
  224. 'more_url' => array('cat_round_edit.php'),
  225. 'readonly' => !$boolGroup,
  226. "items_id" => "cat_round_list",
  227. );
  228. }
  229. if ($showExtra)
  230. {
  231. $section['items'][] = array(
  232. "text" => GetMessage("EXTRA"),
  233. "title" => GetMessage("EXTRA_ALT"),
  234. "url" => "cat_extra.php?lang=".LANGUAGE_ID,
  235. "more_url" => array("cat_extra_edit.php"),
  236. "readonly" => !$boolPrice,
  237. "items_id" => "cat_extra",
  238. );
  239. }
  240. $arSubItems[] = $section;
  241. unset($section);
  242. }
  243. unset($showExtra, $showPrices);
  244. if ($boolRead || $boolVat)
  245. {
  246. $arSubItems[] = array(
  247. "text" => GetMessage("VAT"),
  248. "url" => "cat_vat_admin.php?lang=".LANGUAGE_ID,
  249. "more_url" => array("cat_vat_edit.php"),
  250. "title" => GetMessage("VAT_ALT"),
  251. "readonly" => !$boolVat,
  252. "items_id" => "cat_vat_admin",
  253. );
  254. }
  255. if ($boolRead || $boolExportEdit || $boolExportExec)
  256. {
  257. $arSubItems[] = array(
  258. "text" => GetMessage("SETUP_UNLOAD_DATA"),
  259. "url" => "cat_export_setup.php?lang=".LANGUAGE_ID,
  260. "more_url" => array("cat_exec_exp.php"),
  261. "title" => GetMessage("SETUP_UNLOAD_DATA_ALT"),
  262. "dynamic" => true,
  263. "module_id" => "catalog",
  264. "items_id" => "mnu_catalog_exp",
  265. "readonly" => !$boolExportEdit && !$boolExportExec,
  266. "items" => __get_export_profiles("mnu_catalog_exp"),
  267. );
  268. }
  269. if ($boolRead || $boolImportEdit || $boolImportExec)
  270. {
  271. $arSubItems[] = array(
  272. "text" => GetMessage("SETUP_LOAD_DATA"),
  273. "url" => "cat_import_setup.php?lang=".LANGUAGE_ID,
  274. "more_url" => array("cat_exec_imp.php"),
  275. "title" => GetMessage("SETUP_LOAD_DATA_ALT"),
  276. "dynamic" => true,
  277. "module_id" => "catalog",
  278. "items_id" => "mnu_catalog_imp",
  279. "readonly" => !$boolImportEdit && !$boolImportExec,
  280. "items" => __get_import_profiles("mnu_catalog_imp"),
  281. );
  282. }
  283. if ($boolRead)
  284. {
  285. $arSubItems[] = array(
  286. "text" => GetMessage("SUBSCRIPTION_PRODUCT"),
  287. "url" => "cat_subscription_list.php?lang=".LANGUAGE_ID,
  288. "more_url" => array("cat_subscription_list.php"),
  289. "title" => GetMessage("SUBSCRIPTION_PRODUCT"),
  290. "items_id" => "cat_subscription_list",
  291. );
  292. }
  293. if (empty($arSubItems))
  294. return false;
  295. return array(
  296. "parent_menu" => "global_menu_store",
  297. "section" => "catalog",
  298. "sort" => 200,
  299. "text" => GetMessage("CATALOG_CONTROL"),
  300. "title" => GetMessage("CATALOG_MNU_TITLE"),
  301. "icon" => "trade_catalog_menu_icon",
  302. "page_icon" => "catalog_page_icon",
  303. "items_id" => "mnu_catalog",
  304. "items" => $arSubItems,
  305. );