BxBaseStudioPermissionsLevels.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaView UNA Studio Representation classes
  7. * @ingroup UnaStudio
  8. * @{
  9. */
  10. class BxBaseStudioPermissionsLevels extends BxDolStudioPermissionsLevels
  11. {
  12. public static $iBinMB = 1048576;
  13. protected $sUrlPage;
  14. function __construct($aOptions, $oTemplate = false)
  15. {
  16. parent::__construct($aOptions, $oTemplate);
  17. $this->_aOptions['actions_single']['edit']['attr']['title'] = _t('_adm_prm_btn_level_edit');
  18. $this->_aOptions['actions_single']['delete']['attr']['title'] = _t('_adm_prm_btn_level_delete');
  19. $this->sUrlPage = BX_DOL_URL_STUDIO . 'builder_permissions.php?page=levels';
  20. }
  21. public function performActionAdd()
  22. {
  23. $sAction = 'add';
  24. $oForm = $this->_getFormObject($sAction);
  25. $oForm->initChecker();
  26. if($oForm->isSubmittedAndValid()) {
  27. if(($iId = $this->_getAvailableId()) === false) {
  28. echoJson(array('msg' => _t('_adm_prm_err_level_id')));
  29. return;
  30. }
  31. $mixedIcon = '';
  32. if(!empty($_FILES['Icon_image']['tmp_name'])) {
  33. $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
  34. $mixedIcon = $oStorage->storeFileFromForm($_FILES['Icon_image'], false, 0);
  35. if($mixedIcon === false) {
  36. echoJson(array('msg' => _t('_adm_prm_err_level_icon_image') . $oStorage->getErrorString()));
  37. return;
  38. }
  39. $oStorage->afterUploadCleanup($mixedIcon, 0);
  40. }
  41. if(empty($mixedIcon))
  42. $mixedIcon = $oForm->getCleanValue('Icon');
  43. if(empty($mixedIcon))
  44. $mixedIcon = 'acl-unconfirmed.png';
  45. BxDolForm::setSubmittedValue('Icon', $mixedIcon, $oForm->aFormAttrs['method']);
  46. $fQuotaSize = round($oForm->getCleanValue('QuotaSize'), 1);
  47. BxDolForm::setSubmittedValue('QuotaSize', self::$iBinMB * $fQuotaSize, $oForm->aFormAttrs['method']);
  48. $fQuotaMaxFileSize = round($oForm->getCleanValue('QuotaMaxFileSize'), 1);
  49. BxDolForm::setSubmittedValue('QuotaMaxFileSize', self::$iBinMB * $fQuotaMaxFileSize, $oForm->aFormAttrs['method']);
  50. $iId = (int)$oForm->insert(array('ID' => $iId, 'Icon' => $mixedIcon, 'Order' => $this->oDb->getLevelOrderMax() + 1));
  51. if($iId != 0) {
  52. $iActionsFrom = (int)$oForm->getCleanValue('Actions');
  53. if($iActionsFrom > 0) {
  54. $aActions = array();
  55. $this->oDb->getActions(array('type' => 'by_level_id', 'value' => $iActionsFrom), $aActions, false);
  56. foreach($aActions as $aAction)
  57. $this->oDb->switchAction($iId, $aAction['id'], true, array(
  58. 'AllowedCount' => $aAction['allowed_count'],
  59. 'AllowedPeriodLen' => $aAction['allowed_period_len'],
  60. 'AllowedPeriodStart' => $aAction['allowed_period_start'],
  61. 'AllowedPeriodEnd' => $aAction['allowed_period_end'],
  62. 'AdditionalParamValue' => $aAction['additional_param_value']
  63. ));
  64. }
  65. $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
  66. }
  67. else
  68. $aRes = array('msg' => _t('_adm_prm_err_level_create'));
  69. echoJson($aRes);
  70. }
  71. else {
  72. $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-prm-level-create-popup', _t('_adm_prm_txt_level_create_popup'), $this->_oTemplate->parseHtmlByName('prm_add_level.html', array(
  73. 'form_id' => $oForm->aFormAttrs['id'],
  74. 'form' => $oForm->getCode(true),
  75. 'object' => $this->_sObject,
  76. 'action' => $sAction
  77. )));
  78. echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))));
  79. }
  80. }
  81. public function performActionEdit()
  82. {
  83. $sAction = 'edit';
  84. $aIds = bx_get('ids');
  85. if(!$aIds || !is_array($aIds)) {
  86. $iId = (int)bx_get('id');
  87. if(!$iId) {
  88. echoJson(array());
  89. exit;
  90. }
  91. $aIds = array($iId);
  92. }
  93. $iId = $aIds[0];
  94. $aLevel = array();
  95. $iLevel = $this->oDb->getLevels(array('type' => 'by_id', 'value' => $iId), $aLevel);
  96. if($iLevel != 1 || empty($aLevel)){
  97. echoJson(array());
  98. exit;
  99. }
  100. $oForm = $this->_getFormObject($sAction, $aLevel);
  101. $oForm->initChecker();
  102. if($oForm->isSubmittedAndValid()) {
  103. $bIconImageCur = is_numeric($aLevel['icon']) && (int)$aLevel['icon'] != 0;
  104. $bIconImageNew = !empty($_FILES['Icon_image']['tmp_name']);
  105. $sIconFont = $oForm->getCleanValue('Icon');
  106. $bIconFont = !empty($sIconFont);
  107. if($bIconImageCur && ($bIconImageNew || $bIconFont)) {
  108. $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
  109. if(!$oStorage->deleteFile((int)$aLevel['icon'], 0)) {
  110. echoJson(array('msg' => _t('_adm_prm_err_level_icon_image_remove')));
  111. return;
  112. }
  113. }
  114. $sIcon = $sIconFont;
  115. if($bIconImageNew) {
  116. $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
  117. $sIcon = $oStorage->storeFileFromForm($_FILES['Icon_image'], false, 0);
  118. if($sIcon === false) {
  119. echoJson(array('msg' => _t('_adm_prm_err_level_icon_image') . $oStorage->getErrorString()));
  120. return;
  121. }
  122. $oStorage->afterUploadCleanup($sIcon, 0);
  123. } else if($bIconImageCur && !$bIconFont)
  124. $sIcon = $aLevel['icon'];
  125. BxDolForm::setSubmittedValue('Icon', $sIcon, $oForm->aFormAttrs['method']);
  126. $fQuotaSize = round($oForm->getCleanValue('QuotaSize'), 1);
  127. BxDolForm::setSubmittedValue('QuotaSize', self::$iBinMB * $fQuotaSize, $oForm->aFormAttrs['method']);
  128. $fQuotaMaxFileSize = round($oForm->getCleanValue('QuotaMaxFileSize'), 1);
  129. BxDolForm::setSubmittedValue('QuotaMaxFileSize', self::$iBinMB * $fQuotaMaxFileSize, $oForm->aFormAttrs['method']);
  130. if($oForm->update($iId) !== false)
  131. $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
  132. else
  133. $aRes = array('msg' => _t('_adm_prm_err_level_edit'));
  134. echoJson($aRes);
  135. }
  136. else {
  137. $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-prm-level-edit-popup', _t('_adm_prm_txt_level_edit_popup', _t($aLevel['name'])), $this->_oTemplate->parseHtmlByName('prm_add_level.html', array(
  138. 'form_id' => $oForm->aFormAttrs['id'],
  139. 'form' => $oForm->getCode(true),
  140. 'object' => $this->_sObject,
  141. 'action' => $sAction
  142. )));
  143. echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))));
  144. }
  145. }
  146. public function performActionDelete()
  147. {
  148. $iAffected = 0;
  149. $aIds = bx_get('ids');
  150. if(!$aIds || !is_array($aIds)) {
  151. echoJson(array());
  152. exit;
  153. }
  154. $aIdsAffected = array ();
  155. foreach($aIds as $iId) {
  156. if(!$this->delete($iId))
  157. continue;
  158. $aIdsAffected[] = $iId;
  159. $iAffected++;
  160. }
  161. echoJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_adm_prm_err_level_delete')));
  162. }
  163. public function performActionDeleteIcon()
  164. {
  165. $sAction = 'delete_icon';
  166. $aIds = bx_get('ids');
  167. if(empty($aIds[0])) {
  168. echoJson(array());
  169. exit;
  170. }
  171. $iId = (int)$aIds[0];
  172. $aLevel = array();
  173. $iLevel = $this->oDb->getLevels(array('type' => 'by_id', 'value' => $iId), $aLevel);
  174. if($iLevel != 1 || empty($aLevel)){
  175. echoJson(array());
  176. exit;
  177. }
  178. if(is_numeric($aLevel['icon']) && (int)$aLevel['icon'] != 0)
  179. if(!BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->deleteFile((int)$aLevel['icon'], 0)) {
  180. echoJson(array());
  181. exit;
  182. }
  183. if($this->oDb->updateLevels($aLevel['id'], array('icon' => '')) !== false)
  184. echoJson(array('grid' => $this->getCode(false), 'blink' => $iId, 'preview' => $this->_getIconPreview($aLevel['id']), 'eval' => $this->getJsObject() . ".onDeleteIcon(oData)"));
  185. }
  186. public function getJsObject()
  187. {
  188. return 'oBxDolStudioPermissionsLevels';
  189. }
  190. public function getCode($isDisplayHeader = true)
  191. {
  192. return $this->_oTemplate->parseHtmlByName('prm_levels.html', array(
  193. 'content' => parent::getCode($isDisplayHeader),
  194. 'js_object' => $this->getJsObject(),
  195. 'page_url' => $this->sUrlPage,
  196. 'grid_object' => $this->_sObject,
  197. 'params_divider' => $this->sParamsDivider
  198. ));
  199. }
  200. protected function _addJsCss()
  201. {
  202. parent::_addJsCss();
  203. $this->_oTemplate->addJs(array('jquery.form.min.js', 'permissions_levels.js'));
  204. $oForm = new BxTemplStudioFormView(array());
  205. $oForm->addCssJs();
  206. }
  207. protected function _getCellSwitcher ($mixedValue, $sKey, $aField, $aRow)
  208. {
  209. if(in_array($aRow['ID'], array(MEMBERSHIP_ID_NON_MEMBER, MEMBERSHIP_ID_ACCOUNT, MEMBERSHIP_ID_STANDARD, MEMBERSHIP_ID_UNCONFIRMED, MEMBERSHIP_ID_PENDING, MEMBERSHIP_ID_SUSPENDED)))
  210. return parent::_getCellDefault('', $sKey, $aField, $aRow);;
  211. return parent::_getCellSwitcher($mixedValue, $sKey, $aField, $aRow);
  212. }
  213. protected function _getCellIcon ($mixedValue, $sKey, $aField, $aRow)
  214. {
  215. $mixedValue = $this->_oTemplate->getImage($mixedValue, array('class' => 'bx-prm-level-icon'));
  216. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  217. }
  218. protected function _getCellActionsList ($mixedValue, $sKey, $aField, $aRow)
  219. {
  220. $aActions = array();
  221. $iActions = $this->oDb->getActions(array('type' => 'by_level_id', 'value' => $aRow['ID']), $aActions);
  222. $sLink = BX_DOL_URL_STUDIO . 'builder_permissions.php?page=actions&level=' . $aRow['ID'];
  223. $mixedValue = $this->_oTemplate->parseLink($sLink, _t('_adm_prm_txt_n_actions', $iActions), array(
  224. 'title' => _t('_adm_prm_txt_manage_actions')
  225. ));
  226. return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
  227. }
  228. protected function _getCellQuotaSize ($mixedValue, $sKey, $aField, $aRow)
  229. {
  230. return parent::_getCellDefault ($mixedValue > 0 ? _t_format_size($mixedValue) : '&infin;', $sKey, $aField, $aRow);
  231. }
  232. protected function _getCellQuotaNumber ($mixedValue, $sKey, $aField, $aRow)
  233. {
  234. return parent::_getCellDefault ($mixedValue > 0 ? $mixedValue : '&infin;', $sKey, $aField, $aRow);
  235. }
  236. protected function _getCellQuotaMaxFileSize ($mixedValue, $sKey, $aField, $aRow)
  237. {
  238. return parent::_getCellDefault ($mixedValue > 0 ? _t_format_size($mixedValue) : '&infin;', $sKey, $aField, $aRow);
  239. }
  240. protected function _getActionDelete ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  241. {
  242. if ($sType == 'single' && $aRow['Removable'] != 'yes')
  243. return '';
  244. return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
  245. }
  246. protected function _getIconPreview($iId, $sIconImage = '', $sIconFont = '')
  247. {
  248. $bIconImage = !empty($sIconImage);
  249. $bIconFont = !empty($sIconFont);
  250. return $this->_oTemplate->parseHtmlByName('prm_level_icon_preview.html', array(
  251. 'id' => $iId,
  252. 'bx_if:show_icon_empty' => array(
  253. 'condition' => !$bIconImage && !$bIconFont,
  254. 'content' => array()
  255. ),
  256. 'bx_if:show_icon_image' => array(
  257. 'condition' => $bIconImage,
  258. 'content' => array(
  259. 'js_object' => $this->getJsObject(),
  260. 'url' => $sIconImage,
  261. 'id' => $iId
  262. )
  263. ),
  264. 'bx_if:show_icon_font' => array(
  265. 'condition' => $bIconFont,
  266. 'content' => array(
  267. 'icon' => $sIconFont
  268. )
  269. )
  270. ));
  271. }
  272. protected function _getFormObject($sAction, $aLevel = array())
  273. {
  274. bx_import('BxTemplStudioFormView');
  275. $aForm = array(
  276. 'form_attrs' => array(
  277. 'id' => 'adm-prm-level-create',
  278. 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction,
  279. 'method' => BX_DOL_STUDIO_METHOD_DEFAULT,
  280. 'enctype' => 'multipart/form-data',
  281. ),
  282. 'params' => array (
  283. 'db' => array(
  284. 'table' => 'sys_acl_levels',
  285. 'key' => 'ID',
  286. 'uri' => '',
  287. 'uri_title' => '',
  288. 'submit_name' => 'do_submit'
  289. ),
  290. ),
  291. 'inputs' => array (
  292. 'id' => array(
  293. 'type' => 'hidden',
  294. 'name' => 'id',
  295. 'value' => isset($aLevel['id']) ? (int)$aLevel['id'] : 0,
  296. 'db' => array (
  297. 'pass' => 'Int',
  298. ),
  299. ),
  300. 'Active' => array(
  301. 'type' => 'hidden',
  302. 'name' => 'Active',
  303. 'value' => 'yes',
  304. 'db' => array (
  305. 'pass' => 'Xss',
  306. ),
  307. ),
  308. 'Purchasable' => array(
  309. 'type' => 'hidden',
  310. 'name' => 'Purchasable',
  311. 'value' => 'no',
  312. 'db' => array (
  313. 'pass' => 'Xss',
  314. ),
  315. ),
  316. 'Removable' => array(
  317. 'type' => 'hidden',
  318. 'name' => 'Removable',
  319. 'value' => 'yes',
  320. 'db' => array (
  321. 'pass' => 'Xss',
  322. ),
  323. ),
  324. 'Name' => array(
  325. 'type' => 'text_translatable',
  326. 'name' => 'Name',
  327. 'caption' => _t('_adm_prm_txt_level_name'),
  328. 'info' => _t('_adm_prm_dsc_level_name'),
  329. 'value' => '_adm_prm_txt_level',
  330. 'required' => '1',
  331. 'db' => array (
  332. 'pass' => 'Xss',
  333. ),
  334. 'checker' => array (
  335. 'func' => 'LengthTranslatable',
  336. 'params' => array(3, 100, 'Name'),
  337. 'error' => _t('_adm_prm_err_level_name'),
  338. ),
  339. ),
  340. 'Description' => array(
  341. 'type' => 'textarea_translatable',
  342. 'name' => 'Description',
  343. 'caption' => _t('_adm_prm_txt_level_description'),
  344. 'info' => _t('_adm_prm_dsc_level_description'),
  345. 'value' => isset($aLevel['description']) ? $aLevel['description'] : '_adm_prm_txt_level',
  346. 'code' => 1,
  347. 'db' => array (
  348. 'pass' => 'XssHtml',
  349. )
  350. ),
  351. 'QuotaSize' => array(
  352. 'type' => 'text',
  353. 'name' => 'QuotaSize',
  354. 'caption' => _t('_adm_prm_txt_level_quota_size'),
  355. 'info' => _t('_adm_prm_dsc_level_quota_size'),
  356. 'value' => isset($aLevel['quota_size']) ? round($aLevel['quota_size'] / self::$iBinMB, 1) : '0',
  357. 'required' => '1',
  358. 'db' => array (
  359. 'pass' => 'Float',
  360. ),
  361. 'checker' => array (
  362. 'func' => 'preg',
  363. 'params' => array('/^[0-9\.]+$/'),
  364. 'error' => _t('_adm_prm_err_level_quota_size'),
  365. ),
  366. ),
  367. 'QuotaMaxFileSize' => array(
  368. 'type' => 'text',
  369. 'name' => 'QuotaMaxFileSize',
  370. 'caption' => _t('_adm_prm_txt_level_quota_max_file_size'),
  371. 'info' => _t('_adm_prm_dsc_level_quota_max_file_size'),
  372. 'value' => isset($aLevel['quota_max_file_size']) ? round($aLevel['quota_max_file_size'] / self::$iBinMB, 1) : '',
  373. 'required' => '1',
  374. 'db' => array (
  375. 'pass' => 'Float',
  376. ),
  377. 'checker' => array (
  378. 'func' => 'preg',
  379. 'params' => array('/^[0-9\.]+$/'),
  380. 'error' => _t('_adm_prm_err_level_quota_max_file_size'),
  381. ),
  382. ),
  383. 'QuotaNumber' => array(
  384. 'type' => 'text',
  385. 'name' => 'QuotaNumber',
  386. 'caption' => _t('_adm_prm_txt_level_quota_number'),
  387. 'info' => _t('_adm_prm_dsc_level_quota_number'),
  388. 'value' => isset($aLevel['quota_number']) ? (int)$aLevel['quota_number'] : '0',
  389. 'required' => '1',
  390. 'db' => array (
  391. 'pass' => 'Int',
  392. ),
  393. 'checker' => array (
  394. 'func' => 'preg',
  395. 'params' => array('/^[0-9]+$/'),
  396. 'error' => _t('_adm_prm_err_level_quota_number'),
  397. ),
  398. ),
  399. 'Icon' => array(
  400. 'type' => 'text',
  401. 'name' => 'Icon',
  402. 'caption' => _t('_adm_prm_txt_level_icon'),
  403. 'info' => _t('_adm_prm_dsc_level_icon'),
  404. 'value' => '',
  405. 'required' => '0',
  406. 'db' => array (
  407. 'pass' => 'Xss',
  408. ),
  409. 'checker' => array (
  410. 'func' => '',
  411. 'params' => array(),
  412. 'error' => _t('_adm_prm_err_level_icon'),
  413. ),
  414. ),
  415. 'Icon_image' => array(
  416. 'type' => 'file',
  417. 'name' => 'Icon_image',
  418. 'caption' => _t('_adm_prm_txt_level_icon_image'),
  419. 'info' => _t('_adm_prm_dsc_level_icon_image'),
  420. 'value' => '',
  421. 'checker' => array (
  422. 'func' => '',
  423. 'params' => '',
  424. 'error' => _t('_adm_prm_err_level_icon_image'),
  425. ),
  426. ),
  427. 'Icon_preview' => array(
  428. 'type' => 'custom',
  429. 'name' => 'Icon_preview',
  430. 'caption' => _t('_adm_prm_txt_level_icon_image_old'),
  431. 'content' => ''
  432. ),
  433. 'Actions' => array(
  434. 'type' => 'select',
  435. 'name' => 'Actions',
  436. 'caption' => _t('_adm_prm_txt_level_actions_copy'),
  437. 'values' => array(
  438. array('key' => 0, 'value' => _t('_sys_txt_empty'))
  439. ),
  440. ),
  441. 'controls' => array(
  442. 'name' => 'controls',
  443. 'type' => 'input_set',
  444. array(
  445. 'type' => 'submit',
  446. 'name' => 'do_submit',
  447. 'value' => _t('_adm_prm_btn_level_add'),
  448. ),
  449. array (
  450. 'type' => 'reset',
  451. 'name' => 'close',
  452. 'value' => _t('_adm_prm_btn_level_cancel'),
  453. 'attrs' => array(
  454. 'onclick' => "$('.bx-popup-applied:visible').dolPopupHide()",
  455. 'class' => 'bx-def-margin-sec-left',
  456. ),
  457. )
  458. )
  459. )
  460. );
  461. $aLevels = array();
  462. $this->oDb->getLevels(array('type' => 'all_pair'), $aLevels, false);
  463. foreach($aLevels as $iId => $sName)
  464. $aForm['inputs']['Actions']['values'][] = array('key' => $iId, 'value' => _t($sName));
  465. switch($sAction) {
  466. case 'add':
  467. unset($aForm['inputs']['id']);
  468. unset($aForm['inputs']['Icon_preview']);
  469. $aForm['form_attrs']['id'] .= 'create';
  470. break;
  471. case 'edit':
  472. unset($aForm['inputs']['Active']);
  473. unset($aForm['inputs']['Purchasable']);
  474. unset($aForm['inputs']['Removable']);
  475. unset($aForm['inputs']['Name']);
  476. unset($aForm['inputs']['Actions']);
  477. $aForm['form_attrs']['id'] .= 'edit';
  478. $aForm['inputs']['Icon_image']['caption'] = _t('_adm_prm_txt_level_icon_image_new');
  479. $aForm['inputs']['controls'][0]['value'] = _t('_adm_prm_btn_level_save');
  480. $sIconImage = $sIconFont = "";
  481. if(!empty($aLevel['icon'])) {
  482. if(is_numeric($aLevel['icon']) && (int)$aLevel['icon'] != 0) {
  483. $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
  484. $sIconImage = $oStorage->getFileUrlById((int)$aLevel['icon']);
  485. } else {
  486. $sIconFont = $aLevel['icon'];
  487. $aForm['inputs']['Icon']['value'] = $sIconFont;
  488. }
  489. }
  490. $aForm['inputs']['Icon_preview']['content'] = $this->_getIconPreview($aLevel['id'], $sIconImage, $sIconFont);
  491. break;
  492. }
  493. return new BxTemplStudioFormView($aForm);
  494. }
  495. protected function _getAvailableId()
  496. {
  497. $aLevels = array();
  498. $this->oDb->getLevels(array('type' =>'all_order_id'), $aLevels, false);
  499. $iId = 1;
  500. foreach($aLevels as $aLevel) {
  501. if($iId != (int)$aLevel['id'])
  502. break;
  503. $iId++;
  504. }
  505. return $iId <= BX_DOL_STUDIO_PERMISSIONS_LEVEL_ID_INT_MAX ? $iId : false;
  506. }
  507. }
  508. /** @} */