inc/users.inc.php
changeset 85 1687c1b107fa
parent 83 90fbb34b3d97
child 89 61c49e66c9b0
--- a/inc/users.inc.php	Wed Mar 26 08:32:24 2008 +0000
+++ b/inc/users.inc.php	Wed Mar 26 09:06:58 2008 +0000
@@ -568,6 +568,34 @@
 }
 
 
+// Add a permission template.
+
+function add_perm_templ($details) {
+	global $db;
+
+	// Fix permission template name and description first. 
+
+	$query = "INSERT INTO perm_templ 
+			VALUES (
+				'', " 
+				. $db->quote($details['templ_name']) . ", " 
+				. $db->quote($details['templ_descr']) . ")";
+
+	$result = $db->query($query);
+	if (PEAR::isError($response)) { error($response->getMessage()); return false; }
+
+	$perm_templ_id = $db->lastInsertId('perm_templ', 'id');
+
+	foreach ($details['perm_id'] AS $perm_id) {
+		$r_insert_values[] = "(''," . $db->quote($perm_templ_id) . "," . $db->quote($perm_id) . ")";
+	}
+	$query = "INSERT INTO perm_templ_items VALUES " . implode(',', $r_insert_values) ;
+	$result = $db->query($query);
+	if (pear::iserror($response)) { error($response->getmessage()); return false; }
+
+	return true;
+}
+
 // Update all details of a permission template.
 
 function update_perm_templ_details($details) {