3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This is some kind of special-purpose router/front-controller for the various profile URLs.
21 class CRM_Profile_Page_Router
extends CRM_Core_Page
{
24 * This is some kind of special-purpose router/front-controller for the various profile URLs.
27 * this array contains the arguments of the url.
31 public function run($args = NULL) {
32 if ($args[1] !== 'profile') {
36 $secondArg = CRM_Utils_Array
::value(2, $args, '');
38 if ($secondArg == 'map') {
39 $controller = new CRM_Core_Controller_Simple(
40 'CRM_Contact_Form_Task_Map',
42 NULL, FALSE, FALSE, TRUE
45 $gids = explode(',', CRM_Utils_Request
::retrieve('gid', 'String', CRM_Core_DAO
::$_nullObject, FALSE, 0, 'GET'));
47 if (count($gids) > 1) {
48 foreach ($gids as $pfId) {
49 $profileIds[] = CRM_Utils_Type
::escape($pfId, 'Positive');
51 $controller->set('gid', $profileIds[0]);
52 $profileGID = $profileIds[0];
55 $profileGID = CRM_Utils_Request
::retrieve('gid', 'Integer', $controller, TRUE);
58 // make sure that this profile enables mapping
60 $isMap = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_UFGroup', $profileGID, 'is_map');
62 CRM_Core_Error
::statusBounce(ts('This profile does not have the map feature turned on.'));
65 $profileView = CRM_Utils_Request
::retrieve('pv', 'Integer', $controller, FALSE);
67 // set the userContext stack
68 $session = CRM_Core_Session
::singleton();
70 $session->pushUserContext(CRM_Utils_System
::url('civicrm/profile/view'));
73 $session->pushUserContext(CRM_Utils_System
::url('civicrm/profile', 'force=1'));
76 $controller->set('profileGID', $profileGID);
77 $controller->process();
78 return $controller->run();
81 if ($secondArg == 'edit' ||
$secondArg == 'create') {
82 $allowRemoteSubmit = Civi
::settings()->get('remote_profile_submissions');
83 if ($secondArg == 'edit') {
84 $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Edit',
86 CRM_Core_Action
::UPDATE
,
87 FALSE, FALSE, $allowRemoteSubmit
89 $controller->set('edit', 1);
90 $controller->process();
91 return $controller->run();
94 $wrapper = new CRM_Utils_Wrapper();
95 return $wrapper->run('CRM_Profile_Form_Edit',
98 'mode' => CRM_Core_Action
::ADD
,
99 'ignoreKey' => $allowRemoteSubmit,
105 if ($secondArg == 'view' ||
empty($secondArg)) {
106 $page = new CRM_Profile_Page_Listings();
110 CRM_Utils_System
::permissionDenied();