* @copyright Deakin University 2007,2008 * @package queXS * @subpackage admin * @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 * * * @todo Make timezone a drop down list * */ /** * Configuration file */ include ("../config.inc.php"); /** * Database file */ include ("../db.inc.php"); /** * Authentication file */ require ("auth-admin.php"); /** * XHTML functions */ include ("../functions/functions.xhtml.php"); global $db; $a = false; $client =""; $firstname="";$lastname="";$email=""; $time_zone_name=""; if (isset($_POST['client']) && !empty($_POST['client'])) { $client = $db->qstr($_POST['client'],get_magic_quotes_gpc()); $firstname = $db->qstr($_POST['firstname'],get_magic_quotes_gpc()); $email = $db->qstr($_POST['email'],get_magic_quotes_gpc()); $lastname = $db->qstr($_POST['lastname'],get_magic_quotes_gpc()); $time_zone_name = $db->qstr($_POST['Time_zone_name'],get_magic_quotes_gpc()); /* check if there'a record with this username*/ $sql = "SELECT `username`,`client_id` from client WHERE `username` LIKE $client"; $rs = $db->GetAll($sql); if (isset($_GET['edit']) && $_GET['edit'] >0 ) { $clid = intval($_GET['edit']); $uid = intval($_POST['uid']); } if (empty($rs) || count($rs)==1 && $rs[0]['client_id'] == $clid){ // update client if (isset($_GET['edit']) && $_GET['edit'] >0 ) { $sql = "UPDATE `client` SET `username`= $client,`firstName` = $firstname,`lastName` = $lastname,`Time_zone_name` = $time_zone_name WHERE `client_id` = $clid "; if ($db->Execute($sql)) { $sql = "UPDATE " . LIME_PREFIX . "users SET `users_name` = $client, `full_name` = $firstname, `email` = $email"; /* rewrite 'password' only if not blank in edit mode */ if (isset($_GET['edit']) && $_GET['edit'] >0 && isset($_POST['password']) && !empty($_POST['password'])) { include_once("../include/limesurvey/admin/classes/core/sha256.php"); $sql .=",`password` = '" . SHA256::hashing($_POST['password']) . "'"; } $sql .= "WHERE `uid` = $uid"; if ($db->Execute($sql)) $a = T_("Updated") . ": " . $client; else $a = T_("Update error"); } else $a = T_("Could not update") . " " . $client; } else { //save as a new client $sql = "INSERT INTO client (`client_id` ,`username` ,`firstName` ,`lastName`, `Time_zone_name`) VALUES (NULL , $client, $firstname , $lastname, $time_zone_name);"; if ($db->Execute($sql)) { include_once("../include/limesurvey/admin/classes/core/sha256.php"); //Insert into lime_users $sql = "INSERT INTO " . LIME_PREFIX . "users (`users_name`,`password`,`full_name`,`parent_id`,`superadmin`,`email`,`lang`) VALUES ($client, '" . SHA256::hashing($_POST['password']) . "', $firstname ,1,0,$email,'auto')"; if ($db->Execute($sql)) $a = T_("Added") . ": " . $client; else $a = T_("Error adding client"); } else $a = T_("Could not add") . " " . $client; } } else $a = T_("Username") . " " . $client . ". " . T_("is already in use"); $client =""; $firstname="";$lastname="";$email=""; $time_zone_name=""; unset($_POST['client'],$_POST['password'],$_POST['lastname'],$_POST['firstname'],$_POST['email'],$_POST['Time_zone_name']); } $header = T_("Add a client"); $sbut = T_("Add new client"); $req = "required"; if (isset($_GET['edit']) && $_GET['edit'] >0 ) { $header = T_("Edit client data"); $clid = intval($_GET['edit']); $sql = "SELECT client.*, u.email, u.uid from client, " . LIME_PREFIX . "users as u WHERE client_id=$clid and u.users_name=username"; $cdata = $db->GetRow($sql); if (!$cdata) { unset($_GET['edit']); die(T_("NO such client")); } else{ $uid = $cdata['uid']; $client = $cdata['username']; $firstname= $cdata['firstName']; $lastname= $cdata['lastName']; $email= $cdata['email']; $time_zone_name = $cdata['Time_zone_name']; $sbut = T_("Update client data"); $req = ""; } } xhtml_head($header,true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css")); $sql = "SELECT Time_zone_name as value, Time_zone_name as description FROM timezone_template"; $tzs = $db->GetAll($sql); if ($a) { ?>
0 ){ echo " " . T_("You can assign a client to a particular project with"). " "; ?> "; } ?>