<?php
/*************************************************************
* Mambo Community Builder
* Author MamboJoe
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
*************************************************************/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

class HTML_comprofiler {
	function emailUser($option,$rowFrom,$rowTo) {
	global $ueConfig,$_REQUEST,$mosConfig_live_site;
?>
	<script>
	  function submitbutton() {
	    var coll = document.emailUser;
	    var errorMSG = '';
	    var iserror=0;
	     if (coll != null) {
	       var elements = coll.elements;
	       // loop through all input elements in form
	       for (var i=0; i < elements.length; i++) {
	         // check if element is mandatory; here mosReq=1
	         if (elements.item(i).getAttribute('mosReq') == 1) {
	           if (elements.item(i).value == '') {
	             //alert(elements.item(i).getAttribute('mosLabel') + ':' + elements.item(i).getAttribute('mosReq'));
	             // add up all error messages
	             errorMSG += elements.item(i).getAttribute('mosLabel') + ' <?php echo _UE_REQUIRED_ERROR; ?>\n';
	             // notify user by changing background color, in this case to red
	             elements.item(i).style.background = "red";
	             iserror=1;
	           }
	         }
	       }
	      }
	    if(iserror==1) { alert(errorMSG); }
	    else {
	      document.emailUser.submit();
	    }
	  }
	</script>
	<div style="text-align:left;">
	<div class="contentheading" ><?php echo sprintf(_UE_EMAILFORMINSTRUCT,$rowTo->id,getNameFormat($rowTo->name,$rowTo->username,$ueConfig['name_format'])); ?></div>
	<form name=emailUser method=post action=index.php>
		<?php echo _UE_EMAILFORMSUBJECT; ?><br />
		<input mosReq=1 mosLabel='<?php echo _UE_EMAILFORMSUBJECT; ?>' type=text class="inputbox" name=emailSubject size="50" /><?php echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; ?><br />
		<?php echo _UE_EMAILFORMMESSAGE; ?><br />
		<textarea mosReq=1 mosLabel='<?php echo _UE_EMAILFORMMESSAGE; ?>' class="inputbox" name=emailBody cols=50 rows=15 ></textarea><?php echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; ?><br />
		<div><?php echo _UE_EMAILFORMWARNING; ?></div>
		<input type=hidden name=fromID value="<?php echo $rowFrom->id; ?>" />
		<input type=hidden name=toID value="<?php echo $rowTo->id; ?>" />
		<input type=hidden name=option value="<?php echo $option; ?>" />
		<input type=hidden name=task value=sendUserEmail />
		<input type="button" onclick="submitbutton();" class="button" name=btnsubmit value="Send Email" />
		
	</form>
	</div>
	<div style="align:center;">
	<?php
	echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "._UE_FIELDREQUIRED;
	?>
	</div>
<?php

	}

/******************************
Profile Functions
******************************/

	function userEdit($row, $rowExtras, $rowFields, $rowFieldValues, $option,$submitvalue,$fieldJS=null)
	{
	global $database,$ueConfig,$_REQUEST,$mosConfig_live_site;

?>
<link rel="stylesheet" type="text/css" media="all" href="includes/js/calendar/calendar-mos.css" title="green" />
<!-- import the calendar script -->
<script type="text/javascript" src="includes/js/calendar/calendar.js"></script>
<!-- import the language module -->
<script type="text/javascript" src="includes/js/calendar/lang/calendar-en.js"></script>
<script language="Javascript" src="includes/js/dhtml.js"></script>
<script language="javascript" type="text/javascript">
  function getObject(obj) {
    var strObj;
    if (document.all) {
      strObj = document.all.item(obj);
    } else if (document.getElementById) {
      strObj = document.getElementById(obj);
    }
    return strObj;
  }

  function submitbutton() {
    //alert("I got clicked!");
    var coll = document.EditUser; //getObject("EndUser");
    var errorMSG = '';
    var iserror=0;
 <?php echo $fieldJS; ?>
	if(document.all) {
		coll.fireEvent('onsubmit');
	} else if (document.getElementById) {
		var evt = document.createEvent("HTMLEvents");
		evt.initEvent("onsubmit", false, false);
		window.dispatchEvent(evt);
	}
     if (coll != null) {
       var elements = coll.elements;
	//elements += document.getElementsByTagName('textarea');
       // loop through all input elements in form
       for (var i=0; i < elements.length; i++) {
         // check if element is mandatory; here mosReq=1
         if (elements.item(i).getAttribute('mosReq') == 1) {
           if (elements.item(i).value == '') {
             //alert(elements.item(i).getAttribute('mosLabel') + ':' + elements.item(i).getAttribute('mosReq'));
             // add up all error messages
             errorMSG += elements.item(i).getAttribute('mosLabel') + ' <?php echo _UE_REQUIRED_ERROR; ?>\n';
             // notify user by changing background color, in this case to red
             elements.item(i).style.background = "red";
             iserror=1;
           }
         }
       }
      }
    if(iserror==1) { alert(errorMSG); }
    else {
     	document.EditUser.submit();
    }
  }

  function showCalendar2(id,dFormat) {
    var el = getObject(id);
    if (calendar != null) {
      // we already have one created, so just update it.
      calendar.hide();    // hide the existing calendar
      calendar.parseDate(el.value); // set it to a new date
    } else {
      // first-time call, create the calendar
      var cal = new Calendar(true, null, selected, closeHandler);
      calendar = cal;    // remember the calendar in the global
      cal.setRange(1900, 2070);  // min/max year allowed
      cal.dateFormat = dFormat;
      calendar.create();    // create a popup calendar
    }
    calendar.sel = el;    // inform it about the input field in use
    calendar.showAtElement(el);  // show the calendar next to the input field

    // catch mousedown on the document
    Calendar.addEvent(document, "mousedown", checkCalendar);
    return false;
  }
</script>
<form action="index.php" method="post" id="EditUser" name="EditUser">
<!-- TAB -->
<?
$ptabs='';
$pfields='';
$poldtab='';
$t=2;
if(count($rowFields)>0) {
for($i=0, $n=count( $rowFields ); $i < $n; $i++) {
	if($poldtab <> $rowFields[$i]->tab)  {
		$ptabs .= "<td id=\"ue_tab".$t."\" class=\"offtab\" onClick=\"dhtml.cycleTab(this.id)\">".getLangDefinition($rowFields[$i]->tab)."</td>\n";
		if($i > 0) $pfields .= "\t</table>\n</div>\n";
		$pfields .= "<div id=\"ue_page".$t."\"  class=\"pagetext\" width=\"100%\">\n";
		$pfields .= "\t<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n";
		if($rowFields[$i]->tab!='' && $rowFields[$i]->tab!=null) $pfields .= "\t\t<br /><div><b>".getLangDefinition($rowFields[$i]->tabdesc)."</b></div>\n";
		$t++;
	}
	if($rowFields[$i]->table=='#__users') $dArray ='$row->';
	else $dArray ='$rowExtras->';
	$poldtab=$rowFields[$i]->tab;
	$pfields .= "\t\t<tr>";
	$pfields .= "\t\t\t<td class=\"titleCell\">". getLangDefinition($rowFields[$i]->title) .":</td>";
	eval("\$oValue = \"".$dArray.$rowFields[$i]->name."\";");
	$pfields .= "\t\t\t<td>" 
		.getFieldEntry($rowFields[$i]->type,$rowFields[$i]->name,$oValue,$rowFields[$i]->required,$rowFields[$i]->title,$rowFields[$i]->id,$rowFields[$i]->size, $rowFields[$i]->maxlength, $rowFields[$i]->cols, $rowFields[$i]->rows,$rowFields[$i]->profile,$rowFieldValues['lst_'.$rowFields[$i]->name],$rowFields[$i]->readonly);
		
		//Rodax Software
		if (($rowFields[$i]->name == 'jefe') || ($rowFields[$i]->name == 'cuerda') ||
		    ($rowFields[$i]->name == 'orden') || ($rowFields[$i]->name == 'perfil') 
		) {
		   $pfields .= getFieldEntry('hidden',$rowFields[$i]->name,$oValue,$rowFields[$i]->required,$rowFields[$i]->title,$rowFields[$i]->id,$rowFields[$i]->size, $rowFields[$i]->maxlength, $rowFields[$i]->cols, $rowFields[$i]->rows,$rowFields[$i]->profile,$rowFieldValues['lst_'.$rowFields[$i]->name],$rowFields[$i]->readonly);
		}
	
	$pfields .= "</td>\n";
	$pfields .= "\t\t</tr>";
}
	$pfields .= "\t\t</tr>";
	$pfields .= "\t</table>";
	$pfields .= "</div>";
}

?>
<div class="componentheading"><?php echo _UE_EDIT_TITLE; ?></div>
<?php
	//Rodax Software
	/*<table class="contentpaneopen">
        <tr>
          <td width="" class="tabpadding">&nbsp;</td>
          <td id="ue_tab1" class="offtab" onClick="dhtml.cycleTab(this.id)"><?php echo _UE_CONTACT_INFO_HEADER; ?></td>
	<?php echo $ptabs; ?>
          <td width="50%" class="tabpadding">&nbsp;</td>
       </tr>
</table>  */
?>
<table class="contentpaneopen">
	<tr>
		<td class="contentheading"><?php echo _UE_CONTACT_INFO_HEADER; ?></td>
	</tr>
</table>

<div id="ue_page1"  class="pagetext" width="100%">
	<table cellpadding="5" cellspacing="0" border="0" width="100%">	
		<tr>
			<td class="titleCell"><?php echo _UE_UNAME; ?></td>
 			<td><?php IF($ueConfig['usernameedit']==1) { ?><input class="inputbox" type="text" size="40" name="username" value="<?php echo $row->username;?>" /><?php } else echo $row->username; ?><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' />"; IF($ueConfig['name_format']!=1) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
<?php
	SWITCH($ueConfig['name_style']) {
		case 2:
?>
		<tr>
			<td class="titleCell">First Name:</td>
			<td><input class="inputbox" type="text" size="40" mosReq=1 mosLabel="<?php echo _UE_YOUR_FNAME; ?>" name="firstname" value="<?php echo $rowExtras->firstname;?>" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['name_format']!=3) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
		<tr>
			<td class="titleCell">Last Name:</td>
			<td><input class="inputbox" type="text" size="40" mosReq=1 mosLabel="<?php echo _UE_YOUR_LNAME; ?>" name="lastname" value="<?php echo $rowExtras->lastname;?>" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['name_format']!=3) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
<?php
		break;
		case 3:
?>
		<tr>
			<td class="titleCell">First Name:</td>
			<td><input class="inputbox" type="text" size="40" mosReq=1 mosLabel="<?php echo _UE_YOUR_FNAME; ?>" name="firstname" value="<?php echo $rowExtras->firstname;?>" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['name_format']!=3) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
		<tr>
			<td class="titleCell">Middle Name:</td>
			<td><input class="inputbox" type="text" size="40" mosReq=0 mosLabel="<?php echo _UE_YOUR_MNAME; ?>" name="middlename" value="<?php echo $rowExtras->middlename;?>" /><?php IF($ueConfig['name_format']!=3) echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
		<tr>
			<td class="titleCell">Last Name:</td>
			<td><input class="inputbox" type="text" size="40" mosReq=1 mosLabel="<?php echo _UE_YOUR_LNAME; ?>" name="lastname" value="<?php echo $rowExtras->lastname;?>" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['name_format']!=3) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
