コード例 #1
0
ファイル: ancestors.php プロジェクト: Lothurm/J3.x
 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;
 }
コード例 #2
0
ファイル: interactivemap.php プロジェクト: Lothurm/J3.x
 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();
 }
コード例 #3
0
ファイル: helper.php プロジェクト: Lothurm/J3.x
 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;
 }
コード例 #4
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;
 }
コード例 #5
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;
 }
コード例 #6
0
ファイル: source.php プロジェクト: Lothurm/J3.x
 public function getApplicationId()
 {
     return JoaktreeHelper::getApplicationId();
 }
コード例 #7
0
ファイル: helper.php プロジェクト: Lothurm/J3.x
 function getTreeId($intern = false, $requestonly = false)
 {
     static $_treeId;
     if (!isset($_treeId)) {
         $db = JFactory::getDBO();
         $input = JFactory::getApplication()->input;
         $tmp1 = $input->get('treeId', null, 'string');
         $tmp2 = $input->get('treeId', null, 'int');
         if (empty($tmp2) && !$requestonly) {
             // no tree id in request, try the parameters.
             $params = self::getJTParams($requestonly);
             $tmp1 = $params->get('treeId');
             $tmp2 = (int) $tmp1;
         }
         if (empty($tmp2)) {
             // no treeId is given in request
             if ($intern) {
                 // Function is called from getPersonId
                 // That means that there is also no person given in request.
                 die('wrong request');
             } else {
                 $personId = JoaktreeHelper::getPersonId(true, $requestonly);
                 $app_id = JoaktreeHelper::getApplicationId(true, $requestonly);
                 $levels = self::getUserAccessLevels();
                 if (isset($personId) and isset($app_id) and isset($levels)) {
                     $query = $db->getQuery(true);
                     $query->select(' jan.default_tree_id ');
                     $query->from(' #__joaktree_admin_persons  jan ');
                     $query->innerJoin(' #__joaktree_trees  jte ' . 'ON     (   jte.app_id = jan.app_id ' . '       AND jte.id     = jan.default_tree_id ' . '       ) ');
                     $query->where(' jan.app_id    = ' . $app_id . ' ');
                     $query->where(' jan.id        = ' . $db->Quote($personId) . ' ');
                     $query->where(' jan.published = true ');
                     $query->where(' jte.access    IN ' . $levels . ' ');
                     $query->where(' jte.published = true ');
                     $db->setQuery($query);
                     $tmp3 = $db->loadResult();
                     if ($error = $db->getErrorMsg()) {
                         throw new JException($error);
                     }
                     if ($tmp3 == null) {
                         // Nothing is retrieved. Person does not exists or has an emtpy default tree.
                         // We set treeId to 0, and let the standard no access message be the result.
                         $tmp3 = 0;
                     }
                 } else {
                     $tmp3 = 0;
                 }
             }
         } else {
             // something is given -> check this
             if ($tmp1 !== (string) $tmp2) {
                 die('wrong request');
             } else {
                 if ($tmp2 <= 0) {
                     die('wrong request');
                 } else {
                     $tmp3 = intval($tmp2);
                 }
             }
         }
         $_treeId = $db->escape($tmp3);
     }
     return $_treeId;
 }