updateAlwaysAvailable() public static method

Set the always available flag for a content object
public static updateAlwaysAvailable ( integer $objectID, integer $newAlwaysAvailable ) : array
$objectID integer
$newAlwaysAvailable integer
return array An array with operation status, always true
 function runOperation(&$node)
 {
     if (eZOperationHandler::operationIsAvailable('content_updatealwaysavailable')) {
         $operationResult = eZOperationHandler::execute('content', 'updatealwaysavailable', array('object_id' => $node->attribute('contentobject_id'), 'new_always_available' => $this->available, 'node_id' => $node->attribute('node_id')));
     } else {
         eZContentOperationCollection::updateAlwaysAvailable($node->attribute('contentobject_id'), $this->available);
     }
     return true;
 }
Beispiel #2
0
            $operationResult = eZOperationHandler::execute('content', 'updateinitiallanguage', array('object_id' => $objectID, 'new_initial_language_id' => $newInitialLanguageID, 'node_id' => $nodeID));
        } else {
            eZContentOperationCollection::updateInitialLanguage($objectID, $newInitialLanguageID);
        }
    }
    return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
} else {
    if ($module->isCurrentAction('UpdateAlwaysAvailable')) {
        if (!$object->canEdit()) {
            return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel', array());
        }
        $newAlwaysAvailable = $module->hasActionParameter('AlwaysAvailable');
        if (eZOperationHandler::operationIsAvailable('content_updatealwaysavailable')) {
            $operationResult = eZOperationHandler::execute('content', 'updatealwaysavailable', array('object_id' => $objectID, 'new_always_available' => $newAlwaysAvailable, 'node_id' => $nodeID));
        } else {
            eZContentOperationCollection::updateAlwaysAvailable($objectID, $newAlwaysAvailable);
        }
        return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
    } else {
        if ($module->isCurrentAction('RemoveTranslation')) {
            if (!$module->hasActionParameter('LanguageID')) {
                return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
            }
            $languageIDArray = $module->actionParameter('LanguageID');
            if ($module->hasActionParameter('ConfirmRemoval') && $module->actionParameter('ConfirmRemoval')) {
                if (eZOperationHandler::operationIsAvailable('content_removetranslation')) {
                    $operationResult = eZOperationHandler::execute('content', 'removetranslation', array('object_id' => $objectID, 'language_id_list' => $languageIDArray, 'node_id' => $nodeID));
                } else {
                    eZContentOperationCollection::removeTranslation($objectID, $languageIDArray);
                }
                return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
Beispiel #3
0
 /**
  * Ensures that eZURLAliasML::fetchPathByActionList() always uses prioritized languages,
  * even if a locale is enforced (3rd param) and always available flag is false.
  *
  * @see http://issues.ez.no/19055
  * @group issue19055
  * @covers eZURLAliasML::fetchPathByActionList
  */
 public function testFetchPathByActionListWithFallback()
 {
     $frenchLocale = $this->frenchLanguage->attribute('locale');
     ezpINIHelper::setINISettings(array(array('site.ini', 'RegionalSettings', 'ContentObjectLocale', $frenchLocale), array('site.ini', 'RegionalSettings', 'Locale', $frenchLocale), array('site.ini', 'RegionalSettings', 'SiteLanguageList', array($frenchLocale, 'eng-GB')), array('site.ini', 'RegionalSettings', 'ShowUntranslatedObjects', 'disabled')));
     eZContentOperationCollection::updateAlwaysAvailable(1, false);
     /*
      * - Create a content object in Norsk
      * - Remove AlwaysAvailable flag
      * - Add a translation in english
      * - Try to fetch path for this content in French (fallback is eng-GB as configured above)
      */
     $folder = new ezpObject('folder', 2, 14, 1, $this->norskLanguage->attribute('locale'));
     $folder->name = 'norsk folder';
     $folder->publish();
     eZContentOperationCollection::updateAlwaysAvailable($folder->object->attribute('id'), false);
     $folder->refresh();
     $folder->addTranslation('eng-GB', array('name' => 'english translation'));
     $folder->publish();
     $generatedPath = eZURLAliasML::fetchPathByActionList('eznode', array($folder->mainNode->node_id), $frenchLocale);
     self::assertNotNull($generatedPath);
     self::assertEquals('english-translation', $generatedPath);
     eZContentOperationCollection::updateAlwaysAvailable(1, true);
     ezpINIHelper::restoreINISettings();
     $folder->remove();
 }
<?php

$params = array(
    'ClassFilterArray' => array ('publisher_folder'),
    'ClassFilterType' => 'include',
    'Depth' => 1,
    'Limit' => 1000,
    'AsObject' => false,
);

$nodes = eZContentObjectTreeNode::subTreeByNodeID( $params, 59);

echo "To treat : " . count($nodes) . "\n";

foreach ( $nodes as $node )
{
    $objectId = $node['contentobject_id'];

    eZContentOperationCollection::updateAlwaysAvailable( $objectId, true );
}


    /**
     * Update null field only for active language
     * @param SQLIContent $content
     * @param string $activeLanguage
     * @throws SQLIContentException
     */
    public function publish( SQLIContent $content )
    {
        $options = array('modification_check' => false);
        $this->setOptions(new SQLIContentPublishOptions($options));

        $initialLocations = array();

        if( $content->isNew() && !$this->options['parent_node_id'] ) // parent_node_id is mandatory for new content
        {
            // Check for initial locations that may have been registered in content
            if( $content->hasInitialLocations() )
            {
                $initialLocations = $content->getInitialLocations();
                $initialMainLocation = array_shift( $initialLocations );
                $this->options['parent_node_id'] = $initialMainLocation->getNodeID();
            }
            else
            {
                throw new SQLIContentException( __METHOD__.' : Initial location or "parent_node_id" option not defined for new content !' );
            }
        }

        $contentObject  = $content->getRawContentObject();
        $db             = eZDB::instance();

        $db->begin();

        $canPublish     = false;
        $version        = null;
        $activeLanguage = $content->fields->getActiveLanguage();

        // Loop against all fieldsets (by language) and edit attributes
        foreach( $content->fields as $lang => $fieldset )
        {
            // Publish only if necessary and/or allowed (will let $canPublish to false)
            if( !$this->publicationAllowed( $content, $lang ) )
            {
                $msg = 'Content object #'.$contentObject->attribute( 'id' ).' in language '.$lang.' has no need to be modified';
                eZDebug::writeNotice( $msg, __METHOD__ );
                continue;
            }

            // Create new $version only if necessary (this is an optimization : $version->removeThis() is very very slow !)
            if ( is_null( $version ) )
            {
                $version = $this->createNewVersion( $content );
            }

            $canPublish = true;
            $fieldset->refreshDataMap( $version );

            // Now store attributes one by one
            foreach( $fieldset as $fieldName => $field )
            {
                $data = $field->getData();

                // For non active language, don't update field if its data is null and "update_null_field" option is false
                if( $lang != $activeLanguage && is_null( $data ) )
                    continue;

                self::storeAttributeFromString($field, $data);
            }
        }

        $db->commit();

        // Publication is allowed (content modified)
        if( $canPublish )
        {
            // Now do publish for current language
            eZDebug::accumulatorStart( 'sqlicontentpublisher_publish', 'sqlicontentpublisher', 'Publishing object #'.$contentObject->attribute( 'id' ) );
            $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id'    => $contentObject->attribute( 'id' ),
                                                                                         'version'      => $version->attribute( 'version' ) ) );
            eZDebug::accumulatorStop( 'sqlicontentpublisher_publish' );

            // Now cleaning
            $contentObject->cleanupInternalDrafts();
            $content->refresh();
            $content->addPendingClearCacheIfNeeded();

            // Handling additional "initial" locations. Only for new content
            if( count( $initialLocations ) > 0 )
            {
                foreach( $initialLocations as $initialAdditionalLocation )
                {
                    $this->addLocationToContent( $initialAdditionalLocation , $content);
                }
            }

            if ( $content->getRawContentObject()->attribute('class_identifier') == 'publisher_folder' )
            {
                eZContentOperationCollection::updateAlwaysAvailable( $content->getRawContentObject()->attribute('id'), true );
            }
        }
        else
        {
            throw new MMSynchException('Nothing to publish for publisher');
        }

        // Now cleaning internal options
        $this->options['parent_node_id'] = null;
    }