Newer
Older
function unl_node_prepare($node) {
Eric Rasmussen
committed
$node->menu['expanded'] = 1;
Eric Rasmussen
committed
/**
* Implementation of hook_wywiwyg_plugin() found in wysiwyg.api.php
*/
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function unl_wysiwyg_plugin($editor) {
switch ($editor) {
case 'tinymce':
return array(
'unl' => array(
// A URL to the plugin's homepage.
'url' => 'http://gforge.unl.edu/gf/project/wdn_tinymce/',
// The full path to the native editor plugin.
'path' => $editor['library path'] . '/plugins/unl',
// A list of editor extensions provided by this native plugin.
// Extensions are not displayed as buttons and touch the editor's
// internals, so you should know what you are doing.
'extensions' => array(
'unl' => 'UNL Extension'
),
// Boolean whether this plugin is a native plugin, i.e. shipped with
// the editor. Definition must be ommitted for plugins provided by
// other modules.
'internal' => TRUE,
// Boolean whether the editor needs to load this plugin. When TRUE,
// the editor will automatically load the plugin based on the 'path'
// variable provided. If FALSE, the plugin either does not need to
// be loaded or is already loaded by something else on the page.
// Most plugins should define TRUE here.
'load' => TRUE,
// A list of buttons provided by this native plugin. The key has to
// match the corresponding JavaScript implementation. The value is
// is displayed on the editor configuration form only.
'buttons' => array(
'unlZenBox' => 'UNL Zen Box',
'unlZenTable' => 'UNL Zen Table',
'unlLayout' => 'UNL Layout',
'unlTooltip' => 'UNL Tooltip',
),
// A list of global, native editor configuration settings to
// override. To be used rarely and only when required.
'options' => array(
'skin' => 'unl',
'table_styles' => 'ZenTable Bright (yellow)=zentable bright;ZenTable Cool (blue)=zentable cool;ZenTable Energetic (orange)=zentable energetic;ZenTable Soothing (green)=zentable soothing;ZenTable Primary (red)=zentable primary;ZenTable Neutral (gray)=zentable neutral;', 'doctype' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
),
)
// Wysiwyg wrapper plugin AJAX callback.
// 'callback' => url('myplugin/browse'),
// 'icon' => drupal_get_path('module', 'mymodule') . '/myplugin/myplugin.png',
// Might need to be set later on; after retrieving customized editor
// layout.
//'theme_advanced_buttons1' => array(t('Button title (optional)') => 'myplugin'),
);
}
Eric Rasmussen
committed
function unl_permission() {
return array(
'unl migration' => array(
'title' => t('Migration'),
'description' => t('Migrate UNL Template based sites to drupal'),
),
'unl site creation' => array(
'title' => t('Site Creation'),
'description' => t('Create new drupal sites using the UNL profile'),
Tim Steiner
committed
'restrict access' => TRUE,
),
'unl grant all permissions' => array(
'title' => t('Grant All Permissions'),
'description' => t('If this is not checked, a user can only grant permissions that they themselves have. Requires the "Administer permissions" permission.'),
Tim Steiner
committed
'restrict access' => TRUE,
),
'unl administer administrator permissions' => array(
'title' => t('Administer Administrator\'s Permissions'),
'description' => t('If this is not checked, a user can not change the permissions of the administrator role. Requires the "Administer permissions" permission.'),
'restrict access' => TRUE,
),
Eric Rasmussen
committed
/**
* Adds UNL Migration Tool to the Content menu for admin
*/
function unl_menu() {
$access = array();
$items['admin/content/unl/migration'] = array(
'title' => 'UNL Migration Tool',
'description' => 'Migrate a static UNL template page into drupal',
'access arguments' => array('unl migration'),
'page callback' => 'drupal_get_form',
'page arguments' => array('unl_migration'),
'type' => MENU_LOCAL_TASK,
'file' => 'unl_migration.php',
);
Eric Rasmussen
committed
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
if (conf_path() == 'sites/default') {
$items['admin/sites/unl'] = array(
'title' => 'UNL Site Creation Tool',
'description' => 'Create a new UNL Drupal site',
'access arguments' => array('unl site creation'),
'page callback' => 'drupal_get_form',
'page arguments' => array('unl_site_creation'),
'type' => MENU_LOCAL_TASK,
'file' => 'unl_site_creation.php',
);
$items['admin/sites/unl/add'] = array(
'title' => 'Add',
'description' => 'Determine access to features by selecting permissions for roles.',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -8,
);
$items['admin/sites/unl/list'] = array(
'title' => 'List',
'description' => 'List UNL Drupal sites',
'access arguments' => array('unl site creation'),
'page callback' => 'drupal_get_form',
'page arguments' => array('unl_site_list'),
'type' => MENU_LOCAL_TASK,
'file' => 'unl_site_creation.php',
);
}
function unl_form_alter(&$form, $form_state, $form_id) {
// Make new menu items expanded by default.
if ($form_id == 'menu_edit_item' && $form['mlid']['#value'] == 0) {
$form['expanded']['#default_value'] = TRUE;
}
Tim Steiner
committed
if ($form_id == 'system_site_information_settings') {
$form['site_information']['https'] = array(
'#type' => 'checkbox',
'#title' => 'SSL Enabled',
'#default_value' => variable_get('https', FALSE),
);
$form['#submit'][] = 'unl_system_settings_form_submit';
}
Tim Steiner
committed
if ($form_id == 'user_admin_permissions' && !in_array(variable_get('user_admin_role', -1), array_keys($GLOBALS['user']->roles))) {
Tim Steiner
committed
if (!user_access('unl grant all permissions')) {
// Remove permissions this user doesn't have from the headings list.
foreach ($form['permission'] as $permission => $sub_form) {
if (is_int($permission)) {
continue;
}
if (!user_access($permission)) {
unset($form['permission'][$permission]);
}
}
Tim Steiner
committed
// Remove any empty permission section headings.
$permission_sections = array_keys($form['permission']);
foreach ($permission_sections as $index => $permission_section) {
if (!is_int($permission_section)) {
continue;
}
if (!isset($permission_sections[$index + 1]) || is_int($permission_sections[$index + 1])) {
unset($form['permission'][$permission_section]);
}
}
Tim Steiner
committed
// Remove the permissions this user doesn't have from the checkboxes list.
foreach ($form['checkboxes'] as $role_id => $sub_form) {
foreach ($sub_form['#options'] as $permission => $value) {
if (!user_access($permission)) {
unset($form['checkboxes'][$role_id]['#options'][$permission]);
}
}
}
}
Tim Steiner
committed
if (!user_access('unl administer administrator permissions')) {
$role_id = variable_get('user_admin_role', -1);
unset($form['role_names'][$role_id]);
unset($form['role_names']['#value'][$role_id]);
unset($form['checkboxes'][$role_id]);
}
}
Tim Steiner
committed
}
function unl_system_settings_form_submit($form, &$form_state) {
variable_set('https', (bool) $form_state['values']['https']);
Tim Steiner
committed
function unl_theme() {
return array(
'unl_site_list_table' => array(
'render element' => 'form'
)
);
Tim Steiner
committed
}
Tim Steiner
committed
function unl_url_outbound_alter(&$path, &$options, $original_path) {
$path_parts = parse_url($path);
if (isset($path_parts['scheme']) || $path == 'user/cas') {
return;
}
$user = $GLOBALS['user'];
$user_roles = array_keys($user->roles);
$generic_user = TRUE;
foreach ($user_roles as $user_role) {
if (in_array($user_role, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
continue;
}
$generic_user = FALSE;
}
$options['https'] = (bool) (variable_get('https', 0) && !$generic_user);
}