BxBaseStudioPermissionsLevels.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup TridentView Trident Studio Representation classes
  7. * @ingroup TridentStudio
  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 bx-def-border'));
  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. $mixedValue = $this->_oTemplate->parseHtmlByName('bx_a.html', array(
  223. 'href' => BX_DOL_URL_STUDIO . 'builder_permissions.php?page=actions&level=' . $aRow['ID'],
  224. 'title' => _t('_adm_prm_txt_manage_actions'),
  225. 'bx_repeat:attrs' => array(),
  226. 'content' => _t('_adm_prm_txt_n_actions', $iActions)
  227. ));
  228. return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
  229. }
  230. protected function _getCellQuotaSize ($mixedValue, $sKey, $aField, $aRow)
  231. {
  232. return parent::_getCellDefault ($mixedValue > 0 ? _t_format_size($mixedValue) : '&infin;', $sKey, $aField, $aRow);
  233. }
  234. protected function _getCellQuotaNumber ($mixedValue, $sKey, $aField, $aRow)
  235. {
  236. return parent::_getCellDefault ($mixedValue > 0 ? $mixedValue : '&infin;', $sKey, $aField, $aRow);
  237. }
  238. protected function _getCellQuotaMaxFileSize ($mixedValue, $sKey, $aField, $aRow)
  239. {
  240. return parent::_getCellDefault ($mixedValue > 0 ? _t_format_size($mixedValue) : '&infin;', $sKey, $aField, $aRow);
  241. }
  242. protected function _getActionDelete ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  243. {
  244. if ($sType == 'single' && $aRow['Removable'] != 'yes')
  245. return '';
  246. return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
  247. }
  248. protected function _getIconPreview($iId, $sIconImage = '', $sIconFont = '')
  249. {
  250. $bIconImage = !empty($sIconImage);
  251. $bIconFont = !empty($sIconFont);
  252. return $this->_oTemplate->parseHtmlByName('prm_level_icon_preview.html', array(
  253. 'id' => $iId,
  254. 'bx_if:show_icon_empty' => array(
  255. 'condition' => !$bIconImage && !$bIconFont,
  256. 'content' => array()
  257. ),
  258. 'bx_if:show_icon_image' => array(
  259. 'condition' => $bIconImage,
  260. 'content' => array(
  261. 'js_object' => $this->getJsObject(),
  262. 'url' => $sIconImage,
  263. 'id' => $iId
  264. )
  265. ),
  266. 'bx_if:show_icon_font' => array(
  267. 'condition' => $bIconFont,
  268. 'content' => array(
  269. 'icon' => $sIconFont
  270. )
  271. )
  272. ));
  273. }
  274. protected function _getFormObject($sAction, $aLevel = array())
  275. {
  276. bx_import('BxTemplStudioFormView');
  277. $aForm = array(
  278. 'form_attrs' => array(
  279. 'id' => 'adm-prm-level-create',
  280. 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction,
  281. 'method' => BX_DOL_STUDIO_METHOD_DEFAULT,
  282. 'enctype' => 'multipart/form-data',
  283. ),
  284. 'params' => array (
  285. 'db' => array(
  286. 'table' => 'sys_acl_levels',
  287. 'key' => 'ID',
  288. 'uri' => '',
  289. 'uri_title' => '',
  290. 'submit_name' => 'do_submit'
  291. ),
  292. ),
  293. 'inputs' => array (
  294. 'id' => array(
  295. 'type' => 'hidden',
  296. 'name' => 'id',
  297. 'value' => isset($aLevel['id']) ? (int)$aLevel['id'] : 0,
  298. 'db' => array (
  299. 'pass' => 'Int',
  300. ),
  301. ),
  302. 'Active' => array(
  303. 'type' => 'hidden',
  304. 'name' => 'Active',
  305. 'value' => 'yes',
  306. 'db' => array (
  307. 'pass' => 'Xss',
  308. ),
  309. ),
  310. 'Purchasable' => array(
  311. 'type' => 'hidden',
  312. 'name' => 'Purchasable',
  313. 'value' => 'no',
  314. 'db' => array (
  315. 'pass' => 'Xss',
  316. ),
  317. ),
  318. 'Removable' => array(
  319. 'type' => 'hidden',
  320. 'name' => 'Removable',
  321. 'value' => 'yes',
  322. 'db' => array (
  323. 'pass' => 'Xss',
  324. ),
  325. ),
  326. 'Name' => array(
  327. 'type' => 'text_translatable',
  328. 'name' => 'Name',
  329. 'caption' => _t('_adm_prm_txt_level_name'),
  330. 'info' => _t('_adm_prm_dsc_level_name'),
  331. 'value' => '_adm_prm_txt_level',
  332. 'required' => '1',
  333. 'db' => array (
  334. 'pass' => 'Xss',
  335. ),
  336. 'checker' => array (
  337. 'func' => 'LengthTranslatable',
  338. 'params' => array(3, 100, 'Name'),
  339. 'error' => _t('_adm_prm_err_level_name'),
  340. ),
  341. ),
  342. 'Description' => array(
  343. 'type' => 'textarea_translatable',
  344. 'name' => 'Description',
  345. 'caption' => _t('_adm_prm_txt_level_description'),
  346. 'info' => _t('_adm_prm_dsc_level_description'),
  347. 'value' => isset($aLevel['description']) ? $aLevel['description'] : '_adm_prm_txt_level',
  348. 'db' => array (
  349. 'pass' => 'XssHtml',
  350. )
  351. ),
  352. 'QuotaSize' => array(
  353. 'type' => 'text',
  354. 'name' => 'QuotaSize',
  355. 'caption' => _t('_adm_prm_txt_level_quota_size'),
  356. 'info' => _t('_adm_prm_dsc_level_quota_size'),
  357. 'value' => isset($aLevel['quota_size']) ? round($aLevel['quota_size'] / self::$iBinMB, 1) : '0',
  358. 'required' => '1',
  359. 'db' => array (
  360. 'pass' => 'Float',
  361. ),
  362. 'checker' => array (
  363. 'func' => 'preg',
  364. 'params' => array('/^[0-9\.]+$/'),
  365. 'error' => _t('_adm_prm_err_level_quota_size'),
  366. ),
  367. ),
  368. 'QuotaMaxFileSize' => array(
  369. 'type' => 'text',
  370. 'name' => 'QuotaMaxFileSize',
  371. 'caption' => _t('_adm_prm_txt_level_quota_max_file_size'),
  372. 'info' => _t('_adm_prm_dsc_level_quota_max_file_size'),
  373. 'value' => isset($aLevel['quota_max_file_size']) ? round($aLevel['quota_max_file_size'] / self::$iBinMB, 1) : '',
  374. 'required' => '1',
  375. 'db' => array (
  376. 'pass' => 'Float',
  377. ),
  378. 'checker' => array (
  379. 'func' => 'preg',
  380. 'params' => array('/^[0-9\.]+$/'),
  381. 'error' => _t('_adm_prm_err_level_quota_max_file_size'),
  382. ),
  383. ),
  384. 'QuotaNumber' => array(
  385. 'type' => 'text',
  386. 'name' => 'QuotaNumber',
  387. 'caption' => _t('_adm_prm_txt_level_quota_number'),
  388. 'info' => _t('_adm_prm_dsc_level_quota_number'),
  389. 'value' => isset($aLevel['quota_number']) ? (int)$aLevel['quota_number'] : '0',
  390. 'required' => '1',
  391. 'db' => array (
  392. 'pass' => 'Int',
  393. ),
  394. 'checker' => array (
  395. 'func' => 'preg',
  396. 'params' => array('/^[0-9]+$/'),
  397. 'error' => _t('_adm_prm_err_level_quota_number'),
  398. ),
  399. ),
  400. 'Icon' => array(
  401. 'type' => 'text',
  402. 'name' => 'Icon',
  403. 'caption' => _t('_adm_prm_txt_level_icon'),
  404. 'info' => _t('_adm_prm_dsc_level_icon'),
  405. 'value' => '',
  406. 'required' => '0',
  407. 'db' => array (
  408. 'pass' => 'Xss',
  409. ),
  410. 'checker' => array (
  411. 'func' => '',
  412. 'params' => array(),
  413. 'error' => _t('_adm_prm_err_level_icon'),
  414. ),
  415. ),
  416. 'Icon_image' => array(
  417. 'type' => 'file',
  418. 'name' => 'Icon_image',
  419. 'caption' => _t('_adm_prm_txt_level_icon_image'),
  420. 'info' => _t('_adm_prm_dsc_level_icon_image'),
  421. 'value' => '',
  422. 'checker' => array (
  423. 'func' => '',
  424. 'params' => '',
  425. 'error' => _t('_adm_prm_err_level_icon_image'),
  426. ),
  427. ),
  428. 'Icon_preview' => array(
  429. 'type' => 'custom',
  430. 'name' => 'Icon_preview',
  431. 'caption' => _t('_adm_prm_txt_level_icon_image_old'),
  432. 'content' => ''
  433. ),
  434. 'Actions' => array(
  435. 'type' => 'select',
  436. 'name' => 'Actions',
  437. 'caption' => _t('_adm_prm_txt_level_actions_copy'),
  438. 'values' => array(
  439. array('key' => 0, 'value' => _t('_sys_txt_empty'))
  440. ),
  441. ),
  442. 'controls' => array(
  443. 'name' => 'controls',
  444. 'type' => 'input_set',
  445. array(
  446. 'type' => 'submit',
  447. 'name' => 'do_submit',
  448. 'value' => _t('_adm_prm_btn_level_add'),
  449. ),
  450. array (
  451. 'type' => 'reset',
  452. 'name' => 'close',
  453. 'value' => _t('_adm_prm_btn_level_cancel'),
  454. 'attrs' => array(
  455. 'onclick' => "$('.bx-popup-applied:visible').dolPopupHide()",
  456. 'class' => 'bx-def-margin-sec-left',
  457. ),
  458. )
  459. )
  460. )
  461. );
  462. $aLevels = array();
  463. $this->oDb->getLevels(array('type' => 'all_pair'), $aLevels, false);
  464. foreach($aLevels as $iId => $sName)
  465. $aForm['inputs']['Actions']['values'][] = array('key' => $iId, 'value' => _t($sName));
  466. switch($sAction) {
  467. case 'add':
  468. unset($aForm['inputs']['id']);
  469. unset($aForm['inputs']['Icon_preview']);
  470. $aForm['form_attrs']['id'] .= 'create';
  471. break;
  472. case 'edit':
  473. unset($aForm['inputs']['Active']);
  474. unset($aForm['inputs']['Purchasable']);
  475. unset($aForm['inputs']['Removable']);
  476. unset($aForm['inputs']['Name']);
  477. unset($aForm['inputs']['Actions']);
  478. $aForm['form_attrs']['id'] .= 'edit';
  479. $aForm['inputs']['Icon_image']['caption'] = _t('_adm_prm_txt_level_icon_image_new');
  480. $aForm['inputs']['controls'][0]['value'] = _t('_adm_prm_btn_level_save');
  481. $sIconImage = $sIconFont = "";
  482. if(!empty($aLevel['icon'])) {
  483. if(is_numeric($aLevel['icon']) && (int)$aLevel['icon'] != 0) {
  484. $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
  485. $sIconImage = $oStorage->getFileUrlById((int)$aLevel['icon']);
  486. } else {
  487. $sIconFont = $aLevel['icon'];
  488. $aForm['inputs']['Icon']['value'] = $sIconFont;
  489. }
  490. }
  491. $aForm['inputs']['Icon_preview']['content'] = $this->_getIconPreview($aLevel['id'], $sIconImage, $sIconFont);
  492. break;
  493. }
  494. return new BxTemplStudioFormView($aForm);
  495. }
  496. protected function _getAvailableId()
  497. {
  498. $aLevels = array();
  499. $this->oDb->getLevels(array('type' =>'all_order_id'), $aLevels, false);
  500. $iId = 1;
  501. foreach($aLevels as $aLevel) {
  502. if($iId != (int)$aLevel['id'])
  503. break;
  504. $iId++;
  505. }
  506. return $iId <= BX_DOL_STUDIO_PERMISSIONS_LEVEL_ID_INT_MAX ? $iId : false;
  507. }
  508. }
  509. /** @} */