<?php
		break;
		DEFAULT:
?>

		<tr>
			<td class="titleCell"><?php echo _UE_YOUR_NAME;?></td>
			<td><input class="inputbox" type="text" size="40" name="name" mosReq=1 mosLabel="Name"  value="<?php echo $row->name;?>" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['name_format']!=3) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
<?php 		
		break;
	} 
?>
		<tr>
			<td class="titleCell"><?php echo _UE_EMAIL; ?></td>
			<td><input class="inputbox" type="text" name="email" value="<?php echo $row->email;?>" size="40" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['allow_email_display']==1 || $ueConfig['allow_email_display']==2) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />";  ?></td>
		</tr>
		<tr>
			<td class="titleCell"><?php echo _UE_PASS; ?></td>
			<td><input class="inputbox" type="password" size="40" name="password" value="" /></td>
		</tr>
		<tr>
			<td class="titleCell"><?php echo _UE_VPASS; ?></td>
			<td><input class="inputbox" type="password" size="40" name="verifyPass" /></td>
		</tr>
	</table>
</div>                        
<?php echo $pfields; ?>
<br/>
<table class="contentpaneopen">	
	<tr>
		<td>
			<input class="button" type="button" name="btnsubmit" onclick="submitbutton();" value="<?php echo $submitvalue; ?>" /> 
			<?php 
			 /* Rodax Software
			    <input type="button" class="button" name=btncancel value="<?php echo _UE_CANCEL; ?>" onclick="window.location='<?php echo sefRelToAbs("index.php?option=".$_REQUEST['option']."&Itemid=".$_REQUEST['Itemid']); ?>';" />
			 */
			?>
			<input type="button" class="button" name=btncancel value="<?php echo _UE_CANCEL; ?>" onclick="window.location='<?php echo sefRelToAbs("index.php?option=".$_REQUEST['option']."&task=userProfile&user=".$row->id); ?>';" />
		</td>
	</tr>
</table>
	<input type="hidden" name="id" value="<?php echo $row->id;?>" />
	<input type="hidden" name="option" value="<?php echo $option;?>">
	<input type="hidden" name="task" value="saveUserEdit" />
