Example #1
0
 private function _buildQuery()
 {
     $treeId = intval($this->getTreeId());
     $levels = JoaktreeHelper::getUserAccessLevels();
     $displayAccess = JoaktreeHelper::getDisplayAccess();
     $query = $this->_db->getQuery(true);
     // select from persons
     $query->select(' jpn.id ');
     $query->select(' jpn.app_id ');
     $query->select(' MIN( ' . JoaktreeHelper::getSelectFirstName() . ' ) AS firstName ');
     $query->select(' MIN( ' . JoaktreeHelper::getSelectPatronym() . ' ) AS patronym ');
     $query->select(' MIN( ' . JoaktreeHelper::getConcatenatedFamilyName() . ' ) AS familyName ');
     $query->select(' MIN( ' . JoaktreeHelper::getSelectBirthYear() . ' ) AS birthDate ');
     $query->select(' MIN( ' . JoaktreeHelper::getSelectDeathYear() . ' ) AS deathDate ');
     $query->from(' #__joaktree_persons jpn ');
     // select from admin persons
     $query->innerJoin(JoaktreeHelper::getJoinAdminPersons(false));
     // select from tree x persons
     $query->innerJoin(' #__joaktree_tree_persons  jtp ' . ' ON (   jtp.app_id    = jpn.app_id ' . '    AND jtp.person_id = jpn.id ' . '    ) ');
     $query->innerJoin(' #__joaktree_trees         jte ' . ' ON (   jte.app_id    = jtp.app_id ' . '    AND jte.id        = jtp.tree_id ' . '    AND jte.published = true ' . '    AND jte.access    IN ' . $levels . ' ' . '    ) ');
     // select from birth and death
     $query->leftJoin(JoaktreeHelper::getJoinBirth());
     $query->leftJoin(JoaktreeHelper::getJoinDeath());
     // Get the WHERE, GROUP BY and ORDER BY clauses for the query
     $wheres = $this->_buildContentWhere();
     foreach ($wheres as $where) {
         $query->where(' ' . $where . ' ');
     }
     $query->group(' jpn.id ');
     $query->group(' jpn.app_id ');
     $query->order(' ' . $this->_buildContentOrderBy() . ' ');
     return $query;
 }
Example #2
0
 private function _buildQuery()
 {
     $query = $this->_db->getQuery(true);
     // persons
     $query->select(' jpn.app_id                     AS app_id ');
     $query->select(' jpn.id                	        AS id ');
     $query->select(' MIN( jpn.firstName )        	AS firstName ');
     $query->select(' MIN( jpn.patronym )         	AS patronym ');
     $query->select(JoaktreeHelper::getConcatenatedFamilyName() . ' AS familyName ');
     $query->select(' MIN( jpn.sex )              	AS sex ');
     $query->from(' #__joaktree_persons jpn ');
     // person administration
     $query->select(' MIN( jan.default_tree_id )  	AS default_tree_id ');
     $query->select(' MIN( jan.published )         	AS published ');
     $query->select(' MIN( jan.living )            	AS living ');
     $query->select(' MIN( jan.page )              	AS page ');
     $query->select(' MIN( jan.map )              	AS map ');
     $query->select(' MIN( jan.robots )            	AS robots ');
     $query->innerJoin(' #__joaktree_admin_persons  jan' . ' ON (   jan.app_id = jpn.app_id ' . '    AND jan.id     = jpn.id ' . '    ) ');
     // applications
     $query->select(' MIN( japp.title )              AS appTitle ');
     $query->innerJoin(' #__joaktree_applications  japp ' . ' ON (japp.id = jpn.app_id) ');
     // trees
     $query->select(' MIN( jte.name )              	AS familyTree ');
     $query->leftJoin(' #__joaktree_trees jte ' . ' ON (   jte.app_id     = jan.app_id ' . '    AND jte.id         = jan.default_tree_id ' . '    ) ');
     // births
     $query->select(' MIN( jpe1.eventDate )         	AS birthDate ');
     $query->select(' MIN( jpe1.location )        	AS birthPlace ');
     $query->leftJoin(' #__joaktree_person_events jpe1 ' . ' ON (   jpe1.app_id    = jpn.app_id ' . '    AND jpe1.person_id = jpn.id ' . '    AND jpe1.code = ' . $this->_db->Quote('BIRT') . ' ' . '    ) ');
     // deaths
     $query->select(' MIN( jpe2.eventDate )         	AS deathDate ');
     $query->select(' MIN( jpe2.location )        	AS deathPlace ');
     $query->leftJoin(' #__joaktree_person_events jpe2 ' . ' ON (   jpe2.app_id    = jpn.app_id ' . '    AND jpe2.person_id = jpn.id ' . '    AND jpe2.code = ' . $this->_db->Quote('DEAT') . ' ' . '    ) ');
     // burials
     $query->select(' MIN( jpe3.eventDate )        	AS burialDate ');
     $query->select(' MIN( jpe3.location )         	AS burialPlace ');
     $query->leftJoin(' #__joaktree_person_events jpe3 ' . ' ON (   jpe3.app_id    = jpn.app_id ' . '    AND jpe3.person_id = jpn.id ' . '    AND jpe3.code = ' . $this->_db->Quote('BURI') . ' ' . '    ) ');
     // person - period
     $attribs = array();
     $attribs[] = ' IFNULL(SUBSTR( RTRIM(jpe1.eventDate), -4 ), ' . $this->_db->Quote('?') . ' ) ';
     $attribs[] = ' SUBSTR(IFNULL( RTRIM(jpe2.eventDate), RTRIM(jpe3.eventDate) ), -4) ';
     $query->select(' MIN(' . $query->concatenate($attribs, ' - ') . ') AS period ');
     // WHERE, GROUP BY and ORDER BY clauses for the query
     $wheres = $this->_buildContentWhere();
     foreach ($wheres as $where) {
         $query->where(' ' . $where . ' ');
     }
     $query->group(' jpn.id ');
     $query->group(' jpn.app_id ');
     $query->order(' ' . $this->_buildContentOrderBy() . ' ');
     // ready
     return $query;
 }
