function attribute($attr) { switch ($attr) { case 'state_group': return eZContentObjectStateGroup::fetchByOffset(); default: return eZWorkflowEventType::attribute($attr); } }
/** * @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}