Skip to content

Commit

Permalink
oo-ify permissions page links
Browse files Browse the repository at this point in the history
  • Loading branch information
demeritcowboy committed Nov 17, 2020
1 parent 74a98ec commit bc4824a
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 36 deletions.
42 changes: 6 additions & 36 deletions CRM/Admin/Page/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,19 @@

/**
* Dashboard page for managing Access Control.
*
* For initial version, this page only contains static links - so this class is empty for now.
*/
class CRM_Admin_Page_Access extends CRM_Core_Page {

/**
* @return string
*/
public function run() {
$config = CRM_Core_Config::singleton();

switch ($config->userFramework) {
case 'Drupal':
$this->assign('ufAccessURL', url('admin/people/permissions'));
break;

case 'Drupal6':
$this->assign('ufAccessURL', url('admin/user/permissions'));
break;

case 'Joomla':
//condition based on Joomla version; <= 2.5 uses modal window; >= 3.0 uses full page with return value
if (version_compare(JVERSION, '3.0', 'lt')) {
JHTML::_('behavior.modal');
$url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&tmpl=component';
$jparams = 'rel="{handler: \'iframe\', size: {x: 875, y: 550}, onClose: function() {}}" class="modal"';

$this->assign('ufAccessURL', $url);
$this->assign('jAccessParams', $jparams);
}
else {
$uri = (string) JUri::getInstance();
$return = urlencode(base64_encode($uri));
$url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&return=' . $return;

$this->assign('ufAccessURL', $url);
$this->assign('jAccessParams', '');
}
break;

case 'WordPress':
$this->assign('ufAccessURL', CRM_Utils_System::url('civicrm/admin/access/wp-permissions', 'reset=1'));
break;
$urlParams = CRM_Utils_System::getCMSPermissionsUrlParams();
if (isset($urlParams['ufAccessURL'])) {
$this->assign('ufAccessURL', $urlParams['ufAccessURL']);
}
if (isset($urlParams['jAccessParams'])) {
$this->assign('jAccessParams', $urlParams['jAccessParams']);
}
return parent::run();
}
Expand Down
8 changes: 8 additions & 0 deletions CRM/Utils/System/Backdrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -1049,4 +1049,12 @@ public function sessionStart() {
}
}

/**
* Return the CMS-specific url for its permissions page
* @return array
*/
public function getCMSPermissionsUrlParams() {
return ['ufAccessURL' => url('admin/config/people/permissions')];
}

}
8 changes: 8 additions & 0 deletions CRM/Utils/System/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -1004,4 +1004,12 @@ public function viewsExists() {
public function prePostRedirect() {
}

/**
* Return the CMS-specific url for its permissions page
* @return array
*/
public function getCMSPermissionsUrlParams() {
return NULL;
}

}
8 changes: 8 additions & 0 deletions CRM/Utils/System/Drupal6.php
Original file line number Diff line number Diff line change
Expand Up @@ -809,4 +809,12 @@ public function synchronizeUsers() {
];
}

/**
* Return the CMS-specific url for its permissions page
* @return array
*/
public function getCMSPermissionsUrlParams() {
return ['ufAccessURL' => url('admin/user/permissions')];
}

}
8 changes: 8 additions & 0 deletions CRM/Utils/System/Drupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,4 +827,12 @@ public function viewsExists() {
return FALSE;
}

/**
* Return the CMS-specific url for its permissions page
* @return array
*/
public function getCMSPermissionsUrlParams() {
return ['ufAccessURL' => \Drupal\Core\Url::fromRoute('user.admin_permissions')->toString()];
}

}
8 changes: 8 additions & 0 deletions CRM/Utils/System/DrupalBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,4 +701,12 @@ public function viewsExists() {
return FALSE;
}

/**
* Return the CMS-specific url for its permissions page
* @return array
*/
public function getCMSPermissionsUrlParams() {
return ['ufAccessURL' => url('admin/people/permissions')];
}

}
25 changes: 25 additions & 0 deletions CRM/Utils/System/Joomla.php
Original file line number Diff line number Diff line change
Expand Up @@ -917,4 +917,29 @@ public function getCiviSourceStorage() {
];
}

/**
* Return the CMS-specific url for its permissions page
* @return array
*/
public function getCMSPermissionsUrlParams() {
$ufAccessURL = '';
$jAccessParams = '';
$config = CRM_Core_Config::singleton();
//condition based on Joomla version; <= 2.5 uses modal window; >= 3.0 uses full page with return value
if (version_compare(JVERSION, '3.0', 'lt')) {
JHTML::_('behavior.modal');
$ufAccessURL = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&tmpl=component';
$jAccessParams = 'rel="{handler: \'iframe\', size: {x: 875, y: 550}, onClose: function() {}}" class="modal"';
}
else {
$uri = (string) JUri::getInstance();
$return = urlencode(base64_encode($uri));
$ufAccessURL = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&return=' . $return;
}
return [
'ufAccessURL' => $ufAccessURL,
'jAccessParams' => $jAccessParams,
];
}

}
8 changes: 8 additions & 0 deletions CRM/Utils/System/WordPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -1244,4 +1244,12 @@ private function setAuthCookie($name, $value, $options) {
$_COOKIE[$name] = $value;
}

/**
* Return the CMS-specific url for its permissions page
* @return array
*/
public function getCMSPermissionsUrlParams() {
return ['ufAccessURL' => CRM_Utils_System::url('civicrm/admin/access/wp-permissions', 'reset=1')];
}

}

0 comments on commit bc4824a

Please sign in to comment.