/** * * Get Avatar based on the installed community component * @param int $id - userid * @return object */ function getAvatar($id) { $avatar = ''; $found = false; Citruscart::load('CitruscartHelperAmbra', 'helpers.ambra'); $helper_ambra = CitruscartHelperBase::getInstance('Ambra'); //check if ambra installed if ($helper_ambra->isInstalled() && !$found) { if (!class_exists('Ambra')) { JLoader::register("Ambra", JPATH_ADMINISTRATOR . "/components/com_ambra/defines.php"); } //Get Ambra Avatar if ($image = Ambra::getClass("AmbraHelperUser", 'helpers.user')->getAvatar($id)) { $link = JRoute::_(JURI::root() . 'index.php?option=com_ambra&view=users&id=' . $id, false); $avatar .= "<a href='{$link}' target='_blank'>"; $avatar .= "<img src='{$image}' style='max-width:80px; border:1px solid #ccccce;' />"; $avatar .= "</a>"; } $found = true; } //check if jomsocial installed if (DSC::getApp()->isComponentInstalled('com_community') && !$found) { //Get JomSocial Avatar $database = JFactory::getDBO(); $query = "\r\n\t\t\tSELECT\r\n\t\t\t\t*\r\n\t\t\tFROM\r\n\t\t\t\t#__community_users\r\n\t\t\tWHERE\r\n\t\t\t\t`userid` = '" . $id . "'\r\n\t\t\t"; $database->setQuery($query); $result = $database->loadObject(); if (isset($result->thumb)) { $image = JURI::root() . $result->thumb; } $link = JRoute::_(JURI::root() . 'index.php?option=com_community&view=profile&userid=' . $id, false); $avatar .= "<a href='{$link}' target='_blank'>"; $avatar .= "<img src='{$image}' style='max-width:80px; border:1px solid #ccccce;' />"; $avatar .= "</a>"; $found = true; } //check if community builder is installed if (DSC::getApp()->isComponentInstalled('com_comprofiler') && !$found) { //Get JomSocial Avatar $database = JFactory::getDBO(); $query = "\r\n\t\t\tSELECT\r\n\t\t\t\t*\r\n\t\t\tFROM\r\n\t\t\t\t#__comprofiler\r\n\t\t\tWHERE\r\n\t\t\t\t`id` = '" . $id . "'\r\n\t\t\t"; $database->setQuery($query); $result = $database->loadObject(); if (isset($result->avatar)) { $image = JURI::root() . 'images/comprofiler/' . $result->avatar; } else { $image = JRoute::_(JURI::root() . 'components/com_comprofiler/plugin/templates/default/images/avatar/nophoto_n.png'); } $link = JRoute::_(JURI::root() . 'index.php?option=com_comprofiler&userid=' . $id, false); $avatar .= "<a href='{$link}' target='_blank'>"; $avatar .= "<img src='{$image}' style='max-width:80px; border:1px solid #ccccce;' />"; $avatar .= "</a>"; $found = true; } return $avatar; }