Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117746948
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
8 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/kolab_admin_form_value_actions.php b/lib/kolab_admin_form_value_actions.php
new file mode 100644
index 0000000..90cc20c
--- /dev/null
+++ b/lib/kolab_admin_form_value_actions.php
@@ -0,0 +1,130 @@
+<?php
+
+ /**
+ *
+ */
+ class kolab_admin_form_value_actions extends kolab_admin_service
+ {
+ public function capabilities($domain)
+ {
+ return array(
+ 'list' => 'l',
+ 'info' => 'r',
+ );
+ }
+
+ public function generate_cn($getdata, $postdata) {
+ if (!isset($postdata['user_type_id'])) {
+ throw new Exception("No user type ID specified", 34);
+ }
+
+ $user_type = mysql_fetch_assoc(query("SELECT attributes FROM user_types WHERE id = '" . $postdata['user_type_id'] ."'"));
+
+ $uta = json_decode(unserialize($user_type['attributes']), true);
+
+ if (isset($uta['auto_form_fields']) && isset($uta['auto_form_fields']['cn'])) {
+ // Use Data Please
+ foreach ($uta['auto_form_fields']['cn']['data'] as $key) {
+ if (!isset($postdata[$key])) {
+ throw new Exception("Key not set: " . $key, 12356);
+ }
+ }
+
+ return Array("cn" => $postdata['givenname'] . " " . $postdata['sn']);
+ }
+
+ }
+
+ public function generate_displayname($getdata, $postdata) {
+ if (!isset($postdata['user_type_id'])) {
+ throw new Exception("No user type ID specified", 34);
+ }
+
+ $user_type = mysql_fetch_assoc(query("SELECT attributes FROM user_types WHERE id = '" . $postdata['user_type_id'] ."'"));
+
+ $uta = json_decode(unserialize($user_type['attributes']), true);
+
+ if (isset($uta['auto_form_fields']) && isset($uta['auto_form_fields']['displayname'])) {
+ // Use Data Please
+ foreach ($uta['auto_form_fields']['displayname']['data'] as $key) {
+ if (!isset($postdata[$key])) {
+ throw new Exception("Key not set: " . $key, 12356);
+ }
+ }
+
+ return Array("displayname" => $postdata['sn'] . ", " . $postdata['givenname']);
+ }
+
+ }
+
+ public function generate_mail($getdata, $postdata) {
+ if (!isset($postdata['user_type_id'])) {
+ throw new Exception("No user type ID specified", 34);
+ }
+
+ $user_type = mysql_fetch_assoc(query("SELECT attributes FROM user_types WHERE id = '" . $postdata['user_type_id'] ."'"));
+
+ $uta = json_decode(unserialize($user_type['attributes']), true);
+
+ if (isset($uta['auto_form_fields']) && isset($uta['auto_form_fields']['mail'])) {
+ // Use Data Please
+ foreach ($uta['auto_form_fields']['mail']['data'] as $key) {
+ if (!isset($postdata[$key])) {
+ throw new Exception("Key not set: " . $key, 12356);
+ }
+ }
+
+ $givenname = iconv('UTF-8', 'ASCII//TRANSLIT', $postdata['givenname']);
+ $sn = iconv('UTF-8', 'ASCII//TRANSLIT', $postdata['sn']);
+
+ $givenname = strtolower($givenname);
+
+ $sn = str_replace(' ', '', $sn);
+ $sn = strtolower($sn);
+
+ return Array('mail' => $givenname . "." . $sn . "@" . $_SESSION['user']->get_domain());
+ }
+
+ }
+
+ public function generate_password($getdata, $postdata) {
+ exec("head -c 200 /dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c15", $userpassword_plain);
+ $userpassword_plain = $userpassword_plain[0];
+ return Array('password' => $userpassword_plain);
+ }
+
+ public function generate_uid($getdata, $postdata) {
+ if (!isset($postdata['user_type_id'])) {
+ throw new Exception("No user type ID specified", 34);
+ }
+
+ $user_type = mysql_fetch_assoc(query("SELECT attributes FROM user_types WHERE id = '" . $postdata['user_type_id'] ."'"));
+
+ $uta = json_decode(unserialize($user_type['attributes']), true);
+
+ if (isset($uta['auto_form_fields']) && isset($uta['auto_form_fields']['uid'])) {
+ // Use Data Please
+ foreach ($uta['auto_form_fields']['uid']['data'] as $key) {
+ if (!isset($postdata[$key])) {
+ throw new Exception("Key not set: " . $key, 12356);
+ }
+ }
+
+ $uid = iconv('UTF-8', 'ASCII//TRANSLIT', $postdata['sn']);
+
+ $uid = strtolower($uid);
+ $uid = str_replace(' ', '', $uid);
+
+ return Array('uid' => $uid);
+ }
+
+ }
+
+ public function generate_userpassword($getdata, $postdata) {
+ $password = $this->generate_password($getdata, $postdata);
+ return Array('userpassword' => $password['password']);
+ }
+
+ }
+
+?>
diff --git a/lib/kolab_admin_user_actions.php b/lib/kolab_admin_user_actions.php
new file mode 100644
index 0000000..3312615
--- /dev/null
+++ b/lib/kolab_admin_user_actions.php
@@ -0,0 +1,66 @@
+<?php
+
+ /**
+ *
+ */
+ class kolab_admin_user_actions extends kolab_admin_service
+ {
+ public function capabilities($domain)
+ {
+ return array(
+ 'list' => 'l',
+ 'info' => 'r',
+ );
+ }
+
+ public function user_add($getdata, $postdata) {
+# print_r($postdata);
+
+ if (!isset($postdata['user_type_id'])) {
+ throw new Exception("No user type ID specified", 346781);
+ }
+
+ $user_type = mysql_fetch_assoc(query("SELECT attributes FROM user_types WHERE id = '" . $postdata['user_type_id'] ."'"));
+
+ $uta = json_decode(unserialize($user_type['attributes']), true);
+
+ $user_attributes = Array();
+
+ if (isset($uta['form_fields'])) {
+ foreach ($uta['form_fields'] as $key => $value) {
+ error_log("form field $key");
+ if (!isset($postdata[$key]) || empty($postdata[$key])) {
+ throw new Exception("Missing input value for $key", 345);
+ } else {
+ $user_attributes[$key] = $postdata[$key];
+ }
+ }
+ }
+
+ if (isset($uta['auto_form_fields'])) {
+ foreach ($uta['auto_form_fields'] as $key => $value) {
+ if (!isset($postdata[$key])) {
+ throw new Exception("Key not set: " . $key, 12356);
+ } else {
+ $user_attributes[$key] = $postdata[$key];
+ }
+ }
+ }
+
+ if (isset($uta['fields'])) {
+ foreach ($uta['fields'] as $key => $value) {
+ if (!isset($postdata[$key]) || empty($postdata[$key])) {
+ $user_attributes[$key] = $uta['fields'][$key];
+ } else {
+ $user_attributes[$key] = $postdata[$key];
+ }
+ }
+ }
+
+ $auth = Auth::get_instance();
+ $result = $auth->user_add($user_attributes, $postdata['user_type_id']);
+ return $result;
+ }
+ }
+
+?>
diff --git a/lib/kolab_admin_user_types_actions.php b/lib/kolab_admin_user_types_actions.php
index 9d3238c..2467eac 100644
--- a/lib/kolab_admin_user_types_actions.php
+++ b/lib/kolab_admin_user_types_actions.php
@@ -1,39 +1,39 @@
<?php
/**
*
*/
class kolab_admin_user_types_actions extends kolab_admin_service
{
public function capabilities($domain)
{
return array(
'list' => 'l',
'info' => 'r',
);
}
public function user_types_list($get, $post) {
$result = query("SELECT * FROM user_types");
$user_types = Array();
while ($row = mysql_fetch_assoc($result)) {
$user_types[$row['id']] = Array();
foreach ($row as $key => $value) {
if ($key != "id") {
if ($key == "attributes") {
- $user_types[$row['id']][$key] = json_decode(base64_decode($value));
+ $user_types[$row['id']][$key] = json_decode(unserialize($value), true);
} else {
$user_types[$row['id']][$key] = $value;
}
}
}
}
return $user_types;
}
}
?>
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Apr 4 2026, 12:00 AM (4 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18821596
Default Alt Text
(8 KB)
Attached To
Mode
rWAP webadmin
Attached
Detach File
Event Timeline