Conditions | 214 |
Paths | 1528 |
Total Lines | 1017 |
Code Lines | 770 |
Lines | 0 |
Ratio | 0 % |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
531 | function _dispatch($view, $item, $root, $get_show_view) { |
||
532 | $item_factory =& $this->_getItemFactory(); |
||
533 | $user =& $this->getUser(); |
||
534 | $dpm = $this->_getPermissionsManager(); |
||
535 | |||
536 | switch ($view) { |
||
537 | case 'show': |
||
538 | if($item->isObsolete()) { |
||
539 | if(!$this->userCanAdmin($item->getId())) { |
||
540 | // redirect to details view |
||
541 | $this->view = 'Details'; |
||
542 | break; |
||
543 | } |
||
544 | } |
||
545 | $this->view = $item->accept($get_show_view, $this->request->get('report')); |
||
546 | break; |
||
547 | case 'expandFolder': |
||
548 | $this->action = 'expandFolder'; |
||
549 | if ($this->request->get('view') == 'ulsubfolder') { |
||
550 | $this->view = 'RawTree'; |
||
551 | } else { |
||
552 | $this->_viewParams['item'] =& $root; |
||
553 | $this->view = 'Tree'; |
||
554 | } |
||
555 | break; |
||
556 | case 'getRootFolder': |
||
557 | $this->_viewParams['action_result'] = $root->getId(); |
||
558 | $this->_setView('getRootFolder'); |
||
559 | break; |
||
560 | case 'collapseFolder': |
||
561 | $this->action = 'collapseFolder'; |
||
562 | $this->_viewParams['item'] =& $root; |
||
563 | $this->view = 'Tree'; |
||
564 | break; |
||
565 | case 'admin_set_permissions': |
||
566 | $this->action = $view; |
||
567 | $this->view = 'Admin_Permissions'; |
||
568 | break; |
||
569 | case 'admin_change_view': |
||
570 | $this->action = $view; |
||
571 | $this->_viewParams['default_url_params'] = array('action' => 'admin_view', |
||
572 | 'id' => $item->getParentId()); |
||
573 | $this->view = 'RedirectAfterCrud'; |
||
574 | break; |
||
575 | case 'admin': |
||
576 | case 'details': |
||
577 | $this->view = ucfirst($view); |
||
578 | break; |
||
579 | case 'admin_view': |
||
580 | $this->view = 'Admin_View'; |
||
581 | break; |
||
582 | case 'admin_permissions': |
||
583 | $this->view = 'Admin_Permissions'; |
||
584 | break; |
||
585 | case 'admin_metadata': |
||
586 | $this->view = 'Admin_Metadata'; |
||
587 | $mdFactory = new Docman_MetadataFactory($this->_viewParams['group_id']); |
||
588 | $mdIter =& $mdFactory->getMetadataForGroup(); |
||
589 | $this->_viewParams['mdIter'] =& $mdIter; |
||
590 | break; |
||
591 | case 'admin_md_details': |
||
592 | // Sanitize |
||
593 | $_mdLabel = $this->request->get('md'); |
||
594 | |||
595 | $md = null; |
||
596 | $mdFactory = new Docman_MetadataFactory($this->_viewParams['group_id']); |
||
597 | $valid = $this->validateMetadata($_mdLabel, $md); |
||
598 | |||
599 | if(!$valid) { |
||
600 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', |
||
601 | 'error_invalid_md')); |
||
602 | $this->view = 'RedirectAfterCrud'; |
||
603 | $this->_viewParams['default_url_params'] = array('action' => 'admin_metadata'); |
||
604 | } |
||
605 | else { |
||
606 | $this->view = 'Admin_MetadataDetails'; |
||
607 | $mdFactory->appendMetadataValueList($md, false); |
||
608 | $this->_viewParams['md'] =& $md; |
||
609 | } |
||
610 | break; |
||
611 | case 'admin_md_details_update': |
||
612 | $_name = trim($this->request->get('name')); |
||
613 | $_label = $this->request->get('label'); |
||
614 | |||
615 | $mdFactory = $this->_getMetadataFactory($this->_viewParams['group_id']); |
||
616 | if($mdFactory->isValidLabel($_label)) { |
||
617 | $this->_viewParams['default_url_params'] = array('action' => 'admin_md_details', 'md' => $_label); |
||
618 | if ($mdFactory->isHardCodedMetadata($_label) || $this->validateUpdateMetadata($_name, $_label)) { |
||
619 | $this->action = $view; |
||
620 | } |
||
621 | } else { |
||
622 | $this->_viewParams['default_url_params'] = array('action' => 'admin_metadata'); |
||
623 | } |
||
624 | $this->view = 'RedirectAfterCrud'; |
||
625 | break; |
||
626 | case 'admin_create_metadata': |
||
627 | $_name = trim($this->request->get('name')); |
||
628 | $valid = $this->validateNewMetadata($_name); |
||
629 | |||
630 | if ($valid) { |
||
631 | $this->action = $view; |
||
632 | } |
||
633 | |||
634 | $this->_viewParams['default_url_params'] = array('action' => 'admin_metadata'); |
||
635 | $this->view = 'RedirectAfterCrud'; |
||
636 | break; |
||
637 | case 'admin_delete_metadata': |
||
638 | $valid = false; |
||
639 | // md |
||
640 | // Sanitize |
||
641 | $_mdLabel = $this->request->get('md'); |
||
642 | |||
643 | // Valid |
||
644 | $logmsg = ''; |
||
645 | $mdFactory = new Docman_MetadataFactory($this->_viewParams['group_id']); |
||
646 | $md = null; |
||
647 | $vld = $this->validateMetadata($_mdLabel, $md); |
||
648 | if($vld) { |
||
649 | if(!$mdFactory->isHardCodedMetadata($md->getLabel())) { |
||
650 | $valid = true; |
||
651 | } |
||
652 | else { |
||
653 | $logmsg = $GLOBALS['Language']->getText('plugin_docman', |
||
654 | 'error_cannot_delete_hc_md'); |
||
655 | } |
||
656 | } |
||
657 | else { |
||
658 | $logmsg = $GLOBALS['Language']->getText('plugin_docman', |
||
659 | 'error_invalid_md'); |
||
660 | } |
||
661 | |||
662 | if(!$valid) { |
||
663 | if($logmsg != '') { |
||
664 | $this->feedback->log('error', $logmsg); |
||
665 | } |
||
666 | $this->view = 'RedirectAfterCrud'; |
||
667 | $this->_viewParams['default_url_params'] = array('action' => 'admin_metadata'); |
||
668 | } |
||
669 | else { |
||
670 | $this->action = $view; |
||
671 | $this->_actionParams['md'] = $md; |
||
672 | } |
||
673 | |||
674 | break; |
||
675 | case 'admin_create_love': |
||
676 | $mdFactory = $this->_getMetadataFactory($this->_viewParams['group_id']); |
||
677 | if($mdFactory->isValidLabel($this->request->get('md'))) { |
||
678 | $this->action = $view; |
||
679 | $this->_viewParams['default_url_params'] = array('action' => 'admin_md_details', |
||
680 | 'md' => $this->request->get('md')); |
||
681 | } else { |
||
682 | $this->_viewParams['default_url_params'] = array('action' => 'admin_metadata'); |
||
683 | } |
||
684 | $this->view = 'RedirectAfterCrud'; |
||
685 | break; |
||
686 | case 'admin_delete_love': |
||
687 | $mdFactory = $this->_getMetadataFactory($this->_viewParams['group_id']); |
||
688 | if($mdFactory->isValidLabel($this->request->get('md'))) { |
||
689 | $this->action = $view; |
||
690 | $this->_viewParams['default_url_params'] = array('action' => 'admin_md_details', |
||
691 | 'md' => $this->request->get('md')); |
||
692 | } else { |
||
693 | $this->_viewParams['default_url_params'] = array('action' => 'admin_metadata'); |
||
694 | } |
||
695 | $this->view = 'RedirectAfterCrud'; |
||
696 | break; |
||
697 | case 'admin_display_love': |
||
698 | $valid = false; |
||
699 | // Required params: |
||
700 | // md (string [a-z_]+) |
||
701 | // loveid (int) |
||
702 | |||
703 | // Sanitize |
||
704 | $_mdLabel = $this->request->get('md'); |
||
705 | $_loveId = (int) $this->request->get('loveid'); |
||
706 | |||
707 | // Valid |
||
708 | $md = null; |
||
709 | $love = null; |
||
710 | $this->validateMetadata($_mdLabel, $md); |
||
711 | if($md !== null && $md->getLabel() !== 'status') { |
||
712 | $valid = $this->validateLove($_loveId, $md, $love); |
||
713 | } |
||
714 | |||
715 | if(!$valid) { |
||
716 | $this->view = 'RedirectAfterCrud'; |
||
717 | $this->_viewParams['default_url_params'] = array('action' => 'admin_metadata'); |
||
718 | } |
||
719 | else { |
||
720 | $mdFactory = new Docman_MetadataFactory($this->groupId); |
||
721 | $mdFactory->appendMetadataValueList($md, false); |
||
722 | |||
723 | $this->view = 'Admin_MetadataDetailsUpdateLove'; |
||
724 | $this->_viewParams['md'] = $md; |
||
725 | $this->_viewParams['love'] = $love; |
||
726 | } |
||
727 | break; |
||
728 | case 'admin_update_love': |
||
729 | $valid = false; |
||
730 | // Required params: |
||
731 | // md (string [a-z_]+) |
||
732 | // loveid (int) |
||
733 | // |
||
734 | // rank (beg, end, [0-9]+) |
||
735 | // name |
||
736 | // descr |
||
737 | |||
738 | // Sanitize |
||
739 | /// @todo sanitize md, rank, name, descr |
||
740 | $_mdLabel = $this->request->get('md'); |
||
741 | $_loveId = (int) $this->request->get('loveid'); |
||
742 | $_rank = $this->request->get('rank'); |
||
743 | $_name = $this->request->get('name'); |
||
744 | $_descr = $this->request->get('descr'); |
||
745 | |||
746 | // Valid |
||
747 | $md = null; |
||
748 | $love = null; |
||
749 | $this->validateMetadata($_mdLabel, $md); |
||
750 | if($md !== null && $md->getLabel() !== 'status') { |
||
751 | $valid = $this->validateLove($_loveId, $md, $love); |
||
752 | } |
||
753 | |||
754 | if(!$valid) { |
||
755 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_md_or_love')); |
||
756 | $this->view = 'RedirectAfterCrud'; |
||
757 | $this->_viewParams['default_url_params'] = array('action' => 'admin_metadata'); |
||
758 | } |
||
759 | else { |
||
760 | // Set parameters |
||
761 | $love->setRank($_rank); |
||
762 | $love->setName($_name); |
||
763 | $love->setDescription($_descr); |
||
764 | |||
765 | // define action |
||
766 | $this->action = $view; |
||
767 | $this->_actionParams['md'] = $md; |
||
768 | $this->_actionParams['love'] = $love; |
||
769 | } |
||
770 | break; |
||
771 | |||
772 | case 'admin_import_metadata_check': |
||
773 | $ok = false; |
||
774 | if($this->request->existAndNonEmpty('plugin_docman_metadata_import_group')) { |
||
775 | $pm = ProjectManager::instance(); |
||
776 | $srcGroup = $pm->getProjectFromAutocompleter($this->request->get('plugin_docman_metadata_import_group')); |
||
777 | if ($srcGroup && !$srcGroup->isError()) { |
||
778 | $this->_viewParams['sSrcGroupId'] = $srcGroup->getGroupId(); |
||
779 | $this->view = 'Admin_MetadataImport'; |
||
780 | $ok = true; |
||
781 | } |
||
782 | } |
||
783 | if (!$ok) { |
||
784 | $this->view = 'RedirectAfterCrud'; |
||
785 | $this->_viewParams['default_url_params'] = array('action' => 'admin_metadata'); |
||
786 | } |
||
787 | break; |
||
788 | |||
789 | case 'admin_import_metadata': |
||
790 | if($this->request->existAndNonEmpty('confirm')) { |
||
791 | |||
792 | if($this->request->existAndNonEmpty('plugin_docman_metadata_import_group')) { |
||
793 | $pm = ProjectManager::instance(); |
||
794 | $srcGroup = $pm->getProjectFromAutocompleter($this->request->get('plugin_docman_metadata_import_group')); |
||
795 | $srcGroupId = $srcGroup->getGroupId(); |
||
796 | $this->_actionParams['sSrcGroupId'] = $srcGroupId; |
||
797 | $this->_actionParams['sGroupId'] = $this->_viewParams['group_id']; |
||
798 | |||
799 | $this->action = $view; |
||
800 | } else { |
||
801 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'missing_param')); |
||
802 | $this->feedback->log('info', $GLOBALS['Language']->getText('plugin_docman', 'operation_canceled')); |
||
803 | } |
||
804 | } else { |
||
805 | $this->feedback->log('info', $GLOBALS['Language']->getText('plugin_docman', 'operation_canceled')); |
||
806 | } |
||
807 | $this->view = 'RedirectAfterCrud'; |
||
808 | $this->_viewParams['default_url_params'] = array('action' => 'admin_metadata'); |
||
809 | break; |
||
810 | |||
811 | case 'admin_obsolete': |
||
812 | $this->view = 'Admin_Obsolete'; |
||
813 | break; |
||
814 | |||
815 | case 'admin_lock_infos': |
||
816 | $this->view = 'Admin_LockInfos'; |
||
817 | break; |
||
818 | |||
819 | case 'move': |
||
820 | if (!$this->userCanWrite($item->getId()) || !$this->userCanWrite($item->getParentId())) { |
||
821 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_move')); |
||
822 | $this->view = 'Details'; |
||
823 | } else { |
||
824 | if ($this->request->exist('quick_move')) { |
||
825 | $this->action = 'move'; |
||
826 | $this->view = null; |
||
827 | } else { |
||
828 | $this->_viewParams['hierarchy'] =& $this->getItemHierarchy($root); |
||
829 | $this->view = ucfirst($view); |
||
830 | } |
||
831 | } |
||
832 | break; |
||
833 | case 'newGlobalDocument': |
||
834 | if ($dpm->oneFolderIsWritable($user)) { |
||
835 | $this->_viewParams['hierarchy'] =& $this->getItemHierarchy($root); |
||
836 | $this->view = 'New_FolderSelection'; |
||
837 | } else { |
||
838 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_create')); |
||
839 | $this->view = $item->accept($get_show_view, $this->request->get('report')); |
||
840 | } |
||
841 | break; |
||
842 | case 'newDocument': |
||
843 | case 'newFolder': |
||
844 | if ($this->request->exist('cancel')) { |
||
845 | $this->_set_redirectView(); |
||
846 | } else { |
||
847 | if (!$this->userCanWrite($item->getId())) { |
||
848 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_create')); |
||
849 | $this->view = 'Details'; |
||
850 | } else { |
||
851 | //$this->_viewParams['hierarchy'] =& $this->getItemHierarchy($root); |
||
852 | $this->_viewParams['ordering'] = $this->request->get('ordering'); |
||
853 | if($this->request->get('item_type') == PLUGIN_DOCMAN_ITEM_TYPE_FOLDER) { |
||
854 | $view = 'newFolder'; |
||
855 | } |
||
856 | $this->view = ucfirst($view); |
||
857 | } |
||
858 | } |
||
859 | break; |
||
860 | case 'monitor': |
||
861 | if ($this->request->exist('monitor')) { |
||
862 | $this->_actionParams['monitor'] = $this->request->get('monitor'); |
||
863 | if ($this->request->exist('cascade')) { |
||
864 | $this->_actionParams['cascade'] = $this->request->get('cascade'); |
||
865 | } |
||
866 | $this->_actionParams['item'] =& $item; |
||
867 | $this->action = 'monitor'; |
||
868 | } |
||
869 | $this->_setView('Details'); |
||
870 | break; |
||
871 | case 'remove_monitoring': |
||
872 | $this->_actionParams['listeners_to_delete'] = array(); |
||
873 | if ($this->userCanManage($item->getId())) { |
||
874 | if ($this->request->exist('listeners_to_delete')) { |
||
875 | $um = UserManager::instance(); |
||
876 | $vUserId = new Valid_UInt('listeners_to_delete'); |
||
877 | if($this->request->validArray($vUserId)) { |
||
878 | $userIds = $this->request->get('listeners_to_delete'); |
||
879 | $users = array(); |
||
880 | foreach ($userIds as $userId) { |
||
881 | $users[] = $um->getUserById($userId); |
||
882 | } |
||
883 | $this->_actionParams['listeners_to_delete'] = $users; |
||
884 | $this->_actionParams['item'] = $item; |
||
885 | } |
||
886 | } |
||
887 | $this->action = 'remove_monitoring'; |
||
888 | $this->_setView('Details'); |
||
889 | } else { |
||
890 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'notifications_permission_denied')); |
||
891 | $this->_setView('Details'); |
||
892 | } |
||
893 | break; |
||
894 | |||
895 | case 'add_monitoring': |
||
896 | $this->_actionParams['listeners_to_add'] = array(); |
||
897 | $this->_actionParams['invalid_users'] = false; |
||
898 | if ($this->userCanManage($item->getId())) { |
||
899 | if ($this->request->exist('listeners_to_add')) { |
||
900 | $um = UserManager::instance(); |
||
901 | $vUser = new Valid_Text('listeners_to_add'); |
||
902 | if($this->request->valid($vUser)) { |
||
903 | $usernames = array_map('trim', preg_split('/[,;]/', $this->request->get('listeners_to_add'))); |
||
904 | $users = array(); |
||
905 | $vUserName = new Valid_String(); |
||
906 | $vUserName->required(); |
||
907 | foreach ($usernames as $username) { |
||
908 | if ($vUserName->validate($username) && $user = $um->findUser($username)) { |
||
909 | $users[] =$user; |
||
910 | } else { |
||
911 | $this->_actionParams['invalid_users'] = true; |
||
912 | } |
||
913 | } |
||
914 | if ($this->request->exist('monitor_cascade')) { |
||
915 | $this->_actionParams['monitor_cascade'] = $this->request->get('monitor_cascade'); |
||
916 | } |
||
917 | $this->_actionParams['listeners_to_add'] = $users; |
||
918 | $this->_actionParams['item'] = $item; |
||
919 | } |
||
920 | } |
||
921 | $this->action = 'add_monitoring'; |
||
922 | $this->_setView('Details'); |
||
923 | } else { |
||
924 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'notifications_permission_denied')); |
||
925 | $this->_setView('Details'); |
||
926 | } |
||
927 | break; |
||
928 | |||
929 | case 'move_here': |
||
930 | if (!$this->request->exist('item_to_move')) { |
||
931 | $this->feedback->log('error', 'Missing parameter.'); |
||
932 | $this->view = 'DocmanError'; |
||
933 | } else { |
||
934 | $item_to_move =& $item_factory->getItemFromDb($this->request->get('item_to_move')); |
||
935 | $this->view = null; |
||
936 | if ($this->request->exist('confirm')) { |
||
937 | if (!$item_to_move || !($this->userCanWrite($item->getId()) && $this->userCanWrite($item_to_move->getId()) && $this->userCanWrite($item_to_move->getParentId()))) { |
||
938 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_move')); |
||
939 | $this->_set_moveView_errorPerms(); |
||
940 | } else { |
||
941 | $this->action = 'move'; |
||
942 | } |
||
943 | } |
||
944 | if (!$this->view) { |
||
945 | $this->_set_redirectView(); |
||
946 | } |
||
947 | } |
||
948 | break; |
||
949 | case 'permissions': |
||
950 | if (!$this->userCanManage($item->getId())) { |
||
951 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_perms')); |
||
952 | $this->view = 'Details'; |
||
953 | } else { |
||
954 | $this->action = 'permissions'; |
||
955 | $this->view = 'Details'; |
||
956 | } |
||
957 | break; |
||
958 | case 'confirmDelete': |
||
959 | if (!$this->userCanWrite($item->getId()) || !$this->userCanWrite($item->getParentId())) { |
||
960 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_delete')); |
||
961 | $this->view = 'Details'; |
||
962 | } else { |
||
963 | $this->view = 'Delete'; |
||
964 | } |
||
965 | break; |
||
966 | case 'action_new_version': |
||
967 | if (!$this->userCanWrite($item->getId())) { |
||
968 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_edit')); |
||
969 | $this->view = 'Details'; |
||
970 | } else { |
||
971 | $dPm = $this->_getPermissionsManager(); |
||
972 | if($dPm->getLockFactory()->itemIsLocked($item)) { |
||
973 | $this->feedback->log('warning', $GLOBALS['Language']->getText('plugin_docman', 'event_lock_add')); |
||
974 | } |
||
975 | $this->view = 'NewVersion'; |
||
976 | } |
||
977 | break; |
||
978 | case 'action_update': |
||
979 | if (!$this->userCanWrite($item->getId())) { |
||
980 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_edit')); |
||
981 | $this->view = 'Details'; |
||
982 | } else { |
||
983 | $this->view = 'Update'; |
||
984 | } |
||
985 | break; |
||
986 | |||
987 | case 'action_copy': |
||
988 | //@XSS: validate action against a regexp. |
||
989 | $_action = $this->request->get('orig_action'); |
||
990 | $_id = (int) $this->request->get('orig_id'); |
||
991 | $this->_actionParams['item'] = $item; |
||
992 | |||
993 | $this->action = $view; |
||
994 | if(!$this->request->exist('ajax_copy')) { |
||
995 | $this->_viewParams['default_url_params'] = array('action' => $_action, |
||
996 | 'id' => $_id); |
||
997 | $this->view = 'RedirectAfterCrud'; |
||
998 | } |
||
999 | break; |
||
1000 | |||
1001 | case 'action_cut': |
||
1002 | $_action = $this->request->get('orig_action'); |
||
1003 | $_id = (int) $this->request->get('orig_id'); |
||
1004 | $this->_actionParams['item'] = $item; |
||
1005 | |||
1006 | $this->action = $view; |
||
1007 | if(!$this->request->exist('ajax_cut')) { |
||
1008 | $this->_viewParams['default_url_params'] = array('action' => $_action, |
||
1009 | 'id' => $_id); |
||
1010 | $this->view = 'RedirectAfterCrud'; |
||
1011 | } |
||
1012 | break; |
||
1013 | |||
1014 | case 'action_paste': |
||
1015 | $itemToPaste = null; |
||
1016 | $mode = null; |
||
1017 | $allowed = $this->checkPasteIsAllowed($item, $itemToPaste, $mode); |
||
1018 | if(!$allowed) { |
||
1019 | $this->view = 'Details'; |
||
1020 | } |
||
1021 | else { |
||
1022 | $this->_viewParams['itemToPaste'] = $itemToPaste; |
||
1023 | $this->_viewParams['srcMode'] = $mode; |
||
1024 | $this->view = 'Paste'; |
||
1025 | } |
||
1026 | break; |
||
1027 | |||
1028 | case 'paste_cancel': |
||
1029 | // intend to be only called through ajax call |
||
1030 | $item_factory->delCopyPreference(); |
||
1031 | $item_factory->delCutPreference(); |
||
1032 | break; |
||
1033 | |||
1034 | case 'paste': |
||
1035 | if($this->request->exist('cancel')) { |
||
1036 | $this->_viewParams['default_url_params'] = array('action' => 'show'); |
||
1037 | $this->view = 'RedirectAfterCrud'; |
||
1038 | } else { |
||
1039 | $itemToPaste = null; |
||
1040 | $mode = null; |
||
1041 | $allowed = $this->checkPasteIsAllowed($item, $itemToPaste, $mode); |
||
1042 | if(!$allowed) { |
||
1043 | $this->view = 'Details'; |
||
1044 | } |
||
1045 | else { |
||
1046 | $this->_viewParams['importMd'] = false; |
||
1047 | if($this->userCanAdmin()) { |
||
1048 | if($this->request->exist('import_md') && |
||
1049 | $this->request->get('import_md') == '1') { |
||
1050 | $this->_viewParams['importMd'] = true; |
||
1051 | } |
||
1052 | } |
||
1053 | $this->_viewParams['item'] = $item; |
||
1054 | $this->_viewParams['rank'] = $this->request->get('rank'); |
||
1055 | $this->_viewParams['itemToPaste'] = $itemToPaste; |
||
1056 | $this->_viewParams['srcMode'] = $mode; |
||
1057 | /*$this->action = $view; |
||
1058 | |||
1059 | $this->_viewParams['default_url_params'] = array('action' => 'show', |
||
1060 | 'id' => $item->getId()); |
||
1061 | $this->view = 'RedirectAfterCrud';*/ |
||
1062 | $this->_viewParams['item'] = $item; |
||
1063 | $this->_viewParams['rank'] = $this->request->get('rank'); |
||
1064 | $this->_viewParams['itemToPaste'] = $itemToPaste; |
||
1065 | $this->_viewParams['srcMode'] = $mode; |
||
1066 | $this->view = 'PasteInProgress'; |
||
1067 | } |
||
1068 | } |
||
1069 | break; |
||
1070 | |||
1071 | case 'approval_create': |
||
1072 | if (!$this->userCanWrite($item->getId())) { |
||
1073 | $this->feedback->log('error', $this->txt('error_perms_edit')); |
||
1074 | $this->view = 'Details'; |
||
1075 | } else { |
||
1076 | $this->view = 'ApprovalCreate'; |
||
1077 | } |
||
1078 | break; |
||
1079 | |||
1080 | case 'approval_delete': |
||
1081 | if (!$this->userCanWrite($item->getId())) { |
||
1082 | $this->feedback->log('error', $this->txt('error_perms_edit')); |
||
1083 | $this->view = 'Details'; |
||
1084 | } else { |
||
1085 | if ($this->request->exist('confirm')) { |
||
1086 | $this->action = $view; |
||
1087 | $this->_actionParams['item'] = $item; |
||
1088 | |||
1089 | // Version |
||
1090 | $vVersion = new Valid_UInt('version'); |
||
1091 | $vVersion->required(); |
||
1092 | if($this->request->valid($vVersion)) { |
||
1093 | $this->_actionParams['version'] = $this->request->get('version'); |
||
1094 | } else { |
||
1095 | $this->_actionParams['version'] = null; |
||
1096 | } |
||
1097 | } |
||
1098 | |||
1099 | $this->_viewParams['default_url_params'] = array('action' => 'details', |
||
1100 | 'section' => 'approval', |
||
1101 | 'id' => $item->getId()); |
||
1102 | $this->view = 'RedirectAfterCrud'; |
||
1103 | } |
||
1104 | break; |
||
1105 | |||
1106 | case 'approval_update': |
||
1107 | if (!$this->userCanWrite($item->getId())) { |
||
1108 | $this->feedback->log('error', $this->txt('error_perms_edit')); |
||
1109 | $this->view = 'Details'; |
||
1110 | } else { |
||
1111 | $this->_actionParams['item'] = $item; |
||
1112 | |||
1113 | // Settings |
||
1114 | $this->_actionParams['status'] = (int) $this->request->get('status'); |
||
1115 | $this->_actionParams['description'] = $this->request->get('description'); |
||
1116 | $this->_actionParams['notification'] = (int) $this->request->get('notification'); |
||
1117 | $this->_actionParams['reminder'] = $this->request->get('reminder'); |
||
1118 | $this->_actionParams['occurence'] = (int) $this->request->get('occurence'); |
||
1119 | $this->_actionParams['period'] = (int) $this->request->get('period'); |
||
1120 | |||
1121 | // Users |
||
1122 | $this->_actionParams['user_list'] = $this->request->get('user_list'); |
||
1123 | $this->_actionParams['ugroup_list'] = null; |
||
1124 | if(is_array($this->request->get('ugroup_list'))) { |
||
1125 | $this->_actionParams['ugroup_list'] = array_map('intval', $this->request->get('ugroup_list')); |
||
1126 | } |
||
1127 | |||
1128 | // Selected users |
||
1129 | $this->_actionParams['sel_user'] = null; |
||
1130 | if(is_array($this->request->get('sel_user'))) { |
||
1131 | $this->_actionParams['sel_user'] = array_map('intval', $this->request->get('sel_user')); |
||
1132 | } |
||
1133 | $allowedAct = array('100', 'mail', 'del'); |
||
1134 | $this->_actionParams['sel_user_act'] = null; |
||
1135 | if(in_array($this->request->get('sel_user_act'), $allowedAct)) { |
||
1136 | $this->_actionParams['sel_user_act'] = $this->request->get('sel_user_act'); |
||
1137 | } |
||
1138 | |||
1139 | // Resend |
||
1140 | $this->_actionParams['resend_notif'] = false; |
||
1141 | if($this->request->get('resend_notif') == 'yes') { |
||
1142 | $this->_actionParams['resend_notif'] = true; |
||
1143 | } |
||
1144 | |||
1145 | // Version |
||
1146 | $vVersion = new Valid_UInt('version'); |
||
1147 | $vVersion->required(); |
||
1148 | if($this->request->valid($vVersion)) { |
||
1149 | $this->_actionParams['version'] = $this->request->get('version'); |
||
1150 | } else { |
||
1151 | $this->_actionParams['version'] = null; |
||
1152 | } |
||
1153 | |||
1154 | // Import |
||
1155 | $vImport = new Valid_WhiteList('app_table_import', array('copy', 'reset', 'empty')); |
||
1156 | $vImport->required(); |
||
1157 | $this->_actionParams['import'] = $this->request->getValidated('app_table_import', $vImport, false); |
||
1158 | |||
1159 | // Owner |
||
1160 | $vOwner = new Valid_String('table_owner'); |
||
1161 | $vOwner->required(); |
||
1162 | $this->_actionParams['table_owner'] = $this->request->getValidated('table_owner', $vOwner, false); |
||
1163 | |||
1164 | // |
||
1165 | // Special handeling of table deletion |
||
1166 | if($this->_actionParams['status'] == PLUGIN_DOCMAN_APPROVAL_TABLE_DELETED) { |
||
1167 | $this->_viewParams['default_url_params'] = array('action' => 'approval_create', |
||
1168 | 'delete' => 'confirm', |
||
1169 | 'id' => $item->getId()); |
||
1170 | } else { |
||
1171 | // Action! |
||
1172 | $this->action = $view; |
||
1173 | $this->_viewParams['default_url_params'] = array('action' => 'approval_create', |
||
1174 | 'id' => $item->getId()); |
||
1175 | } |
||
1176 | if($this->_actionParams['version'] !== null) { |
||
1177 | $this->_viewParams['default_url_params']['version'] = $this->_actionParams['version']; |
||
1178 | } |
||
1179 | $this->view = 'RedirectAfterCrud'; |
||
1180 | } |
||
1181 | break; |
||
1182 | |||
1183 | case 'approval_upd_user': |
||
1184 | if (!$this->userCanWrite($item->getId())) { |
||
1185 | $this->feedback->log('error', $this->txt('error_perms_edit')); |
||
1186 | $this->view = 'Details'; |
||
1187 | } else { |
||
1188 | $this->_actionParams['item'] = $item; |
||
1189 | $this->_actionParams['user_id'] = (int) $this->request->get('user_id'); |
||
1190 | $this->_actionParams['rank'] = $this->request->get('rank'); |
||
1191 | $this->action = $view; |
||
1192 | |||
1193 | $this->_viewParams['default_url_params'] = array('action' => 'approval_create', |
||
1194 | 'id' => $item->getId()); |
||
1195 | $this->view = 'RedirectAfterCrud'; |
||
1196 | } |
||
1197 | break; |
||
1198 | |||
1199 | case 'approval_del_user': |
||
1200 | if (!$this->userCanWrite($item->getId())) { |
||
1201 | $this->feedback->log('error', $this->txt('error_perms_edit')); |
||
1202 | $this->view = 'Details'; |
||
1203 | } else { |
||
1204 | $this->_actionParams['item'] = $item; |
||
1205 | $this->_actionParams['user_id'] = (int) $this->request->get('user_id'); |
||
1206 | $this->action = $view; |
||
1207 | |||
1208 | $this->_viewParams['default_url_params'] = array('action' => 'approval_create', |
||
1209 | 'id' => $item->getId()); |
||
1210 | $this->view = 'RedirectAfterCrud'; |
||
1211 | } |
||
1212 | break; |
||
1213 | |||
1214 | case 'approval_user_commit': |
||
1215 | $atf =& Docman_ApprovalTableFactoriesFactory::getFromItem($item); |
||
1216 | $table = $atf->getTable(); |
||
1217 | $atrf =& new Docman_ApprovalTableReviewerFactory($table, $item); |
||
1218 | if (!$this->userCanRead($item->getId()) |
||
1219 | || !$atrf->isReviewer($user->getId()) |
||
1220 | || !$table->isEnabled()) { |
||
1221 | $this->feedback->log('error', $this->txt('error_perms_edit')); |
||
1222 | $this->view = 'Details'; |
||
1223 | } |
||
1224 | else { |
||
1225 | $this->_actionParams['item'] = $item; |
||
1226 | |||
1227 | $svState = 0; |
||
1228 | $sState = (int) $this->request->get('state'); |
||
1229 | if($sState >= 0 && $sState < 5) { |
||
1230 | $svState = $sState; |
||
1231 | } |
||
1232 | $this->_actionParams['svState'] = $svState; |
||
1233 | |||
1234 | $this->_actionParams['sVersion'] = null; |
||
1235 | if($this->request->exist('version')) { |
||
1236 | $sVersion = (int) $this->request->get('version'); |
||
1237 | switch($item_factory->getItemTypeForItem($item)) { |
||
1238 | case PLUGIN_DOCMAN_ITEM_TYPE_WIKI: |
||
1239 | if($sVersion <= 0) { |
||
1240 | $sVersion = null; |
||
1241 | } |
||
1242 | case PLUGIN_DOCMAN_ITEM_TYPE_FILE: |
||
1243 | case PLUGIN_DOCMAN_ITEM_TYPE_EMBEDDEDFILE: |
||
1244 | // assume ok: do nothing. |
||
1245 | break; |
||
1246 | default: |
||
1247 | $sVersion = null; |
||
1248 | } |
||
1249 | $this->_actionParams['sVersion'] = $sVersion; |
||
1250 | } |
||
1251 | $this->_actionParams['usComment'] = $this->request->get('comment'); |
||
1252 | $this->_actionParams['monitor'] = (int) $this->request->get('monitor'); |
||
1253 | |||
1254 | $this->action = $view; |
||
1255 | |||
1256 | $this->_viewParams['default_url_params'] = array('action' => 'details', |
||
1257 | 'section' => 'approval', |
||
1258 | 'id' => $item->getId()); |
||
1259 | $this->view = 'RedirectAfterCrud'; |
||
1260 | } |
||
1261 | break; |
||
1262 | |||
1263 | case 'approval_notif_resend': |
||
1264 | if (!$this->userCanWrite($item->getId())) { |
||
1265 | $this->feedback->log('error', $this->txt('error_perms_edit')); |
||
1266 | $this->view = 'Details'; |
||
1267 | } else { |
||
1268 | $this->action = $view; |
||
1269 | $this->_actionParams['item'] = $item; |
||
1270 | |||
1271 | $this->_viewParams['default_url_params'] = array('action' => 'approval_create', |
||
1272 | 'id' => $item->getId()); |
||
1273 | $this->view = 'RedirectAfterCrud'; |
||
1274 | } |
||
1275 | break; |
||
1276 | |||
1277 | case 'edit': |
||
1278 | if (!$this->userCanWrite($item->getId())) { |
||
1279 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_edit')); |
||
1280 | $this->view = 'Details'; |
||
1281 | } else { |
||
1282 | $mdFactory = new Docman_MetadataFactory($this->_viewParams['group_id']); |
||
1283 | $mdFactory->appendAllListOfValuesToItem($item); |
||
1284 | $this->view = 'Edit'; |
||
1285 | } |
||
1286 | break; |
||
1287 | case 'delete': |
||
1288 | if (!($this->userCanWrite($item->getId()) && $this->userCanWrite($item->getParentId()))) { |
||
1289 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_delete')); |
||
1290 | $this->_set_deleteView_errorPerms(); |
||
1291 | } else if ($this->request->exist('confirm')) { |
||
1292 | $this->action = $view; |
||
1293 | $this->_set_redirectView(); |
||
1294 | } else { |
||
1295 | $this->view = 'Details'; |
||
1296 | } |
||
1297 | break; |
||
1298 | |||
1299 | case 'deleteVersion': |
||
1300 | if (!($this->userCanWrite($item->getId()) && $this->userCanWrite($item->getParentId()))) { |
||
1301 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_delete')); |
||
1302 | $this->_set_deleteView_errorPerms(); |
||
1303 | } else if ($this->request->exist('confirm')) { |
||
1304 | $this->action = $view; |
||
1305 | $this->_set_redirectView(); |
||
1306 | } else { |
||
1307 | $this->view = 'Details'; |
||
1308 | } |
||
1309 | break; |
||
1310 | |||
1311 | case 'createFolder': |
||
1312 | case 'createDocument': |
||
1313 | case 'createItem': |
||
1314 | if ($this->request->exist('cancel')) { |
||
1315 | $this->_set_redirectView(); |
||
1316 | } else { |
||
1317 | $i = $this->request->get('item'); |
||
1318 | if (!$i || !isset($i['parent_id'])) { |
||
1319 | $this->feedback->log('error', 'Missing parameter.'); |
||
1320 | $this->view = 'DocmanError'; |
||
1321 | } else { |
||
1322 | $parent =& $item_factory->getItemFromDb($i['parent_id']); |
||
1323 | if (!$parent || $parent->getGroupId() != $this->getGroupId() || !$this->userCanWrite($parent->getId())) { |
||
1324 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_create')); |
||
1325 | $this->_set_createItemView_errorParentDoesNotExist($item, $get_show_view); |
||
1326 | } else { |
||
1327 | //Validations |
||
1328 | $new_item = $this->createItemFromUserInput(); |
||
1329 | |||
1330 | $valid = $this->_validateRequest(array_merge($new_item->accept(new Docman_View_GetFieldsVisitor()), |
||
1331 | $new_item->accept(new Docman_View_GetSpecificFieldsVisitor(), array('request' => &$this->request)))); |
||
1332 | |||
1333 | if ($user->isMember($this->getGroupId(), 'A') || $user->isMember($this->getGroupId(), 'N1') || $user->isMember($this->getGroupId(), 'N2')) { |
||
1334 | $news = $this->request->get('news'); |
||
1335 | if ($news) { |
||
1336 | $is_news_details = isset($news['details']) && trim($news['details']); |
||
1337 | $is_news_summary = isset($news['summary']) && trim($news['summary']); |
||
1338 | if ($is_news_details && !$is_news_summary) { |
||
1339 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_create_news_summary')); |
||
1340 | $valid = false; |
||
1341 | } |
||
1342 | if (!$is_news_details && $is_news_summary) { |
||
1343 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_create_news_details')); |
||
1344 | $valid = false; |
||
1345 | } |
||
1346 | } |
||
1347 | } |
||
1348 | |||
1349 | if ($valid) { |
||
1350 | $this->action = $view; |
||
1351 | $this->_set_redirectView(); |
||
1352 | } else { |
||
1353 | // Propagate return page |
||
1354 | $this->_viewParams['token'] = $this->request->get('token'); |
||
1355 | |||
1356 | $this->_viewParams['force_item'] = $new_item; |
||
1357 | $this->_viewParams['force_news'] = $this->request->get('news'); |
||
1358 | $this->_viewParams['force_permissions'] = $this->request->get('permissions'); |
||
1359 | $this->_viewParams['force_ordering'] = $this->request->get('ordering'); |
||
1360 | $this->_viewParams['display_permissions'] = $this->request->exist('user_has_displayed_permissions'); |
||
1361 | $this->_viewParams['display_news'] = $this->request->exist('user_has_displayed_news'); |
||
1362 | $this->_viewParams['hierarchy'] =& $this->getItemHierarchy($root); |
||
1363 | $this->_set_createItemView_afterCreate($view); |
||
1364 | } |
||
1365 | } |
||
1366 | } |
||
1367 | } |
||
1368 | break; |
||
1369 | case 'update': |
||
1370 | $this->_viewParams['recurseOnDocs'] = false; |
||
1371 | $this->_actionParams['recurseOnDocs'] = false; |
||
1372 | if($this->request->get('recurse_on_doc') == 1) { |
||
1373 | $this->_viewParams['recurseOnDocs'] = true; |
||
1374 | $this->_actionParams['recurseOnDocs'] = true; |
||
1375 | } |
||
1376 | case 'update_wl': |
||
1377 | case 'new_version': |
||
1378 | if (!$this->userCanWrite($item->getId())) { |
||
1379 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_edit')); |
||
1380 | $this->view = 'Details'; |
||
1381 | } else { |
||
1382 | // For properties update ('update' action), we need to confirm |
||
1383 | // the recursive application of metadata update. |
||
1384 | if($view == 'update' && |
||
1385 | $this->request->exist('recurse') && |
||
1386 | !$this->request->exist('cancel')) { |
||
1387 | $this->_viewParams['recurse'] = $this->request->get('recurse'); |
||
1388 | if(!$this->request->exist('validate_recurse')) { |
||
1389 | $updateConfirmed = false; |
||
1390 | } elseif($this->request->get('validate_recurse') != 'true') { |
||
1391 | $updateConfirmed = false; |
||
1392 | } else { |
||
1393 | $updateConfirmed = true; |
||
1394 | } |
||
1395 | } else { |
||
1396 | $updateConfirmed = true; |
||
1397 | } |
||
1398 | |||
1399 | $valid = true; |
||
1400 | if ($this->request->exist('confirm')) { |
||
1401 | //Validations |
||
1402 | if ($view == 'update') { |
||
1403 | $this->updateMetadataFromUserInput($item); |
||
1404 | $valid = $this->_validateRequest($item->accept(new Docman_View_GetFieldsVisitor())); |
||
1405 | } else { |
||
1406 | $this->updateItemFromUserInput($item); |
||
1407 | $valid = (($this->_validateApprovalTable($this->request, $item))&&($this->_validateRequest($item->accept(new Docman_View_GetSpecificFieldsVisitor(), array('request' => &$this->request))))); |
||
1408 | } |
||
1409 | //Actions |
||
1410 | if ($valid && $updateConfirmed) { |
||
1411 | if ($view == 'update_wl') { |
||
1412 | $this->action = 'update'; |
||
1413 | } else { |
||
1414 | $this->action = $view; |
||
1415 | } |
||
1416 | } |
||
1417 | } |
||
1418 | //Views |
||
1419 | if ($valid && $updateConfirmed) { |
||
1420 | if ($redirect_to = Docman_Token::retrieveUrl($this->request->get('token'))) { |
||
1421 | $this->_viewParams['redirect_to'] = $redirect_to; |
||
1422 | } |
||
1423 | $this->view = 'RedirectAfterCrud'; |
||
1424 | } else { |
||
1425 | if ($view == 'update_wl') { |
||
1426 | $this->view = 'Update'; |
||
1427 | } else if ($view == 'new_version') { |
||
1428 | // Keep fields values |
||
1429 | $v = $this->request->get('version'); |
||
1430 | $this->_viewParams['label'] = $v['label']; |
||
1431 | $this->_viewParams['changelog'] = $v['changelog']; |
||
1432 | if ($item instanceof Docman_EmbeddedFile) { |
||
1433 | $v = $item->getCurrentVersion(); |
||
1434 | $v->setContent($this->request->get('content')); |
||
1435 | } |
||
1436 | $this->view = 'NewVersion'; |
||
1437 | } else { |
||
1438 | $mdFactory = new Docman_MetadataFactory($this->_viewParams['group_id']); |
||
1439 | $mdFactory->appendAllListOfValuesToItem($item); |
||
1440 | if($this->request->existAndNonEmpty('token')) { |
||
1441 | // propagate the token so the user will be |
||
1442 | // redirected to the original page even after |
||
1443 | // several properties update errors or |
||
1444 | // confirmations. |
||
1445 | $this->_viewParams['token'] = $this->request->get('token'); |
||
1446 | } |
||
1447 | $this->_viewParams['updateConfirmed'] = $updateConfirmed; |
||
1448 | // The item may have changed (new user input) |
||
1449 | unset($this->_viewParams['item']); |
||
1450 | $this->_viewParams['item'] =& $item; |
||
1451 | |||
1452 | $this->view = 'Edit'; |
||
1453 | } |
||
1454 | } |
||
1455 | } |
||
1456 | break; |
||
1457 | case 'change_view': |
||
1458 | $this->action = $view; |
||
1459 | break; |
||
1460 | case 'install': |
||
1461 | $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_alreadyinstalled')); |
||
1462 | $this->view = 'DocmanError'; |
||
1463 | break; |
||
1464 | case 'search': |
||
1465 | $this->view = 'Table'; |
||
1466 | break; |
||
1467 | case 'positionWithinFolder': |
||
1468 | $this->_viewParams['force_ordering'] = $this->request->get('default_position'); |
||
1469 | $this->_viewParams['exclude'] = $this->request->get('exclude'); |
||
1470 | $this->_viewParams['hierarchy'] =& $this->getItemHierarchy($root); |
||
1471 | $this->view = ucfirst($view); |
||
1472 | break; |
||
1473 | case 'permissionsForItem': |
||
1474 | $this->_viewParams['user_can_manage'] = $this->userCanManage($item->getId()); |
||
1475 | $this->view = ucfirst($view); |
||
1476 | break; |
||
1477 | case 'report_settings': |
||
1478 | $this->view = 'ReportSettings'; |
||
1479 | break; |
||
1480 | case 'report_del': |
||
1481 | if($this->request->exist('report_id')) { |
||
1482 | $this->_actionParams['sReportId'] = (int) $this->request->get('report_id'); |
||
1483 | $this->_actionParams['sGroupId'] = $this->_viewParams['group_id']; |
||
1484 | |||
1485 | $this->action = $view; |
||
1486 | } |
||
1487 | $this->_viewParams['default_url_params'] = array('action' => 'report_settings'); |
||
1488 | $this->view = 'RedirectAfterCrud'; |
||
1489 | |||
1490 | break; |
||
1491 | case 'report_upd': |
||
1492 | if($this->request->exist('report_id')) { |
||
1493 | $this->_actionParams['sReportId'] = (int) $this->request->get('report_id'); |
||
1494 | $this->_actionParams['sGroupId'] = $this->_viewParams['group_id']; |
||
1495 | $usScope = $this->request->get('scope'); |
||
1496 | if($usScope === 'I' || $usScope === 'P') { |
||
1497 | $this->_actionParams['sScope'] = $usScope; |
||
1498 | } |
||
1499 | $this->_actionParams['description'] = $this->request->get('description'); |
||
1500 | $this->_actionParams['title'] = $this->request->get('title'); |
||
1501 | $this->_actionParams['sImage'] = (int) $this->request->get('image'); |
||
1502 | |||
1503 | $this->action = $view; |
||
1504 | } |
||
1505 | $this->_viewParams['default_url_params'] = array('action' => 'report_settings'); |
||
1506 | $this->view = 'RedirectAfterCrud'; |
||
1507 | break; |
||
1508 | |||
1509 | case 'report_import': |
||
1510 | if($this->request->exist('import_search_report_from_group')) { |
||
1511 | $pm = ProjectManager::instance(); |
||
1512 | $srcGroup = $pm->getProjectFromAutocompleter($this->request->get('import_search_report_from_group')); |
||
1513 | if ($srcGroup && !$srcGroup->isError()) { |
||
1514 | $this->_actionParams['sGroupId'] = $this->_viewParams['group_id']; |
||
1515 | $this->_actionParams['sImportGroupId'] = $srcGroup->getGroupId(); |
||
1516 | $this->_actionParams['sImportReportId'] = null; |
||
1517 | if($this->request->exist('import_report_id') && trim($this->request->get('import_report_id')) != '') { |
||
1518 | $this->_actionParams['sImportReportId'] = (int) $this->request->get('import_report_id'); |
||
1519 | } |
||
1520 | $this->action = $view; |
||
1521 | } |
||
1522 | } |
||
1523 | |||
1524 | $this->_viewParams['default_url_params'] = array('action' => 'report_settings'); |
||
1525 | $this->view = 'RedirectAfterCrud'; |
||
1526 | break; |
||
1527 | |||
1528 | case 'action_lock_add': |
||
1529 | $this->_actionParams['item'] = $item; |
||
1530 | $this->action = 'action_lock_add'; |
||
1531 | break; |
||
1532 | |||
1533 | case 'action_lock_del': |
||
1534 | $this->_actionParams['item'] = $item; |
||
1535 | $this->action = 'action_lock_del'; |
||
1536 | break; |
||
1537 | |||
1538 | case 'ajax_reference_tooltip': |
||
1539 | $this->view = 'AjaxReferenceTooltip'; |
||
1540 | break; |
||
1541 | |||
1542 | default: |
||
1543 | $purifier = Codendi_HTMLPurifier::instance(); |
||
1544 | die($purifier->purify($view) . ' is not supported'); |
||
1545 | break; |
||
1546 | } |
||
1547 | } |
||
1548 | |||
1815 | } |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.