@@ -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,248 +444,248 @@ 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 | - $modx->clearCache('full'); |
|
660 | - } |
|
657 | + if ($syncsite == 1) { |
|
658 | + // empty cache |
|
659 | + $modx->clearCache('full'); |
|
660 | + } |
|
661 | 661 | |
662 | - if ($_POST['refresh_preview'] == '1') |
|
663 | - $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
664 | - else { |
|
665 | - if ($_POST['stay'] != '2' && $id > 0) { |
|
666 | - $modx->unlockElement(7, $id); |
|
667 | - } |
|
668 | - if ($_POST['stay'] != '') { |
|
669 | - $id = $_REQUEST['id']; |
|
670 | - if ($type == "reference") { |
|
671 | - // weblink |
|
672 | - $a = ($_POST['stay'] == '2') ? "27&id=$id" : "72&pid=$parent"; |
|
662 | + if ($_POST['refresh_preview'] == '1') |
|
663 | + $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
664 | + else { |
|
665 | + if ($_POST['stay'] != '2' && $id > 0) { |
|
666 | + $modx->unlockElement(7, $id); |
|
667 | + } |
|
668 | + if ($_POST['stay'] != '') { |
|
669 | + $id = $_REQUEST['id']; |
|
670 | + if ($type == "reference") { |
|
671 | + // weblink |
|
672 | + $a = ($_POST['stay'] == '2') ? "27&id=$id" : "72&pid=$parent"; |
|
673 | + } else { |
|
674 | + // document |
|
675 | + $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent"; |
|
676 | + } |
|
677 | + $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path; |
|
673 | 678 | } else { |
674 | - // document |
|
675 | - $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent"; |
|
679 | + $header = "Location: index.php?a=3&id=$id&r=1".$add_path; |
|
676 | 680 | } |
677 | - $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path; |
|
681 | + } |
|
682 | + if (headers_sent()) { |
|
683 | + $header = str_replace('Location: ','',$header); |
|
684 | + echo "<script>document.location.href='$header';</script>\n"; |
|
678 | 685 | } else { |
679 | - $header = "Location: index.php?a=3&id=$id&r=1".$add_path; |
|
686 | + header($header); |
|
680 | 687 | } |
681 | - } |
|
682 | - if (headers_sent()) { |
|
683 | - $header = str_replace('Location: ','',$header); |
|
684 | - echo "<script>document.location.href='$header';</script>\n"; |
|
685 | - } else { |
|
686 | - header($header); |
|
687 | - } |
|
688 | - break; |
|
689 | - default : |
|
690 | - $modx->webAlertAndQuit("No operation set in request."); |
|
688 | + break; |
|
689 | + default : |
|
690 | + $modx->webAlertAndQuit("No operation set in request."); |
|
691 | 691 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | if (!$modx->hasPermission('save_document')) { |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | $document_groups = (isset($_POST['chkalldocs']) && $_POST['chkalldocs'] == 'on') ? array() : $_POST['docgroups']; |
29 | 29 | $type = $_POST['type']; |
30 | 30 | $contentType = $modx->db->escape($_POST['contentType']); |
31 | -$contentdispo = (int)$_POST['content_dispo']; |
|
31 | +$contentdispo = (int) $_POST['content_dispo']; |
|
32 | 32 | $longtitle = $modx->db->escape($_POST['longtitle']); |
33 | -$donthit = (int)$_POST['donthit']; |
|
33 | +$donthit = (int) $_POST['donthit']; |
|
34 | 34 | $menutitle = $modx->db->escape($_POST['menutitle']); |
35 | -$hidemenu = (int)$_POST['hidemenu']; |
|
35 | +$hidemenu = (int) $_POST['hidemenu']; |
|
36 | 36 | $aliasvisible = $_POST['alias_visible']; |
37 | 37 | |
38 | 38 | /************* webber ********/ |
39 | -$sd=isset($_POST['dir'])?'&dir='.$_POST['dir']:'&dir=DESC'; |
|
40 | -$sb=isset($_POST['sort'])?'&sort='.$_POST['sort']:'&sort=pub_date'; |
|
41 | -$pg=isset($_POST['page'])?'&page='.(int)$_POST['page']:''; |
|
42 | -$add_path=$sd.$sb.$pg; |
|
39 | +$sd = isset($_POST['dir']) ? '&dir='.$_POST['dir'] : '&dir=DESC'; |
|
40 | +$sb = isset($_POST['sort']) ? '&sort='.$_POST['sort'] : '&sort=pub_date'; |
|
41 | +$pg = isset($_POST['page']) ? '&page='.(int) $_POST['page'] : ''; |
|
42 | +$add_path = $sd.$sb.$pg; |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | // auto assign alias |
74 | 74 | if (!$alias && $automatic_alias) { |
75 | 75 | $alias = strtolower($modx->stripAlias(trim($pagetitle))); |
76 | - if(!$allow_duplicate_alias) { |
|
76 | + if (!$allow_duplicate_alias) { |
|
77 | 77 | if ($modx->db->getValue($modx->db->select('COUNT(id)', $tbl_site_content, "id<>'$id' AND alias='$alias'")) != 0) { |
78 | 78 | $cnt = 1; |
79 | 79 | $tempAlias = $alias; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | $alias = $tempAlias; |
86 | 86 | } |
87 | - }else{ |
|
87 | + } else { |
|
88 | 88 | if ($modx->db->getValue($modx->db->select('COUNT(id)', $tbl_site_content, "id<>'$id' AND parent=$parent AND alias='$alias'")) != 0) { |
89 | 89 | $cnt = 1; |
90 | 90 | $tempAlias = $alias; |
@@ -165,19 +165,19 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | // get document groups for current user |
168 | -$tmplvars = array (); |
|
168 | +$tmplvars = array(); |
|
169 | 169 | if ($_SESSION['mgrDocgroups']) { |
170 | 170 | $docgrp = implode(",", $_SESSION['mgrDocgroups']); |
171 | 171 | } |
172 | 172 | |
173 | 173 | // ensure that user has not made this document inaccessible to themselves |
174 | -if($_SESSION['mgrRole'] != 1 && is_array($document_groups)) { |
|
174 | +if ($_SESSION['mgrRole'] != 1 && is_array($document_groups)) { |
|
175 | 175 | $document_group_list = implode(',', $document_groups); |
176 | - $document_group_list = implode(',', array_filter(explode(',',$document_group_list), 'is_numeric')); |
|
177 | - if(!empty($document_group_list)) { |
|
176 | + $document_group_list = implode(',', array_filter(explode(',', $document_group_list), 'is_numeric')); |
|
177 | + if (!empty($document_group_list)) { |
|
178 | 178 | $rs = $modx->db->select('COUNT(mg.id)', "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg", "mga.membergroup = mg.user_group AND mga.documentgroup IN({$document_group_list}) AND mg.member = {$_SESSION['mgrInternalKey']}"); |
179 | 179 | $count = $modx->db->getValue($rs); |
180 | - if($count == 0) { |
|
180 | + if ($count == 0) { |
|
181 | 181 | if ($actionToTake == 'edit') { |
182 | 182 | $modx->manager->saveFormValues(27); |
183 | 183 | $modx->webAlertAndQuit(sprintf($_lang["resource_permissions_error"]), "index.php?a=27&id={$id}"); |
@@ -195,45 +195,45 @@ discard block |
||
195 | 195 | INNER JOIN {$tbl_site_tmplvar_templates} AS tvtpl ON tvtpl.tmplvarid = tv.id |
196 | 196 | LEFT JOIN {$tbl_site_tmplvar_contentvalues} AS tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$id}' |
197 | 197 | LEFT JOIN {$tbl_site_tmplvar_access} AS tva ON tva.tmplvarid=tv.id", |
198 | - "tvtpl.templateid = '{$template}' AND (1='{$_SESSION['mgrRole']}' OR ISNULL(tva.documentgroup)" . ((!$docgrp) ? "" : " OR tva.documentgroup IN ($docgrp)") . ")", |
|
198 | + "tvtpl.templateid = '{$template}' AND (1='{$_SESSION['mgrRole']}' OR ISNULL(tva.documentgroup)".((!$docgrp) ? "" : " OR tva.documentgroup IN ($docgrp)").")", |
|
199 | 199 | "tv.rank" |
200 | 200 | ); |
201 | 201 | while ($row = $modx->db->getRow($rs)) { |
202 | 202 | $tmplvar = ''; |
203 | 203 | switch ($row['type']) { |
204 | 204 | case 'url': |
205 | - $tmplvar = $_POST["tv" . $row['id']]; |
|
206 | - if ($_POST["tv" . $row['id'] . '_prefix'] != '--') { |
|
207 | - $tmplvar = str_replace(array ( |
|
205 | + $tmplvar = $_POST["tv".$row['id']]; |
|
206 | + if ($_POST["tv".$row['id'].'_prefix'] != '--') { |
|
207 | + $tmplvar = str_replace(array( |
|
208 | 208 | "feed://", |
209 | 209 | "ftp://", |
210 | 210 | "http://", |
211 | 211 | "https://", |
212 | 212 | "mailto:" |
213 | 213 | ), "", $tmplvar); |
214 | - $tmplvar = $_POST["tv" . $row['id'] . '_prefix'] . $tmplvar; |
|
214 | + $tmplvar = $_POST["tv".$row['id'].'_prefix'].$tmplvar; |
|
215 | 215 | } |
216 | 216 | break; |
217 | 217 | case 'file': |
218 | - $tmplvar = $_POST["tv" . $row['id']]; |
|
218 | + $tmplvar = $_POST["tv".$row['id']]; |
|
219 | 219 | break; |
220 | 220 | default: |
221 | - if (is_array($_POST["tv" . $row['id']])) { |
|
221 | + if (is_array($_POST["tv".$row['id']])) { |
|
222 | 222 | // handles checkboxes & multiple selects elements |
223 | - $feature_insert = array (); |
|
224 | - $lst = $_POST["tv" . $row['id']]; |
|
223 | + $feature_insert = array(); |
|
224 | + $lst = $_POST["tv".$row['id']]; |
|
225 | 225 | while (list ($featureValue, $feature_item) = each($lst)) { |
226 | 226 | $feature_insert[count($feature_insert)] = $feature_item; |
227 | 227 | } |
228 | 228 | $tmplvar = implode("||", $feature_insert); |
229 | 229 | } else { |
230 | - $tmplvar = $_POST["tv" . $row['id']]; |
|
230 | + $tmplvar = $_POST["tv".$row['id']]; |
|
231 | 231 | } |
232 | 232 | break; |
233 | 233 | } |
234 | 234 | // save value if it was modified |
235 | 235 | if (strlen($tmplvar) > 0 && $tmplvar != $row['default_text']) { |
236 | - $tmplvars[$row['id']] = array ( |
|
236 | + $tmplvars[$row['id']] = array( |
|
237 | 237 | $row['id'], |
238 | 238 | $tmplvar |
239 | 239 | ); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | // check to see if the user is allowed to save the document in the place he wants to save it in |
257 | 257 | if ($use_udperms == 1) { |
258 | 258 | if ($existingDocument['parent'] != $parent) { |
259 | - include_once MODX_MANAGER_PATH ."processors/user_documents_permissions.class.php"; |
|
259 | + include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
260 | 260 | $udperms = new udperms(); |
261 | 261 | $udperms->user = $modx->getLoginUserID(); |
262 | 262 | $udperms->document = $parent; |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | case 'new' : |
279 | 279 | |
280 | 280 | // invoke OnBeforeDocFormSave event |
281 | - switch($modx->config['docid_incrmnt_method']) |
|
281 | + switch ($modx->config['docid_incrmnt_method']) |
|
282 | 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"; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $id = $modx->db->getValue($rs); |
288 | 288 | break; |
289 | 289 | case '2': |
290 | - $rs = $modx->db->select('MAX(id)+1',$tbl_site_content); |
|
290 | + $rs = $modx->db->select('MAX(id)+1', $tbl_site_content); |
|
291 | 291 | $id = $modx->db->getValue($rs); |
292 | 292 | break; |
293 | 293 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $id = ''; |
296 | 296 | } |
297 | 297 | |
298 | - $modx->invokeEvent("OnBeforeDocFormSave", array ( |
|
298 | + $modx->invokeEvent("OnBeforeDocFormSave", array( |
|
299 | 299 | "mode" => "new", |
300 | 300 | "id" => $id |
301 | 301 | )); |
@@ -310,48 +310,47 @@ discard block |
||
310 | 310 | $publishedon = ($published ? $currentdate : 0); |
311 | 311 | $publishedby = ($published ? $modx->getLoginUserID() : 0); |
312 | 312 | |
313 | - if ((!empty($pub_date))&&($published)){ |
|
314 | - $publishedon=$pub_date; |
|
315 | - } |
|
316 | - |
|
317 | - $dbInsert = array |
|
318 | - ( |
|
319 | - "introtext" => $introtext , |
|
320 | - "content" => $content , |
|
321 | - "pagetitle" => $pagetitle , |
|
322 | - "longtitle" => $longtitle , |
|
323 | - "type" => $type , |
|
324 | - "description" => $description , |
|
325 | - "alias" => $alias , |
|
326 | - "link_attributes" => $link_attributes , |
|
327 | - "isfolder" => $isfolder , |
|
328 | - "richtext" => $richtext , |
|
329 | - "published" => $published , |
|
330 | - "parent" => $parent , |
|
331 | - "template" => $template , |
|
332 | - "menuindex" => $menuindex , |
|
333 | - "searchable" => $searchable , |
|
334 | - "cacheable" => $cacheable , |
|
335 | - "createdby" => $modx->getLoginUserID() , |
|
336 | - "createdon" => $currentdate , |
|
337 | - "editedby" => $modx->getLoginUserID() , |
|
338 | - "editedon" => $currentdate , |
|
339 | - "publishedby" => $publishedby , |
|
340 | - "publishedon" => $publishedon , |
|
341 | - "pub_date" => $pub_date , |
|
342 | - "unpub_date" => $unpub_date , |
|
343 | - "contentType" => $contentType , |
|
344 | - "content_dispo" => $contentdispo , |
|
345 | - "donthit" => $donthit , |
|
346 | - "menutitle" => $menutitle , |
|
347 | - "hidemenu" => $hidemenu , |
|
313 | + if ((!empty($pub_date)) && ($published)) { |
|
314 | + $publishedon = $pub_date; |
|
315 | + } |
|
316 | + |
|
317 | + $dbInsert = array( |
|
318 | + "introtext" => $introtext, |
|
319 | + "content" => $content, |
|
320 | + "pagetitle" => $pagetitle, |
|
321 | + "longtitle" => $longtitle, |
|
322 | + "type" => $type, |
|
323 | + "description" => $description, |
|
324 | + "alias" => $alias, |
|
325 | + "link_attributes" => $link_attributes, |
|
326 | + "isfolder" => $isfolder, |
|
327 | + "richtext" => $richtext, |
|
328 | + "published" => $published, |
|
329 | + "parent" => $parent, |
|
330 | + "template" => $template, |
|
331 | + "menuindex" => $menuindex, |
|
332 | + "searchable" => $searchable, |
|
333 | + "cacheable" => $cacheable, |
|
334 | + "createdby" => $modx->getLoginUserID(), |
|
335 | + "createdon" => $currentdate, |
|
336 | + "editedby" => $modx->getLoginUserID(), |
|
337 | + "editedon" => $currentdate, |
|
338 | + "publishedby" => $publishedby, |
|
339 | + "publishedon" => $publishedon, |
|
340 | + "pub_date" => $pub_date, |
|
341 | + "unpub_date" => $unpub_date, |
|
342 | + "contentType" => $contentType, |
|
343 | + "content_dispo" => $contentdispo, |
|
344 | + "donthit" => $donthit, |
|
345 | + "menutitle" => $menutitle, |
|
346 | + "hidemenu" => $hidemenu, |
|
348 | 347 | "alias_visible" => $aliasvisible |
349 | 348 | ); |
350 | 349 | |
351 | 350 | if ($id != '') |
352 | 351 | $dbInsert["id"] = $id; |
353 | 352 | |
354 | - $key = $modx->db->insert( $dbInsert, $tbl_site_content); |
|
353 | + $key = $modx->db->insert($dbInsert, $tbl_site_content); |
|
355 | 354 | |
356 | 355 | $tvChanges = array(); |
357 | 356 | foreach ($tmplvars as $field => $value) { |
@@ -373,7 +372,7 @@ discard block |
||
373 | 372 | foreach ($document_groups as $value_pair) { |
374 | 373 | // first, split the pair (this is a new document, so ignore the second value |
375 | 374 | list($group) = explode(',', $value_pair); // @see actions/mutate_content.dynamic.php @ line 1138 (permissions list) |
376 | - $new_groups[] = '('.(int)$group.','.$key.')'; |
|
375 | + $new_groups[] = '('.(int) $group.','.$key.')'; |
|
377 | 376 | } |
378 | 377 | $saved = true; |
379 | 378 | if (!empty($new_groups)) { |
@@ -382,7 +381,7 @@ discard block |
||
382 | 381 | } else { |
383 | 382 | $isManager = $modx->hasPermission('access_permissions'); |
384 | 383 | $isWeb = $modx->hasPermission('web_access_permissions'); |
385 | - if($use_udperms && !($isManager || $isWeb) && $parent != 0) { |
|
384 | + if ($use_udperms && !($isManager || $isWeb) && $parent != 0) { |
|
386 | 385 | // inherit document access permissions |
387 | 386 | $modx->db->insert( |
388 | 387 | array( |
@@ -401,17 +400,17 @@ discard block |
||
401 | 400 | } |
402 | 401 | |
403 | 402 | // invoke OnDocFormSave event |
404 | - $modx->invokeEvent("OnDocFormSave", array ( |
|
403 | + $modx->invokeEvent("OnDocFormSave", array( |
|
405 | 404 | "mode" => "new", |
406 | 405 | "id" => $key |
407 | 406 | )); |
408 | 407 | |
409 | 408 | // secure web documents - flag as private |
410 | - include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php"; |
|
409 | + include MODX_MANAGER_PATH."includes/secure_web_documents.inc.php"; |
|
411 | 410 | secureWebDocument($key); |
412 | 411 | |
413 | 412 | // secure manager documents - flag as private |
414 | - include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php"; |
|
413 | + include MODX_MANAGER_PATH."includes/secure_mgr_documents.inc.php"; |
|
415 | 414 | secureMgrDocument($key); |
416 | 415 | |
417 | 416 | // Set the item name for logger |
@@ -430,13 +429,13 @@ discard block |
||
430 | 429 | // document |
431 | 430 | if ($_POST['mode'] == "4") |
432 | 431 | $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent"; |
433 | - $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay']; |
|
432 | + $header = "Location: index.php?a=".$a."&r=1&stay=".$_POST['stay']; |
|
434 | 433 | } else { |
435 | 434 | $header = "Location: index.php?a=3&id=$key&r=1"; |
436 | 435 | } |
437 | 436 | |
438 | 437 | if (headers_sent()) { |
439 | - $header = str_replace('Location: ','',$header); |
|
438 | + $header = str_replace('Location: ', '', $header); |
|
440 | 439 | echo "<script>document.location.href='$header';</script>\n"; |
441 | 440 | } else { |
442 | 441 | header($header); |
@@ -490,7 +489,7 @@ discard block |
||
490 | 489 | if (!$was_published && $published) { |
491 | 490 | $publishedon = $currentdate; |
492 | 491 | $publishedby = $modx->getLoginUserID(); |
493 | - }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
492 | + }elseif ((!empty($pub_date) && $pub_date <= $currentdate && $published)) { |
|
494 | 493 | $publishedon = $pub_date; |
495 | 494 | $publishedby = $modx->getLoginUserID(); |
496 | 495 | }elseif ($was_published && !$published) { |
@@ -502,7 +501,7 @@ discard block |
||
502 | 501 | } |
503 | 502 | |
504 | 503 | // invoke OnBeforeDocFormSave event |
505 | - $modx->invokeEvent("OnBeforeDocFormSave", array ( |
|
504 | + $modx->invokeEvent("OnBeforeDocFormSave", array( |
|
506 | 505 | "mode" => "upd", |
507 | 506 | "id" => $id |
508 | 507 | )); |
@@ -527,7 +526,7 @@ discard block |
||
527 | 526 | . "menuindex={$menuindex}, " |
528 | 527 | . "searchable={$searchable}, " |
529 | 528 | . "cacheable={$cacheable}, " |
530 | - . "editedby=" . $modx->getLoginUserID() . ", " |
|
529 | + . "editedby=".$modx->getLoginUserID().", " |
|
531 | 530 | . "editedon={$currentdate}, " |
532 | 531 | . "publishedon={$publishedon}, " |
533 | 532 | . "publishedby={$publishedby}, " |
@@ -541,7 +540,7 @@ discard block |
||
541 | 540 | |
542 | 541 | // update template variables |
543 | 542 | $rs = $modx->db->select('id, tmplvarid', $tbl_site_tmplvar_contentvalues, "contentid='{$id}'"); |
544 | - $tvIds = array (); |
|
543 | + $tvIds = array(); |
|
545 | 544 | while ($row = $modx->db->getRow($rs)) { |
546 | 545 | $tvIds[$row['tmplvarid']] = $row['id']; |
547 | 546 | } |
@@ -594,7 +593,7 @@ discard block |
||
594 | 593 | 'groups.id, groups.document_group', |
595 | 594 | "{$tbl_document_groups} AS groups |
596 | 595 | 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}'" |
|
596 | + "((1=".(int) $isManager." AND dgn.private_memgroup) OR (1=".(int) $isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
|
598 | 597 | ); |
599 | 598 | $old_groups = array(); |
600 | 599 | while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id']; |
@@ -606,7 +605,7 @@ discard block |
||
606 | 605 | unset($old_groups[$group]); |
607 | 606 | continue; |
608 | 607 | } elseif ($link_id == 'new') { |
609 | - $insertions[] = '('.(int)$group.','.$id.')'; |
|
608 | + $insertions[] = '('.(int) $group.','.$id.')'; |
|
610 | 609 | } |
611 | 610 | } |
612 | 611 | if (!empty($insertions)) { |
@@ -638,17 +637,17 @@ discard block |
||
638 | 637 | |
639 | 638 | |
640 | 639 | // invoke OnDocFormSave event |
641 | - $modx->invokeEvent("OnDocFormSave", array ( |
|
640 | + $modx->invokeEvent("OnDocFormSave", array( |
|
642 | 641 | "mode" => "upd", |
643 | 642 | "id" => $id |
644 | 643 | )); |
645 | 644 | |
646 | 645 | // secure web documents - flag as private |
647 | - include MODX_MANAGER_PATH . "includes/secure_web_documents.inc.php"; |
|
646 | + include MODX_MANAGER_PATH."includes/secure_web_documents.inc.php"; |
|
648 | 647 | secureWebDocument($id); |
649 | 648 | |
650 | 649 | // secure manager documents - flag as private |
651 | - include MODX_MANAGER_PATH . "includes/secure_mgr_documents.inc.php"; |
|
650 | + include MODX_MANAGER_PATH."includes/secure_mgr_documents.inc.php"; |
|
652 | 651 | secureMgrDocument($id); |
653 | 652 | |
654 | 653 | // Set the item name for logger |
@@ -674,13 +673,13 @@ discard block |
||
674 | 673 | // document |
675 | 674 | $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent"; |
676 | 675 | } |
677 | - $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path; |
|
676 | + $header = "Location: index.php?a=".$a."&r=1&stay=".$_POST['stay'].$add_path; |
|
678 | 677 | } else { |
679 | 678 | $header = "Location: index.php?a=3&id=$id&r=1".$add_path; |
680 | 679 | } |
681 | 680 | } |
682 | 681 | if (headers_sent()) { |
683 | - $header = str_replace('Location: ','',$header); |
|
682 | + $header = str_replace('Location: ', '', $header); |
|
684 | 683 | echo "<script>document.location.href='$header';</script>\n"; |
685 | 684 | } else { |
686 | 685 | header($header); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | $alias = $tempAlias; |
86 | 86 | } |
87 | - }else{ |
|
87 | + } else { |
|
88 | 88 | if ($modx->db->getValue($modx->db->select('COUNT(id)', $tbl_site_content, "id<>'$id' AND parent=$parent AND alias='$alias'")) != 0) { |
89 | 89 | $cnt = 1; |
90 | 90 | $tempAlias = $alias; |
@@ -134,8 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | //end webber |
136 | 136 | } |
137 | -} |
|
138 | -elseif ($alias) { |
|
137 | +} elseif ($alias) { |
|
139 | 138 | $alias = $modx->stripAlias($alias); |
140 | 139 | } |
141 | 140 | |
@@ -149,8 +148,7 @@ discard block |
||
149 | 148 | |
150 | 149 | if ($pub_date < $currentdate) { |
151 | 150 | $published = 1; |
152 | - } |
|
153 | - elseif ($pub_date > $currentdate) { |
|
151 | + } elseif ($pub_date > $currentdate) { |
|
154 | 152 | $published = 0; |
155 | 153 | } |
156 | 154 | } |
@@ -278,8 +276,7 @@ discard block |
||
278 | 276 | case 'new' : |
279 | 277 | |
280 | 278 | // invoke OnBeforeDocFormSave event |
281 | - switch($modx->config['docid_incrmnt_method']) |
|
282 | - { |
|
279 | + switch($modx->config['docid_incrmnt_method']) { |
|
283 | 280 | case '1': |
284 | 281 | $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id"; |
285 | 282 | $where = "T1.id IS NULL"; |
@@ -310,7 +307,7 @@ discard block |
||
310 | 307 | $publishedon = ($published ? $currentdate : 0); |
311 | 308 | $publishedby = ($published ? $modx->getLoginUserID() : 0); |
312 | 309 | |
313 | - if ((!empty($pub_date))&&($published)){ |
|
310 | + if ((!empty($pub_date))&&($published)) { |
|
314 | 311 | $publishedon=$pub_date; |
315 | 312 | } |
316 | 313 | |
@@ -348,8 +345,9 @@ discard block |
||
348 | 345 | "alias_visible" => $aliasvisible |
349 | 346 | ); |
350 | 347 | |
351 | - if ($id != '') |
|
352 | - $dbInsert["id"] = $id; |
|
348 | + if ($id != '') { |
|
349 | + $dbInsert["id"] = $id; |
|
350 | + } |
|
353 | 351 | |
354 | 352 | $key = $modx->db->insert( $dbInsert, $tbl_site_content); |
355 | 353 | |
@@ -425,11 +423,13 @@ discard block |
||
425 | 423 | // redirect/stay options |
426 | 424 | if ($_POST['stay'] != '') { |
427 | 425 | // weblink |
428 | - if ($_POST['mode'] == "72") |
|
429 | - $a = ($_POST['stay'] == '2') ? "27&id=$key" : "72&pid=$parent"; |
|
426 | + if ($_POST['mode'] == "72") { |
|
427 | + $a = ($_POST['stay'] == '2') ? "27&id=$key" : "72&pid=$parent"; |
|
428 | + } |
|
430 | 429 | // document |
431 | - if ($_POST['mode'] == "4") |
|
432 | - $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent"; |
|
430 | + if ($_POST['mode'] == "4") { |
|
431 | + $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent"; |
|
432 | + } |
|
433 | 433 | $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay']; |
434 | 434 | } else { |
435 | 435 | $header = "Location: index.php?a=3&id=$key&r=1"; |
@@ -490,10 +490,10 @@ discard block |
||
490 | 490 | if (!$was_published && $published) { |
491 | 491 | $publishedon = $currentdate; |
492 | 492 | $publishedby = $modx->getLoginUserID(); |
493 | - }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
493 | + } elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) { |
|
494 | 494 | $publishedon = $pub_date; |
495 | 495 | $publishedby = $modx->getLoginUserID(); |
496 | - }elseif ($was_published && !$published) { |
|
496 | + } elseif ($was_published && !$published) { |
|
497 | 497 | $publishedon = 0; |
498 | 498 | $publishedby = 0; |
499 | 499 | } else { |
@@ -549,7 +549,9 @@ discard block |
||
549 | 549 | $tvChanges = array(); |
550 | 550 | foreach ($tmplvars as $field => $value) { |
551 | 551 | if (!is_array($value)) { |
552 | - if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value]; |
|
552 | + if (isset($tvIds[$value])) { |
|
553 | + $tvDeletions[] = $tvIds[$value]; |
|
554 | + } |
|
553 | 555 | } else { |
554 | 556 | $tvId = $value[0]; |
555 | 557 | $tvVal = $value[1]; |
@@ -597,7 +599,9 @@ discard block |
||
597 | 599 | "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'" |
598 | 600 | ); |
599 | 601 | $old_groups = array(); |
600 | - while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id']; |
|
602 | + while ($row = $modx->db->getRow($rs)) { |
|
603 | + $old_groups[$row['document_group']] = $row['id']; |
|
604 | + } |
|
601 | 605 | |
602 | 606 | // update the permissions in the database |
603 | 607 | $insertions = $deletions = array(); |
@@ -659,9 +663,9 @@ discard block |
||
659 | 663 | $modx->clearCache('full'); |
660 | 664 | } |
661 | 665 | |
662 | - if ($_POST['refresh_preview'] == '1') |
|
663 | - $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
664 | - else { |
|
666 | + if ($_POST['refresh_preview'] == '1') { |
|
667 | + $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev"; |
|
668 | + } else { |
|
665 | 669 | if ($_POST['stay'] != '2' && $id > 0) { |
666 | 670 | $modx->unlockElement(7, $id); |
667 | 671 | } |