Example #3
0
 private function _buildQuery()
 {
     $query = $this->_db->getQuery(true);
     // select from trees
     $query->select(' jte.id ');
     $query->select(' jte.app_id ');
     $query->select(' jte.holds ');
     $query->select(' jte.published ');
     $query->select(' jte.access ');
     $query->select(' jte.name ');
     $query->select(' jte.indGendex ');
     $query->select(' jte.root_person_id ');
     $query->from(' #__joaktree_trees        jte ');
     // select from applications
     $query->select(' japp.title     AS appTitle ');
     $query->leftJoin(' #__joaktree_applications japp ' . ' ON (japp.id = jte.app_id) ');
     // select from persons
     $query->select(' jpn.firstName ');
     $query->select(JoaktreeHelper::getConcatenatedFamilyName() . ' AS familyName ');
     $query->leftJoin(' #__joaktree_persons      jpn ' . ' ON (   jpn.app_id  = jte.app_id ' . '    AND jpn.id      = jte.root_person_id ' . '    ) ');
     // select from access
     $query->select(' vll.title      AS access_level ');
     $query->leftJoin(' #__viewlevels            vll ' . ' ON ( vll.id = jte.access ) ');
     // select from themes
     $query->select(' jth.name       AS theme ');
     $query->leftJoin(' #__joaktree_themes       jth ' . ' ON ( jth.id = jte.theme_id ) ');
     // count number of persons in tree
     $query->select(' COUNT(jtp.id)  AS numberOfPersons ');
     $query->leftJoin(' #__joaktree_tree_persons jtp ' . ' ON ( jtp.tree_id = jte.id ) ');
     // Get the WHERE, ORDER BY and GROUP BY clauses for the query
     $wheres = $this->_buildContentWhere();
     foreach ($wheres as $where) {
         $query->where(' ' . $where . ' ');
     }
     $query->group(' jte.id ');
     $query->group(' jte.app_id ');
     $query->group(' jte.holds ');
     $query->group(' jte.published ');
     $query->group(' jte.access ');
     $query->group(' jte.name ');
     $query->group(' jte.indGendex ');
     $query->group(' jte.root_person_id ');
     $query->group(' japp.title ');
     $query->group(' jpn.firstName ');
     $query->group(JoaktreeHelper::getConcatenatedFamilyName());
     $query->group(' vll.title ');
     $query->group(' jth.name ');
     $orderby = $this->_buildContentOrderBy();
     $query->order(' ' . $orderby . ' ');
     return $query;
 }
