";
}
function approveUser($option,$uids) {
global $database,$ueConfig,$_POST,$my,$mosConfig_emailpass;
$isModerator=isModerator($my->id);
if($ueConfig['allowModUserApproval']==0) {
echo _UE_FUNCTIONALITY_DISABLED;
exit();
}
if ($isModerator!=1){
mosNotAuth();
return;
}
if($mosConfig_emailpass!=1) $mosConfig_emailpass=0;
foreach($uids AS $uid) {
$sql="UPDATE #__comprofiler SET approved='1'WHERE id='".cbGetEscaped($uid)."'";
$database->SetQuery($sql);
$database->query();
//sv0.6232 aprovel-block-combination
$sql="UPDATE #__users SET block='0' WHERE id='".cbGetEscaped($uid)."' AND block='1'";
$database->SetQuery($sql);
$database->query();
$database->setQuery( "SELECT name, username, email FROM #__users"
."\n WHERE id='$uid'" );
$rows = $database->loadObjectList();
foreach ($rows AS $row) {
createEmail($row,'welcome',$ueConfig,null,$mosConfig_emailpass);
}
$comment="";
if(ISSET($_POST[$comment])) $comment=$_POST[$comment];
}
if (!isset($_REQUEST['Itemid'])) {
if ($GLOBALS['Itemid_com']!='') {
$Itemid_c = $GLOBALS['Itemid_com'];
} else {
$Itemid_c = '';
}
} else {
$Itemid_c = "&Itemid=".$_REQUEST['Itemid'];
}
mosRedirect(sefRelToAbs('index.php?option=com_comprofiler'.$Itemid_c.'&task=pendingApprovalUser'),_UE_USERAPPROVAL_SUCCESSFUL);
}
function rejectUser($option,&$uids) {
global $database,$ueConfig,$_POST,$my,$mosConfig_emailpass;
$isModerator=isModerator($my->id);
if($ueConfig['allowModUserApproval']==0) {
echo _UE_FUNCTIONALITY_DISABLED;
exit();
}
if ($isModerator!=1){
mosNotAuth();
return;
}
if($mosConfig_emailpass!=1) $mosConfig_emailpass=0;
foreach($uids AS $uid) {
$sql="UPDATE #__comprofiler SET approved='2'WHERE id='".cbGetEscaped($uid)."'";
$database->SetQuery($sql);
$database->query();
$database->setQuery( "SELECT name, username, email FROM #__users"
."\n WHERE id='$uid'" );
$rows = $database->loadObjectList();
foreach ($rows AS $row) {
createEmail($row,'rejectUser',$ueConfig,$_POST['comment'.$uid],$mosConfig_emailpass);
}
}
if (!isset($_REQUEST['Itemid'])) {
if ($GLOBALS['Itemid_com']!='') {
$Itemid_c = $GLOBALS['Itemid_com'];
} else {
$Itemid_c = '';
}
} else {
$Itemid_c = "&Itemid=".$_REQUEST['Itemid'];
}
mosRedirect(sefRelToAbs('index.php?option=com_comprofiler'.$Itemid_c.'&task=pendingApprovalUser'),_UE_USERREJECT_SUCCESSFUL);
}
function pendingApprovalUsers($option) {
global $database,$ueConfig,$_POST,$my,$mosConfig_emailpass;
$isModerator=isModerator($my->id);
if($ueConfig['allowModUserApproval']==0) {
echo _UE_FUNCTIONALITY_DISABLED;
exit();
}
if ($isModerator!=1){
mosNotAuth();
return;
}
if($mosConfig_emailpass!=1) $mosConfig_emailpass=0;
$database->setQuery( "SELECT u.id, u.name, u.username, u.email, u.registerDate "
."\n FROM #__users u, #__comprofiler c "
."\n WHERE u.id=c.id AND c.approved=0 AND c.confirmed=1" );
$rows = $database->loadObjectList();
HTML_comprofiler::pendingApprovalUsers($option, $rows);
}
function cbsearch( $option, $uid, $submitvalue)
{
global $database,$my,$ueConfig,$enhanced_Config,$acl;
if (!allowAccess( $ueConfig['allow_listviewbyGID'],'RECURSE', userGID($my->id), $acl, '1'))
{
echo _UE_NOT_AUTHORIZED;
return;
}
$whereadd = '';
$prefix = 'ue.';
$query = '';
$sform='';
if (isset($_POST['adminForm']))
{
$database->setQuery( "SELECT f.fieldid, f.name AS name, f.title, f.type, t.range AS range FROM #__comprofiler_fields AS f, #__comprofiler_searchmanager AS t WHERE f.published=1 AND f.fieldid = t.fieldid");
$valids = $database->loadObjectList();
foreach ($valids as $valid)
{
if (($valid->type)=="select" || ($valid->type)=="radio")
{
if (($valid->range)==1)
{
// range = 1
$from = $valid->name."from";
$to = $valid->name."to";
if ( !empty($_POST[($from)]) && !empty($_POST[($to)]) )
{
// neither empty
// patched 14-03-05
$afrom = $database->getEscaped($_POST[($from)]);
$ato = $database->getEscaped($_POST[($to)]);
if ($afrom>$ato)
{
list($afrom, $ato) = array($ato, $afrom);
}
$query .= "AND " . $prefix . ($valid->name) . " BETWEEN '" . $afrom . "' AND '" . $ato . "' ";
}
elseif ( ( empty($_POST[($from)]) && !empty($_POST[($to)]) ) OR ( !empty($_POST[($from)]) && empty($_POST[($to)]) ) )
{
// either one empty, not valid when range = 1
echo _UE_QUERY_NOT_VALID;
return;
}
}
elseif (!empty($_POST[($valid->name)]))
{
// range = 0, only one variable
// patched 14-03-05
$query .= "AND " . $prefix . ($valid->name) . "='" . $database->getEscaped($_POST[($valid->name)]) . "' ";
}
} // end type=select and radio
if (($valid->type)=="checkbox")
{
if (!empty($_POST[($valid->name)]))
{
$query .= "AND " . $prefix . ($valid->name) . "= 1 ";
}
} // end type=checkbox
if (($valid->type)=="text" || ($valid->type)=="textarea" || ($valid->type)=="editorta" || ($valid->type)=="webaddress")
{
// range text
if (($valid->range)==1)
{
// range = 1
$from = $valid->name."from";
$to = $valid->name."to";
if ( !empty($_POST[($from)]) && !empty($_POST[($to)]) )
{
// neither empty
// patched 14-03-05
$afrom = $database->getEscaped($_POST[($from)]);
$ato = $database->getEscaped($_POST[($to)]);
if ($afrom>$ato)
{
list($afrom, $ato) = array($ato, $afrom);
}
$query .= "AND " . $prefix . ($valid->name) . " BETWEEN '" . $afrom . "' AND '" . $ato . "' ";
}
elseif ( ( empty($_POST[($from)]) && !empty($_POST[($to)]) ) OR ( !empty($_POST[($from)]) && empty($_POST[($to)]) ) )
{
// either one empty, not valid when range = 1
echo _UE_QUERY_NOT_VALID;
return;
}
} else {
// range END
if (!empty($_POST[($valid->name)]))
{
$escaped = $database->getEscaped(trim( strtolower( $_POST[($valid->name)] )));
$query .= "AND " . $prefix . ($valid->name) . " LIKE '%$escaped%'";
}
// range close
} // close
} // end type=text, textarea or editorta
// PK edit PREDEFINED
if (($valid->type)=="predefined")
{
if (!empty($_POST[($valid->name)]))
{
$escaped = $database->getEscaped(trim( strtolower( $_POST[($valid->name)] )));
$query .= "AND " . "u." . ($valid->name) . " LIKE '%$escaped%'";
}
} // end type=predefined
// PK MultiSelect
if (($valid->type)=="multiselect")
{
if (!empty($_POST[($valid->name)]) && is_array($_POST[($valid->name)])) {
$query .= "AND ( ";
$mcount = count($_POST[($valid->name)]);
$multi_sarray = $_POST[($valid->name)];
$i=0;
for ($i; $i<$mcount; $i++) {
// $ms_value = $database->getEscaped(trim( strtolower( $multi_sarray[$i] )));
$ms_value = $multi_sarray[$i];
if ($i==0) {
$query .= $prefix.($valid->name)." LIKE '%".$ms_value."%'";
} else {
$query .= " OR ".$prefix.($valid->name)." LIKE '%".$ms_value."%'";
}
}
$query .= ")";
}
} // end multiselect
// PK MultiCheckbox
if (($valid->type)=="multicheckbox")
{
if (!empty($_POST[($valid->name)]) && is_array($_POST[($valid->name)])) {
$query .= "AND ( ";
$mcount = count($_POST[($valid->name)]);
$multi_sarray = $_POST[($valid->name)];
$i=0;
for ($i; $i<$mcount; $i++) {
// $mc_value = $database->getEscaped(trim( strtolower( $multi_sarray[$i] )));
$mc_value = $multi_sarray[$i];
if ($i==0) {
$query .= $prefix.($valid->name)." LIKE '%".$mc_value."%'";
} else {
$query .= " OR ".$prefix.($valid->name)." LIKE '%".$mc_value."%'";
}
}
$query .= ")";
}
} // end type=multicheckbox
// PK Date (Age & Birthday only)
if (($valid->type)=="date")
{
if ($valid->name == $enhanced_Config['lastvisitors_birthday_field']) {
if (($valid->range)==1)
{
// range = 1
$from = $valid->name."from";
$to = $valid->name."to";
if ( !empty($_POST[($from)]) && !empty($_POST[($to)]) )
{
$this_year = date('Y');
$search_age_from = $database->getEscaped($_POST[($from)]);
$search_age_to = $database->getEscaped($_POST[($to)]);
if ($search_age_from < $search_age_to) {
list($search_age_from, $search_age_to) = array($search_age_to, $search_age_from);
}
if ($enhanced_Config['search_age_common_style']=='1') {
$search_year_from = $this_year - 1 - $search_age_from."-01-01";
//$search_year_to = $this_year - 1 - $search_age_to."-12-31";
$search_year_to = $this_year - $search_age_to."-12-31";
} else {
$search_year_from = $this_year - $search_age_from."-01-01";
$search_year_to = $this_year - $search_age_to."-12-31";
}
$query .= "AND " . $prefix . ($valid->name) . " BETWEEN '" . $search_year_from . "' AND '" . $search_year_to . "' ";
}
elseif ( ( empty($_POST[($from)]) && !empty($_POST[($to)]) ) OR ( !empty($_POST[($from)]) && empty($_POST[($to)]) ) )
{
// either one empty, not valid when range = 1
echo _UE_QUERY_NOT_VALID;
return;
}
} else {
//no range
if (!empty($_POST[($valid->name)])) {
$search_age = $_POST[($valid->name)];
$this_year = date('Y');
//if ($enhanced_Config['search_age_common_style']=='1') {
// $search_year = $this_year - 1 - $search_age;
//} else {
$search_year = $this_year - $search_age;
//}
$query .= "AND ".$prefix.($valid->name)." LIKE '".$search_year."%'";
}
}
}
} // end type=date age/birthday
if (($valid->type)=="numericfloat" || ($valid->type)=="numericint") {
if (($valid->range)==1)
{
// range = 1
$from = $valid->name."from";
$to = $valid->name."to";
if ( !empty($_POST[($from)]) && !empty($_POST[($to)]) )
{
$_from = str_replace(',','.',$_POST[($from)]);
$_to = str_replace(',','.',$_POST[($to)]);
$afrom = floatval($database->getEscaped($_from));
$ato = floatval($database->getEscaped($_to));
if ($afrom>$ato) {
list($afrom, $ato) = array($ato, $afrom);
}
$query .= "AND " . $prefix . ($valid->name) . " BETWEEN '" . $afrom . "' AND '" . $ato . "' ";
}
elseif ( ( empty($_POST[($from)]) && !empty($_POST[($to)]) ) OR ( !empty($_POST[($from)]) && empty($_POST[($to)]) ) )
{
// either one empty, not valid when range = 1
echo _UE_QUERY_NOT_VALID;
return;
}
} else {
if (!empty($_POST[($valid->name)])) {
$_escaped = str_replace(',','.',$_POST[($valid->name)]);
$escaped = floatval($database->getEscaped(trim(strtolower($_escaped))));
$query .= "AND " . $prefix . ($valid->name) . " LIKE '$escaped'";
}
} // close
} // end type=nummericint, nummericfloat
}
// end of run-thru of parameters
// now do hidden form to be posted to cbsearchlist
// in order to process the query
if (!isset($_REQUEST['Itemid'])) {
if ($GLOBALS['Itemid_com']!='') {
$Itemid_c = $GLOBALS['Itemid_com'];
} else {
$Itemid_c = '';
}
} else {
$Itemid_c = "&Itemid=".$_REQUEST['Itemid'];
}
$hidecbform ='';
$hidecbform .= '
';
$hidecbform .= '
';
$hidecbform .= '';
// when submitted, query is $_POST'ed to cbsearchlist for further processing
echo $hidecbform;
} // end isset($_POST('AdminForm'))
else
{
// generate the search form
// will be submitted to HTML_comprofiler::cbsearch
// which then reposts it back to this function
// and captured above
for ($g=0; $g<=1; $g++) {
if ($g<1) {
$whereadd = "\n AND t.simple = '1'";
} else {
$whereadd = "\n AND t.advanced = '1'";
}
$database->setQuery( "SELECT f.fieldid, f.name, f.title, f.type, t.range FROM #__comprofiler_fields AS f, #__comprofiler_searchmanager AS t" . "\n WHERE f.published=1"
. "\n AND f.fieldid = t.fieldid"
.$whereadd
. "\n ORDER BY t.ordering" );
$rowFields[$g] = $database->loadObjectList();
foreach ( $rowFields[$g] as $rowField )
{
$fieldid = $rowField->fieldid;
$name = $rowField->name;
$title = getLangDefinition($rowField->title);
$type = $rowField->type;
$rangeflag = $rowField->range;
switch ($type)
{
case "checkbox":
{
$sform[$g] .= '
';
$sform[$g] .= $title.' ';
$sform[$g] .= '
';
$sform[$g] .= '';
$sform[$g] .= '
';
}
break;
// PK MultiCheckbox start
case "multicheckbox":
{
$database->setQuery( "SELECT fieldtitle FROM #__comprofiler_field_values"
. "\n WHERE fieldid = ".$database->getEscaped($fieldid)
. "\n ORDER BY ordering" );
$Values = $database->loadObjectList();
if ( $Values ) {
$options = "
";
$sform[$g] .= '';
}
}
break;
// PK MultiCheckbox end
case "select":
case "radio":
{
// patched 14-03-05
$database->setQuery( "SELECT fieldtitle FROM #__comprofiler_field_values"
. "\n WHERE fieldid = ".$database->getEscaped($fieldid)
. "\n ORDER BY ordering" );
$Values = $database->loadObjectList();
$options='';
if ( $Values ) {
// first create $options because it is common regardless of t.range
$options .= "