registerFunction( 'onAfterDeleteUser', 'userDeleted','getProfileBookTab' ); class getProfileBookTab extends cbTabHandler { /** * Constructor */ function getProfileBook() { $this->cbTabHandler(); } /** * Gets an array of IP addresses taking in account the proxys on the way. * An array is needed because FORWARDED_FOR can be facked as well. * * @return array of IP addresses, first one being host, and last one last proxy (except fackings) */ function _get_ip_list() { $ip_adr_array = array(); if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'],',')) { $ip_adr_array += explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']); } else { $ip_adr_array[] = $_SERVER['HTTP_X_FORWARDED_FOR']; } } $ip_adr_array[] = $_SERVER['REMOTE_ADDR']; return $ip_adr_array; } function pbSave($id, $tab) { global $my, $database, $_SERVER; $postercomment = $this->_getReqParam("postercomments", null); $postername = $this->_getReqParam("postername", null); $posterlocation = $this->_getReqParam("posterlocation", null); $posteremail = $this->_getReqParam("posteremail", null); $posterurl = $this->_getReqParam("posterurl", null); $posterid = $my->id; $posterip = $database->getEscaped(implode(",",$this->_get_ip_list())); $postervote = $this->_getReqParam("postervote", "NULL"); $userConfig = $this->pbGetUserConfig($id); $autoPublish = strtolower($userConfig->cb_pb_autopublish); if($autoPublish=='_ue_no') $published=0; else $published = 1; $query = "SELECT COUNT(*) FROM #__comprofiler_plug_profilebook WHERE postername='$postername' AND posteremail='$posteremail' AND postercomment='$postercomment' AND posterid='$posterid' AND userid='$id'"; $database->setQuery($query); $count=$database->loadResult(); if ($count == 0) { // avoid double-posts on clicking reload ! $query = "INSERT INTO #__comprofiler_plug_profilebook SET postername='$postername', posteremail='$posteremail', posterlocation='$posterlocation', postercomment='$postercomment', postervote=$postervote, posterip='$posterip',posterid='$posterid',userid='$id',published='$published',date=NOW(),posterurl='$posterurl'"; $database->setQuery($query); if (!$database->query()) { print("pbSave SQL error: " . $database->stderr(true)."
"); return; } $notify = strtolower($userConfig->cb_pb_notifyme); if($notify=='_ue_yes'){ $cbNotification = new cbNotification(); $res=$cbNotification->sendFromSystem($id,sprintf(_pb_MSGSUB,getLangDefinition($tab->title)),sprintf(_pb_MSGBODY,$postername,getLangDefinition($tab->title)).sprintf($autoPublish?_pb_MSGBODYAUTOAPPROVED:_pb_MSGBODYREVIEWAPPROVE, getLangDefinition($tab->title),$this->_getAbsURLwithParam(array()))); } } } function pbEdit($id, $userId, $curruser, $iAmModerator, $tab) { global $my, $database, $_SERVER, $ueConfig; $postercomment = $this->_getReqParam("postercomments", null); $postername = $this->_getReqParam("postername", null); $posterlocation = $this->_getReqParam("posterlocation", null); $posteremail = $this->_getReqParam("posteremail", null); $posterurl = $this->_getReqParam("posterurl", null); $posterid = $my->id; $posterip = $database->getEscaped(implode(",",$this->_get_ip_list())); $postervote = $this->_getReqParam("postervote", "NULL"); $editedbyname = ($my->id ? $database->getEscaped(getNameFormat($curruser->name,$curruser->username,$ueConfig['name_format'])) : $postername); $userConfig = $this->pbGetUserConfig($userId); $autoPublish = strtolower($userConfig->cb_pb_autopublish); if ($iAmModerator) { $published = null; } else { if($autoPublish=='_ue_no') $published=0; else $published = 1; } $query = "UPDATE #__comprofiler_plug_profilebook SET editdate=NOW(), " .($my->id ? "editedbyid=".$my->id.", " : "") ."editedbyname='".$editedbyname."', " ."postername='$postername', " .($posteremail ? "posteremail='$posteremail', " : "") ."posterlocation='$posterlocation', postercomment='$postercomment', postervote=$postervote, " ."posterip='$posterip', " .($published !== null ? "published='$published', " : "") ."posterurl='$posterurl' WHERE id=$id AND userid=$userId" .($iAmModerator ? "" : " AND posterid=$posterid"); $database->setQuery($query); if (!$database->query()) { print("pbEdit SQL error: " . $database->stderr(true)."
"); return; } $notify = strtolower($userConfig->cb_pb_notifyme); if($notify=='_ue_yes'){ $cbNotification = new cbNotification(); $res=$cbNotification->sendFromSystem($userId, sprintf(_pb_MSGSUBEDIT, getLangDefinition($tab->title)), sprintf(_pb_MSGBODYEDIT, $editedbyname, $postername, getLangDefinition($tab->title)) .($iAmModerator ? "" : sprintf($autoPublish ? _pb_MSGBODYAUTOAPPROVED : _pb_MSGBODYREVIEWAPPROVE, getLangDefinition($tab->title), $this->_getAbsURLwithParam(array())))); } } function pbDelete($id) { global $database; $database->setQuery("DELETE FROM #__comprofiler_plug_profilebook WHERE id=".$id); $database->query(); if (!$database->query()) { print("pbDelete SQL error: " . $database->stderr(true)."
"); return; } } function pbUpdate($id, $isMe) { global $database; //$postercomment = $this->_getReqParam("postercomments", null); $feedback = $this->_getReqParam("feedback", null); if (!$isMe && $feedback) $feedback = "["._pb_ModeratorEdited."]: ".$feedback; $published = $this->_getReqParam("published", 0); $query = "UPDATE #__comprofiler_plug_profilebook SET feedback='$feedback', published='$published' status='$status' WHERE id='$id'"; $database->setQuery($query); if (!$database->query()) { print("pbUpdate SQL error: " . $database->stderr(true)."
"); return; } } function pbPublish($id) { global $database; $published = $this->_getReqParam("published", 0); $query = "UPDATE #__comprofiler_plug_profilebook SET published='$published' status='$status' WHERE id='$id'"; $database->setQuery($query); if (!$database->query()) { print("pbPublish SQL error: " . $database->stderr(true)."
"); return; } } function pbGetUserConfig($id) { global $database; $database->setQuery("SELECT cb_pb_enable, cb_pb_autopublish, cb_pb_notifyme FROM #__comprofiler WHERE id=".$id); $userConfig=$database->loadObjectList(); return $userConfig[0]; } function getEditTab( $tab, $user, $ui) { $this->_getlanguageFile(); } function _getLanguageFile() { global $mainframe,$mosConfig_lang; $UElanguagePath=$mainframe->getCfg( 'absolute_path' ).'/components/com_comprofiler/plugin/user/plug_cbprofilebook'; if (file_exists($UElanguagePath.'/language/'.$mosConfig_lang.'.php')) { include_once($UElanguagePath.'/language/'.$mosConfig_lang.'.php'); } else include_once($UElanguagePath.'/language/english.php'); } /** * Generates the HTML to display the user profile tab * @param object tab reflecting the tab database entry * @param object mosUser reflecting the user being displayed * @param int 1 for front-end, 2 for back-end * @returns mixed : either string HTML for tab content, or false if ErrorMSG generated */ function getDisplayTab($tab,$user,$ui) { global $database,$mosConfig_live_site,$acl,$my,$mosConfig_offset,$ueConfig,$mainframe,$mosConfig_lang; $this->_getLanguageFile(); $iAmModerator = isModerator($my->id); //Get User Level Configuration Options $userConfig = $this->pbGetUserConfig($user->id); $autoPublish = strtolower($userConfig->cb_pb_autopublish); $notify = strtolower($userConfig->cb_pb_notifyme); //Return if the user doesn't have the ProfileBook enabled no need to go any further if(strtolower($userConfig->cb_pb_enable) == '_ue_no') return; $return=""; //If there is a tab description display it if($tab->description != null) $return .= "\t\t
".unHtmlspecialchars(getLangDefinition($tab->description))."
\n"; //Get the tab related paramaters, these settings are global and set by administrator $params=$this->params; $pbAllowAnony = $params->get('pbAllowAnony', '0'); //Determine whether Anonymous Users can post $pbEnableRating = $params->get('pbEnableRating', '1'); //Determine if Profile Ratings should be used $pbEntriesPerPage = $params->get('pbEntriesPerPage', '10'); //Determine number of posts to show per page $pagingEnabled = $params->get('pbPagingEnabled', 1); //Determine if Pagination is enabled $sortDirection = $params->get('pbSortDirection','DESC'); //Determine sort order of posting date $pbUseLocation = $params->get('pbUseLocation', '1'); //Determine whether to use Location Field $pbLocationField = $params->get('pbLocationField', '0'); //Determine whether what field is the location field $pbUseWebAddress = $params->get('pbUseWebAddress', '1'); //Determine whether to use Web Address Field $pbWebField = $params->get('pbWebField', '0'); //Determine whether what field is the web address field $pbEnableGesture = $params->get('pbEnableGesture','0'); //Determine whether return gestures are enabled $pbAllowBBCode = $params->get('pbAllowBBCode', '1'); //Determine if BBCode is allowed $pbAllowSmiles = $params->get('pbAllowSmiles', '1'); //Determine if Smiles are allowed //Check to see if there are actions that need to be executed $action = $this->_getReqParam("formaction", null); $id = $this->_getReqParam("id",0); $showform = $this->_getReqParam("showform", 0); $jsSent = 0; //Section for posting a entry //Check to see if the visting user is the profile owner if($my->id != $user->id) { //Not the owner $isME=false; //Check to see if the user is logged in if($my->id==0) { //Not logged in so assumed to be annonymous $isAnony=true; $required=true; } else { //Yes logged in so not annonymous $isAnony=false; $required=false; //get the attributes of the user visiting the profile $database->setQuery( "SELECT * FROM #__comprofiler c, #__users u WHERE c.id=u.id AND c.id='".$my->id."'"); $users = $database->loadObjectList(); $curruser = $users[0]; } //Allow Posting based on AllowAnony config setting if(($pbAllowAnony=='1') || ($pbAllowAnony=='0' && $my->id > 0)) { //Check to see if a user has submitted a profile entry to be saved if ($action == "new") { $this->pbSave($user->id, $tab); } else { $formName = "pbnewcomment"; $linkTitle = _pb_SubmitEntry; $txtSubmit = _pb_PostEntry; if (!$jsSent++) echo $this->_getpbJS(); $return .= $this->_hiddenBBeditor(null, $formName, $linkTitle, $txtSubmit, $showform, $curruser, $pbEnableRating, $pbUseLocation, $pbLocationField, $pbUseWebAddress, $pbWebField, $required, $pbAllowBBCode, $pbAllowSmiles, null); } } } else { //The visiting user is the profile owner $isME=true; $isAnony=false; $required=false; $curruser =& $user; } if ($iAmModerator || !$isAnony) { if ($action == 'edit') { $this->pbEdit($id, $user->id, $curruser, $iAmModerator, $tab); } } if ($isME || $iAmModerator) { //Take necessary profile owner action if there is switch ($action) { CASE 'delete': $this->pbDelete($id); //print "I'm deleting post id:".$id; break; CASE 'update': $this->pbUpdate($id, $isME); //print "I'm updating feedback for post id:".$id; break; CASE 'publish': $this->pbPublish($id); //print "I'm publishing post id:".$id; break; DEFAULT: //print "I'm doing nothing:".$id." action:".$action; break; } } //Find and Show Postings $pagingParams = $this->_getPaging(array(),array("pbposts_")); $pWHERE=null; //if the user viewing the profile is not the owner then only show published entries if(!$isME && !$iAmModerator) $pWHERE = "\n AND published=1"; //check to see if the Admin enabled pagination if ($pagingEnabled) { //select a count of all applicable entries for pagination $query="SELECT count(*)" . "\n FROM #__comprofiler_plug_profilebook" . "\n WHERE userid=".$user->id . "\n ".$pWHERE; $database->setQuery($query); $total = $database->loadResult(); if (!is_numeric($total)) $total = 0; if ($pagingParams["pbposts_limitstart"] === null) $pagingParams["pbposts_limitstart"] = "0"; if ($pbEntriesPerPage > $total) $pagingParams["pbposts_limitstart"] = "0"; } else { $pagingParams["pbposts_limitstart"] = "0"; } //select all entries and related details $query="SELECT *, pb.id AS pbid " . "\n FROM #__comprofiler_plug_profilebook pb" . "\n LEFT JOIN #__users u ON pb.posterid=u.id" . "\n LEFT JOIN #__comprofiler c ON pb.posterid=c.id" . "\n WHERE pb.userid=".$user->id . $pWHERE . "\n ORDER BY date ".$sortDirection . "\n LIMIT ".($pagingParams["pbposts_limitstart"]?$pagingParams["pbposts_limitstart"]:"0").",".$pbEntriesPerPage; $database->setQuery( $query ); // print $database->getQuery(); $items = $database->loadObjectList(); //check to make sure we got at least 1 record if(count($items) >0) { //build header information for display table $return .= "
"; $return .= "\n"; $return .= "\n\t"; $return .= "\n"; $return .= "\n"; $return .= "\n"; $i=2; $k=0; //iterate through each item and display it accordingly foreach($items AS $item) { $k++; $i= ($i==1) ? 2 : 1; //get the date that the entry was submitted on a format it according to CB config $signtime = cbFormatDate($item->date); $edittime = cbFormatDate($item->editdate); $img = null; //check to see if Ratings are enabled if($pbEnableRating) $img = $this->_getRatingImage($item->postervote); //start a new row for the record $return .= "\n\t"; $pimg = ""; $returnFavor=null; //check to see if the entry was submitted by a member if($item->posterid!=0 && $item->posterid!="" && $item->posterid!=null && isset($item->username)) { //make link to profile and format name according to cb config $pname="posterid)."\">".htmlspecialchars(getNameFormat($item->name,$item->username,$ueConfig['name_format'])).""; //get users avatar if they have one // if (isset($item->avatar)) { $pimg="
".getFieldValue('image',$item->avatar,$item); // } //get users primary email address and display it according to CB config $pEmail="
".getFieldValue('primaryemailaddress',$item->posteremail,$item); if($pbEnableGesture && $isME) { $returnFavor = "| _getAbsURLwithParam(array('user'=>$item->posterid,'showform'=>1))."\">" ._pb_ReturnFavor.""; } } else { //entry was submitted by anonymous user just diplay entered data $pname=htmlspecialchars($item->postername); $pEmail="
".getFieldValue('emailaddress',$item->posteremail,$item); } //check to see if the location was entered to determine how to display it if($pbUseLocation && $item->posterlocation!=null && $item->posterlocation!="") { $pLocation = "
".htmlspecialchars($item->posterlocation); } else $pLocation=null; //check to see if the web address was entered to determine how to display it if($pbUseWebAddress && $item->posterurl!=null && $item->posterurl!="") { $URL ="
".getFieldValue('webaddress',$item->posterurl); } else $URL=null; //if the profile visitor is the profile owner and the ip address of the poster is not null then show the ip address with link to lookup site $ip=""; if($iAmModerator && $item->posterip!="") { $ips = explode(",",$item->posterip); foreach ($ips as $poster_proxy_ip) { $ip .= "
" . getFieldValue('text',$poster_proxy_ip) . ""; } } //display information about the poster $return .= "\n\t\t"; $return .= "\n\t\t"; $return .= "\n\t"; } $return .= "\n
"._pb_NameHeader.""._pb_EntryHeader."
".$pname."".$pEmail.$pLocation.$URL.$ip.$pimg.""; //display unpublished, signed on date, edited by on date, and rating $return .= ""; if (!$item->published) { $return .= ""._pb_NotPublished." | "; } $return .= sprintf(_pb_CreatedOn, $signtime); if ($item->editdate) { $return .= "
".htmlspecialchars(sprintf(_pb_EditedByOn, $item->editedbyname, $edittime)); } $return .= "
"; if ($img) { $return .= " ".$img.""; } //parse bbcode and display $return .= "

".$this->parseBBCode(nl2br(htmlspecialchars($item->postercomment)), $pbAllowBBCode, $pbAllowSmiles); //add warning if it's not the author who edited if ($item->editdate && ($item->posterid != $item->editedbyid || $item->postername != $item->editedbyname)) { $return .= _pb_EditedByModerator; } //check to see if the profile owner has left feedback and determine how to display if ($item->feedback<>"") { $return .= "
".htmlspecialchars(sprintf(_pb_FeedbackFrom, getNameFormat($user->name,$user->username,$ueConfig['name_format'])))."".$this->parseBBCode(nl2br(htmlspecialchars($item->feedback)), $pbAllowBBCode, $pbAllowSmiles).""; } //check to see if the profile visitor is the profile owner or a moderator or original poster if($isME || $iAmModerator || ($my->id && $my->id == $item->posterid)) { $return .= "
"; } if ($iAmModerator || ($my->id && $my->id == $item->posterid)) { $formName = "pbeditcomment".$k; $linkTitle = _pb_EditEntry; $txtSubmit = _pb_UpdateEntry; if (!$jsSent++) echo $this->_getpbJS(); $return .= $this->_hiddenBBeditor($item, $formName, $linkTitle, $txtSubmit, 0, $curruser, $pbEnableRating, $pbUseLocation, $pbLocationField, $pbUseWebAddress, $pbWebField, $required, $pbAllowBBCode, $pbAllowSmiles, ($iAmModerator && ($my->id != $item->posterid)) ? _pb_EditOthersAreYouSure : null); if ($iAmModerator) { $return .= " | "; } } if ($isME || $iAmModerator) { //yes it is so display action links $base_url = $this->_getAbsURLwithParam($pagingParams); $return .= "
" ."" ."_getPagingParamName("id")."\" value=\"".$item->pbid."\" />" ."_getPagingParamName("published")."\" id=\"published".$k."\" value=\"1\" />" ."_getPagingParamName("status")."\" id=\"status".$k."\" value=\"1\" />" ."_getPagingParamName("formaction")."\" value=\"update\" />" ."
"; if($item->published==0) { $published=null; $publishLink=""._pb_Publish.""; } else { $published = "checked=\"checked\""; $publishLink=""._pb_UnPublish.""; } if($item->status==0) { $status=null; $statusLink="".Mark read.""; } else { $status = "checked=\"checked\""; $statusLink="".Mark read.""; } $popform=null; $popform .= "
"; $popform .= ""._pb_Publish.":_getPagingParamName("published")."\" id=\"published".$k."\" value=\"1\" ".$published." />"; $popform .= "_getPagingParamName("id")."\" value=\"".$item->pbid."\" />_getPagingParamName("formaction")."\" value=\"update\" />"; $popform .= "
"._pb_YourFeedback.":
"; $popform .= "
"; $return .= ""._pb_Delete ." | ".$publishLink." | ".$statusLink; if ($isME || ($iAmModerator && $item->feedback)) { $return .= " | ","'","\n","\r"), array("&","\\\\",""","<",">","\'","\\n","\\r"),$popform)."', STICKY, CAPTION,'"._pb_GiveFeedback."', CENTER,CLOSECLICK,CLOSETEXT,'"._UE_CLOSE_OVERLIB."',WIDTH,350, ANCHOR,'pbFeedback".$k."',ANCHORALIGN,'LR','UR');\">".($item->feedback ? _pb_EditFeedback : _pb_GiveFeedback)." "; } $return .= $returnFavor; } $return .= "

