/** * Constructor. * * @param integer $objectId Identifier of treated object. * @param integer $areaId Name of hook area. * @param string $module Name of the owning module. * @param string $urlString **deprecated** * @param Zikula_ModUrl $urlObject Object carrying url arguments. */ function __construct($objectId, $areaId, $module, $urlString = null, Zikula_ModUrl $urlObject = null) { // call base constructor to store arguments in member vars parent::__construct($objectId, $areaId, $module, $urlString, $urlObject); // derive object type from url object $urlArgs = $urlObject->getArgs(); $objectType = isset($urlArgs['ot']) ? $urlArgs['ot'] : 'review'; $component = $module . ':' . ucwords($objectType) . ':'; $perm = SecurityUtil::checkPermission($component, $objectId . '::', ACCESS_READ); if (!$perm) { return; } $entityClass = $module . '_Entity_' . ucwords($objectType); $serviceManager = ServiceUtil::getManager(); $entityManager = $serviceManager->getService('doctrine.entitymanager'); $repository = $entityManager->getRepository($entityClass); $useJoins = false; /** TODO support composite identifiers properly at this point */ $entity = $repository->selectById($objectId, $useJoins); if ($entity === false || !is_array($entity) && !is_object($entity)) { return; } $this->setObjectTitle($entity->getTitleFromDisplayPattern()); $dateFieldName = $repository->getStartDateFieldName(); if ($dateFieldName != '') { $this->setObjectDate($entity[$dateFieldName]); } else { $this->setObjectDate(''); } if (method_exists($entity, 'getCreatedUserId')) { $this->setObjectAuthor(UserUtil::getVar('uname', $entity['createdUserId'])); } else { $this->setObjectAuthor(''); } }
/** * Construct. * * @param int $objectId Object ID. * @param int $areaId A blockinfo structure. * @param string $module Module. * @param string $urlString Url. * @param Zikula_ModUrl $urlObject Url object. */ function __construct($objectId, $areaId, $module, $urlString = null, Zikula_ModUrl $urlObject = null) { parent::__construct($objectId, $areaId, $module, $urlString, $urlObject); $args = $urlObject->getArgs(); $ot = $args['ot']; if ($ot == 'posting') { $posting = ModUtil::apiFunc('MUBoard', 'selection', 'getEntity', array('ot' => 'posting', 'id' => $this->getObjectId())); // the Api checks for perms and there is nothing else to check if ($posting) { $userid = $posting->getCreatedUserId(); $date = $posting->getCreatedDate(); $title = $posting->getTitle(); $this->setObjectAuthor(UserUtil::getVar('uname', $userid)); $this->setObjectDate($date); $this->setObjectTitle($title); } } if ($ot == 'picture') { $picture = ModUtil::apiFunc('MUImage', 'selection', 'getEntity', array('ot' => 'picture', 'id' => $this->getObjectId())); // the Api checks for perms and there is nothing else to check if ($picture) { $userid = $picture->getCreatedUserId(); $date = $picture->getCreatedDate(); $title = $picture->getTitle(); $this->setObjectAuthor(UserUtil::getVar('uname', $userid)); $this->setObjectDate($date); $this->setObjectTitle($title); } } }
/** * Construct. * * @param int $objectId Object ID. * @param int $areaId A blockinfo structure. * @param string $module Module. * @param string $urlString Url. * @param Zikula_ModUrl $urlObject Url object. */ function __construct($objectId, $areaId, $module, $urlString = null, Zikula_ModUrl $urlObject = null) { parent::__construct($objectId, $areaId, $module, $urlString, $urlObject); $page = ModUtil::apiFunc('Pages', 'user', 'get', array('pageid' => $this->getObjectId())); // the Api checks for perms and there is nothing else to check if ($page) { $this->setObjectAuthor(UserUtil::getVar('uname', $page['cr_uid'])); $this->setObjectDate($page['cr_date']); $this->setObjectTitle($page['title']); } }
/** * Construct. * * @param int $objectId Object ID. * @param int $areaId A blockinfo structure. * @param string $module Module. * @param string $urlString Url. * @param \Zikula_ModUrl $urlObject Url object. */ public function __construct($objectId, $areaId, $module, $urlString = null, \Zikula_ModUrl $urlObject = null) { parent::__construct($objectId, $areaId, $module, $urlString, $urlObject); $sm = \ServiceUtil::getManager(); /** @var \Zikula\PagesModule\Entity\PageEntity $page */ $page = $sm->get('doctrine.entitymanager')->getRepository('ZikulaPagesModule:PageEntity')->find($this->getObjectId()); // the Api checks for perms and there is nothing else to check if ($page) { $this->setObjectAuthor($page->getCreator()->getUname()); $this->setObjectDate($page->getCr_date()); $this->setObjectTitle($page->getTitle()); } }
function __construct($objectId, $areaId, $module, $urlString = null, Zikula_ModUrl $urlObject = null) { parent::__construct($objectId, $areaId, $module, $urlString, $urlObject); $perm = SecurityUtil::checkPermission('Content:page:', $objectId . '::', ACCESS_READ); if ($perm) { $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->getObjectId(), 'preview' => false, 'includeContent' => false)); // the Page Api resolves page active status and availabilty times if ($page) { $this->setObjectAuthor($page['uname']); $this->setObjectDate($page['cr_date']); $this->setObjectTitle(html_entity_decode($page['title'])); } } }
function __construct($objectId, $areaId, $module, $urlString = null, Zikula_ModUrl $urlObject = null) { parent::__construct($objectId, $areaId, $module, $urlString, $urlObject); $newsItem = ModUtil::apiFunc('News', 'user', 'get', array('sid' => $this->getObjectId())); // the api takes care of the permissions check. we must check for pending/expiration & status $expired = (isset($newsItem['to']) && (strtotime($newsItem['to']) < strtotime("now"))); $pending = (strtotime($newsItem['from']) > strtotime("now")); $statuspublished = ($newsItem['published_status'] == News_Api_User::STATUS_PUBLISHED); if ($newsItem && $statuspublished && !$pending && !$expired) { $this->setObjectAuthor($newsItem['contributor']); $this->setObjectDate($newsItem['from']); $this->setObjectTitle($newsItem['title']); } }