cas_attributes.install in CAS Attributes 7
Same filename and directory in other branches
Installation hooks for the CAS Attributes module.
File
cas_attributes.installView source
<?php
/**
* @file
* Installation hooks for the CAS Attributes module.
*/
/**
* Implements hook_uninstall().
*/
function cas_attributes_uninstall() {
// Delete variables.
variable_del('cas_attributes');
}
/**
* Implements hook_requirements().
*/
function cas_attributes_requirements($phase) {
$requirements = array();
$t = get_t();
if ($phase == 'runtime') {
if (!function_exists('cas_phpcas_attributes')) {
$requirements['cas_attributes'] = array(
'title' => $t('CAS'),
'value' => $t('Outdated'),
'severity' => REQUIREMENT_WARNING,
'description' => $t('CAS attributes requires <a href="@url">CAS</a> version 7.x-1.0 or later.', array(
'@url' => 'http://drupal.org/project/cas',
)),
);
}
// Okay to call functions from cas.module since we are in the runtime
// phase. We hide errors here in case phpcas could not be loaded.
if ($version = @cas_phpcas_load()) {
if (!method_exists('phpCAS', 'getAttributes')) {
$requirements['cas_attributes_phpcas'] = array(
'title' => $t('phpCAS (Attribute support)'),
'value' => $version,
'severity' => REQUIREMENT_WARNING,
'description' => $t('CAS attributes requires <a href="@url">phpCAS</a> version 1.1.0 or later.', array(
'@url' => 'https://wiki.jasig.org/display/CASC/phpCAS',
)),
);
}
}
}
return $requirements;
}
function cas_attributes_update_7100() {
$attr = variable_get('cas_attributes', array());
if (array_key_exists('relations', $attr)) {
foreach ($attr['relations'] as $key => $value) {
$attr['relations'][$key] = preg_replace('/\\[cas:attribute:([^:\\?\\]]*)]/', '[cas:attribute:$1:first]', $value);
}
}
variable_set('cas_attributes', $attr);
}
function cas_attributes_update_7101() {
// split the various settings up into their own smaller, more manageable variables
$attr = variable_get('cas_attributes', array());
if (array_key_exists('overwrite', $attr)) {
variable_set('cas_attributes_overwrite', $attr['overwrite']);
}
if (array_key_exists('sync_every_login', $attr)) {
variable_set('cas_attributes_sync_every_login', $attr['sync_every_login']);
}
if (array_key_exists('relations', $attr)) {
variable_set('cas_attributes_relations', $attr['relations']);
}
if (array_key_exists('roles', $attr)) {
if (array_key_exists('manage', $attr['roles'])) {
variable_set('cas_attributes_roles_manage', $attr['roles']['manage']);
}
if (array_key_exists('mapping', $attr['roles'])) {
variable_set('cas_attributes_roles_mapping', $attr['roles']['mapping']);
}
}
// (this one should only exist if cas_ldap has been used at some point)
if (array_key_exists('ldap', $attr)) {
if (array_key_exists('server', $attr['ldap'])) {
variable_set('cas_attributes_ldap_server', $attr['ldap']['server']);
}
}
variable_del('cas_attributes');
}
Functions
Name | Description |
---|---|
cas_attributes_requirements | Implements hook_requirements(). |
cas_attributes_uninstall | Implements hook_uninstall(). |
cas_attributes_update_7100 | |
cas_attributes_update_7101 |