"; //display pagination if ($pagingEnabled && ($pbEntriesPerPage < $total)) { $return .= "
" .$this->_writePaging($pagingParams,"pbposts_",$pbEntriesPerPage,$total) ."
"; } $return .= ""; $return .= "\n
"; } else { //no posts so determine what to display $return .= "

"; $return .= _pb_NoPosts; $return .= "
"; } return $return; } /** * UserBot Called when a user is deleted from backend (prepare future unregistration) * @param object mosUser reflecting the user being deleted * @param int 1 for successful deleting * @returns true if all is ok, or false if ErrorMSG generated */ function userDeleted($user, $success) { global $database,$ueConfig; $sql="DELETE FROM #__comprofiler_plug_profilebook WHERE userid='".$user->id."'"; $database->SetQuery($sql); if (!$database->query()) { $this->_setErrorMSG("SQL error cb.profilebook:userDeleted-1" . $database->stderr(true)); return false; } return true; } function _hiddenBBeditor($item, $formName, $linkTitle, $txtSubmit, $showform, $curruser, $pbEnableRating, $pbUseLocation, $pbLocationField, $pbUseWebAddress, $pbWebField, $required, $pbAllowBBCode, $pbAllowSmiles, $warnText) { $return = ""; $return .= "".$linkTitle." \"\""; $return .= $this->_bbeditor($item, $formName, $txtSubmit, $curruser, $pbEnableRating, $pbUseLocation, $pbLocationField, $pbUseWebAddress, $pbWebField, $required, $pbAllowBBCode, $pbAllowSmiles); if ($showform) $return .= "\n\n"; return $return; } function _bbeditor($item, $idTag, $txtSubmit , $curruser, $pbEnableRating, $pbUseLocation, $pbLocationField, $pbUseWebAddress, $pbWebField, $required, $pbAllowBBCode, $pbAllowSmiles) { global $my, $database, $ueConfig, $acl; if ($item == null) { $item = new stdClass(); $item->postercomment = null; $item->postername = null; $item->posterlocation = null; $item->posteremail = null; $item->posterurl = null; $item->postervote = null; $item->posterid = -1; $item->pbid=null; } $htmltext=""; $htmltext .= "
"; //get the CB initiatied form action path this is used for all forms $base_url = $this->_getAbsURLwithParam(array()); $htmltext .= "
\n"; $htmltext .= "_getPagingParamName("formaction")."\" value=\"".($item->pbid?"edit":"new")."\" />\n"; if ($item->pbid) { $htmltext .= "_getPagingParamName("id")."\" value=\"".$item->pbid."\" />\n"; } if ($pbAllowBBCode) $editor = $this->getEditor($idTag); else $editor = null; $htmltext .= "\n"; $locationField=null; //Check to see if the Location field should be used if($pbUseLocation) { //Check to see if a registered user is logged in and if the admin has defined a a value for the location field if($my->id && $pbLocationField!=0) { $locationField=new moscomprofilerFields($database); $locationField->load($pbLocationField); $pbLocationField=$locationField->name; //if they true then display the location value from the users cb profile in read only $locationField= ""; } else { //else display an entry field to capture the location $locationField= ""; } } $webField=null; if($pbUseWebAddress) { if($my->id && $pbWebField!=0) { $webfield=new moscomprofilerFields($database); $webfield->load($pbWebField); $pbWebField=$webfield->name; $webField= ""; } else { $webField= ""; } } if(!$my->id) { $htmltext .= "\n"; $htmltext .= ""; } else { $htmltext .= "\n"; $htmltext .= ""; } //Check to see if we are displaying the web address or location field. If we are then add a row for them if($webField!=null || $locationField!=null) $htmltext .= "\n".$locationField.$webField.""; $htmltext .= ""; $htmltext .= "\n"; $htmltext .= "
"._pb_Location.":
_getPagingParamName("posterlocation")."\" value=\"".htmlspecialchars($curruser->$pbLocationField)."\" />".getFieldValue('text',$curruser->$pbLocationField,$curruser)."
"._pb_Location.":
_getPagingParamName("posterlocation")."\" value=\"".htmlspecialchars($item->posterlocation)."\" />
"._pb_Url.":
_getPagingParamName("posterurl")."\" value=\"".$curruser->$pbWebField."\" />".getFieldValue('webaddress',$curruser->$pbWebField,$curruser)."
"._pb_Url.":
_getPagingParamName("posterurl")."\" value=\"".htmlspecialchars($item->posterurl)."\" />
"._pb_Name.":
_getPagingParamName("postername")."\" value=\"".htmlspecialchars($item->postername)."\" />
"._pb_Email.":
_getPagingParamName("posteremail")."\" value=\"".htmlspecialchars($item->posteremail)."\" />
"._pb_Name.":
_getPagingParamName("postername")."\" value=\"".htmlspecialchars($item->postername? $item->postername : getNameFormat($curruser->name,$curruser->username,$ueConfig['name_format']))."\" />".htmlspecialchars($item->postername? $item->postername : getNameFormat($curruser->name,$curruser->username,$ueConfig['name_format']))."
"._pb_Email.":
"; if (!$item->posteremail || $my->id==$item->posterid || $acl->acl_check( 'administration', 'manage', 'users', $my->usertype, 'components', 'com_users' )) { $htmltext .= "_getPagingParamName("posteremail")."\" value=\"".($item->posteremail?htmlspecialchars($item->posteremail):$curruser->email)."\" />".($item->posteremail?htmlspecialchars($item->posteremail):getFieldValue('text',$curruser->email,$curruser)); } else { $htmltext .= _pb_Hidden; } $htmltext .= "
"; //Check to see if the admin has enabled rating for profile entries if ($pbEnableRating){ //Yep its enabled so get the ratings HTML/Code $htmltext .= "
"._pb_UserRating.":
" .$this->getRatingForm($item->postervote)."

