Server IP : 1.179.227.78 / Your IP : 10.104.4.41 Web Server : Apache System : Linux afdc-mdu34 5.4.0-153-generic #170-Ubuntu SMP Fri Jun 16 13:43:31 UTC 2023 x86_64 User : www ( 1001) PHP Version : 7.4.30 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/afdc-mdu34.rtarf.mi.th/joomla/plugins/content/contact/ |
Upload File : |
<?php /** * @package Joomla.Plugin * @subpackage Content.Contact * * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\Registry\Registry; /** * Contact Plugin * * @since 3.2 */ class PlgContentContact extends JPlugin { /** * Database object * * @var JDatabaseDriver * @since 3.3 */ protected $db; /** * Plugin that retrieves contact information for contact * * @param string $context The context of the content being passed to the plugin. * @param mixed &$row An object with a "text" property * @param mixed $params Additional parameters. See {@see PlgContentContent()}. * @param integer $page Optional page number. Unused. Defaults to zero. * * @return boolean True on success. */ public function onContentPrepare($context, &$row, $params, $page = 0) { $allowed_contexts = array('com_content.category', 'com_content.article', 'com_content.featured'); if (!in_array($context, $allowed_contexts)) { return true; } // Return if we don't have valid params or don't link the author if (!($params instanceof Registry) || !$params->get('link_author')) { return true; } // Return if an alias is used if ((int) $this->params->get('link_to_alias', 0) === 0 && $row->created_by_alias != '') { return true; } // Return if we don't have a valid article id if (!isset($row->id) || !(int) $row->id) { return true; } $contact = $this->getContactData($row->created_by); $row->contactid = $contact->contactid; $row->webpage = $contact->webpage; $row->email = $contact->email_to; $url = $this->params->get('url', 'url'); if ($row->contactid && $url === 'url') { JLoader::register('ContactHelperRoute', JPATH_SITE . '/components/com_contact/helpers/route.php'); $row->contact_link = JRoute::_(ContactHelperRoute::getContactRoute($contact->contactid . ':' . $contact->alias, $contact->catid)); } elseif ($row->webpage && $url === 'webpage') { $row->contact_link = $row->webpage; } elseif ($row->email && $url === 'email') { $row->contact_link = 'mailto:' . $row->email; } else { $row->contact_link = ''; } return true; } /** * Retrieve Contact * * @param int $userId Id of the user who created the article * * @return mixed|null|integer */ protected function getContactData($userId) { static $contacts = array(); if (isset($contacts[$userId])) { return $contacts[$userId]; } $query = $this->db->getQuery(true); $query->select('MAX(contact.id) AS contactid, contact.alias, contact.catid, contact.webpage, contact.email_to'); $query->from($this->db->quoteName('#__contact_details', 'contact')); $query->where('contact.published = 1'); $query->where('contact.user_id = ' . (int) $userId); if (JLanguageMultilang::isEnabled() === true) { $query->where('(contact.language in ' . '(' . $this->db->quote(JFactory::getLanguage()->getTag()) . ',' . $this->db->quote('*') . ') ' . ' OR contact.language IS NULL)'); } $this->db->setQuery($query); $contacts[$userId] = $this->db->loadObject(); return $contacts[$userId]; } }