/**
  * @dataProvider providerCreateWithValidIdentifier
  */
 public function testCreateWithvalidIdentifier($identifier)
 {
     $row = array('identifier' => $identifier);
     $stateGroup = new eZContentObjectStateGroup($row);
     $trans = $stateGroup->translationByLocale('eng-GB');
     $trans->setAttribute('name', $identifier);
     $messages = array();
     $this->assertTrue($stateGroup->isValid($messages), "Valid state group identifier '{$identifier}' was refused, " . var_export($messages, true));
 }
コード例 #2
0
 function attribute($attr)
 {
     switch ($attr) {
         case 'state_group':
             return eZContentObjectStateGroup::fetchByOffset();
         default:
             return eZWorkflowEventType::attribute($attr);
     }
 }
コード例 #3
0
 function setParameters($parm_array)
 {
     // Make sure no unsupported parameters are specified
     $supported_parameters = array('state_group', 'state');
     $parm_keys = array_keys($parm_array);
     $unsupported_list = array_diff($parm_keys, $supported_parameters);
     if (isset($unsupported_list[0])) {
         return "Unsupported parameter '{$unsupported_list[0]}' in operation";
     }
     // Fetch state id's from the identifiers
     $state_group = eZContentObjectStateGroup::fetchByIdentifier($parm_array['state_group']);
     if ($state_group === false) {
         return 'Missing or illegal state group identifier';
     }
     $state_group_id = $state_group->attribute('id');
     $state = eZContentObjectState::fetchByIdentifier($parm_array['state'], $state_group_id);
     if ($state === false) {
         return 'Missing or illegal state identifier';
     }
     $this->state_id = $state->attribute('id');
     return true;
 }
コード例 #4
0
ファイル: view.php プロジェクト: EVE-Corp-Center/ECC-Website
<?php

/**
 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2012.8
 * @package kernel
 */
