<?php
/**
 * @package linea21.core
 * @subpackage admin
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

function SQL_Get_UserInfo4Auth($login, $pass) {
  $q = "SELECT U.user_id, U.user_last_con, R.*, P.profile_firstname, P.profile_lastname  FROM " . T_USER . " AS U LEFT OUTER JOIN " . T_RIGHT . " AS R ON U.user_rights =R.rights_id LEFT OUTER JOIN " . T_PROFILE . " AS P ON  U.user_profile=P.profile_id WHERE lower(user_login) = '".strtolower($login)."' AND user_password='".$pass."' AND user_validity='Y';";
  return $q;
}

function SQL_Get_isWorkgroupUser($id) {
  $q = "SELECT user_id ,  jwu_workshop_id FROM " . T_USER . " As U LEFT OUTER JOIN " . J_WORK_USERS . " As W ON U.user_id=W.jwu_user_id WHERE user_id='".$id."' AND user_validity='Y';";
  return $q;
}

function SQL_Get_isWorkgroupOrganiser($id) {
	$q = "SELECT user_id ,  jwu_workshop_id FROM " . T_USER . " As U LEFT OUTER JOIN " . J_WORK_USERS . " As W ON U.user_id=W.jwu_user_id WHERE user_id='".$id."' AND user_validity='Y' AND jwu_user_right='O';";
	return $q;
}

function SQL_get_UserInfo($login) {
  $q = "SELECT U.user_id, U.user_login, P.profile_email FROM " . T_USER . " AS U LEFT OUTER JOIN " . T_PROFILE . " AS P ON  U.user_profile=P.profile_id WHERE lower(user_login) = '".strtolower($login)."' AND user_validity='Y';";
  return $q;
}

function SQL_get_UserInfoPK($passkey) {
  $q = "SELECT U.user_id, U.user_login, P.profile_email FROM " . T_USER . " AS U LEFT OUTER JOIN " . T_PROFILE . " AS P ON  U.user_profile=P.profile_id WHERE user_forget_passkey = '".$passkey."' AND user_validity='Y';";
  return $q;
}

function SQL_Get_UserWorkshop($login, $pass) {
	$query = "SELECT user_id ,  jwu_workshop_id FROM " . T_USER . " As U LEFT OUTER JOIN " . J_WORK_USERS . " As W ON U.user_id=W.jwu_user_id WHERE lower(user_login) = '".strtolower($login)."' AND user_password='".$pass."' AND user_validity='Y';";
	return $query;
}

?>