Ejemplo n.º 1
0
function reportUser($option,$form=1,$uid=0) {
	global $_CB_framework, $_CB_database, $ueConfig, $Itemid, $_POST;

	if($ueConfig['allowUserReports']==0) {
			echo _UE_FUNCTIONALITY_DISABLED;
			exit();
	}
	if (!allowAccess( $ueConfig['allow_profileviewbyGID'],'RECURSE', userGID( $_CB_framework->myId() ))) {
		echo _UE_NOT_AUTHORIZED;
		return;
	}
	if($form==1) {
		HTML_comprofiler::reportUserForm($option,$uid);
	} else {
		// simple spoof check security
		cbSpoofCheck( 'reportUserForm' );

		$row = new moscomprofilerUserReport( $_CB_database );

		if (!$row->bind( $_POST )) {
			cbRedirect( cbSef("index.php?option=$option&task=reportUser".($Itemid ? "&Itemid=". (int) $Itemid : ""), false ), $row->getError(), 'error' );
			return;
		}

		_cbMakeHtmlSafe($row);			//TBD: remove this: not urgent but isn't right

		$row->reportedondate = date("Y-m-d H:i:s");

		if (!$row->check()) {
			cbRedirect( cbSef("index.php?option=$option&task=reportUser".($Itemid ? "&Itemid=". (int) $Itemid : ""), false ), $row->getError(), 'error' );
			return;
		}

		if (!$row->store()) {
			cbRedirect( cbSef("index.php?option=$option&task=reportUser".($Itemid ? "&Itemid=". (int) $Itemid : ""), false ), $row->getError(), 'error' );
			return;
		}
		if($ueConfig['moderatorEmail']==1) {
			$cbNotification = new cbNotification();
			$cbNotification->sendToModerators(_UE_USERREPORT_SUB,_UE_USERREPORT_MSG);
		}
		echo _UE_USERREPORT_SUCCESSFUL;
	}
}
/**
 * Deletes a user without any check or warning
 *
 * @param int $id userid
 * @param string $condition php condition string on $user e.g. "return (\$user->block == 1);"
 * @param string $inComprofilerOnly deletes user only in CB, not in Mambo/Joomla
 * @return mixed : "" if user deleted and found ok, null if user not found, false if condition was not met, string error in case of error raised by plugin
 */
function cbDeleteUser($id, $condition = null, $inComprofilerOnly = false)
{
    global $_CB_framework, $_CB_database, $_PLUGINS;
    $msg = null;
    $obj2 = new moscomprofiler($_CB_database);
    $query = "SELECT * FROM #__comprofiler c LEFT JOIN #__users u ON c.id = u.id WHERE c.id = " . (int) $id;
    $_CB_database->setQuery($query);
    $user = $_CB_database->loadObjectList();
    if ($_CB_database->getErrorNum() || count($user) == 0) {
        $query = "SELECT * FROM #__users u LEFT JOIN #__comprofiler c ON c.id = u.id WHERE u.id = " . (int) $id;
        $_CB_database->setQuery($query);
        $user = $_CB_database->loadObjectList();
    }
    if (!$_CB_database->getErrorNum() && count($user) > 0) {
        $user = $user[0];
        if ($condition == null || eval($condition)) {
            $_PLUGINS->loadPluginGroup('user');
            $_PLUGINS->trigger('onBeforeDeleteUser', array($user));
            if ($_PLUGINS->is_errors()) {
                $msg = $_PLUGINS->getErrorMSG();
            } else {
                deleteAvatar($user->avatar);
                $reports = new moscomprofilerUserReport($_CB_database);
                $reports->deleteUserReports($user->id);
                _cbdeleteUserViews($user->id);
                if (!$inComprofilerOnly) {
                    $obj =& $_CB_framework->_getCmsUserObject($id);
                    $obj->delete($id);
                    $msg .= $obj->getError();
                }
                $obj2->delete($id);
                $msg .= $obj2->getError();
                // delete user acounts active sessions
                $query = "DELETE FROM #__session" . "\n WHERE userid = " . (int) $id;
                $_CB_database->setQuery($query);
                $_CB_database->query();
                $_PLUGINS->trigger('onAfterDeleteUser', array($user, true));
            }
        } else {
            $msg = false;
        }
    }
    return $msg;
}