00001 <?php
00002 abstract class GlobalEmailConfirm {
00009 private static function getConfirm($userId) {
00010 $confirm = AuthConfirmEmail::retrieve(array('userId' => $userId));
00011
00012 if(!$confirm) {
00013 $confirm = new AuthConfirmEmail;
00014 $confirm->userId = $userId;
00015 }
00016 return $confirm;
00017 }
00018
00026 public static function send($user, $confirmPage) {
00027
00028 if($user->emailConfirmed)
00029 return false;
00030
00031
00032 if($user->ldapUserId) {
00033 return false;
00034 }
00035
00036
00037 $confirm = self::getConfirm($user->id);
00038
00039
00040 $hash = SRandom::hex(32);
00041 $confirm->hash = $hash;
00042 $confirm->commit();
00043
00044
00045
00046 $values = array(
00047 'confirmurl' => $confirmPage . '?userId=' .$user->id . '&hash=' . $hash,
00048 'username' => $user->username
00049 );
00050
00051 AuthEmail::renderTemplate('confirmEmail', $user->email, $values);
00052 return true;
00053 }
00054
00063 public static function checkConfirm($user, $hash) {
00064 $confirm = AuthConfirmEmail::retrieve(array('userId' => $user->id));
00065 if($confirm) {
00066 $user->emailConfirmed = true;
00067 $user->commit();
00068 return true;
00069 }
00070 return false;
00071 }
00072 }
00073 ?>