</form>
<br/>
<div style="align:center;">
<?php
echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "._UE_FIELDREQUIRED." <br/> ";
echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' /> "._UE_FIELDONPROFILE." <br/> ";		
echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' /> "._UE_FIELDNOPROFILE;
?>
</div>
<script>
dhtml.cycleTab('ue_tab1');
</script>
<?php
	}
	function userProfile($user, &$tablist, $option,$submitvalue)
	{
	global $database, $my, $ueConfig,$mosConfig_lang;	
	$pfields='';
	$isModerator=isModerator($my->id);
	$userIsModerator=isModerator($user->id);
	$database->setQuery("SELECT COUNT(*) FROM #__session WHERE userid =".$user->id);
	$isonline = $database->loadResult();

	$ue_base_url = "index.php?option=com_comprofiler&Itemid=" . $_REQUEST['Itemid'];	// Base URL string
	$ue_userdetails_url = $ue_base_url."&task=userDetails";
	
	// Rodax Software
	if ($isModerator)
		$ue_userdetails_url = $ue_userdetails_url."&user=".$user->id;
	
	$ue_useravatar_url = $ue_base_url."&task=userAvatar";
	
	// Rodax Software
	if ($isModerator)
		$ue_useravatar_url = $ue_useravatar_url."&user=".$user->id;
	
	
	$adminimagesdir = "components/com_comprofiler/images/";
	$showProfile=1;
	if($user->banned!=0) {
			echo "<font color=red>"._UE_USERPROFILEBANNED."</font>";
		if($my->id!=$user->id && $isModerator!=1) {
			$showProfile=0;
		} else {
			echo "<br /><font color=red>".nl2br($user->bannedreason)."</font>";
			$showProfile=1;
		} 
	}
if($showProfile==1) {
?>
	<?php
		// Rodax Software
		//<table cellpadding="5" cellspacing="0" border="0" width="100%">
		echo '<div class="componentheading">'. _UE_PROFILE_TITLE .'</div>';
		echo '<table class="contentpaneopen">';
	?>
		<tr>
			<?php
				/* Rodax Software
				   <td class="contentheading" width=50%><?php echo getNameFormat($user->name,$user->username,$ueConfig['name_format'])." ". _UE_PROFILE_TITLE; ?></td>
					 <td align=right width=50%>
				*/
    		echo '<td class="contentheading">' . getNameFormat($user->name,$user->username,$ueConfig['name_format']) . '</td>';
    		echo '<td align=right class="buttonheading">';
			?>    			 
    			
			<?php 
			if(($my->id==$user->id) || $isModerator) { 
				$y=" | ";
				echo "<a href='".sefRelToAbs($ue_userdetails_url)."'><img src='".$adminimagesdir."updateprofile.gif' border=0 /> "._UE_UPDATEPROFILE."</a>"; 
				if($user->banned==1 && $userIsModerator==0 && $ueConfig['allowUserBanning']==1) echo " | <a href='".sefRelToAbs("index.php?option=com_comprofiler&task=banProfile&act=2&reportform=1&uid=".$user->id)."'>"._UE_REQUESTUNBANPROFILE."</a>";
			} else { 
				if($ueConfig['allowUserReports']==1 && $userIsModerator==0 && $isModerator==0 && $my->id > 0) echo "<a href='".sefRelToAbs("index.php?option=com_comprofiler&task=reportUser&uid=".$user->id)."'>"._UE_REPORTUSER."</a>";

			}
			if($isModerator==1 && $my->id!=$user->id && $userIsModerator==0) {
				$query = "SELECT count(*) FROM #__comprofiler_userreports  WHERE reportedstatus=0 AND reporteduser='".$user->id."'";
				if(!$database->setQuery($query)) print $database->getErrorMsg();
				$userreports = $database->loadResult();
				if($ueConfig['allowUserBanning']==1) {
					if($user->banned!=0 ) echo $y."<a href='".sefRelToAbs("index.php?option=com_comprofiler&task=banProfile&act=0&reportform=0&uid=".$user->id)."'>"._UE_UNBANPROFILE."</a>";			
					else echo $y."<a href='".sefRelToAbs("index.php?option=com_comprofiler&task=banProfile&act=1&uid=".$user->id)."'>"._UE_BANPROFILE."</a>";
				}
				if($ueConfig['allowUserReports']==1 && $userreports>0) echo " | <a href='".sefRelToAbs("index.php?option=com_comprofiler&task=viewReports&uid=".$user->id)."'>"._UE_VIEWUSERREPORTS."</a>";
			}
			?>
			</td>
    </tr>	
    
		<?php
			// Rodax Software
			echo '<table class="contentpaneopen">';
		?>

    
		<tr>
			<td valign=bottom>
				<table cellpadding="5" cellspacing="0" border="0" width="100%" valign=bottom>
					<tr><?php
						$uimage=$user->avatar;
						if($user->avatarapproved==0) $uimage="components/com_comprofiler/images/".$mosConfig_lang."/pendphoto.jpg";	
						elseif($user->avatar=='' || $user->avatar==null) $uimage="components/com_comprofiler/images/".$mosConfig_lang."/nophoto.jpg";
						else $uimage="images/comprofiler/".$uimage; ?>
						<td align=center colspan=2><img src="<?php echo $uimage; ?>" /></td>
					</tr>
					<tr valign="bottom" width=100%>
						<td valign="bottom" class="buttonheading"><?php if(($isModerator) && $ueConfig['allowAvatar']==1 && ($ueConfig['allowAvatarUpload']==1 || $ueConfig['allowAvatarGallery']==1)) { echo "<a href='".sefRelToAbs($ue_useravatar_url)."'><img src='".$adminimagesdir."updateprofile.gif' border=0 /> "._UE_UPDATEAVATAR."</a>"; ?></td>
						<td valign="bottom"><?php if($user->avatar!='' && $user->avatar!=null) echo "<a href='".sefRelToAbs("index.php?option=com_comprofiler&Itemid=".$Itemid."&task=userAvatar&do=deleteavatar")."'>"._UE_DELETE_AVATAR."</a>"; } ?></td>
					</tr>
				</table>
			</td>

			<td valign=top>

				<table cellpadding="5" cellspacing="0" border="0" width="100%" >
				<?php $emailText=getFieldValue('primaryemailaddress',$user->email,$user); ?>
				<?php	$i= ($i==1) ? 2 : 1; IF($ueConfig['allow_email_display']!=4) {?>
					<tr>
						<td  class=sectiontableentry<?php echo $i; ?> width=45% style="font-weight:bold;"><?php echo _UE_EMAIL; ?></td>
						<td  class=sectiontableentry<?php echo $i; ?>><?php echo $emailText;?></td>
					</tr>
				<?php	$i= ($i==1) ? 2 : 1; } IF($ueConfig['pms']!=0 && $my->id!=$user->id) { 
					if($ueConfig['pms']==1) $pmsurl="index.php?option=com_pms&page=new&id=".$user->username; 
					else $pmsurl="index.php?option=com_mypms&task=new&to=".$user->username;
					?>
					<tr>
						<td  class=sectiontableentry<?php echo $i; ?> width=35% style="font-weight:bold;"><?php echo _UE_PM; ?></td>
						<td  class=sectiontableentry<?php echo $i; ?> ><a href="<?php echo sefRelToAbs($pmsurl); ?>"><?php echo UE_PM_USER; ?></a></td>
					</tr>
				<?php $i= ($i==1) ? 2 : 1; } ?>
					<!--<tr>
				      		<td class=sectiontableentry<?php echo $i; ?> width=35% style="font-weight:bold;"><?php echo _UE_HITS; ?></td>
				      		<td class=sectiontableentry<?php echo $i; ?> ><?php echo $user->hits; ?></td>
					</tr>-->
				<?php $i= ($i==1) ? 2 : 1; IF($ueConfig['allow_onlinestatus']==1) { ?>
					<tr>
						<td class=sectiontableentry<?php echo $i; ?> width=35% style="font-weight:bold;"><?php echo _UE_ONLINESTATUS; ?></td>
						<td class=sectiontableentry<?php echo $i; ?> ><?php if($isonline > 0) echo _UE_ISONLINE; 
							  else echo _UE_ISOFFLINE; ?></td>
					</tr>
				<?php $i= ($i==1) ? 2 : 1; } ?>
					<!--<tr>
						<td class=sectiontableentry<?php echo $i; ?> width=35% style="font-weight:bold;"><?php echo _UE_MEMBERSINCE; ?></td>
						<td class=sectiontableentry<?php echo $i; ?> ><?php echo getFieldValue('date',$user->registerDate);?></td>
					</tr>-->
				<?php $i= ($i==1) ? 2 : 1; ?>				
					<tr>
						<td class=sectiontableentry<?php echo $i; ?> width=35% style="font-weight:bold;"><?php echo _UE_LASTONLINE; ?></td>
						<td class=sectiontableentry<?php echo $i; ?> ><?php echo getFieldValue('date',$user->lastvisitDate);?></td>
					</tr>
				<?php $i= ($i==1) ? 2 : 1; ?>
					<!--<tr>
						<td class=sectiontableentry<?php echo $i; ?> width=35% style="font-weight:bold;"><?php echo _UE_LASTUPDATEDON; ?></td>
						<td class=sectiontableentry<?php echo $i; ?> ><?php echo getFieldValue('date',$user->lastupdatedate);?></td>
					</tr>-->
				<?php $i= null; ?>
				</table>
			</td>
		</tr>
	</table>
<?php //print stripslashes($pfields);

	$t=1;
	$colCount=0;
	$tabcount=count($tablist);
	$tabs=0;
	$tabevenodd = $tabcount % 2;

if($tabcount > 0 ) {

	for($i=0, $n=count( $tablist ); $i < $n; $i++) {
			$tablists = $tablist[$i];	
			$tabs++;
			if($tablists[width]==1) $colspan=2;
			else $colspan=1;
			if($i > 0) {			
				if($colspan==2) {
					$pfields .= "\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td colspan=$colspan valign=top>";
					$colCount=0;
				} elseif ($colCount==0){
					$pfields .= "\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td colspan=$colspan valign=top>";
					$colCount=1;		
				} else {
					$pfields .= "\n\t\t\t</td>\n\t\t\t<td colspan=$colspan valign=top>"; 
					$colCount=0;
				}	
			} else {
				$pfields .= "<!-- start dyn table -->\n\t\t<tr>\n\t\t\t<td colspan=$colspan valign=top>";
				if($colspan==2) $colCount=0;
				else $colCount=1;
			}
			$t=1;
			$pfields .= "\n\t\t\t<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"100%\">";
			$pfields .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2 align=center align=center class=\"sectiontableheader\"><h3>".getLangDefinition($tablists[name])."</h3></td>\n\t\t\t\t</tr>";
			$pfields .= $tablists[content];
			$pfields .= "\n\t</table>";
	}

}

	echo "\n\t<table table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"100%\">";
	print $pfields;
	echo "\n\t</td></tr></table>";

if($my->id!=$user->id) {
        $database->setQuery("UPDATE #__comprofiler SET hits=(hits+1) WHERE id='".$user->id."'");
        if (!$database->query()) {
            echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
            exit();
        } 
}
 ?>


<?php
	}
	}

	function userAvatar($row, $option,$submitvalue)
	{
	global $database,$ueConfig;
	include_once ("administrator/components/com_comprofiler/class_resize.php");

	$rowExtras = new moscomprofiler ($database);
	$rowExtras->load($row->id);

	$database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_comprofiler'");
	$Itemid = $database->loadResult();

?> 
<style>
.titleCell {
	font-weight:bold;
	width:85px;
}
</style>
<script language="javascript" type="text/javascript">
		function submitbutton() {
			//alert("I got clicked!");
			var coll = document.EditUser;
			var errorMSG = '';
			var iserror=0;
			     if (coll != null) {
			       var elements = coll.elements;
				//elements += document.getElementsByTagName('textarea');
			       // loop through all input elements in form
			       for (var i=0; i < elements.length; i++) {
			         // check if element is mandatory; here mosReq=1
			         if (elements.item(i).getAttribute('mosReq') == 1) {
			           if (elements.item(i).value == '') {
			             //alert(elements.item(i).getAttribute('mosLabel') + ':' + elements.item(i).getAttribute('mosReq'));
			             // add up all error messages
			             errorMSG += elements.item(i).getAttribute('mosLabel') + ' <?php echo _UE_REQUIRED_ERROR; ?>\n';
			             // notify user by changing background color, in this case to red
			             elements.item(i).style.background = "red";
			             iserror=1;
			           }
			         }
			       }
			      }
			if(iserror==1) { alert(errorMSG); }
			else { 
				document.EditUser.submit(); 
			}

		}
	</script>
<!-- TAB -->

<?php
	// Rodax Software
	/*<table cellspacing="0" cellpadding="4" border="0" width="100%">
	<tr>
		<td class="componentheading" colspan="6"><?php echo _UE_EDIT_TITLE; ?></td>
	</tr>
	</table>   
	*/
	echo "<div class='componentheading'>";
	echo _UE_EDIT_TITLE;
	echo "</div>";
?>

<?php                       
global $my,$avatar,$avatar_name,$mosConfig_absolute_path,$newAvatar;

	// Rodax Software
	//	$row->load( $uid );
	if(!$_REQUEST['user']) 	{
		$uid = $my->id;
	} else {
		$uid = $_REQUEST['user'];
	}

$do='';
$do= mosGetParam( $_REQUEST, 'do', 'init' );

if ($do=='init'){
   if($ueConfig['allowAvatarUpload']){
         echo "<span class='contentheading'>"._UE_UPLOAD_SUBMIT."</span><br><br>";
         echo _UE_UPLOAD_DIMENSIONS.": ".$ueConfig['avatarWidth']."x".$ueConfig['avatarHeight']." - ".$ueConfig['avatarSize']." KB";
         echo "<form action='".sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&do=validate")."' method='post' name='adminForm' enctype='multipart/form-data'>";
         echo "<input type='hidden' value='do' text='validate'>";
         echo "<table width='100%' border='0' cellpadding='4' cellspacing='2'>";
         echo "<tr align='center' valign='middle'><td align='center' valign='top'>";

          $uplabel=_UE_UPLOAD_UPLOAD;
          //echo " <input type='hidden' name='MAX_FILE_SIZE' value='".$maxAllowed."' />";
          echo _UE_UPLOAD_SELECT_FILE." <input type='file' class='button' name='avatar' value='' />";
          echo "<input type='submit' class='button' value='"._UE_UPLOAD_UPLOAD."' />";
          echo "</td></tr></table><br/><br/>";
          echo "</form>";
     }

     if($ueConfig['allowAvatarGallery']){
          echo "<span class='contentheading'>"._UE_UPLOAD_GALLERY."</span><br><br>";
          echo "<table width='100%' border='0' cellpadding='4' cellspacing='2'>";
          echo "<form action='".sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&do=fromgallery&Itemid=".$Itemid)."' method='post' name='adminForm'>";
          echo "<tr align='center' valign='middle'>";
          echo '<td colspan="5">&nbsp;</td></tr>';
          echo "<tr align='center' valign='middle'>";
          $avatar_gallery_path='images/comprofiler/gallery';
          $avatar_images=array();
          $avatar_images=display_avatar_gallery($avatar_gallery_path);
          for($i = 0; $i < count($avatar_images); $i++) {
             $j=$i+1;
             echo '<td>';
             echo '<img src="images/comprofiler/gallery/'. $avatar_images[$i].'">';
             echo '<input type="radio" name="newAvatar" value="gallery/'.$avatar_images[$i].'">';
             echo '</td>';
               if (function_exists('fmod')) {
                   if (!fmod(($j),5)){echo '</tr><tr align="center" valign="middle">';}
               } else {
                   if (!fmodReplace(($j),5)){echo '</tr><tr align="center" valign="middle">';}
               }

          }
          echo '</tr>';
          echo '<tr><td colspan="5" align="center"><input class="button"  type="submit" value="'._UE_UPLOAD_CHOOSE.'">';
          echo '</table>';
          echo "</form>";
       }

}else if ($do=='validate'){
   $filename = split("\.", $avatar_name);
   $avatarName=$filename[0];
   $avatarExt=$filename[1];
   $avatarSize=filesize($avatar);
   $isModerator=isModerator($my->id);

   if (empty($avatar)) {
    MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&Itemid=".$Itemid),_UE_UPLOAD_ERROR_EMPTY);
   }

   //check for allowed file type (jpeg, gif, png)
   if (!($imgtype = check_image_type(strtolower($avatarExt)))){
      MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&Itemid=".$Itemid),_UE_UPLOAD_ERROR_TYPE);
   }
   //check file name characteristics
   if (eregi("[^0-9a-zA-Z_]", $avatarExt)) {
     MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&Itemid=".$Itemid),_UE_UPLOAD_ERROR_NAME);
   }
   //check filesize
   $maxAvSize=$ueConfig['avatarSize']*1024;
   if (!check_filesize($avatar, $maxAvSize)) {
     MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&Itemid=".$Itemid),_UE_UPLOAD_ERROR_SIZE." (".$ueConfig['avatarSize']." KiloBytes)");
     return;
   }

   list($width, $height) = @getimagesize($avatar);
   $GDfuncList = get_extension_funcs('gd');
   if ( $width > $ueConfig['avatarWidth'] || $height > $ueConfig['avatarHeight']){
	if($ueConfig['autoImageResize']==1) {
	        if(!$GDfuncList) {
		     MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&Itemid=".$Itemid),_UE_UPLOAD_ERROR_GDNOTINSTALLED);
		     return;			
	         }
		if (!in_array('imagegd2',$GDfuncList)) {
		     	MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&Itemid=".$Itemid),_UE_UPLOAD_ERROR_GDNOTINSTALLED);	     
			return;	
		}
		$newPic = new resize( 'avatar', $ueConfig['avatarWidth'], $ueConfig['avatarHeight'] );
		if(!$newPic->saveTo(strtolower($my->id.".".$newPic->type),$mosConfig_absolute_path."/images/comprofiler/")) {
			MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&Itemid=".$Itemid),_UE_UPLOAD_ERROR_UPLOADFAILED);
			return;
		}
		@chmod ($mosConfig_absolute_path."/images/comprofiler/".strtolower($my->id.".".$newPic->type), 0755);
		$newFileName=strtolower($my->id.".".$newPic->type);
	} else {
	     MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&Itemid=".$Itemid),_UE_UPLOAD_ERROR_WIDTHHEIGHT." (".$ueConfig['avatarSize']." KiloBytes)");
	     return;	
	}
   } else {
	$newFileName=strtolower($uid.$imgtype);
	$newFile=$mosConfig_absolute_path."/images/comprofiler/$newFileName";
	if(!copy ($avatar, $newFile)) {
		MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&Itemid=".$Itemid),_UE_UPLOAD_ERROR_UPLOADFAILED);
		return;
	}
	@chmod ($newFile, 0644);
   }
   if($ueConfig['autoImageResize']==1) { 
        if(!$GDfuncList) {
	     MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&Itemid=".$Itemid),_UE_UPLOAD_ERROR_GDNOTINSTALLED);
	     return;			
         }
	if (!in_array('imagegd2',$GDfuncList)) {
	     	MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&Itemid=".$Itemid),_UE_UPLOAD_ERROR_GDNOTINSTALLED);	     
		return;	
	}
 	   $thumbail = new resize( 'avatar', $ueConfig['thumbWidth'], $ueConfig['thumbHeight'] );
	   	if(!$thumbail->saveTo(strtolower("TN".$uid.".".$thumbail->type),$mosConfig_absolute_path."/images/comprofiler/")) {
			MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&user=".$uid."&Itemid=".$Itemid),_UE_UPLOAD_ERROR_UPLOADFAILED);
			return;
		}
	   @chmod ($mosConfig_absolute_path."/images/comprofiler/".strtolower("TN".$uid.".".$thumbail->type), 0644);
	   unlink($avatar);
   }
   IF($ueConfig['avatarUploadApproval']==1 && $isModerator==0) {
	$database->setQuery( "SELECT name, email FROM #__users"
	."\n WHERE gid >='".$ueConfig['imageApproverGid']."' AND sendEmail='1'" );
	$rowAdmins = $database->loadObjectList();
	foreach ($rowAdmins AS $rowAdmin) {
		createEmail($row,'imageAdmin',$ueConfig,$rowAdmin);
	}
   	$database->setQuery("UPDATE #__comprofiler SET avatar='$newFileName', avatarapproved=0 WHERE id='$uid'");
   	$redMsg=_UE_UPLOAD_PEND_APPROVAL;
   } ELSE {
   	$database->setQuery("UPDATE #__comprofiler SET avatar='$newFileName', avatarapproved=1, lastupdatedate='".date('Y-m-d\TH:i:s')."' WHERE id='$uid'");
   	$redMsg=_UE_UPLOAD_SUCCESSFUL;
	}

   $database->query();

   mosRedirect (sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=".$uid),$redMsg);
   
   ?>
   <script language="javascript">
     setTimeout("location='index.php?option=com_comprofiler&Itemid=<?=$Itemid;?>&task=userProfile'",350000);
   </script>
   <?
}else if ($do=='fromgallery'){

   if($newAvatar==''){
      MOSredirect(sefRelToAbs("index.php?option=com_comprofiler&task=userAvatar&Itemid=".$Itemid),_UE_UPLOAD_ERROR_CHOOSE);
   }
   $database->setQuery("UPDATE #__comprofiler SET avatar='$newAvatar', avatarapproved=1, lastupdatedate='".date('Y-m-d\TH:i:s')."' WHERE id='$uid'");

   if(!$database->query()) {
      echo _UE_USER_PROFILE_NOT."<br/><br/>";
   }else {
      echo _UE_USER_PROFILE_UPDATED."<br/><br/>";
	mosRedirect (sefRelToAbs("index.php?option=com_comprofiler&Itemid=".$Itemid));
   }
   echo _UE_USER_RETURN_A." <a href=\"".sefRelToAbs("index.php?option=com_comprofiler&Itemid=".$Itemid."&task=userProfile")."\">"._UE_USER_RETURN_B."</a><br/><br/>";
   ?>
   <script language="javascript">
      setTimeout("location='index.php?option=com_comprofiler&Itemid=<?=$Itemid;?>&task=userProfile'",3500);
   </script>
   <?
}else if ($do=='deleteavatar') {
//	echo "<script> alert('$rowExtras->avatar'); </script>";
   	if(eregi("gallery/",$rowExtras->avatar)==false && is_file($mosConfig_absolute_path."/images/comprofiler/".$rowExtras->avatar)) {
		unlink($mosConfig_absolute_path."/images/comprofiler/".$rowExtras->avatar);
		if(is_file($mosConfig_absolute_path."/images/comprofiler/tn".$rowExtras->avatar)) unlink($mosConfig_absolute_path."/images/comprofiler/tn".$rowExtras->avatar);
	}
   	$database->setQuery("UPDATE  #__comprofiler SET avatar=null, avatarapproved=1, lastupdatedate='".date('Y-m-d\TH:i:s')."' WHERE id='$uid'");
  	$database->query();

	mosRedirect (sefRelToAbs("index.php?option=com_comprofiler&Itemid=".$Itemid));
}
	}


/******************************
List Functions
******************************/

	function usersList($row,$lfields,$lists,$listid,$cuerda)
	{
	global $database,$limitstart,$search,$mosConfig_sitename,$ueConfig,$_POST,$acl;
$search = $database->getEscaped(trim( strtolower( $search)));
$cuerdasearch = '&listCuerdas='. $cuerda;
$ue_base_url = "index.php?option=com_comprofiler&task=usersList&Itemid=".$_REQUEST['Itemid']."&listid=".$listid;	// Base URL string
$ue_profile_url = $ue_base_url."&task=userProfile&user=";
$adminimagesdir = "components/com_comprofiler/images/";

$allusergids=array();
$usergids=explode(",",$row->usergroupids);
foreach($usergids AS $usergid) {
	$allusergids[]=$usergid;
	if ($usergid==29 || $usergid==30) {
		$groupchildern=array();
		$groupchildren=$acl->get_group_children( $usergid, 'ARO','RECURSE' );
		$allusergids=array_merge($allusergids,$groupchildren);
	}
}
$usergids=implode(",",$allusergids);

// Total
$query = "SELECT count(u.id) FROM #__users u, #__comprofiler ue WHERE u.id=ue.id AND u.block !=1 AND ue.approved=1 AND ue.banned!=1 AND ue.confirmed=1 AND u.gid IN (".$usergids.")";
if ($cuerda!='')
    $query .= " AND ue.cuerda = '". $cuerda ."'";
$database->setQuery($query);
$total_results = $database->loadResult();

// Search total
$query = "SELECT count(u.id) FROM #__users u, #__comprofiler ue WHERE u.id=ue.id AND u.block !=1 AND ue.approved=1 AND ue.banned!=1 AND ue.confirmed=1 AND u.gid IN (".$usergids.")";
if ($cuerda!='')
    $query .= " AND ue.cuerda = '". $cuerda ."'";
if (isset($search) && $search != "") {
	$query .= " AND (u.name LIKE '%$search%' OR u.username LIKE '%$search%')";
}

if(!$database->setQuery($query)) print $database->getErrorMsg();
$total = $database->loadResult();

if (empty($limitstart)) $limitstart = 0;
$limit = $ueConfig['num_per_page'];
if ($limit > $total) {
	$limitstart = 0;
}

$search_query = "";

// Select query
if($row->sortfields!='') $orderby = " ORDER BY ".$row->sortfields;

$query = "SELECT * FROM #__users u, #__comprofiler ue WHERE u.id=ue.id AND u.block!=1 and ue.approved=1 AND ue.banned!=1 AND ue.confirmed=1 AND u.gid IN (".$usergids.")";
if ($cuerda!='')
    $query .= " AND ue.cuerda = '". $cuerda ."'";

if (isset($search) && $search != "") {
	$query .= " AND (u.name LIKE '%$search%' OR u.username LIKE '%$search%')";
	$search_query = "&search=".$search;
}
$query .= " ".$orderby;
$query .= " LIMIT $limitstart, $limit";

$database->setQuery($query);
$users = $database->loadObjectList();
//print $database->getquery();
?>

<script language="JavaScript">
<!--
function validate(){
	if ((document.ueform.search=="") || (document.ueform.search.value=="")) {
		alert('<?php echo _UE_SEARCH_ALERT; ?>');
		return false;
	} else {
		return true;
	}
}
//-->
</script>

  <table width="100%" cellpadding="4" cellspacing="0" border="0" align="center" class="contentpane">
  	<tr>
  	  <td colspan="2"><span class="componentheading"><?php echo $row->title; ?></span></td>
  	</tr>
  <tr>
  <form name="ueform" method="post" action="<?php echo $ue_base_url;?>&action=search" >
    <td valign="top" class="contentdescription" colspan=2>
       <?php echo $mosConfig_sitename . " " . _UE_HAS . " <b>" . $total_results . "</b> " . _UE_USERS."."; ?>
	</td>
</tr>
<tr>
	<td>
	<table class="contentpane">
		<tr>
			<td>
              			<input type="text" name="search" class="inputbox" size="15" maxlength="100"<?php if (isset($search)) echo " value=".$search; ?>>
              			<input type="image" src="<?php echo $adminimagesdir; ?>search.gif" alt="<?php echo _UE_SEARCH; ?>" border="0" align="top" style="border: 0px;">
			</td>
			<td align=right>
				<?php echo $lists['plists']; ?>
			</td>
		</tr>
	</table>
	</td>	
  </form>
  </tr>
  <tr>
    <td>
      <table class="contentpane">
        <tr>
    		<td><a href="<?php echo $ue_base_url; ?>" onclick="javascript:ueform.search.value=''"><?php echo _UE_LIST_ALL; ?></a></td>

    		<td align="right"><?php echo _UE_PAGE; ?>: <?php echo writePagesLinks($limitstart, $limit, $total, $ue_base_url,$search.$cuerdasearch); ?></td>
        </tr>
      </table>
      
      <table class="contentpane">
        <tr>
		<? 
			echo "<td class='headerlist'>".getLangDefinition($row->col1title)."</td>\n";
			if ($row->col2enabled) echo "<td class='headerlist'>".getLangDefinition($row->col2title)."</td>\n";
			if ($row->col3enabled) echo "<td class='headerlist'>".getLangDefinition($row->col3title)."</td>\n";
			if ($row->col4enabled) echo "<td class='headerlist'>".getLangDefinition($row->col4title)."</td>\n";
		?>		
        </tr>
<?php
	$i = 1;
	foreach($users as $user) {
		$evenodd = $i % 2;
		if ($evenodd == 0) {
			$class = "sectiontableentry1";
		} else {
			$class = "sectiontableentry2";
		}
		$nr=$i+$limitstart;
		//print $user->name; 
		if($ueConfig['allow_profilelink']==1) {
			$onclick = "onclick=\"javascript:window.location='".sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=".$user->id)."'\"";
			$style="style=\"cursor:hand;cursor:pointer;\"";
		}
		print "\t<tr class=\"$class\" ".$style." ".$onclick.">\n";
		//print $lfields;
		eval("\$str = \"$lfields\";");
		echo $str. "\n";
        print "\t</tr>\n";
        $i++;
	}
?>
        </table>	
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
    		<td>&nbsp;</td>
    		<td align="right"><?php echo _UE_PAGE; ?>: <?php echo writePagesLinks($limitstart, $limit, $total, $ue_base_url,$search.$cuerdasearch); ?></td>
        </tr>
      </table>
        <hr noshade size="1">
      </td>
    </tr>
  </TABLE>
<?php }



/******************************
Registration Functions
******************************/

	function confirmation() {
		?>
	<table>
		<tr>
			<td class="componentheading"><?php echo _UE_SUBMIT_SUCCESS; ?></td>
		</tr>
		<tr>
			<td><?php echo _UE_SUBMIT_SUCCESS_DESC; ?></td>
		</tr>
	</table>
<?php
	}
	function lostPassForm($option) {
//TODO: Add ability to change password on form.
		?>
<table cellpadding="4" cellspacing="0" border="0" width="98%" class="contentpane">
  <form action="index.php" method="post">
    <tr>
      <td colspan="2" class="componentheading"><?php echo _PROMPT_PASSWORD; ?></td>
    </tr>
    <tr>
      <td colspan="2"><?php echo _NEW_PASS_DESC; ?></td>
    </tr>
    <tr>
      <td><?php echo _PROMPT_UNAME; ?></td>
      <td><input type="text" name="checkusername" class="inputbox" size="40" maxlength="25" /></td>
    </tr>
    <tr>
      <td><?php echo _PROMPT_EMAIL; ?></td>
      <td><input type="text" name="confirmEmail" class="inputbox" size="40" /></td>
    </tr>
    <tr>
      <td colspan="2"> <input type="hidden" name="option" value="<?php echo $option;?>" />
        <input type="hidden" name="task" value="sendNewPass" /> <input type="submit" class="button" value="<?php echo _BUTTON_SEND_PASS; ?>" /></td>
    </tr>
  </form>
</table>
<?php
	}

	function registerForm($option, $emailpass, $rowFields, $rowFieldValues) {
	global $mosConfig_live_site,$mosConfig_useractivation,$ueConfig;
?>
<link rel="stylesheet" type="text/css" media="all" href="includes/js/calendar/calendar-mos.css" title="green" />
<!-- import the calendar script -->
<script type="text/javascript" src="includes/js/calendar/calendar.js"></script>
<!-- import the language module -->
<script type="text/javascript" src="includes/js/calendar/lang/calendar-en.js"></script>
<script language="Javascript" src="includes/js/dhtml.js"></script>
<script language="Javascript" src="includes/js/mambojavascript.js"></script>
<style>
.titleCell {
	font-weight:bold;
	width:85px;
}
</style>
<script language="javascript" type="text/javascript">
		function submitbutton() {
			var coll = document.mosForm;
			var r = new RegExp("[^0-9A-Za-z]", "i");
			var errorMSG = '';
			var iserror=0;
			if (r.exec(coll.username.value)) {
				errorMSG += "<?php printf( _VALID_AZ09, _PROMPT_UNAME, 6 );?>";
				iserror=1;
    <?php if ($emailpass!="1") { ?>
			} else if ((coll.password.value != "") && (coll.password.value != coll.password2.value)){
				errorMSG += "<?php echo _REGWARN_VPASS2;?>";
				iserror=1;
			} else if (r.exec(coll.password.value)) {
				errorMSG += "<?php printf( _VALID_AZ09, _REGISTER_PASS, 6 );?>";
				iserror=1;
    <?php } ?>
			}
    <?php if($ueConfig['reg_enable_toc']) { ?>
			if(!coll.acceptedterms.checked) {
				errorMSG += "<?php echo _UE_TOC_REQUIRED; ?>"+"\n";
				iserror=1;
			}
    <?php } ?>
		     if (coll != null) {
		       var elements = coll.elements;
			//elements += document.getElementsByTagName('textarea');
		       // loop through all input elements in form
		       for (var i=0; i < elements.length; i++) {
		         // check if element is mandatory; here mosReq=1
		         if (elements.item(i).getAttribute('mosReq') == 1) {
		           if (elements.item(i).value == '') {
		             //alert(elements.item(i).getAttribute('mosLabel') + ':' + elements.item(i).getAttribute('mosReq'));
		             // add up all error messages
		             errorMSG += elements.item(i).getAttribute('mosLabel') + ' <?php echo _UE_REQUIRED_ERROR; ?>\n';
		             // notify user by changing background color, in this case to red
		             elements.item(i).style.background = "red";
		             iserror=1;
		           }
		         }
		       }
		      }
			if(iserror==1) { alert(errorMSG); }
			else { 
				coll.submit(); 
			}
		}
		function showCalendar2(id,dFormat) {
			var el = document.getElementById(id);
			if (calendar != null) {
				// we already have one created, so just update it.
				calendar.hide();		// hide the existing calendar
				calendar.parseDate(el.value); // set it to a new date
			} else {
				// first-time call, create the calendar
				var cal = new Calendar(true, null, selected, closeHandler);
				calendar = cal;		// remember the calendar in the global
				cal.setRange(1900, 2070);	// min/max year allowed
				cal.dateFormat = dFormat;
				calendar.create();		// create a popup calendar
			}
			calendar.sel = el;		// inform it about the input field in use
			calendar.showAtElement(el);	// show the calendar next to the input field
		
			// catch mousedown on the document
			Calendar.addEvent(document, "mousedown", checkCalendar);
			return false;
		}
	</script>
<?php
$ptabs='';
$pfields='';
$poldtab='';
$t=2;
for($i=0, $n=count( $rowFields ); $i < $n; $i++) {
	if($rowFields[$i]->table=='#__users') $dArray ='$row->';
	else $dArray ='$rowExtras->';
	$poldtab=$rowFields[$i]->tab;

	$pfields .= "\t\t<tr>";
	$pfields .= "\t\t\t<td class=\"titleCell\">". getLangDefinition($rowFields[$i]->title) .":</td>";
	eval("\$oValue = \"".$dArray.$rowFields[$i]->name."\";");
	$pfields .= "\t\t\t<td>".getFieldEntry($rowFields[$i]->type,$rowFields[$i]->name,$oValue,$rowFields[$i]->required,$rowFields[$i]->title,$rowFields[$i]->id,$rowFields[$i]->size, $rowFields[$i]->maxlength, $rowFields[$i]->cols, $rowFields[$i]->rows,$rowFields[$i]->profile,$rowFieldValues['lst_'.$rowFields[$i]->name],$rowFields[$i]->readonly)."</td>\n";

}
	$pfields .= "\t\t</tr>";
	$pfields = addslashes($pfields);
	//eval("\$pfields = \"$pfields\";");
	$pfields = stripslashes($pfields);
?>

<table cellpadding="5" cellspacing="0" border="0" width="98%" class="contentpane">

  <form action="index.php" method="POST" name="mosForm">

    <tr>
      <td colspan="2" width="100%" class="componentheading"><?php echo _REGISTER_TITLE; ?></td>
    </tr>

<?php
	SWITCH($ueConfig['name_style']) {
		case 2:
?>
		<tr>
			<td class="titleCell">First Name:</td>
			<td><input class="inputbox" type="text" size="40" mosReq=1 mosLabel="<?php echo _UE_YOUR_FNAME; ?>" name="firstname" value="<?php echo $rowExtras->firstname;?>" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['name_format']!=3) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
		<tr>
			<td class="titleCell">Last Name:</td>
			<td><input class="inputbox" type="text" size="40" mosReq=1 mosLabel="<?php echo _UE_YOUR_LNAME; ?>" name="lastname" value="<?php echo $rowExtras->lastname;?>" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['name_format']!=3) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
<?php
		break;
		case 3:
?>
		<tr>
			<td class="titleCell">First Name:</td>
			<td><input class="inputbox" type="text" size="40" mosReq=1 mosLabel="<?php echo _UE_YOUR_FNAME; ?>" name="firstname" value="<?php echo $rowExtras->firstname;?>" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['name_format']!=3) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
		<tr>
			<td class="titleCell">Middle Name:</td>
			<td><input class="inputbox" type="text" size="40" mosReq=0 mosLabel="<?php echo _UE_YOUR_MNAME; ?>" name="middlename" value="<?php echo $rowExtras->middlename;?>" /><?php IF($ueConfig['name_format']!=3) echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
		<tr>
			<td class="titleCell">Last Name:</td>
			<td><input class="inputbox" type="text" size="40" mosReq=1 mosLabel="<?php echo _UE_YOUR_LNAME; ?>" name="lastname" value="<?php echo $rowExtras->lastname;?>" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['name_format']!=3) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
