1
0

BxBaseAuditGrid.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. class BxBaseAuditGrid extends BxDolAuditGrid
  10. {
  11. protected $sJsObject = 'oBxDolAuditManageTools';
  12. public function __construct($aInfo, $oTemplate = false)
  13. {
  14. parent::__construct($aInfo, $oTemplate);
  15. }
  16. public function getCode($isDisplayHeader = true)
  17. {
  18. list($aCssCalendar, $aJsCalendar) = BxBaseFormView::getCssJsCalendar();
  19. $this->_oTemplate->addCss(array_merge($aCssCalendar, ['manage_tools.css']));
  20. $this->_oTemplate->addJs(array_merge($aJsCalendar, ['BxDolAuditManageTools.js', 'BxDolGrid.js']));
  21. $this->_oTemplate->addJsTranslation(['_sys_grid_search']);
  22. return $this->getJsCode() . parent::getCode($isDisplayHeader);
  23. }
  24. public function getJsCode()
  25. {
  26. $aParams = array(
  27. 'sObjName' => $this->sJsObject,
  28. 'aHtmlIds' => array(),
  29. 'oRequestParams' => array(),
  30. 'sObjNameGrid' => 'sys_audit_administration'
  31. );
  32. return BxDolTemplate::getInstance()->_wrapInTagJsCode("var " . $this->sJsObject . " = new BxDolAuditManageTools(" . json_encode($aParams) . ");");
  33. }
  34. protected function _getCellAdded($mixedValue, $sKey, $aField, $aRow)
  35. {
  36. return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
  37. }
  38. protected function _getCellAction ($mixedValue, $sKey, $aField, $aRow)
  39. {
  40. return parent::_getCellDefault(_t($aRow['action_lang_key'], $aRow['action_lang_key_params']), $sKey, $aField, $aRow);
  41. }
  42. protected function _getCellContentId ($mixedValue, $sKey, $aField, $aRow)
  43. {
  44. $mixedValue = '';
  45. if ($aRow['content_id'] > 0){
  46. $sLink = BxDolRequest::serviceExists($aRow['content_module'], 'get_link') ? BxDolService::call($aRow['content_module'], 'get_link', array($aRow['content_id'])) : '';
  47. $sTitle = BxDolRequest::serviceExists($aRow['content_module'], 'get_title') ? BxDolService::call($aRow['content_module'], 'get_title', array($aRow['content_id'])) : $aRow['content_title'];
  48. if ($sLink){
  49. $mixedValue = BxDolTemplate::getInstance()->parseLink($sLink, $sTitle);
  50. }
  51. else{
  52. $mixedValue = $sTitle;
  53. }
  54. }
  55. $sLinkExtras = '';
  56. $aExtras = unserialize($aRow['extras']);
  57. if (isset($aExtras['display_info'])){
  58. $sLinkExtras = $this->_oTemplate->parseLink('javascript:void(0)',' <i class="sys-icon info-circle"></i>' , array(
  59. 'title' => '',
  60. 'bx_grid_action_single' => 'show_stat',
  61. 'bx_grid_action_data' => json_encode($aExtras)
  62. ));
  63. }
  64. return parent::_getCellDefault($mixedValue . $sLinkExtras, $sKey, $aField, $aRow);
  65. }
  66. protected function _getCellContextProfileId ($mixedValue, $sKey, $aField, $aRow)
  67. {
  68. if ($aRow['context_profile_id'] > 0){
  69. $oProfile = BxDolProfile::getInstance($aRow['context_profile_id']);
  70. if ($oProfile){
  71. $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName());
  72. }
  73. else{
  74. $mixedValue = $aRow['context_profile_title'];
  75. }
  76. }
  77. else{
  78. $mixedValue = '';
  79. }
  80. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  81. }
  82. protected function _getCellContentModule ($mixedValue, $sKey, $aField, $aRow)
  83. {
  84. $oModule = bxDolModule::getInstance($aRow['content_module']);
  85. if($oModule && $oModule instanceof iBxDolContentInfoService){
  86. $mixedValue = $oModule->_aModule['title'];
  87. }
  88. else{
  89. $mixedValue = $aRow['content_module'];
  90. }
  91. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  92. }
  93. protected function _getCellProfileId ($mixedValue, $sKey, $aField, $aRow)
  94. {
  95. if ($aRow['profile_id'] > 0){
  96. $oProfile = BxDolProfile::getInstance($aRow['profile_id']);
  97. if ($oProfile){
  98. $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName());
  99. }
  100. else{
  101. $mixedValue = $aRow['profile_title'];
  102. }
  103. }
  104. else{
  105. $mixedValue = '';
  106. }
  107. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  108. }
  109. protected function _getCellAuthorId ($mixedValue, $sKey, $aField, $aRow)
  110. {
  111. if ($aRow['profile_id'] > 0){
  112. $oProfile = BxDolProfile::getInstance($aRow['profile_id']);
  113. if ($oProfile){
  114. $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName());
  115. }
  116. else{
  117. $mixedValue = $aRow['profile_title'];
  118. }
  119. }
  120. else{
  121. $mixedValue = '';
  122. }
  123. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  124. }
  125. function _getFilterControls()
  126. {
  127. parent::_getFilterControls();
  128. return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values) .
  129. $this->_getFilterSelectOne($this->_sFilterProfileName, $this->_sFilterProfileValue, $this->_aFilterProfileValues) .
  130. $this->_getFilterSelectOne($this->_sFilterActionName, $this->_sFilterActionValue, $this->_aFilterActionValues) .
  131. $this->_getFilterDatePicker($this->_sFilterFromDateName, $this->_sFilterFromDateValue) .
  132. $this->_getFilterLabel('-') .
  133. $this->_getFilterDatePicker($this->_sFilterToDateName, $this->_sFilterToDateValue) .
  134. $this->_getFilterButton();
  135. }
  136. protected function _getFilterDatePicker($sFilterName, $sFilterValue, $bAsArray = false)
  137. {
  138. $aInputDatePicker = parent::_getFilterDatePicker($sFilterName, $sFilterValue, true);
  139. if(!$aInputDatePicker)
  140. return $aInputDatePicker;
  141. $aInputButton['tr_attrs'] ??= [];
  142. $aInputButton['tr_attrs']['class'] = 'bx-grid-controls-filter-datepicker';
  143. if($bAsArray)
  144. return $aInputDatePicker;
  145. $oForm = new BxTemplFormView([]);
  146. return $oForm->genRow($aInputDatePicker);
  147. }
  148. protected function _getFilterButton($bAsArray = false)
  149. {
  150. $aInputButton = parent::_getFilterButton(true);
  151. $aInputButton['tr_attrs'] ??= [];
  152. $aInputButton['tr_attrs']['class'] = 'bx-grid-controls-filter-button';
  153. $aInputButton['attrs'] ??= [];
  154. $aInputButton['attrs']['onClick'] = 'javascript:' . $this->sJsObject . '.onChangeFilter(this)';
  155. if($bAsArray)
  156. return $aInputButton;
  157. $oForm = new BxTemplFormView([]);
  158. return $oForm->genRow($aInputButton);
  159. }
  160. protected function _getFilterLabel($sFilterValue, $bAsArray = false)
  161. {
  162. $aInputLabel = parent::_getFilterLabel($sFilterValue, true);
  163. $aInputLabel['tr_attrs'] ??= [];
  164. $aInputLabel['tr_attrs']['class'] = 'bx-grid-controls-filter-label';
  165. if($bAsArray)
  166. return $aInputLabel;
  167. $oForm = new BxTemplFormView([]);
  168. return $oForm->genRow($aInputLabel);
  169. }
  170. public function performActionShowStat()
  171. {
  172. $aTmp2 = bx_get('ids');
  173. $sData = $aTmp2[0];
  174. $aData = json_decode($sData, true);
  175. $sContentInfo = '';
  176. if (isset($aData['display_info'])) {
  177. foreach($aData['display_info'] as $sKey => $sValue)
  178. $sContentInfo .= $sKey . ': ' . $sValue;
  179. }
  180. $sContent = BxTemplStudioFunctions::getInstance()->popupBox('sys-audit-content-info', _t('_sys_audit_content_info_popup_title'), $sContentInfo);
  181. echoJson(array('popup' => $sContent));
  182. }
  183. }
  184. /** @} */