"; } $htmltext .= ""._pb_Comments.":
".$editor ."\n\n"; if ($pbAllowSmiles) { $htmltext .= "\n"; if ($pbAllowSmiles) { $htmltext .= "\n"; } $htmltext .= "\n
\n"; } else { $htmltext .= "\n"; } $htmltext .= "\n\n".$this->getSmilies($idTag)."
\n
\n"; $htmltext .= "
\n"; $htmltext .="
\n"; //Add the localized Javascript Paramaters so that error messages are properly translated $validateArray = array(); if ($required) { $validateArray[] = array("field"=>"postername", "confirm"=>null, "error"=>_pb_NameRequired); $validateArray[] = array("field"=>"posteremail", "confirm"=>null, "error"=>_pb_EmailRequired); } if ($pbEnableRating == 3) { $validateArray[] = array("field"=>$this->_getPagingParamName("postervote"), "confirm"=>null, "error"=>_pb_RatingRequired); } elseif ($pbEnableRating == 2) { $validateArray[] = array("field"=>$this->_getPagingParamName("postervote"), "confirm"=>_pb_RatingUnselectedAreYouSure, "error"=>null); } $validateArray[] = array("field"=>"profilebookpostercomments", "confirm"=>null, "error"=>_pb_CommentRequired); $res = array(); foreach ($validateArray as $validateField) { $res[] = "Array('".$validateField["field"]."'," ."'".str_replace(array("'","\\"),array("\\'","\\\\"),$validateField["confirm"])."'," ."'".str_replace(array("'","\\"),array("\\'","\\\\"),$validateField["error"])."')"; } $htmltext .="\n\n\n\n"; return $htmltext; } function _getpbJS() { global $mosConfig_live_site; $editor=null; $editor .="\n\n"; /* $editor .="\n"; */ return $editor; } function getEditor($idTag) { $editor=null; $editor .=''; $editor .=' '; $editor .=' '; $editor .=' '; $editor .=' '; $editor .=' '; //$editor .=' '; //$editor .=' '; //$editor .=' '; $editor .='
'; $editor .=' '; $editor .=' '; $editor .=' '; $editor .=' '; $editor .=' '; $editor .=' '; // $editor .=' '; $editor .='
 '._pb_Color.':'; $editor .='  '._pb_Size.':'; $editor .='   '._pb_CloseAll.''; $editor .='
