/** * CB 1.0 COMPATIBILITY FUNCTION: DO NOT USE FOR NEW DEVELOPMENT ! * replaced by cbGetField temporarly * @access private * * @param unknown_type $oType * @param unknown_type $oValue * @param unknown_type $user * @param unknown_type $prefix * @param unknown_type $imgMode * @param unknown_type $linkURL * @param unknown_type $field * @return unknown */ function getFieldValue($oType, $oValue = null, $user = null, $prefix = null, $imgMode = 0, $linkURL = null, $field = null) { global $ueConfig, $_CB_database, $_CB_framework, $_PLUGINS; $oReturn = ""; switch ($oType) { case 'checkbox': if ($oValue != '' && $oValue != null) { if ($oValue == 1) { $oReturn = _UE_YES; } elseif ($oValue == 0) { $oReturn = _UE_NO; } else { $oReturn = null; } } break; case 'select': case 'radio': $oReturn = htmlspecialchars(getLangDefinition($oValue)); break; case 'multiselect': case 'multicheckbox': $oReturn = array(); $oReturn = explode("|*|", htmlspecialchars($oValue)); for ($i = 0; $i < count($oReturn); $i++) { $oReturn[$i] = htmlspecialchars(getLangDefinition($oReturn[$i])); } $oReturn = implode(', ', $oReturn); break; case 'date': if ($oValue != '' || $oValue != null) { if ($oValue != '0000-00-00 00:00:00' && $oValue != '0000-00-00') { $oReturn = cbFormatDate(htmlspecialchars($oValue)); } else { $oReturn = ""; } } break; case 'primaryemailaddress': if ($ueConfig['allow_email_display'] == 3 || $imgMode != 0) { $oValueText = _UE_SENDEMAIL; } else { $oValueText = htmlspecialchars($oValue); } $emailIMG = '<img src="' . $_CB_framework->getCfg('live_site') . '/components/com_comprofiler/images/email.gif" border="0" alt="' . _UE_SENDEMAIL . '" title="' . _UE_SENDEMAIL . '" />'; switch ($imgMode) { case 0: $linkItemImg = null; $linkItemSep = null; $linkItemTxt = $oValueText; break; case 1: $linkItemImg = $emailIMG; $linkItemSep = null; $linkItemTxt = null; break; case 2: $linkItemImg = $emailIMG; $linkItemSep = ' '; $linkItemTxt = $oValueText; break; } //if no email or 4 (do not display email) then return empty string if ($oValue == null || $ueConfig['allow_email_display'] == 4 || $imgMode != 0 && $ueConfig['allow_email_display'] == 1) { $oReturn = ""; } else { switch ($ueConfig['allow_email_display']) { case 1: //display email only $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 0); break; case 2: //mailTo link // cloacking doesn't cloack the text of the hyperlink, if that text does contain email addresses //TODO: fix it. if (!$linkItemImg && $linkItemTxt == htmlspecialchars($oValue)) { $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 1, '', 0); } elseif ($linkItemImg && $linkItemTxt != htmlspecialchars($oValue)) { $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 1, $linkItemImg . $linkItemSep . $linkItemTxt, 0, false); } elseif ($linkItemImg && $linkItemTxt == htmlspecialchars($oValue)) { $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 1, $linkItemImg, 0, false) . $linkItemSep; $oReturn .= moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 1, '', 0); } elseif (!$linkItemImg && $linkItemTxt != htmlspecialchars($oValue)) { $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 1, $linkItemTxt, 0); } break; case 3: //email Form (with cloacked email address if visible) $oReturn = "<a href=\"" . cbSef("index.php?option=com_comprofiler&task=emailUser&uid=" . $user->id . getCBprofileItemid(true)) . "\" title=\"" . _UE_MENU_SENDUSEREMAIL_DESC . "\">" . $linkItemImg . $linkItemSep; if ($linkItemTxt && $linkItemTxt != _UE_SENDEMAIL) { $oReturn .= moscomprofilerHTML::emailCloaking($linkItemTxt, 0); } else { $oReturn .= $linkItemTxt; } $oReturn .= "</a>"; break; } } break; case 'pm': $pmIMG = '<img src="' . $_CB_framework->getCfg('live_site') . '/components/com_comprofiler/images/pm.gif" border="0" alt="' . _UE_PM_USER . '" title="' . _UE_PM_USER . '" />'; $oReturn = ""; global $_CB_PMS; $resultArray = $_CB_PMS->getPMSlinks($user->id, $_CB_framework->myId(), "", "", 1); // toid,fromid,subject,message,1: link to compose new PMS message for $toid user. if (count($resultArray) > 0) { foreach ($resultArray as $res) { if (is_array($res)) { switch ($imgMode) { case 0: $linkItem = getLangDefinition($res["caption"]); break; case 1: $linkItem = $pmIMG; break; case 2: $linkItem = $pmIMG . ' ' . getLangDefinition($res["caption"]); break; } $oReturn .= "<a href=\"" . cbSef($res["url"]) . "\" title=\"" . getLangDefinition($res["tooltip"]) . "\">" . $linkItem . "</a>"; } } } break; case 'emailaddress': if ($oValue == null) { $oReturn = ''; } else { if ($ueConfig['allow_email'] == 1) { $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 1, "", 0); } else { $oReturn = moscomprofilerHTML::emailCloaking(htmlspecialchars($oValue), 0); } } break; case 'webaddress': if ($oValue == null) { $oReturn = ""; } elseif ($ueConfig['allow_website'] == 1) { $oReturn = array(); $oReturn = explode("|*|", $oValue); if (count($oReturn) < 2) { $oReturn[1] = $oReturn[0]; } $oReturn = "<a href=\"http://" . htmlspecialchars($oReturn[0]) . "\" target=\"_blank\" rel=\"nofollow\">" . htmlspecialchars($oReturn[1]) . "</a>"; } else { $oReturn = $oValue; } break; case 'image': $cbUser =& CBuser::getInstance(null); $cbUser->loadCbRow($user); $oValue = $cbUser->avatarFilePath(); /* if(is_dir($_CB_framework->getCfg('absolute_path')."/components/com_comprofiler/plugin/language/".$_CB_framework->getCfg( 'lang' )."/images")) $fileLang=$_CB_framework->getCfg( 'lang' ); else $fileLang="default_language"; if($user->avatarapproved==0) $oValue="components/com_comprofiler/plugin/language/".$fileLang."/images/tnpendphoto.jpg"; elseif(($user->avatar=='' || $user->avatar==null) && $user->avatarapproved==1) $oValue = "components/com_comprofiler/plugin/language/".$fileLang."/images/tnnophoto.jpg"; elseif(strpos($user->avatar,"gallery/")===false) $oValue="images/comprofiler/tn".$oValue; else $oValue="images/comprofiler/".$oValue; if(!is_file($_CB_framework->getCfg('absolute_path')."/".$oValue)) $oValue = "components/com_comprofiler/plugin/language/".$fileLang."/images/tnnophoto.jpg"; if(is_file($_CB_framework->getCfg('absolute_path')."/".$oValue)) { */ $onclick = null; $aTag = null; if ($ueConfig['allow_profilelink'] == 1) { $profileURL = cbSef("index.php?option=com_comprofiler&task=userProfile&user="******"onclick=\"javascript:window.location='".$profileURL."'\""; $aTag = "<a href=\"" . $profileURL . "\">"; } $oReturn = $aTag . "<img src=\"" . $oValue . "\" " . $onclick . " alt=\"\" style=\"border-style: none;\" />" . ($aTag ? "</a>" : ""); /* } */ break; case 'status': if ($ueConfig['allow_onlinestatus'] == 1) { if (isset($user)) { $_CB_database->setQuery("SELECT COUNT(*) FROM #__session WHERE userid = " . (int) $user->id . " AND guest = 0"); $isonline = $_CB_database->loadResult(); } else { $isonline = $oValue; } if ($isonline > 0) { $oValue = _UE_ISONLINE; // $img = 'online.png'; $class = 'cb_online'; // $onlineIMG= "<img src=\"components/com_comprofiler/images/online.gif\" border=\"0\" alt=\"".$oValue."\" title=\"".$oValue."\" />"; } else { $oValue = _UE_ISOFFLINE; // $img = 'offline.png'; $class = 'cb_offline'; // $onlineIMG= "<img src=\"components/com_comprofiler/images/offline.gif\" border=\"0\" alt=\"".$oValue."\" title=\"".$oValue."\" />"; } switch ($imgMode) { case 0: $oReturn = $oValue; break; case 1: //$oReturn=$onlineIMG; $oReturn = '<span class="' . $class . '" title="' . htmlspecialchars($oValue) . '"> </span>'; break; case 2: //$oReturn=$onlineIMG.' '.$oValue; $oReturn = '<span class="' . $class . '"><span>' . htmlspecialchars($oValue) . '</span></span>'; break; } } break; case 'formatname': if ($linkURL && $ueConfig['allow_profilelink'] == 1) { $oReturn = "<a href=\"" . $linkURL . "\">"; } $oReturn .= getNameFormat($user->name, $user->username, $ueConfig['name_format']); if ($linkURL && $ueConfig['allow_profilelink'] == 1) { $oReturn .= "</a>"; } break; case 'textarea': $oReturn = nl2br(htmlspecialchars($oValue)); break; case 'delimiter': if ($field !== null && $user !== null) { $oReturn = cbReplaceVars(getLangDefinition(cbUnHtmlspecialchars($field->description)), $user); //TBD: unhtml is kept for backwards database compatibility until CB 2.0 } else { $oReturn = cbReplaceVars(getLangDefinition($oValue), $user); } break; case 'editorta': $cbFielfs = new cbFields(); $badHtmlFilter =& $cbFielfs->getInputFilter(array(), array(), 1, 1); if (isset($ueConfig['html_filter_allowed_tags']) && $ueConfig['html_filter_allowed_tags']) { $badHtmlFilter->tagBlacklist = array_diff($badHtmlFilter->tagBlacklist, explode(" ", $ueConfig['html_filter_allowed_tags'])); } $oReturn = $cbFielfs->clean($badHtmlFilter, $oValue); unset($cbFielfs); break; case 'predefined': if ($linkURL && $ueConfig['allow_profilelink'] == 1) { $oReturn = "<a href=\"" . $linkURL . "\">"; } $oReturn .= htmlspecialchars(cbUnHtmlspecialchars($oValue)); // needed for #__users:name (has &039; instead of ' in it...) //TBD: unhtml is kept for backwards database compatibility until CB 2.0 if ($linkURL && $ueConfig['allow_profilelink'] == 1) { $oReturn .= "</a>"; } break; case 'text': default: if ($field != null) { $args = array(&$field, &$user, 'html', 'profile'); $oReturn = $_PLUGINS->callField($oType, 'getField', $args, $field); } else { $oReturn = htmlspecialchars($oValue); } break; } if ($prefix != null && ($oReturn != null || $oReturn != '')) { $oReturn = $prefix . $oReturn; } return $oReturn; }
/** * Returns a field in specified format * * @param moscomprofilerFields $field * @param moscomprofilerUser $user * @param string $output 'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit' * @param string $reason 'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists * @param int $list_compare_types IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search * @return mixed */ function getField(&$field, &$user, $output, $reason, $list_compare_types) { global $_CB_framework, $ueConfig; $value = $user->get(implode('', $field->getTableColumns())); switch ($output) { case 'html': case 'rss': $cbFields = new cbFields(); $badHtmlFilter =& $cbFields->getInputFilter(array(), array(), 1, 1); if (isset($ueConfig['html_filter_allowed_tags']) && $ueConfig['html_filter_allowed_tags']) { $badHtmlFilter->tagBlacklist = array_diff($badHtmlFilter->tagBlacklist, explode(" ", $ueConfig['html_filter_allowed_tags'])); } $html = $cbFields->clean($badHtmlFilter, $value); unset($cbFields); break; case 'htmledit': if ($reason == 'search') { $fsize = $field->size; if ($field->size > 120) { $field->size = null; } $html = $this->_fieldEditToHtml($field, $user, $reason, 'input', 'text', $value, ''); $field->size = $fsize; $html = $this->_fieldSearchModeHtml($field, $user, $html, 'text', $list_compare_types); } elseif (!$this->_isReadOnly($field, $user, $reason)) { $cbFields = new cbFields(); $badHtmlFilter =& $cbFields->getInputFilter(array(), array(), 1, 1); if (isset($ueConfig['html_filter_allowed_tags']) && $ueConfig['html_filter_allowed_tags']) { $badHtmlFilter->tagBlacklist = array_diff($badHtmlFilter->tagBlacklist, explode(" ", $ueConfig['html_filter_allowed_tags'])); } $value = $cbFields->clean($badHtmlFilter, $value); unset($cbFields); $html = $_CB_framework->displayCmsEditor($field->name, $value, 600, 350, $field->cols, $field->rows) . $this->_fieldIconsHtml($field, $user, $output, $reason, null, $field->type, $value, 'input', null, true, $this->_isRequired($field, $user, $reason) && !$this->_isReadOnly($field, $user, $reason)); $this->_addSaveAndValidateCode($field, $user, $reason); } else { $html = null; } break; case 'json': case 'php': case 'xml': case 'csvheader': case 'fieldslist': case 'csv': default: return parent::getField($field, $user, $output, $reason, $list_compare_types); break; } return $html; }