Browse Source

Merge branch '7.x' of github.com:daniel-dgi/islandora into daniel-dgi-7.x

Conflicts:
	includes/solution_packs.inc
	islandora.info
pull/392/head
jonathangreen 11 years ago
parent
commit
4194bf70e3
  1. 16
      includes/solution_packs.inc
  2. 1
      islandora.info
  3. 83
      islandora.module
  4. 59
      tests/islandora_tuque.test

16
includes/solution_packs.inc

@ -318,6 +318,14 @@ function islandora_install_solution_pack($module, $op = 'install', $force = FALS
return;
}
// Login as user 1 if the installation is coming from the command line (e.g.
// drush).
if (drupal_is_cli()) {
global $user;
$user = user_load(1);
user_login_finalize();
}
$t = get_t();
// Some general replacements.
@ -412,6 +420,14 @@ function islandora_install_solution_pack($module, $op = 'install', $force = FALS
* directly for each solution pack.
*/
function islandora_uninstall_solution_pack($module, $force = FALSE) {
// Login as user 1 if the uninstall is coming from the command line (e.g.
// drush).
if (drupal_is_cli()) {
global $user;
$user = user_load(1);
user_login_finalize();
}
$t = get_t();
drupal_load('module', 'islandora');
module_load_include('inc', 'islandora', 'includes/utilities');

1
islandora.info

@ -19,4 +19,5 @@ files[] = tests/hooked_access.test
files[] = tests/islandora_manage_permissions.test
files[] = tests/datastream_versions.test
files[] = tests/derivatives.test
files[] = tests/islandora_tuque.test
php = 5.3

83
islandora.module

@ -985,7 +985,7 @@ function islandora_default_islandora_printer_object($object, $alter) {
*
* Includes some very basic error logging.
*
* @param object $user
* @param object $new_user
* The user to connect as.
* @param string $url
* The URL to connect to.
@ -993,23 +993,92 @@ function islandora_default_islandora_printer_object($object, $alter) {
* @return IslandoraTuque
* A IslandoraTuque instance
*/
function islandora_get_tuque_connection($user = NULL, $url = NULL) {
function islandora_get_tuque_connection($new_user = NULL, $url = NULL) {
$tuque = &drupal_static(__FUNCTION__);
global $user;
// $user_for_tuque = NULL;
//
// if TUQUE DOES NOT EXIST {
// if PROVIDED USER IS NOT NULL {
// MAKE TUQUE WITH PROVIDED USER
// }
// else
// {
// MAKE TUQUE WITH GLOBAL USER
// }
// }
// else {
// if PROVIDED USER IS NOT NULL {
// if PROVIDED USER IS NOT TUQUE'S USER {
// MAKE TUQUE WITH PROVIDED USER
// }
// else {
// LEAVE TUQUE ALONE
// }
// }
// else {
// if GLOBAL USER IS NOT TUQUE'S USER {
// MAKE TUQUE WITH GLOBAL USER
// }
// else {
// LEAVE TUQUE ALONE
// }
// }
// }
// If tuque is NULL.
if (!$tuque) {
// If the provided user is not null, pass it along to Tuque.
if ($new_user) {
$tuque = islandora_make_tuque($new_user, $url);
}
// Otherwise give Tuque the global user.
else {
$tuque = islandora_make_tuque($user, $url);
}
}
// Else, tuque already exists. So only make it if the users are different.
else {
if ($new_user) {
// Get the name of the new user. If it's '', then it's actually
// 'anonymous' as far as Tuque is concerned.
$new_user_name = $new_user->name;
if (empty($new_user_name)) {
$new_user_name = 'anonymous';
}
if ($new_user_name != $tuque->connection->username) {
$tuque = islandora_make_tuque($new_user);
}
}
else {
// Get the name of the global user. If it's '', then it's actually
// 'anonymous' as far as Tuque is concerned.
$user_name = $user->name;
if (empty($user_name)) {
$user_name = 'anonymous';
}
if ($user->name != $tuque->connection->username) {
$tuque = islandora_make_tuque($user);
}
}
}
return $tuque;
}
function islandora_make_tuque($user, $url) {
if (IslandoraTuque::exists()) {
try {
$tuque = new IslandoraTuque($user, $url);
return new IslandoraTuque($user, $url);
}
catch (Exception $e) {
drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error');
}
}
else {
return NULL;
}
}
return $tuque;
}
/**
* Loads the object from the given ID if possible.

59
tests/islandora_tuque.test

@ -0,0 +1,59 @@
<?php
/**
* @file
* Tests islandora tuque functionality.
*/
class IslandoraTuqueTestCase extends IslandoraWebTestCase {
/**
* Gets info to display to describe this test.
*
* @see IslandoraWebTestCase::getInfo()
*/
public static function getInfo() {
return array(
'name' => 'Islandora Tuque',
'description' => 'Tests basic tuque functionality.',
'group' => 'Islandora',
);
}
/**
* Prepares enviroment for testing.
*
* @see IslandoraWebTestCase::setUp()
*/
public function setUp() {
parent::setUp(array('islandora'));
}
/**
* Tests that a new tuque instance is created when a new user is provided.
*/
public function testTuqueUserChange() {
global $user;
$tuque = islandora_get_tuque_connection($user);
$old_user_name = $tuque->connection->username;
$new_user = user_load(0);
$tuque = islandora_get_tuque_connection($new_user);
$new_user_name = $tuque->connection->username;
$this->assertNotEqual($old_user_name, $new_user_name, "User in tuque's connection changes when a new user is provided to islandora_get_tuque_connection().");
$old_user_name = $new_user_name;
$tuque = islandora_get_tuque_connection();
$new_user_name = $tuque->connection->username;
$this->assertEqual($old_user_name, $new_user_name, "User in tuque's connection does not change when no user is provided to islandora_get_tuque_connection().");
}
}
Loading…
Cancel
Save