/** * Register a user and return errors if errors occurred * * @param array $inputs The user inputs in an array($columnName => $value) pairs to set the object * * @return array The occurred errors or success in a array */ public function register(array $inputs) : array { $success = false; $errors = $this->checkMustDefinedField(array_keys($inputs)); try { if (count($errors['SERVER']) === 0) { $query = 'SELECT MAX(id) FROM ' . (new User())->getTableName(); $this->entity->id = (int) DB::query($query)->fetchColumn() + 1; $this->bindInputs($inputs); $errors = $this->errors; if (count($errors) === 0) { $this->sendEmail(_('[awesomeChatRoom] Account created'), WebContentInclude::formatTemplate(WebContentInclude::getEmailTemplate('register'), ['firstName' => $this->entity->firstName, 'lastName' => $this->entity->lastName, 'password' => $inputs['password']])); $success = $this->saveEntity(); } } } catch (\Exception $e) { $errors['SERVER'] = _('Confirmation email failed to be sent by the server'); (new Logger())->log($e->getCode(), $e->getMessage()); } finally { return array('success' => $success, 'errors' => $errors, 'user' => $this->entity->__toArray()); } }
============================--> <?php WebContentInclude::includeDirectoryFiles(Ini::getParam('Web', 'pagesPath')); ?> <!--==== End of Pages ====--> <!--============================ = Modals = =============================--> <?php WebContentInclude::includeDirectoryFiles(Ini::getParam('Web', 'modalsPath')); ?> <!--==== End of Modals ====--> <!--============================ = Alerts = =============================--> <?php WebContentInclude::includeDirectoryFiles(Ini::getParam('Web', 'alertsPath')); ?> <!--==== End of Alerts ====--> </body> </html>