Example #4
0
 public function getItems()
 {
     // information is only selected for level: public
     $public = true;
     $userAccessLevels = '(1)';
     $displayAccess = JoaktreeHelper::getDisplayAccess($public);
     // retrieve persons
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     // select the basics
     $query->select(' jpn.app_id ');
     $query->select(' jpn.id ');
     $query->select(JoaktreeHelper::getSelectFirstName() . ' AS firstName ');
     $query->select(JoaktreeHelper::getConcatenatedFamilyName() . ' AS familyName ');
     $query->from(' #__joaktree_persons  jpn ');
     // privacy filter
     $query->select(' jan.default_tree_id  AS treeId ');
     $query->innerJoin(JoaktreeHelper::getJoinAdminPersons(false));
     $query->innerJoin(' #__joaktree_trees  jte ' . ' ON (   jte.app_id    = jan.app_id ' . '    AND jte.id        = jan.default_tree_id ' . '    AND jte.published = true ' . '    AND jte.access    IN ' . $userAccessLevels . ' ' . '    AND jte.indGendex = 2 ' . '    ) ');
     // birth info
     $query->select(' birth.eventDate  AS birthDate ');
     $query->select(' birth.location   AS birthPlace ');
     $query->leftJoin(' #__joaktree_person_events  birth ' . ' ON (   birth.app_id    = jpn.app_id ' . '    AND birth.person_id = jpn.id ' . '    AND birth.code      = ' . $this->_db->Quote('BIRT') . ' ' . '    AND (  (jan.living = false AND ' . $displayAccess['BIRTperson']->notLiving . ' = 2 ) ' . '        OR (jan.living = true  AND ' . $displayAccess['BIRTperson']->living . '    = 2 ) ' . '        ) ' . '    ) ');
     // death info
     $query->select(' death.eventDate  AS deathDate ');
     $query->select(' death.location   AS deathPlace ');
     $query->leftJoin(' #__joaktree_person_events  death ' . ' ON (   death.app_id    = jpn.app_id ' . '    AND death.person_id = jpn.id ' . '    AND death.code = ' . $this->_db->Quote('DEAT') . ' ' . '    AND (  (jan.living = false AND ' . $displayAccess['DEATperson']->notLiving . ' = 2 ) ' . '        OR (jan.living = true  AND ' . $displayAccess['DEATperson']->living . '    = 2 ) ' . '        ) ' . '    ) ');
     //$query = 'SELECT    jpn.app_id '
     //		.',         jpn.id '
     //		.',         jan.default_tree_id      AS treeId '
     //		.',         jpn.firstName '
     //		.',         CONCAT_WS('.$this->_db->quote(' ').' '
     //		.'                   , jpn.namePreposition '
     //		.'                   , jpn.familyName '
     //		.'                   )               AS familyName '
     //		// no alternative text is shown
     //		.',         birth.eventDate          AS birthDate '
     //		.',         birth.location           AS birthPlace '
     //		.',         death.eventDate          AS deathDate '
     //		.',         death.location           AS deathPlace '
     //		.'FROM      #__joaktree_persons           jpn '
     //		.'JOIN      #__joaktree_admin_persons     jan '
     //		.'ON        (   jan.app_id    = jpn.app_id '
     //		.'          AND jan.id        = jpn.id '
     //		.'          AND jan.published = true '
     //        // privacy filter
     //		.'          AND (  (jan.living = false AND '.$displayAccess['NAMEname']->notLiving.' = 2 ) '
     //		.'              OR (jan.living = true  AND '.$displayAccess['NAMEname']->living.'    = 2 ) '
     //		.'              ) '
     //		.'          ) '
     //		.'JOIN      #__joaktree_trees             jte '
     //		.'ON        (   jte.app_id    = jan.app_id '
     //		.'          AND jte.id        = jan.default_tree_id '
     //		.'          AND jte.published = true '
     //		.'          AND jte.access    IN '.$userAccessLevels.' '
     //		// only trees with Gendex = yes (=2)
     //		.'          AND jte.indGendex = 2 '
     //		.'          ) '
     //		.'LEFT JOIN #__joaktree_person_events birth '
     //		.'ON        (   birth.app_id    = jpn.app_id '
     //		.'          AND birth.person_id = jpn.id '
     //		.'          AND birth.code      = '.$this->_db->Quote('BIRT').' '
     //		// no alternative text is shown
     //		.'          AND (  (jan.living = false AND '.$displayAccess['BIRTperson']->notLiving.' = 2 ) '
     //		.'              OR (jan.living = true  AND '.$displayAccess['BIRTperson']->living.'    = 2 ) '
     //		.'              ) '
     //		.'          ) '
     //		.'LEFT JOIN #__joaktree_person_events death '
     //		.'ON        (   death.app_id    = jpn.app_id '
     //		.'          AND death.person_id = jpn.id '
     //		.'          AND death.code = '.$this->_db->Quote('DEAT').' '
     //		// no alternative text is shown
     //		.'          AND (  (jan.living = false AND '.$displayAccess['DEATperson']->notLiving.' = 2 ) '
     //		.'              OR (jan.living = true  AND '.$displayAccess['DEATperson']->living.'    = 2 ) '
     //		.'              ) '
     //		.'          ) ';
     $this->_db->setQuery($query);
     $result = $this->_db->loadObjectList();
     return $result;
 }
