Commit 464db64d authored by Francesco Iannuzzelli's avatar Francesco Iannuzzelli

#34 Internal user groups

parent 8cb4cf14
......@@ -111,6 +111,7 @@ if ($from=="user_admin")
$login = $post['login'];
$password = $post['password'];
$admin_notes = $post['admin_notes'];
$id_group = (int)$post['id_group'];
$active = $fh->Checkbox2Bool($post['active']);
$verified = $fh->Checkbox2Bool($post['verified']);
$start_date = $fh->Strings2Date($post['start_date_d'],$post['start_date_m'],$post['start_date_y']);
......@@ -126,14 +127,14 @@ if ($from=="user_admin")
}
else
{
$id_user = $u->UserInsert( $name,$email,$login,$password,$active,$admin_notes,$id_language,$start_date );
$id_user = $u->UserInsert( $name,$email,$login,$password,$active,$admin_notes,$id_language,$start_date,$id_group );
$url = "user.php?id=$id_user";
}
}
if ($action=="update")
{
$u->id = $id_user;
$u->UserUpdateByAdmin( $login,$active,$admin_notes,$id_language,$super_right,$start_date,$verified );
$u->UserUpdateByAdmin( $login,$active,$admin_notes,$id_language,$super_right,$start_date,$verified,$id_group );
}
if ($action=="reminder")
{
......
......@@ -190,7 +190,7 @@ $("#form1").validate({
}
echo $hh->input_text("login","login",$row['login'],20,0,$input_super_right,"",true);
if ($id>0)
if ($id>0)
echo $hh->input_text("password","pass","******",20,0,0,($id==$ah->current_user_id || $input_super_right==1)? " (<a href=\"user_password.php?id=".$id."\">" . $hh->tr->Translate("password_change") . "</a>)" : "",true);
else
{
......@@ -201,6 +201,7 @@ $("#form1").validate({
echo $hh->input_textarea("user_notes","admin_notes",$row['admin_notes'],20,4,"",$input_super_right);
echo $hh->input_array("language","id_language",$id_language,$ah->Languages(),$input_right);
echo $hh->input_array("group","id_group",$row['id_group'],$hh->tr->Translate("users_groups"),$input_right);
echo $hh->input_checkbox("active","active",$active,0,$input_super_right);
......
......@@ -59,7 +59,7 @@ define('PHPEACE_VERSION',"2.6.32");
* PhPeace Database version number (integer)
* Increased by 1 for each DB schema change
*/
define('PHPEACE_DB_VERSION',270);
define('PHPEACE_DB_VERSION',271);
/* ##################################### */
......
......@@ -126,7 +126,10 @@ class PhPeaceUpdates
{
switch($version_new)
{
case "305":
case "311":
$this->UpdateDB("271");
break;
case "305":
$this->UpdateDB("270");
break;
case "304":
......@@ -479,7 +482,10 @@ class PhPeaceUpdates
$dbconf = $conf->Get("dbconf");
switch($db_version)
{
case "270":
case "271":
$db->ColumnAdd("users","id_group","SMALLINT(3)","0");
break;
case "270":
$db->ColumnAdd("translations","id_rev","SMALLINT(4)","0");
$db->ColumnAdd("translations","id_ad","SMALLINT(4)","0");
break;
......
......@@ -719,7 +719,7 @@ class User
$db =& Db::globaldb();
$db->query_single( $user, "SELECT name,phone,mobile,email,email_visible,signature,active,user_show,login,
id_geo,notes,admin_notes,id_language,connections,UNIX_TIMESTAMP(start_date) AS start_date_ts,id_p,
UNIX_TIMESTAMP(last_conn) AS last_conn_ts,id_tutor,verified,bounces,photo_visible
UNIX_TIMESTAMP(last_conn) AS last_conn_ts,id_tutor,verified,bounces,photo_visible,id_group
FROM users u INNER JOIN user_notes USING(id_user) WHERE u.id_user='$this->id'");
return $user;
}
......@@ -735,7 +735,7 @@ class User
return $user;
}
public function UserInsert( $name,$email,$login,$password,$active,$admin_notes,$id_language,$start_date="" )
public function UserInsert( $name,$email,$login,$password,$active,$admin_notes,$id_language,$start_date="",$id_group=0 )
{
$id_tutor = (int)($this->id);
$email = trim($email);
......@@ -754,8 +754,8 @@ class User
$db->begin();
$db->lock( "users" );
$this->id = $db->nextId( "users", "id_user" );
$sqlstr = "INSERT INTO users (id_user,name,login,password,email,active,admin_notes,id_language,start_date,id_tutor)
VALUES ($this->id,'$name','$login','$cpassword','$email',$active,'$admin_notes',$id_language,'$start_date',$id_tutor)";
$sqlstr = "INSERT INTO users (id_user,name,login,password,email,active,admin_notes,id_language,start_date,id_tutor,id_group)
VALUES ($this->id,'$name','$login','$cpassword','$email',$active,'$admin_notes',$id_language,'$start_date',$id_tutor,$id_group)";
$res[] = $db->query( $sqlstr );
$db->lock( "user_notes" );
$res[] = $db->query("INSERT INTO user_notes (id_user,signature,notes) VALUES ($this->id,'','')");
......@@ -846,13 +846,13 @@ class User
Db::finish( $res, $db);
}
public function UserUpdateByAdmin( $login,$active,$admin_notes,$id_language,$super_right,$start_date,$verified )
public function UserUpdateByAdmin( $login,$active,$admin_notes,$id_language,$super_right,$start_date,$verified,$id_group )
{
include_once(SERVER_ROOT."/../classes/session.php");
$session = new Session();
$this->LoginUnique($login,$this->id);
if ($super_right=="1")
$cond = ",admin_notes='$admin_notes',start_date='$start_date',verified='$verified'";
$cond = ",admin_notes='$admin_notes',start_date='$start_date',verified='$verified',id_group='$id_group'";
$db =& Db::globaldb();
$db->begin();
$db->lock( "users" );
......
......@@ -3218,6 +3218,7 @@ CREATE TABLE `users` (
`department` varchar(50) NOT NULL DEFAULT '',
`job_position` varchar(50) NOT NULL DEFAULT '',
`photo_visible` tinyint(1) NOT NULL DEFAULT '0',
`id_group` smallint(3) NOT NULL DEFAULT '0',
PRIMARY KEY (`id_user`)
);
/*!40101 SET character_set_client = @saved_cs_client */;
......
......@@ -1036,6 +1036,7 @@ user_stats = Stats
used_in = Currently used in
users = Users
users_available = List of available users in domain <em>%s</em>. Click on the user you want to add.
users_groups = { -- | Editors | Translators | Trainees | Guests }
users_list = Users' list
users_message = Send a message to all the users
username = username
......
......@@ -1037,6 +1037,7 @@ username = username
used_in = Usato in
users = Utenti
users_available = Elenco utenti disponibili nel dominio <em>%s</em>. Clicca sull'utente che vuoi aggiungere.
users_groups = { -- | Redazione | Traduzioni | Apprendisti | Ospiti }
users_list = Elenco utenti
users_message = Invia messaggio a tutti gli utenti
verify = Verifica
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment