@@ -515,6 +515,9 @@ discard block |
||
| 515 | 515 | $this->setDroptables(false); |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | + /** |
|
| 519 | + * @param boolean $state |
|
| 520 | + */ |
|
| 518 | 521 | public function setDroptables($state) |
| 519 | 522 | { |
| 520 | 523 | $this->_isDroptables = $state; |
@@ -722,6 +725,9 @@ discard block |
||
| 722 | 725 | $_SESSION['result_msg'] = $result_code; |
| 723 | 726 | } |
| 724 | 727 | |
| 728 | +/** |
|
| 729 | + * @param string $dumpstring |
|
| 730 | + */ |
|
| 725 | 731 | function dumpSql(&$dumpstring) |
| 726 | 732 | { |
| 727 | 733 | global $modx; |
@@ -741,6 +747,9 @@ discard block |
||
| 741 | 747 | return true; |
| 742 | 748 | } |
| 743 | 749 | |
| 750 | +/** |
|
| 751 | + * @param string $dumpstring |
|
| 752 | + */ |
|
| 744 | 753 | function snapshot(&$dumpstring) |
| 745 | 754 | { |
| 746 | 755 | global $path; |
@@ -447,6 +447,10 @@ discard block |
||
| 447 | 447 | /** |
| 448 | 448 | * return XML parser, and possibly re-encoded source |
| 449 | 449 | * |
| 450 | + * @param string $source |
|
| 451 | + * @param string $out_enc |
|
| 452 | + * @param string|null $in_enc |
|
| 453 | + * @param boolean $detect |
|
| 450 | 454 | */ |
| 451 | 455 | function create_parser($source, $out_enc, $in_enc, $detect) { |
| 452 | 456 | if ( substr(phpversion(),0,1) == 5) { |
@@ -556,6 +560,9 @@ discard block |
||
| 556 | 560 | } |
| 557 | 561 | } |
| 558 | 562 | |
| 563 | + /** |
|
| 564 | + * @param integer $lvl |
|
| 565 | + */ |
|
| 559 | 566 | function error ($errormsg, $lvl=E_USER_WARNING) { |
| 560 | 567 | // append PHP's error message if track_errors enabled |
| 561 | 568 | if ( isset($php_errormsg) ) { |
@@ -591,6 +598,9 @@ discard block |
||
| 591 | 598 | define('CASE_LOWER', 0); |
| 592 | 599 | |
| 593 | 600 | |
| 601 | + /** |
|
| 602 | + * @param integer $case |
|
| 603 | + */ |
|
| 594 | 604 | function array_change_key_case($array, $case=CASE_LOWER) { |
| 595 | 605 | $output = array(); |
| 596 | 606 | switch($case){ |
@@ -275,11 +275,11 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | switch ($actionToTake) { |
| 278 | - case 'new' : |
|
| 278 | + case 'new' : |
|
| 279 | 279 | |
| 280 | - // invoke OnBeforeDocFormSave event |
|
| 281 | - switch($modx->config['docid_incrmnt_method']) |
|
| 282 | - { |
|
| 280 | + // invoke OnBeforeDocFormSave event |
|
| 281 | + switch($modx->config['docid_incrmnt_method']) |
|
| 282 | + { |
|
| 283 | 283 | case '1': |
| 284 | 284 | $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id"; |
| 285 | 285 | $where = "T1.id IS NULL"; |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | default: |
| 295 | 295 | $id = ''; |
| 296 | - } |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | 298 | $modx->invokeEvent("OnBeforeDocFormSave", array ( |
| 299 | 299 | "mode" => "new", |
@@ -444,256 +444,256 @@ discard block |
||
| 444 | 444 | |
| 445 | 445 | |
| 446 | 446 | break; |
| 447 | - case 'edit' : |
|
| 448 | - |
|
| 449 | - // get the document's current parent |
|
| 450 | - $oldparent = $existingDocument['parent']; |
|
| 451 | - $doctype = $existingDocument['type']; |
|
| 452 | - |
|
| 453 | - if ($id == $site_start && $published == 0) { |
|
| 454 | - $modx->manager->saveFormValues(27); |
|
| 455 | - $modx->webAlertAndQuit("Document is linked to site_start variable and cannot be unpublished!"); |
|
| 456 | - } |
|
| 457 | - $today = $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time']; |
|
| 458 | - if ($id == $site_start && ($pub_date > $today || $unpub_date != "0")) { |
|
| 459 | - $modx->manager->saveFormValues(27); |
|
| 460 | - $modx->webAlertAndQuit("Document is linked to site_start variable and cannot have publish or unpublish dates set!"); |
|
| 461 | - } |
|
| 462 | - if ($parent == $id) { |
|
| 463 | - $modx->manager->saveFormValues(27); |
|
| 464 | - $modx->webAlertAndQuit("Document can not be it's own parent!"); |
|
| 465 | - } |
|
| 447 | + case 'edit' : |
|
| 466 | 448 | |
| 467 | - $parents = $modx->getParentIds($parent); |
|
| 468 | - if (in_array($id, $parents)) { |
|
| 469 | - $modx->webAlertAndQuit("Document descendant can not be it's parent!"); |
|
| 470 | - } |
|
| 449 | + // get the document's current parent |
|
| 450 | + $oldparent = $existingDocument['parent']; |
|
| 451 | + $doctype = $existingDocument['type']; |
|
| 471 | 452 | |
| 472 | - // check to see document is a folder |
|
| 473 | - $rs = $modx->db->select('count(id)', $tbl_site_content, "parent='{$id}'"); |
|
| 474 | - $count = $modx->db->getValue($rs); |
|
| 475 | - if ($count > 0) { |
|
| 476 | - $isfolder = 1; |
|
| 477 | - } |
|
| 453 | + if ($id == $site_start && $published == 0) { |
|
| 454 | + $modx->manager->saveFormValues(27); |
|
| 455 | + $modx->webAlertAndQuit("Document is linked to site_start variable and cannot be unpublished!"); |
|
| 456 | + } |
|
| 457 | + $today = $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time']; |
|
| 458 | + if ($id == $site_start && ($pub_date > $today || $unpub_date != "0")) { |
|
| 459 | + $modx->manager->saveFormValues(27); |
|
| 460 | + $modx->webAlertAndQuit("Document is linked to site_start variable and cannot have publish or unpublish dates set!"); |
|
| 461 | + } |
|
| 462 | + if ($parent == $id) { |
|
| 463 | + $modx->manager->saveFormValues(27); |
|
| 464 | + $modx->webAlertAndQuit("Document can not be it's own parent!"); |
|
| 465 | + } |
|
| 478 | 466 | |
| 479 | - // set publishedon and publishedby |
|
| 480 | - $was_published = $existingDocument['published']; |
|
| 467 | + $parents = $modx->getParentIds($parent); |
|
| 468 | + if (in_array($id, $parents)) { |
|
| 469 | + $modx->webAlertAndQuit("Document descendant can not be it's parent!"); |
|
| 470 | + } |
|
| 481 | 471 | |
| 482 | - // keep original publish state, if change is not permitted |
|
| 483 | - if (!$modx->hasPermission('publish_document')) { |
|
| 484 | - $published = $was_published; |
|
| 485 | - $pub_date = 'pub_date'; |
|
| 486 | - $unpub_date = 'unpub_date'; |
|
| 487 | - } |
|
| 472 | + // check to see document is a folder |
|
| 473 | + $rs = $modx->db->select('count(id)', $tbl_site_content, "parent='{$id}'"); |
|
| 474 | + $count = $modx->db->getValue($rs); |
|
| 475 | + if ($count > 0) { |
|
| 476 | + $isfolder = 1; |
|
| 477 | + } |
|
| 488 | 478 | |
| 489 | - // if it was changed from unpublished to published |
|
| 490 | - if (!$was_published && $published) { |
|
| 491 | - $publishedon = $currentdate; |
|
| 492 | - $publishedby = $modx->getLoginUserID(); |
|
| 493 | - }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
| 494 | - $publishedon = $pub_date; |
|
| 495 | - $publishedby = $modx->getLoginUserID(); |
|
| 496 | - }elseif ($was_published && !$published) { |
|
| 497 | - $publishedon = 0; |
|
| 498 | - $publishedby = 0; |
|
| 499 | - } else { |
|
| 500 | - $publishedon = 'publishedon'; |
|
| 501 | - $publishedby = 'publishedby'; |
|
| 502 | - } |
|
| 479 | + // set publishedon and publishedby |
|
| 480 | + $was_published = $existingDocument['published']; |
|
| 503 | 481 | |
| 504 | - // invoke OnBeforeDocFormSave event |
|
| 505 | - $modx->invokeEvent("OnBeforeDocFormSave", array ( |
|
| 506 | - "mode" => "upd", |
|
| 507 | - "id" => $id |
|
| 508 | - )); |
|
| 482 | + // keep original publish state, if change is not permitted |
|
| 483 | + if (!$modx->hasPermission('publish_document')) { |
|
| 484 | + $published = $was_published; |
|
| 485 | + $pub_date = 'pub_date'; |
|
| 486 | + $unpub_date = 'unpub_date'; |
|
| 487 | + } |
|
| 509 | 488 | |
| 510 | - // update the document |
|
| 511 | - $modx->db->update( |
|
| 512 | - "introtext='{$introtext}', " |
|
| 513 | - . "content='{$content}', " |
|
| 514 | - . "pagetitle='{$pagetitle}', " |
|
| 515 | - . "longtitle='{$longtitle}', " |
|
| 516 | - . "type='{$type}', " |
|
| 517 | - . "description='{$description}', " |
|
| 518 | - . "alias='{$alias}', " |
|
| 519 | - . "link_attributes='{$link_attributes}', " |
|
| 520 | - . "isfolder={$isfolder}, " |
|
| 521 | - . "richtext={$richtext}, " |
|
| 522 | - . "published={$published}, " |
|
| 523 | - . "pub_date={$pub_date}, " |
|
| 524 | - . "unpub_date={$unpub_date}, " |
|
| 525 | - . "parent={$parent}, " |
|
| 526 | - . "template={$template}, " |
|
| 527 | - . "menuindex={$menuindex}, " |
|
| 528 | - . "searchable={$searchable}, " |
|
| 529 | - . "cacheable={$cacheable}, " |
|
| 530 | - . "editedby=" . $modx->getLoginUserID() . ", " |
|
| 531 | - . "editedon={$currentdate}, " |
|
| 532 | - . "publishedon={$publishedon}, " |
|
| 533 | - . "publishedby={$publishedby}, " |
|
| 534 | - . "contentType='{$contentType}', " |
|
| 535 | - . "content_dispo={$contentdispo}, " |
|
| 536 | - . "donthit={$donthit}, " |
|
| 537 | - . "menutitle='{$menutitle}', " |
|
| 538 | - . "hidemenu={$hidemenu}, " |
|
| 539 | - . "alias_visible={$aliasvisible}" |
|
| 540 | - , $tbl_site_content, "id='{$id}'"); |
|
| 541 | - |
|
| 542 | - // update template variables |
|
| 543 | - $rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, "contentid='{$id}'"); |
|
| 544 | - $tvIds = array (); |
|
| 545 | - while ($row = $modx->db->getRow($rs)) { |
|
| 546 | - $tvIds[$row['tmplvarid']] = $row['id']; |
|
| 547 | - } |
|
| 548 | - $tvDeletions = array(); |
|
| 549 | - $tvChanges = array(); |
|
| 550 | - foreach ($tmplvars as $field => $value) { |
|
| 551 | - if (!is_array($value)) { |
|
| 552 | - if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value]; |
|
| 489 | + // if it was changed from unpublished to published |
|
| 490 | + if (!$was_published && $published) { |
|
| 491 | + $publishedon = $currentdate; |
|
| 492 | + $publishedby = $modx->getLoginUserID(); |
|
| 493 | + }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
| 494 | + $publishedon = $pub_date; |
|
| 495 | + $publishedby = $modx->getLoginUserID(); |
|
| 496 | + }elseif ($was_published && !$published) { |
|
| 497 | + $publishedon = 0; |
|
| 498 | + $publishedby = 0; |
|
| 553 | 499 | } else { |
| 554 | - $tvId = $value[0]; |
|
| 555 | - $tvVal = $value[1]; |
|
| 500 | + $publishedon = 'publishedon'; |
|
| 501 | + $publishedby = 'publishedby'; |
|
| 502 | + } |
|
| 556 | 503 | |
| 557 | - if (isset($tvIds[$tvId])) { |
|
| 558 | - $tvChanges[] = array(array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal)), array('id' => $tvIds[$tvId])); |
|
| 504 | + // invoke OnBeforeDocFormSave event |
|
| 505 | + $modx->invokeEvent("OnBeforeDocFormSave", array ( |
|
| 506 | + "mode" => "upd", |
|
| 507 | + "id" => $id |
|
| 508 | + )); |
|
| 509 | + |
|
| 510 | + // update the document |
|
| 511 | + $modx->db->update( |
|
| 512 | + "introtext='{$introtext}', " |
|
| 513 | + . "content='{$content}', " |
|
| 514 | + . "pagetitle='{$pagetitle}', " |
|
| 515 | + . "longtitle='{$longtitle}', " |
|
| 516 | + . "type='{$type}', " |
|
| 517 | + . "description='{$description}', " |
|
| 518 | + . "alias='{$alias}', " |
|
| 519 | + . "link_attributes='{$link_attributes}', " |
|
| 520 | + . "isfolder={$isfolder}, " |
|
| 521 | + . "richtext={$richtext}, " |
|
| 522 | + . "published={$published}, " |
|
| 523 | + . "pub_date={$pub_date}, " |
|
| 524 | + . "unpub_date={$unpub_date}, " |
|
| 525 | + . "parent={$parent}, " |
|
| 526 | + . "template={$template}, " |
|
| 527 | + . "menuindex={$menuindex}, " |
|
| 528 | + . "searchable={$searchable}, " |
|
| 529 | + . "cacheable={$cacheable}, " |
|
| 530 | + . "editedby=" . $modx->getLoginUserID() . ", " |
|
| 531 | + . "editedon={$currentdate}, " |
|
| 532 | + . "publishedon={$publishedon}, " |
|
| 533 | + . "publishedby={$publishedby}, " |
|
| 534 | + . "contentType='{$contentType}', " |
|
| 535 | + . "content_dispo={$contentdispo}, " |
|
| 536 | + . "donthit={$donthit}, " |
|
| 537 | + . "menutitle='{$menutitle}', " |
|
| 538 | + . "hidemenu={$hidemenu}, " |
|
| 539 | + . "alias_visible={$aliasvisible}" |
|
| 540 | + , $tbl_site_content, "id='{$id}'"); |
|
| 541 | + |
|
| 542 | + // update template variables |
|
| 543 | + $rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, "contentid='{$id}'"); |
|
| 544 | + $tvIds = array (); |
|
| 545 | + while ($row = $modx->db->getRow($rs)) { |
|
| 546 | + $tvIds[$row['tmplvarid']] = $row['id']; |
|
| 547 | + } |
|
| 548 | + $tvDeletions = array(); |
|
| 549 | + $tvChanges = array(); |
|
| 550 | + foreach ($tmplvars as $field => $value) { |
|
| 551 | + if (!is_array($value)) { |
|
| 552 | + if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value]; |
|
| 559 | 553 | } else { |
| 560 | - $tvAdded[] = array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal)); |
|
| 554 | + $tvId = $value[0]; |
|
| 555 | + $tvVal = $value[1]; |
|
| 556 | + |
|
| 557 | + if (isset($tvIds[$tvId])) { |
|
| 558 | + $tvChanges[] = array(array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal)), array('id' => $tvIds[$tvId])); |
|
| 559 | + } else { |
|
| 560 | + $tvAdded[] = array('tmplvarid' => $tvId, 'contentid' => $id, 'value' => $modx->db->escape($tvVal)); |
|
| 561 | + } |
|
| 561 | 562 | } |
| 562 | 563 | } |
| 563 | - } |
|
| 564 | 564 | |
| 565 | - if (!empty($tvDeletions)) { |
|
| 566 | - $modx->db->delete($tbl_site_tmplvar_contentvalues, 'id IN('.implode(',', $tvDeletions).')'); |
|
| 567 | - } |
|
| 568 | - |
|
| 569 | - if (!empty($tvAdded)) { |
|
| 570 | - foreach ($tvAdded as $tv) { |
|
| 571 | - $modx->db->insert($tv, $tbl_site_tmplvar_contentvalues); |
|
| 565 | + if (!empty($tvDeletions)) { |
|
| 566 | + $modx->db->delete($tbl_site_tmplvar_contentvalues, 'id IN('.implode(',', $tvDeletions).')'); |
|
| 572 | 567 | } |
| 573 | - } |
|
| 574 | 568 | |
| 575 | - if (!empty($tvChanges)) { |
|
| 576 | - foreach ($tvChanges as $tv) { |
|
| 577 | - $modx->db->update($tv[0], $tbl_site_tmplvar_contentvalues, "id='{$tv[1]['id']}'"); |
|
| 569 | + if (!empty($tvAdded)) { |
|
| 570 | + foreach ($tvAdded as $tv) { |
|
| 571 | + $modx->db->insert($tv, $tbl_site_tmplvar_contentvalues); |
|
| 572 | + } |
|
| 578 | 573 | } |
| 579 | - } |
|
| 580 | 574 | |
| 581 | - // set document permissions |
|
| 582 | - if ($use_udperms == 1 && is_array($document_groups)) { |
|
| 583 | - $new_groups = array(); |
|
| 584 | - // process the new input |
|
| 585 | - foreach ($document_groups as $value_pair) { |
|
| 586 | - list($group, $link_id) = explode(',', $value_pair); // @see actions/mutate_content.dynamic.php @ line 1138 (permissions list) |
|
| 587 | - $new_groups[$group] = $link_id; |
|
| 575 | + if (!empty($tvChanges)) { |
|
| 576 | + foreach ($tvChanges as $tv) { |
|
| 577 | + $modx->db->update($tv[0], $tbl_site_tmplvar_contentvalues, "id='{$tv[1]['id']}'"); |
|
| 578 | + } |
|
| 588 | 579 | } |
| 589 | 580 | |
| 590 | - // grab the current set of permissions on this document the user can access |
|
| 591 | - $isManager = $modx->hasPermission('access_permissions'); |
|
| 592 | - $isWeb = $modx->hasPermission('web_access_permissions'); |
|
| 593 | - $rs = $modx->db->select( |
|
| 594 | - 'groups.id, groups.document_group', |
|
| 595 | - "{$tbl_document_groups} AS groups |
|
| 581 | + // set document permissions |
|
| 582 | + if ($use_udperms == 1 && is_array($document_groups)) { |
|
| 583 | + $new_groups = array(); |
|
| 584 | + // process the new input |
|
| 585 | + foreach ($document_groups as $value_pair) { |
|
| 586 | + list($group, $link_id) = explode(',', $value_pair); // @see actions/mutate_content.dynamic.php @ line 1138 (permissions list) |
|
| 587 | + $new_groups[$group] = $link_id; |
|
| 588 | + } |
|
| 589 | + |
|
| 590 | + // grab the current set of permissions on this document the user can access |
|
| 591 | + $isManager = $modx->hasPermission('access_permissions'); |
|
| 592 | + $isWeb = $modx->hasPermission('web_access_permissions'); |
|
| 593 | + $rs = $modx->db->select( |
|
| 594 | + 'groups.id, groups.document_group', |
|
| 595 | + "{$tbl_document_groups} AS groups |
|
| 596 | 596 | LEFT JOIN {$tbl_documentgroup_names} AS dgn ON dgn.id = groups.document_group", |
| 597 | - "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
|
| 598 | - ); |
|
| 599 | - $old_groups = array(); |
|
| 600 | - while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id']; |
|
| 601 | - |
|
| 602 | - // update the permissions in the database |
|
| 603 | - $insertions = $deletions = array(); |
|
| 604 | - foreach ($new_groups as $group => $link_id) { |
|
| 605 | - if (array_key_exists($group, $old_groups)) { |
|
| 606 | - unset($old_groups[$group]); |
|
| 607 | - continue; |
|
| 608 | - } elseif ($link_id == 'new') { |
|
| 609 | - $insertions[] = '('.(int)$group.','.$id.')'; |
|
| 597 | + "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
|
| 598 | + ); |
|
| 599 | + $old_groups = array(); |
|
| 600 | + while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id']; |
|
| 601 | + |
|
| 602 | + // update the permissions in the database |
|
| 603 | + $insertions = $deletions = array(); |
|
| 604 | + foreach ($new_groups as $group => $link_id) { |
|
| 605 | + if (array_key_exists($group, $old_groups)) { |
|
| 606 | + unset($old_groups[$group]); |
|
| 607 | + continue; |
|
| 608 | + } elseif ($link_id == 'new') { |
|
| 609 | + $insertions[] = '('.(int)$group.','.$id.')'; |
|
| 610 | + } |
|
| 611 | + } |
|
| 612 | + if (!empty($insertions)) { |
|
| 613 | + $modx->db->query("INSERT INTO {$tbl_document_groups} (document_group, document) VALUES ".implode(',', $insertions)); |
|
| 614 | + } |
|
| 615 | + if (!empty($old_groups)) { |
|
| 616 | + $modx->db->delete($tbl_document_groups, "id IN (".implode(',', $old_groups).")"); |
|
| 617 | + } |
|
| 618 | + // necessary to remove all permissions as document is public |
|
| 619 | + if ((isset($_POST['chkalldocs']) && $_POST['chkalldocs'] == 'on')) { |
|
| 620 | + $modx->db->delete($tbl_document_groups, "document='{$id}'"); |
|
| 610 | 621 | } |
| 611 | 622 | } |
| 612 | - if (!empty($insertions)) { |
|
| 613 | - $modx->db->query("INSERT INTO {$tbl_document_groups} (document_group, document) VALUES ".implode(',', $insertions)); |
|
| 614 | - } |
|
| 615 | - if (!empty($old_groups)) { |
|
| 616 | - $modx->db->delete($tbl_document_groups, "id IN (".implode(',', $old_groups).")"); |
|
| 617 | - } |
|
| 618 | - // necessary to remove all permissions as document is public |
|
| 619 | - if ((isset($_POST['chkalldocs']) && $_POST['chkalldocs'] == 'on')) { |
|
| 620 | - $modx->db->delete($tbl_document_groups, "document='{$id}'"); |
|
| 623 | + |
|
| 624 | + // do the parent stuff |
|
| 625 | + if ($parent != 0) { |
|
| 626 | + $fields = array('isfolder' => 1); |
|
| 627 | + $modx->db->update($fields, $tbl_site_content, "id='{$_REQUEST['parent']}'"); |
|
| 621 | 628 | } |
| 622 | - } |
|
| 623 | 629 | |
| 624 | - // do the parent stuff |
|
| 625 | - if ($parent != 0) { |
|
| 626 | - $fields = array('isfolder' => 1); |
|
| 627 | - $modx->db->update($fields, $tbl_site_content, "id='{$_REQUEST['parent']}'"); |
|
| 628 | - } |
|
| 630 | + // finished moving the document, now check to see if the old_parent should no longer be a folder |
|
| 631 | + $rs = $modx->db->select('COUNT(id)', $tbl_site_content, "parent='{$oldparent}'"); |
|
| 632 | + $limit = $modx->db->getValue($rs); |
|
| 629 | 633 | |
| 630 | - // finished moving the document, now check to see if the old_parent should no longer be a folder |
|
| 631 | - $rs = $modx->db->select('COUNT(id)', $tbl_site_content, "parent='{$oldparent}'"); |
|
| 632 | - $limit = $modx->db->getValue($rs); |
|
| 634 | + if ($limit == 0) { |
|
| 635 | + $fields = array('isfolder' => 0); |
|
| 636 | + $modx->db->update($fields, $tbl_site_content, "id='{$oldparent}'"); |
|
| 637 | + } |
|
| 633 | 638 | |
| 634 | - if ($limit == 0) { |
|
| 635 | - $fields = array('isfolder' => 0); |
|
| 636 | - $modx->db->update($fields, $tbl_site_content, "id='{$oldparent}'"); |
|
| 637 | - } |
|
| 638 | 639 | |
| 640 | + // invoke OnDocFormSave event |
|
| 641 | + $modx->invokeEvent("OnDocFormSave", array ( |
|
| 642 | + "mode" => "upd", |
|
| 643 | + "id" => $id |
|
| 644 | + )); |
|
| 639 | 645 | |
| 640 | - // invoke OnDocFormSave event |
|
| 641 | - $modx->invokeEvent("OnDocFormSave", array ( |
|
| 642 | - "mode" => "upd", |
|
| 643 | - "id" => $id |
|
| 644 | - )); |
|
| 646 | + // secure web documents - flag as private |
|
| 647 | + include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php"; |
|
| 648 | + secureWebDocument($id); |
|
| 645 | 649 | |
| 646 | - // secure web documents - flag as private |
|
| 647 | - include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php"; |
|
| 648 | - secureWebDocument($id); |
|
| 649 | - |
|
| 650 | - // secure manager documents - flag as private |
|
| 651 | - include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php"; |
|
| 652 | - secureMgrDocument($id); |
|
| 650 | + // secure manager documents - flag as private |
|
| 651 | + include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php"; |
|
| 652 | + secureMgrDocument($id); |
|
| 653 | 653 | |
| 654 | - // Set the item name for logger |
|
| 655 | - $_SESSION['itemname'] = $no_esc_pagetitle; |
|
| 654 | + // Set the item name for logger |
|
| 655 | + $_SESSION['itemname'] = $no_esc_pagetitle; |
|
| 656 | 656 | |
| 657 | - if ($syncsite == 1) { |
|
| 658 | - // empty cache |
|
| 659 | - $keys = array('alias','parent','published','isfolder','menuindex','alias_visible'); |
|
| 660 | - $flag = ''; |
|
| 661 | - foreach($keys as $key) { |
|
| 662 | - if ($existingDocument[$key]===$_POST[$key]) continue; |
|
| 663 | - $flag = 'full'; |
|
| 664 | - break; |
|
| 657 | + if ($syncsite == 1) { |
|
| 658 | + // empty cache |
|
| 659 | + $keys = array('alias','parent','published','isfolder','menuindex','alias_visible'); |
|
| 660 | + $flag = ''; |
|
| 661 | + foreach($keys as $key) { |
|
| 662 | + if ($existingDocument[$key]===$_POST[$key]) continue; |
|
| 663 | + $flag = 'full'; |
|
| 664 | + break; |
|
| 665 | + } |
|
| 666 | + if($flag==='full') $modx->clearCache('full'); |
|
| 667 | + else $modx->clearCache($id); |
|
| 665 | 668 | } |
| 666 | - if($flag==='full') $modx->clearCache('full'); |
|
| 667 | - else $modx->clearCache($id); |
|
| 668 | - } |
|
| 669 | 669 | |
| 670 | - if ($_POST['refresh_preview'] == '1') |
|
| 671 | - $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
| 672 | - else { |
|
| 673 | - if ($_POST['stay'] != '2' && $id > 0) { |
|
| 674 | - $modx->unlockElement(7, $id); |
|
| 675 | - } |
|
| 676 | - if ($_POST['stay'] != '') { |
|
| 677 | - $id = $_REQUEST['id']; |
|
| 678 | - if ($type == "reference") { |
|
| 679 | - // weblink |
|
| 680 | - $a = ($_POST['stay'] == '2') ? "27&id=$id" : "72&pid=$parent"; |
|
| 670 | + if ($_POST['refresh_preview'] == '1') |
|
| 671 | + $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
| 672 | + else { |
|
| 673 | + if ($_POST['stay'] != '2' && $id > 0) { |
|
| 674 | + $modx->unlockElement(7, $id); |
|
| 675 | + } |
|
| 676 | + if ($_POST['stay'] != '') { |
|
| 677 | + $id = $_REQUEST['id']; |
|
| 678 | + if ($type == "reference") { |
|
| 679 | + // weblink |
|
| 680 | + $a = ($_POST['stay'] == '2') ? "27&id=$id" : "72&pid=$parent"; |
|
| 681 | + } else { |
|
| 682 | + // document |
|
| 683 | + $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent"; |
|
| 684 | + } |
|
| 685 | + $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path; |
|
| 681 | 686 | } else { |
| 682 | - // document |
|
| 683 | - $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent"; |
|
| 687 | + $header = "Location: index.php?a=3&id=$id&r=1".$add_path; |
|
| 684 | 688 | } |
| 685 | - $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path; |
|
| 689 | + } |
|
| 690 | + if (headers_sent()) { |
|
| 691 | + $header = str_replace('Location: ','',$header); |
|
| 692 | + echo "<script>document.location.href='$header';</script>\n"; |
|
| 686 | 693 | } else { |
| 687 | - $header = "Location: index.php?a=3&id=$id&r=1".$add_path; |
|
| 694 | + header($header); |
|
| 688 | 695 | } |
| 689 | - } |
|
| 690 | - if (headers_sent()) { |
|
| 691 | - $header = str_replace('Location: ','',$header); |
|
| 692 | - echo "<script>document.location.href='$header';</script>\n"; |
|
| 693 | - } else { |
|
| 694 | - header($header); |
|
| 695 | - } |
|
| 696 | - break; |
|
| 697 | - default : |
|
| 698 | - $modx->webAlertAndQuit("No operation set in request."); |
|
| 696 | + break; |
|
| 697 | + default : |
|
| 698 | + $modx->webAlertAndQuit("No operation set in request."); |
|
| 699 | 699 | } |