Exemplo n.º 1
0
 public static function getUserMailtoLink($evid, $userid, $admin = false, $event)
 {
     $db = JFactory::getDBO();
     static $arr_userids;
     static $arr_evids;
     $cfg = JEVConfig::getInstance();
     if (!$arr_userids) {
         $arr_userids = array();
     }
     if (!$arr_evids) {
         $arr_evids = array();
     }
     $agenda_viewmail = $cfg->get('com_mailview');
     $agenda_viewmail |= $admin;
     if ($userid) {
         if (!isset($arr_userids[$userid])) {
             $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
             $userdet = JEVHelper::getContact($userid);
             $contactlink = "";
             if ($userdet) {
                 if (isset($userdet->slug) && $userdet->slug && $agenda_viewmail == '1') {
                     $contactlink = JRoute::_('index.php?option=com_contact&view=contact&id=' . $userdet->slug . '&catid=' . $userdet->catslug);
                     $contactlink = '<a href="' . $contactlink . '" title="' . JText::_('JEV_EMAIL_TO_AUTHOR') . '" target="_blank" >' . $userdet->contactname . '</a>';
                 } else {
                     if ($userdet->email && $agenda_viewmail == '1') {
                         //$contactlink = '<a href="mailto:' . $userdet->email
                         //. '" title="' . JText::_('JEV_EMAIL_TO_AUTHOR') . '">'
                         //. $userdet->username . '</a>';
                         if ($params->get('contact_display_name', 0) == 1) {
                             $contactlink = JHTML::_('email.cloak', $userdet->email, 1, $userdet->name, 0);
                         } else {
                             $contactlink = JHTML::_('email.cloak', $userdet->email, 1, $userdet->username, 0);
                         }
                     } else {
                         if ($params->get('contact_display_name', 0) == 1) {
                             $contactlink = $userdet->name;
                         } else {
                             $contactlink = $userdet->username;
                         }
                     }
                 }
             }
             $arr_userids[$userid] = $contactlink;
         }
         return $arr_userids[$userid];
     } else {
         if (!isset($arr_evids[$evid])) {
             $contactlink = JText::_('JEV_ANONYME');
             $anonplugin = JPluginHelper::getPlugin("jevents", "jevanonuser");
             if ($anonplugin) {
                 $db = JFactory::getDBO();
                 $db->setQuery("SELECT a.* FROM #__jev_anoncreator as a LEFT JOIN #__jevents_repetition as r on a.ev_id=r.eventid where r.rp_id=" . intval($evid) . " LIMIT 1");
                 $anonrow = $db->loadObject();
                 if ($anonrow) {
                     if ($agenda_viewmail == '1') {
                         $contactlink = JHTML::_('email.cloak', $anonrow->email, 1, $anonrow->name, 0);
                     } else {
                         $contactlink = $anonrow->name;
                     }
                 }
             }
             $arr_evids[$evid] = $contactlink;
         }
         return $arr_evids[$evid];
     }
     return '?';
 }