67d3ffab626b1f3cd94864ec65b8e26b41567d94
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

1) <?php
2) 
3) require_once("inc/debug.php");
4) require_once("inc/db_connect.php");
5) 
6) 
7) 
8) function customer_may_have_useraccounts()
9) {
10)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
11)   $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde={$customerno}");
12)   return (mysql_num_rows($result) > 0);
13) }
14) 
bernd nicht mehr der user mit der...

bernd authored 16 years ago

15) function customer_useraccount($uid) {
16)   $uid = (int) $uid;
17)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
18)   $result = db_query("SELECT 1 FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid} AND kundenaccount=1");
19)   return mysql_num_rows($result) > 0;
20) }
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

21) 
bernd Primärer Useraccount kann d...

bernd authored 16 years ago

22) function primary_useraccount()
23) {
24)   if (! ($_SESSION['role'] & ROLE_SYSTEMUSER))
25)     return NULL;
26)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
27)   $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde={$customerno}");
28)   $uid = mysql_fetch_object($result)->uid;
29)   DEBUG("primary useraccount: {$uid}");
30)   return $uid;
31) }
32) 
33) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

34) function available_shells()
35) {
36)   $result = db_query("SELECT path, name FROM system.shells WHERE usable=1");
37)   $ret = array();
38)   while ($s = mysql_fetch_assoc($result))
39)   {
40)     $ret[$s['path']] = $s['name'];
41)   }
42)   DEBUG($ret);
43)   return $ret;
44) }
45) 
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

46) 
47) function list_useraccounts()
48) {
49)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

50)   $result = db_query("SELECT uid,username,name,erstellungsdatum,quota,shell FROM system.useraccounts WHERE kunde={$customerno}");
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

51)   $ret = array();
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

52)   while ($item = mysql_fetch_assoc($result))
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

53)   {
54)     array_push($ret, $item);
55)   }
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

56)   DEBUG($ret);
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

57)   return $ret;
58) }
59) 
60) 
bernd Erlaube Änderung von Name u...

bernd authored 14 years ago

61) function get_account_details($uid, $customerno=0)
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

62) {
63)   $uid = (int) $uid;
bernd Erlaube Änderung von Name u...

bernd authored 14 years ago

64)   $customerno = (int) $customerno;
65)   if ($customerno == 0)
66)     $customerno = $_SESSION['customerinfo']['customerno'];
67)   $result = db_query("SELECT uid,username,name,shell,quota,erstellungsdatum FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid}");
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

68)   if (mysql_num_rows($result) == 0)
69)     system_failure("Cannot find the requestes useraccount (for this customer).");
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

70)   return mysql_fetch_assoc($result);
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

71) }
72) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

73) function get_used_quota($uid)
74) {
75)   $uid = (int) $uid;
bernd Mailaccount-Quota auch bei...

bernd authored 13 years ago

76)   $result = db_query("SELECT s.hostname AS server, systemquota, systemquota_used, mailquota, mailquota_used FROM system.v_quota AS q LEFT JOIN system.servers AS s ON (s.id=q.server) WHERE uid='{$uid}'");
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

77)   $ret = array();
78)   while ($line = mysql_fetch_assoc($result))
79)     $ret[] = $line;
80)   DEBUG($ret);
81)   return $ret;
82) }
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

83) 
84) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

85) function set_account_details($account)
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

86) {
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

87)   $uid = (int) $account['uid'];
bernd Erlaube Änderung von Name u...

bernd authored 14 years ago

88)   $customerno = NULL;
89)   if ($_SESSION['role'] & ROLE_CUSTOMER)
90)     $customerno = (int) $_SESSION['customerinfo']['customerno'];
91)   else
92)     $customerno = (int) $_SESSION['userinfo']['customerno'];
93) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

94)   $fullname = maybe_null(mysql_real_escape_string(filter_input_general($account['name'])));
95)   $shell = mysql_real_escape_string(filter_input_general($account['shell']));
96)   $quota = (int) $account['quota'];
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

97) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

98)   db_query("UPDATE system.useraccounts SET name={$fullname}, quota={$quota}, shell='{$shell}' WHERE kunde={$customerno} AND uid={$uid}");
99)   logger(LOG_INFO, "modules/systemuser/include/useraccounts", "systemuser", "updated details for uid {$uid}");
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

100) 
101) }
102) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

103) function get_customer_quota()
104) {
105)   $cid = (int) $_SESSION['customerinfo']['customerno'];
106)   $result = db_query("SELECT SUM(u.quota) AS assigned, cq.quota AS max FROM system.customerquota AS cq INNER JOIN system.useraccounts AS u ON (u.kunde=cq.cid) WHERE cq.cid={$cid}");
107)   $ret = mysql_fetch_assoc($result);
108)   DEBUG($ret);
109)   return $ret;
110) }
111)