'; return $editor; } function smiliesArray() { $smilies = array( ':)'=>'smile.png' ,';)'=>'wink.png' ,'B)'=>'cool.png' ,'8)'=>'cool.png' ,':lol:'=>'grin.png' ,':laugh:'=>'laughing.png' ,':cheer:'=>'cheerful.png' ,':kiss:'=>'kissing.png' ,':silly:'=>'silly.png' ,':ohmy:'=>'shocked.png' ,':woohoo:'=>'w00t.png' ,':whistle:'=>'whistling.png' ,':('=>'sad.png' ,':angry:'=>'angry.png' ,':blink:'=>'blink.png' ,':sick:'=>'sick.png' ,':unsure:'=>'unsure.png' ,':dry:'=>'ermm.png' ,':huh:'=>'wassat.png' ,':pinch:'=>'pinch.png' ,':side:'=>'sideways.png' ,':evil:'=>'devil.png' ,':blush:'=>'blush.png' ,':-)'=>'smile.png' ,':-('=>'sad.png' ,';-)'=>'wink.png' ,':S'=>'dizzy.png' ,':s'=>'dizzy.png' ,':P'=>'tongue.png' ,':p'=>'tongue.png' ,':D'=>'laughing.png' ,':X'=>'sick.png' ,':x'=>'sick.png'); return $smilies; } function getSmilies($idTag) { $params = $this->params; $pbAllowSmiles=$params->get('pbAllowSmiles', '1'); //Determine if Smilies are allowed if(!$pbAllowSmiles) { return null; } $smilies = $this->smiliesArray(); $return=null; $outputed = array(); foreach($smilies as $code => $location) { if (!in_array($location,$outputed)) { $return .= '' . $code . ' '; $outputed[] = $location; } } return $return; } function getRatingForm($vote) { global $mosConfig_live_site; // look for images in template if available if (is_callable(array("mosAdminMenus","ImageCheck"))) { $starImageOn = mosAdminMenus::ImageCheck( 'rating_star.png', '/images/M_images/' ); $starImageOff = mosAdminMenus::ImageCheck( 'rating_star_blank.png', '/images/M_images/' ); } else { // Mambo 4.5.0: $starImageOn = ''; $starImageOff = ''; } $chk = ' checked="checked"'; $html=null; $html .= ''; $html .= _VOTE_POOR; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= _VOTE_BEST; $html .= ''; return $html; } function _getRatingImage( $rating, $alwaysShowStars=false ) { global $mosConfig_live_site; if (!$alwaysShowStars && $rating === null) return ""; //get standard joomla rating stars for template if (is_callable(array("mosAdminMenus","ImageCheck"))) { $starImageOn = mosAdminMenus::ImageCheck( 'rating_star.png', '/images/M_images/' ); $starImageOff = mosAdminMenus::ImageCheck( 'rating_star_blank.png', '/images/M_images/' ); } else { // Mambo 4.5.0: $starImageOn = ''; $starImageOff = ''; } $img=""; //return $rating; //get all the colored rating images for ($j=0; $j < $rating; $j++) { $img .= $starImageOn; } //get all the grayed out rating images for ($j=$rating; $j < 5; $j++) { $img .= $starImageOff; } return $img; } function parseSmilies($text){ $smilies = $this->smiliesArray(); foreach($smilies as $code => $location) { $text = str_replace($code,'',$text); } return $text; } function parseBBCode($text, $pbAllowBBCode, $pbAllowSmiles) { if ($pbAllowSmiles) { $text = $this->parseSmilies($text); } if ($pbAllowBBCode) { require_once("components/com_comprofiler/plugin/user/plug_cbprofilebook/classes/bbcode.inc.php"); $bbcode = new bbcode(); $bbcode->add_tag(array('Name'=>'quote','HtmlBegin'=>'
','HtmlEnd'=>'
')); $bbcode->add_tag(array('Name'=>'b','HtmlBegin'=>'','HtmlEnd'=>'')); $bbcode->add_tag(array('Name'=>'ul','HtmlBegin'=>'')); $bbcode->add_tag(array('Name'=>'ol','HtmlBegin'=>'
    ','HtmlEnd'=>'
