_sSystem)) return; $this->_oQuery = new BxDolViewQuery($this); } /** * get votes object instanse * @param $sSys view object name * @param $iId associated content id, where vote is available * @param $iInit perform initialization * @return null on error, or ready to use class instance */ public static function getObjectInstance($sSys, $iId, $iInit = true) { if(isset($GLOBALS['bxDolClasses']['BxDolView!' . $sSys . $iId])) return $GLOBALS['bxDolClasses']['BxDolView!' . $sSys . $iId]; $aSystems = self::getSystems(); if(!isset($aSystems[$sSys])) return null; $sClassName = 'BxTemplView'; if(!empty($aSystems[$sSys]['class_name'])) { $sClassName = $aSystems[$sSys]['class_name']; if(!empty($aSystems[$sSys]['class_file'])) require_once(BX_DIRECTORY_PATH_ROOT . $aSystems[$sSys]['class_file']); } $o = new $sClassName($sSys, $iId, $iInit); return ($GLOBALS['bxDolClasses']['BxDolView!' . $sSys . $iId] = $o); } public static function &getSystems() { $sKey = 'bx_dol_cache_memory_view_systems'; if(!isset($GLOBALS[$sKey])) $GLOBALS[$sKey] = BxDolDb::getInstance()->fromCache('sys_objects_view', 'getAllWithKey', ' SELECT `id` as `id`, `name` AS `name`, `table_track` AS `table_track`, `period` AS `period`, `is_on` AS `is_on`, `trigger_table` AS `trigger_table`, `trigger_field_id` AS `trigger_field_id`, `trigger_field_author` AS `trigger_field_author`, `trigger_field_count` AS `trigger_field_count`, `class_name` AS `class_name`, `class_file` AS `class_file` FROM `sys_objects_view`', 'name'); return $GLOBALS[$sKey]; } public static function onAuthorDelete ($iAuthorId) { $aSystems = self::getSystems(); foreach($aSystems as $sSystem => $aSystem) self::getObjectInstance($sSystem, 0)->getQueryObject()->deleteAuthorEntries($iAuthorId); return true; } public function actionGetViewedBy() { if (!$this->isEnabled()) return ''; return $this->_getViewedBy(); } public function doView() { if(!$this->isEnabled()) return false; $iObjectId = $this->getId(); $iAuthorId = $this->_getAuthorId(); $sAuthorIp = $this->_getAuthorIp(); if($this->_oQuery->doView($iObjectId, $iAuthorId, $sAuthorIp)) { $this->_trigger(); $oZ = new BxDolAlerts($this->_sSystem, 'view', $iObjectId, $iAuthorId); $oZ->alert(); return true; } return false; } /** * Permissions functions * * Note. The 'view' action is performed automatically and therefore the manual action is not allowed. */ public function isAllowedView($isPerformAction = false) { return false; } public function isAllowedViewView($isPerformAction = false) { if(isAdmin()) return true; return $this->checkAction('view_view', $isPerformAction); } public function isAllowedViewViewViewers($isPerformAction = false) { $oAcl = BxDolAcl::getInstance(); if(isAdmin() || $oAcl->isMemberLevelInSet(array(MEMBERSHIP_ID_MODERATOR, MEMBERSHIP_ID_ADMINISTRATOR))) return true; $iObjectAuthorId = $this->_oQuery->getObjectAuthorId($this->_iId); return $iObjectAuthorId != 0 && $iObjectAuthorId == $this->_getAuthorId() && $this->checkAction('view_view_viewers', $isPerformAction); } /** * Internal functions */ protected function _getIconDo() { return 'eye'; } protected function _getTitleDo() { return '_view_do_view'; } } /** @} */