$Module = $Params['Module'];
$GroupIdentifier = $Params['GroupIdentifier'];
$StateIdentifier = $Params['StateIdentifier'];
$LanguageCode = $Params['Language'];
$group = eZContentObjectStateGroup::fetchByIdentifier($GroupIdentifier);
if (!is_object($group)) {
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
$state = $group->stateByIdentifier($StateIdentifier);
if (!is_object($state)) {
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
$currentAction = $Module->currentAction();
if ($currentAction == 'Edit') {
    return $Module->redirectTo("state/edit/{$GroupIdentifier}/{$StateIdentifier}");
}
if ($LanguageCode) {
    $state->setCurrentLanguage($LanguageCode);
}
$tpl = eZTemplate::factory();
$tpl->setVariable('group', $group);
$tpl->setVariable('state', $state);
$Result = array('content' => $tpl->fetch('design:state/view.tpl'), 'path' => array(array('url' => false, 'text' => ezpI18n::tr('kernel/state', 'State')), array('url' => 'state/group/' . $group->attribute('identifier'), 'text' => $group->attribute('identifier')), array('url' => false, 'text' => $state->attribute('identifier'))));
コード例 #5
0
ファイル: module.php プロジェクト: jordanmanning/ezpublish
<?php

/**
 * @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2013.11
 * @package kernel
 */
$Module = array('name' => 'eZContentObjectState', 'variable_params' => false);
$ViewList = array();
$ViewList['assign'] = array('default_navigation_part' => 'ezsetupnavigationpart', 'script' => 'assign.php', 'params' => array('ObjectID', 'SelectedStateID'), 'functions' => array('assign'), 'single_post_actions' => array('AssignButton' => 'Assign'), 'post_action_parameters' => array('Assign' => array('ObjectID' => 'ObjectID', 'SelectedStateIDList' => 'SelectedStateIDList', 'RedirectRelativeURI' => 'RedirectRelativeURI')));
$ViewList['groups'] = array('default_navigation_part' => 'ezsetupnavigationpart', 'script' => 'groups.php', 'params' => array(), 'functions' => array('administrate'), 'unordered_params' => array('offset' => 'Offset'), 'single_post_actions' => array('CreateButton' => 'Create', 'RemoveButton' => 'Remove'), 'post_action_parameters' => array('Remove' => array('RemoveIDList' => 'RemoveIDList')));
$ViewList['group'] = array('default_navigation_part' => 'ezsetupnavigationpart', 'script' => 'group.php', 'params' => array('GroupIdentifier', 'Language'), 'functions' => array('administrate'), 'single_post_actions' => array('CreateButton' => 'Create', 'UpdateOrderButton' => 'UpdateOrder', 'EditButton' => 'Edit', 'RemoveButton' => 'Remove'), 'post_action_parameters' => array('UpdateOrder' => array('Order' => 'Order'), 'Remove' => array('RemoveIDList' => 'RemoveIDList')));
$ViewList['group_edit'] = array('default_navigation_part' => 'ezsetupnavigationpart', 'script' => 'group_edit.php', 'ui_context' => 'edit', 'params' => array('GroupIdentifier'), 'functions' => array('administrate'), 'single_post_actions' => array('StoreButton' => 'Store', 'CancelButton' => 'Cancel'));
$ViewList['view'] = array('default_navigation_part' => 'ezsetupnavigationpart', 'script' => 'view.php', 'params' => array('GroupIdentifier', 'StateIdentifier', 'Language'), 'functions' => array('administrate'), 'single_post_actions' => array('EditButton' => 'Edit'));
$ViewList['edit'] = array('default_navigation_part' => 'ezsetupnavigationpart', 'script' => 'edit.php', 'ui_context' => 'edit', 'params' => array('GroupIdentifier', 'StateIdentifier'), 'functions' => array('administrate'), 'single_post_actions' => array('StoreButton' => 'Store', 'CancelButton' => 'Cancel'));
$ClassID = array('name' => 'Class', 'values' => array(), 'class' => 'eZContentClass', 'function' => 'fetchList', 'parameter' => array(0, false, false, array('name' => 'asc')));
$SectionID = array('name' => 'Section', 'values' => array(), 'class' => 'eZSection', 'function' => 'fetchList', 'parameter' => array(false));
$Assigned = array('name' => 'Owner', 'values' => array(array('Name' => 'Self', 'value' => '1')));
$AssignedGroup = array('name' => 'Group', 'single_select' => true, 'values' => array(array('Name' => 'Self', 'value' => '1')));
$Node = array('name' => 'Node', 'values' => array());
$Subtree = array('name' => 'Subtree', 'values' => array());
$stateLimitations = eZContentObjectStateGroup::limitations();
$NewState = array('name' => 'NewState', 'values' => array(), 'class' => 'eZContentObjectState', 'function' => 'limitationList', 'parameter' => array());
$FunctionList = array();
$FunctionList['administrate'] = array();
$FunctionList['assign'] = array('Class' => $ClassID, 'Section' => $SectionID, 'Owner' => $Assigned, 'Group' => $AssignedGroup, 'Node' => $Node, 'Subtree' => $Subtree);
$FunctionList['assign'] = array_merge($FunctionList['assign'], $stateLimitations, array('NewState' => $NewState));
コード例 #6
0
 public function group()
 {
     return eZContentObjectStateGroup::fetchById($this->GroupID);
 }
コード例 #7
0
ファイル: group_edit.php プロジェクト: legende91/ez
<?php

/**
 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2012.6
 * @package kernel
 */
$GroupIdentifier = $Params['GroupIdentifier'];
$Module = $Params['Module'];
$group = $GroupIdentifier === null ? new eZContentObjectStateGroup() : eZContentObjectStateGroup::fetchByIdentifier($GroupIdentifier);
if (!is_object($group)) {
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
if ($group->isInternal()) {
    return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
}
$tpl = eZTemplate::factory();
$currentAction = $Module->currentAction();
if ($currentAction == 'Cancel') {
    return $Module->redirectTo('state/groups');
} else {
    if ($currentAction == 'Store') {
        $group->fetchHTTPPersistentVariables();
        $messages = array();
        $isValid = $group->isValid($messages);
        if ($isValid) {
            $group->store();
            if ($GroupIdentifier === null) {
                return $Module->redirectTo('state/group/' . $group->attribute('identifier'));
            } else {
コード例 #8
0
 /**
  *
  *
  * @param integer $id
  */
 public static function removeByID($id)
 {
     $db = eZDB::instance();
     $db->begin();
     $states = eZContentObjectState::fetchByGroup($id);
     foreach ($states as $state) {
         eZContentObjectState::removeByID($state->attribute('id'));
     }
     eZPersistentObject::removeObject(eZContentObjectStateGroupLanguage::definition(), array('contentobject_state_group_id' => $id));
     eZPersistentObject::removeObject(eZContentObjectStateGroup::definition(), array('id' => $id));
     $db->commit();
 }
コード例 #9
0
 /**
  * Creates an array with sorting SQL strings to be appended to a query
  *
  * @param array|bool $sortList
  * @param string $treeTableName
  * @param bool $allowCustomColumns
  * @return array
  */
 static function createSortingSQLStrings($sortList, $treeTableName = 'ezcontentobject_tree', $allowCustomColumns = false)
 {
     $sortingInfo = array('sortCount' => 0, 'sortingFields' => " path_string ASC", 'attributeJoinCount' => 0, 'attributeFromSQL' => "", 'attributeTargetSQL' => "", 'attributeWhereSQL' => "");
     if ($sortList and is_array($sortList) and count($sortList) > 0) {
         if (count($sortList) > 1 and !is_array($sortList[0])) {
             $sortList = array($sortList);
         }
         $sortingFields = '';
         $sortCount = 0;
         $attributeJoinCount = 0;
         $stateJoinCount = 0;
         $attributeFromSQL = "";
         $attributeWhereSQL = "";
         $datatypeSortingTargetSQL = "";
         foreach ($sortList as $sortBy) {
             if (is_array($sortBy) and count($sortBy) > 0) {
                 if ($sortCount > 0) {
                     $sortingFields .= ', ';
                 }
                 $sortField = $sortBy[0];
                 switch ($sortField) {
                     case 'path':
                         $sortingFields .= 'path_string';
                         break;
                     case 'path_string':
                         $sortingFields .= 'path_identification_string';
                         break;
                     case 'published':
                         $sortingFields .= 'ezcontentobject.published';
                         break;
                     case 'modified':
                         $sortingFields .= 'ezcontentobject.modified';
                         break;
                     case 'modified_subnode':
                         $sortingFields .= 'modified_subnode';
                         break;
                     case 'section':
                         $sortingFields .= 'ezcontentobject.section_id';
                         break;
                     case 'node_id':
                         $sortingFields .= $treeTableName . '.node_id';
                         break;
                     case 'contentobject_id':
                         $sortingFields .= 'ezcontentobject.id';
                         break;
                     case 'depth':
                         $sortingFields .= 'depth';
                         break;
                     case 'class_identifier':
                         $sortingFields .= 'ezcontentclass.identifier';
                         break;
                     case 'class_name':
                         $classNameFilter = eZContentClassName::sqlFilter();
                         $sortingFields .= 'contentclass_name';
                         $datatypeSortingTargetSQL .= ", {$classNameFilter['nameField']} AS contentclass_name";
                         $attributeFromSQL .= " INNER JOIN {$classNameFilter['from']} ON ({$classNameFilter['where']})";
                         break;
                     case 'priority':
                         $sortingFields .= $treeTableName . '.priority';
                         break;
                     case 'name':
                         $sortingFields .= 'ezcontentobject_name.name';
                         break;
                     case 'attribute':
                         $classAttributeID = $sortBy[2];
                         if (!is_numeric($classAttributeID)) {
                             $classAttributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier($classAttributeID);
                         }
                         $contentAttributeTableAlias = "a{$attributeJoinCount}";
                         $datatypeFromSQL = "ezcontentobject_attribute {$contentAttributeTableAlias}";
                         $datatypeWhereSQL = "\n                                   {$contentAttributeTableAlias}.contentobject_id = ezcontentobject.id AND\n                                   {$contentAttributeTableAlias}.contentclassattribute_id = {$classAttributeID} AND\n                                   {$contentAttributeTableAlias}.version = ezcontentobject.current_version AND";
                         $datatypeWhereSQL .= eZContentLanguage::sqlFilter($contentAttributeTableAlias, 'ezcontentobject');
                         $dataType = eZDataType::create(eZContentObjectTreeNode::dataTypeByClassAttributeID($classAttributeID));
                         if (is_object($dataType) && $dataType->customSorting()) {
                             $params = array();
                             $params['contentobject_attr_id'] = "{$contentAttributeTableAlias}.id";
                             $params['contentobject_attr_version'] = "{$contentAttributeTableAlias}.version";
                             $params['table_alias_suffix'] = "{$attributeJoinCount}";
                             $sql = $dataType->customSortingSQL($params);
                             $datatypeFromSQL .= " INNER JOIN {$sql['from']} ON ({$sql['where']})";
                             $datatypeSortingFieldSQL = $sql['sorting_field'];
                             $datatypeSortingTargetSQL .= ', ' . $sql['sorting_field'];
                         } else {
                             // Look up datatype for standard sorting
                             $sortKeyType = eZContentObjectTreeNode::sortKeyByClassAttributeID($classAttributeID);
                             switch ($sortKeyType) {
                                 case 'string':
                                     $sortKey = 'sort_key_string';
                                     break;
                                 case 'int':
                                 default:
                                     $sortKey = 'sort_key_int';
                                     break;
                             }
                             $datatypeSortingFieldSQL = "a{$attributeJoinCount}.{$sortKey}";
                             $datatypeSortingTargetSQL .= ', ' . $datatypeSortingFieldSQL;
                         }
                         $sortingFields .= "{$datatypeSortingFieldSQL}";
                         $attributeFromSQL .= " INNER JOIN {$datatypeFromSQL} ON ({$datatypeWhereSQL})";
                         $attributeJoinCount++;
                         break;
                     case 'state':
                         $stateGroupID = $sortBy[2];
                         if (!is_numeric($stateGroupID)) {
                             $stateGroup = eZContentObjectStateGroup::fetchByIdentifier($stateGroupID);
                             if ($stateGroup) {
                                 $stateGroupID = $stateGroup->attribute('id');
                             } else {
                                 eZDebug::writeError("Unknown content object state group '{$stateGroupID}'");
                                 continue 2;
                             }
                         }
                         $stateAlias = "s{$stateJoinCount}";
                         $stateLinkAlias = "sl{$stateJoinCount}";
                         $sortingFields .= "{$stateAlias}.priority";
                         $datatypeSortingTargetSQL .= ", {$stateAlias}.priority";
                         $attributeFromSQL .= " INNER JOIN ezcobj_state {$stateAlias} ON ({$stateAlias}.group_id = {$stateGroupID})" . " INNER JOIN ezcobj_state_link {$stateLinkAlias}" . "     ON ({$stateLinkAlias}.contentobject_id = ezcontentobject.id AND {$stateLinkAlias}.contentobject_state_id = {$stateAlias}.id)";
                         break;
                     default:
                         if ($allowCustomColumns) {
                             $sortingFields .= $sortField;
                         } else {
                             eZDebug::writeWarning('Unknown sort field: ' . $sortField, __METHOD__);
                             continue;
                         }
                 }
                 $sortOrder = true;
                 // true is ascending
                 if (isset($sortBy[1])) {
                     $sortOrder = $sortBy[1];
                 }
                 $sortingFields .= $sortOrder ? " ASC" : " DESC";
                 ++$sortCount;
             }
         }
         $sortingInfo['sortCount'] = $sortCount;
         $sortingInfo['sortingFields'] = $sortingFields;
         $sortingInfo['attributeTargetSQL'] = $datatypeSortingTargetSQL;
         $sortingInfo['attributeJoinCount'] = $attributeJoinCount;
         $sortingInfo['attributeFromSQL'] = $attributeFromSQL;
         $sortingInfo['attributeWhereSQL'] = $attributeWhereSQL;
     } else {
         if ($sortList === array()) {
             $sortingInfo['sortingFields'] = '';
         }
     }
     return $sortingInfo;
 }
コード例 #10
0
$localeToUse = false;
$localeIDToUse = false;
// this script inserts English names, so preferably use an English locale
$preferredLocales = array('eng-GB', 'eng-US');
foreach ($preferredLocales as $preferredLocale) {
    if (in_array($preferredLocale, $locales)) {
        $localeToUse = $preferredLocale;
        break;
    }
}
// when none of the preferred locales are in use, then use the top priority language
if ($localeToUse === false) {
    $prioritizedLanguage = eZContentLanguage::topPriorityLanguage();
    $localeToUse = $prioritizedLanguage->attribute('locale');
}
$lockGroup = new eZContentObjectStateGroup(array('identifier' => 'ez_lock'));
$trans = $lockGroup->translationByLocale($localeToUse);
$trans->setAttribute('name', 'Lock');
$trans->setAttribute('description', 'Lock group');
$messages = array();
if ($lockGroup->isValid($messages)) {
    $cli->output('storing state group ez_lock');
    $lockGroup->store();
} else {
    eZDebug::writeDebug($messages);
    $db->rollback();
    $script->shutdown(2);
}
$notLockedState = $lockGroup->newState('not_locked');
$trans = $notLockedState->translationByLocale($localeToUse);
$trans->setAttribute('name', 'Not locked');
コード例 #11
0
    /**
     * @param eZUser|null $user
     * @return array
     */
    function allowedAssignStateList( eZUser $user = null )
    {
        $allowedStateIDList = $this->allowedAssignStateIDList( $user );

        // retrieve state groups, and for each state group the allowed states (including the current state)
        $groups = eZContentObjectStateGroup::fetchByOffset( false, false );

        $allowedAssignList = array();
        foreach ( $groups as $group )
        {
            // we do not return any internal state
            // all internal states are prepended with the string : "ez_"
            if( strpos( $group->attribute( 'identifier' ), 'ez' ) === 0 )
                continue;

            $states = array();
            $groupStates = $group->attribute( 'states' );

            $currentStateIDArray = $this->attribute( 'state_id_array' );

            $current = false;
            foreach ( $groupStates as $groupState )
            {
                $stateID = $groupState->attribute( 'id' );
                if ( in_array( $stateID, $allowedStateIDList ) )
                {
                    $states[] = $groupState;
                }

                if ( in_array( $stateID, $currentStateIDArray ) )
                {
                    $current = $groupState;
                }
            }

            $allowedAssignList[] = array( 'group' => $group, 'states' => $states, 'current' => $current );
        }
        return $allowedAssignList;
    }
);
$options = $script->getOptions( '', '', array( '-q' => 'Quiet mode' ) );

$cli = eZCLI::instance();

$script->initialize();
$script->startup();

$db = eZDB::instance();

$limit = 50;
$offset = 0;

while ( true )
{
    $groups = eZContentObjectStateGroup::fetchByOffset( $limit, $offset );
    if ( empty( $groups ) )
    {
        break;
    }
    foreach ( $groups as $group )
    {
        $cli->output( 'Fixing translations for group ' . $group->attribute( 'identifier' ), false );
        $groupId = $group->attribute( 'id' );
        $defaultLangId = $group->attribute( 'default_language_id' );

        // for the default language id, the correct record is the one with
        // the always available bit, so we delete records without it
        // ie language_id = real_language_id = $defaultLangId
        $queryDefaultLang = "DELETE FROM ezcobj_state_group_language
            WHERE contentobject_state_group_id={$groupId}
コード例 #13
0
    default:
        $limit = 10;
        break;
}
$languages = eZContentLanguage::fetchList();
$tpl = eZTemplate::factory();
eZDebug::writeDebug($Module->currentAction());
if ($Module->isCurrentAction('Remove') && $Module->hasActionParameter('RemoveIDList')) {
    $removeIDList = $Module->actionParameter('RemoveIDList');
    foreach ($removeIDList as $removeID) {
        $group = eZContentObjectStateGroup::fetchById($removeID);
        if ($group && !$group->isInternal()) {
            eZContentObjectStateGroup::removeByID($removeID);
        }
    }
} else {
    if ($Module->isCurrentAction('Create')) {
        return $Module->redirectTo('state/group_edit');
    }
}
$groups = eZContentObjectStateGroup::fetchByOffset($limit, $offset);
$groupCount = eZPersistentObject::count(eZContentObjectStateGroup::definition());
$viewParameters = array('offset' => $offset);
$tpl->setVariable('limit', $limit);
$tpl->setVariable('list_limit_preference_name', $listLimitPreferenceName);
$tpl->setVariable('list_limit_preference_value', $listLimitPreferenceValue);
$tpl->setVariable('groups', $groups);
$tpl->setVariable('group_count', $groupCount);
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('languages', $languages);
$Result = array('content' => $tpl->fetch('design:state/groups.tpl'), 'path' => array(array('url' => false, 'text' => ezpI18n::tr('kernel/state', 'State')), array('url' => false, 'text' => ezpI18n::tr('kernel/state', 'Groups'))));