4 commits - lib/Auth lib/Auth.php lib/hosted lib/kolab_client_task.php lib/kolab_recipient_policy.php
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Mon Sep 3 16:17:23 CEST 2012
lib/Auth.php | 8 +++---
lib/Auth/LDAP.php | 24 +++---------------
lib/hosted/kolab_client_task_signup.php | 23 +++++++++++------
lib/kolab_client_task.php | 42 +++++++++++++++++++-------------
lib/kolab_recipient_policy.php | 5 ++-
5 files changed, 52 insertions(+), 50 deletions(-)
New commits:
commit 50abe6a1f61f368c63aa84c7283b3cfa447c81e9
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Sep 3 15:16:53 2012 +0100
Select the domain before doing anything else
diff --git a/lib/hosted/kolab_client_task_signup.php b/lib/hosted/kolab_client_task_signup.php
index e5ba005..7813da7 100644
--- a/lib/hosted/kolab_client_task_signup.php
+++ b/lib/hosted/kolab_client_task_signup.php
@@ -152,9 +152,13 @@ class kolab_client_task_signup extends kolab_client_task
return;
}
+ $this->api->get('system.select_domain', array('domain', $data['domain']));
+
// Remove domain from $data before adding user
unset($data['domain']);
+ $data['cn'] = $this->api->post('form_value.generate', $data);
+
// Add user
$result = $this->api->post('user.add', null, $data);
commit 577a094c6b786d9a96367e14fc308efe3b550adb
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Sep 3 15:16:23 2012 +0100
Correct function calls to obtain a base dn for roles
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index b351593..33214e5 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -670,7 +670,7 @@ class LDAP extends Net_LDAP3 {
$this->bind($_SESSION['user']->user_bind_dn, $_SESSION['user']->user_bind_pw);
- $base_dn = $this->subject_base_dn('role');
+ $base_dn = $this->_subject_base_dn('role');
// TODO: The rdn is configurable as well.
// Use [$type_str . "_"]user_rdn_attr
@@ -750,24 +750,10 @@ class LDAP extends Net_LDAP3 {
}
// Check if the user_type has a specific base DN specified.
- $base_dn = $this->conf->get($this->domain, $type_str . "_user_base_dn");
- // If not, take the regular user_base_dn
- if (empty($base_dn))
- $base_dn = $this->conf->get($this->domain, "user_base_dn");
-
- // If no user_base_dn either, take the user type specific from the parent
- // configuration
- if (empty($base_dn))
- $base_dn = $this->conf->get('ldap', $type_str . "_user_base_dn");
-
- if (empty($base_dn))
- $base_dn = $this->conf->get('ldap', "user_base_dn");
-
- // If still no base dn to add the user to... use the toplevel dn
- if (empty($base_dn))
- $base_dn = $this->conf->get($this->domain, "base_dn");
- if (empty($base_dn))
- $base_dn = $this->conf->get('ldap', "base_dn");
+ $base_dn = $this->_subject_base_dn($type_str . "_user");
+ if (empty($base_dn)) {
+ $base_dn = $this->_subject_base_dn("user");
+ }
if (!empty($attrs['ou'])) {
$base_dn = $attrs['ou'];
commit a53394a2e77ba16241e8291d57782c636b6c042f
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Sep 3 15:16:08 2012 +0100
Log with the domain included
diff --git a/lib/Auth.php b/lib/Auth.php
index 20da7b6..3240da5 100644
--- a/lib/Auth.php
+++ b/lib/Auth.php
@@ -121,11 +121,11 @@ class Auth {
{
if (empty($domain)) {
if (!empty($_SESSION['user'])) {
- Log::trace("Using domain from session");
$domain = $_SESSION['user']->get_domain();
+ Log::trace("Using domain from session: $domain");
} else {
- Log::trace("Using primary_domain");
$domain = $this->conf->get('primary_domain');
+ Log::trace("Using primary_domain: " . $domain);
}
Log::trace("Domain to connect to not specified, connecting to $domain");
} else {
@@ -162,11 +162,11 @@ class Auth {
{
if (empty($domain)) {
if (!empty($_SESSION['user'])) {
- Log::trace("Using domain from session");
$domain = $_SESSION['user']->get_domain();
+ Log::trace("Using domain from session: " . $domain);
} else {
- Log::trace("Using primary_domain");
$domain = $this->conf->get('primary_domain');
+ Log::trace("Using primary_domain: " . $domain);
}
}
commit dc2c82a5f5d3479c136075cb7681da637076c6c8
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Sep 3 14:17:48 2012 +0100
Only substitute the part of the form with a captcha if a public key has been configured.
Get only the user types for the 'hosted'.
Avoid requiring input for the password confirmation as it collides with the regular web admin interface.
diff --git a/lib/hosted/kolab_client_task_signup.php b/lib/hosted/kolab_client_task_signup.php
index 359e6fa..e5ba005 100644
--- a/lib/hosted/kolab_client_task_signup.php
+++ b/lib/hosted/kolab_client_task_signup.php
@@ -84,14 +84,17 @@ class kolab_client_task_signup extends kolab_client_task
// add captcha
$publickey = $this->config_get('recaptcha_public_key');
- // TODO find a less dirty way to add captcha into form
- $form = preg_replace('/<div class="formbuttons">/', '<div id="recaptcha_div"></div><div class="formbuttons">', $form);
- // load captcha
- $form .= '
- <script type="text/javascript">
- Recaptcha.create("'.$publickey.'", "recaptcha_div", {theme: "red"});
- </script>';
+ if (!empty($publickey)) {
+ // TODO find a less dirty way to add captcha into form
+ $form = preg_replace('/<div class="formbuttons">/', '<div id="recaptcha_div"></div><div class="formbuttons">', $form);
+
+ // load captcha
+ $form .= '
+ <script type="text/javascript">
+ Recaptcha.create("'.$publickey.'", "recaptcha_div", {theme: "red"});
+ </script>';
+ }
$this->output->assign('form', $form);
$this->output->set_object('taskcontent', $form);
@@ -183,7 +186,7 @@ class kolab_client_task_signup extends kolab_client_task
);
// Prepare fields
- list($fields, $types, $type) = $this->form_prepare('user', $data, array('userpassword2'));
+ list($fields, $types, $type) = $this->form_prepare('user', $data, array('userpassword2'), 'hosted');
// Show only required fields
foreach ($fields as $field_name => $field_attrs) {
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index 250332a..da97fe4 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -461,7 +461,8 @@ class kolab_client_task
$type = kolab_utils::REQUEST_ANY;
}
- return kolab_utils::get_input($name, $type, $allow_html);
+ $result = kolab_utils::get_input($name, $type, $allow_html);
+ return $result;
}
/**
@@ -479,8 +480,6 @@ class kolab_client_task
$capabilities = $this->capabilities();
- Log::trace("kolab_client_task::menu() capabilities:", $capabilities);
-
foreach ($this->menu as $idx => $label) {
//console("$task: $task, idx: $idx, label: $label");
@@ -524,21 +523,31 @@ class kolab_client_task
*
* @return array List of user types
*/
- protected function user_types()
+ protected function user_types($used_for = NULL)
{
- if (isset($_SESSION['user_types'])) {
+ if (isset($_SESSION['user_types']) && !$this->config_get('devel_mode')) {
return $_SESSION['user_types'];
}
+ $list = Array();
+
$result = $this->api->post('user_types.list');
- $list = $result->get('list');
+ $_list = $result->get('list');
+
+ if (!empty($used_for)) {
+ foreach ($_list as $user_type_id => $user_type_attrs) {
+ if (array_key_exists('used_for', $user_type_attrs) && $user_type_attrs['used_for'] == $used_for) {
+ $list[$user_type_id] = $user_type_attrs;
+ }
+ }
+ } else {
+ $list = $_list;
+ }
if (is_array($list) && !$this->config_get('devel_mode')) {
$_SESSION['user_types'] = $list;
}
- //console("user_types() \$list", $list);
-
return $list;
}
@@ -792,13 +801,9 @@ class kolab_client_task
*
* @return array Fields list, Object types list, Current type ID
*/
- protected function form_prepare($name, &$data, $extra_fields = array())
+ protected function form_prepare($name, &$data, $extra_fields = array(), $used_for = null)
{
- //console("Preparing form for $name with data", $data);
-
- $types = (array) $this->{$name . '_types'}();
-
- //console("form_prepare types", $types);
+ $types = (array) $this->{$name . '_types'}($used_for);
$form_id = $attribs['id'];
$add_mode = empty($data['id']);
@@ -1023,7 +1028,8 @@ class kolab_client_task
);
}
- return array($fields, $types, $type);
+ $result = array($fields, $types, $type);
+ return $result;
}
/**
@@ -1166,8 +1172,10 @@ class kolab_client_task
if ($field['type'] && $field['type'] != kolab_form::INPUT_HIDDEN) {
$writeable++;
}
- if (!empty($field['required'])) {
- $req_fields[] = $idx;
+ if ($idx != "userpassword2") {
+ if (!empty($field['required'])) {
+ $req_fields[] = $idx;
+ }
}
}
diff --git a/lib/kolab_recipient_policy.php b/lib/kolab_recipient_policy.php
index 10179d8..15d190a 100644
--- a/lib/kolab_recipient_policy.php
+++ b/lib/kolab_recipient_policy.php
@@ -169,11 +169,12 @@ class kolab_recipient_policy {
);
}
} else {
- //console("Key " . $substrings[1][$x] . " does not exist in \$userdata");
+ Log::error("Recipient policy finds that key " . $substrings[1][$x] . " does not exist in \$userdata (primary_mail)");
}
}
- return self::parse_email($primary_mail);
+ $parsed_email = self::parse_email($primary_mail);
+ return $parsed_email;
}
static function secondary_mail($userdata)
More information about the commits
mailing list