3 commits - doc/sample-insert-hosted-user_types.php lib/Auth lib/Conf.php lib/hosted
Torsten Grote
grote at kolabsys.com
Mon Jul 9 17:05:51 CEST 2012
doc/sample-insert-hosted-user_types.php | 121 ++++++++++++++++++++++++++++++++
lib/Auth/LDAP.php | 8 +-
lib/Conf.php | 3
lib/hosted/kolab_client_task_signup.php | 39 +++++++---
4 files changed, 157 insertions(+), 14 deletions(-)
New commits:
commit 6c5371d73d00175f350cd9e1b0a6e9f3e05086fe
Author: Torsten Grote <grote at kolabsys.com>
Date: Mon Jul 9 15:05:28 2012 +0200
adapt signup page to new user_types table
diff --git a/lib/Conf.php b/lib/Conf.php
index e91110c..e978c8a 100644
--- a/lib/Conf.php
+++ b/lib/Conf.php
@@ -28,7 +28,8 @@ class Conf {
private $_conf = array();
- const CONFIG_FILE = '/etc/kolab/kolab.conf';
+// const CONFIG_FILE = '/etc/kolab/kolab.conf';
+ const CONFIG_FILE = '/home/grote/public_html/kolab-webadmin/kolab.conf';
const STRING = 0;
const BOOL = 1;
diff --git a/lib/hosted/kolab_client_task_signup.php b/lib/hosted/kolab_client_task_signup.php
index 11bb3bd..36617a7 100644
--- a/lib/hosted/kolab_client_task_signup.php
+++ b/lib/hosted/kolab_client_task_signup.php
@@ -79,18 +79,19 @@ class kolab_client_task_signup extends kolab_client_task
private function user_form($data = array()) {
$attribs['id'] = 'signup-form';
+ $show_fields = array('mailalternateaddress');
// Prepare fields
list($fields, $types, $type) = $this->form_prepare('user', $data, array('userpassword2'));
-
- // remove delete button
+
+ // Remove delete button
if(($key = array_search('delete', $data['effective_rights']['entry'])) !== false) {
unset($data['effective_rights']['entry'][$key]);
}
// Show only required fields
foreach ($fields as $field_name => $field_attrs) {
- if(!array_key_exists('required', $field_attrs) or $field_attrs['required'] != 'true') {
+ if((!array_key_exists('required', $field_attrs) or $field_attrs['required'] != 'true') and !in_array($field_name, $show_fields)) {
unset($fields[$field_name]);
}
}
@@ -98,15 +99,30 @@ class kolab_client_task_signup extends kolab_client_task
// Add user type field
$fields['type_id'] = array(
'type' => kolab_form::INPUT_HIDDEN,
- 'value' => $this->type_id,
+ 'value' => $type,
);
-
+
+ // Add object type
+ $fields['object_type'] = array(
+ 'type' => kolab_form::INPUT_HIDDEN,
+ 'value' => 'user',
+ );
+
// Add available domains
- $fields['mailhost']['options'] = $this->get_domains();
+ $fields['domain'] = array(
+ 'type' => kolab_form::INPUT_SELECT,
+ 'options' => $this->get_domains(),
+ 'onchange' => 'kadm.form_value_change(["mail"])',
+ );
+ // TODO get domain into auto-fields
+
+
+ // Require mail alternate address
+ $fields['mailalternateaddress']['required'] = 'true';
- // Hide ou field
- if (isset($fields['ou'])) {
- $fields['ou']['type'] = kolab_form::INPUT_HIDDEN;
+ // Hide cn field
+ if (isset($fields['cn'])) {
+ $fields['cn']['type'] = kolab_form::INPUT_HIDDEN;
}
// Add password confirmation
@@ -121,18 +137,19 @@ class kolab_client_task_signup extends kolab_client_task
));
}
}
+
// Change field labels for hosted case
// TODO make translatable
$fields['uid']['label'] = "Username";
$fields['mail']['label'] = "Your Future Email Address";
$fields['mailalternateaddress']['label'] = "Your Current Email Address";
- $fields['mailhost']['label'] = "Domain";
+ $fields['domain']['label'] = "Domain";
// Create form object and populate with fields
$form = $this->form_create('user', $attribs, array('other'), $fields, array(), $data, true);
- $form->set_title(kolab_html::escape($title));
+ $form->set_title(kolab_html::escape('Sign up'));
$this->output->add_translation('user.password.mismatch', 'user.add.success', 'user.edit.success', 'user.delete.success');
commit bc730a0c082eb6204edbab20bd46e241c37b4a77
Author: Torsten Grote <grote at kolabsys.com>
Date: Mon Jul 9 15:02:45 2012 +0200
new user_types table for hosted case
diff --git a/doc/sample-insert-hosted-user_types.php b/doc/sample-insert-hosted-user_types.php
new file mode 100644
index 0000000..8361c5f
--- /dev/null
+++ b/doc/sample-insert-hosted-user_types.php
@@ -0,0 +1,121 @@
+#!/usr/bin/php
+<?php
+
+ if (isset($_SERVER["REQUEST_METHOD"]) && !empty($SERVER["REQUEST_METHOD"])) {
+ die("Not intended for execution through the webserver, sorry!");
+ }
+
+ require_once("lib/functions.php");
+
+ $db = SQL::get_instance();
+
+ $result = $db->query("TRUNCATE `user_types`");
+
+ $attributes = Array(
+
+ /*
+ *
+ * The form fields for which the values can be
+ * generated automatically, using the existing
+ * values of form_fields
+ */
+ "auto_form_fields" => Array(
+ /*
+ *
+ * The 'cn' attribute is required for
+ * the LDAP objectclasses we use, but
+ * can be composed from a 'givenname'
+ * and 'sn' attribute form_field (of
+ * which 'sn' is also a required
+ * attribute.
+ */
+ "cn" => Array(
+ "data" => Array(
+ "givenname",
+ "sn",
+ ),
+ ),
+ /*
+ *
+ * The 'mail' attribute is supposed to
+ * contain the email address this user
+ * will use for this environment, and
+ * is (supposed?) to match the 'uid'
+ * for the user account.
+ *
+ * Disable this auto_form_field if
+ * the API is not capable of making
+ * a 'uid' become a 'uid'@'domain',
+ * where 'domain' is not a valid
+ * LDAP attribute for a user entry.
+ */
+ "mail" => Array(
+ "data" => Array(
+ "uid",
+ ),
+ ),
+ ),
+ "form_fields" => Array(
+ "givenname" => Array(),
+ "kolabdelegate" => Array(
+ "type" => "list",
+ "autocomplete" => true,
+ "optional" => true,
+ ),
+ "kolabinvitationpolicy" => Array(
+ "type" => "select",
+ "values" => Array(
+ "",
+ "ACT_MANUAL",
+ "ACT_REJECT",
+ ),
+ "optional" => true,
+ ),
+ "kolaballowsmtprecipient" => Array(
+ "type" => "list",
+ "optional" => true,
+ ),
+ "kolaballowsmtpsender" => Array(
+ "type" => "list",
+ "optional" => true,
+ ),
+ /*
+ *
+ * The 'mailalternateaddress' is supposed
+ * to contain the original email address
+ * for the user.
+ */
+ "mailalternateaddress" => Array(
+ "type" => "list",
+ "optional" => true,
+ ),
+ "mailquota" => Array(
+ "optional" => true,
+ ),
+ "nsroledn" => Array(
+ "type" => "list",
+ "autocomplete" => true,
+ "optional" => true
+ ),
+ "sn" => Array(),
+ "uid" => Array(),
+ "userpassword" => Array(
+ "optional" => true,
+ ),
+ ),
+ "fields" => Array(
+ "objectclass" => Array(
+ "top",
+ "inetorgperson",
+ "kolabinetorgperson",
+ "mailrecipient",
+ "organizationalperson",
+ "person",
+ ),
+ ),
+ );
+
+ $result = $db->query("INSERT INTO `user_types` (`key`, `name`, `description`, `attributes`) " .
+ "VALUES ('personal','Personal', 'A user with a personal hosted plan'," .
+ "'" . json_encode($attributes) . "')");
+?>
commit 0adbdbf12189cf52a3a1acd6db86bdf243c506bf
Author: Torsten Grote <grote at kolabsys.com>
Date: Mon Jul 9 14:19:46 2012 +0200
fixed typo
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 0cd9f1c..5574457 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -955,6 +955,7 @@ class LDAP
*/
private function domain_root_dn($domain = '')
{
+ //console("Auth::LDAP::domain_root_dn(\$domain) called with \$domain", $domain);
$conf = Conf::get_instance();
if ($domain == '') {
@@ -986,13 +987,14 @@ class LDAP
);
$result = $result[key($result)];
+ //console("intermediate result for domain_root_dn()", $result);
if (is_array($result)) {
- if (in_array('inetdomainbasedn', $result)) {
+ if (in_array('inetdomainbasedn', $result) && !empty($result['inetdomainbasedn'])) {
return $result['inetdomainbasedn'];
} else {
if (is_array($result[$domain_name_attribute])) {
- return $this->_standard_root_dn($result[$domain_name_attribute[0]]);
+ return $this->_standard_root_dn($result[$domain_name_attribute][0]);
} else {
return $this->_standard_root_dn($result[$domain_name_attribute]);
}
@@ -1067,6 +1069,8 @@ class LDAP
private function entry_find_by_attribute($attribute, $base_dn = null)
{
+ //console("Auth::LDAP::entry_find_by_attribute(\$attribute, \$base_dn) called with base_dn", $base_dn);
+
if (empty($attribute) || !is_array($attribute)) {
return false;
}
More information about the commits
mailing list