| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <19-Aug-2002 16:38:41 sp> 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 27 /*! \file edit.php 28 */ 29 30 include_once ( 'kernel/classes/ezmodulemanager.php' ); 31 include_once ( 'kernel/classes/ezrole.php' ); 32 include_once ( 'kernel/classes/ezpolicy.php' ); 33 34 include_once ( 'kernel/classes/ezsearch.php' ); 35 36 include_once ( 'lib/ezutils/classes/ezhttptool.php' ); 37 include_once ( 'lib/ezutils/classes/ezhttppersistence.php' ); 38 include_once ( 'lib/ezutils/classes/ezmodule.php' ); 39 40 include_once ( 'kernel/common/template.php' ); 41 42 $tpl =& templateInit(); 43 $Module =& $Params['Module']; 44 $roleID =& $Params['RoleID']; 45 46 $modules = eZModuleManager::availableModules(); 47 sort( $modules ); 48 49 $role = eZRole::fetch( 0, $roleID ); 50 if ( is_null( $role ) ) 51 { 52 $role = eZRole::fetch( $roleID ); 53 if ( $role ) 54 { 55 if ( $role->attribute( 'version' ) == '0' ) 56 { 57 $temporaryRole = $role->createTemporaryVersion(); 58 unset( $role ); 59 $role = $temporaryRole; 60 } 61 } 62 else 63 { 64 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 65 } 66 } 67 68 $http =& eZHTTPTool::instance(); 69 70 $tpl->setVariable( 'module', $Module ); 71 72 $role->turnOffCaching(); 73 74 $tpl->setVariable( 'role', $role ); 75 $Module->setTitle( 'Edit ' . $role->attribute( 'name' ) ); 76 77 if ( $http->hasPostVariable( 'NewName' ) && $role->attribute( 'name' ) != $http->postVariable( 'NewName' ) ) 78 { 79 $role->setAttribute( 'name' , $http->postVariable( 'NewName' ) ); 80 $role->store(); 81 // Set flag for audit. If true audit will be processed 82 $http->setSessionVariable( 'RoleWasChanged', true ); 83 } 84 85 $showModules = true; 86 $showFunctions = false; 87 $showLimitations = false; 88 $noFunctions = false; 89 $noLimitations = false; 90 91 if ( $http->hasPostVariable( 'Apply' ) ) 92 { 93 $originalRole = eZRole::fetch( $role->attribute( 'version' ) ); 94 $originalRoleName = $originalRole->attribute( 'name' ); 95 $originalRoleID = $originalRole->attribute( 'id' ); 96 97 // Who changes which role(s) should be logged. 98 if ( $http->hasSessionVariable( 'RoleWasChanged' ) and 99 $http->sessionVariable( 'RoleWasChanged' ) === true ) 100 { 101 include_once ( "kernel/classes/ezaudit.php" ); 102 eZAudit::writeAudit( 'role-change', array( 'Role ID' => $originalRoleID, 'Role name' => $originalRoleName, 103 'Comment' => 'Changed the current role: kernel/role/edit.php' ) ); 104 $http->removeSessionVariable( 'RoleWasChanged' ); 105 } 106 107 $originalRole->revertFromTemporaryVersion(); 108 include_once ( 'kernel/classes/ezcontentcachemanager.php' ); 109 eZContentCacheManager::clearAllContentCache(); 110 111 $Module->redirectTo( $Module->functionURI( 'view' ) . '/' . $originalRoleID . '/'); 112 113 /* Clean up policy cache */ 114 include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' ); 115 eZUser::cleanupCache(); 116 } 117 118 if ( $http->hasPostVariable( 'Discard' ) ) 119 { 120 $http->removeSessionVariable( 'RoleWasChanged' ); 121 122 $role = eZRole::fetch( $roleID ) ; 123 $originalRole = eZRole::fetch( $role->attribute( 'version') ); 124 $role->remove(); 125 if ( $originalRole != null && $originalRole->attribute( 'is_new' ) == 1 ) 126 { 127 $originalRole->remove(); 128 } 129 $Module->redirectTo( $Module->functionURI( 'list' ) . '/' ); 130 } 131 132 if ( $http->hasPostVariable( 'ChangeRoleName' ) ) 133 { 134 $role->setAttribute( 'name', $http->postVariable( 'NewName' ) ); 135 // Set flag for audit. If true audit will be processed 136 $http->setSessionVariable( 'RoleWasChanged', true ); 137 } 138 if ( $http->hasPostVariable( 'AddModule' ) ) 139 { 140 $currentModule = $http->postVariable( 'Modules' ); 141 $policy = eZPolicy::createNew( $roleID, array( 'ModuleName'=> $currentModule, 142 'FunctionName' => '*' ) ); 143 } 144 if ( $http->hasPostVariable( 'AddFunction' ) ) 145 { 146 $currentModule = $http->postVariable( 'CurrentModule' ); 147 $currentFunction = $http->postVariable( 'ModuleFunction' ); 148 eZDebugSetting::writeDebug( 'kernel-role-edit', $currentModule, 'currentModule'); 149 $policy = eZPolicy::createNew( $roleID, array( 'ModuleName'=> $currentModule, 150 'FunctionName' => $currentFunction ) ); 151 } 152 153 if ( $http->hasPostVariable( 'AddLimitation' ) ) 154 { 155 $policy = false; 156 157 if ( $http->hasSessionVariable( 'BrowsePolicyID' ) ) 158 { 159 $hasNodeLimitation = false; 160 $policy = eZPolicy::fetch( $http->sessionVariable( 'BrowsePolicyID' ) ); 161 if ( $policy ) 162 { 163 $limitationList = eZPolicyLimitation::fetchByPolicyID( $policy->attribute( 'id' ) ); 164 foreach ( $limitationList as $limitation ) 165 { 166 $limitationID = $limitation->attribute( 'id' ); 167 $limitationIdentifier = $limitation->attribute( 'identifier' ); 168 if ( $limitationIdentifier != 'Node' and $limitationIdentifier != 'Subtree' ) 169 eZPolicyLimitation::remove( $limitationID ); 170 if ( $limitationIdentifier == 'Node' ) 171 { 172 $nodeLimitationValues = eZPolicyLimitationValue::fetchList( $limitationID ); 173 if ( $nodeLimitationValues != null ) 174 $hasNodeLimitation = true; 175 else 176 eZPolicyLimitation::remove( $limitationID ); 177 } 178 179 if ( $limitationIdentifier == 'Subtree' ) 180 { 181 $nodeLimitationValues = eZPolicyLimitationValue::fetchList( $limitationID ); 182 if ( $nodeLimitationValues == null ) 183 eZPolicyLimitation::remove( $limitationID ); 184 } 185 } 186 187 // if ( !$hasNodeLimitation ) 188 { 189 $currentModule = $http->postVariable( 'CurrentModule' ); 190 $currentFunction = $http->postVariable( 'CurrentFunction' ); 191 192 $mod = & eZModule::exists( $currentModule ); 193 $functions =& $mod->attribute( 'available_functions' ); 194 $currentFunctionLimitations = $functions[ $currentFunction ]; 195 foreach ( $currentFunctionLimitations as $functionLimitation ) 196 { 197 if ( $http->hasPostVariable( $functionLimitation['name'] ) and 198 $functionLimitation['name'] != 'Node' and 199 $functionLimitation['name'] != 'Subtree' ) 200 { 201 $limitationValues = $http->postVariable( $functionLimitation['name'] ); 202 203 if ( !in_array( '-1', $limitationValues ) ) 204 { 205 $policyLimitation = eZPolicyLimitation::createNew( $policy->attribute('id'), $functionLimitation['name'], $currentModule, $currentFunction ); 206 foreach ( $limitationValues as $limitationValue ) 207 { 208 eZPolicyLimitationValue::createNew( $policyLimitation->attribute( 'id' ), $limitationValue ); 209 } 210 } 211 } 212 } 213 } 214 } 215 } 216 217 if ( !$policy ) 218 { 219 $currentModule = $http->postVariable( 'CurrentModule' ); 220 $currentFunction = $http->postVariable( 'CurrentFunction' ); 221 $policy = eZPolicy::createNew( $roleID, array( 'ModuleName'=> $currentModule, 222 'FunctionName' => $currentFunction, 223 'Limitation' => '' ) ); 224 225 $mod = & eZModule::exists( $currentModule ); 226 $functions =& $mod->attribute( 'available_functions' ); 227 $currentFunctionLimitations = $functions[ $currentFunction ]; 228 eZDebugSetting::writeDebug( 'kernel-role-edit', $currentFunctionLimitations, 'currentFunctionLimitations' ); 229 230 $db =& eZDB::instance(); 231 $db->begin(); 232 foreach ( $currentFunctionLimitations as $functionLimitation ) 233 { 234 if ( $http->hasPostVariable( $functionLimitation['name'] ) ) 235 { 236 $limitationValues = $http->postVariable( $functionLimitation['name'] ); 237 eZDebugSetting::writeDebug( 'kernel-role-edit', $limitationValues, 'limitationValues' ); 238 239 if ( !in_array('-1', $limitationValues ) ) 240 { 241 $policyLimitation = eZPolicyLimitation::createNew( $policy->attribute('id'), $functionLimitation['name'], $currentModule, $currentFunction ); 242 foreach ( $limitationValues as $limitationValue ) 243 { 244 eZPolicyLimitationValue::createNew( $policyLimitation->attribute( 'id' ), $limitationValue ); 245 } 246 } 247 } 248 } 249 $db->commit(); 250 } 251 } 252 253 if ( $http->hasPostVariable( 'RemovePolicy' ) ) 254 { 255 $policyID = $http->postVariable( 'RolePolicy' ) ; 256 eZDebugSetting::writeDebug( 'kernel-role-edit', $policyID, 'trying to remove policy' ); 257 eZPolicy::remove( $policyID ); 258 // Set flag for audit. If true audit will be processed 259 $http->setSessionVariable( 'RoleWasChanged', true ); 260 } 261 if ( $http->hasPostVariable( 'RemovePolicies' ) and 262 $http->hasPostVariable( 'DeleteIDArray' ) ) 263 { 264 $db =& eZDB::instance(); 265 $db->begin(); 266 foreach( $http->postVariable( 'DeleteIDArray' ) as $deleteID) 267 { 268 eZDebugSetting::writeDebug( 'kernel-role-edit', $deleteID, 'trying to remove policy' ); 269 eZPolicy::remove( $deleteID ); 270 } 271 $db->commit(); 272 // Set flag for audit. If true audit will be processed 273 $http->setSessionVariable( 'RoleWasChanged', true ); 274 } 275 276 277 if ( $http->hasPostVariable( 'CustomFunction' ) ) 278 { 279 $currentModule = $http->postVariable( 'Modules' ); 280 if ( $currentModule != '*' ) 281 { 282 $mod = & eZModule::exists( $currentModule ); 283 $functions =& $mod->attribute( 'available_functions' ); 284 $functionNames = array_keys( $functions ); 285 } 286 else 287 { 288 $functionNames = array(); 289 } 290 291 $showModules = false; 292 $showFunctions = true; 293 294 if ( count( $functionNames ) < 1 ) 295 { 296 $showModules = true; 297 $showFunctions = false; 298 $showLimitations = false; 299 $noFunctions = true; 300 } 301 302 $tpl->setVariable( 'current_module', $currentModule ); 303 $tpl->setVariable( 'functions', $functionNames ); 304 $tpl->setVariable( 'no_functions', $noFunctions ); 305 306 $Module->setTitle( 'Edit ' . $role->attribute( 'name' ) ); 307 $Result = array(); 308 309 $Result['path'] = array( array( 'url' => false , 310 'text' => ezi18n( 'kernel/role', 311 'Create new policy, step 2: select function' ) ) ); 312 313 $Result['content'] =& $tpl->fetch( 'design:role/createpolicystep2.tpl' ); 314 return; 315 } 316 317 if ( $http->hasPostVariable( 'DiscardFunction' ) ) 318 { 319 $showModules = true; 320 $showFunctions = false; 321 } 322 323 if ( $http->hasPostVariable( 'SelectButton' ) or 324 $http->hasPostVariable( 'BrowseCancelButton' ) or 325 $http->hasPostVariable( 'Limitation' ) or 326 $http->hasPostVariable( 'SelectedNodeIDArray' ) or 327 $http->hasPostVariable( 'BrowseLimitationNodeButton' ) or 328 $http->hasPostVariable( 'DeleteNodeButton' ) or 329 $http->hasPostVariable( 'BrowseLimitationSubtreeButton' ) or 330 $http->hasPostVariable( 'DeleteSubtreeButton' ) ) 331 { 332 $db =& eZDB::instance(); 333 $db->begin(); 334 if ( $http->hasPostVariable( 'DeleteNodeButton' ) and $http->hasSessionVariable( 'BrowsePolicyID' ) ) 335 { 336 if ( $http->hasPostVariable( 'DeleteNodeIDArray' ) ) 337 { 338 $deletedIDList = $http->postVariable( 'DeleteNodeIDArray' ); 339 340 foreach ( $deletedIDList as $deletedID ) 341 { 342 eZPolicyLimitationValue::removeByValue( $deletedID, $http->sessionVariable( 'BrowsePolicyID' ) ); 343 } 344 } 345 } 346 347 if ( $http->hasPostVariable( 'DeleteSubtreeButton' ) and $http->hasSessionVariable( 'BrowsePolicyID' ) ) 348 { 349 if ( $http->hasPostVariable( 'DeleteSubtreeIDArray' ) ) 350 { 351 $deletedIDList = $http->postVariable( 'DeleteSubtreeIDArray' ); 352 353 foreach ( $deletedIDList as $deletedID ) 354 { 355 $subtree = eZContentObjectTreeNode::fetch( $deletedID ); 356 $path = $subtree->attribute( 'path_string' ); 357 eZPolicyLimitationValue::removeByValue( $path, $http->sessionVariable( 'BrowsePolicyID' ) ); 358 } 359 } 360 } 361 362 if ( $http->hasPostVariable( 'Limitation' ) and $http->hasSessionVariable( 'BrowsePolicyID' ) ) 363 $http->removeSessionVariable( 'BrowsePolicyID' ); 364 365 if ( $http->hasSessionVariable( 'BrowseCurrentModule' ) ) 366 $currentModule = $http->sessionVariable( 'BrowseCurrentModule' ); 367 368 if ( $http->hasPostVariable( 'CurrentModule' ) ) 369 $currentModule = $http->postVariable( 'CurrentModule' ); 370 371 $mod = & eZModule::exists( $currentModule ); 372 $functions =& $mod->attribute( 'available_functions' ); 373 $functionNames = array_keys( $functions ); 374 375 $showModules = false; 376 $showFunctions = false; 377 $showLimitations = true; 378 $nodeList = array(); 379 $nodeIDList = array(); 380 $subtreeList = array(); 381 $subtreeIDList = array(); 382 383 // Check for temporary node and subtree policy limitation 384 if ( $http->hasSessionVariable( 'BrowsePolicyID' ) ) 385 { 386 $policyID = $http->sessionVariable( 'BrowsePolicyID' ); 387 // Fetch node limitations 388 $nodeLimitation = eZPolicyLimitation::fetchByIdentifier( $policyID, 'Node' ); 389 if ( $nodeLimitation != null ) 390 { 391 $nodeLimitationID = $nodeLimitation->attribute('id'); 392 $nodeLimitationValues = eZPolicyLimitationValue::fetchList( $nodeLimitationID ); 393 foreach ( $nodeLimitationValues as $nodeLimitationValue ) 394 { 395 $nodeID = $nodeLimitationValue->attribute( 'value' ); 396 $nodeIDList[] = $nodeID; 397 $node = eZContentObjectTreeNode::fetch( $nodeID ); 398 $nodeList[] = $node; 399 } 400 } 401 402 // Fetch subtree limitations 403 $subtreeLimitation = eZPolicyLimitation::fetchByIdentifier( $policyID, 'Subtree' ); 404 if ( $subtreeLimitation != null ) 405 { 406 $subtreeLimitationID = $subtreeLimitation->attribute('id'); 407 $subtreeLimitationValues = eZPolicyLimitationValue::fetchList( $subtreeLimitationID ); 408 409 foreach ( $subtreeLimitationValues as $subtreeLimitationValue ) 410 { 411 $subtreePath = $subtreeLimitationValue->attribute( 'value' ); 412 $subtreeObject = eZContentObjectTreeNode::fetchByPath( $subtreePath ); 413 if ( $subtreeObject ) 414 { 415 $subtreeID = $subtreeObject->attribute( 'node_id' ); 416 $subtreeIDList[] = $subtreeID; 417 $subtree = eZContentObjectTreeNode::fetch( $subtreeID ); 418 $subtreeList[] = $subtree; 419 } 420 } 421 } 422 } 423 424 if ( $http->hasSessionVariable( 'BrowseCurrentFunction' ) ) 425 $currentFunction = $http->sessionVariable( 'BrowseCurrentFunction' ); 426 427 if ( $http->hasPostVariable( 'CurrentFunction' ) ) 428 $currentFunction = $http->postVariable( 'CurrentFunction' ); 429 430 if ( $http->hasPostVariable( 'ModuleFunction' ) ) 431 $currentFunction = $http->postVariable( 'ModuleFunction' ); 432 433 $currentFunctionLimitations = array(); 434 foreach( array_keys( $functions[ $currentFunction ] ) as $key ) 435 { 436 $limitation =& $functions[ $currentFunction ][ $key ]; 437 if( count( $limitation[ 'values' ] == 0 ) && array_key_exists( 'class', $limitation ) ) 438 { 439 $basePath = 'kernel/'; //set default basepath for limitationValueClasses 440 if( array_key_exists( 'extension', $limitation ) && $limitation['extension'] ) 441 { 442 $basePath = 'extension/' . $limitation['extension'] . '/'; 443 } 444 include_once( $basePath . $limitation['path'] . $limitation['file'] ); 445 $obj = new $limitation['class']( array() ); 446 $limitationValueList = call_user_func_array ( array( &$obj , $limitation['function']) , $limitation['parameter'] ); 447 $limitationValueArray = array(); 448 foreach( $limitationValueList as $limitationValue ) 449 { 450 $limitationValuePair = array(); 451 $limitationValuePair['Name'] = $limitationValue[ 'name' ]; 452 $limitationValuePair['value'] = $limitationValue[ 'id' ]; 453 $limitationValueArray[] = $limitationValuePair; 454 } 455 $limitation[ 'values' ] = $limitationValueArray; 456 } 457 $currentFunctionLimitations[ $key ] = $limitation; 458 } 459 460 if ( count( $currentFunctionLimitations ) < 1 ) 461 { 462 $showModules = false; 463 $showFunctions = true; 464 $showLimitations = false; 465 $noLimitations = true; 466 } 467 468 469 if ( $http->hasPostVariable( 'BrowseLimitationSubtreeButton' ) || 470 $http->hasPostVariable( 'BrowseLimitationNodeButton' ) ) 471 { 472 // Store other limitations 473 if ( $http->hasSessionVariable( 'BrowsePolicyID' ) ) 474 { 475 $policy = eZPolicy::fetch( $http->sessionVariable( 'BrowsePolicyID' ) ); 476 $limitationList = eZPolicyLimitation::fetchByPolicyID( $policy->attribute( 'id' ) ); 477 foreach ( $limitationList as $limitation ) 478 { 479 $limitationID = $limitation->attribute( 'id' ); 480 $limitationIdentifier = $limitation->attribute( 'identifier' ); 481 if ( $limitationIdentifier != 'Node' and $limitationIdentifier != 'Subtree' ) 482 eZPolicyLimitation::remove( $limitationID ); 483 } 484 485 foreach ( $currentFunctionLimitations as $functionLimitation ) 486 { 487 if ( $http->hasPostVariable( $functionLimitation['name'] ) and 488 $functionLimitation['name'] != 'Node' and 489 $functionLimitation['name'] != 'Subtree' ) 490 { 491 $limitationValues = $http->postVariable( $functionLimitation['name'] ); 492 eZDebugSetting::writeDebug( 'kernel-role-edit', $limitationValues, 'limitationValues'); 493 494 if ( !in_array('-1', $limitationValues ) ) 495 { 496 $policyLimitation = eZPolicyLimitation::createNew( $policy->attribute('id'), $functionLimitation['name'], $currentModule, $currentFunction ); 497 foreach ( $limitationValues as $limitationValue ) 498 { 499 eZPolicyLimitationValue::createNew( $policyLimitation->attribute( 'id' ), $limitationValue ); 500 } 501 } 502 } 503 } 504 } 505 else 506 { 507 $policy = eZPolicy::createNew( $roleID, array( 'ModuleName'=> $currentModule, 508 'FunctionName' => $currentFunction, 509 'Limitation' => '') ); 510 511 $http->setSessionVariable( 'BrowsePolicyID', $policy->attribute('id') ); 512 foreach ( $currentFunctionLimitations as $functionLimitation ) 513 { 514 if ( $http->hasPostVariable( $functionLimitation['name'] )) 515 { 516 $limitationValues = $http->postVariable( $functionLimitation['name'] ); 517 eZDebugSetting::writeDebug( 'kernel-role-edit', $limitationValues, 'limitationValues'); 518 519 if ( !in_array( '-1', $limitationValues ) ) 520 { 521 $policyLimitation = eZPolicyLimitation::createNew( $policy->attribute('id'), $functionLimitation['name'], $currentModule, $currentFunction); 522 eZDebugSetting::writeDebug( 'kernel-role-edit', $policyLimitation, 'policyLimitationCreated' ); 523 foreach ( $limitationValues as $limitationValue ) 524 { 525 eZPolicyLimitationValue::createNew( $policyLimitation->attribute( 'id' ), $limitationValue ); 526 } 527 } 528 } 529 } 530 } 531 $db->commit(); 532 533 $http->setSessionVariable( 'BrowseCurrentModule', $currentModule ); 534 $http->setSessionVariable( 'BrowseCurrentFunction', $currentFunction ); 535 if ( $http->hasPostVariable( 'BrowseLimitationSubtreeButton' ) ) 536 { 537 538 include_once ( 'kernel/classes/ezcontentbrowse.php' ); 539 eZContentBrowse::browse( array( 'action_name' => 'FindLimitationSubtree', 540 'from_page' => '/role/edit/' . $roleID . '/' ), 541 $Module ); 542 } 543 elseif ( $http->hasPostVariable( 'BrowseLimitationNodeButton' ) ) 544 { 545 include_once ( 'kernel/classes/ezcontentbrowse.php' ); 546 eZContentBrowse::browse( array( 'action_name' => 'FindLimitationNode', 547 'from_page' => '/role/edit/' . $roleID . '/' ), 548 $Module ); 549 550 } 551 return; 552 } 553 554 if ( $http->hasPostVariable( 'SelectedNodeIDArray' ) and 555 $http->postVariable( 'BrowseActionName' ) == 'FindLimitationNode' and 556 !$http->hasPostVariable( 'BrowseCancelButton' ) ) 557 { 558 $selectedNodeIDList = $http->postVariable( 'SelectedNodeIDArray' ); 559 560 if ( $http->hasSessionVariable( 'BrowsePolicyID' ) ) 561 { 562 $policy = eZPolicy::fetch( $http->sessionVariable( 'BrowsePolicyID' ) ); 563 $limitationList = eZPolicyLimitation::fetchByPolicyID( $policy->attribute( 'id' ) ); 564 565 // Remove other limitations. When the policy is applied to node, no other constraints needed. 566 // Removes limitations only from a DropList if it is specified in the module. 567 if ( isset( $currentFunctionLimitations['Node']['DropList'] ) ) 568 { 569 $dropList = $currentFunctionLimitations['Node']['DropList']; 570 foreach ( $limitationList as $limitation ) 571 { 572 $limitationID = $limitation->attribute( 'id' ); 573 $limitationIdentifier = $limitation->attribute( 'identifier' ); 574 if ( in_array( $limitationIdentifier, $dropList ) ) 575 { 576 eZPolicyLimitation::remove( $limitationID ); 577 } 578 } 579 } 580 else 581 { 582 foreach ( $limitationList as $limitation ) 583 { 584 $limitationID = $limitation->attribute( 'id' ); 585 $limitationIdentifier = $limitation->attribute( 'identifier' ); 586 if ( $limitationIdentifier != 'Node' and $limitationIdentifier != 'Subtree' ) 587 eZPolicyLimitation::remove( $limitationID ); 588 } 589 } 590 } 591 else 592 { 593 $policy = eZPolicy::createNew( $roleID, array( 'ModuleName'=> $currentModule, 594 'FunctionName' => $currentFunction, 595 'Limitation' => '') ); 596 $http->setSessionVariable( 'BrowsePolicyID', $policy->attribute('id') ); 597 } 598 599 $nodeLimitation = eZPolicyLimitation::fetchByIdentifier( $policy->attribute('id'), 'Node' ); 600 if ( $nodeLimitation == null ) 601 $nodeLimitation = eZPolicyLimitation::createNew( $policy->attribute('id'), 'Node', $currentModule, $currentFunction); 602 603 foreach ( $selectedNodeIDList as $nodeID ) 604 { 605 if ( !in_array( $nodeID, $nodeIDList ) ) 606 { 607 $nodeLimitationValue = eZPolicyLimitationValue::createNew( $nodeLimitation->attribute( 'id' ), $nodeID ); 608 $node = eZContentObjectTreeNode::fetch( $nodeID ); 609 $nodeList[] = $node; 610 } 611 } 612 } 613 614 if ( $http->hasPostVariable( 'SelectedNodeIDArray' ) and 615 $http->postVariable( 'BrowseActionName' ) == 'FindLimitationSubtree' and 616 !$http->hasPostVariable( 'BrowseCancelButton' ) ) 617 { 618 $selectedSubtreeIDList = $http->postVariable( 'SelectedNodeIDArray' ); 619 if ( $http->hasSessionVariable( 'BrowsePolicyID' ) ) 620 { 621 $policy = eZPolicy::fetch( $http->sessionVariable( 'BrowsePolicyID' ) ); 622 } 623 else 624 { 625 $policy = eZPolicy::createNew( $roleID, array( 'ModuleName'=> $currentModule, 626 'FunctionName' => $currentFunction, 627 'Limitation' => '') ); 628 $http->setSessionVariable( 'BrowsePolicyID', $policy->attribute('id') ); 629 } 630 631 $subtreeLimitation = eZPolicyLimitation::fetchByIdentifier( $policy->attribute('id'), 'Subtree' ); 632 if ( $subtreeLimitation == null ) 633 $subtreeLimitation = eZPolicyLimitation::createNew( $policy->attribute('id'), 'Subtree', $currentModule, $currentFunction); 634 635 foreach ( $selectedSubtreeIDList as $nodeID ) 636 { 637 if ( !in_array( $nodeID, $subtreeIDList ) ) 638 { 639 $subtree = eZContentObjectTreeNode::fetch( $nodeID ); 640 $pathString = $subtree->attribute( 'path_string' ); 641 $policyLimitationValue = eZPolicyLimitationValue::createNew( $subtreeLimitation->attribute( 'id' ), $pathString ); 642 $subtreeList[] = $subtree; 643 } 644 } 645 } 646 647 if ( $http->hasPostVariable( 'Limitation' ) && count( $currentFunctionLimitations ) == 0 ) 648 { 649 $currentModule = $http->postVariable( 'CurrentModule' ); 650 $currentFunction = $http->postVariable( 'ModuleFunction' ); 651 eZDebugSetting::writeDebug( 'kernel-role-edit', $currentModule, 'currentModule' ); 652 $policy = eZPolicy::createNew( $roleID, array( 'ModuleName'=> $currentModule, 653 'FunctionName' => $currentFunction ) ); 654 } 655 else 656 { 657 $db->commit(); 658 659 $currentLimitationList = array(); 660 foreach ( $currentFunctionLimitations as $currentFunctionLimitation ) 661 { 662 $limitationName = $currentFunctionLimitation['name']; 663 $currentLimitationList[$limitationName] = '-1'; 664 } 665 if ( isset( $policyID ) ) 666 { 667 $limitationList = eZPolicyLimitation::fetchByPolicyID( $policyID ); 668 foreach ( $limitationList as $limitation ) 669 { 670 $limitationID = $limitation->attribute( 'id' ); 671 $limitationIdentifier = $limitation->attribute( 'identifier' ); 672 $limitationValues = eZPolicyLimitationValue::fetchList( $limitationID ); 673 $valueList = array(); 674 foreach ( $limitationValues as $limitationValue ) 675 { 676 $value = $limitationValue->attribute( 'value' ); 677 $valueList[] = $value; 678 } 679 $currentLimitationList[$limitationIdentifier] = $valueList; 680 } 681 } 682 683 684 $tpl->setVariable( 'current_function', $currentFunction ); 685 $tpl->setVariable( 'function_limitations', $currentFunctionLimitations ); 686 $tpl->setVariable( 'no_limitations', $noLimitations ); 687 688 $tpl->setVariable( 'current_module', $currentModule ); 689 $tpl->setVariable( 'functions', $functionNames ); 690 $tpl->setVariable( 'node_list', $nodeList ); 691 $tpl->setVariable( 'subtree_list', $subtreeList ); 692 $tpl->setVariable( 'current_limitation_list', $currentLimitationList ); 693 694 $Result = array(); 695 $Result['path'] = array( array( 'url' => false , 696 'text' => ezi18n( 'kernel/role', 697 'Create new policy, step three: set function limitations' ) ) ); 698 699 $Result['content'] =& $tpl->fetch( 'design:role/createpolicystep3.tpl' ); 700 return; 701 } 702 $db->commit(); 703 } 704 705 if ( $http->hasPostVariable( 'DiscardLimitation' ) || $http->hasPostVariable( 'Step2') ) 706 { 707 $currentModule = $http->postVariable( 'CurrentModule' ); 708 $mod = & eZModule::exists( $currentModule ); 709 $functions =& $mod->attribute( 'available_functions' ); 710 $functionNames = array_keys( $functions ); 711 712 $showModules = false; 713 $showFunctions = true; 714 $tpl->setVariable( 'current_module', $currentModule ); 715 $tpl->setVariable( 'functions', $functionNames ); 716 $tpl->setVariable( 'no_functions', false ); 717 718 $Result = array(); 719 $Result['path'] = array( array( 'url' => false , 720 'text' => ezi18n( 'kernel/role', 721 'Create new policy, step two: select function' ) ) ); 722 723 $Result['content'] =& $tpl->fetch( 'design:role/createpolicystep2.tpl' ); 724 return; 725 } 726 727 if ( $http->hasPostVariable( 'CreatePolicy' ) || $http->hasPostVariable( 'Step1' ) ) 728 { 729 // Set flag for audit. If true audit will be processed 730 $http->setSessionVariable( 'RoleWasChanged', true ); 731 $Module->setTitle( 'Edit ' . $role->attribute( 'name' ) ); 732 $tpl->setVariable( 'modules', $modules ); 733 $tpl->setVariable( 'role', $role ); 734 $tpl->setVariable( 'module', $Module ); 735 736 $Result = array(); 737 $Result['path'] = array( array( 'url' => false , 738 'text' => ezi18n( 'kernel/role', 739 'Create new policy, step one: select module' ) ) ); 740 741 $Result['content'] =& $tpl->fetch( 'design:role/createpolicystep1.tpl' ); 742 return; 743 } 744 745 // Set flag for audit. If true audit will be processed 746 // Cancel button was pressed 747 if ( $http->hasPostVariable( 'CancelPolicyButton' ) ) 748 $http->setSessionVariable( 'RoleWasChanged', false ); 749 750 $policies = $role->attribute( 'policies' ); 751 $tpl->setVariable( 'no_functions', $noFunctions ); 752 $tpl->setVariable( 'no_limitations', $noLimitations ); 753 754 $tpl->setVariable( 'show_modules', $showModules ); 755 $tpl->setVariable( 'show_limitations', $showLimitations ); 756 $tpl->setVariable( 'show_functions', $showFunctions ); 757 758 $tpl->setVariable( 'policies', $policies ); 759 $tpl->setVariable( 'modules', $modules ); 760 $tpl->setVariable( 'module', $Module ); 761 $tpl->setVariable( 'role', $role ); 762 763 $tpl->setVariable( 'step', 0 ); 764 765 $Module->setTitle( 'Edit ' . $role->attribute( 'name' ) ); 766 767 $Result = array(); 768 $Result['path'] = array( array( 'text' => 'Role', 769 'url' => 'role/list' ), 770 array( 'text' => $role->attribute( 'name' ), 771 'url' => false ) ); 772 773 $Result['content'] =& $tpl->fetch( 'design:role/edit.tpl' ); 774 775 ?>
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 |