Example #5
0
 function __construct($id, $type = 'basic')
 {
     $this->_db =& JFactory::getDBO();
     $app = JFactory::getApplication();
     // get parameters
     $params = JoaktreeHelper::getJTParams();
     $patronymSetting = (int) $params->get('patronym');
     $patronymString = $params->get('patronymSeparation');
     // get user access info
     $this->_levels = JoaktreeHelper::getUserAccessLevels();
     $displayAccess = JoaktreeHelper::getDisplayAccess();
     // basic or full
     $indFull = $type != 'basic' && $type != 'ancestor';
     // retrieve person from database
     $query = $this->_db->getQuery(true);
     // select from persons
     $query->select(' jpn.app_id            AS app_id ');
     $query->select(' jpn.id                AS id ');
     // names
     if ($indFull) {
         $query->select(JoaktreeHelper::getSelectFirstName() . ' AS firstName ');
         $query->select(JoaktreeHelper::getSelectPatronym() . ' AS patronym ');
         $query->select(JoaktreeHelper::getConcatenatedFamilyName() . ' AS familyName ');
         $query->select(' jpn.namePreposition ');
         $query->select(' jpn.prefix ');
         $query->select(' jpn.suffix ');
         $query->select(' jpn.familyName        AS rawFamilyName ');
     } else {
         $query->select(JoaktreeHelper::getConcatenatedFullName() . ' AS fullName ');
     }
     $query->select(' jpn.sex               AS sex ');
     $query->select(' jpn.indHasParent ');
     $query->select(' jpn.indHasPartner ');
     $query->select(' jpn.indHasChild ');
     $query->select(' DATE_FORMAT( jpn.lastUpdateTimeStamp, "%e %b %Y" ) ' . '                       AS lastUpdateDate ');
     if ($indFull) {
         $query->select(' IF( (  (jan.living = false AND ' . $displayAccess['NOTEperson']->notLiving . ' > 0 ) ' . '     OR (jan.living = true  AND ' . $displayAccess['NOTEperson']->living . '    > 0 ) ' . '     ) ' . '   , jpn.indNote ' . '   , false ' . '   )                   AS indNote ');
         $query->select(' IF( (  (jan.living = false AND ' . $displayAccess['SOURperson']->notLiving . ' > 0 ) ' . '     OR (jan.living = true  AND ' . $displayAccess['SOURperson']->living . '    > 0 ) ' . '     ) ' . '   , jpn.indCitation ' . '   , false ' . '   )                   AS indCitation ');
     }
     $query->from(' #__joaktree_persons   jpn ');
     $query->where(' jpn.app_id    = ' . $id['app_id'] . ' ');
     $query->where(' jpn.id        = ' . $this->_db->Quote($id['person_id']) . ' ');
     // select from admin persons
     $query->select(' jan.living            AS living ');
     $query->select(' jan.published         AS published ');
     $query->select(' jan.page              AS page ');
     $query->select(' jan.map               AS map ');
     $query->select(' IF( ISNULL( NULLIF( jan.default_tree_id, 0) ) ' . '   , false ' . '   , jan.page ' . '   )                   AS indHasPage ');
     $query->select(' IF( (  (jan.living = false AND ' . $displayAccess['NAMEname']->notLiving . ' > 0 ) ' . '     OR (jan.living = true  AND ' . $displayAccess['NAMEname']->living . '    > 0 ) ' . '     ) ' . '   , true ' . '   , false ' . '   )                   AS indNameDisplay ');
     $query->select(' IF((jan.robots > 0), jan.robots, jte.robots ) AS robots ');
     if ($indFull) {
         $query->select(' IF( (jan.living = true AND ' . $displayAccess['NAMEname']->living . ' = 1 ) ' . '   , true ' . '   , false ' . '   )                   AS indAltName ');
         $query->select(' IF( (jan.living = true AND ' . $displayAccess['NOTEperson']->living . ' = 1 ) ' . '   , true ' . '   , false ' . '   )                   AS indAltNote ');
         $query->select(' IF( (jan.living = true AND ' . $displayAccess['SOURperson']->living . ' = 1 ) ' . '   , true ' . '   , false ' . '   )                   AS indAltSource ');
     }
     $query->innerJoin(JoaktreeHelper::getJoinAdminPersons(true));
     if ($indFull) {
         // select from tree x persons
         $query->select(' jtp.tree_id           AS tree_id ');
         $query->select(' jtp.lineage ');
         $query->innerJoin(' #__joaktree_tree_persons  jtp ' . ' ON (   jtp.app_id    = jpn.app_id ' . '    AND jtp.person_id = jpn.id ' . '    AND jtp.tree_id   = ' . $id['tree_id'] . ' ' . '    ) ');
         $query->innerJoin(' #__joaktree_trees         jte ' . ' ON (   jte.app_id    = jtp.app_id ' . '    AND jte.id        = jtp.tree_id ' . '    AND jte.published = true ' . '    AND jte.access    IN ' . $this->_levels . ' ' . '    ) ');
     } else {
         // select from default tree
         $query->select(' jte.id                AS tree_id ');
         $query->leftJoin(' #__joaktree_trees    jte ' . ' ON (   jte.app_id    = jan.app_id ' . '    AND jte.id        = jan.default_tree_id ' . '    AND jte.published = true ' . '    AND jte.access    IN ' . $this->_levels . ' ' . '    ) ');
     }
     // select birth and death dates for ancestors
     if ($type == 'ancestor') {
         // select from birth
         $query->select(' MIN( IF( (jan.living = true AND ' . $displayAccess['BIRTperson']->living . ' = 1 ) ' . '        , NULL ' . '        , birth.eventDate ' . '        ) ' . '    ) AS birthDate ');
         $query->leftJoin(' #__joaktree_person_events birth ' . ' ON (   birth.app_id    = jpn.app_id ' . '    AND birth.person_id = jpn.id ' . '    AND birth.code      = ' . $this->_db->Quote('BIRT') . ' ' . '    AND (  (jan.living = false AND ' . $displayAccess['BIRTperson']->notLiving . ' > 0 ) ' . '        OR (jan.living = true  AND ' . $displayAccess['BIRTperson']->living . '    > 0 ) ' . '        ) ' . '    ) ');
         // select from death
         $query->select(' MIN( IF( (jan.living = true AND ' . $displayAccess['DEATperson']->living . ' = 1 ) ' . '        , NULL ' . '        , death.eventDate ' . '        ) ' . '    ) AS deathDate ');
         $query->leftJoin(' #__joaktree_person_events death ' . ' ON (   death.app_id    = jpn.app_id ' . '    AND death.person_id = jpn.id ' . '    AND death.code = ' . $this->_db->Quote('DEAT') . ' ' . '    AND (  (jan.living = false AND ' . $displayAccess['DEATperson']->notLiving . ' > 0 ) ' . '        OR (jan.living = true  AND ' . $displayAccess['DEATperson']->living . '    > 0 ) ' . '        ) ' . '    ) ');
         $query->group(' jpn.app_id ');
         $query->group(' jpn.id ');
         $query->group(JoaktreeHelper::getConcatenatedFullName());
         $query->group(' jpn.sex ');
         $query->group(' jpn.indHasParent ');
         $query->group(' jpn.indHasPartner ');
         $query->group(' jpn.indHasChild ');
         $query->group(' DATE_FORMAT( jpn.lastUpdateTimeStamp, "%e %b %Y" ) ');
         // select from admin persons
         $query->group(' jan.living ');
         $query->group(' jan.published ');
         $query->group(' jan.page ');
         $query->group(' jan.map ');
         $query->group(' IF( ISNULL( NULLIF( jan.default_tree_id, 0) ) ' . '   , false ' . '   , jan.page ' . '   ) ');
         $query->group(' IF( (  (jan.living = false AND ' . $displayAccess['NAMEname']->notLiving . ' > 0 ) ' . '     OR (jan.living = true  AND ' . $displayAccess['NAMEname']->living . '    > 0 ) ' . '     ) ' . '   , true ' . '   , false ' . '   ) ');
         $query->group(' IF((jan.robots > 0), jan.robots, jte.robots ) ');
         $query->group(' jte.id ');
     }
     $this->_db->setQuery($query);
     $person = $this->_db->loadAssoc();
     // Check for a error.
     if ($error = $this->_db->getErrorMsg()) {
         throw new JException($error);
     }
     if (!$person && $indFull) {
         $query->clear();
         // select from persons
         $query->select(' jpn.app_id            AS app_id ');
         $query->select(' jpn.id                AS id ');
         $query->select(JoaktreeHelper::getSelectFirstName() . ' AS firstName ');
         $query->select(JoaktreeHelper::getSelectPatronym() . ' AS patronym ');
         $query->select(JoaktreeHelper::getConcatenatedFamilyName() . ' AS familyName ');
         $query->select(' jpn.namePreposition ');
         $query->select(' jpn.prefix ');
         $query->select(' jpn.suffix ');
         $query->select(' jpn.familyName        AS rawFamilyName ');
         $query->select(' jpn.sex               AS sex ');
         $query->select(' jpn.indHasParent ');
         $query->select(' jpn.indHasPartner ');
         $query->select(' jpn.indHasChild ');
         $query->select(' IF( (  (jan.living = false AND ' . $displayAccess['NOTEperson']->notLiving . ' > 0 ) ' . '     OR (jan.living = true  AND ' . $displayAccess['NOTEperson']->living . '    > 0 ) ' . '     ) ' . '   , jpn.indNote ' . '   , false ' . '   )                   AS indNote ');
         $query->select(' IF( (  (jan.living = false AND ' . $displayAccess['SOURperson']->notLiving . ' > 0 ) ' . '     OR (jan.living = true  AND ' . $displayAccess['SOURperson']->living . '    > 0 ) ' . '     ) ' . '   , jpn.indCitation ' . '   , false ' . '   )                   AS indCitation ');
         $query->select(' DATE_FORMAT( jpn.lastUpdateTimeStamp, "%e %b %Y" ) ' . '                       AS lastUpdateDate ');
         $query->from(' #__joaktree_persons   jpn ');
         $query->where(' jpn.app_id    = ' . $id['app_id'] . ' ');
         $query->where(' jpn.id        = ' . $this->_db->Quote($id['person_id']) . ' ');
         $query->where(' NOT EXISTS ' . ' ( SELECT 1 ' . '   FROM   #__joaktree_tree_persons  jtp2 ' . '   WHERE  jtp2.app_id    = jpn.app_id ' . '   AND    jtp2.person_id = jpn.id ' . '   AND    jtp2.tree_id   = ' . $id['tree_id'] . ' ' . ' ) ');
         // select from tree x persons
         $query->select(' IFNULL( jan.default_tree_id ' . '       , ' . $id['tree_id'] . ' ' . '       )               AS tree_id ');
         // select from admin persons
         $query->select(' jan.living            AS living ');
         $query->select(' jan.published         AS published ');
         $query->select(' jan.page              AS page ');
         $query->select(' jan.map               AS map ');
         $query->select(' IF( ISNULL( NULLIF( jan.default_tree_id, 0) ) ' . '   , false ' . '   , jan.page ' . '   )                   AS indHasPage ');
         $query->select(' IF( (  (jan.living = false AND ' . $displayAccess['NAMEname']->notLiving . ' > 0 ) ' . '     OR (jan.living = true  AND ' . $displayAccess['NAMEname']->living . '    > 0 ) ' . '     ) ' . '   , true ' . '   , false ' . '   )                   AS indNameDisplay ');
         $query->select(' IF( (jan.living = true AND ' . $displayAccess['NAMEname']->living . ' = 1 ) ' . '   , true ' . '   , false ' . '   )                   AS indAltName ');
         $query->select(' IF( (jan.living = true AND ' . $displayAccess['NOTEperson']->living . ' = 1 ) ' . '   , true ' . '   , false ' . '   )                   AS indAltNote ');
         $query->select(' IF( (jan.living = true AND ' . $displayAccess['SOURperson']->living . ' = 1 ) ' . '   , true ' . '   , false ' . '   )                   AS indAltSource ');
         $query->innerJoin(JoaktreeHelper::getJoinAdminPersons(true));
         // robots
         $query->select(' IF((jan.robots > 0), jan.robots, jte.robots ) AS robots ');
         $query->leftJoin(' #__joaktree_trees    jte ' . ' ON (   jte.app_id    = jan.app_id ' . '    AND jte.id        = IFNULL( jan.default_tree_id ' . '                              , ' . $id['tree_id'] . ' ' . '                              ) ' . '    AND jte.published = true ' . '    AND jte.access    IN ' . $this->_levels . ' ' . '    ) ');
         $this->_db->setQuery($query);
         $person = $this->_db->loadAssoc();
         // Check for a error.
         if ($error = $this->_db->getErrorMsg()) {
             throw new JException($error);
         }
     }
     $this->app_id = $person['app_id'];
     $this->id = $person['id'];
     $this->tree_id = $person['tree_id'];
     $this->sex = $person['sex'];
     $this->indHasParent = $person['indHasParent'];
     $this->indHasPartner = $person['indHasPartner'];
     $this->indHasChild = $person['indHasChild'];
     $this->lastUpdateDate = $person['lastUpdateDate'];
     $this->living = $person['living'];
     $this->published = $person['published'];
     $this->page = $person['page'];
     $this->map = $person['map'];
     $this->indHasPage = $person['indHasPage'];
     $this->indNameDisplay = $person['indNameDisplay'];
     $this->robots = $person['robots'];
     // names
     if ($indFull) {
         // when patronyms are shown, there are concatenated to the first name
         $this->firstName = $person['firstName'];
         $this->patronym = $person['patronym'];
         if ($patronymSetting == 0 or $this->patronym == null) {
             $this->firstNamePatronym = $this->firstName;
         } else {
             $this->firstNamePatronym = $this->firstName . ' ' . $patronymString . $person['patronym'] . $patronymString;
         }
         $this->familyName = $person['familyName'];
         $this->prefix = $person['prefix'];
         $this->suffix = $person['suffix'];
         $this->namePreposition = $person['namePreposition'];
         $this->rawFamilyName = $person['rawFamilyName'];
         $this->indNote = $person['indNote'];
         $this->indCitation = $person['indCitation'];
         $this->indAltName = $person['indAltName'];
         $this->indAltNote = $person['indAltNote'];
         $this->indAltSource = $person['indAltSource'];
         $this->lineage = isset($person['lineage']) ? trim($person['lineage']) : null;
     } else {
         $this->fullName = $person['fullName'];
     }
     if ($type == 'ancestor') {
         $this->birthDate = JoaktreeHelper::displayDate($person['birthDate']);
         $this->deathDate = JoaktreeHelper::displayDate($person['deathDate']);
     }
     $this->secondParent_id = null;
     $this->family_id = null;
     $this->relationtype = null;
     $this->orderNr = null;
     $this->languageFilter = $app->getLanguageFilter();
     if (isset($person['tree_id']) && $person['tree_id']) {
         $menus = $this->getMenus();
         $this->menuItemId = $menus[$person['tree_id']];
     }
     if (!isset($this->menuItemId)) {
         $menu = $app->getMenu();
         $item = $menu->getActive();
         $this->menuItemId = $item->id;
     }
 }