inc/users.inc.php
changeset 126 cb06e3e29ed8
parent 119 f74e4f88b680
child 183 aae57715199e
equal deleted inserted replaced
125:700a3674b72e 126:cb06e3e29ed8
   142 		 "id"                    =>              $r["id"],
   142 		 "id"                    =>              $r["id"],
   143 		 "username"              =>              $r["username"],
   143 		 "username"              =>              $r["username"],
   144 		 "fullname"              =>              $r["fullname"],
   144 		 "fullname"              =>              $r["fullname"],
   145 		 "email"                 =>              $r["email"],
   145 		 "email"                 =>              $r["email"],
   146 		 "description"           =>              $r["description"],
   146 		 "description"           =>              $r["description"],
   147 		 "level"                 =>              $r["level"],
   147 //		 "level"                 =>              $r["level"],
   148 		 "active"                =>              $r["active"],
   148 		 "active"                =>              $r["active"],
   149 		 "numdomains"            =>              $r["aantal"]
   149 		 "numdomains"            =>              $r["aantal"]
   150 		);
   150 		);
   151 	}
   151 	}
   152 	return $ret;
   152 	return $ret;
   205  */
   205  */
   206 function delete_user($uid,$zones)
   206 function delete_user($uid,$zones)
   207 {
   207 {
   208 	global $db;
   208 	global $db;
   209 
   209 
   210 	if (($uid != $_SESSION['userid'] && !verify_permission(user_edit_others)) || ($uid == $_SESSION['userid'] && !verify_permission(user_edit_own))) {
   210 	if (($uid != $_SESSION['userid'] && !verify_permission('user_edit_others')) || ($uid == $_SESSION['userid'] && !verify_permission('user_edit_own'))) {
   211 		 error(ERR_PERM_DEL_USER);
   211 		 error(ERR_PERM_DEL_USER);
   212 		 return false;
   212 		 return false;
   213 	} else {
   213 	} else {
   214 
   214 
   215 		if (is_array($zones)) {
   215 		if (is_array($zones)) {
   234 }
   234 }
   235 
   235 
   236 function delete_perm_templ($ptid) {
   236 function delete_perm_templ($ptid) {
   237 
   237 
   238 	global $db;
   238 	global $db;
   239 	if (!(verify_permission(user_edit_templ_perm))) {
   239 	if (!(verify_permission('user_edit_templ_perm'))) {
   240 		error(ERR_PERM_DEL_PERM_TEMPL);
   240 		error(ERR_PERM_DEL_PERM_TEMPL);
   241 	} else {
   241 	} else {
   242 		$query = "SELECT id FROM users WHERE perm_templ = " . $ptid;
   242 		$query = "SELECT id FROM users WHERE perm_templ = " . $ptid;
   243 		$result = $db->query($query);
   243 		$result = $db->query($query);
   244 		if (PEAR::isError($result)) { error($response->getMessage()); return false; }
   244 		if (PEAR::isError($result)) { error($response->getMessage()); return false; }
   266  */
   266  */
   267 function edit_user($id, $user, $fullname, $email, $perm_templ, $description, $active, $password)
   267 function edit_user($id, $user, $fullname, $email, $perm_templ, $description, $active, $password)
   268 {
   268 {
   269 	global $db;
   269 	global $db;
   270 
   270 
   271 	verify_permission(user_edit_own) ? $perm_edit_own = "1" : $perm_edit_own = "0" ;
   271 	verify_permission('user_edit_own') ? $perm_edit_own = "1" : $perm_edit_own = "0" ;
   272 	verify_permission(user_edit_others) ? $perm_edit_others = "1" : $perm_edit_others = "0" ;
   272 	verify_permission('user_edit_others') ? $perm_edit_others = "1" : $perm_edit_others = "0" ;
   273 
   273 
   274 	if (($id == $_SESSION["userid"] && $perm_edit_own == "1") || ($id != $_SESSION["userid"] && $perm_edit_others == "1" )) {
   274 	if (($id == $_SESSION["userid"] && $perm_edit_own == "1") || ($id != $_SESSION["userid"] && $perm_edit_others == "1" )) {
   275 
   275 
   276 		if (!is_valid_email($email)) {
   276 		if (!is_valid_email($email)) {
   277 			error(ERR_INV_EMAIL);
   277 			error(ERR_INV_EMAIL);
   472 
   472 
   473 
   473 
   474 	if (v_num($specific)) {
   474 	if (v_num($specific)) {
   475 		$sql_add = "AND users.id = " . $db->quote($specific) ;
   475 		$sql_add = "AND users.id = " . $db->quote($specific) ;
   476 	} else {
   476 	} else {
   477 		if (verify_permission(user_view_others)) {
   477 		if (verify_permission('user_view_others')) {
   478 			$sql_add = "";
   478 			$sql_add = "";
   479 		} else {
   479 		} else {
   480 			$sql_add = "AND users.id = " . $db->quote($userid) ;
   480 			$sql_add = "AND users.id = " . $db->quote($userid) ;
   481 		}
   481 		}
   482 	}
   482 	}
   657 
   657 
   658 function update_user_details($details) {
   658 function update_user_details($details) {
   659 
   659 
   660 	global $db;
   660 	global $db;
   661 
   661 
   662 	verify_permission(user_edit_own) ? $perm_edit_own = "1" : $perm_edit_own = "0" ;
   662 	verify_permission('user_edit_own') ? $perm_edit_own = "1" : $perm_edit_own = "0" ;
   663 	verify_permission(user_edit_others) ? $perm_edit_others = "1" : $perm_edit_others = "0" ;
   663 	verify_permission('user_edit_others') ? $perm_edit_others = "1" : $perm_edit_others = "0" ;
   664 
   664 
   665 	if (($details['uid'] == $_SESSION["userid"] && $perm_edit_own == "1") || 
   665 	if (($details['uid'] == $_SESSION["userid"] && $perm_edit_own == "1") || 
   666 			($details['uid'] != $_SESSION["userid"] && $perm_edit_others == "1" )) {
   666 			($details['uid'] != $_SESSION["userid"] && $perm_edit_others == "1" )) {
   667 
   667 
   668 		if (!is_valid_email($details['email'])) {
   668 		if (!is_valid_email($details['email'])) {
   736 // Add a new user
   736 // Add a new user
   737 
   737 
   738 function add_new_user($details) {
   738 function add_new_user($details) {
   739 	global $db;
   739 	global $db;
   740 
   740 
   741 	if (!verify_permission(user_add_new)) {
   741 	if (!verify_permission('user_add_new')) {
   742 		error(ERR_PERM_ADD_USER);
   742 		error(ERR_PERM_ADD_USER);
   743 
   743 
   744 	} elseif (user_exists($details['username'])) {
   744 	} elseif (user_exists($details['username'])) {
   745 		error(ERR_USER_EXISTS);
   745 		error(ERR_USER_EXISTS);
   746 
   746