+ function handler_accounts(PlPage $page)
+ {
+ $page->changeTpl('admin/accounts.tpl');
+ $page->setTitle('Administration - Comptes');
+ $page->addJsLink('password.js');
+
+ if (Post::has('create_account')) {
+ S::assert_xsrf_token();
+ $firstname = Post::t('firstname');
+ $lastname = strtoupper(Post::t('lastname'));
+ $sex = Post::b('sex') ? User::GENDER_FEMALE : User::GENDER_FEMALE;
+ $email = Post::t('email');
+ $login = PlUser::makeHrid($firstname, $lastname, 'ax');
+ if (!isvalid_email($email)) {
+ $page->trigError("Invalid email address: $email");
+ } else if (strlen(Post::s('pwhash')) != 40) {
+ $page->trigError("Invalid password hash");
+ } else {
+ $full_name = $firstname . ' ' . $lastname;
+ $directory_name = $lastname . ' ' . $firstname;
+ XDB::execute("INSERT INTO accounts (hruid, type, state, password,
+ registration_date, email, full_name,
+ display_name, sex, directory_name)
+ VALUES ({?}, 'ax', 'active', {?}, NOW(), {?}, {?}, {?}, {?}, {?})",
+ $login, Post::s('pwhash'), $email, $full_name, $full_name, $sex,
+ $directory_name);
+ }
+ }
+
+ $uf = new UserFilter(new UFC_AccountType('ax'));
+ $page->assign('users', $uf->iterUsers(new PlLimit(10)));
+
+ }
+
+ function handler_account_types(&$page, $action = 'list', $id = null)