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
20 * This is some kind of special-purpose router/front-controller for the various profile URLs.
22 class CRM_Profile_Page_Router
extends CRM_Core_Page
{
25 * This is some kind of special-purpose router/front-controller for the various profile URLs.
28 * this array contains the arguments of the url.
32 public function run($args = NULL) {
33 if ($args[1] !== 'profile') {
37 $secondArg = CRM_Utils_Array
::value(2, $args, '');
39 if ($secondArg == 'map') {
40 $controller = new CRM_Core_Controller_Simple(
41 'CRM_Contact_Form_Task_Map',
43 NULL, FALSE, FALSE, TRUE
46 $gids = explode(',', CRM_Utils_Request
::retrieve('gid', 'String', CRM_Core_DAO
::$_nullObject, FALSE, 0, 'GET'));
48 if (count($gids) > 1) {
49 foreach ($gids as $pfId) {
50 $profileIds[] = CRM_Utils_Type
::escape($pfId, 'Positive');
52 $controller->set('gid', $profileIds[0]);
53 $profileGID = $profileIds[0];
56 $profileGID = CRM_Utils_Request
::retrieve('gid', 'Integer', $controller, TRUE);
59 // make sure that this profile enables mapping
61 $isMap = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_UFGroup', $profileGID, 'is_map');
63 CRM_Core_Error
::statusBounce(ts('This profile does not have the map feature turned on.'));
66 $profileView = CRM_Utils_Request
::retrieve('pv', 'Integer', $controller, FALSE);
68 // set the userContext stack
69 $session = CRM_Core_Session
::singleton();
71 $session->pushUserContext(CRM_Utils_System
::url('civicrm/profile/view'));
74 $session->pushUserContext(CRM_Utils_System
::url('civicrm/profile', 'force=1'));
77 $controller->set('profileGID', $profileGID);
78 $controller->process();
79 return $controller->run();
82 if ($secondArg == 'edit' ||
$secondArg == 'create') {
83 $allowRemoteSubmit = Civi
::settings()->get('remote_profile_submissions');
84 if ($secondArg == 'edit') {
85 $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Edit',
87 CRM_Core_Action
::UPDATE
,
88 FALSE, FALSE, $allowRemoteSubmit
90 $controller->set('edit', 1);
91 $controller->process();
92 return $controller->run();
95 $wrapper = new CRM_Utils_Wrapper();
96 return $wrapper->run('CRM_Profile_Form_Edit',
99 'mode' => CRM_Core_Action
::ADD
,
100 'ignoreKey' => $allowRemoteSubmit,
106 if ($secondArg == 'view' ||
empty($secondArg)) {
107 $page = new CRM_Profile_Page_Listings();
111 CRM_Utils_System
::permissionDenied();