Skip to content
Snippets Groups Projects
Commit 08b07f5a authored by Tim Steiner's avatar Tim Steiner
Browse files

[gh-128] Merging from testing into staging

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@801 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent 19753be1
No related branches found
No related tags found
No related merge requests found
......@@ -13,3 +13,32 @@ function unl_load_zend_framework() {
$autoloader->registerNamespace('Unl_');
$isLoaded = TRUE;
}
/**
* Custom function to get the db prefix of the 'main' site.
*/
function unl_get_shared_db_prefix() {
require 'sites/default/settings.php';
$shared_prefix = $databases['default']['default']['prefix'];
return $shared_prefix;
}
/**
* Custom function.
*/
function unl_shared_variable_get($name, $default = NULL) {
$shared_prefix = unl_get_shared_db_prefix();
$data = db_query(
"SELECT * "
. "FROM {$shared_prefix}variable "
. "WHERE name = :name",
array(':name' => $name)
)->fetchAll();
if (count($data) == 0) {
return $default;
}
return unserialize($data[0]->value);
}
<?php
require_once dirname(__FILE__) . '/includes/common.php';
/**
* Implements hook_field_attach_view_alter().
*/
......@@ -304,7 +306,7 @@ function unl_form_alter(&$form, $form_state, $form_id) {
/**
* Modify the Permissions and Roles forms for non-administrators
*/
$admin_role_id = variable_get('user_admin_role', -1);
$admin_role_id = unl_shared_variable_get('user_admin_role', -1);
if (!in_array($admin_role_id, array_keys($GLOBALS['user']->roles))) {
switch ($form_id) {
// Add additional validation on admin/people/permissions/roles/edit/%
......@@ -534,7 +536,7 @@ function unl_user_access($permissions, $account = NULL) {
* to prevent a user from deleting the administrator role. (This is not needed if permissions are shared and only administrators can edit roles.)
*/
function unl_user_admin_role_validate($form, &$form_state) {
$admin_role_id = variable_get('user_admin_role', -1);
$admin_role_id = unl_shared_variable_get('user_admin_role', -1);
if ($form_state['values']['op'] == t('Delete role')) {
$role = user_role_load_by_name($form_state['values']['name']);
......@@ -669,13 +671,6 @@ function unl_create_db_prefix($site) {
return $db_prefix;
}
function unl_get_shared_db_prefix() {
require 'sites/default/settings.php';
$shared_prefix = $databases['default']['default']['prefix'];
return $shared_prefix;
}
function unl_get_alternate_base_uris() {
$shared_prefix = unl_get_shared_db_prefix();
if (is_array($GLOBALS['databases']['default']['default']['prefix'])) {
......@@ -810,22 +805,6 @@ function unl_send_site_created_email($site = NULL) {
}
}
function unl_shared_variable_get($name, $default = NULL) {
$shared_prefix = unl_get_shared_db_prefix();
$data = db_query(
"SELECT * "
. "FROM {$shared_prefix}variable "
. "WHERE name = :name",
array(':name' => $name)
)->fetchAll();
if (count($data) == 0) {
return $default;
}
return unserialize($data[0]->value);
}
// A simple "I'm still alive" page to check to see that drupal is working.
function unl_still_alive()
{
......
<?php
require_once dirname(__FILE__) . '/unl_loader.php';
unl_load_zend_framework();
require_once dirname(__FILE__) . '/../includes/common.php';
function unl_cas_enable() {
variable_set('user_register', 0);
......@@ -31,6 +30,8 @@ function unl_cas_init() {
* @return Unl_Cas
*/
function unl_cas_get_adapter() {
unl_load_zend_framework();
// Start the session because if drupal doesn't then Zend_Session will.
drupal_session_start();
static $adapter;
......@@ -243,7 +244,7 @@ function unl_cas_user_presave(&$edit, $account, $category) {
$username = $edit['name'];
}
$local_admin_role_id = variable_get('user_admin_role');
$local_admin_role_id = unl_shared_variable_get('user_admin_role');
if (_unl_cas_is_user_default_site_administrator($username)) {
$local_admin_role = user_role_load($local_admin_role_id);
......@@ -269,7 +270,7 @@ function unl_cas_user_login(&$edit, $account) {
return;
}
if (!in_array(variable_get('user_admin_role'), array_keys($account->roles))) {
if (!in_array(unl_shared_variable_get('user_admin_role'), array_keys($account->roles))) {
return;
}
......@@ -280,12 +281,8 @@ function unl_cas_user_login(&$edit, $account) {
}
function _unl_cas_is_user_default_site_administrator($username) {
require 'sites/default/settings.php';
$shared_prefix = $databases['default']['default']['prefix'];
$data = db_query("SELECT value FROM {$shared_prefix}variable WHERE name='user_admin_role'")->fetchCol();
$shared_admin_role_id = unserialize($data[0]);
$shared_prefix = unl_get_shared_db_prefix();
$shared_admin_role_id = unl_shared_variable_get('user_admin_role');
$shared_admin_usernames = db_query("SELECT u.name FROM {$shared_prefix}users AS u JOIN {$shared_prefix}users_roles AS r ON u.uid = r.uid WHERE name=:name AND rid=:rid", array(':name' => $username, ':rid' => $shared_admin_role_id))->fetchCol();
return count($shared_admin_usernames) > 0;
}
......@@ -330,7 +327,7 @@ function unl_cas_set_setting($name, $value) {
function unl_cas_user_is_administrator() {
$user = $GLOBALS['user'];
if ($user && in_array(variable_get('user_admin_role'), array_keys($user->roles))) {
if ($user && in_array(unl_shared_variable_get('user_admin_role'), array_keys($user->roles))) {
return TRUE;
}
return FALSE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment