コード例 #1
0
ファイル: familylist.php プロジェクト: Lothurm/J3.x
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  * @since   11.1
  */
 protected function getOptions()
 {
     // Possible actions are: addparent, addchild, addpartner
     // Initialize variables.
     $appId = JoaktreeHelper::getApplicationId();
     $action = JoaktreeHelper::getAction();
     $personId = JoaktreeHelper::getRelationId();
     // Initialize variables.
     $options = array();
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     switch ($action) {
         case "addparent":
             // family for adding parents
             // select all parents of the person, and for every parent its family-id
             $query->select(' jrn.family_id ');
             $query->select(' jrn.person_id_2 AS pid2 ');
             $query->from(' #__joaktree_relations  jrn ');
             $query->where(' jrn.app_id      = ' . $appId . ' ');
             $query->where(' jrn.person_id_1 = ' . $db->quote($personId) . ' ');
             $query->where(' jrn.type        IN (' . $db->quote('father') . ', ' . $db->quote('mother') . ') ');
             $query->select(JoaktreeHelper::getConcatenatedFullName() . ' AS fullName ');
             $query->innerJoin(' #__joaktree_persons  jpn ' . ' ON (   jpn.app_id = jrn.app_id ' . '    AND jpn.id     = jrn.person_id_2 ' . '    ) ');
             $query->innerJoin(JoaktreeHelper::getJoinAdminPersons());
             break;
         case "addchild":
             // family for adding children
             // select all partners of the person, and for every partner its family-id
             $query->select(' jrn.family_id ');
             $query->select(' IF( (jrn.person_id_1 = ' . $db->quote($personId) . ') ' . '   , jrn.person_id_2 ' . '   , jrn.person_id_1 ' . '   ) AS pid2 ');
             $query->from(' #__joaktree_relations  jrn ');
             $query->where(' jrn.app_id      = ' . $appId . ' ');
             $query->where(' (  jrn.person_id_1 = ' . $db->quote($personId) . ' ' . ' OR jrn.person_id_2 = ' . $db->quote($personId) . ' ' . ' ) ');
             $query->where(' jrn.type        = ' . $db->quote('partner') . ' ');
             $query->select(JoaktreeHelper::getConcatenatedFullName() . ' AS fullName ');
             $query->innerJoin(' #__joaktree_persons  jpn ' . ' ON (   jpn.app_id = jrn.app_id ' . '    AND (  jpn.id     = jrn.person_id_1 ' . '        OR jpn.id     = jrn.person_id_2 ' . '        ) ' . '    AND jpn.id != ' . $db->quote($personId) . ' ' . '    ) ');
             $query->innerJoin(JoaktreeHelper::getJoinAdminPersons());
             break;
         default:
             // continue
             break;
     }
     if ($action == 'addparent' || $action == 'addchild') {
         // Set the query and get the result list.
         $db->setQuery($query);
         $items = $db->loadObjectlist();
         // Check for an error.
         if ($db->getErrorNum()) {
             JError::raiseWarning(500, $db->getErrorMsg());
             return $options;
         }
         // Build the field options.
         if (!empty($items)) {
             foreach ($items as $item) {
                 $options[] = JHtml::_('select.option', $item->pid2 . '!' . $item->family_id, $item->fullName);
             }
         }
     }
     if ($action == 'addpartner' || $action == 'addchild') {
         // select family-id of single parent families.
         // new partner or new child may be added to this family
         $query->clear();
         $query->select(' DISTINCT jrn.family_id ');
         $query->from(' #__joaktree_relations  jrn ');
         $query->where(' jrn.app_id = ' . $appId . ' ');
         $query->where(' jrn.person_id_2 = ' . $db->quote($personId) . ' ');
         $query->where(' jrn.type IN (' . $db->quote('father') . ', ' . $db->quote('mother') . ') ');
         $query->where(' NOT EXISTS ' . ' ( SELECT 1 ' . '   FROM   #__joaktree_relations  jrn2 ' . '   WHERE  jrn2.app_id    = jrn.app_id ' . '   AND    jrn2.family_id = jrn.family_id ' . '   AND    jrn2.type      = ' . $db->quote('partner') . ' ' . ' ) ');
         $query->select(' GROUP_CONCAT(jpn.firstName SEPARATOR ' . $db->quote(', ') . ') AS names ');
         $query->innerJoin(' #__joaktree_persons  jpn ' . ' ON (   jpn.app_id = jrn.app_id ' . '    AND jpn.id     = jrn.person_id_1 ' . '    ) ');
         $query->innerJoin(JoaktreeHelper::getJoinAdminPersons());
         $db->setQuery($query);
         $familyId = $db->loadObject();
     }
     // if familyId is unknown (either in case of addparent, of with no result for the last query
     // the familyId is set to be '0'. The option is added to the list.
     switch ($action) {
         case "addparent":
             $options[] = JHtml::_('select.option', '0!0', JText::_('JT_NEWFAMILY1'));
             break;
         case "addchild":
             $familyId = is_object($familyId) && $familyId->family_id ? $familyId->family_id : '0';
             $options[] = JHtml::_('select.option', '0!' . $familyId, JText::_('JT_NEWFAMILY3'));
             break;
         case "addpartner":
             if (is_object($familyId) && $familyId->family_id) {
                 $options[] = JHtml::_('select.option', '0!' . $familyId->family_id, $familyId->names);
             }
             // finally we add the option for a new partner / new family
             $options[] = JHtml::_('select.option', '0!0', JText::_('JT_NEWFAMILY2'));
             break;
         default:
             // continue
             break;
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
コード例 #2
0
ファイル: joaktreestart.php プロジェクト: Lothurm/J3.x
 private function _buildQuery()
 {
     $params = JoaktreeHelper::getJTParams();
     //JComponentHelper::getParams('com_joaktree') ;
     $abbreviation = (int) $params->get('abbreviation', 0);
     $levels = JoaktreeHelper::getUserAccessLevels();
     $displayAccess = JoaktreeHelper::getDisplayAccess();
     if ($abbreviation == null or $abbreviation <= 0) {
         // no abbreviation of names
         $displayFamilyName = JoaktreeHelper::getConcatenatedDutchFamilyName(false);
     } else {
         // abbreviation on n characters, where n = $abbreviation
         $displayFamilyName = 'SUBSTR( ' . JoaktreeHelper::getConcatenatedDutchFamilyName(false) . ' ' . '      , 1 ' . '      , ' . $abbreviation . ' ' . '      )';
     }
     $query = $this->_db->getQuery(true);
     $query->select(' COUNT(' . $displayFamilyName . ') AS nameCount ');
     $query->select(' ' . $displayFamilyName . ' AS familyName ');
     $query->from(' #__joaktree_tree_persons jtp ');
     $query->innerJoin(' #__joaktree_trees        jte ' . ' ON (   jte.app_id = jtp.app_id ' . '    AND jte.id     = jtp.tree_id ' . '    ) ');
     $query->innerJoin(' #__joaktree_persons      jpn ' . ' ON (   jpn.app_id = jtp.app_id ' . '    AND jpn.id     = jtp.person_id ' . '    ) ');
     $query->innerJoin(JoaktreeHelper::getJoinAdminPersons(false));
     // Get the WHERE clauses for the query
     $wheres = $this->_buildContentWhere();
     foreach ($wheres as $where) {
         $query->where(' ' . $where . ' ');
     }
     // GROUP BY
     $query->group(' ' . $displayFamilyName . ' ');
     return $query;
 }
コード例 #3
0
ファイル: changehistory.php プロジェクト: Lothurm/J3.x
 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;
 }
コード例 #4
0
ファイル: gendex.php プロジェクト: Lothurm/J3.x
 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;
 }
コード例 #5
0
ファイル: joaktreelist.php プロジェクト: Lothurm/J3.x
 private function getPartnerSet($number1, $appId, $personId)
 {
     $db = JFactory::getDBO();
     $number2 = $number1 == '1' ? '2' : '1';
     $query = $db->getQuery(true);
     // select relationship
     $query->select(' jrn.family_id ');
     $query->select(' jrn.person_id_' . $number2 . ' AS relation_id ');
     $query->from(' #__joaktree_relations  jrn ');
     $query->where(' jrn.app_id = ' . $appId . ' ');
     $query->where(' jrn.person_id_' . $number1 . ' = ' . $db->quote($personId) . ' ');
     $query->where(' jrn.type = ' . $db->quote('partner') . ' ');
     // select name partner
     $query->select(JoaktreeHelper::getConcatenatedFullName() . ' AS fullName ');
     $query->innerJoin(' #__joaktree_persons  jpn ' . ' ON (   jpn.app_id = jrn.app_id ' . '    AND jpn.id     = jrn.person_id_' . $number2 . ' ' . '    ) ');
     // select from admin persons
     $query->innerJoin(JoaktreeHelper::getJoinAdminPersons());
     $db->setQuery($query);
     $partners = $db->loadAssocList();
     return $partners;
 }
コード例 #6
0
ファイル: helper.php プロジェクト: Lothurm/J3.x
 public static function getList($numberInList)
 {
     // get cookie
     $params = JComponentHelper::getParams('com_joaktree');
     $indCookie = $params->get('indCookies', false);
     if (!$indCookie) {
         return false;
     }
     // array to return
     $person = array();
     // we fetch the cookie
     $cookie = new JInputCookie();
     $tmp = $cookie->get('jt_last_persons', '', 'string');
     // prepare the array
     if ($tmp) {
         $cookieList = (array) json_decode(base64_decode($tmp));
     } else {
         $cookieList = array();
     }
     if (count($cookieList)) {
         $db = JFactory::getDBO();
         $query = $db->getQuery(true);
         // get user access info
         $levels = JoaktreeHelper::getUserAccessLevels();
         // set up maximum number of items
         $maxItem = count($cookieList) > $numberInList ? $numberInList : count($cookieList);
         // get menuId & technology
         $menus = JoaktreeHelper::getMenus('joaktree');
         $linkBase = 'index.php?option=com_joaktree&view=joaktree';
         for ($i = 0; $i < $maxItem; $i++) {
             $query->clear();
             // item is a string separated by !: app_id, person_id, tree_id;
             $elements = explode('!', array_shift($cookieList));
             // retrieve person
             $app_id = array_shift($elements);
             $person_id = array_shift($elements);
             $tree_id = array_shift($elements);
             if (!empty($app_id) && !empty($person_id) && !empty($tree_id)) {
                 $query->select(JoaktreeHelper::getConcatenatedFullName() . ' AS fullName ');
                 $query->from(' #__joaktree_persons   jpn ');
                 $query->where(' jpn.app_id    = ' . $app_id . ' ');
                 $query->where(' jpn.id        = ' . $db->Quote($person_id) . ' ');
                 // join with admin persons
                 $query->innerJoin(JoaktreeHelper::getJoinAdminPersons(true));
                 // join with trees
                 $query->innerJoin(' #__joaktree_tree_persons  jtp ' . ' ON (   jtp.app_id    = jpn.app_id ' . '    AND jtp.person_id = jpn.id ' . '    AND jtp.tree_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 ' . $levels . ' ' . '    ) ');
                 // fetch from database
                 $db->setQuery($query);
                 $tmpPerson = $db->loadObject();
                 if ($tree_id && isset($menus[$tree_id])) {
                     $menuItemId = $menus[$tree_id];
                     $tmpPerson->route = JRoute::_($linkBase . '&Itemid=' . $menuItemId . '&treeId=' . $tree_id . '&personId=' . $app_id . '!' . $person_id);
                     $tmpPerson->robot = '';
                 } else {
                     $tmpPerson->route = 0;
                     $tmpPerson->robot = '';
                 }
                 if (!empty($tmpPerson->fullName)) {
                     $person[] = $tmpPerson;
                 }
                 unset($tmpPerson);
             }
         }
     }
     return $person;
 }
コード例 #7
0
ファイル: person.php プロジェクト: Lothurm/J3.x
 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;
     }
 }