inc/users.inc.php
changeset 109 34b2d49f52c6
parent 89 61c49e66c9b0
child 113 e7a448dba024
equal deleted inserted replaced
108:b1015b3055af 109:34b2d49f52c6
   594 function add_perm_templ($details) {
   594 function add_perm_templ($details) {
   595 	global $db;
   595 	global $db;
   596 
   596 
   597 	// Fix permission template name and description first. 
   597 	// Fix permission template name and description first. 
   598 
   598 
   599 	$query = "INSERT INTO perm_templ 
   599 	$query = "INSERT INTO perm_templ (name, descr)
   600 			VALUES (
   600 			VALUES (" 
   601 				'', " 
       
   602 				. $db->quote($details['templ_name']) . ", " 
   601 				. $db->quote($details['templ_name']) . ", " 
   603 				. $db->quote($details['templ_descr']) . ")";
   602 				. $db->quote($details['templ_descr']) . ")";
   604 
   603 
   605 	$result = $db->query($query);
   604 	$result = $db->query($query);
   606 	if (PEAR::isError($response)) { error($response->getMessage()); return false; }
   605 	if (PEAR::isError($response)) { error($response->getMessage()); return false; }
   607 
   606 
   608 	$perm_templ_id = $db->lastInsertId('perm_templ', 'id');
   607 	$perm_templ_id = $db->lastInsertId('perm_templ', 'id');
   609 
   608 
   610 	foreach ($details['perm_id'] AS $perm_id) {
   609 	foreach ($details['perm_id'] AS $perm_id) {
   611 		$r_insert_values[] = "(''," . $db->quote($perm_templ_id) . "," . $db->quote($perm_id) . ")";
   610 		$r_insert_values[] = "(" . $db->quote($perm_templ_id) . "," . $db->quote($perm_id) . ")";
   612 	}
   611 	}
   613 	$query = "INSERT INTO perm_templ_items VALUES " . implode(',', $r_insert_values) ;
   612 	$query = "INSERT INTO perm_templ_items (templ_id, perm_id) VALUES " . implode(',', $r_insert_values) ;
   614 	$result = $db->query($query);
   613 	$result = $db->query($query);
   615 	if (pear::iserror($response)) { error($response->getmessage()); return false; }
   614 	if (pear::iserror($response)) { error($response->getmessage()); return false; }
   616 
   615 
   617 	return true;
   616 	return true;
   618 }
   617 }
   642 	$query = "DELETE FROM perm_templ_items WHERE templ_id = " . $details['templ_id'] ;
   641 	$query = "DELETE FROM perm_templ_items WHERE templ_id = " . $details['templ_id'] ;
   643 	$result = $db->query($query);
   642 	$result = $db->query($query);
   644 	if (pear::iserror($response)) { error($response->getmessage()); return false; }
   643 	if (pear::iserror($response)) { error($response->getmessage()); return false; }
   645 
   644 
   646 	foreach ($details['perm_id'] AS $perm_id) {
   645 	foreach ($details['perm_id'] AS $perm_id) {
   647 		$r_insert_values[] = "(''," . $db->quote($details['templ_id']) . "," . $db->quote($perm_id) . ")";
   646 		$r_insert_values[] = "(" . $db->quote($details['templ_id']) . "," . $db->quote($perm_id) . ")";
   648 	}
   647 	}
   649 	$query = "INSERT INTO perm_templ_items VALUES " . implode(',', $r_insert_values) ;
   648 	$query = "INSERT INTO perm_templ_items (templ_id, perm_id) VALUES " . implode(',', $r_insert_values) ;
   650 	$result = $db->query($query);
   649 	$result = $db->query($query);
   651 	if (pear::iserror($response)) { error($response->getmessage()); return false; }
   650 	if (pear::iserror($response)) { error($response->getmessage()); return false; }
   652 
   651 
   653 	return true;
   652 	return true;
   654 }
   653 }
   749 		$active = 1;
   748 		$active = 1;
   750 	} else {
   749 	} else {
   751 		$active = 0;
   750 		$active = 0;
   752 	}
   751 	}
   753 
   752 
   754 	$query = "INSERT INTO users VALUES ( "
   753 	$query = "INSERT INTO users (username, password, fullname, email, description, perm_templ, active) VALUES ("
   755 			. "'', "
       
   756 			. $db->quote($details['username']) . ", "
   754 			. $db->quote($details['username']) . ", "
   757 			. $db->quote(md5($details['password'])) . ", "
   755 			. $db->quote(md5($details['password'])) . ", "
   758 			. $db->quote($details['fullname']) . ", "
   756 			. $db->quote($details['fullname']) . ", "
   759 			. $db->quote($details['email']) . ", "
   757 			. $db->quote($details['email']) . ", "
   760 			. $db->quote($details['descr']) . ", "
   758 			. $db->quote($details['descr']) . ", "