\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
"._pb_NameHeader."
";
$return .= "\n
"._pb_EntryHeader."
";
$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
".$pname."".$pEmail.$pLocation.$URL.$ip.$pimg."
";
$return .= "\n\t\t
";
//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 .= "";
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 .= "";
$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 .= "
";
} 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 .="
\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 .='