Пример #1
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"];