home *** CD-ROM | disk | FTP | other *** search
- <?php
- /*
- Copyright Intermesh 2003
- Author: Merijn Schering <mschering@intermesh.nl>
- Version: 1.0 Release date: 08 July 2003
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
- */
-
- require("../../Group-Office.php");
- $GO_SECURITY->authenticate(true);
- require($GO_LANGUAGE->get_language_file('users'));
- require($GO_LANGUAGE->get_language_file('common'));
- require($GO_CONFIG->class_path."users.class.inc");
- $users = new users();
-
- $datepicker = new date_picker();
- $GO_HEADER['head'] = $datepicker->get_header();
-
- $page_title = $registration_title;
- require($GO_THEME->theme_path."header.inc");
-
- require($GO_CONFIG->class_path."/validate.class.inc");
- $val = new validate;
-
- $module_acl = isset($_POST['module_acl']) ? $_POST['module_acl'] : array();
-
- if ($_SERVER['REQUEST_METHOD'] == "POST")
- {
- $val->error_required = $error_required;
- $val->error_min_length = $error_min_length;
- $val->error_max_length = $error_max_length;
- $val->error_expression = $error_email;
-
- $val->name="first_name";
- $val->input=$_POST['first_name'];
- $val->max_length=50;
- $val->required=true;
- $val->validate_input();
-
- $val->name="last_name";
- $val->input=$_POST['last_name'];
- $val->max_length=50;
- $val->required=true;
- $val->validate_input();
-
- $val->name="username";
- $val->input=$_POST['username'];
- $val->min_length=3;
- $val->max_length=20;
- $val->required=true;
- $val->validate_input();
-
- $val->name="pass1";
- $val->input=$_POST['pass1'];
- $val->min_length=3;
- $val->max_length=20;
- $val->required=true;
- $val->validate_input();
-
- $val->name="pass2";
- $val->input=$_POST['pass2'];
- $val->min_length=3;
- $val->max_length=20;
- $val->required=true;
- $val->validate_input();
-
-
- $val->name="email";
- $val->input=$_POST['email'];
- $val->max_length=75;
-
- if (!isset($_POST['create_email']))
- {
- $val->required=true;
- }
-
- $val->expression="^([a-z0-9]+)([._-]([a-z0-9]+))*[@]([a-z0-9]+)([._-]([a-z0-9]+))*[.]([a-z0-9]){2}([a-z0-9])?([a-z0-9])?$";
- $val->validate_input();
-
- $val->error_match = $error_match_pass;
- $val->name="pass1";
- $val->match1=$_POST['pass1'];
- $val->match2=$_POST['pass2'];
- $val->validate_input();
-
- if (!$val->validated)
- {
- $error ="<p class='Error'>".$errors_in_form."</p>";
- //check if username already exists
- }elseif($users->get_profile_by_username($_POST['username']))
- {
- $error = "<p class='Error'>".$error_username_exists."</p>";
- //check if email is already registered
- }elseif($users->email_exists($_POST['email']))
- {
- $error = "<p class='Error'>".$error_email_exists."</p>";
- }else
- {
- $birthday = date_to_db_date($_POST['birthday']);
-
- $email = ($_POST['email'] == '') ? $_POST['username'].'@'.$GO_CONFIG->inmail_host : $_POST['email'];
-
- //get a new acl_id for the user
- if ($acl_id = $GO_SECURITY->get_new_acl($email))
- {
- $create_samba_user = isset($_POST['create_samba_user']) ? true : false;
- $middle_name = trim($_POST['middle_name']);
- $authcode = $users->random_password();
- //register the new user. function returns new user_id or -1 on failure.
- if ($new_user_id = $users->add_user($_POST['username'],$_POST['pass1'], $_POST['first_name'], $middle_name, $_POST['last_name'], $_POST['initials'], $_POST['title'], $_POST['sex'], $birthday, $email, $authcode, $_POST['work_phone'], $_POST['home_phone'], $_POST['fax'], $_POST['cellular'], $_POST['country'], $_POST['state'], $_POST['city'], $_POST['zip'], $_POST['address'], $_POST['company'], $_POST['work_country'], $_POST['work_state'], $_POST['work_city'], $_POST['work_zip'], $_POST['work_address'], $_POST['work_fax'], $_POST['homepage'], $_POST['department'], $_POST['function'], $_POST['language'], $_POST['theme'], $acl_id, $create_samba_user))
- {
- $GO_SECURITY->set_acl_owner($acl_id, $new_user_id);
-
- if (isset($_POST['create_email']))
- {
- require_once($GO_CONFIG->class_path."email.class.inc");
- $email_client = new email();
- require($GO_LANGUAGE->get_language_file('email'));
- if (!$account_id = $email_client->add_account($new_user_id, $GO_CONFIG->inmail_type,$GO_CONFIG->local_email_host, $GO_CONFIG->inmail_port, $GO_CONFIG->inmail_root, $_POST['username'], $_POST['pass1'], $_POST['name'], $_POST['username']."@".$GO_CONFIG->inmail_host, "", $ml_sent_items, $ml_spam, $ml_trash))
- {
- echo "<p class=\"Error\">".$registration_email_error."</p>";
- echo "<p class=\"Error\">".$email_client->last_error."</p>";
- }
- }
-
- //send email to the user with password
- $middle_name = $middle_name == '' ? '' : $middle_name.' ';
-
- $registration_mail_body = str_replace("%sex%", $sir_madam[$_POST['sex']], $registration_mail_body);
- $registration_mail_body = str_replace("%last_name%", $_POST['last_name'], $registration_mail_body);
- $registration_mail_body = str_replace("%middle_name%", $middle_name, $registration_mail_body);
- $registration_mail_body = str_replace("%first_name%", $_POST['first_name'], $registration_mail_body);
- $registration_mail_body = str_replace("%username%",$_POST['username'], $registration_mail_body);
- $registration_mail_body = str_replace("%password%",$_POST['pass1'], $registration_mail_body);
- $registration_mail_body .= "\n\n".$GO_CONFIG->full_url;
- sendmail($email, $GO_CONFIG->webmaster_email, $GO_CONFIG->title, $registration_mail_subject, $registration_mail_body);
- //add the user to the everyone group
- require_once($GO_CONFIG->class_path."groups.class.inc");
- $groups = new groups();
- $groups->add_user_to_group($new_user_id,$GO_SECURITY->group_everyone);
-
- //add administrator to the users acl
- $GO_SECURITY->add_group_to_acl($GO_SECURITY->group_root, $acl_id);
-
- //add the user to it's own acl
- $GO_SECURITY->add_user_to_acl($new_user_id, $acl_id);
-
- //if user want's to be visible to any one add the everyone group to the users acl_id
- if (isset($_POST['visible']))
- {
- $GO_SECURITY->add_group_to_acl($GO_SECURITY->group_everyone, $acl_id);
- }
-
- //set module permissions
- for ($i=0;$i<count($module_acl);$i++)
- {
- $GO_SECURITY->add_user_to_acl($new_user_id, $_POST['module_acl'][$i]);
- }
-
- //create Group-Office home directory
- $old_umask = umask(000);
- mkdir($GO_CONFIG->file_storage_path.$_POST['username'], $GO_CONFIG->create_mode);
- umask($old_umask);
-
- //confirm registration to the user and exit the script so the form won't load
- echo $registration_success." <b>".$email."</b>";
- echo '<br /><br />';
- $button = new button($cmdContinue, "javascript:document.location='index.php';");
-
- echo '</td></tr></table>';
- require($GO_THEME->theme_path."footer.inc");
- exit;
- }else
- {
- $error = "<p class=\"Error\">".$registration_failure."</p>";
- }
- }else
- {
- $error = "<p class=\"Error\">".$registration_failure."</p>";
- }
- }
- }
- if (!$users->max_users_reached())
- {
- require("register_form.inc");
- }else
- {
- echo '<h1>'.$max_user_limit.'</h1>'.$max_users_text;
- }
- require($GO_THEME->theme_path."footer.inc");
- ?>
-