Example #1
0
 public function create_user()
 {
     // If there are no users then let's create one.
     $db = Database::get_instance();
     $db->query('SELECT * FROM `users` LIMIT 1');
     if ($db->has_rows() && !Auth::get_instance()->logged_in()) {
         Flash::set('<p class="flash validation">Sorry but to create new users, you must be logged in.</p>');
         Core_Helpers::redirect(WEB_ROOT . 'login/');
     }
     $validator = Error::instance();
     if (isset($_POST['email'])) {
         $validator->email($_POST['email'], 'email');
         $validator->blank($_POST['username'], 'username');
         $validator->blank($_POST['password'], 'password');
         $validator->passwords($_POST['password'], $_POST['confirm_password'], 'confirm_password');
         $user = new Users();
         if ($user->select(array('username' => $_POST['username']))) {
             $validator->add('username', 'The username <strong>' . htmlspecialchars($_POST['username']) . '</strong> is already taken.');
         }
         if ($validator->ok()) {
             $user = new Users();
             $user->load($_POST);
             $user->level = 'admin';
             $user->insert();
             Flash::set('<p class="flash success">User created successfully.</p>');
             Core_Helpers::redirect(WEB_ROOT . 'login/');
         }
     }
     $this->data['error'] = $validator;
     $this->load_template('create_user');
 }
Example #2
0
 function update()
 {
     $user = new Users();
     $user->select(array('id' => $this->id));
     // Because passwords are stored hashed, we don't want to hash a hash
     if ($user->password !== $this->password) {
         $this->password = Auth::get_instance()->create_hashed_password($this->password);
     }
     parent::update();
 }
Example #3
0
 function __construct($data = '')
 {
     // Kick out user if already logged in
     if (!Auth::get_instance()->logged_in()) {
         Flash::set('<p class="flash warning">You must be logged in to access admin.</p>');
         Core_Helpers::redirect(WEB_ROOT . 'login/');
     }
     $this->default_method = 'dashboard';
     $links_object = new Admin_Links();
     $data['header_links'] = $links_object->get_links();
     // Router uri = app/controller/method
     parent::__construct($data);
 }
<?php

require_once "/usr/share/kolab-webadmin/lib/functions.php";
require_once "/usr/share/kolab-webadmin/lib/api/kolab_api_service_user_types.php";
$conf = Conf::get_instance();
$primary_domain = $conf->get('kolab', 'primary_domain');
$ldappassword = $conf->get('ldap', 'bind_pw');
$_SESSION['user'] = new User();
$valid = $_SESSION['user']->authenticate("cn=Directory Manager", $ldappassword, $primary_domain);
if ($valid === false) {
    die("cannot authenticate user cn=Directory Manager");
}
$auth = Auth::get_instance();
$user_types = new kolab_api_service_user_types(null);
$list = $user_types->user_types_list(null, null);
# copy the entry for kolab
if ($list['list'][1]['key'] != 'kolab') {
    echo "failure: expected user type kolab at position 1, but found " . $list['list'][1]['key'] . "\n";
    die;
}
$kolabUserType = $list['list'][1];
$kolabUserType['id'] = 1;
$kolabUserType['type'] = 'user';
$kolabUserType['attributes']['fields']['objectclass'][] = 'tbitskolabuser';
$kolabUserType['attributes']['form_fields']['tbitskolablastlogin'] = array('type' => 'text-unixtimestamp', 'optional' => 1);
$kolabUserType['attributes']['form_fields']['tbitskolabisdomainadmin'] = array('type' => 'checkbox', 'optional' => 1);
$kolabUserType['attributes']['form_fields']['tbitskolabmaxaccounts'] = array('type' => 'text', 'optional' => 1);
$kolabUserType['attributes']['form_fields']['tbitskolaboverallquota'] = array('type' => 'text-quota', 'optional' => 1);
$kolabUserType['attributes']['form_fields']['tbitskolabdefaultquota'] = array('type' => 'text-quota', 'optional' => 1);
$service_type = new kolab_api_service_type(null);
if (false === $service_type->type_edit(null, $kolabUserType)) {