function controller_account_create($args) { if (!User::authorized("mail")) { throw new Exception("not allowed"); } $vars["account"] = new MailAccount(); if (!empty($args["domain"])) { $vars["account"]->domain = $args["domain"]->domain; } if (!empty($args["account"])) { foreach ($args["account"] as $k => $v) { $vars["account"]->{$k} = $k == "pass" && !empty($v) ? md5($v) : $v; } $vars["success"] = 0; // FIXME - this is ugly and could just be done with $vars["account"]->isValid() if we cleaned up validators if (!empty($vars["account"]->username) && !empty($vars["account"]->domain) && (!empty($vars["account"]->forward) && empty($vars["account"]->pass) || !empty($vars["account"]->pass) && empty($vars["account"]->forward))) { if (empty($vars["account"]->forward)) { $vars["account"]->maildir = "_virtual_/" . $vars["account"]->domain . "/" . $vars["account"]->username . "/"; } try { $this->orm->save($vars["account"]); $vars["success"] = 1; header("Location: /elation/mail/?domain=" . urlencode($vars["account"]->domain)); } catch (Exception $e) { } } else { } } return $this->GetComponentResponse("./account_create.tpl", $vars); }
public function getUser() { // $user = User::register(array('email' => 'smoren', 'password' => '123', 'name' => 'Smoren Freelight')); // $user = User::login('smoren', '123', true); // User::logout(); if ($user = User::authorized()) { echo "authorized\n"; } else { echo "NOT authorized\n"; } print_r(array(User::error())); print_r($user); return Response::text('end'); }