BxBaseStudioPermissionsLevels.php 26 KB

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