diff -rupN imce.old/imce.module imce.new/imce.module --- a/imce.module +++ b/imce.module @@ -19,16 +19,30 @@ function imce_menu() { 'file' => 'inc/imce.page.inc', 'type' => MENU_CALLBACK, ); - $items['user/%user/imce'] = array( - 'title' => 'File browser', - 'page callback' => 'imce_user_page', - 'page arguments' => array(1), - 'access callback' => 'imce_user_page_access', - 'access arguments' => array(1), - 'file' => 'inc/imce.page.inc', - 'type' => MENU_LOCAL_TASK, - 'weight' => 10, - ); + // User menu link + if (1 === variable_get('imce_settings_link_user', 1)) { + $items['user/%user/imce'] = array( + 'title' => 'File browser', + 'page callback' => 'imce_user_page', + 'page arguments' => array(1), + 'access callback' => 'imce_user_page_access', + 'access arguments' => array(1), + 'file' => 'inc/imce.page.inc', + 'type' => MENU_LOCAL_TASK, + 'weight' => 10, + ); + } + // Custom menu link + if (1 === variable_get('imce_settings_link_custom', 0)) { + $items[variable_get('imce_settings_link_path', 'admin/content/imce')] = array( + 'title' => variable_get('imce_settings_link_title', 'File browser'), + 'page callback' => 'imce_user_page', + 'access callback' => 'imce_user_page_access', + 'file' => 'inc/imce.page.inc', + 'type' => variable_get('imce_settings_link_type', MENU_LOCAL_TASK), + 'weight' => 10, + ); + } $items['admin/config/media/imce'] = array( 'title' => 'IMCE', 'description' => 'Control how your image/file browser works.', @@ -186,10 +200,13 @@ function imce_access($user = FALSE, $sch /** * Checks access to user/{$account->uid}/imce for the $user. */ -function imce_user_page_access($account, $user = FALSE) { +function imce_user_page_access($account = FALSE, $user = FALSE) { if ($user === FALSE) { global $user; } + if ($account === FALSE) { + $account = $user; + } return ($user->uid == 1 || $account->uid == $user->uid) && ($profile = imce_user_profile($account)) && $profile['usertab']; } diff -rupN imce.old/inc/imce.admin.inc imce.new/inc/imce.admin.inc --- a/inc/imce.admin.inc +++ b/inc/imce.admin.inc @@ -96,6 +96,52 @@ function imce_admin_form($form, &$form_s '#default_value' => variable_get('imce_settings_disable_private', 1), '#description' => t('IMCE serves all files under private files directory without applying any access restrictions. This allows anonymous access to any file(/system/files/filename) unless there is a module restricting access to the files. Here you can disable this feature.'), ); + $form['common']['link_user'] = array( + '#type' => 'checkbox', + '#title' => t('Provide a user menu tab'), + '#description' => t('Provide a menu tab for each user in among their account pages.'), + '#default_value' => variable_get('imce_settings_link_user', 1), + ); + $form['common']['link_custom'] = array( + '#type' => 'checkbox', + '#title' => t('Provide a custom menu link'), + '#description' => t('Provide a global customizable menu link.'), + '#default_value' => variable_get('imce_settings_link_custom', 0), + ); + $form['common']['link'] = array( + '#type' => 'fieldset', + '#title' => t('Custom link'), + '#collapsible' => true, + '#collapsed' => true, + '#tree' => true, + '#states' => array( + 'enabled' => array( + ':input[name="link_custom"]' => array('checked' => true), + ), + ), + ); + $form['common']['link']['title'] = array( + '#type' => 'textfield', + '#title' => t('Menu link title'), + '#description' => t('Defaults to "File browser".'), + '#default_value' => variable_get('imce_settings_link_title', ''), + ); + $form['common']['link']['path'] = array( + '#type' => 'textfield', + '#title' => t('Menu link placement'), + '#description' => t('Defaults to admin/content/imce.'), + '#default_value' => variable_get('imce_settings_link_path', ''), + ); + $form['common']['link']['type'] = array( + '#type' => 'radios', + '#title' => t('Menu link type'), + '#options' => array( + MENU_CALLBACK => t('Menu link'), + MENU_LOCAL_TASK => t('Menu tab'), + MENU_DEFAULT_LOCAL_TASK => t('Default menu tab'), + ), + '#default_value' => variable_get('imce_settings_link_type', MENU_CALLBACK), + ); $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); $form['#theme'] = 'imce_admin'; @@ -159,7 +205,13 @@ function imce_admin_submit($form, &$form variable_set('imce_settings_replace', $form_state['values']['replace']); variable_set('imce_settings_thumb_method', $form_state['values']['thumb_method']); variable_set('imce_settings_disable_private', $form_state['values']['disable_private']); + variable_set('imce_settings_link_user', $form_state['values']['link_user']); + variable_set('imce_settings_link_custom', $form_state['values']['link_custom']); + variable_set('imce_settings_link_title', $form_state['values']['link']['title']); + variable_set('imce_settings_link_path', $form_state['values']['link']['path']); + variable_set('imce_settings_link_type', $form_state['values']['link']['type']); drupal_set_message(t('Changes have been saved.')); + menu_cache_clear_all(); } /** diff -rupN imce.old/inc/imce.page.inc imce.new/inc/imce.page.inc --- a/inc/imce.page.inc +++ b/inc/imce.page.inc @@ -19,7 +19,11 @@ function imce($scheme = NULL) { /** * q = user/x/imce. */ -function imce_user_page($account) { +function imce_user_page($account = FALSE) { + if ($account === FALSE) { + global $user; + $account = $user; + } return theme('imce_user_page', array('account' => $account)); }