Skip to content
This repository has been archived by the owner on May 19, 2021. It is now read-only.

Commit

Permalink
Update modredirect.plugin.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay Lanets committed Nov 20, 2014
1 parent bb6acc4 commit 0f07590
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions core/components/modredirect/elements/plugins/modredirect.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
if($modx->getOption('friendly_urls')){


if(!function_exists('modRedirect_write_redirect')){
function modRedirect_write_redirect($resource){
if(!function_exists('_write_redirect')){
function _write_redirect($resource){
global $modx;
$uri = $resource->uri;

Expand All @@ -30,7 +30,7 @@ function modRedirect_write_redirect($resource){
*/
if($Children = $resource->Children){
foreach($Children as $Child){
modRedirect_write_redirect($Child);
_write_redirect($Child);
}
}

Expand All @@ -42,17 +42,21 @@ function modRedirect_write_redirect($resource){

case 'OnBeforeDocFormSave':

$data = $scriptProperties['data'];
// Пытаемся получить объект документа
if(
!empty($scriptProperties['resource'])
AND $object = & $scriptProperties['resource']
AND $original = $modx->getObject('modResource', $object->id)
){

// Проверяем совпадает ли УРЛ
if($original->uri != $object->getAliasPath($object->alias)){
modRedirect_write_redirect($original);
}

$resource = null;
foreach($scriptProperties as & $object){
if(
is_object($object)
AND $object instanceof modResource
AND $original = $modx->getObject('modResource', $object->id)
){
if($original->uri != $object->getAliasPath($object->alias)){
_write_redirect($original);
}
break;
}
}

break;
Expand Down Expand Up @@ -112,7 +116,7 @@ function modRedirect_write_redirect($resource){
OR $resource->parent != $node['parent']
)
){
modRedirect_write_redirect($resource);
_write_redirect($resource);
}
}
}
Expand Down

0 comments on commit 0f07590

Please sign in to comment.