public function getPerson() { static $person; if (!isset($person)) { $id['app_id'] = JoaktreeHelper::getApplicationId(); $id['person_id'] = JoaktreeHelper::getPersonId(); $person = new Person($id, 'basic'); } return $person; }
function __construct() { $id = array(); $id['map'] = Map::getMapId(true); $id['location'] = Map::getLocationId(true); $id['distance'] = Map::getDistance(true); $id['person'] = JoaktreeHelper::getPersonId(false, true); $id['tree'] = JoaktreeHelper::getTreeId(false, true); $id['app'] = JoaktreeHelper::getApplicationId(false, true); $this->map = new Map($id); parent::__construct(); }
function getArticleList() { $nullDate = $this->_db->getNullDate(); $date = JFactory::getDate(); $now = $date->toSql(); $params = JComponentHelper::getParams('com_joaktree'); $indArticleLink = (int) $params->get('indArticleLink', 9); $displayAccess = JoaktreeHelper::getDisplayAccess(); $userAccess = JoaktreeHelper::getUserAccess(); $accessLevels = JoaktreeHelper::getUserAccessLevels(); $related = array(); $likes = array(); // situation: article is shown to user -> find other related articles + related persons if ($this->_option == 'com_content' && $this->_view == 'article' && $this->_id) { // select the meta keywords from the article and fill the "likes" parameter $query = $this->_db->getQuery(true); $query->select(' metakey '); $query->from(' #__content '); $query->where(' id = ' . (int) $this->_id . ' '); $this->_db->setQuery($query); if ($metakey = trim($this->_db->loadResult())) { // explode the meta keys on a comma $keys = explode(',', $metakey); // assemble any non-blank word(s) foreach ($keys as $key) { $key = trim($key); if ($key) { // surround with commas so first and last items have surrounding commas $likes[] = ',' . $this->_db->escape($key) . ','; } } } } // situation: persons is shown to user -> find related articles // and fill the "likes" parameter with parameters from the person if ($this->_option == 'com_joaktree' && $this->_view == 'joaktree') { $query = $this->_db->getQuery(true); // get tree id $treeId = JoaktreeHelper::getTreeId(); // get application id $appId = JoaktreeHelper::getApplicationId(); // get the person id $personId = JoaktreeHelper::getPersonId(); // check acces to person and tree is allowed $accessAllowed = JoaktreeHelper::getAccess(); // retrieve name of person, if access is allowed if ($accessAllowed and $indArticleLink != 0) { $concat_string = ' CONCAT_WS( "," '; if ($indArticleLink == 1 or $indArticleLink == 9) { // 1: By ID; 9: All options $concat_string .= ' , CONCAT_WS( ' . $this->_db->quote('!') . ' ' . ' , jpn.app_id ' . ' , jpn.id ' . ' ) ' . ' , jpn.id '; } if ($indArticleLink == 2 or $indArticleLink == 5 or $indArticleLink == 9) { // 2: By first name; 5: All names; 9: All options $concat_string .= ' , jpn.firstName '; } if ($indArticleLink == 3 or $indArticleLink == 5 or $indArticleLink == 9) { // 3: By family name; 5: All names; 9: All options $concat_string .= ' , CONCAT_WS( ' . $this->_db->quote(' ') . ' ' . ' , jpn.namePreposition ' . ' , jpn.familyName ' . ' ) '; } if ($indArticleLink == 4 or $indArticleLink == 5 or $indArticleLink == 9) { // 4: By first + family name; 5: All names; 9: All options $concat_string .= ' , CONCAT_WS( ' . $this->_db->quote(' ') . ' ' . ' , jpn.firstName ' . ' , jpn.namePreposition ' . ' , jpn.familyName ' . ' ) '; } $concat_string .= ' ) AS metakey '; $query->select($concat_string); $query->from(' #__joaktree_persons jpn '); $query->innerJoin(' #__joaktree_admin_persons jan ' . ' ON ( jan.app_id = jpn.app_id ' . ' AND jan.id = jpn.id ' . ' AND jan.published = true ' . ' AND jan.page = true ' . ' AND ( (jan.living = false AND ' . $displayAccess['NAMEname']->notLiving . ' = 2 ) ' . ' OR (jan.living = true AND ' . $displayAccess['NAMEname']->living . ' = 2 ) ' . ' ) ' . ' ) '); $query->where(' jpn.id = ' . $this->_db->quote($personId) . ' '); $this->_db->setQuery($query); if ($metakey = trim($this->_db->loadResult())) { // explode the meta keys on a comma $keys = explode(',', $metakey); // assemble any non-blank word(s) foreach ($keys as $key) { $key = trim($key); if ($key) { // surround with commas so first and last items have surrounding commas $likes[] = ',' . $this->_db->escape($key) . ','; } } } } } // the "likes" parameter is filled - either from article or from person // process the "likes" - search in keyword of articles if (count($likes)) { // select other items based on the metakey field 'like' the keys found $query = $this->_db->getQuery(true); $query->select(' a.id '); $query->select(' a.title '); $query->select(' DATE_FORMAT(a.created, "%Y-%m-%d") AS created '); $query->select(' a.catid '); $query->select(' CASE WHEN CHAR_LENGTH(a.alias) ' . ' THEN CONCAT_WS(":", a.id, a.alias) ' . ' ELSE a.id ' . ' END AS slug '); $query->select(' a.language '); $query->from(' #__content AS a '); // join with categories $query->select(' cc.access AS cat_access '); $query->select(' cc.published AS cat_state '); $query->select(' CASE WHEN CHAR_LENGTH(cc.alias) ' . ' THEN CONCAT_WS(":", cc.id, cc.alias) ' . ' ELSE cc.id ' . ' END AS catslug '); $query->leftJoin(' #__categories AS cc ' . ' ON ( cc.id = a.catid ' . ' AND cc.published = 1 ' . ' AND cc.access IN ' . $accessLevels . ' ' . ' ) '); $query->where(' a.id != ' . (int) $this->_id . ' '); $query->where(' a.state = 1 '); $query->where(' a.access IN ' . $accessLevels . ' '); $query->where(' ( CONCAT( "," ' . ' , REPLACE( a.metakey ' . ' , ", " ' . ' , "," ' . ' ) ' . ' , "," ' . ' ) ' . ' LIKE "%' . implode('%" OR CONCAT( "," ' . ' , REPLACE( a.metakey ' . ' , ", " ' . ' , "," ' . ' ) ' . ' , "," ' . ' ) LIKE "%', $likes) . '%" ' . ' ) '); //remove single space after commas in keywords $query->where(' ( a.publish_up = ' . $this->_db->Quote($nullDate) . ' ' . ' OR a.publish_up <= ' . $this->_db->Quote($now) . ' ' . ' ) '); $query->where(' ( a.publish_down = ' . $this->_db->Quote($nullDate) . ' ' . ' OR a.publish_down >= ' . $this->_db->Quote($now) . ' ' . ' ) '); // Filter by language if ($this->languageFilter) { $query->where('a.language in (' . $this->_db->Quote(JFactory::getLanguage()->getTag()) . ',' . $this->_db->Quote('*') . ') '); } $query->order(' a.title '); $this->_db->setQuery($query); $temp = $this->_db->loadObjectList(); if (count($temp)) { foreach ($temp as $row) { if (($row->cat_state == 1 || $row->cat_state == '') && (in_array($row->cat_access, $userAccess) || $row->cat_access == '')) { $row->route = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug)); $row->robot = ''; $related[] = $row; } } } unset($temp); } return $related; }
public function getPersonName() { $personId = JoaktreeHelper::getPersonId(false, true); $appId = JoaktreeHelper::getApplicationId(false, true); if (empty($appId) || empty($personId)) { $retObj = $this->getReturnObject(); if (is_object($retObj) && $retObj->object == 'prsn') { $appId = $retObj->app_id; $personId = $retObj->object_id; } } if (!empty($appId) && !empty($personId)) { $displayAccess = JoaktreeHelper::getDisplayAccess(); $db = $this->getDbo(); $query = $db->getQuery(true); $query->select(JoaktreeHelper::getConcatenatedFullName() . ' AS fullName '); $query->from(' #__joaktree_persons jpn '); $query->where(' jpn.app_id = ' . (int) $appId . ' '); $query->where(' jpn.id = ' . $db->quote($personId) . ' '); $query->innerJoin(JoaktreeHelper::getJoinAdminPersons(true)); $db->setQuery($query); $name = $db->loadResult(); if ($error = $db->getErrorMsg()) { throw new JException($error); } } return isset($name) ? $name : null; }
function getAccess() { static $_access; if (!isset($_access)) { $db = JFactory::getDBO(); $treeId = intval($this->getTreeId()); $userAccess = self::getUserAccess(); // determine the access of the user to the tree if (isset($treeId) and intval($treeId) > 0) { // only execute this query when the tree is known $query = $db->getQuery(true); $query->select(' jte.access '); $query->from(' #__joaktree_trees jte '); $query->where(' jte.published = true '); $query->where(' jte.id = ' . $treeId . ' '); $db->setQuery($query); $jte_access = $db->loadResult(); if ($error = $db->getErrorMsg()) { throw new JException($error); } if (isset($jte_access) && isset($userAccess) && in_array($jte_access, $userAccess)) { // access to tree is true, but is there a valid person? $personId = JoaktreeHelper::getPersonId(); if (!isset($personId) or $personId == null) { // no personID found, therefore no access $_access = false; } else { // personId found, check whether person is accessible $person = $this->getPerson(); if (!isset($person->id) or $person->id == null) { // no person found, therefore no access $_access = false; } else { // check whether person and tree-id are related $query = $db->getQuery(true); $query->select(' 1 AS result '); $query->from(' #__joaktree_tree_persons jtp '); $query->where(' jtp.app_id = ' . $person->app_id . ' '); $query->where(' jtp.person_id = ' . $db->Quote($person->id) . ' '); $query->where(' jtp.tree_id = ' . $treeId . ' '); $db->setQuery($query); $related = $db->loadResult(); if ($error = $db->getErrorMsg()) { throw new JException($error); } if ($related) { // tree and person are linked, therefore access is allowed $_access = true; } else { // tree and person are not linked, access is denied $_access = false; } } } } else { // access to tree is false $_access = false; } } else { // tree is not known, therefore no access $_access = false; } } return $_access; }
public function getPersonId() { return JoaktreeHelper::getPersonId(); }
public function getPersonId() { return JoaktreeHelper::getPersonId(false, true); }