_iProfileId = bx_get_logged_profile_id(); } // ====== ACTIONS METHODS public function actionRss ($sMode = '') { $aArgs = func_get_args(); $sMode = array_shift($aArgs); if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedBrowse())) { $this->_oTemplate->displayAccessDenied ($sMsg); exit; } $aParams = $this->_buildRssParams($sMode, $aArgs); bx_import ('SearchResult', $this->_aModule); $sClass = $this->_aModule['class_prefix'] . 'SearchResult'; $o = new $sClass($sMode, $aParams); if ($o->isError) { $this->_oTemplate->displayPageNotFound (); exit; } $o->outputRSS(); exit; } // ====== SERVICE METHODS public function serviceManageTools($sType = 'common') { bx_import('BxDolGrid'); $oGrid = BxDolGrid::getObjectInstance($this->_oConfig->getGridObject($sType)); if(!$oGrid) return ''; $CNF = &$this->_oConfig->CNF; bx_import('BxDolAcl'); $oAcl = BxDolAcl::getInstance(); $sMenu = ''; if($oAcl->isMemberLevelInSet(192)) { bx_import('BxDolPermalinks'); $oPermalink = BxDolPermalinks::getInstance(); $aMenuItems = array(); if(!empty($CNF['OBJECT_GRID_COMMON']) && !empty($CNF['T']['menu_item_manage_my'])) $aMenuItems[] = array('id' => 'manage-common', 'name' => 'manage-common', 'class' => '', 'link' => $oPermalink->permalink($CNF['URL_MANAGE_COMMON']), 'target' => '_self', 'title' => _t($CNF['T']['menu_item_manage_my']), 'active' => 1); if(!empty($CNF['OBJECT_GRID_MODERATION']) && !empty($CNF['T']['menu_item_manage_all']) && $oAcl->isMemberLevelInSet(64)) $aMenuItems[] = array('id' => 'manage-moderation', 'name' => 'manage-moderation', 'class' => '', 'link' => $oPermalink->permalink($CNF['URL_MANAGE_MODERATION']), 'target' => '_self', 'title' => _t($CNF['T']['menu_item_manage_all']), 'active' => 1); if(!empty($CNF['OBJECT_GRID_ADMINISTRATION']) && !empty($CNF['T']['menu_item_manage_all']) && $oAcl->isMemberLevelInSet(128)) $aMenuItems[] = array('id' => 'manage-administration', 'name' => 'manage-administration', 'class' => '', 'link' => $oPermalink->permalink($CNF['URL_MANAGE_ADMINISTRATION']), 'target' => '_self', 'title' => _t($CNF['T']['menu_item_manage_all']), 'active' => 1); if(count($aMenuItems) > 1) { bx_import('BxTemplMenu'); $oMenu = new BxTemplMenu(array( 'template' => 'menu_vertical.html', 'menu_items' => $aMenuItems ), $this->_oTemplate); $oMenu->setSelected($this->_aModule['name'], 'manage-' . $sType); $sMenu = $oMenu->getCode(); } } if(!empty($CNF['OBJECT_MENU_SUBMENU'])) { bx_import('BxTemplMenu'); BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SUBMENU'])->setSelected($this->_aModule['name'], $CNF['URI_MANAGE_COMMON']); } $this->_oTemplate->addCss(array('manage_tools.css')); $this->_oTemplate->addJs(array('manage_tools.js')); $this->_oTemplate->addJsTranslation(array('_sys_grid_search')); return array( 'content' => $this->_oTemplate->getJsCode('manage_tools', array('sObjNameGrid' => $this->_oConfig->getGridObject($sType))) . $oGrid->getCode(), 'menu' => $sMenu ); } public function serviceGetMenuAddonManageTools() { return 0; } public function serviceGetMenuAddonManageToolsProfileStats() { return 0; } /** * Add entry form * @return HTML string */ public function serviceEntityCreate () { bx_import('FormsEntryHelper', $this->_aModule); $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper'; $oFormsHelper = new $sClass($this); return $oFormsHelper->addDataForm(); } public function serviceEntityEdit ($iContentId = 0) { return $this->_serviceEntityForm ('editDataForm', $iContentId); } public function serviceEntityDelete ($iContentId = 0) { return $this->_serviceEntityForm ('deleteDataForm', $iContentId); } public function serviceEntityInfo ($iContentId = 0) { return $this->_serviceEntityForm ('viewDataForm', $iContentId); } /** * Entry actions block */ public function serviceEntityActions ($iContentId = 0) { if (!$iContentId) $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT); if (!$iContentId) return false; bx_import('BxTemplMenu'); $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']); return $oMenu ? $oMenu->getCode() : false; } // ====== PERMISSION METHODS /** * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make "true === " checking. */ public function checkAllowedBrowse () { return CHECK_ACTION_RESULT_ALLOWED; } /** * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking. */ public function checkAllowedView ($aDataEntry, $isPerformAction = false) { $CNF = &$this->_oConfig->CNF; // moderator and owner always have access if ($aDataEntry[$CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_isModerator($isPerformAction)) return CHECK_ACTION_RESULT_ALLOWED; // check ACL $aCheck = checkActionModule($this->_iProfileId, 'view entry', $this->getName(), $isPerformAction); if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED) return $aCheck[CHECK_ACTION_MESSAGE]; // check privacy if (!empty($CNF['OBJECT_PRIVACY_VIEW'])) { bx_import('BxDolPrivacy'); $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']); if ($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']])) return _t('_sys_access_denied_to_private_content'); } return CHECK_ACTION_RESULT_ALLOWED; } /** * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking. */ public function checkAllowedAdd ($isPerformAction = false) { // check ACL $aCheck = checkActionModule($this->_iProfileId, 'create entry', $this->getName(), $isPerformAction); if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED) return $aCheck[CHECK_ACTION_MESSAGE]; return CHECK_ACTION_RESULT_ALLOWED; } /** * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking. */ public function checkAllowedEdit ($aDataEntry, $isPerformAction = false) { // moderator and owner always have access if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_isModerator($isPerformAction)) return CHECK_ACTION_RESULT_ALLOWED; return _t('_sys_txt_access_denied'); } /** * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking. */ public function checkAllowedDelete (&$aDataEntry, $isPerformAction = false) { // moderator always has access if ($this->_isModerator($isPerformAction)) return CHECK_ACTION_RESULT_ALLOWED; // check ACL $aCheck = checkActionModule($this->_iProfileId, 'delete entry', $this->getName(), $isPerformAction); if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED) return CHECK_ACTION_RESULT_ALLOWED; return _t('_sys_txt_access_denied'); } /** * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking. */ public function checkAllowedSetMembership (&$aDataEntry, $isPerformAction = false) { // admin always has access if (isAdmin($this->_iProfileId)) return CHECK_ACTION_RESULT_ALLOWED; // check ACL $aCheck = checkActionModule($this->_iProfileId, 'set acl level', 'system', $isPerformAction); if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED) return $aCheck[CHECK_ACTION_MESSAGE]; return CHECK_ACTION_RESULT_ALLOWED; } // ====== PROTECTED METHODS protected function _serviceBrowse ($sMode, $aParams = false, $iDesignBox = BX_DB_PADDING_DEF, $bDisplayEmptyMsg = false, $bAjaxPaginate = true) { if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedBrowse())) return MsgBox($sMsg); bx_import('SearchResult', $this->_aModule); $sClass = $this->_aModule['class_prefix'] . 'SearchResult'; $o = new $sClass($sMode, $aParams); $o->setDesignBoxTemplateId($iDesignBox); $o->setDisplayEmptyMsg($bDisplayEmptyMsg); $o->setAjaxPaginate($bAjaxPaginate); if ($o->isError) return ''; if ($s = $o->processing()) return $s; else return ''; } protected function _isModerator ($isPerformAction = false) { // check moderator ACL $aCheck = checkActionModule($this->_iProfileId, 'edit any entry', $this->getName(), $isPerformAction); return $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED; } protected function _serviceEntityForm ($sFormMethod, $iContentId = 0, $sDisplay = false) { if (!$iContentId) $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT); if (!$iContentId) return false; bx_import('FormsEntryHelper', $this->_aModule); $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper'; $oFormsHelper = new $sClass($this); return $oFormsHelper->$sFormMethod((int)$iContentId, $sDisplay); } protected function _serviceTemplateFunc ($sFunc, $iContentId) { if (!$iContentId) $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT); if (!$iContentId) return false; $aContentInfo = $this->_oDb->getContentInfoById($iContentId); if (!$aContentInfo) return false; return $this->_oTemplate->$sFunc($aContentInfo); } } /** @} */