コード例 #1
0
ファイル: joaktreestart.php プロジェクト: Lothurm/J3.x
 public function getUserAccess()
 {
     return JoaktreeHelper::getUserAccess();
 }
コード例 #2
0
ファイル: helper.php プロジェクト: Lothurm/J3.x
 function getJoaktreeList()
 {
     $related = array();
     $jt_likes = array();
     // we only searching for persons when currently one article is shown
     if ($this->_option == 'com_content' && $this->_view == 'article' && $this->_id) {
         $params = JComponentHelper::getParams('com_joaktree');
         $indArticleLink = (int) $params->get('indArticleLink', 9);
         // we only searching for persons when Joaktree setting is set
         if ($indArticleLink != 0) {
             $displayAccess = JoaktreeHelper::getDisplayAccess();
             $userAccess = JoaktreeHelper::getUserAccess();
             $accessLevels = JoaktreeHelper::getUserAccessLevels();
             // select the meta keywords from the item
             $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) {
                         // no commas
                         $jt_likes[] = $this->_db->escape($key);
                     }
                 }
             }
             // process the "jt_likes" - search in joaktree tables
             if (count($jt_likes)) {
                 // select from Joaktree tables
                 $query->clear();
                 $query->select(' jpn.app_id ');
                 $query->select(' jpn.id ');
                 $query->select(' CONCAT_WS( ' . $this->_db->quote(' ') . ' ' . '          , jpn.firstName ' . '          , jpn.namePreposition ' . '          , jpn.familyName ' . '          )           AS title ');
                 $query->select(' NULL                 AS created ');
                 $query->select(' jan.default_tree_id  AS catid ');
                 $query->select(' NULL                 AS cat_access ');
                 $query->select(' NULL                 AS cat_state ');
                 $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 = 1 ' . '    AND jan.page      = 1 ' . '    AND (  (jan.living = false AND ' . $displayAccess['NAMEname']->notLiving . ' = 2 ) ' . '        OR (jan.living = true  AND ' . $displayAccess['NAMEname']->living . '    = 2 ) ' . '        ) ' . '    ) ');
                 $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 ' . $accessLevels . ' ' . '    ) ');
                 // section to set the where-clause
                 if ($indArticleLink == 9) {
                     // 9: All options
                     $query->where(' jpn.id = "' . implode('" OR jpn.id = "', $jt_likes) . '" ' . ' OR CONCAT_WS( ' . $this->_db->quote('!') . ' ' . '             , jpn.app_id ' . '             , jpn.id ' . '             ) = "' . implode('" OR CONCAT_WS( ' . $this->_db->quote('!') . ' ' . '                                            , jpn.app_id ' . '                                            , jpn.id ' . '                                            ) = "', $jt_likes) . '" ' . ' OR CONCAT_WS( ' . $this->_db->quote(' ') . ' ' . '             , jpn.firstName ' . '             , jpn.namePreposition ' . '             , jpn.familyName ' . '             ) ' . '    LIKE "%' . implode('%" OR CONCAT_WS( ' . $this->_db->quote(' ') . ' ' . '                                      , jpn.firstName ' . '                                      , jpn.namePreposition ' . '                                      , jpn.familyName ' . '                                      ) LIKE "%', $jt_likes) . '%" ');
                 }
                 if ($indArticleLink == 1) {
                     // 1: By ID
                     $query->where(' jpn.id = "' . implode('" OR jpn.id = "', $jt_likes) . '" ' . ' OR CONCAT_WS( ' . $this->_db->quote('!') . ' ' . '             , jpn.app_id ' . '             , jpn.id ' . '             ) = "' . implode('" OR CONCAT_WS( ' . $this->_db->quote('!') . ' ' . '                                            , jpn.app_id ' . '                                            , jpn.id ' . '                                            ) = "', $jt_likes) . '" ');
                 }
                 if ($indArticleLink == 2) {
                     // 2: By first name
                     $query->where(' jpn.firstName ' . '   LIKE "%' . implode('%" OR jpn.firstName LIKE "%', $jt_likes) . '%" ');
                 }
                 if ($indArticleLink == 3) {
                     // 3: By family name
                     $query->where(' CONCAT_WS( ' . $this->_db->quote(' ') . ' ' . '          , jpn.namePreposition ' . '          , jpn.familyName ' . '          ) ' . ' LIKE "%' . implode('%" OR CONCAT_WS( ' . $this->_db->quote(' ') . ' ' . '                                   , jpn.namePreposition ' . '                                   , jpn.familyName ' . '                                   ) LIKE "%', $jt_likes) . '%" ');
                 }
                 if ($indArticleLink == 4 or $indArticleLink == 5) {
                     // 4: By first + family name; 5: All names
                     $query->where(' CONCAT_WS( ' . $this->_db->quote(' ') . ' ' . '          , jpn.firstName ' . '          , jpn.namePreposition ' . '          , jpn.familyName ' . '          ) ' . ' LIKE "%' . implode('%" OR CONCAT_WS( ' . $this->_db->quote(' ') . ' ' . '                                   , jpn.firstName ' . '                                   , jpn.namePreposition ' . '                                   , jpn.familyName ' . '                                   ) LIKE "%', $jt_likes) . '%" ');
                 }
                 // end section for setting where-clause -> continue with creating the query
                 $query->order(' CONCAT_WS( ' . $this->_db->quote(' ') . ' ' . '          , jpn.firstName ' . '          , jpn.namePreposition ' . '          , jpn.familyName ' . '          ) ');
                 $this->_db->setQuery($query);
                 $temp = $this->_db->loadObjectList();
                 if (count($temp)) {
                     // get menuId & technology
                     $menus = JoaktreeHelper::getMenus('joaktree');
                     $technology = JoaktreeHelper::getTechnology();
                     $linkBase = 'index.php?option=com_joaktree&view=joaktree&tech=' . $technology . '';
                     foreach ($temp as $row) {
                         $menuItemId = $menus[$row->catid];
                         $row->route = JRoute::_($linkBase . '&Itemid=' . $menuItemId . '&treeId=' . $row->catid . '&personId=' . $row->app_id . '!' . $row->id);
                         $row->robot = $technology == 'a' ? '' : 'rel="noindex, nofollow"';
                         $related[] = $row;
                     }
                 }
                 unset($temp);
             }
         }
     }
     return $related;
 }
