Exemplo n.º 1
0
 /**
  * Logs in the user if applied login and password is valid.
  *
  * @param string $login
  * @param string $password
  * @param bool $authenticationMatch
  * @return mixed eZUser or false
  */
 public static function loginUser($login, $password, $authenticationMatch = false)
 {
     $user = self::_loginUser($login, $password, $authenticationMatch);
     if ($user instanceof eZUser) {
         $userID = $user->attribute('contentobject_id');
         $paex = eZPaEx::getPaEx($userID, true);
         if ($paex instanceof eZPaEx && $paex->isExpired()) {
             self::passwordHasExpired($user);
             return false;
         } else {
             self::loginSucceeded($user);
             return $user;
         }
     } else {
         self::loginFailed($user, $login);
         return false;
     }
     return $user;
 }
Exemplo n.º 2
0
$mbpaexIni = eZINI::instance('mbpaex.ini');
// Fetch the user to use in the process
$updateChildrenUser = $mbpaexIni->variable('mbpaexSettings', 'UpdateChildrenUser');
// Default to admin if user is not found in the ini
if (!trim($updateChildrenUser)) {
    $updateChildrenUser = '******';
}
$user = eZUser::fetchByName($updateChildrenUser);
eZUser::setCurrentlyLoggedInUser($user, $user->attribute('contentobject_id'));
if ($user->isLoggedIn()) {
    $cli->output("eZPaEx: Update children process start");
    ini_set('max_execution_time', 0);
    ini_set('memory_limit', '-1');
    eZDebug::addTimingPoint('Fetch update pending list');
    // Get list of paex objects marked to updatechildren
    $pendingList = eZPaEx::fetchUpdateChildrenPendingList();
    $pendingListCount = count($pendingList);
    if (!$pendingListCount) {
        $cli->output("No pending update subtrees found");
    } else {
        $cli->output("Found " . $pendingListCount . " ezpaex objects with pending updatechildren");
        $pendingIdList = array();
        foreach ($pendingList as $pendingObject) {
            $pendingIdList[] = $pendingObject->attribute('contentobject_id');
        }
        // Fetch array of nodes corresponding to objects in the pendingIDList to sort them by depth
        $nodeArray = eZContentObjectTreeNode::findMainNodeArray($pendingIdList, false);
        // Make an array of objects ids with its deph based on the corresponding node
        $objectDepthList = array();
        foreach ($nodeArray as $key => $node) {
            $objectDepthList[0][$key] = $node["depth"];
<?php

/**
 * File containing the sendexpirynotifications CLI script
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @package ezmbpaex
 */
$cli->output("eZPaEx: Send expiry notifications process start");
ini_set('max_execution_time', 0);
ini_set('memory_limit', '-1');
eZDebug::addTimingPoint('Fetch notification pending list');
$paexPendingList = eZPaEx::fetchExpiryNotificationPendingList();
$paexPendingListCount = count($paexPendingList);
if (!$paexPendingListCount) {
    $cli->output("No pending update notifications found");
} else {
    $cli->output("Found " . $paexPendingListCount . " objects pending notification, send notifications:");
    $totalNotificationsSent = 0;
    eZDebug::addTimingPoint('Send notifications');
    foreach ($paexPendingList as $paexObject) {
        $userID = $paexObject->attribute('contentobject_id');
        $userObject = eZUser::fetch($userID);
        if ($userObject instanceof eZUser && $userObject->isEnabled()) {
            if (!$paexObject->sendExpiryNotification($userObject)) {
                $cli->output("Error sending notification. UserID: " . $userID);
            } else {
                $cli->output("Notification sent ok. UserID: " . $userID);
                $paexObject->setExpiryNotificationSent();
                $totalNotificationsSent++;
Exemplo n.º 4
0
 /**
  * Fetch the eZPaEx objects that have updatechildren flag set to 1
  *
  * @param bool $asObject
  * @return array of contentobject_id's corresponding to users that have to be notified
  */
 static function fetchUpdateChildrenPendingList($asObject = true)
 {
     $resultArray = array();
     $conds = array('updatechildren' => 1);
     $pendingList = eZPersistentObject::fetchObjectList(eZPaEx::definition(), null, $conds, null, null, $asObject);
     if (is_array($pendingList) && count($pendingList)) {
         foreach ($pendingList as $pendingItem) {
             $resultArray[$pendingItem->attribute('contentobject_id')] = $pendingItem;
         }
     }
     return $resultArray;
 }
Exemplo n.º 5
0
 /**
  * Returns the content.
  */
 function objectAttributeContent($contentObjectAttribute)
 {
     $paexID = $contentObjectAttribute->attribute("contentobject_id");
     $paex = eZPaEx::fetch($paexID);
     return $paex;
 }
Exemplo n.º 6
0
 }
 // The forgotPasswdObj was previously validated, fetch the corresponding user object
 $UserID = $forgotPasswdObj->attribute('user_id');
 $user = eZUser::fetch($UserID);
 $login = $user->attribute("login");
 $type = $user->attribute("password_hash_type");
 $hash = $user->attribute("password_hash");
 $site = $user->site();
 if ($newPassword == $confirmPassword) {
     if (!$user->validatePassword($newPassword)) {
         // if audit is enabled password changes should be logged
         eZAudit::writeAudit('user-forgotpassword-fail', array('UserID' => $UserID, 'Login' => $login, 'Comment: ' => 'Password not pass standard validation'));
         $tpl->setVariable('newPasswordNotValidate', true);
     } else {
         // Patch for use mbpaex::validatePassword
         $paex = eZPaEx::getPaEx($UserID);
         if (!$paex->validatePassword($newPassword)) {
             // if audit is enabled password changes should be logged
             eZAudit::writeAudit('user-forgotpassword-fail', array('UserID' => $UserID, 'Login' => $login, 'Comment: ' => 'Password not pass PAEX validation'));
             $tpl->setVariable('newPasswordNotValidate', true);
         } else {
             $newHash = $user->createHash($login, $newPassword, $site, $type);
             if ($newHash == $user->attribute('password_hash')) {
                 // if audit is enabled password changes should be logged
                 eZAudit::writeAudit('user-forgotpassword-fail', array('UserID' => $UserID, 'Login' => $login, 'Comment: ' => 'New and old password are the same'));
                 $tpl->setVariable('newPasswordMustDiffer', true);
             } else {
                 // if audit is enabled password changes should be logged
                 eZAudit::writeAudit('user-forgotpassword', array('UserID' => $UserID, 'Login' => $login, 'Comment: ' => 'Password changed successfully'));
                 $user->setAttribute("password_hash", $newHash);
                 $user->store();
Exemplo n.º 7
0
 /**
  * Unit test for eZPaEx::isUser()
  */
 public function testIsUser()
 {
     $this->assertTrue($this->paex->isUser(), "PaEx object should have been a user");
     $paex = new eZPaEx(array());
     $this->assertFalse($paex->isUser(), "PaEx object shouldn't have been a user");
 }
Exemplo n.º 8
0
}
$script->setUseDebugOutput($debugOutput);
$script->setAllowedDebugLevels($allowedDebugLevels);
$script->setUseDebugAccumulators($useDebugAccumulators);
$script->setUseDebugTimingPoints($useDebugTimingpoints);
$script->setUseIncludeFiles($useIncludeFiles);
$script->setDebugMessage("\n\n" . str_repeat('#', 36) . $cli->style('emphasize') . " DEBUG " . $cli->style('emphasize-end') . str_repeat('#', 36) . "\n");
$script->initialize();
if (!$script->isInitialized()) {
    $cli->error('Error initializing script: ' . $script->initializationError() . '.');
    $script->shutdown();
    exit;
}
$cli->output("eZPaEx: Set password last updated to current time in all existing users");
$db = eZDB::instance();
$db->setIsSQLOutputEnabled($showSQL);
$db->begin();
$def = eZPaEx::definition();
$table = $def['name'];
$current_time = time();
$query = "UPDATE {$table} SET password_last_updated = {$current_time}";
$db->query($query);
$db->commit();
// The transaction check
$transactionCounterCheck = eZDB::checkTransactionCounter();
if (isset($transactionCounterCheck['error'])) {
    $cli->error($transactionCounterCheck['error']);
}
$cli->output("eZPaEx: Done.");
$script->shutdown();
exit;