private static function sendWelcomeEmail($user_name, $user_email) { $subject = Config::get('email.welcome.subject'); $body = Config::get('email.welcome.content'); $mail = new \Iubar\Login\Core\EmailSender(); $mail->setTo($user_email); $mail->setSubject($subject); $mail->setBodyHtml($body); $mail_sent = $mail->go(true); if ($mail_sent) { Session::add(Session::SESSION_FEEDBACK_POSITIVE, Text::get('FEEDBACK_WELCOME_MAIL_SENDING_SUCCESSFUL')); return true; } else { Session::add(Session::SESSION_FEEDBACK_NEGATIVE, Text::get('FEEDBACK_WELCOME_MAIL_SENDING_ERROR')); return false; } }
/** * Removes the avatar image file from the filesystem * * @param string $userName * @return bool */ public static function deleteAvatarImageFile($userName) { $avatarId = $this->getIdForImage($userName); // Check if file exists if (!file_exists(Config::get('avatar.path') . $avatarId . ".jpg")) { Session::add(Session::SESSION_FEEDBACK_NEGATIVE, Text::get("FEEDBACK_AVATAR_IMAGE_DELETE_NO_FILE")); return false; } // Delete avatar file if (!unlink(Config::get('avatar.path') . $avatarId . ".jpg")) { Session::add(Session::SESSION_FEEDBACK_NEGATIVE, Text::get("FEEDBACK_AVATAR_IMAGE_DELETE_FAILED")); return false; } return true; }
/** * Deletes the cookie * It's necessary to split deleteCookie() and logout() as cookies are deleted without logging out too! * Sets the remember-me-cookie to ten years ago (3600sec * 24 hours * 365 days * 10). * that's obviously the best practice to kill a cookie @see http://stackoverflow.com/a/686166/1114320 */ public static function deleteCookie($user_name = null) { // is $user_name was set, then clear remember_me token in database if ($user_name) { $user_name = Filter::html_entity_invert($user_name); $user = UserModel::getByUsername($user_name); $user->setRemembermetoken(NULL); $em = DbResource::getEntityManager(); $em->persist($user); $em->flush(); } // delete remember_me cookie in browser setcookie(self::COOKIE_REMEMBER_ME, false, time() - 3600 * 24 * 3650, Config::get('cookie.path'), Config::get('cookie.domain'), Config::get('cookie.secure'), Config::get('cookie.http')); }
/** * Send the password reset mail * * @param string $user_name username * @param string $user_password_reset_hash password reset hash * @param string $user_email user email * * @return bool success status */ public static function sendPasswordResetMail($user_name, $user_password_reset_hash, $user_email) { // create email body $app = \Slim\Slim::getInstance(); $url = $app->config('app.baseurl') . '/' . Config::get('email.pwdreset.url') . '/' . urlencode($user_password_reset_hash) . "?user_name=" . urlencode(Encryption::encrypt($user_name)); $subject = Config::get('email.pwdreset.subject'); $body = Config::get('email.pwdreset.content') . ' <a href="' . $url . '">' . $url . '</a>'; // create instance of EmailSender class, try sending and check $mail = new \Application\Core\EmailSender(); $mail->setTo($user_email); $mail->setSubject($subject); $mail->setBodyHtml($body); $mail_sent = $mail->go(true); if ($mail_sent) { Session::add(Session::SESSION_FEEDBACK_POSITIVE, Text::get('FEEDBACK_PASSWORD_RESET_MAIL_SENDING_SUCCESSFUL')); return true; } Session::add(Session::SESSION_FEEDBACK_NEGATIVE, Text::get('FEEDBACK_PASSWORD_RESET_MAIL_SENDING_ERROR')); return false; }