コード例 #3
0
ファイル: todaymanyyearsago.php プロジェクト: Lothurm/J3.x
 public function getList($moduleId)
 {
     $moduleId = (int) $moduleId;
     $params = $this->getModuleParams($moduleId);
     $periodType = $params->get('periodType');
     $limit = (int) $params->get('searchlimit', 10);
     $userAccessLevels = JoaktreeHelper::getUserAccessLevels();
     $personStatus = $params->get('personStatus', 0);
     $showTitle = $params->get('showHeading', 1);
     $today = getdate();
     if ($params->get('freeChoice')) {
         // only when user is allowed to enter a day/month we are checking these values.
         $day = JoaktreeHelper::getDay();
         $month = JoaktreeHelper::getMonth();
     }
     // for titles we want to know if we have day and/or months from the front end
     $indUI = !isset($day) && !isset($month) || $day == 0 && $month == 0 ? false : true;
     // if day and/or month is not set, we use today's info
     $day = !isset($day) || $day == 0 ? $today['mday'] : $day;
     $month = !isset($month) || $month == 0 ? $today['mon'] : $month;
     if ($showTitle == 1) {
         if (!$indUI) {
             // nothing from front end -> use standard titles
             switch ($periodType) {
                 case 2:
                     // continue
                 // continue
                 case 3:
                     $this->_title = JText::_('JTMOD_TMYA_HEADING_THISMONTH');
                     break;
                 case 4:
                     // continue
                 // continue
                 case 5:
                     $this->_title = JText::_('JTMOD_TMYA_HEADING_THISWEEK');
                     break;
                 case 0:
                     // continue
                 // continue
                 case 1:
                     // continue
                 // continue
                 default:
                     $this->_title = JText::_('JTMOD_TMYA_HEADING_TODAY');
                     break;
             }
         } else {
             // use information from front end
             switch ($periodType) {
                 case 2:
                     // continue
                 // continue
                 case 3:
                     $this->_title = JText::_($this->getMonthName($month));
                     break;
                 case 4:
                     // continue
                 // continue
                 case 5:
                     // continue
                 // continue
                 case 0:
                     // continue
                 // continue
                 case 1:
                     // continue
                 // continue
                 default:
                     $this->_title = $day . ' ' . JText::_($this->getMonthName($month));
                     break;
             }
         }
     } else {
         $this->_title = null;
     }
     switch ($periodType) {
         case 2:
             // continue
         // continue
         case 3:
             $this->_buttonText = JText::_('JTMOD_TMYA_HEADING_THISMONTH');
             break;
         case 4:
             // continue
         // continue
         case 5:
             $this->_buttonText = JText::_('JTMOD_TMYA_HEADING_THISWEEK');
             break;
         case 0:
             // continue
         // continue
         case 1:
             // continue
         // continue
         default:
             $this->_buttonText = JText::_('JTMOD_TMYA_HEADING_TODAY');
             break;
     }
     $result = array();
     $displayAccess = JoaktreeHelper::getDisplayAccess();
     $userAccess = JoaktreeHelper::getUserAccess();
     $where = $this->_buildContentWhere($day, $month, $today['year']);
     $order = $this->_buildOrderBy();
     // retrieve person events
     $query = '( SELECT  CONCAT_WS(' . $this->_db->quote(' ') . ' ' . '                   , jpn.firstName ' . '                   , jpn.namePreposition ' . '                   , jpn.familyName ' . '                   )               AS name ' . ',         jet.app_id               AS appId ' . ',         jet.person_id            AS personId ' . ',         jan.default_tree_id      AS treeId ' . ',			IF ( ( jet.code = ' . $this->_db->Quote('EVEN') . ' ) ' . '             , IFNULL( jet.type, jet.code ) ' . '             , jet.code ' . '             )                     AS code ' . ',         jet.eventdate ' . ',         DATE_FORMAT(STR_TO_DATE(eventdate, "%d %M %Y"), "%m%d") AS sortingdate ' . ',         SUBSTR( RTRIM(jet.eventdate), -4 ) AS eventyear ' . ',         jpn.familyName           AS familyName ' . 'FROM      #__joaktree_person_events     jet ' . 'JOIN      #__joaktree_persons           jpn ' . 'ON        (   jpn.app_id = jet.app_id ' . '          AND jpn.id     = jet.person_id ' . '          ) ' . 'JOIN      #__joaktree_admin_persons     jan ' . 'ON        (   jan.app_id    = jpn.app_id ' . '          AND jan.id        = jpn.id ' . '          AND jan.published = true ' . ($personStatus == 0 ? 'AND jan.living = false ' : ' ') . ($personStatus == 1 ? 'AND jan.living = true ' : ' ') . '          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 . ' ' . '          ) ' . 'JOIN      #__joaktree_display_settings  jds ' . 'ON        (   jds.code = jet.code ' . '          AND jds.level = ' . $this->_db->quote('person') . ' ' . '          AND jds.published = true ' . '          AND (  (jan.living = false AND jds.access       IN ' . $userAccessLevels . ') ' . '              OR (jan.living = true  AND jds.accessLiving IN ' . $userAccessLevels . ') ' . '              ) ' . '          ) ' . $where . ' ) ' . 'UNION ' . '( SELECT  CONCAT_WS(' . $this->_db->quote(' + ') . ' ' . '                   , CONCAT_WS(' . $this->_db->quote(' ') . ' ' . '                              , jpn1.firstName ' . '                              , jpn1.namePreposition ' . '                              , jpn1.familyName ' . '                              ) ' . '                   , CONCAT_WS(' . $this->_db->quote(' ') . ' ' . '                              , jpn2.firstName ' . '                              , jpn2.namePreposition ' . '                              , jpn2.familyName ' . '                              ) ' . '                   )               AS name ' . ',         jet.app_id               AS appId ' . ',         jet.person_id_1          AS personId ' . ',         jan1.default_tree_id     AS treeId ' . ',			IF ( ( jet.code = ' . $this->_db->Quote('EVEN') . ' ) ' . '             , IFNULL( jet.type, jet.code ) ' . '             , jet.code ' . '             )                     AS code ' . ',         jet.eventdate ' . ',         DATE_FORMAT(STR_TO_DATE(eventdate, "%d %M %Y"), "%m%d") AS sortingdate ' . ',         SUBSTR( RTRIM(jet.eventdate), -4 ) AS eventyear ' . ',         jpn1.familyName          AS familyName ' . 'FROM      #__joaktree_relation_events   jet ' . 'JOIN      #__joaktree_persons           jpn1 ' . 'ON        (   jpn1.app_id = jet.app_id ' . '          AND jpn1.id     = jet.person_id_1 ' . '          ) ' . 'JOIN      #__joaktree_admin_persons     jan1 ' . 'ON        (   jan1.app_id    = jpn1.app_id ' . '          AND jan1.id        = jpn1.id ' . '          AND jan1.published = true ' . ($personStatus == 0 ? 'AND jan1.living = false ' : ' ') . ($personStatus == 1 ? 'AND jan1.living = true ' : ' ') . '          AND (  (jan1.living = false AND ' . $displayAccess['NAMEname']->notLiving . ' = 2 ) ' . '              OR (jan1.living = true  AND ' . $displayAccess['NAMEname']->living . '    = 2 ) ' . '              ) ' . '          ) ' . 'JOIN      #__joaktree_trees             jte1 ' . 'ON        (   jte1.app_id    = jan1.app_id ' . '          AND jte1.id        = jan1.default_tree_id ' . '          AND jte1.published = true ' . '          AND jte1.access    IN ' . $userAccessLevels . ' ' . '          ) ' . 'JOIN      #__joaktree_persons           jpn2 ' . 'ON        (   jpn2.app_id = jet.app_id ' . '          AND jpn2.id     = jet.person_id_2 ' . '          ) ' . 'JOIN      #__joaktree_admin_persons     jan2 ' . 'ON        (   jan2.app_id    = jpn2.app_id ' . '          AND jan2.id        = jpn2.id ' . '          AND jan2.published = true ' . ($personStatus == 0 ? 'AND jan2.living = false ' : ' ') . ($personStatus == 1 ? 'AND jan2.living = true ' : ' ') . '          AND (  (jan2.living = false AND ' . $displayAccess['NAMEname']->notLiving . ' = 2 ) ' . '              OR (jan2.living = true  AND ' . $displayAccess['NAMEname']->living . '    = 2 ) ' . '              ) ' . '          ) ' . 'JOIN      #__joaktree_trees             jte2 ' . 'ON        (   jte2.app_id    = jan2.app_id ' . '          AND jte2.id        = jan2.default_tree_id ' . '          AND jte2.published = true ' . '          AND jte2.access    IN ' . $userAccessLevels . ' ' . '          ) ' . 'JOIN      #__joaktree_display_settings  jds ' . 'ON        (   jds.code = jet.code ' . '          AND jds.level = ' . $this->_db->quote('relation') . ' ' . '          AND jds.published = true ' . '          AND (  (   jan1.living = false ' . '                 AND jan2.living = false ' . '                 AND jds.access  IN ' . $userAccessLevels . ' ' . '                 ) ' . '              OR (   (  jan1.living = true ' . '                     OR jan2.living = true ' . '                     ) ' . '                 AND jds.accessLiving IN ' . $userAccessLevels . ' ' . '                 ) ' . '              ) ' . '          ) ' . $where . ' ) ' . $order . ' ';
     $this->_db->setQuery($query, 0, $limit);
     $temp = $this->_db->loadObjectList();
     if (count($temp)) {
         // get menuId & technology
         $menus = JoaktreeHelper::getMenus('joaktree');
         $technology = JoaktreeHelper::getTechnology();
         $linkBase = 'index.php?option=com_joaktree&view=joaktree&tech=' . $technology . '';
         $robot = $technology == 'a' ? '' : 'rel="noindex, nofollow"';
         foreach ($temp as $row) {
             $menuItemId = $menus[$row->treeId];
             $row->route = JRoute::_($linkBase . '&Itemid=' . $menuItemId . '&treeId=' . $row->treeId . '&personId=' . $row->appId . '!' . $row->personId);
             $row->robot = $robot;
             $row->yearsago = $today['year'] - (int) $row->eventyear;
             $tmp = ucwords(strtolower($row->eventdate));
             $row->eventday = substr(JoaktreeHelper::convertDateTime($tmp), 0, -4);
             $row->eventdate = JoaktreeHelper::displayDate($row->eventdate);
             $row->code = JText::_($row->code);
             $result[] = $row;
         }
     }
     unset($temp);
     return $result;
 }