Esempio n. 1
0
 static function removeUser($userID)
 {
     $user = eZUser::fetch($userID);
     if (!$user) {
         eZDebug::writeError("unable to find user with ID {$userID}", __METHOD__);
         return false;
     }
     eZUser::removeSessionData($userID);
     eZSubtreeNotificationRule::removeByUserID($userID);
     eZCollaborationNotificationRule::removeByUserID($userID);
     eZUserSetting::removeByUserID($userID);
     eZUserAccountKey::removeByUserID($userID);
     eZForgotPassword::removeByUserID($userID);
     eZWishList::removeByUserID($userID);
     eZGeneralDigestUserSettings::removeByUserId($userID);
     eZPersistentObject::removeObject(eZUser::definition(), array('contentobject_id' => $userID));
     return true;
 }
Esempio n. 2
0
 */

$tpl = eZTemplate::factory();
$tpl->setVariable( 'generated', false );
$tpl->setVariable( 'wrong_email', false );
$tpl->setVariable( 'link', false );
$tpl->setVariable( 'wrong_key', false );

$http = eZHTTPTool::instance();
$module = $Params['Module'];
$hashKey = $Params["HashKey"];
$ini = eZINI::instance();

if ( strlen( $hashKey ) == 32 )
{
    $forgotPasswdObj = eZForgotPassword::fetchByKey( $hashKey );
    if ( $forgotPasswdObj )
    {
        $userID = $forgotPasswdObj->attribute( 'user_id' );
        $user   = eZUser::fetch( $userID  );
        $email  = $user->attribute( 'email' );

        $ini = eZINI::instance();
        $passwordLength = $ini->variable( "UserSettings", "GeneratePasswordLength" );
        $newPassword = eZUser::createPassword( $passwordLength );

        $userToSendEmail = $user;

        $db = eZDB::instance();
        $db->begin();
Esempio n. 3
0
 static function removeUser($userID)
 {
     $user = eZUser::fetch($userID);
     if (!$user) {
         eZDebug::writeError("unable to find user with ID {$userID}", __METHOD__);
         return false;
     }
     eZUser::removeSessionData($userID);
     eZSubtreeNotificationRule::removeByUserID($userID);
     eZCollaborationNotificationRule::removeByUserID($userID);
     eZUserSetting::removeByUserID($userID);
     eZUserAccountKey::removeByUserID($userID);
     eZForgotPassword::removeByUserID($userID);
     eZWishList::removeByUserID($userID);
     // only remove general digest setting if there are no other users with the same e-mail
     $email = $user->attribute('email');
     $usersWithEmailCount = eZPersistentObject::count(eZUser::definition(), array('email' => $email));
     if ($usersWithEmailCount == 1) {
         eZGeneralDigestUserSettings::removeByAddress($email);
     }
     eZPersistentObject::removeObject(eZUser::definition(), array('contentobject_id' => $userID));
     return true;
 }
Esempio n. 4
0
    eZBasket::cleanup();
    $cli->output( "Removing all wishlists" );
    eZWishList::cleanup();
    $cli->output( "Removing all orders" );
    eZOrder::cleanup();
    $productCount = eZPersistentObject::count( eZProductCollection::definition() );
    if ( $productCount > 0 )
    {
        $cli->warning( "$productCount product collections still exists, must be a leak" );
    }
}

if ( $clean['forgotpassword'] )
{
    $cli->output( "Removing all forgot password requests" );
    eZForgotPassword::cleanup();
}

if ( $clean['workflow'] )
{
    $cli->output( "Removing all workflow processes and operation mementos" );
    eZOperationMemento::cleanup();
    eZWorkflowProcess::cleanup();
}

if ( $clean['collaboration'] )
{
    $cli->output( "Removing all collaboration elements" );
    eZCollaborationItem::cleanup();
}
 /**
  * Generate forgotpassword object
  *
  * @param int $userID
  * @param string $passwordHash
  * @param int $time
  *
  * @return array An array with operation status, always true if userID is ok
  */
 public static function forgotpassword($userID, $passwordHash, $time)
 {
     $user = eZUser::fetch($userID);
     if ($user instanceof eZUser) {
         $forgotPasswdObj = eZForgotPassword::createNew($userID, $passwordHash, $time);
         $forgotPasswdObj->store();
         return array('status' => true);
     } else {
         eZDebug::writeError("Failed to generate password hash for user {$userID} (could not fetch user)", __METHOD__);
         return array('status' => false);
     }
 }
 static function removeByUserID($userID)
 {
     eZPersistentObject::removeObject(eZForgotPassword::definition(), array('user_id' => $userID));
 }
Esempio n. 7
0
 $password = eZUser::createPassword($passwordLength);
 $passwordConfirm = $password;
 if ($module->hasActionParameter("Email") && eZMail::validate($module->actionParameter("Email"))) {
     $email = $module->actionParameter("Email");
     if (trim($email) != "") {
         $users = eZPersistentObject::fetchObjectList(eZUser::definition(), null, array('email' => $email), null, null, true);
     }
     if (!empty($users)) {
         $user = $users[0];
         $time = time();
         $hashKey = md5($time . ":" . mt_rand());
         $db = eZDB::instance();
         $db->begin();
         // Remove previous generated hash keys for same user
         eZForgotPassword::removeByUserID($user->id());
         $forgotPasswdObj = eZForgotPassword::createNew($user->id(), $hashKey, $time);
         $forgotPasswdObj->store();
         $userToSendEmail = $user;
         require_once "kernel/common/template.php";
         $receiver = $email;
         $mail = new eZMail();
         if (!$mail->validate($receiver)) {
         }
         $tpl = templateInit();
         $tpl->setVariable('user', $userToSendEmail);
         $tpl->setVariable('object', $userToSendEmail->attribute('contentobject'));
         $tpl->setVariable('password', $password);
         $tpl->setVariable('link', true);
         $tpl->setVariable('hash_key', $hashKey);
         $tpl->setVariable('hash_key_lifetime', date("d/m/Y H:i", time() + $forgotPasswdHashLifeTime));
         $http = eZHTTPTool::instance();