diff --git a/administrator/components/com_contact/config.xml b/administrator/components/com_contact/config.xml index 4221b0e580074..38efe5fc0117f 100644 --- a/administrator/components/com_contact/config.xml +++ b/administrator/components/com_contact/config.xml @@ -249,6 +249,29 @@ + + + + + + + + + + + + + + + + + + JHIDE + + + + + + + + + + + + + + + + + + + getState('params')->get('show_contact_list')) - { - $registry = new Registry; - $registry->loadString($result->params); - $this->getState('params')->merge($registry); - } } catch (Exception $e) { @@ -345,60 +336,91 @@ protected function getContactQuery($pk = null) if ($result) { - $user = JFactory::getUser(); - $groups = implode(',', $user->getAuthorisedViewLevels()); - - // Get the content by the linked user - $query = $db->getQuery(true) - ->select('a.id') - ->select('a.title') - ->select('a.state') - ->select('a.access') - ->select('a.catid') - ->select('a.created') - ->select('a.language'); - - // SQL Server changes - $case_when = ' CASE WHEN '; - $case_when .= $query->charLength('a.alias', '!=', '0'); - $case_when .= ' THEN '; - $a_id = $query->castAsChar('a.id'); - $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); - $case_when .= ' ELSE '; - $case_when .= $a_id . ' END as slug'; - $case_when1 = ' CASE WHEN '; - $case_when1 .= $query->charLength('c.alias', '!=', '0'); - $case_when1 .= ' THEN '; - $c_id = $query->castAsChar('c.id'); - $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); - $case_when1 .= ' ELSE '; - $case_when1 .= $c_id . ' END as catslug'; - $query->select($case_when1 . ',' . $case_when) - ->from('#__content as a') - ->join('LEFT', '#__categories as c on a.catid=c.id') - ->where('a.created_by = ' . (int) $result->user_id) - ->where('a.access IN (' . $groups . ')') - ->order('a.state DESC, a.created DESC'); - - // Filter per language if plugin published - if (JLanguageMultilang::isEnabled()) + + $contactParams = new Registry; + $contactParams->loadString($result->params); + + // If we are showing a contact list, then the contact parameters take priority + // So merge the contact parameters with the merged parameters + if ($this->getState('params')->get('show_contact_list')) { - $query->where( - ('a.created_by = ' . (int) $result->user_id) . ' AND ' . - ('a.language=' . $db->quote(JFactory::getLanguage()->getTag()) . ' OR a.language=' . $db->quote('*')) - ); + $this->getState('params')->merge($contactParams); } - if (is_numeric($published)) + // Get the com_content articles by the linked user + if ((int) $result->user_id && $this->getState('params')->get('show_articles')) { - $query->where('a.state IN (1,2)') - ->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')') - ->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')'); - } - $db->setQuery($query, 0, 10); - $articles = $db->loadObjectList(); - $result->articles = $articles; + $query = $db->getQuery(true) + ->select('a.id') + ->select('a.title') + ->select('a.state') + ->select('a.access') + ->select('a.catid') + ->select('a.created') + ->select('a.language'); + + // SQL Server changes + $case_when = ' CASE WHEN '; + $case_when .= $query->charLength('a.alias', '!=', '0'); + $case_when .= ' THEN '; + $a_id = $query->castAsChar('a.id'); + $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); + $case_when .= ' ELSE '; + $case_when .= $a_id . ' END as slug'; + $case_when1 = ' CASE WHEN '; + $case_when1 .= $query->charLength('c.alias', '!=', '0'); + $case_when1 .= ' THEN '; + $c_id = $query->castAsChar('c.id'); + $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); + $case_when1 .= ' ELSE '; + $case_when1 .= $c_id . ' END as catslug'; + $query->select($case_when1 . ',' . $case_when) + ->from('#__content as a') + ->join('LEFT', '#__categories as c on a.catid=c.id') + ->where('a.created_by = ' . (int) $result->user_id) + ->where('a.access IN (' . $groups . ')') + ->order('a.state DESC, a.created DESC'); + + // Filter per language if plugin published + if (JLanguageMultilang::isEnabled()) + { + $query->where( + ('a.created_by = ' . (int) $result->user_id) . ' AND ' . + ('a.language=' . $db->quote(JFactory::getLanguage()->getTag()) . ' OR a.language=' . $db->quote('*')) + ); + } + + if (is_numeric($published)) + { + $query->where('a.state IN (1,2)') + ->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')') + ->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')'); + } + + // Number of articles to display from config/menu params + $articles_display_num = $this->getState('params')->get('articles_display_num', 10); + + // Use contact setting? + if ($articles_display_num === 'use_contact') + { + $articles_display_num = $contactParams->get('articles_display_num', 10); + + // Use global? + if ((string) $articles_display_num === '') + { + $articles_display_num = JComponentHelper::getParams('com_contact')->get('articles_display_num', 10); + } + } + + $db->setQuery($query, 0, (int) $articles_display_num); + $articles = $db->loadObjectList(); + $result->articles = $articles; + } + else + { + $result->articles = null; + } // Get the profile information for the linked user require_once JPATH_ADMINISTRATOR . '/components/com_users/models/user.php'; diff --git a/components/com_contact/models/forms/form.xml b/components/com_contact/models/forms/form.xml index 0852089007dd3..91eab7aaccc88 100644 --- a/components/com_contact/models/forms/form.xml +++ b/components/com_contact/models/forms/form.xml @@ -409,6 +409,27 @@ + + + + + + + + + + + + + + + + + + diff --git a/components/com_contact/views/categories/tmpl/default.xml b/components/com_contact/views/categories/tmpl/default.xml index 03ea5dce12bce..93ce1d6524447 100644 --- a/components/com_contact/views/categories/tmpl/default.xml +++ b/components/com_contact/views/categories/tmpl/default.xml @@ -486,6 +486,28 @@ + + + + + + + + + + + + + + + + + + + JSHOW + + + + + + + + + + + + + + + + + + + JSHOW + + + + + + + + + + + + + + + + + + + JSHOW + + + + + + + + + + + + + + + + + + +