<?php
		break;
		DEFAULT:
?>
		<tr>
			<td class="titleCell">Name:</td>
			<td><input class="inputbox" type="text" size="40" name="name" mosReq=1 mosLabel="Name"  value="<?php echo $row->name;?>" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['name_format']!=3) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
		</tr>
<?php 		
		break;
	} 
?>

    <tr>

      <td class="titleCell"><?php echo _REGISTER_UNAME; ?></td>
      <td><input type="text" name="username" mosReq="1" mosLabel="<?php echo _REGISTER_UNAME; ?>"  size="40" value="" class="inputbox" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['name_format']!=1) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />"; ?></td>
    <tr>

      <td class="titleCell"><?php echo _REGISTER_EMAIL; ?></td>
      <td><input type="text" name="email" mosReq="1" mosLabel="<?php echo _REGISTER_EMAIL; ?>" size="40" value="" class="inputbox" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "; IF($ueConfig['allow_email_display']==1 || $ueConfig['allow_email_display']==2) echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />"; ELSE echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />";  ?></td>
    </tr>

    <?php if ($emailpass=="0" || isset($mosConfig_useractivation)) { ?>

    <tr>

      <td class="titleCell"><?php echo _REGISTER_PASS; ?></td>
      <td><input class="inputbox" type="password" name="password" size="40" value="" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' />"; ?></td>
    </tr>

    <tr>

      <td class="titleCell"><?php echo _REGISTER_VPASS; ?></td>
      <td><input class="inputbox" type="password" name="password2" size="40" value="" /><?php echo " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' />"; ?></td>
    </tr>

    <?php } else { ?>

    <tr>

      <td colspan="2"><?php echo _SENDING_PASSWORD; ?></td>
      <input type="hidden" name="password" value="" />
      <input type="hidden" name="password2" value="" />

	</tr>

    <?php } 
	print stripslashes($pfields); 