')); $bbcode->add_tag(array('Name'=>'li','HtmlBegin'=>'
  • ','HtmlEnd'=>'
  • ')); $bbcode->add_tag(array('Name'=>'i','HtmlBegin'=>'','HtmlEnd'=>'')); $bbcode->add_tag(array('Name'=>'u','HtmlBegin'=>'','HtmlEnd'=>'')); $bbcode->add_tag(array('Name'=>'link','HasParam'=>true,'HtmlBegin'=>'','HtmlEnd'=>'')); $bbcode->add_tag(array('Name'=>'img','HasParam'=>true,'HtmlBegin'=>'','HasEnd'=>false)); $bbcode->add_tag(array('Name'=>'color','HasParam'=>true,'ParamRegex'=>'[A-Za-z0-9#]+','HtmlBegin'=>'','HtmlEnd'=>'','ParamRegexReplace'=>array('/^[A-Fa-f0-9]{6}$/'=>'#$0'))); $bbcode->add_tag(array('Name'=>'email','HasParam'=>true,'HtmlBegin'=>'','HtmlEnd'=>'')); // $bbcode->add_tag(array('Name'=>'size','HasParam'=>true,'HtmlBegin'=>'','HtmlEnd'=>'','ParamRegex'=>'[0-9]+')); $bbcode->add_tag(array('Name'=>'size','HasParam'=>true,'HtmlBegin'=>'','HtmlEnd'=>'','ParamRegexReplace'=>array('/^1$/'=>'80','/^2$/'=>'90','/^3$/'=>'100','/^4$/'=>'125','/^5$/'=>'200') )); $bbcode->add_tag(array('Name'=>'align','HtmlBegin'=>'
    ','HtmlEnd'=>'
    ','HasParam'=>true,'ParamRegex'=>'(center|right|left)')); $bbcode->add_alias('url','link'); $text = $bbcode->parse_bbcode($text); } return $text; } /** * ProfileBook Internal method: sets User Status * @access private * @param array sbConfig * @param object user being displayed * @param object sbUserDetails */ function _setStatusMenuPBstats(&$params, $value) { if ($params->get('pbStatRating', '1')) { $mi = array(); $mi["_UE_MENU_STATUS"][getLangDefinition($params->get('pbStatRatingText', "_pb_DefaultRatingText"))]["duplicate"]=null; $this->addMenu( array( "position" => "menuList" , // "menuBar", "menuList" "arrayPos" => $mi , "caption" => $value , "url" => "" , // can also be "" or "javascript:void(0)" or "" "target" => "" , // e.g. "_blank" "img" => null , // e.g. "" "alt" => null , // e.g. "text" "tooltip" => "") ); } } /** * Generates the menu and user status to display on the user profile by calling back $this->addMenu * @param object tab reflecting the tab database entry * @param object mosUser reflecting the user being displayed * @param int 1 for front-end, 2 for back-end * @returns boolean : either true, or false if ErrorMSG generated */ function getMenuAndStatus($tab,$user,$ui) { $this->_getLanguageFile(); $params=$this->params; $pbStatDisplay=$params->get('pbStatRating', '1'); if ($pbStatDisplay==1) { $value = $this->_getAvgRating($user); $this->_setStatusMenuPBstats($params, $value); } return true; } function _getAvgRating($user){ global $database; $sql = "SELECT ROUND(AVG(postervote),0) FROM #__comprofiler_plug_profilebook WHERE userid=".$user->id; $database->setQuery($sql); $value = $database->loadResult(); return $this->_getRatingImage($value, true); } } // end class getForumTab. ?>