first import
This commit is contained in:
274
sites/all/modules/mb/LICENSE.txt
Normal file
274
sites/all/modules/mb/LICENSE.txt
Normal file
@@ -0,0 +1,274 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
|
||||
verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to
|
||||
share and change it. By contrast, the GNU General Public License is
|
||||
intended to guarantee your freedom to share and change free software--to
|
||||
make sure the software is free for all its users. This General Public License
|
||||
applies to most of the Free Software Foundation's software and to any other
|
||||
program whose authors commit to using it. (Some other Free Software
|
||||
Foundation software is covered by the GNU Library General Public License
|
||||
instead.) You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our
|
||||
General Public Licenses are designed to make sure that you have the
|
||||
freedom to distribute copies of free software (and charge for this service if
|
||||
you wish), that you receive source code or can get it if you want it, that you
|
||||
can change the software or use pieces of it in new free programs; and that
|
||||
you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to
|
||||
deny you these rights or to ask you to surrender the rights. These restrictions
|
||||
translate to certain responsibilities for you if you distribute copies of the
|
||||
software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for
|
||||
a fee, you must give the recipients all the rights that you have. You must make
|
||||
sure that they, too, receive or can get the source code. And you must show
|
||||
them these terms so they know their rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and (2)
|
||||
offer you this license which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain that
|
||||
everyone understands that there is no warranty for this free software. If the
|
||||
software is modified by someone else and passed on, we want its recipients
|
||||
to know that what they have is not the original, so that any problems
|
||||
introduced by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We
|
||||
wish to avoid the danger that redistributors of a free program will individually
|
||||
obtain patent licenses, in effect making the program proprietary. To prevent
|
||||
this, we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification
|
||||
follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
|
||||
MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains a notice
|
||||
placed by the copyright holder saying it may be distributed under the terms
|
||||
of this General Public License. The "Program", below, refers to any such
|
||||
program or work, and a "work based on the Program" means either the
|
||||
Program or any derivative work under copyright law: that is to say, a work
|
||||
containing the Program or a portion of it, either verbatim or with
|
||||
modifications and/or translated into another language. (Hereinafter, translation
|
||||
is included without limitation in the term "modification".) Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not covered
|
||||
by this License; they are outside its scope. The act of running the Program is
|
||||
not restricted, and the output from the Program is covered only if its contents
|
||||
constitute a work based on the Program (independent of having been made
|
||||
by running the Program). Whether that is true depends on what the Program
|
||||
does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's source
|
||||
code as you receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice and
|
||||
disclaimer of warranty; keep intact all the notices that refer to this License
|
||||
and to the absence of any warranty; and give any other recipients of the
|
||||
Program a copy of this License along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you
|
||||
may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion of it,
|
||||
thus forming a work based on the Program, and copy and distribute such
|
||||
modifications or work under the terms of Section 1 above, provided that you
|
||||
also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices stating that
|
||||
you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in whole or in
|
||||
part contains or is derived from the Program or any part thereof, to be
|
||||
licensed as a whole at no charge to all third parties under the terms of this
|
||||
License.
|
||||
|
||||
c) If the modified program normally reads commands interactively when run,
|
||||
you must cause it, when started running for such interactive use in the most
|
||||
ordinary way, to print or display an announcement including an appropriate
|
||||
copyright notice and a notice that there is no warranty (or else, saying that
|
||||
you provide a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this License.
|
||||
(Exception: if the Program itself is interactive but does not normally print such
|
||||
an announcement, your work based on the Program is not required to print
|
||||
an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable
|
||||
sections of that work are not derived from the Program, and can be
|
||||
reasonably considered independent and separate works in themselves, then
|
||||
this License, and its terms, do not apply to those sections when you distribute
|
||||
them as separate works. But when you distribute the same sections as part
|
||||
of a whole which is a work based on the Program, the distribution of the
|
||||
whole must be on the terms of this License, whose permissions for other
|
||||
licensees extend to the entire whole, and thus to each and every part
|
||||
regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your rights to
|
||||
work written entirely by you; rather, the intent is to exercise the right to
|
||||
control the distribution of derivative or collective works based on the
|
||||
Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of a
|
||||
storage or distribution medium does not bring the other work under the scope
|
||||
of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it, under
|
||||
Section 2) in object code or executable form under the terms of Sections 1
|
||||
and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable source
|
||||
code, which must be distributed under the terms of Sections 1 and 2 above
|
||||
on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three years, to give
|
||||
any third party, for a charge no more than your cost of physically performing
|
||||
source distribution, a complete machine-readable copy of the corresponding
|
||||
source code, to be distributed under the terms of Sections 1 and 2 above on
|
||||
a medium customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer to distribute
|
||||
corresponding source code. (This alternative is allowed only for
|
||||
noncommercial distribution and only if you received the program in object
|
||||
code or executable form with such an offer, in accord with Subsection b
|
||||
above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source code
|
||||
means all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation and
|
||||
installation of the executable. However, as a special exception, the source
|
||||
code distributed need not include anything that is normally distributed (in
|
||||
either source or binary form) with the major components (compiler, kernel,
|
||||
and so on) of the operating system on which the executable runs, unless that
|
||||
component itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering access to
|
||||
copy from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place counts as distribution of the source code,
|
||||
even though third parties are not compelled to copy the source along with the
|
||||
object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program except as
|
||||
expressly provided under this License. Any attempt otherwise to copy,
|
||||
modify, sublicense or distribute the Program is void, and will automatically
|
||||
terminate your rights under this License. However, parties who have received
|
||||
copies, or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not signed it.
|
||||
However, nothing else grants you permission to modify or distribute the
|
||||
Program or its derivative works. These actions are prohibited by law if you
|
||||
do not accept this License. Therefore, by modifying or distributing the
|
||||
Program (or any work based on the Program), you indicate your acceptance
|
||||
of this License to do so, and all its terms and conditions for copying,
|
||||
distributing or modifying the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the original
|
||||
licensor to copy, distribute or modify the Program subject to these terms and
|
||||
conditions. You may not impose any further restrictions on the recipients'
|
||||
exercise of the rights granted herein. You are not responsible for enforcing
|
||||
compliance by third parties to this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues), conditions
|
||||
are imposed on you (whether by court order, agreement or otherwise) that
|
||||
contradict the conditions of this License, they do not excuse you from the
|
||||
conditions of this License. If you cannot distribute so as to satisfy
|
||||
simultaneously your obligations under this License and any other pertinent
|
||||
obligations, then as a consequence you may not distribute the Program at all.
|
||||
For example, if a patent license would not permit royalty-free redistribution
|
||||
of the Program by all those who receive copies directly or indirectly through
|
||||
you, then the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply and
|
||||
the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents or
|
||||
other property right claims or to contest validity of any such claims; this
|
||||
section has the sole purpose of protecting the integrity of the free software
|
||||
distribution system, which is implemented by public license practices. Many
|
||||
people have made generous contributions to the wide range of software
|
||||
distributed through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing to
|
||||
distribute software through any other system and a licensee cannot impose
|
||||
that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a
|
||||
consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in certain
|
||||
countries either by patents or by copyrighted interfaces, the original copyright
|
||||
holder who places the Program under this License may add an explicit
|
||||
geographical distribution limitation excluding those countries, so that
|
||||
distribution is permitted only in or among countries not thus excluded. In such
|
||||
case, this License incorporates the limitation as if written in the body of this
|
||||
License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will be
|
||||
similar in spirit to the present version, but may differ in detail to address new
|
||||
problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies
|
||||
a version number of this License which applies to it and "any later version",
|
||||
you have the option of following the terms and conditions either of that
|
||||
version or of any later version published by the Free Software Foundation. If
|
||||
the Program does not specify a version number of this License, you may
|
||||
choose any version ever published by the Free Software Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free programs
|
||||
whose distribution conditions are different, write to the author to ask for
|
||||
permission. For software which is copyrighted by the Free Software
|
||||
Foundation, write to the Free Software Foundation; we sometimes make
|
||||
exceptions for this. Our decision will be guided by the two goals of
|
||||
preserving the free status of all derivatives of our free software and of
|
||||
promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
|
||||
PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
|
||||
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
|
||||
NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
|
||||
AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
|
||||
ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
|
||||
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
|
||||
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
|
||||
OR DATA BEING RENDERED INACCURATE OR LOSSES
|
||||
SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
|
||||
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
|
||||
IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
|
||||
THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
51
sites/all/modules/mb/README.txt
Normal file
51
sites/all/modules/mb/README.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
The More Buttons (MB) module allows to use additional buttons with Drupal.
|
||||
MB is a suite of several modules:
|
||||
|
||||
- More Buttons
|
||||
- More Buttons Content
|
||||
- More Buttons Comment
|
||||
- More Buttons User
|
||||
- More Buttons Extra
|
||||
|
||||
|
||||
Requirements
|
||||
--------------------------------------------------------------------------------
|
||||
The MB modules are written for Drupal 7.0+.
|
||||
|
||||
|
||||
Installation
|
||||
--------------------------------------------------------------------------------
|
||||
Copy the MB module folder, complete with all sub modules, to your module
|
||||
directory and then enable the modules on the admin modules page.
|
||||
|
||||
|
||||
Documentation
|
||||
--------------------------------------------------------------------------------
|
||||
- More Buttons (MB)
|
||||
|
||||
You can interact with the MB module. You can use the button and tab values,
|
||||
defined by the MB module.
|
||||
For more informations please read the code included comments of the function
|
||||
mb_get_values() in the mb.module file.
|
||||
|
||||
Example to get the "Save and continue" button value:
|
||||
|
||||
$value = module_invoke('mb', 'get_values', 'mb', 'sac');
|
||||
|
||||
Use the t() function to display the value.
|
||||
|
||||
|
||||
Module developers
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Please read the documentation hints for the MB module.
|
||||
|
||||
|
||||
Maintainer
|
||||
--------------------------------------------------------------------------------
|
||||
Quiptime Group
|
||||
Siegfried Neumann
|
||||
www.quiptime.com
|
||||
quiptime [ at ] gmail [ dot ] com
|
||||
|
158
sites/all/modules/mb/mb/mb.admin.inc
Normal file
158
sites/all/modules/mb/mb/mb.admin.inc
Normal file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Function file to administer the MB module settings.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the MB button values settings form.
|
||||
*/
|
||||
function mb_admin() {
|
||||
$module = 'mb';
|
||||
$mb_default_values = mb_default_values($module);
|
||||
$mb_values = mb_get_values($module);
|
||||
|
||||
// Provide customizable button and tab values.
|
||||
// Don't make default value strings translatable here!
|
||||
$form['values'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Button and tab values'),
|
||||
'#description' => t('Use your own names for the buttons and the tab. These names are translatable with the translation interface. Do not enter translated texts here.'),
|
||||
'#collapsible' => FALSE,
|
||||
'#collapsed' => FALSE
|
||||
);
|
||||
$form['values'][$module . '_value_cancel'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Cancel button'),
|
||||
'#size' => 20,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => isset($mb_values['cancel']) ? $mb_values['cancel'] : $mb_default_values['cancel'],
|
||||
'#required' => TRUE,
|
||||
'#prefix' => '<div class="' . $module . '-values-first, ' . $module . '-values-first">'
|
||||
);
|
||||
$form['values'][$module . '_value_sac'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Save and continue button'),
|
||||
'#size' => 20,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => isset($mb_values['sac']) ? $mb_values['sac'] : $mb_default_values['sac'],
|
||||
'#required' => TRUE,
|
||||
'#suffix' => '</div>'
|
||||
);
|
||||
$form['values'][$module . '_value_sacn'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Save and create new button'),
|
||||
'#size' => 20,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => isset($mb_values['sacn']) ? $mb_values['sacn'] : $mb_default_values['sacn'],
|
||||
'#required' => TRUE,
|
||||
'#prefix' => '<div class="' . $module . '-values-last, ' . $module . '-values-last">'
|
||||
);
|
||||
$form['values'][$module . '_value_tabcn'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Create new tab'),
|
||||
'#description' => t('This tab are displayed in addition to the content %edit tab.', array('%edit' => t('Edit'))),
|
||||
'#size' => 20,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => isset($mb_values['tabcn']) ? $mb_values['tabcn'] : $mb_default_values['tabcn'],
|
||||
'#required' => TRUE,
|
||||
'#suffix' => '</div>'
|
||||
);
|
||||
|
||||
$form['submit']['save'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'save',
|
||||
'#value' => t('Save')
|
||||
);
|
||||
$form['submit']['reset'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'reset',
|
||||
'#value' => t('Reset to defaults')
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the MB button values settings form page.
|
||||
*
|
||||
* @return
|
||||
* The complete HTML formatted administer page.
|
||||
*/
|
||||
function theme_mb_admin($variables) {
|
||||
$form = drupal_get_form('mb_admin');
|
||||
|
||||
$output = drupal_render($output);
|
||||
$output .= drupal_render_children($form);
|
||||
|
||||
$output .= '<p style="text-align: right">' . t('Module development by <a href="@development-url">Quiptime Group</a>.', array('@development-url' => url('http://www.quiptime.com'))) . '</p>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings from the admin form.
|
||||
*/
|
||||
function mb_admin_submit($form, &$form_state) {
|
||||
$module = 'mb';
|
||||
$mb_values = array();
|
||||
|
||||
$mb_default_values = mb_default_values($module);
|
||||
|
||||
if ($form_state['clicked_button']['#id'] == 'edit-save') {
|
||||
// Save the MB button value settings.
|
||||
// Don't make value strings translatable here!
|
||||
$mb_values = array(
|
||||
'cancel' => isset($form_state['values'][$module . '_value_cancel']) ? trim($form_state['values'][$module . '_value_cancel']) : $mb_default_values['cancel'],
|
||||
'sac' => isset($form_state['values'][$module . '_value_sac']) ? trim($form_state['values'][$module . '_value_sac']) : $mb_default_values['sac'],
|
||||
'sacn' => isset($form_state['values'][$module . '_value_sacn']) ? trim($form_state['values'][$module . '_value_sacn']) : $mb_default_values['sacn'],
|
||||
'tabcn' => isset($form_state['values'][$module . '_value_tabcn']) ? trim($form_state['values'][$module . '_value_tabcn']) : $mb_default_values['tabcn']
|
||||
);
|
||||
variable_set($module . '_values', $mb_values);
|
||||
|
||||
drupal_set_message(t('The %module settings have been saved.', array('%module' => t('More Buttons'))), 'status');
|
||||
}
|
||||
elseif ($form_state['clicked_button']['#id'] == 'edit-reset') {
|
||||
$form_state['redirect'] = 'admin/config/mb/buttons/reset';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback. Define the confirm form output.
|
||||
*
|
||||
* @return
|
||||
* The confirm form.
|
||||
*/
|
||||
function mb_reset() {
|
||||
$question = t('Are you sure you want to reset all %module settings to their default values?', array('%module' => t('More Buttons')));
|
||||
|
||||
$variables = array(
|
||||
'items' => mb_default_values('mb'),
|
||||
'title' => 'Default values'
|
||||
);
|
||||
|
||||
$information = theme('item_list', $variables);
|
||||
$information .= '<p>' . t('This action cannot be undone.') . '</p>';
|
||||
|
||||
return confirm_form(array(),
|
||||
$question,
|
||||
array('path' => 'admin/config/mb/buttons', 'attributes' => array('class' => 'button')), $information,
|
||||
t('Reset'),
|
||||
t('Cancel')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resave all system variables with their default values to reset the module settings.
|
||||
*/
|
||||
function mb_reset_submit($form, &$form_state) {
|
||||
// Resave variables.
|
||||
$mb_default_values = mb_default_values('mb');
|
||||
variable_set('mb_values', $mb_default_values);
|
||||
|
||||
drupal_set_message(t('The %module settings have been set back.', array('%module' => t('More Buttons'))), 'status');
|
||||
watchdog('More Buttons', 'The %module settings have been set back.', array('%module' => t('More Buttons')), WATCHDOG_NOTICE, l(t('view'), 'admin/config/mb/buttons'));
|
||||
|
||||
$form_state['redirect'] = 'admin/config/mb/buttons';
|
||||
}
|
12
sites/all/modules/mb/mb/mb.info
Normal file
12
sites/all/modules/mb/mb/mb.info
Normal file
@@ -0,0 +1,12 @@
|
||||
name = More Buttons
|
||||
description = "The More Buttons (MB) module allows to use additional buttons with Drupal."
|
||||
package = "More Buttons"
|
||||
core = 7.x
|
||||
files[] = mb.module
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-02-25
|
||||
version = "7.x-1.x-dev"
|
||||
core = "7.x"
|
||||
project = "mb"
|
||||
datestamp = "1298619614"
|
||||
|
23
sites/all/modules/mb/mb/mb.install
Normal file
23
sites/all/modules/mb/mb/mb.install
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installs, updates, and uninstalls More Buttons.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function mb_install() {
|
||||
module_load_include('module', 'mb');
|
||||
$default_values = mb_default_values();
|
||||
variable_set('mb_values', $default_values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function mb_uninstall() {
|
||||
// Remove variables.
|
||||
variable_del('mb_values');
|
||||
}
|
324
sites/all/modules/mb/mb/mb.module
Normal file
324
sites/all/modules/mb/mb/mb.module
Normal file
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* The More Buttons (MB) module allows to use additional buttons with Drupal.
|
||||
*
|
||||
* This module provides functions are used from the MB sub modules.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function mb_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['admin/config/mb'] = array(
|
||||
'title' => 'More Buttons',
|
||||
'position' => 'right',
|
||||
'weight' => -4,
|
||||
'page callback' => 'system_admin_menu_block_page',
|
||||
'access arguments' => array('access administration pages'),
|
||||
'file' => 'system.admin.inc',
|
||||
'file path' => drupal_get_path('module', 'system'),
|
||||
);
|
||||
|
||||
$items['admin/config/mb/buttons'] = array(
|
||||
'title' => 'Button settings',
|
||||
'description' => 'Administer the suite of More Buttons (MB) modules.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('mb_admin'),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'file' => 'mb.admin.inc',
|
||||
'weight' => -10,
|
||||
);
|
||||
$items['admin/config/mb/buttons/values'] = array(
|
||||
'title' => 'Values',
|
||||
'type' => MENU_DEFAULT_LOCAL_TASK,
|
||||
'weight' => -10,
|
||||
);
|
||||
|
||||
$items['admin/config/mb/buttons/reset'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('mb_reset'),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_CALLBACK,
|
||||
'file' => 'mb.admin.inc'
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function mb_theme() {
|
||||
return array(
|
||||
'mb_admin' => array(
|
||||
'variables' => array('form' => NULL),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all More Buttons mappings.
|
||||
*
|
||||
* @param string $module
|
||||
* The name of the MB sub module. Values: mb_content, mb_comment, mb_user
|
||||
*
|
||||
* @return array
|
||||
* The array is keyed with the node types and contains the node type name
|
||||
* and the MB mappings.
|
||||
* Return is sanitized.
|
||||
*/
|
||||
function mb_get_mappings($module) {
|
||||
$mappings = array();
|
||||
$types = array();
|
||||
|
||||
switch ($module) {
|
||||
case 'mb':
|
||||
case 'mb_content':
|
||||
$types = node_type_get_types();
|
||||
|
||||
foreach ($types as $type) {
|
||||
$mappings[check_plain($type->type)] = array(
|
||||
'name' => check_plain($type->name),
|
||||
'extends' => array(
|
||||
'cancel' => variable_get($module . '_cancel_' . $type->type, 0),
|
||||
'sac' => variable_get($module . 'sac_' . $type->type, 0),
|
||||
'tabcn' => variable_get($module . 'tabcn_' . $type->type, 0)
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'mb_comment':
|
||||
$types = node_type_get_types();
|
||||
|
||||
foreach ($types as $type) {
|
||||
$mappings[check_plain($type->type)] = array(
|
||||
'name' => check_plain($type->name),
|
||||
'extends' => array(
|
||||
'cancel' => variable_get($module . '_cancel_' . $type->type, 0)
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'mb_user':
|
||||
$page_types = mb_user_type_get_types();
|
||||
|
||||
foreach ($page_types as $type) {
|
||||
$mappings[$type['type']] = array(
|
||||
'name' => $type['name'],
|
||||
'extends' => array(
|
||||
'cancel' => variable_get($module . '_cancel_' . $type['name'], 0),
|
||||
'sac' => variable_get($module . 'sac_' . $type['name'], 0),
|
||||
'sacn' => variable_get($module . 'sacn_' . $type['name'], 0),
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $mappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all button and tab values or an single value.
|
||||
*
|
||||
* Module developer:
|
||||
* You can use this function to get the values of the buttons or the tab.
|
||||
*
|
||||
* Example to get the "Save and continue" button value:
|
||||
* @code
|
||||
* $value = module_invoke('mb', 'get_values', 'mb', 'sac');
|
||||
* @endcode
|
||||
*
|
||||
* Use the t() function to display the value.
|
||||
*
|
||||
* @param string $module
|
||||
* The short cut name of the MB module. Optional if not used the parameter $value.
|
||||
* Possible values: mb
|
||||
* Note:
|
||||
* The button and tab values, saved with the MB module administration,
|
||||
* are use the parameter mb.
|
||||
* @param string $value
|
||||
* Optional an string to get an single button or tab value.
|
||||
* Possible parameters:
|
||||
* - cancel
|
||||
* - sac
|
||||
* - sacn
|
||||
* - tabcn
|
||||
* @return array or string
|
||||
* - Associative array if the parameter $value not given: key => value
|
||||
* cancel => The configured "Cancel" button value
|
||||
* sac => The configured "Save and continue" button value
|
||||
* sacn => The configured "Save and create new" button value
|
||||
* tabcn => The configured "Create new" tab value
|
||||
*
|
||||
* - String if the parameter $value given.
|
||||
* The configured value.
|
||||
*/
|
||||
function mb_get_values($module = NULL, $value = NULL) {
|
||||
if (!isset($module)) {
|
||||
$module = 'mb';
|
||||
}
|
||||
|
||||
$mb_values = variable_get($module . '_values', array());
|
||||
|
||||
if (!isset($value)) {
|
||||
return $mb_values;
|
||||
}
|
||||
else {
|
||||
$val = isset($mb_values[$value]) ? $mb_values[$value] : t('n/a');
|
||||
return $val;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the button and tab values.
|
||||
*
|
||||
* @param string $module
|
||||
* Optional the MB module. Possible values:
|
||||
* mb, mb_content, mb_comment, mb_user
|
||||
* @param string $value
|
||||
* Optional the needed single value for an button or the tab.
|
||||
* Possible values:
|
||||
* cancel, sac, sacn, tabcn
|
||||
* @return array or string
|
||||
* - Associative array if the parameter $value not given: key => value
|
||||
* cancel => Cancel
|
||||
* sac => Save and continue
|
||||
* sacn => Save and create new'
|
||||
* tabcn => Create new
|
||||
*
|
||||
* - String if the parameter $value given.
|
||||
*/
|
||||
function mb_default_values($module = 'mb', $value = NULL) {
|
||||
// Don't translate the value strings here.
|
||||
switch ($module) {
|
||||
case 'mb':
|
||||
$values = array(
|
||||
'cancel' => 'Cancel',
|
||||
'sac' => 'Save and continue',
|
||||
'sacn' => 'Save and create new',
|
||||
'tabcn' => 'Create new'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'mb_content':
|
||||
$values = array(
|
||||
'cancel' => 'Cancel',
|
||||
'sac' => 'Save and continue',
|
||||
'tabcn' => 'Create new'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'mb_comment':
|
||||
$values = array(
|
||||
'cancel' => 'Cancel'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'mb_user':
|
||||
$values = array(
|
||||
'cancel' => 'Cancel',
|
||||
'sac' => 'Save and continue',
|
||||
'sacn' => 'Save and create new'
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($value)) {
|
||||
$val = isset($values[$value]) ? $values[$value] : t('n/a');
|
||||
return $val;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the button position options.
|
||||
*
|
||||
* Options are usable for the buttons:
|
||||
* - Save and continue
|
||||
* - Save and create new.
|
||||
*
|
||||
* @param string $module
|
||||
* The shortcut name of the MB sub module. Values: mb_content, mb_comment, mb_user
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function mb_save_button_positions($module) {
|
||||
switch ($module) {
|
||||
case 'mb_content':
|
||||
case 'mb_comment':
|
||||
$options = array(
|
||||
0 => t('None'),
|
||||
1 => t('Left of Save'),
|
||||
2 => t('Right of Save')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'mb_user':
|
||||
// The MB user module use two buttons to save.
|
||||
// The + allow the different positions
|
||||
// - further to the right
|
||||
// - further to the left.
|
||||
$options = array(
|
||||
0 => t('None'),
|
||||
1 => t('Left of Save'),
|
||||
2 => t('Left + of Save'),
|
||||
3 => t('Right of Save'),
|
||||
4 => t('Right + of Save')
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the Cancel button position options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function mb_cancel_button_positions() {
|
||||
return array(
|
||||
0 => t('None'),
|
||||
1 => t('Left'),
|
||||
2 => t('Right')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the Create new options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function mb_create_new_options() {
|
||||
return array(
|
||||
0 => t('None'),
|
||||
1 => t('Create new as tab'),
|
||||
2 => t('Create new as action link')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load CSS files.
|
||||
*
|
||||
* @param string $op
|
||||
* Possible values: admin, frontend
|
||||
*/
|
||||
function _mb_load_css($op) {
|
||||
switch ($op) {
|
||||
case 'admin':
|
||||
drupal_add_css(drupal_get_path('module', 'mb') . '/mb_admin.css');
|
||||
break;
|
||||
|
||||
case 'frontend':
|
||||
drupal_add_css(drupal_get_path('module', 'mb') . '/mb_frontend.css');
|
||||
break;
|
||||
}
|
||||
}
|
42
sites/all/modules/mb/mb/mb_admin.css
Normal file
42
sites/all/modules/mb/mb/mb_admin.css
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
#more-node-buttons-admin h3 {
|
||||
margin: 0.75em 0 0.5em 0
|
||||
}
|
||||
.mb-admin-table thead th, .mb-admin-table th, .mb-admin-table tbody {
|
||||
border: none
|
||||
}
|
||||
.mb-admin-table thead th {
|
||||
padding-bottom: 1em
|
||||
}
|
||||
.mb-admin-table .odd, .mb-admin-table .even {
|
||||
background-color: inherit;
|
||||
border: none
|
||||
}
|
||||
.mb-admin-table .odd-mb {
|
||||
background-color: transparent
|
||||
}
|
||||
.mb-admin-table .even-mb {
|
||||
background-color: rgba(200, 200, 200, 0.2)
|
||||
}
|
||||
.mb-admin-table .odd-mb-type td, .mb-admin-table .even-mb-type td {
|
||||
padding-top: 0.5em
|
||||
}
|
||||
.mb-admin-table .odd-mb-elements td, .mb-admin-table .even-mb-elements td {
|
||||
padding-bottom: 1em
|
||||
}
|
||||
#more-node-buttons-admin p {
|
||||
margin: 0 0 0.5em
|
||||
}
|
||||
#more-node-buttons-admin .form-submit {
|
||||
margin: 0.75em 0.5em 1em 0
|
||||
}
|
||||
.mb-values-first, .mb-values-last {
|
||||
display: inline;
|
||||
float: left
|
||||
}
|
||||
.mb-values-last {
|
||||
margin: 0 0 0 3em
|
||||
}
|
||||
.form-wrapper p {
|
||||
margin-top: 0;
|
||||
}
|
1
sites/all/modules/mb/mb/mb_frontend.css
Normal file
1
sites/all/modules/mb/mb/mb_frontend.css
Normal file
@@ -0,0 +1 @@
|
||||
|
177
sites/all/modules/mb/mb_comment/mb_comment.admin.inc
Normal file
177
sites/all/modules/mb/mb_comment/mb_comment.admin.inc
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Function file to administer the MB Comment module settings.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the central MB Content settings form.
|
||||
*/
|
||||
function mb_comment_admin() {
|
||||
$module = 'mb_comment';
|
||||
$mb_comment_mappings = mb_get_mappings($module);
|
||||
$mb_comment_values = mb_get_values($module);
|
||||
|
||||
$form['#mappings'] = $mb_comment_mappings;
|
||||
|
||||
foreach ($mb_comment_mappings as $type => $v) {
|
||||
// It makes no sense to use the MB Content module with the content type panel.
|
||||
if ($type == 'panel') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Provide "Cancel" button settings.
|
||||
$form[$module][$type][$module . '_cancel_' . $type] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => mb_cancel_button_positions(),
|
||||
'#default_value' => variable_get($module . '_cancel_' . $type, 0),
|
||||
);
|
||||
}
|
||||
|
||||
$form['submit']['save'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'save',
|
||||
'#value' => t('Save')
|
||||
);
|
||||
$form['submit']['reset'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'reset',
|
||||
'#value' => t('Reset to defaults'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a central MB Content settings form page.
|
||||
*
|
||||
* @return
|
||||
* The complete HTML formatted administer page.
|
||||
*/
|
||||
function theme_mb_comment_admin($variables) {
|
||||
_mb_load_css('admin');
|
||||
|
||||
$module = 'mb_comment';
|
||||
$mappings = array();
|
||||
$output = '';
|
||||
$extra_info = '';
|
||||
$rows = array();
|
||||
|
||||
$form = drupal_get_form($module . '_admin');
|
||||
$mappings = $form['#mappings'];
|
||||
|
||||
$output = '<h3>' . t('Comment settings') . '</h3>';
|
||||
$output .= '<p>' . t('Which %module functions are used by different content type pages.', array('%module' => t('More Buttons Comment'))) . '</p>';
|
||||
|
||||
$header = array(t('Cancel'));
|
||||
|
||||
$i = 1;
|
||||
foreach ($mappings as $type => $maps) {
|
||||
// It makes no sense to use the MB Comment module with the content type panel.
|
||||
if ($type == 'panel') {
|
||||
// Define an additional information.
|
||||
$extra_info .= '<p>' . t('For the content type %type no settings can be made.', array('%type' => t($mappings['panel']['name']))) . '</p>';
|
||||
continue;
|
||||
}
|
||||
|
||||
// Convert underscores in the machine redeable type names to hyphen for right path building.
|
||||
$parsed_type = str_replace('_', '-', $type);
|
||||
|
||||
// Provide own odd/even functionality.
|
||||
$evenodd = $i % 2 ? 'odd-mb' : 'even-mb';
|
||||
$evenodd = $i & 1 ? 'odd-mb' : 'even-mb';
|
||||
|
||||
$type_link = 'admin/structure/types/manage/' . $parsed_type;
|
||||
$link = l($maps['name'], $type_link, array('query' => array('destination' => 'admin/config/mb/buttons/more-buttons-comment'), 'attributes' => array('title' => t('Edit this content type'))));
|
||||
|
||||
// The content type row; Include an link to directly edit the MB Content settings in the content type.
|
||||
$rows[] = array('data' => array($link), 'class' => array($evenodd . ' ' . $evenodd . '-type'));
|
||||
|
||||
// The row contains the form elements.
|
||||
$rows[] = array(
|
||||
'data' => array(
|
||||
drupal_render($form[$module][$type][$module . '_cancel_' . $type])
|
||||
),
|
||||
'class' => array($evenodd . ' ' . $evenodd . '-elements')
|
||||
);
|
||||
|
||||
unset($form[$module][$type]);
|
||||
++$i;
|
||||
}
|
||||
|
||||
$output .= theme('table', array(
|
||||
'header' => $header,
|
||||
'rows' => $rows,
|
||||
'attributes' => array('class' => array('mb-admin-table', $module . '-admin-table'))
|
||||
));
|
||||
|
||||
// Display additional informations.
|
||||
if ($extra_info != '') {
|
||||
$output .= $extra_info;
|
||||
}
|
||||
|
||||
$output .= drupal_render($output);
|
||||
$output .= drupal_render_children($form);
|
||||
$output .= '<p style="text-align: right">' . t('Module development by <a href="@development-url">Quiptime Group</a>.', array('@development-url' => url('http://www.quiptime.com'))) . '</p>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings from admin form.
|
||||
*/
|
||||
function mb_comment_admin_submit($form, &$form_state) {
|
||||
$module = 'mb_comment';
|
||||
$mappings = $form['#mappings'];
|
||||
|
||||
if ($form_state['clicked_button']['#id'] == 'edit-save') {
|
||||
// Save the MB Comment button settings.
|
||||
foreach ($mappings as $type => $maps) {
|
||||
if ($type == 'panel') {
|
||||
continue;
|
||||
}
|
||||
variable_set($module . '_cancel_' . $type, $form_state['values'][$module . '_cancel_' . $type]);
|
||||
}
|
||||
|
||||
drupal_set_message(t('The %module settings have been saved.', array('%module' => t('More Buttons Comment'))), 'status');
|
||||
}
|
||||
elseif ($form_state['clicked_button']['#id'] == 'edit-reset') {
|
||||
$form_state['redirect'] = 'admin/config/mb/buttons/more-buttons-comment/reset';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback to define the confirm form output.
|
||||
*
|
||||
* @return
|
||||
* The confirm form.
|
||||
*/
|
||||
function mb_comment_reset() {
|
||||
$question = t('Are you sure you want to reset all %module settings?', array('%module' => t('More Buttons Comment')));
|
||||
|
||||
$information = '<p>' . t('This action disables the settings for all buttons. This action cannot be undone.') . '</p>';
|
||||
|
||||
return confirm_form(array(),
|
||||
$question,
|
||||
array('path' => 'admin/config/mb/buttons/more-buttons-comment', 'attributes' => array('class' => 'button')), $information,
|
||||
t('Reset'),
|
||||
t('Cancel')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resave all system variables of the MB Content module to reset the module settings.
|
||||
*/
|
||||
function mb_comment_reset_submit($form, &$form_state) {
|
||||
// Resave variables.
|
||||
$node_types = array_keys(node_type_get_types());
|
||||
foreach ($node_types as $type) {
|
||||
variable_set('mb_comment_cancel_' . $type, 0);
|
||||
}
|
||||
|
||||
drupal_set_message(t('The %module settings have been set back.', array('%module' => t('More Buttons Content'))), 'status');
|
||||
watchdog('More Buttons Comment', 'The %module settings have been set back.', array('%module' => t('More Buttons Comment')), WATCHDOG_NOTICE, l(t('view'), 'admin/config/mb/buttons/more-buttons-comment'));
|
||||
|
||||
$form_state['redirect'] = 'admin/config/mb/buttons/more-buttons-comment';
|
||||
}
|
15
sites/all/modules/mb/mb_comment/mb_comment.info
Normal file
15
sites/all/modules/mb/mb_comment/mb_comment.info
Normal file
@@ -0,0 +1,15 @@
|
||||
name = More Buttons Comment
|
||||
description = "Provides an <em>Cancel</em> button for comments."
|
||||
package = "More Buttons"
|
||||
dependencies[] = comment
|
||||
dependencies[] = mb
|
||||
core = 7.x
|
||||
files[] = mb_comment.module
|
||||
files[] = mb_comment.admin.module
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-02-25
|
||||
version = "7.x-1.x-dev"
|
||||
core = "7.x"
|
||||
project = "mb"
|
||||
datestamp = "1298619614"
|
||||
|
17
sites/all/modules/mb/mb_comment/mb_comment.install
Normal file
17
sites/all/modules/mb/mb_comment/mb_comment.install
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installs, updates, and uninstalls More Buttons Comment.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function mb_comment_uninstall() {
|
||||
// Remove variables.
|
||||
$node_types = array_keys(node_type_get_types());
|
||||
foreach ($node_types as $type) {
|
||||
variable_del('mb_comment_cancel_' . $type);
|
||||
}
|
||||
}
|
200
sites/all/modules/mb/mb_comment/mb_comment.module
Normal file
200
sites/all/modules/mb/mb_comment/mb_comment.module
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides a Cancel button for comments.
|
||||
*
|
||||
* Currently available buttons:
|
||||
* - Cancel
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function mb_comment_permission() {
|
||||
return array(
|
||||
'access mb comment' => array(
|
||||
'title' => t('Use More Comment Buttons'),
|
||||
'description' => t('Use the buttons defined by More Buttons Comment.')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function mb_comment_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['admin/config/mb/buttons/more-buttons-comment'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('mb_comment_admin'),
|
||||
'title' => 'Comments',
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'description' => 'An overview of what content type uses buttons/functions of the MB Comment module.',
|
||||
'file' => 'mb_comment.admin.inc',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 10
|
||||
);
|
||||
$items['admin/config/mb/buttons/more-buttons-comment/reset'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('mb_comment_reset'),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_CALLBACK,
|
||||
'file' => 'mb_comment.admin.inc'
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function mb_comment_theme() {
|
||||
return array(
|
||||
'mb_comment_admin' => array(
|
||||
'variables' => array('form' => NULL),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*/
|
||||
function mb_comment_form_alter(&$form, &$form_state, $form_id) {
|
||||
$module = 'mb_comment';
|
||||
|
||||
if ($form['#id']) {
|
||||
if ($form['#id'] == 'comment-form') {
|
||||
$node = $form['#node'];
|
||||
|
||||
if (arg(0) == 'comment') {
|
||||
$default_values = mb_default_values();
|
||||
$mb_content_values = mb_get_values('mb');
|
||||
$destination = drupal_get_destination();
|
||||
|
||||
$settings = array();
|
||||
$settings['cancel'] = variable_get($module . '_cancel_' . $node->type, 0);
|
||||
|
||||
if (!preg_match('/comment\/reply/', url($_SERVER["HTTP_REFERER"]))) {
|
||||
$form['comment_referer'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => url($_SERVER["HTTP_REFERER"])
|
||||
);
|
||||
}
|
||||
|
||||
$form_state['cache'] = TRUE;
|
||||
|
||||
// Define the "Cancel" form element.
|
||||
if ($settings['cancel'] > 0) {
|
||||
if ($settings['cancel'] == 1) {
|
||||
$weight_cancel = $form['actions']['submit']['#weight'] - 1;
|
||||
}
|
||||
elseif ($settings['cancel'] == 2) {
|
||||
$weight_cancel = 16;
|
||||
}
|
||||
|
||||
$form['actions']['cancel'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => isset($mb_comment_values['cancel']) ? t('@cancel-value', array('@cancel-value' => t($mb_comment_values['cancel']))) : t($default_values['cancel']),
|
||||
'#weight' => 30,
|
||||
'#validate' => array('mb_comment_cancel_validate')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch ($form_id) {
|
||||
case 'node_type_delete_confirm':
|
||||
// Delete MB Comment content type system variables
|
||||
// if content types will be deleted.
|
||||
$form['#submit'][] = 'mb_comment_delete_confirm_submit';
|
||||
|
||||
break;
|
||||
|
||||
case 'node_type_form':
|
||||
// Provide the prepared additional MB Comment button settings.
|
||||
|
||||
// Check the specific case add content type form.
|
||||
if (empty($form['#node_type']->type)) {
|
||||
// Add content type.
|
||||
$type = 'mb_comment_type_dummy';
|
||||
}
|
||||
else {
|
||||
// Edit an content type.
|
||||
$type = $form['#node_type']->type;
|
||||
}
|
||||
|
||||
// It makes no sense to use the MB Comment module with the content type panel.
|
||||
if ($type == 'panel') {
|
||||
return;
|
||||
}
|
||||
|
||||
// The additional button settings.
|
||||
$form['comment_buttons'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Button settings - comments'),
|
||||
'#group' => 'additional_settings',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#weight' => 5,
|
||||
'#attached' => array(
|
||||
'js' => array(drupal_get_path('module', $module) . '/' . $module . '_node_form.js')
|
||||
)
|
||||
);
|
||||
|
||||
// Provide "Cancel" button settings.
|
||||
$form['comment_buttons'][$module . '_cancel'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Cancel button'),
|
||||
'#description' => t('Please select using the button or its position.'),
|
||||
'#options' => mb_cancel_button_positions(),
|
||||
'#default_value' => variable_get($module . '_cancel_' . $type, 0)
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_validate().
|
||||
*
|
||||
* Handle the "Cancel" button validation.
|
||||
*/
|
||||
function mb_comment_cancel_validate(&$form, &$form_state) {
|
||||
// This is the cancel action. No validation required.
|
||||
mb_comment_cancel_action($form, $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* The "Cancel" action.
|
||||
*
|
||||
* Handle different submit actions and make different redirects.
|
||||
*
|
||||
* @see mb_comment_cancel_validate()
|
||||
*/
|
||||
function mb_comment_cancel_action(&$form, &$form_state) {
|
||||
// Hide the error messages.
|
||||
drupal_get_messages('error');
|
||||
|
||||
$redirect = 'node/' . $form['nid']['#value'];
|
||||
|
||||
if (isset($form['comment_referer']['#value'])) {
|
||||
$redirect = $form['comment_referer']['#value'];
|
||||
}
|
||||
|
||||
drupal_goto($redirect);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit callback to delete MB Comment content type system variables
|
||||
* if content types will be deleted.
|
||||
*/
|
||||
function mb_comment_delete_confirm_submit($form, &$form_state) {
|
||||
$module = 'mb_comment';
|
||||
|
||||
foreach ($form_state['build_info']['args'] as $type) {
|
||||
variable_del($module . '_cancel_' . $type->type);
|
||||
}
|
||||
}
|
20
sites/all/modules/mb/mb_comment/mb_comment_node_form.js
Normal file
20
sites/all/modules/mb/mb_comment/mb_comment_node_form.js
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
(function ($) {
|
||||
|
||||
Drupal.behaviors.mbCommentFieldsetSummaries = {
|
||||
attach: function (context) {
|
||||
// Provide the summary for the content type form.
|
||||
$('fieldset#edit-comment-buttons', context).drupalSetSummary(function(context) {
|
||||
var vals = [];
|
||||
|
||||
// Cancel button.
|
||||
var cancel = $("select[name='mb_comment_cancel'] option:selected", context).text();
|
||||
cancel = Drupal.t('Cancel button') + ": " + cancel;
|
||||
vals.push(cancel);
|
||||
|
||||
return Drupal.checkPlain(vals.join(', '));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
194
sites/all/modules/mb/mb_content/mb_content.admin.inc
Normal file
194
sites/all/modules/mb/mb_content/mb_content.admin.inc
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Function file to administer the MB Content module settings.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the central MB Content settings form.
|
||||
*/
|
||||
function mb_content_admin() {
|
||||
$module = 'mb_content';
|
||||
$mb_content_mappings = mb_get_mappings($module);
|
||||
|
||||
$form['#mappings'] = $mb_content_mappings;
|
||||
|
||||
foreach ($mb_content_mappings as $type => $v) {
|
||||
// It makes no sense to use the MB Content module with the content type panel.
|
||||
if ($type == 'panel') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Provide "Cancel" button setting.
|
||||
$form[$module][$type][$module . '_cancel_' . $type] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => mb_cancel_button_positions(),
|
||||
'#default_value' => variable_get($module . '_cancel_' . $type, 0),
|
||||
);
|
||||
// Provide "Save and continue" button setting.
|
||||
$form[$module][$type][$module . '_sac_' . $type] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => mb_save_button_positions($module),
|
||||
'#default_value' => variable_get($module . '_sac_' . $type, 0)
|
||||
);
|
||||
// Provide the "Create new" setting.
|
||||
$form[$module][$type][$module . '_tabcn_' . $type] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => mb_create_new_options(),
|
||||
'#default_value' => variable_get($module . '_tabcn_' . $type, 0)
|
||||
);
|
||||
}
|
||||
|
||||
$form['submit']['save'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'save',
|
||||
'#value' => t('Save')
|
||||
);
|
||||
$form['submit']['reset'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'reset',
|
||||
'#value' => t('Reset to defaults'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a central MB Content settings form page.
|
||||
*
|
||||
* @return
|
||||
* The complete HTML formatted administer page.
|
||||
*/
|
||||
function theme_mb_content_admin($variables) {
|
||||
_mb_load_css('admin');
|
||||
|
||||
$module = 'mb_content';
|
||||
$mappings = array();
|
||||
$output = '';
|
||||
$extra_info = '';
|
||||
$rows = array();
|
||||
|
||||
$form = drupal_get_form($module . '_admin');
|
||||
$mappings = $form['#mappings'];
|
||||
|
||||
$output = '<h3>' . t('Content settings') . '</h3>';
|
||||
$output .= '<p>' . t('Which %module functions are used by different content type pages.', array('%module' => t('More Buttons Content'))) . '</p>';
|
||||
|
||||
$header = array(t('Cancel'), t('Save and continue'), t('Create new'));
|
||||
|
||||
$i = 1;
|
||||
foreach ($mappings as $type => $maps) {
|
||||
// It makes no sense to use the MB Content module with the content type panel.
|
||||
if ($type == 'panel') {
|
||||
// Define an additional information.
|
||||
$extra_info .= '<p>' . t('For the content type %type no settings can be made.', array('%type' => t($mappings['panel']['name']))) . '</p>';
|
||||
continue;
|
||||
}
|
||||
|
||||
// Convert underscores in the machine redeable type names to hyphen for right path building.
|
||||
$parsed_type = str_replace('_', '-', $type);
|
||||
|
||||
// Provide own odd/even functionality.
|
||||
$evenodd = $i % 2 ? 'odd-mb' : 'even-mb';
|
||||
$evenodd = $i & 1 ? 'odd-mb' : 'even-mb';
|
||||
|
||||
$type_link = 'admin/structure/types/manage/' . $parsed_type;
|
||||
$link = l($maps['name'], $type_link, array('query' => array('destination' => 'admin/config/mb/buttons/more-buttons-content'), 'attributes' => array('title' => t('Edit this content type'))));
|
||||
|
||||
// The content type row; Include an link to directly edit the MB Content settings in the content type.
|
||||
$rows[] = array('data' => array($link, array('colspan' => 3)), 'class' => array($evenodd . ' ' . $evenodd . '-type'));
|
||||
|
||||
// The row contains the form elements.
|
||||
$rows[] = array(
|
||||
'data' => array(
|
||||
drupal_render($form[$module][$type][$module . '_cancel_' . $type]),
|
||||
drupal_render($form[$module][$type][$module . '_sac_' . $type]),
|
||||
drupal_render($form[$module][$type][$module . '_tabcn_' . $type])
|
||||
),
|
||||
'class' => array($evenodd . ' ' . $evenodd . '-elements')
|
||||
);
|
||||
|
||||
unset($form[$module][$type]);
|
||||
++$i;
|
||||
}
|
||||
|
||||
$output .= theme('table', array(
|
||||
'header' => $header,
|
||||
'rows' => $rows,
|
||||
'attributes' => array('class' => array('mb-admin-table', $module . '-admin-table'))
|
||||
));
|
||||
|
||||
// Display additional informations.
|
||||
if ($extra_info != '') {
|
||||
$output .= $extra_info;
|
||||
}
|
||||
|
||||
$output .= drupal_render($output);
|
||||
$output .= drupal_render_children($form);
|
||||
$output .= '<p style="text-align: right">' . t('Module development by <a href="@development-url">Quiptime Group</a>.', array('@development-url' => url('http://www.quiptime.com'))) . '</p>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings from admin form.
|
||||
*/
|
||||
function mb_content_admin_submit($form, &$form_state) {
|
||||
$module = 'mb_content';
|
||||
$mappings = $form['#mappings'];
|
||||
|
||||
if ($form_state['clicked_button']['#id'] == 'edit-save') {
|
||||
// Save the MB Content button and tab settings.
|
||||
foreach ($mappings as $type => $maps) {
|
||||
if ($type == 'panel') {
|
||||
continue;
|
||||
}
|
||||
variable_set($module . '_cancel_' . $type, $form_state['values'][$module . '_cancel_' . $type]);
|
||||
variable_set($module . '_sac_' . $type, $form_state['values'][$module . '_sac_' . $type]);
|
||||
variable_set($module . '_tabcn_' . $type, $form_state['values'][$module . '_tabcn_' . $type]);
|
||||
}
|
||||
|
||||
drupal_set_message(t('The %module settings have been saved.', array('%module' => t('More Buttons Content'))), 'status');
|
||||
}
|
||||
elseif ($form_state['clicked_button']['#id'] == 'edit-reset') {
|
||||
$form_state['redirect'] = 'admin/config/mb/buttons/more-buttons-content/reset';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback to define the confirm form output.
|
||||
*
|
||||
* @return
|
||||
* The confirm form.
|
||||
*/
|
||||
function mb_content_reset() {
|
||||
$question = t('Are you sure you want to reset all %module settings?', array('%module' => t('More Buttons Content')));
|
||||
|
||||
$information = '<p>' . t('This action disables the settings for all buttons and the tab. This action cannot be undone.') . '</p>';
|
||||
|
||||
return confirm_form(array(),
|
||||
$question,
|
||||
array('path' => 'admin/config/mb/buttons/more-buttons-content', 'attributes' => array('class' => 'button')), $information,
|
||||
t('Reset'),
|
||||
t('Cancel')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resave all system variables of the MB Content module to reset the module settings.
|
||||
*/
|
||||
function mb_content_reset_submit($form, &$form_state) {
|
||||
// Resave variables.
|
||||
$node_types = array_keys(node_type_get_types());
|
||||
foreach ($node_types as $type) {
|
||||
variable_set('mb_content_cancel_' . $type, 0);
|
||||
variable_set('mb_content_sac_' . $type, 0);
|
||||
variable_set('mb_content_tabcn_' . $type, 0);
|
||||
}
|
||||
|
||||
drupal_set_message(t('The %module settings have been set back.', array('%module' => t('More Buttons Content'))), 'status');
|
||||
watchdog('More Buttons Content', 'The %module settings have been set back.', array('%module' => t('More Buttons Content')), WATCHDOG_NOTICE, l(t('view'), 'admin/config/mb/buttons/more-buttons-content'));
|
||||
|
||||
$form_state['redirect'] = 'admin/config/mb/buttons/more-buttons-content';
|
||||
}
|
14
sites/all/modules/mb/mb_content/mb_content.info
Normal file
14
sites/all/modules/mb/mb_content/mb_content.info
Normal file
@@ -0,0 +1,14 @@
|
||||
name = More Buttons Content
|
||||
description = "Provides additional buttons for nodes such as <em>Cancel</em> and <em>Save and continue</em>."
|
||||
package = "More Buttons"
|
||||
dependencies[] = mb
|
||||
core = 7.x
|
||||
files[] = mb_content.module
|
||||
files[] = mb_content.admin.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-02-25
|
||||
version = "7.x-1.x-dev"
|
||||
core = "7.x"
|
||||
project = "mb"
|
||||
datestamp = "1298619614"
|
||||
|
19
sites/all/modules/mb/mb_content/mb_content.install
Normal file
19
sites/all/modules/mb/mb_content/mb_content.install
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installs, updates, and uninstalls More Buttons Content.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function mb_content_uninstall() {
|
||||
// Remove variables.
|
||||
$node_types = array_keys(node_type_get_types());
|
||||
foreach ($node_types as $type) {
|
||||
variable_del('mb_content_cancel_' . $type);
|
||||
variable_del('mb_content_sac_' . $type);
|
||||
variable_del('mb_content_tabcn_' . $type);
|
||||
}
|
||||
}
|
512
sites/all/modules/mb/mb_content/mb_content.module
Normal file
512
sites/all/modules/mb/mb_content/mb_content.module
Normal file
@@ -0,0 +1,512 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides additional buttons for nodes.
|
||||
*
|
||||
* Currently available buttons:
|
||||
* - Cancel
|
||||
* - Save and Continue
|
||||
*
|
||||
* Furthermore available is the Create new action.
|
||||
* - The action can used as tab in addition to the node View or node Edit tab.
|
||||
* - The action can used as action link.
|
||||
*
|
||||
* @todo
|
||||
* OG compatibility
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function mb_content_permission() {
|
||||
return array(
|
||||
'access mb content' => array(
|
||||
'title' => t('Use More Content Buttons'),
|
||||
'description' => t('Use the buttons defined by More Buttons Content.')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function mb_content_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['admin/config/mb/buttons/more-buttons-content'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('mb_content_admin'),
|
||||
'title' => 'Contents',
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'description' => 'An overview of what content type uses buttons/functions of the MB Content module.',
|
||||
'file' => 'mb_content.admin.inc',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 9
|
||||
);
|
||||
$items['admin/config/mb/buttons/more-buttons-content/reset'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('mb_content_reset'),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_CALLBACK,
|
||||
'file' => 'mb_content.admin.inc'
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Title callback to provide the title for the create new tab.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function mb_content_createnew_title() {
|
||||
$mb_default_values = mb_default_values('mb_content');
|
||||
$mb_values = variable_get('mb_values', array());
|
||||
|
||||
return isset($mb_values['tabcn']) ? $mb_values['tabcn'] : $mb_default_values['tabcn'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function mb_content_theme() {
|
||||
return array(
|
||||
'mb_content_admin' => array(
|
||||
'variables' => array('form' => NULL),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*/
|
||||
function mb_content_form_alter(&$form, &$form_state, $form_id) {
|
||||
// Make sure the form alter changes take place only in certain forms.
|
||||
// Get the right node types.
|
||||
$node_type = '';
|
||||
$module = 'mb_content';
|
||||
|
||||
// Node add/edit forms.
|
||||
if (isset($form['#node']->type) && isset($form['#node_edit_form'])) {
|
||||
$node_type = $form['#node']->type;
|
||||
}
|
||||
// Preparing the administration of MB Content; Content type edit form.
|
||||
elseif (isset($form['type']) && !empty($form['#type']['#value']) && isset($form['#node_edit_form'])) {
|
||||
$node_type = $form['#type']['#value'];
|
||||
}
|
||||
// Prepare the administration of MB Content; Content type add form.
|
||||
elseif (isset($form['#node']->type) && empty($form['#type']['#value']) && isset($form['#node_edit_form'])) {
|
||||
// Use temporary an content type as dummy to handle button management on the "Add content type" page.
|
||||
$node_type = 'mb_content_type_dummy';
|
||||
}
|
||||
|
||||
switch ($form_id) {
|
||||
case 'node_type_form':
|
||||
// Provide the prepared MB Content button settings.
|
||||
|
||||
// Check the specific case add content type form.
|
||||
if (empty($form['#node_type']->type)) {
|
||||
// Add content type.
|
||||
$type = 'mb_content_type_dummy';
|
||||
}
|
||||
else {
|
||||
// Edit an content type.
|
||||
$type = $form['#node_type']->type;
|
||||
}
|
||||
|
||||
// It makes no sense to use the MB Content module with the content type panel.
|
||||
if ($type == 'panel') {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The additional buttons and tab settings.
|
||||
*/
|
||||
$form['node_buttons'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Button settings - content'),
|
||||
'#group' => 'additional_settings',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#weight' => 4,
|
||||
'#attached' => array(
|
||||
'js' => array(drupal_get_path('module', $module) . '/' . $module . '_node_form.js')
|
||||
)
|
||||
);
|
||||
// Provide "Cancel" button settings.
|
||||
$form['node_buttons'][$module . '_cancel'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Cancel button'),
|
||||
'#description' => t('Please select using the button or its position.'),
|
||||
'#options' => mb_cancel_button_positions(),
|
||||
'#default_value' => variable_get($module . '_cancel_' . $type, 0)
|
||||
);
|
||||
// Provide "Save and continue" button settings.
|
||||
$form['node_buttons'][$module . '_sac'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Save and continue button'),
|
||||
'#description' => t('Please select using the button or its position.'),
|
||||
'#options' => mb_save_button_positions($module),
|
||||
'#default_value' => variable_get($module . '_sac_' . $type, 0)
|
||||
);
|
||||
// Provide the "Create new" tab option.
|
||||
$form['node_buttons'][$module . '_tabcn'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Create new tab'),
|
||||
'#description' => t('Enable an "Create new" tab in addition to the %view or %edit tab.', array('%view' => t('View'), '%edit' => t('Edit'))),
|
||||
'#default_value' => variable_get($module . '_tabcn_' . $type, 0)
|
||||
);
|
||||
|
||||
// Use an own submit callback to save the settings
|
||||
// on the add/edit content type forms.
|
||||
$form['#submit'][] = 'mb_content_admin_form_submit';
|
||||
|
||||
break;
|
||||
|
||||
case 'node_type_delete_confirm':
|
||||
// Use an own submit callback to delete MB Content
|
||||
// content type system variables if content types will be deleted.
|
||||
$form['#submit'][] = 'mb_content_delete_confirm_submit';
|
||||
|
||||
break;
|
||||
|
||||
case $node_type . '_node_form':
|
||||
// It makes no sense to use the MB Content module with the content type panel.
|
||||
if ($node_type == 'panel') {
|
||||
return;
|
||||
}
|
||||
|
||||
$mb_default_values = mb_default_values();
|
||||
$mb_content_values = mb_get_values('mb');
|
||||
$destination = drupal_get_destination();
|
||||
|
||||
$settings = array();
|
||||
$settings['cancel'] = variable_get($module . '_cancel_' . $node_type, 0);
|
||||
$settings['sac'] = variable_get($module . '_sac_' . $node_type, 0);
|
||||
$settings['tabcn'] = variable_get($module . '_tabcn_' . $node_type, 0);
|
||||
|
||||
// Insert the referer.
|
||||
$referer = preg_replace('/.*\/node\//', 'node/', url($_SERVER["HTTP_REFERER"]));
|
||||
$form['#referer'] = $referer;
|
||||
|
||||
$form_state['cache'] = TRUE;
|
||||
|
||||
/**
|
||||
* Destination parameter handling.
|
||||
*
|
||||
* Deactivate the destination parameter
|
||||
* and keep these parameter in order to be able to use it anyway.
|
||||
*/
|
||||
if (preg_match('/\?destination/', $form['#action'])) {
|
||||
$form_state['storage']['#mb_redirect'] = preg_replace('/^.*\?destination\=/', '', $form['#action']);
|
||||
}
|
||||
elseif (preg_match('/\?destination/', $form['#referer'])) {
|
||||
$form_state['storage']['#mb_redirect'] = preg_replace('/^.*\?destination\=/', '', $form['#referer']);
|
||||
}
|
||||
$form['#action'] = preg_replace('/\?destination.*/', '', $form['#action']);
|
||||
|
||||
if (isset($form_state['storage']['#mb_redirect'])) {
|
||||
$form['storage']['#mb_redirect'] = $form_state['storage']['#mb_redirect'];
|
||||
}
|
||||
elseif (isset($form['storage']['#mb_redirect'])) {
|
||||
$form_state['#mb_redirect'] = $form['storage']['#mb_redirect'];
|
||||
}
|
||||
|
||||
// Identify the "Create new" tab action.
|
||||
if (preg_match('/node\/\d+/', $referer) && !isset($form_state['clicked_button']['#id'])) {
|
||||
$form['#tabcn_referer'] = $referer;
|
||||
}
|
||||
|
||||
/**
|
||||
* The "Save and continue" form element.
|
||||
*/
|
||||
if ($settings['sac'] > 0) {
|
||||
// Left of Save.
|
||||
if ($settings['sac'] == 1) {
|
||||
$weight_sac = $form['actions']['submit']['#weight'] - 0.025;
|
||||
}
|
||||
// Right of Save
|
||||
if ($settings['sac'] == 2) {
|
||||
$weight_sac = $form['actions']['submit']['#weight'] + 0.025;
|
||||
}
|
||||
|
||||
// Define the "Save and continue" form element.
|
||||
$form['actions']['sac'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => isset($mb_content_values['sac']) ? t('@sac-value', array('@sac-value' => t($mb_content_values['sac']))) : t($mb_default_values['sac']),
|
||||
'#weight' => $weight_sac,
|
||||
'#validate' => array('mb_content_changed_validate'),
|
||||
'#submit' => array('node_form_submit', 'mb_content_sac_submit')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The "Cancel" form element.
|
||||
*/
|
||||
if ($settings['cancel'] > 0) {
|
||||
if ($settings['cancel'] == 1) {
|
||||
$weight_cancel = $form['actions']['submit']['#weight'] - 1;
|
||||
}
|
||||
elseif ($settings['cancel'] == 2) {
|
||||
$weight_cancel = 16;
|
||||
}
|
||||
|
||||
// Define the "Cancel" form element.
|
||||
$form['actions']['cancel'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => isset($mb_content_values['cancel']) ? t('@cancel-value', array('@cancel-value' => t($mb_content_values['cancel']))) : t($mb_default_values['cancel']),
|
||||
'#weight' => $weight_cancel,
|
||||
'#validate' => array('mb_content_cancel_validate'),
|
||||
'#limit_validation_errors' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extra validation for the standard buttons.
|
||||
* Without this break the normal form handling.
|
||||
* @see mb_content_cancel_validate(), mb_content_changed_submit()
|
||||
* Call edit form from admin/content is no needed this callbacks.
|
||||
*/
|
||||
if ($settings['sac'] > 0 || $destination['destination'] != 'admin/content') {
|
||||
$form['actions']['preview']['#validate'][] = 'mb_content_changed_validate';
|
||||
$form['actions']['submit']['#validate'][] = 'mb_content_changed_validate';
|
||||
$form['actions']['delete']['#validate'][] = 'mb_content_changed_validate';
|
||||
// Corresponding submit callbacks.
|
||||
$form['actions']['preview']['#submit'][] = 'mb_content_changed_submit';
|
||||
$form['actions']['submit']['#submit'][] = 'mb_content_changed_submit';
|
||||
}
|
||||
|
||||
// OG compatibility.
|
||||
// Provide the group ID.
|
||||
// Add an new group article.
|
||||
// if (isset($_GET['gids_node'])) {
|
||||
// $gids_node = $_GET['gids_node'];
|
||||
// $form['#mnb']['og']['group_id'] = (int)$gids_node[0];
|
||||
// }
|
||||
// Edit an group article.
|
||||
// $og_context = module_invoke('og', 'get_context_by_url');
|
||||
// if (isset($og_context->nid)) {
|
||||
// $form['#mnb']['og']['group_id'] = $og_context->nid;
|
||||
// }
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu_local_tasks_alter().
|
||||
*
|
||||
* Alter the node local tasks to
|
||||
* - use an destination parameter
|
||||
* - provide the "Create new" tab.
|
||||
*/
|
||||
function mb_content_menu_local_tasks_alter(&$data, $router_item, $root_path) {
|
||||
global $base_url;
|
||||
|
||||
$destination = drupal_get_destination();
|
||||
$module = 'mb_content';
|
||||
|
||||
if ($router_item['tab_root'] == 'node/%') {
|
||||
$node = $router_item['map'][1];
|
||||
$node_type_name = node_type_get_name($node);
|
||||
|
||||
// Add Create new as local task tab.
|
||||
// Note: access_callback no works.
|
||||
if (variable_get('mb_content_tabcn_' . $node->type, 0) == 1) {
|
||||
// Note: The weight setting are not accepted.
|
||||
// Organize the proper tab weight for the new "Create new" tab to display the new tab on the right position.
|
||||
$holder = array();
|
||||
|
||||
// User with node edit permission. The tabs are displayed and the Edit tab exists.
|
||||
if (isset($data['tabs'][0]['output'][1]) && $data['tabs'][0]['output'][1]['#link']['page_callback'] == 'node_page_edit') {
|
||||
$holder = array_splice($data['tabs'][0]['output'], 2);
|
||||
}
|
||||
// User without node edit permission. The tabs are displayed and the Edit tab is not exist.
|
||||
elseif (isset($data['tabs'][0]['output'][1]) && $data['tabs'][0]['output'][1]['#link']['page_callback'] != 'node_page_edit') {
|
||||
$holder = array_splice($data['tabs'][0]['output'], 1);
|
||||
}
|
||||
|
||||
// Insert the new tab.
|
||||
$data['tabs'][0]['output'][] = array(
|
||||
'#theme' => 'menu_local_task',
|
||||
'#link' => array(
|
||||
'title' => mb_content_createnew_title(),
|
||||
'href' => 'node/add/' . $node->type,
|
||||
'tab_root_href' => 'node/' . $node->nid,
|
||||
'weight' => 2,
|
||||
'localized_options' => array(
|
||||
'attributes' => array(
|
||||
'title' => t('Create new @content', array('@content' => t($node_type_name))),
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Rebuild the tabs to display all tabs.
|
||||
$data['tabs'][0]['output'] = array_merge($data['tabs'][0]['output'], $holder);
|
||||
}
|
||||
|
||||
// Add Create new as action link.
|
||||
if ($root_path == 'node/%/edit' && variable_get('mb_content_tabcn_' . $node->type, 0) == 2) {
|
||||
$css_node_type = str_replace('_', '-', $node->type);
|
||||
|
||||
$item = menu_get_item('node/add/' . $node->type);
|
||||
$item['title'] = t('Create new @content', array('@content' => t($node_type_name)));
|
||||
$item['localized_options']['attributes']['class'] = array('node-action-link', 'node-action-link-' . $css_node_type);
|
||||
|
||||
$data['actions']['output'][] = array(
|
||||
'#theme' => 'menu_local_action',
|
||||
'#link' => $item,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_validate().
|
||||
*
|
||||
* Handle the "Cancel" validation.
|
||||
*/
|
||||
function mb_content_cancel_validate($form, &$form_state) {
|
||||
// This is the cancel action. No validation required.
|
||||
mb_content_cancel_action($form, $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_validate().
|
||||
*
|
||||
* Skip the function node_last_changed().
|
||||
*/
|
||||
function mb_content_changed_validate($form, &$form_state) {
|
||||
$form['changed']['#default_value'] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_submit().
|
||||
*
|
||||
* Handle different submit actions and make different redirects.
|
||||
* - "Preview"
|
||||
* - "Save"
|
||||
* - "Delete"
|
||||
*/
|
||||
function mb_content_changed_submit($form, &$form_state) {
|
||||
$redirect = '<front>';
|
||||
|
||||
if ($form_state['clicked_button']['#id'] == 'edit-preview') {
|
||||
$form_state['redirect'] = FALSE;
|
||||
}
|
||||
if ($form_state['clicked_button']['#id'] == 'edit-submit') {
|
||||
$redirect = 'node/' . $form_state['nid'];
|
||||
drupal_goto($redirect);
|
||||
}
|
||||
if ($form_state['clicked_button']['#id'] == 'edit-delete') {
|
||||
$form_state['redirect'] = $redirect;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The "Cancel" action.
|
||||
*
|
||||
* Handle different submit actions and make different redirects.
|
||||
*
|
||||
* @see mb_content_cancel_validate()
|
||||
*/
|
||||
function mb_content_cancel_action($form, &$form_state) {
|
||||
// Hide the error messages.
|
||||
drupal_get_messages('error');
|
||||
|
||||
$redirect = '<front>';
|
||||
// $options query example:
|
||||
// array('query' => array('destination' => 'node/' . $node->nid))
|
||||
$options = array();
|
||||
|
||||
if (arg(0) === 'node' && arg(1) === 'add') {
|
||||
// Limitation:
|
||||
// Exist only one content type this redirect does not work.
|
||||
$redirect = 'node/add';
|
||||
|
||||
if (isset($form['#tabcn_referer'])) {
|
||||
$redirect = $form['#tabcn_referer'];
|
||||
}
|
||||
}
|
||||
|
||||
if (arg(0) === 'node' && is_numeric(arg(1)) && arg(2) === 'edit') {
|
||||
$redirect = 'node/' . arg(1);
|
||||
}
|
||||
|
||||
if (isset($form_state['storage']['#mb_redirect'])) {
|
||||
$redirect = $form_state['storage']['#mb_redirect'];
|
||||
}
|
||||
elseif (isset($form['storage']['#mb_redirect'])) {
|
||||
$redirect = $form['storage']['#mb_redirect'];
|
||||
}
|
||||
|
||||
drupal_goto($redirect, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_submit().
|
||||
*
|
||||
* Handle the "Save and continue" action.
|
||||
*/
|
||||
function mb_content_sac_submit($form, &$form_state) {
|
||||
$destination = drupal_get_destination();
|
||||
|
||||
$nid = $form_state['build_info']['args'][0]->nid;
|
||||
$redirect = 'node/' . $nid . '/edit';
|
||||
|
||||
$form_state['rebuild'] = TRUE;
|
||||
|
||||
if (isset($form_state['storage']['#mb_redirect'])) {
|
||||
$form['storage']['#mb_redirect'] = $form_state['storage']['#mb_redirect'];
|
||||
}
|
||||
elseif (isset($form['storage']['#mb_redirect'])) {
|
||||
$form_state['#mb_redirect'] = $form['storage']['#mb_redirect'];
|
||||
}
|
||||
|
||||
// Is meant edit nodes from content management page.
|
||||
if ($destination['destination'] != 'admin/content') {
|
||||
drupal_get_messages('error');
|
||||
$form_state['redirect'] = $redirect;
|
||||
}
|
||||
|
||||
$form_state['redirect'] = $redirect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_submit().
|
||||
*
|
||||
* Save options from "Add content type" form and administer nodetype form.
|
||||
*/
|
||||
function mb_content_admin_form_submit($form, &$form_state) {
|
||||
// Handle button management on the "Add content type" page.
|
||||
// Delete the dummy content type system variable
|
||||
// and set the right content type system variable.
|
||||
foreach ($form_state['values'] as $key => $value) {
|
||||
if ($key == 'type') {
|
||||
$type = $value;
|
||||
}
|
||||
if (preg_match("/^mb_content_type_dummy/", $key)) {
|
||||
// Insert the right content type.
|
||||
$new_type = preg_replace("/mb_content_type_dummy/", $type, $key);
|
||||
$form_state['values'][$new_type] = $value;
|
||||
// Delete the dummy content type.
|
||||
unset($form_state['values'][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit callback to delete MB Content content type system variables
|
||||
* if content types will be deleted.
|
||||
*/
|
||||
function mb_content_delete_confirm_submit($form, &$form_state) {
|
||||
$module = 'mb_content';
|
||||
|
||||
foreach ($form_state['build_info']['args'] as $type) {
|
||||
variable_del($module . '_cancel_' . $type->type);
|
||||
variable_del($module . '_sac_' . $type->type);
|
||||
variable_del($module . '_tabcn_' . $type->type);
|
||||
}
|
||||
}
|
35
sites/all/modules/mb/mb_content/mb_content_node_form.js
Normal file
35
sites/all/modules/mb/mb_content/mb_content_node_form.js
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
(function ($) {
|
||||
|
||||
Drupal.behaviors.mbContentFieldsetSummaries = {
|
||||
attach: function (context) {
|
||||
// Provide the summary for the content type form.
|
||||
$('fieldset#edit-node-buttons', context).drupalSetSummary(function(context) {
|
||||
var vals = [];
|
||||
|
||||
// Cancel button.
|
||||
var cancel = $("select[name='mb_content_cancel'] option:selected", context).text();
|
||||
cancel = Drupal.t('Cancel button') + ": " + cancel;
|
||||
vals.push(cancel);
|
||||
|
||||
// Save and continue button.
|
||||
var sac = $("select[name='mb_content_sac'] option:selected", context).text();
|
||||
sac = Drupal.t('Save and continue button') + ": " + sac;
|
||||
vals.push(sac);
|
||||
|
||||
// Create new tab.
|
||||
var tabcn = $("input[name='mb_content_tabcn']:checked", context).next('label').text();
|
||||
if (tabcn) {
|
||||
tabcn = Drupal.t('Create new tab') + ": " + tabcn;
|
||||
}
|
||||
else {
|
||||
tabcn = Drupal.t('Create new tab') + ": " + Drupal.t('No tab');
|
||||
}
|
||||
vals.push(tabcn);
|
||||
|
||||
return Drupal.checkPlain(vals.join(', '));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
127
sites/all/modules/mb/mb_extra/mb_extra.admin.inc
Normal file
127
sites/all/modules/mb/mb_extra/mb_extra.admin.inc
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Function file to administer the MB Extra module settings.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the MB Extra settings form.
|
||||
*/
|
||||
function mb_extra_admin() {
|
||||
$module = 'mb_extra';
|
||||
$form = array();
|
||||
|
||||
$description_tabs_destination = '<p>' . t('Use the node local task links with destination parameter.') . '</p>';
|
||||
$description_tabs_destination .= '<p>' . t('If activated the %overlay module is not available this feature.', array('%overlay' => t('Overlay'))) . '</p>';
|
||||
|
||||
$form[$module]['tabs_destination'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Content local tasks'),
|
||||
'#description' => $description_tabs_destination,
|
||||
'#collapsible' => false,
|
||||
'#collapsed' => false,
|
||||
'#tree' => true
|
||||
);
|
||||
$form[$module]['tabs_destination'][$module . '_destination_tabs'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Enable node tab links with destination parameter.'),
|
||||
'#default_value' => variable_get($module . '_destination_tabs', 0)
|
||||
);
|
||||
|
||||
$form[$module]['confirm_cancel'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Confirm cancel'),
|
||||
'#description' => '<p>' . t('Alter the confirm form cancel link to display it as button.') . '</p>',
|
||||
'#collapsible' => false,
|
||||
'#collapsed' => false,
|
||||
'#tree' => true
|
||||
);
|
||||
$form[$module]['confirm_cancel'][$module . '_confirm_cancel'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display link as button'),
|
||||
'#default_value' => variable_get($module . '_confirm_cancel', 0)
|
||||
);
|
||||
|
||||
$form['submit']['save'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'save',
|
||||
'#value' => t('Save')
|
||||
);
|
||||
$form['submit']['reset'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'reset',
|
||||
'#value' => t('Reset to defaults'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the MB Extra settings form page.
|
||||
*
|
||||
* @return
|
||||
* The complete HTML formatted administer page.
|
||||
*/
|
||||
function theme_mb_extra_admin($variables) {
|
||||
_mb_load_css('admin');
|
||||
|
||||
$module = 'mb_extra';
|
||||
$output = '';
|
||||
|
||||
$form = drupal_get_form($module . '_admin');
|
||||
|
||||
$output .= drupal_render($output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings from admin form.
|
||||
*/
|
||||
function mb_extra_admin_submit($form, &$form_state) {
|
||||
$module = 'mb_extra';
|
||||
|
||||
if ($form_state['clicked_button']['#id'] == 'edit-save') {
|
||||
variable_set($module . '_destination_tabs', $form_state['values']['tabs_destination'][$module . '_destination_tabs']);
|
||||
variable_set($module . '_confirm_cancel', $form_state['values']['confirm_cancel'][$module . '_confirm_cancel']);
|
||||
|
||||
drupal_set_message(t('The %module settings have been saved.', array('%module' => t('More Buttons Extra'))), 'status');
|
||||
}
|
||||
elseif ($form_state['clicked_button']['#id'] == 'edit-reset') {
|
||||
$form_state['redirect'] = 'admin/config/mb/buttons/more-buttons-extra/reset';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback to define the confirm form output.
|
||||
*
|
||||
* @return
|
||||
* The confirm form.
|
||||
*/
|
||||
function mb_extra_reset() {
|
||||
$question = t('Are you sure you want to reset all %module settings?', array('%module' => t('More Buttons Extra')));
|
||||
|
||||
$information = '<p>' . t('This action disables the extra settings. This action cannot be undone.') . '</p>';
|
||||
|
||||
return confirm_form(array(),
|
||||
$question,
|
||||
array('path' => 'admin/config/mb/buttons/more-buttons-extra', 'attributes' => array('class' => 'button')), $information,
|
||||
t('Reset'),
|
||||
t('Cancel')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resave extras system variables of the MB Content module to reset the module extra settings.
|
||||
*/
|
||||
function mb_extra_reset_submit($form, &$form_state) {
|
||||
// Resave variables.
|
||||
variable_set('mb_extra_destination_tabs', 0);
|
||||
variable_set('mb_extra_confirm_cancel', 0);
|
||||
|
||||
drupal_set_message(t('The %module settings have been set back.', array('%module' => t('More Buttons Extra'))), 'status');
|
||||
watchdog('More Buttons Extra', 'The %module settings have been set back.', array('%module' => t('More Buttons Extra')), WATCHDOG_NOTICE, l(t('view'), 'admin/config/mb/buttons/more-buttons-extra'));
|
||||
|
||||
$form_state['redirect'] = 'admin/config/mb/buttons/more-buttons-extra';
|
||||
}
|
14
sites/all/modules/mb/mb_extra/mb_extra.info
Normal file
14
sites/all/modules/mb/mb_extra/mb_extra.info
Normal file
@@ -0,0 +1,14 @@
|
||||
name = More Buttons Extra
|
||||
description = "Provides various functions for the expansion of core modules."
|
||||
package = "More Buttons"
|
||||
dependencies[] = mb
|
||||
core = 7.x
|
||||
files[] = mb_extra.module
|
||||
files[] = mb_extra.admin.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-02-25
|
||||
version = "7.x-1.x-dev"
|
||||
core = "7.x"
|
||||
project = "mb"
|
||||
datestamp = "1298619614"
|
||||
|
15
sites/all/modules/mb/mb_extra/mb_extra.install
Normal file
15
sites/all/modules/mb/mb_extra/mb_extra.install
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installs, updates, and uninstalls More Buttons Extra.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function mb_extra_uninstall() {
|
||||
// Remove variables.
|
||||
variable_del('mb_extra_destination_tabs');
|
||||
variable_del('mb_extra_confirm_cancel');
|
||||
}
|
108
sites/all/modules/mb/mb_extra/mb_extra.module
Normal file
108
sites/all/modules/mb/mb_extra/mb_extra.module
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides various functions for the expansion of core modules.
|
||||
*
|
||||
* Implemented:
|
||||
* - Alter menu local task links from node to insert destination parameter.
|
||||
* Children tabs supported to level 1.
|
||||
* - Alter the confirm form cancel link to display the link as button.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function mb_extra_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['admin/config/mb/buttons/more-buttons-extra'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('mb_extra_admin'),
|
||||
'title' => 'Extras',
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'file' => 'mb_extra.admin.inc',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 15
|
||||
);
|
||||
$items['admin/config/mb/buttons/more-buttons-extra/reset'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('mb_extra_reset'),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_CALLBACK,
|
||||
'file' => 'mb_extra.admin.inc'
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter the local tasks to use an destination parameter.
|
||||
*/
|
||||
function mb_extra_menu_local_tasks_alter(&$data, $router_item, $root_path) {
|
||||
if (module_exists('overlay')) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $base_url;
|
||||
|
||||
$module = 'mb_extra';
|
||||
|
||||
if ($router_item['tab_root'] == 'node/%') {
|
||||
if (variable_get($module . '_destination_tabs', 0) == TRUE && count($data['tabs']) > 0) {
|
||||
$destination = drupal_get_destination();
|
||||
|
||||
foreach (element_children($data['tabs'][0]['output']) as $key) {
|
||||
if ($data['tabs'][0]['output'][$key]['#link']['tab_root_href'] != $destination['destination'] && !stristr($destination['destination'], $data['tabs'][0]['output'][$key]['#link']['tab_root_href'])) {
|
||||
$params = $data['tabs'][0]['output'][$key]['#link'];
|
||||
$data['tabs'][0]['output'][$key]['#link']['href'] = $base_url . '/' . $params['href'] . '?destination=' . $destination['destination'];
|
||||
//$data['tabs'][0]['output'][$key]['#link']['tab_root_href'] = $base_url . '/' . $params['tab_root_href'] . '?destination=' . $destination['destination'];
|
||||
//$data['tabs'][0]['output'][$key]['#link']['tab_parent_href'] = $base_url . '/' . $params['tab_parent_href'] . '?destination=' . $destination['destination'];
|
||||
}
|
||||
}
|
||||
|
||||
// Children tabs level 1.
|
||||
if (isset($data['tabs'][1])) {
|
||||
foreach (element_children($data['tabs'][1]['output']) as $key) {
|
||||
if ($data['tabs'][1]['output'][$key]['#link']['tab_root_href'] != $destination['destination']) {
|
||||
$params = $data['tabs'][1]['output'][$key]['#link'];
|
||||
$data['tabs'][1]['output'][$key]['#link']['href'] = $base_url . '/' . $params['href'] . '?destination=' . $destination['destination'];
|
||||
//$data['tabs'][0]['output'][$key]['#link']['tab_root_href'] = $base_url . '/' . $params['tab_root_href'] . '?destination=' . $destination['destination'];
|
||||
//$data['tabs'][0]['output'][$key]['#link']['tab_parent_href'] = $base_url . '/' . $params['tab_parent_href'] . '?destination=' . $destination['destination'];
|
||||
|
||||
if (isset($data['tabs'][1]['output'][$key]['#active'])) {
|
||||
$data['tabs'][1]['output'][$key]['#link']['localized_options'] = array(
|
||||
'attributes' => array(
|
||||
'class' => 'active'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function mb_extra_theme() {
|
||||
return array(
|
||||
'mb_extra_admin' => array(
|
||||
'variables' => array('form' => NULL),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*/
|
||||
function mb_extra_form_alter(&$form, &$form_state, $form_id) {
|
||||
$module = 'mb_extra';
|
||||
|
||||
// Alter the confirm form cancel link to display the link as button.
|
||||
if (isset($form['confirm']) && variable_get($module . '_confirm_cancel', 0) == TRUE) {
|
||||
$form['actions']['cancel']['#attributes']['class'][] = 'button';
|
||||
}
|
||||
}
|
175
sites/all/modules/mb/mb_user/mb_user.admin.inc
Normal file
175
sites/all/modules/mb/mb_user/mb_user.admin.inc
Normal file
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Function file to administer the MB User module settings.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the MB User settings form.
|
||||
*/
|
||||
function mb_user_admin() {
|
||||
$module = 'mb_user';
|
||||
|
||||
$mb_user_mappings = mb_get_mappings($module);
|
||||
$mb_user_values = mb_get_values($module);
|
||||
|
||||
$form['#mappings'] = $mb_user_mappings;
|
||||
|
||||
foreach ($mb_user_mappings as $type => $v) {
|
||||
// Provide "Cancel" button settings.
|
||||
$form[$module][$type][$module . '_cancel_' . $type] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => mb_cancel_button_positions(),
|
||||
'#default_value' => variable_get($module . '_cancel_' . $type, 0),
|
||||
);
|
||||
// Provide "Save and continue" button settings.
|
||||
$form[$module][$type][$module . '_sac_' . $type] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => mb_save_button_positions($module),
|
||||
'#default_value' => variable_get($module . '_sac_' . $type, 0)
|
||||
);
|
||||
// Provide "Save and create new" button settings.
|
||||
$form[$module][$type][$module . '_sacn_' . $type] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => mb_save_button_positions($module),
|
||||
'#default_value' => variable_get($module . '_sacn_' . $type, 0)
|
||||
);
|
||||
}
|
||||
|
||||
$form['submit']['save'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'save',
|
||||
'#value' => t('Save')
|
||||
);
|
||||
$form['submit']['reset'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'reset',
|
||||
'#value' => t('Reset to defaults'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the MB User settings form page.
|
||||
*
|
||||
* @return
|
||||
* The complete HTML formatted administer page.
|
||||
*/
|
||||
function theme_mb_user_admin($variables) {
|
||||
_mb_load_css('admin');
|
||||
|
||||
$module = 'mb_user';
|
||||
$mappings = array();
|
||||
$output = '';
|
||||
$extra_info = '';
|
||||
$rows = array();
|
||||
|
||||
$form = drupal_get_form($module . '_admin');
|
||||
$mappings = $form['#mappings'];
|
||||
|
||||
$output = '<h3>' . t('User settings') . '</h3>';
|
||||
$output .= '<p>' . t('Which %module functions are used by different user pages.', array('%module' => t('More Buttons User'))) . '</p>';
|
||||
|
||||
$header = array(t('Cancel'), t('Save and continue'), t('Save and create new'));
|
||||
|
||||
$i = 1;
|
||||
foreach ($mappings as $type => $maps) {
|
||||
// Provide own odd/even functionality.
|
||||
$evenodd = $i % 2 ? 'odd-mb' : 'even-mb';
|
||||
$evenodd = $i & 1 ? 'odd-mb' : 'even-mb';
|
||||
|
||||
$rows[] = array('data' => array($maps['name'], array('colspan' => 2)), 'class' => array($evenodd . ' ' . $evenodd . '-type'));
|
||||
|
||||
// The row contains the form elements.
|
||||
$rows[] = array(
|
||||
'data' => array(
|
||||
drupal_render($form[$module][$type][$module . '_cancel_' . $type]),
|
||||
drupal_render($form[$module][$type][$module . '_sac_' . $type]),
|
||||
drupal_render($form[$module][$type][$module . '_sacn_' . $type])
|
||||
),
|
||||
'class' => array($evenodd . ' ' . $evenodd . '-elements')
|
||||
);
|
||||
|
||||
unset($form[$module][$type]);
|
||||
++$i;
|
||||
}
|
||||
|
||||
$output .= theme('table', array(
|
||||
'header' => $header,
|
||||
'rows' => $rows,
|
||||
'attributes' => array('class' => array('mb-admin-table', $module . '-admin-table'))
|
||||
));
|
||||
|
||||
// Display additional informations.
|
||||
if ($extra_info != '') {
|
||||
$output .= $extra_info;
|
||||
}
|
||||
|
||||
$output .= drupal_render($output);
|
||||
$output .= drupal_render_children($form);
|
||||
$output .= '<p style="text-align: right">' . t('Module development by <a href="@development-url">Quiptime Group</a>.', array('@development-url' => url('http://www.quiptime.com'))) . '</p>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings from admin form.
|
||||
*/
|
||||
function mb_user_admin_submit($form, &$form_state) {
|
||||
$module = 'mb_user';
|
||||
$mappings = $form['#mappings'];
|
||||
|
||||
if ($form_state['clicked_button']['#id'] == 'edit-save') {
|
||||
// Save the MB User button settings.
|
||||
foreach ($mappings as $type => $maps) {
|
||||
variable_set($module . '_cancel_' . $type, $form_state['values'][$module . '_cancel_' . $type]);
|
||||
variable_set($module . '_sac_' . $type, $form_state['values'][$module . '_sac_' . $type]);
|
||||
variable_set($module . '_sacn_' . $type, $form_state['values'][$module . '_sacn_' . $type]);
|
||||
}
|
||||
|
||||
drupal_set_message(t('Your changes have been saved.'), 'status');
|
||||
}
|
||||
elseif ($form_state['clicked_button']['#id'] == 'edit-reset') {
|
||||
$form_state['redirect'] = 'admin/config/mb/buttons/more-buttons-user/reset';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback to define the confirm form output.
|
||||
*
|
||||
* @return
|
||||
* The confirm form.
|
||||
*/
|
||||
function mb_user_reset() {
|
||||
$question = t('Are you sure you want to reset all %module settings?', array('%module' => t('More Buttons User')));
|
||||
|
||||
$information = '<p>' . t('This action disables the settings for all buttons. This action cannot be undone.') . '</p>';
|
||||
|
||||
return confirm_form(array(),
|
||||
$question,
|
||||
array('path' => 'admin/config/mb/buttons/more-buttons-user', 'attributes' => array('class' => 'button')), $information,
|
||||
t('Reset'),
|
||||
t('Cancel')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resave all system variables of the MB User module to reset the module settings.
|
||||
*/
|
||||
function mb_user_reset_submit($form, &$form_state) {
|
||||
// Resave variables.
|
||||
$page_types = array_keys(mb_user_type_get_types());
|
||||
|
||||
foreach ($page_types as $type) {
|
||||
variable_set('mb_user_cancel_' . $type, 0);
|
||||
variable_set('mb_user_sac_' . $type, 0);
|
||||
variable_set('mb_user_sacn_' . $type, 0);
|
||||
}
|
||||
|
||||
drupal_set_message(t('The %module settings have been set back.', array('%module' => t('More Buttons User'))), 'status');
|
||||
watchdog('More Buttons User', 'The %module settings have been set back.', array('%module' => t('More Buttons User')), WATCHDOG_NOTICE, l(t('view'), 'admin/config/mb/buttons/more-buttons-user'));
|
||||
|
||||
$form_state['redirect'] = 'admin/config/mb/buttons/more-buttons-user';
|
||||
}
|
13
sites/all/modules/mb/mb_user/mb_user.info
Normal file
13
sites/all/modules/mb/mb_user/mb_user.info
Normal file
@@ -0,0 +1,13 @@
|
||||
name = More Buttons User
|
||||
description = "Provides additional buttons for content in user context such as <em>Cancel</em> and <em>Save and continue</em>."
|
||||
package = "More Buttons"
|
||||
dependencies[] = mb
|
||||
core = 7.x
|
||||
files[] = mb_user.module
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-02-25
|
||||
version = "7.x-1.x-dev"
|
||||
core = "7.x"
|
||||
project = "mb"
|
||||
datestamp = "1298619614"
|
||||
|
19
sites/all/modules/mb/mb_user/mb_user.install
Normal file
19
sites/all/modules/mb/mb_user/mb_user.install
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installs, updates, and uninstalls More Buttons User.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function mb_user_uninstall() {
|
||||
// Remove variables.
|
||||
$page_types = array_keys(mb_user_type_get_types());
|
||||
foreach ($page_types as $type) {
|
||||
variable_del('mb_content_cancel_' . $type);
|
||||
variable_del('mb_content_sac_' . $type);
|
||||
variable_del('mb_content_sacn_' . $type);
|
||||
}
|
||||
}
|
236
sites/all/modules/mb/mb_user/mb_user.module
Normal file
236
sites/all/modules/mb/mb_user/mb_user.module
Normal file
@@ -0,0 +1,236 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides additional buttons for content in user context.
|
||||
*
|
||||
* Currently available context:
|
||||
* - User account
|
||||
*
|
||||
* Currently available buttons:
|
||||
* - Cancel
|
||||
* - Save and Continue
|
||||
* - Save and create new
|
||||
*
|
||||
* The "Save and create new" button is only usable for users wth the permission "Administer users".
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function mb_user_permission() {
|
||||
return array(
|
||||
'access mb user' => array(
|
||||
'title' => t('Use More User Buttons'),
|
||||
'description' => t('Use the buttons defined by More Buttons User.')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function mb_user_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['admin/config/mb/buttons/more-buttons-user'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('mb_user_admin'),
|
||||
'title' => 'Users',
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'description' => 'An overview of what page types uses buttons of the MB User module.',
|
||||
'file' => 'mb_user.admin.inc',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 11
|
||||
);
|
||||
$items['admin/config/mb/buttons/more-buttons-user/reset'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('mb_user_reset'),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_CALLBACK,
|
||||
'file' => 'mb_user.admin.inc'
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function mb_user_theme() {
|
||||
return array(
|
||||
'mb_user_admin' => array(
|
||||
'variables' => array('form' => NULL),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*/
|
||||
function mb_user_form_alter(&$form, &$form_state, $form_id) {
|
||||
$module = 'mb_user';
|
||||
|
||||
switch ($form_id) {
|
||||
case 'user_profile_form':
|
||||
$default_values = mb_default_values();
|
||||
$mb_user_values = mb_get_values('mb');
|
||||
|
||||
if (!isset($form['actions']['submit']['#weight'])) {
|
||||
$form['actions']['submit']['#weight'] = 10;
|
||||
}
|
||||
if (isset($form['actions']['cancel'])) {
|
||||
$form['actions']['cancel']['#weight'] = 25;
|
||||
}
|
||||
|
||||
$settings = array();
|
||||
$settings['cancel'] = variable_get($module . '_cancel_user_account', 0);
|
||||
$settings['sac'] = variable_get($module . '_sac_user_account', 0);
|
||||
$settings['sacn'] = variable_get($module . '_sacn_user_account', 0);
|
||||
|
||||
// The "Cancel" form element on user account page.
|
||||
if ($settings['cancel'] > 0) {
|
||||
if ($settings['cancel'] == 1) {
|
||||
$weight_cancel = $form['actions']['submit']['#weight'] - 1;
|
||||
}
|
||||
elseif ($settings['cancel'] == 2) {
|
||||
$weight_cancel = 16;
|
||||
}
|
||||
|
||||
// Define the "Cancel" form element.
|
||||
$form['actions']['cancel_mb'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => isset($mb_user_values['cancel']) ? t('@cancel-value', array('@cancel-value' => t($mb_user_values['cancel']))) : t($default_values['cancel']),
|
||||
'#weight' => $weight_cancel,
|
||||
'#validate' => array('mb_user_cancel_validate')
|
||||
);
|
||||
}
|
||||
|
||||
// The "Save and continue" form element on user account page.
|
||||
if ($settings['sac'] > 0) {
|
||||
// Left
|
||||
if ($settings['sac'] == 1) {
|
||||
$weight_sac = $form['actions']['submit']['#weight'] - 0.025;
|
||||
}
|
||||
// Right
|
||||
if ($settings['sac'] == 2) {
|
||||
$weight_sac = $form['actions']['submit']['#weight'] - 0.050;
|
||||
}
|
||||
//
|
||||
if ($settings['sac'] == 3) {
|
||||
$weight_sac = $form['actions']['submit']['#weight'] + 1.025;
|
||||
}
|
||||
//
|
||||
if ($settings['sac'] == 4) {
|
||||
$weight_sac = $form['actions']['submit']['#weight'] + 1.050;
|
||||
}
|
||||
// Define the "Save and continue" form element.
|
||||
$submit = $form['#submit'];
|
||||
$submit[] = 'mb_user_sac_submit';
|
||||
|
||||
$form['actions']['sac'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => isset($mb_user_values['sac']) ? t('@sac-value', array('@sac-value' => t($mb_user_values['sac']))) : t($default_values['sac']),
|
||||
'#weight' => $weight_sac,
|
||||
'#submit' => $submit
|
||||
);
|
||||
}
|
||||
|
||||
// The "Save and create new" form element on user account page.
|
||||
if ($settings['sacn'] > 0 && user_access('administer users')) {
|
||||
//
|
||||
if ($settings['sacn'] == 1) {
|
||||
$weight_sacn = $form['actions']['submit']['#weight'] - 0.025;
|
||||
}
|
||||
//
|
||||
if ($settings['sacn'] == 2) {
|
||||
$weight_sacn = $form['actions']['submit']['#weight'] - 0.050;
|
||||
}
|
||||
//
|
||||
if ($settings['sacn'] == 3) {
|
||||
$weight_sacn = $form['actions']['submit']['#weight'] + 1.025;
|
||||
}
|
||||
//
|
||||
if ($settings['sacn'] == 4) {
|
||||
$weight_sacn = $form['actions']['submit']['#weight'] + 1.050;
|
||||
}
|
||||
|
||||
// Define the "Save and create new" form element.
|
||||
$submit = $form['#submit'];
|
||||
$submit[] = 'mb_user_sacn_submit';
|
||||
|
||||
$form['actions']['sacn'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => isset($mb_user_values['sacn']) ? t('@sacn-value', array('@sacn-value' => t($mb_user_values['sacn']))) : t($default_values['sacn']),
|
||||
'#weight' => $weight_sacn,
|
||||
'#submit' => $submit
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_validate().
|
||||
*
|
||||
* Handle the "Cancel" button validation.
|
||||
*/
|
||||
function mb_user_cancel_validate($form, &$form_state) {
|
||||
// This is the cancel action. No validation required.
|
||||
mb_user_cancel_action($form, $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* The "Cancel" button action.
|
||||
*
|
||||
* @see mb_user_cancel_validate()
|
||||
*/
|
||||
function mb_user_cancel_action($form, &$form_state) {
|
||||
// Hide the error messages.
|
||||
drupal_get_messages('error');
|
||||
|
||||
$redirect = 'user/' . $form['#user']->uid;
|
||||
|
||||
drupal_goto($redirect);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_submit().
|
||||
*
|
||||
* Handle the "Save and continue" button action.
|
||||
*/
|
||||
function mb_user_sac_submit($form, &$form_state) {
|
||||
$redirect = 'user/' . $form['#user']->uid . '/edit';
|
||||
|
||||
drupal_goto($redirect);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_submit().
|
||||
*
|
||||
* Handle the "Save and create new" button action.
|
||||
*/
|
||||
function mb_user_sacn_submit($form, &$form_state) {
|
||||
$redirect = 'admin/people/create';
|
||||
|
||||
drupal_goto($redirect);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the types of pages allowed to use more buttons.
|
||||
*
|
||||
* At the moment are only supported the user accounts.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function mb_user_type_get_types() {
|
||||
$account = array();
|
||||
|
||||
$account['type'] = 'user_account';
|
||||
$account['name'] = t('User account');
|
||||
|
||||
$page_types = array('user_account' => $account);
|
||||
|
||||
return $page_types;
|
||||
}
|
Reference in New Issue
Block a user