if($ueConfig['reg_enable_toc']) {
	echo "<tr>\n";
      	echo "<td>&nbsp;</td>\n<td colspan='2'><input type=checkbox name='acceptedterms' value=1 mosReq=1 mosLabel='"._UE_TOC."' /><a href='".$ueConfig['reg_toc_url']."' target='_BLANK'> "._UE_TOC."</a></td>\n";
	echo "</tr>\n";
}
	?>

    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>

    <tr>

      <td colspan=2>
  <input type="hidden" name="id" value="0" />
  <input type="hidden" name="gid" value="0" />
  <input type="hidden" name="emailpass" value="<?php echo $emailpass;?>" />
  <input type="hidden" name="option" value="<?php echo $option; ?>" />
  <input type="hidden" name="task" value="saveRegistration" />
  <input type="button" value="<?php echo _BUTTON_SEND_REG; ?>" class="button" onclick="submitbutton()" />
  </form></td>
		</tr>
</table>
<div style="align:center;">
<?php
echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' /> "._UE_FIELDREQUIRED." | ";
echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' /> "._UE_FIELDONPROFILE." | ";		
echo "<img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' /> "._UE_FIELDNOPROFILE;
?>
</div>
<?php
	}


/******************************
Moderation Functions
******************************/

	function reportUserForm($option,$uid)
	{
	global $database,$ueConfig,$my;
	if($ueConfig['allowUserReports']==0) {
			echo _UE_FUNCTIONALITY_DISABLED;
			return;
	}
?> 
<script>
		function submitbutton() {
			var coll = document.userReport;
			var errorMSG = '';
			var iserror=0;
			if (coll!=null) {
			    for (i=0; i<coll.elements.length; i++)
				if(coll.elements.item(i).mosReq==1) {
					if(coll.elements.item(i).value=='') {
			        	//alert(coll.elements.item(i).mosLabel + ':' + coll.item(i).mosReq);
					errorMSG += coll.item(i).mosLabel + ' <?php echo _UE_REQUIRED_ERROR; ?>\n';
					iserror=1;
					}
					if(coll.elements.item(i).mosLength > 0) {
						if(coll.elements.item(i).value.length > coll.elements.item(i).mosLength) {
							errorMSG += coll.item(i).mosLabel + ' <?php echo _UE_LENGTH_ERROR; ?>\n';
							iserror=1;					
						}
					}
				}
			}
			if(iserror==1) { alert(errorMSG); }
			else { 
				coll.submit(); 
			}
		}

</script>

<!-- TAB -->
<table cellspacing="0" cellpadding="4" border="0" width="100%">
	<tr>
		<td class="componentheading" colspan="6"><?php echo _UE_REPORTUSER_TITLE; ?></td>
	</tr>
</table>   
<table width='100%' border='0' cellpadding='4' cellspacing='2'>
<form action='index.php?option=com_comprofiler&task=reportUser' method='post' name='userReport'>
<tr align='center' valign='middle'>
	<td colspan="4">&nbsp;</td>
</tr>
<tr align='center' valign='middle'>
<br /><br />
<?php echo _UE_REPORTUSERSACTIVITY; ?><br />
<textarea maxlenght=4000 align=center mosReq=1 mosLabel='User Report' cols=50 rows=10 name=reportexplaination></textarea>
<br /><br ?>
</tr>
<tr><td colspan="4" align="center">
<input class="button" onclick="submitbutton();" type="button" value="<?php echo _UE_SUBMITFORM; ?>">
</table>
<input type=hidden name="reportedbyuser" value="<?php echo $my->id; ?>">
<input type=hidden name="reporteduser" value="<?php echo $uid; ?>">
<input type=hidden name="reportform" value="0">
</form>
<?php

}
	function banUserForm($option,$uid,$act,$orgbannedreason)
	{
	global $database,$ueConfig,$my;
	if($ueConfig['allowUserBanning']==0) {
			echo _UE_FUNCTIONALITY_DISABLED;
			return;
	}
?> 
<script>
		function submitbutton() {
			var coll = document.userReport;
			var errorMSG = '';
			var iserror=0;
			if (coll!=null) {
			    for (i=0; i<coll.elements.length; i++)
				if(coll.elements.item(i).mosReq==1) {
					if(coll.elements.item(i).value=='') {
			        	//alert(coll.elements.item(i).mosLabel + ':' + coll.item(i).mosReq);
					errorMSG += coll.item(i).mosLabel + ' <?php echo _UE_REQUIRED_ERROR; ?>\n';
					iserror=1;
					}
					if(coll.elements.item(i).mosLength > 0) {
						if(coll.elements.item(i).value.length > coll.elements.item(i).mosLength) {
							errorMSG += coll.item(i).mosLabel + ' <?php echo _UE_LENGTH_ERROR; ?>\n';
							iserror=1;					
						}
					}
				}
			}
			if(iserror==1) { alert(errorMSG); }
			else { 
				coll.submit(); 
			}
		}

</script>

<!-- TAB -->
<table cellspacing="0" cellpadding="4" border="0" width="100%">
	<tr>
		<td class="componentheading" colspan="6"><?php if($my->id != $uid) echo _UE_REPORTBAN_TITLE; ELSE echo _UE_REPORTUNBAN_TITLE;; ?></td>
	</tr>
</table>   
<table width='100%' border='0' cellpadding='4' cellspacing='2'>
<form action='index.php?option=com_comprofiler&task=banProfile&act=<?php if($my->id != $uid) echo 1; ELSE echo 2; ?>' method='post' name='userReport'>
<tr align='center' valign='middle'>
	<td colspan="4">&nbsp;</td>
</tr>
<tr align='center' valign='middle'>
<br /><br />
<?php if($my->id != $uid) echo _UE_BANREASON; ELSE echo _UE_UNBANREQUEST; ?><br />
<textarea maxlenght=4000 align=center mosReq=1 mosLabel='<?php if($my->id != $uid) echo _UE_BANREASON; ELSE echo _UE_UNBANREQUEST; ?>' cols=50 rows=10 name=bannedreason></textarea>
<br /><br ?>
</tr>
<tr><td colspan="4" align="center">
<input class="button" onclick="submitbutton();" type="button" value="<?php echo _UE_SUBMITFORM; ?>">
</table>
<input type=hidden name="bannedby" value="<?php echo $my->id; ?>">
<input type=hidden name="uid" value="<?php echo $uid; ?>">
<input type=hidden name="orgbannedreason" value="<?php echo $orgbannedreason; ?>">
<input type=hidden name="reportform" value="0">
</form>
<?php
}

