Subversion Repositories ALCASAR

Rev

Rev 325 | Rev 1805 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
325 richard 1
<?php
2
require_once('../lib/functions.php');
3
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
4
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
5
else{
6
	echo "<b>Could not include SQL library</b><br>\n";
7
	exit();
8
}
9
if ($config[sql_use_operators] == 'true'){
10
	include("../lib/operators.php");
11
	$text = ',op';
12
	$passwd_op = ",':='";
13
}
14
$da_abort=0;
15
$op_val2 = '';
16
$link = @da_sql_pconnect($config);
17
if ($link){
18
	$Members = preg_split("/[\n\s]+/",$members,-1,PREG_SPLIT_NO_EMPTY);
19
	if (!empty($Members)){
20
		foreach ($Members as $member){
21
			$member = da_sql_escape_string($member);
22
			$res = @da_sql_query($link,$config,
23
			"INSERT INTO $config[sql_usergroup_table] (username,groupname)
24
			VALUES ('$member','$login');");
25
			if (!$res || !@da_sql_affected_rows($link,$res,$config)){
26
				echo "<b>Unable to add user $member in group $login: " . da_sql_error($link,$config) . "</b><br>\n";
27
				$da_abort=1;
28
			}
29
		}
30
	}
31
	else
32
		{
33
		$res = @da_sql_query($link,$config,
34
			"INSERT INTO $config[sql_usergroup_table] (username,groupname)
35
			VALUES ('$login','$login');");
36
			if (!$res || !@da_sql_affected_rows($link,$res,$config))
37
				{
38
				echo "<b>Unable to add user $member in group $login: " . da_sql_error($link,$config) . "</b><br>\n";
39
				$da_abort=1;
40
				}
41
			else
42
				{
43
				echo "<b>Un groupe ne pouvant &ecirc;tre vide, l'usager '$login' a &eacute;t&eacute; cr&eacute;&eacute; (usager virtuel)<br>";
44
				}
45
		}
46
	if (!$da_abort)
47
		{
48
		foreach($show_attrs as $key => $attr){
49
			if ($attrmap["$key"] == 'none')
50
				continue;
1377 richard 51
			if ($key == "Filter-Id" && $$attrmap["$key"] == "None")
52
				continue;
325 richard 53
			if ($attrmap["$key"] == ''){
54
				$attrmap["$key"] = $key;
55
				$attr_type["$key"] = 'replyItem';
56
				$rev_attrmap["$key"] = $key;
57
			}
58
			if ($attr_type["$key"] == 'checkItem'){
59
				$table = "$config[sql_groupcheck_table]";
60
				$type = 1;
61
			}
62
			else if ($attr_type["$key"] == 'replyItem'){
63
				$table = "$config[sql_groupreply_table]";
64
				$type = 2;
65
			}
66
			$val = $$attrmap["$key"];
67
			$val = da_sql_escape_string($val);
68
			$op_name = $attrmap["$key"] . '_op';
69
			$op_val = $$op_name;
70
			if ($op_val != ''){
71
				$op_val = da_sql_escape_string($op_val);
72
				if (check_operator($op_val,$type) == -1){
73
					echo "<b>Invalid operator ($op_val) for attribute $key</b><br>\n";
74
					coninue;
75
				}
76
				$op_val2 = ",'$op_val'";
77
			}
78
			if ($val == '' || check_defaults($val,$op_val,$default_vals["$key"]))
79
				continue;
80
			$res = @da_sql_query($link,$config,
81
			"INSERT INTO $table (attribute,value,groupname $text)
82
			VALUES ('$attrmap[$key]','$val','$login' $op_val2);");
83
			if (!$res || !@da_sql_affected_rows($link,$res,$config))
84
				echo "<b>Query failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
85
		}
86
		echo "<b>Le groupe $login a &eacute;t&eacute; correctement cr&eacute;&eacute;</b><br>\n";
87
	}
88
}
89
else
90
	echo "<b>Could not connect to SQL database</b><br>\n";
91
?>