| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <15-Aug-2002 14:37:29 bf> 4 // 5 // SOFTWARE NAME: eZ publish 6 // SOFTWARE RELEASE: 3.9.0 7 // BUILD VERSION: 17785 8 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 9 // SOFTWARE LICENSE: GNU General Public License v2.0 10 // NOTICE: > 11 // This program is free software; you can redistribute it and/or 12 // modify it under the terms of version 2.0 of the GNU General 13 // Public License as published by the Free Software Foundation. 14 // 15 // This program is distributed in the hope that it will be useful, 16 // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 // GNU General Public License for more details. 19 // 20 // You should have received a copy of version 2.0 of the GNU General 21 // Public License along with this program; if not, write to the Free 22 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 // MA 02110-1301, USA. 24 // 25 // 26 function &makeTriggerArray( &$triggerList ) 27 { 28 $triggerArray = array(); 29 foreach ( array_keys( $triggerList ) as $key ) 30 { 31 $trigger =& $triggerList[$key]; 32 $newKey = $trigger->attribute( 'module_name' ) . '_' . $trigger->attribute( 'function_name' ) . '_' . $trigger->attribute( 'connect_type' ); 33 $triggerArray[$newKey] =& $trigger; 34 } 35 return $triggerArray; 36 } 37 38 include_once ( 'kernel/classes/ezcontentobject.php' ); 39 include_once ( 'kernel/classes/ezcontentobjecttreenode.php' ); 40 include_once ( 'kernel/classes/ezcontentclass.php' ); 41 include_once ( 'kernel/common/template.php' ); 42 include_once ( 'kernel/classes/eztrigger.php' ); 43 include_once ( "kernel/classes/ezmodulemanager.php" ); 44 45 $http =& eZHTTPTool::instance(); 46 47 $Module =& $Params['Module']; 48 49 $moduleName= & $Params['ModuleName1']; 50 $functionName= & $Params['FunctionName1']; 51 52 $wfINI =& eZINI::instance( 'workflow.ini' ); 53 $operations = $wfINI->variableArray( 'OperationSettings', 'AvailableOperations' ); 54 $operations = array_unique( array_merge( $operations, $wfINI->variable( 'OperationSettings', 'AvailableOperationList' ) ) ); 55 $possibleTriggers = array(); 56 57 $triggers =& makeTriggerArray( eZTrigger::fetchList() ); 58 59 foreach ( $operations as $operation ) 60 { 61 if ( $operation == '' ) 62 { 63 continue; 64 } 65 $trigger = array(); 66 67 // the operation string has either two or three underscore characters. 68 // Eg: shop_checkout, before_shop_checkout, after_shop_checkout. 69 // Only the strings before and after are allowed in front of the module. 70 $explodedOperation = explode ('_', $operation); 71 $i = 0; 72 73 if (sizeof ($explodedOperation) >= 3) 74 { 75 if (strcmp($explodedOperation[$i], "before") == 0 || strcmp($explodedOperation[$i], "after") == 0) 76 $moduleParts = array ($explodedOperation[$i++]); 77 } 78 else 79 { 80 $moduleParts = array ("before", "after"); 81 } 82 83 foreach ($moduleParts as $trigger['connect_type']) 84 { 85 $trigger['module'] = $explodedOperation[$i]; // $i is either 0 or 1 86 $trigger['operation'] = $explodedOperation[$i + 1]; 87 $trigger['workflow_id'] = 0; 88 $trigger['key'] = $trigger['module'] . '_' . $trigger['operation'] . '_' . $trigger['connect_type'][0]; 89 $trigger['allowed_workflows'] = eZWorkflow::fetchLimited( $trigger['module'], $trigger['operation'], $trigger['connect_type'] ); 90 91 foreach ( array_keys ( $triggers ) as $key ) 92 { 93 $existendTrigger =& $triggers[$key]; 94 95 if ( $existendTrigger->attribute( 'module_name' ) == $trigger['module'] && 96 $existendTrigger->attribute( 'function_name' ) == $trigger['operation'] && 97 $existendTrigger->attribute( 'connect_type' ) == $trigger['connect_type'][0] ) 98 { 99 $trigger['workflow_id'] = $existendTrigger->attribute( 'workflow_id' ); 100 } 101 } 102 103 $possibleTriggers[] = $trigger; 104 } 105 } 106 107 if ( $http->hasPostVariable( 'StoreButton' ) ) 108 { 109 $db =& eZDB::instance(); 110 $db->begin(); 111 foreach ( array_keys( $possibleTriggers ) as $key ) 112 { 113 $trigger =& $possibleTriggers[$key]; 114 115 eZDebug::writeDebug( $trigger, "check trigger" ); 116 117 if ( $http->hasPostVariable( 'WorkflowID_' . $trigger['key'] ) ) 118 { 119 $workflowID = $http->postVariable( 'WorkflowID_' . $trigger['key'] ); 120 if( $workflowID != -1 ) 121 { 122 if ( !array_key_exists( $trigger['key'], $triggers ) ) 123 { 124 //create trigger 125 if ( $trigger['connect_type'] == 'before' ) 126 { 127 $connectType = 'b'; 128 } 129 else 130 { 131 $connectType = 'a'; 132 } 133 $newTrigger = eZTrigger::createNew( $trigger['module'], $trigger['operation'], $connectType, $workflowID ); 134 } 135 else 136 { 137 $existendTrigger =& $triggers[$trigger['key']]; 138 if ( $existendTrigger->attribute( 'workflow_id' ) != $workflowID ) 139 { 140 $existendTrigger =& $triggers[$trigger['key']]; 141 $existendTrigger->setAttribute( 'workflow_id', $workflowID ); 142 $existendTrigger->store(); 143 } 144 // update trigger 145 } 146 } 147 else if ( array_key_exists( $trigger['key'], $triggers ) ) 148 { 149 $existendTrigger =& $triggers[$trigger['key']]; 150 $existendTrigger->remove(); 151 //remove trigger 152 } 153 } 154 } 155 $db->commit(); 156 $Module->redirectToView( 'list' ); 157 158 } 159 160 161 if ( $moduleName == '' ) 162 { 163 $moduleName='*'; 164 } 165 if ( $functionName == '' ) 166 { 167 $functionName='*'; 168 } 169 170 if ( $http->hasPostVariable( 'RemoveButton' ) ) 171 { 172 if ( $http->hasPostVariable( 'DeleteIDArray' ) ) 173 { 174 $deleteIDArray = $http->postVariable( 'DeleteIDArray' ); 175 176 $db =& eZDB::instance(); 177 $db->begin(); 178 foreach ( $deleteIDArray as $deleteID ) 179 { 180 eZTrigger::remove( $deleteID ); 181 } 182 $db->commit(); 183 } 184 } 185 186 if ( $http->hasPostVariable( 'NewButton' ) ) 187 { 188 $trigger = eZTrigger::createNew( ); 189 } 190 191 192 $tpl =& templateInit(); 193 194 $triggers = eZTrigger::fetchList( array( 195 'module' => $moduleName, 196 'function' => $functionName 197 ) ); 198 $showModuleList = false; 199 $showFunctionList = false; 200 $functionList = array(); 201 $moduleList = array(); 202 if ( $moduleName == '*' ) 203 { 204 $showModuleList = true; 205 $moduleList = eZModuleManager::availableModules(); 206 } 207 elseif( $functionName == '*' ) 208 { 209 $mod =& eZModule::exists( $moduleName ); 210 $functionList = array_keys( $mod->attribute( 'available_functions' ) ); 211 eZDebug::writeNotice( $functionList, "functions" ); 212 $showFunctionList = true; 213 } 214 215 $tpl->setVariable( 'current_module', $moduleName ); 216 $tpl->setVariable( 'current_function', $functionName ); 217 $tpl->setVariable( 'show_functions', $showFunctionList ); 218 $tpl->setVariable( 'show_modules', $showModuleList ); 219 220 $tpl->setVariable( 'possible_triggers', $possibleTriggers ); 221 222 $tpl->setVariable( 'modules', $moduleList ); 223 $tpl->setVariable( 'functions', $functionList ); 224 225 $tpl->setVariable( 'triggers', $triggers ); 226 $tpl->setVariable( 'module', $Module ); 227 228 $Result['content'] =& $tpl->fetch( 'design:trigger/list.tpl' ); 229 $Result['path'] = array( array( 'text' => ezi18n( 'kernel/trigger', 'Trigger' ), 230 'url' => false ), 231 array( 'text' => ezi18n( 'kernel/trigger', 'List' ), 232 'url' => false ) ); 233 234 235 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |