Exemple #1
0
 public function install()
 {
     $this->db()->queryMulti($this->getInstallSql());
     $groupMapper = new \Modules\User\Mappers\Group();
     $adminGroup = $groupMapper->getGroupById(1);
     $usersGroup = $groupMapper->getGroupById(2);
     $userMapper = new \Modules\User\Mappers\User();
     $databaseConfig = new \Ilch\Config\Database($this->db());
     $databaseConfig->set('regist_accept', '1');
     $databaseConfig->set('regist_confirm', '1');
     $databaseConfig->set('regist_rules', '<p>Die Registrierung ist völlig kostenlos</p>
                           <p>Die Betreiber der Seite übernehmen keine Haftung.</p>
                           <p>Bitte verhalten Sie sich angemessen und mit Respekt gegenüber den anderen Community Mitgliedern.</p>');
     $databaseConfig->set('regist_confirm_mail', '<p>Hallo <b>{name}</b>,</p>
                           <p>&nbsp;</p>
                           <p>Willkommen auf <i>{sitetitle}</i>.</p>
                           <p>um die Registrierung erfolgreich abzuschlie&szlig;en klicken Sie Bitte auf folgenden Link.</p>
                           <p>{confirm}</p>
                           <p>&nbsp;</p>
                           <p>Mit freundlichen Gr&uuml;&szlig;en</p>
                           <p>Administrator</p>');
     $databaseConfig->set('password_change_mail', '<p>Hallo <b>{name}</b>,</p>
                           <p>&nbsp;</p>
                           <p>um Ihr Passwort auf <i>{sitetitle}</i> zu ändern klicken Sie Bitte auf folgenden Link.</p>
                           <p>{confirm}</p>
                           <p>&nbsp;</p>
                           <p>Mit freundlichen Gr&uuml;&szlig;en</p>
                           <p>Administrator</p>');
     $databaseConfig->set('avatar_uploadpath', 'application/modules/user/static/upload/avatar/');
     $databaseConfig->set('avatar_height', '120');
     $databaseConfig->set('avatar_width', '120');
     $databaseConfig->set('avatar_size', '51200');
     $databaseConfig->set('avatar_filetypes', 'jpg jpeg png gif');
     $databaseConfig->set('usergallery_allowed', '1');
     $databaseConfig->set('usergallery_uploadpath', 'application/modules/user/static/upload/gallery/');
     $databaseConfig->set('usergallery_filetypes', 'jpg jpeg png gif');
     $user = new \Modules\User\Models\User();
     $user->setName($_SESSION['install']['adminName']);
     $user->setPassword((new PasswordService())->hash($_SESSION['install']['adminPassword']));
     $user->setEmail($_SESSION['install']['adminEmail']);
     $user->addGroup($adminGroup);
     $user->addGroup($usersGroup);
     $dateCreated = new \Ilch\Date();
     $user->setDateConfirmed($dateCreated);
     $user->setDateCreated($dateCreated);
     $userMapper->save($user);
 }
Exemple #2
0
 public function inputAction()
 {
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuRegist'), array('action' => 'index'))->add($this->getTranslator()->trans('step2to3'), array('action' => 'input'));
     $registMapper = new UserMapper();
     $errors = array();
     if ($this->getRequest()->getPost('saveRegist')) {
         $name = $this->getRequest()->getPost('name');
         $password = $this->getRequest()->getPost('password');
         $password2 = $this->getRequest()->getPost('password2');
         $email = trim($this->getRequest()->getPost('email'));
         $captcha = trim(strtolower($this->getRequest()->getPost('captcha')));
         $profilName = $registMapper->getUserByName($name);
         $profilEmail = $registMapper->getUserByEmail($email);
         if (empty($_SESSION['captcha']) || $captcha != $_SESSION['captcha']) {
             $errors['captcha'] = 'invalidCaptcha';
         }
         if (!empty($profilName)) {
             $errors['name'] = 'nameExist';
         }
         if (!empty($profilEmail)) {
             $errors['email'] = 'emailExist';
         }
         if (empty($name)) {
             $errors['name'] = 'fieldEmpty';
         }
         if (empty($password)) {
             $errors['password'] = '******';
         }
         if (empty($password2)) {
             $errors['password2'] = 'fieldEmpty';
         }
         if ($password !== $password2) {
             $errors['password'] = '******';
             $errors['password2'] = 'fieldDiffersPassword';
         }
         if (empty($email)) {
             $errors['email'] = 'fieldEmpty';
         } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $errors['email'] = 'fieldEmail';
         }
         if (empty($errors)) {
             $groupMapper = new \Modules\User\Mappers\Group();
             $userGroup = $groupMapper->getGroupById(2);
             $currentDate = new \Ilch\Date();
             $model = new \Modules\User\Models\User();
             $model->setName($name);
             $model->setPassword((new PasswordService())->hash($password));
             $model->setEmail($email);
             $model->setDateCreated($currentDate);
             $model->addGroup($userGroup);
             if ($this->getConfig()->get('regist_confirm') == 0) {
                 $model->setDateConfirmed($currentDate);
             } else {
                 $confirmedCode = md5(uniqid(rand()));
                 $model->setConfirmed(0);
                 $model->setConfirmedCode($confirmedCode);
             }
             $registMapper->save($model);
             $_SESSION["name"] = $name;
             $_SESSION["email"] = $email;
             if ($this->getConfig()->get('regist_confirm') == 1) {
                 $sitetitle = $this->getConfig()->get('page_title');
                 $confirmCode = '<a href="' . BASE_URL . '/index.php/user/regist/confirm/code/' . $confirmedCode . '" class="btn btn-primary btn-sm">' . $this->getTranslator()->trans('confirmMailButtonText') . '</a>';
                 $date = new \Ilch\Date();
                 $layout = '';
                 if (isset($_SESSION['layout'])) {
                     $layout = $_SESSION['layout'];
                 }
                 if ($layout == $this->getConfig()->get('default_layout') && file_exists(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/user/layouts/mail/registconfirm.php')) {
                     $messageTemplate = file_get_contents(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/user/layouts/mail/registconfirm.php');
                 } else {
                     $messageTemplate = file_get_contents(APPLICATION_PATH . '/modules/user/layouts/mail/registconfirm.php');
                 }
                 $messageReplace = array('{content}' => $this->getConfig()->get('regist_confirm_mail'), '{sitetitle}' => $sitetitle, '{date}' => $date->format("l, d. F Y", true), '{name}' => $name, '{confirm}' => $confirmCode, '{footer}' => $this->getTranslator()->trans('noReplyMailFooter'));
                 $message = str_replace(array_keys($messageReplace), array_values($messageReplace), $messageTemplate);
                 $mail = new \Ilch\Mail();
                 $mail->setTo($email, $name)->setSubject($this->getTranslator()->trans('automaticEmail'))->setFrom($this->getTranslator()->trans('automaticEmail'), $sitetitle)->setMessage($message)->addGeneralHeader('Content-type', 'text/html; charset="utf-8"');
                 $mail->send();
             }
             $this->redirect(array('action' => 'finish'));
         }
         $this->getView()->set('errors', $errors);
     }
     $this->getView();
 }