Exemple #1
0
 protected function actionDelete()
 {
     $aParams = $this->getParams();
     $iUser = intval($aParams["delete"]);
     if ($this->actionDeleteConfirmed() !== false) {
         # catching Exception thrown when model already destroyed
         # happens when user refreshes delete-page, for instance
         try {
             $oUser = new \Baikal\Model\User($iUser);
             $oUser->destroy();
         } catch (\Exception $e) {
             # user is already deleted; silently discarding
         }
         # Redirecting to admin home
         \Flake\Util\Tools::redirectUsingMeta($this->link());
     } else {
         $oUser = new \Baikal\Model\User($iUser);
         $this->aMessages[] = \Formal\Core\Message::warningConfirmMessage("Check twice, you're about to delete " . $oUser->label() . "</strong> from the database !", "<p>You are about to delete a user and all it's calendars / contacts. This operation cannot be undone.</p><p>So, now that you know all that, what shall we do ?</p>", $this->linkDeleteConfirm($oUser), "Delete <strong><i class='" . $oUser->icon() . " icon-white'></i> " . $oUser->label() . "</strong>", $this->link());
     }
 }
 /**
  * create an internal user, when user not exists
  *
  * @param string $username
  */
 private function autoUserCreation($username)
 {
     /* get account values from backend */
     $values = $this->getAccountValues($username);
     if (!isset($values['displayname']) or strlen($values['displayname']) === 0) {
         $values['displayname'] = $username;
     }
     if (!isset($values['email']) or strlen($values['email']) === 0) {
         if (filter_var($username, FILTER_VALIDATE_EMAIL)) {
             $values['email'] = $username;
         } else {
             $values['email'] = 'unset-mail';
         }
     }
     /* create user */
     $user = new \Baikal\Model\User();
     $user->set('username', $username);
     $user->set('displayname', $values['displayname']);
     $user->set('email', $values['email']);
     $user->persist();
 }