function pendingApprovalUsers($option,$users) {
	global $ueConfig,$limitstart,$my;

	// Rodax Software
	/*<table cellspacing="0" cellpadding="0" border="0" width="100%">
		<tr>
		<td class="componentheading" colspan="6"><?php echo _UE_MODERATE_TITLE; ?></td>
		</tr>
		</table>   
		<br />                    */
	echo "<div class='componentheading'>";
	echo _UE_MODERATE_TITLE;
	echo "</div>";
?>
		<span class='contentheading'><?php echo _UE_USERAPPROVAL_MODERATE; ?></span><br><br>
          <form action='index.php?option=com_comprofiler&task=processReports' method='post' name='userAdmin'>
          <table width='100%' border='0' cellpadding='4' cellspacing='2'>
		<thead>
		<th>&nbsp;</th>
		<th><?php echo _UE_USER; ?></th>
		<th><?php echo _UE_EMAIL; ?></th>
		<th><?php echo _UE_REGISTERDATE; ?></th>
		<th><?php echo _UE_COMMENT; ?></th>
		</thead>	
<?php  
          for($i = 0; $i < count($users); $i++) {
             $j=$i+1;
	     echo "<tr align='center' valign='middle'>";
             echo "<td><input id='".$users[$i]->id."' type=\"checkbox\" CHECKED name=\"uids[]\" value=\"".$users[$i]->id."\"></td>";
             echo "<td><a href='".sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=".$users[$i]->id)."'>".getNameFormat($users[$i]->name,$users[$i]->username,$ueConfig['name_format']). "</a></td>";
	     echo "<td>".$users[$i]->email."</td>";
	     echo "<td>".dateConverter($users[$i]->registerDate,'Y-m-d',$ueConfig['date_format'])."</td>";
	     echo "<td><textarea name='comment".$users[$i]->id."' cols=20 rows=3></textarea></td>";
	     echo "</tr>";
          }
          echo "<input type=hidden name=task value='' />";
          echo "<input type=hidden name=option value=".$option." />";
          echo '<tr align="center" valign="middle"><td colspan=5><input class="button" onclick="userAdmin.task.value=\'approveUser\';userAdmin.submit();" type="button" value="'._UE_APPROVE.'"><input class="button" onclick="userAdmin.task.value=\'rejectUser\';userAdmin.submit();" type="button" value="'._UE_REJECT.'"></td></tr>';
          echo '</table>';
          echo "</form>";
}

}

	function moderateBans($option)
	{
	global $database,$ueConfig,$limitstart,$my;
	$isModerator=isModerator($my->id);
	if ($isModerator == 0) {
		mosNotAuth();
		return;
	}
$ue_base_url = "index.php?option=com_comprofiler&task=moderateBans";	// Base URL string


$query = "SELECT count(*) FROM #__comprofiler WHERE banned=2";
if(!$database->setQuery($query)) print $database->getErrorMsg();
$total = $database->loadResult();

if($total<1) {
	echo _UE_NOUNBANREQUESTS;
	return;
}

if (empty($limitstart)) $limitstart = 0;
$limit = 20;
if ($limit > $total) {
	$limitstart = 0;
}

	$query = "SELECT u2.name AS bannedbyname, u2.username as bannedbyusername, u.name as bannedname, u.username as bannedusername, c.* FROM #__users u, #__comprofiler c, #__users u2 WHERE u.id=c.id AND c.bannedby=u2.id AND c.banned=2 AND u.id!='".$my->id."'";
	$query .= " LIMIT $limitstart, $limit";
	$database->setQuery($query);
	$row = $database->loadObjectList();
?> 
<style>
.titleCell {
	font-weight:bold;
	width:85px;
}
</style>
<script>

function process() {
	imageAdmin.submit();
}


</script>

<!-- TAB -->
<table cellspacing="0" cellpadding="4" border="0" width="100%">
	<tr>
		<td class="componentheading" colspan="6"><?php echo _UE_MODERATE_TITLE; ?></td>
	</tr>
</table>   
                    
<span class='contentheading'><?php echo _UE_UNBAN_MODERATE; ?></span><br><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td align="right"><?php echo _UE_PAGE; ?>: <?php echo writePagesLinks($limitstart, $limit, $total, $ue_base_url); ?></td>
</tr>
</table>
          <form action='index.php?option=com_comprofiler&task=processReports' method='post' name='imageAdmin'>
          <table width='100%' border='0' cellpadding='4' cellspacing='2'>
		<thead>
		<th><?php echo _UE_BANNEDUSER; ?></th>
		<th><?php echo _UE_BANNEDREASON; ?></th>
		<th><?php echo _UE_BANNEDON; ?></th>
		<th><?php echo _UE_BANNEDBY; ?></th>
		</thead>	
<?php  
          for($i = 0; $i < count($row); $i++) {
             $j=$i+1;
	     echo "<tr align='center' valign='middle'>";
             echo "<td><a href='".sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=".$row[$i]->id)."'>".getNameFormat($row[$i]->bannedname,$row[$i]->bannedusername,$ueConfig['name_format']). "</a></td>";
	     echo "<td>".nl2br($row[$i]->bannedreason)."</td>";  
	     echo "<td>".dateConverter($row[$i]->banneddate,'Y-m-d',$ueConfig['date_format'])."</td>";
             echo "<td><a href='".sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=".$row[$i]->bannedby)."'>".getNameFormat($row[$i]->bannedbyname,$row[$i]->bannedbyusername,$ueConfig['name_format']). "</a></td>";           
	     echo '</tr>';
          }
          echo '</table>';
          echo "</form>";
       }


	function moderateReports($option)
	{
	global $database,$ueConfig,$limitstart,$my;
	$isModerator=isModerator($my->id);
	if ($isModerator == 0) {
		mosNotAuth();
		return;
	}
$ue_base_url = "index.php?option=com_comprofiler&task=moderateReports";	// Base URL string


$query = "SELECT count(*) FROM #__comprofiler_userreports  WHERE reportedstatus=0 ";
if(!$database->setQuery($query)) print $database->getErrorMsg();
$total = $database->loadResult();

if($total<1) {
	echo _UE_NONEWUSERREPORTS;
	return;
}

if (empty($limitstart)) $limitstart = 0;
$limit = 20;
if ($limit > $total) {
	$limitstart = 0;
}

	$query = "SELECT u2.name as reportedbyname, u2.username as reportedbyusername, u.name as reportedname, u.username as reportedusername, ur.* FROM #__users u, #__comprofiler_userreports ur, #__users u2 WHERE u.id=ur.reporteduser AND u2.id=ur.reportedbyuser AND  ur.reportedstatus=0 ORDER BY ur.reporteduser,ur.reportedondate";
	$query .= " LIMIT $limitstart, $limit";
	$database->setQuery($query);
	$row = $database->loadObjectList();
?> 
<style>
.titleCell {
	font-weight:bold;
	width:85px;
}
</style>
<script>

function process() {
	imageAdmin.submit();
}


</script>

<!-- TAB -->
<table cellspacing="0" cellpadding="4" border="0" width="100%">
	<tr>
		<td class="componentheading" colspan="6"><?php echo _UE_MODERATE_TITLE; ?></td>
	</tr>
</table>   
                    
<span class='contentheading'><?php echo _UE_USERREPORT_MODERATE; ?></span><br><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td align="right"><?php echo _UE_PAGE; ?>: <?php echo writePagesLinks($limitstart, $limit, $total, $ue_base_url); ?></td>
</tr>
</table>
          <form action='index.php?option=com_comprofiler&task=processReports' method='post' name='imageAdmin'>
          <table width='100%' border='0' cellpadding='4' cellspacing='2'>
		<thead>
		<th>&nbsp;</th>
		<th><?php echo _UE_REPORTEDUSER; ?></th>
		<th><?php echo _UE_REPORT; ?></th>
		<th><?php echo _UE_REPORTEDONDATE; ?></th>
		<th><?php echo _UE_REPORTEDBY; ?></th>	
		</thead>	
<?php  
          for($i = 0; $i < count($row); $i++) {
             $j=$i+1;
	     echo "<tr align='center' valign='middle'>";
             echo "<td><input id='img".$row[$i]->reportid."' type=\"checkbox\" CHECKED name=\"reports[]\" value=\"".$row[$i]->reportid."\"></td>";
             echo "<td><a href='".sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=".$row[$i]->reporteduser)."'>".getNameFormat($row[$i]->reportedname,$row[$i]->reportedusername,$ueConfig['name_format']). "</a></td>";
	     echo "<td>".$row[$i]->reportexplaination."</td>";  
	     echo "<td>".dateConverter($row[$i]->reportedondate,'Y-m-d',$ueConfig['date_format'])."</td>";
             echo "<td><a href='".sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=".$row[$i]->reportedbyuser)."'>".getNameFormat($row[$i]->reportedbyname,$row[$i]->reportedbyusername,$ueConfig['name_format']). "</a></td>";           
	     echo '</tr>';
          }
          
          echo '<tr align="center" valign="middle"><td colspan=5><input class="button" onclick="javascript:process();" type="button" value="'._UE_PROCESSUSERREPORT.'"></td></tr>';
          echo '</table>';
          echo "</form>";
       }



	function moderateImages($option)
	{
	global $database,$ueConfig,$limitstart,$my;
	$isModerator=isModerator($my->id);
	if ($isModerator == 0) {
		mosNotAuth();
		return;
	}
$ue_base_url = "index.php?option=com_comprofiler&task=moderateImages";	// Base URL string


$query = "SELECT count(*) FROM #__comprofiler  WHERE avatarapproved=0";
if(!$database->setQuery($query)) print $database->getErrorMsg();
$total = $database->loadResult();

if($total<1) {
	echo _UE_NOIMAGESTOAPPROVE;
	return;
}

if (empty($limitstart)) $limitstart = 0;
$limit = 20;
if ($limit > $total) {
	$limitstart = 0;
}

	$query = "SELECT * FROM #__comprofiler c, #__users u WHERE u.id= c.id AND c.avatarapproved=0";
	$query .= " LIMIT $limitstart, $limit";
	$database->setQuery($query);
	$row = $database->loadObjectList();
?> 
<style>
.titleCell {
	font-weight:bold;
	width:85px;
}
</style>
<script>
function approve() {
	//imageAdmin.action='index.php?option=com_comprofiler&task=approveImage';
	imageAdmin.act.value='1';
	imageAdmin.submit();
}
function reject() {
	//imageAdmin.action='index.php?option=com_comprofiler&task=approveImage';
	imageAdmin.act.value='0';
	imageAdmin.submit();
}


</script>

<!-- TAB -->
<table cellspacing="0" cellpadding="4" border="0" width="100%">
	<tr>
		<td class="componentheading" colspan="6"><?php echo _UE_MODERATE_TITLE; ?></td>
	</tr>
</table>   
                    
<span class='contentheading'><?php echo _UE_IMAGE_MODERATE; ?></span><br><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td align="right"><?php echo _UE_PAGE; ?>: <?php echo writePagesLinks($limitstart, $limit, $total, $ue_base_url); ?></td>
</tr>
</table>
<?php  
          echo "<table width='100%' border='0' cellpadding='4' cellspacing='2'>";
          echo "<form action='index.php?option=com_comprofiler&task=approveImage' method='post' name='imageAdmin'>";
          echo "<tr align='center' valign='middle'>";
          echo '<td colspan="4">&nbsp;</td></tr>';
          echo "<tr align='center' valign='middle'>";
          $avatar_gallery_path='images/comprofiler/';
          $sys_gallery_path='components/com_comprofiler/images/';
          for($i = 0; $i < count($row); $i++) {
             $j=$i+1;
		if($ueConfig['autoImageResize']==1) $image=$avatar_gallery_path.'tn'.$row[$i]->avatar;
		else $image=$avatar_gallery_path.$row[$i]->avatar;
             echo '<td>';
             echo '<img style="cursor:hand;" src="'.$image.'" onclick="this.src=\''.$avatar_gallery_path.$row[$i]->avatar.'\'" /><br />';
             echo "<label for='img".$row[$i]->id."'>".getNameFormat($row[$i]->name,$row[$i]->username,$ueConfig['name_format']). " <input id='img".$row[$i]->id."' type=\"checkbox\" CHECKED name=\"avatar[]\" value=\"".$row[$i]->id."\"></label>";
	     echo "<br /><img style='cursor:hand;' onclick='javascript:window.location=\"".sefRelToAbs("index.php?option=com_comprofiler&task=approveImage&flag=1&avatars=".$row[$i]->id)."\"' src='".$sys_gallery_path."approve.png' title='Approval Image'> <img style='cursor:hand;' src='".$sys_gallery_path."reject.png' onclick='javascript:window.location=\"".sefRelToAbs("index.php?option=com_comprofiler&task=approveImage&flag=0&avatars=".$row[$i]->id)."\"' title='Reject Image'> <img style='cursor:hand;' src='".$sys_gallery_path."updateprofile.gif' title='View Profile' onclick='javascript:window.location=\"".sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=".$row[$i]->id)."\"'> <img style='cursor:hand;' src='".$sys_gallery_path."ban.png' title='Ban Profile'>";
             echo '</td>';
               if (function_exists('fmod')) {
                   if (!fmod(($j),4)){echo '</tr><tr align="center" valign="middle">';}
               } else {
                   if (!fmodReplace(($j),4)){echo '</tr><tr align="center" valign="middle">';}
               }

          }
          echo '</tr>';
          echo '<tr><td colspan="4" align="center"><input class="button" onclick="javascript:approve();" type="button" value="'._UE_APPROVE_IMAGES.'"><input class="button" onclick="javascript:reject();" type="button" value="'._UE_REJECT_IMAGES.'">';
          echo '</table>';
	  echo '<input type=hidden name="act" value="">';
          echo "</form>";
       }


	function viewReports($option,$uid)
	{
	global $database,$ueConfig,$limitstart,$my;
	$isModerator=isModerator($my->id);
	if ($isModerator == 0) {
		mosNotAuth();
		return;
	}
$ue_base_url = "index.php?option=com_comprofiler&task=viewReports";	// Base URL string


$query = "SELECT count(*) FROM #__comprofiler_userreports  WHERE reportedstatus=0 AND reporteduser='".$uid."'";
if(!$database->setQuery($query)) print $database->getErrorMsg();
$total = $database->loadResult();


if (empty($limitstart)) $limitstart = 0;
$limit = 20;
if ($limit > $total) {
	$limitstart = 0;
}

	$query = "SELECT u2.name as reportedbyname, u2.username as reportedbyusername, u.name as reportedname, u.username as reportedusername, ur.* FROM #__users u, #__comprofiler_userreports ur, #__users u2 WHERE u.id=ur.reporteduser AND u2.id=ur.reportedbyuser AND  ur.reportedstatus=0 AND ur.reporteduser='".$uid."' ORDER BY ur.reporteduser,ur.reportedondate";
	$query .= " LIMIT $limitstart, $limit";
	$database->setQuery($query);
	$row = $database->loadObjectList();
?> 
<style>
.titleCell {
	font-weight:bold;
	width:85px;
}
</style>

<!-- TAB -->
<table cellspacing="0" cellpadding="4" border="0" width="100%">
	<tr>
		<td class="componentheading" colspan="6"><?php echo _UE_MODERATE_TITLE; ?></td>
	</tr>
</table>   
                    
<span class='contentheading'><?php echo _UE_USERREPORT; ?></span><br><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td align="right"><?php echo _UE_PAGE; ?>: <?php echo writePagesLinks($limitstart, $limit, $total, $ue_base_url); ?></td>
</tr>
</table>
          <table width='100%' border='0' cellpadding='4' cellspacing='2'>
		<thead>
		<th><?php echo _UE_REPORTEDUSER; ?></th>
		<th><?php echo _UE_REPORT; ?></th>
		<th><?php echo _UE_REPORTEDONDATE; ?></th>
		<th><?php echo _UE_REPORTEDBY; ?></th>	
		</thead>	
<?php  
          for($i = 0; $i < count($row); $i++) {
             $j=$i+1;
	     echo "<tr align='center' valign='middle'>";
             echo "<td><a href='".sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=".$row[$i]->reporteduser)."'>".getNameFormat($row[$i]->reportedname,$row[$i]->reportedusername,$ueConfig['name_format']). "</a></td>";
	     echo "<td>".$row[$i]->reportexplaination."</td>";  
	     echo "<td>".dateConverter($row[$i]->reportedondate,'Y-m-d',$ueConfig['date_format'])."</td>";
             echo "<td><a href='".sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=".$row[$i]->reportedbyuser)."'>".getNameFormat($row[$i]->reportedbyname,$row[$i]->reportedbyusername,$ueConfig['name_format']). "</a></td>";           
	     echo '</tr>';
          }          
          echo '</table>';
       }

?>