first global commit
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -0,0 +1,3 @@
|
||||
.genpass-password {
|
||||
white-space: nowrap;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
name = Generate Password
|
||||
description = Generate a password when adding a new user.
|
||||
core = 7.x
|
||||
configure = admin/config/people/accounts
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-02-20
|
||||
version = "7.x-1.0"
|
||||
core = "7.x"
|
||||
project = "genpass"
|
||||
datestamp = "1329772844"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function genpass_uninstall() {
|
||||
variable_del('genpass_algorithm');
|
||||
variable_del('genpass_display');
|
||||
variable_del('genpass_entropy');
|
||||
variable_del('genpass_length');
|
||||
variable_del('genpass_mode');
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
|
||||
define('GENPASS_REQUIRED', 0);
|
||||
define('GENPASS_OPTIONAL', 1);
|
||||
define('GENPASS_RESTRICTED', 2);
|
||||
|
||||
define('GENPASS_DISPLAY_NONE', 0);
|
||||
define('GENPASS_DISPLAY_ADMIN', 1);
|
||||
define('GENPASS_DISPLAY_USER', 2);
|
||||
define('GENPASS_DISPLAY_BOTH', 3);
|
||||
|
||||
/**
|
||||
* Implements of hook_init().
|
||||
*/
|
||||
function genpass_init() {
|
||||
drupal_add_css(drupal_get_path('module', 'genpass') . '/genpass.css');
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines default characters allowed for passwords.
|
||||
*/
|
||||
function _GENPASS_REQUIRED_entropy() {
|
||||
return 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789!#$%&()*+,-./:;<=>?@[]^_{|}~';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new password using the preferred password generation algorithm.
|
||||
*
|
||||
* @return a fresh password.
|
||||
*/
|
||||
function genpass_generate() {
|
||||
return module_invoke(genpass_algorithm_module(), 'password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new password using genpass's internal password generation
|
||||
* algorithm.
|
||||
* Based on the original D6 user_password function (with more characters)
|
||||
*
|
||||
* @return a fresh password according to the settings made in /admin/user/settings
|
||||
*
|
||||
* @see genpass_form_alter()
|
||||
*/
|
||||
function genpass_password() {
|
||||
$pass = '';
|
||||
$length = variable_get('genpass_length', 8);
|
||||
$allowable_characters = variable_get('genpass_entropy', _GENPASS_REQUIRED_entropy());
|
||||
|
||||
// Zero-based count of characters in the allowable list:
|
||||
$len = strlen($allowable_characters) - 1;
|
||||
|
||||
// Loop the number of times specified by $length.
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
// Each iteration, pick a random character from the
|
||||
// allowable string and append it to the password:
|
||||
$pass .= $allowable_characters[mt_rand(0, $len)];
|
||||
}
|
||||
|
||||
return $pass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to find a item in the user form, since its position
|
||||
* within the form-array depends on the profile module (account-category).
|
||||
*/
|
||||
function &_genpass_get_form_item(&$form, $field) {
|
||||
if (isset($form['account'][$field])) {
|
||||
return $form['account'][$field];
|
||||
}
|
||||
else {
|
||||
return $form[$field];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_form_alter()
|
||||
*/
|
||||
function genpass_form_alter(&$form, $form_state, $form_id) {
|
||||
|
||||
switch ($form_id) {
|
||||
|
||||
// User admin settings form at admin/config/people/accounts
|
||||
case 'user_admin_settings':
|
||||
|
||||
$form['registration_cancellation']['genpass_mode'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Password handling'),
|
||||
'#default_value' => variable_get('genpass_mode', GENPASS_REQUIRED),
|
||||
'#options' => array(
|
||||
GENPASS_REQUIRED => t('Users <strong>must</strong> enter a password on registration. This is disabled if e-mail verification is enabled above.'),
|
||||
GENPASS_OPTIONAL => t('Users <strong>may</strong> enter a password on registration. If left empty, a random password will be generated. This always applies when an administer is creating the account.'),
|
||||
GENPASS_RESTRICTED => t('Users <strong>cannot</strong> enter a password on registration; a random password will be generated. This always applies for the regular user registration form if e-mail verification is enabled above.'),
|
||||
),
|
||||
'#description' => t('Choose a password handling mode for new users.'),
|
||||
);
|
||||
$form['registration_cancellation']['genpass_length'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Generated password length'),
|
||||
'#default_value' => variable_get('genpass_length', 8),
|
||||
'#size' => 2,
|
||||
'#maxlength' => 2,
|
||||
'#description' => t('Set the length of generated passwords here. Allowed range: 5 to 32.'),
|
||||
);
|
||||
$form['registration_cancellation']['genpass_entropy'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Generated password entropy'),
|
||||
'#size' => 100,
|
||||
'#default_value' => variable_get('genpass_entropy', _GENPASS_REQUIRED_entropy()),
|
||||
'#description' => t('Give a list of possible characters for a generated password. Note that the list must contain at least X different characters where X is defined by the length you have given above.'),
|
||||
);
|
||||
// Provide a selection mechanism to choose the preferred algorithm for
|
||||
// generating passwords. Any module which implements hook_password() is
|
||||
// displayed here.
|
||||
$form['registration_cancellation']['genpass_algorithm'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Password generation algorithm'),
|
||||
'#default_value' => genpass_algorithm_module(),
|
||||
'#options' => genpass_add_samples(genpass_algorithm_modules()),
|
||||
'#description' => t('If third party modules define a password generation algorithm, you can select which one to use. Note that algorithms other than genpass will ignore the preferred entropy and password length. The currently selected algorithm produced the password @pw.', array('@pw' => genpass_generate())),
|
||||
);
|
||||
$form['registration_cancellation']['genpass_display'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Generated password display'),
|
||||
'#default_value' => variable_get('genpass_display', GENPASS_DISPLAY_BOTH),
|
||||
'#options' => array(
|
||||
GENPASS_DISPLAY_NONE => t('Do not display.'),
|
||||
GENPASS_DISPLAY_ADMIN => t('Display when site administrators create new user accounts.'),
|
||||
GENPASS_DISPLAY_USER => t('Display when users create their own accounts.'),
|
||||
GENPASS_DISPLAY_BOTH => t('Display to both site administrators and users.'),
|
||||
),
|
||||
'#description' => t('Whether or not the generated password should display after a user account is created.'),
|
||||
);
|
||||
$form['#validate'][] = 'genpass_user_admin_settings_validate';
|
||||
// Move the "When cancelling a user account" field down.
|
||||
$form['registration_cancellation']['user_cancel_method']['#weight'] = 1;
|
||||
break;
|
||||
|
||||
// User registration form at admin/people/create
|
||||
case 'user_register_form':
|
||||
$mode = variable_get('genpass_mode', GENPASS_REQUIRED);
|
||||
|
||||
// Add validation function, where password may get set
|
||||
$form['#validate'][] = 'genpass_register_validate';
|
||||
|
||||
// Administrator is creating the user
|
||||
if ($_GET['q'] == 'admin/user/user/create') {
|
||||
// Switch to optional mode
|
||||
$mode = GENPASS_OPTIONAL;
|
||||
// Help avoid obvious consequence of password being optional
|
||||
$notify_item =& _genpass_get_form_item($form, 'notify');
|
||||
$notify_item['#description'] = t('This is recommended when auto-generating the password; otherwise, neither you nor the new user will know the password.');
|
||||
}
|
||||
|
||||
// Pass mode to validation function
|
||||
$form['genpass_mode'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => $mode,
|
||||
);
|
||||
|
||||
$pass_item =& _genpass_get_form_item($form, 'pass');
|
||||
switch ($mode) {
|
||||
// If password is optional, don't require it, and give the user an
|
||||
// indication of what will happen if left blank
|
||||
case GENPASS_OPTIONAL:
|
||||
$pass_item['#required'] = FALSE;
|
||||
$pass_item['#description'] = (empty($pass_item['#description']) ? '' : $pass_item['#description'] . ' ') . t('If left blank, a password will be generated for you.');
|
||||
break;
|
||||
// If password is restricted, remove access
|
||||
case GENPASS_RESTRICTED:
|
||||
$pass_item['#access'] = FALSE;
|
||||
$pass_item['#required'] = FALSE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* User settings validation.
|
||||
*/
|
||||
function genpass_user_admin_settings_validate($form, &$form_state) {
|
||||
// Validate length of password
|
||||
$length = $form_state['values']['genpass_length'];
|
||||
if (!is_numeric($length) || $length < 5 || $length > 32) {
|
||||
form_set_error('genpass_length', t('The length of a generated password must be between 5 and 32.'));
|
||||
return;
|
||||
}
|
||||
// Validate allowed characters
|
||||
$chars = array_unique(preg_split('//', $form_state['values']['genpass_entropy'], -1, PREG_SPLIT_NO_EMPTY));
|
||||
if (count($chars) < $length) {
|
||||
form_set_error('genpass_entropy', t('The list of possible characters is not long or unique enough.'));
|
||||
return;
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* User registration validation.
|
||||
*/
|
||||
function genpass_register_validate($form, &$form_state) {
|
||||
if (empty($form_state['values']['pass']) && !form_get_errors()) {
|
||||
|
||||
// Generate and set password
|
||||
$pass = genpass_generate();
|
||||
$pass_item =& _genpass_get_form_item($form, 'pass');
|
||||
form_set_value($pass_item, $pass, $form_state);
|
||||
|
||||
$display = variable_get('genpass_display', GENPASS_DISPLAY_BOTH);
|
||||
|
||||
// Administrator created the user.
|
||||
if ($_GET['q'] == 'admin/people/create') {
|
||||
$message = t('Since you did not provide a password, it was generated automatically for this account.');
|
||||
if (in_array($display, array(GENPASS_DISPLAY_ADMIN, GENPASS_DISPLAY_BOTH))) {
|
||||
$message .= ' ' . t('The password is: <strong class="genpass-password">!password</strong>', array('!password' => $pass));
|
||||
}
|
||||
}
|
||||
// Optional - User did not provide password, so it was generated
|
||||
elseif ($form_state['values']['genpass_mode'] == GENPASS_OPTIONAL) {
|
||||
$message = t('Since you did not provide a password, it was generated for you.');
|
||||
if (in_array($display, array(GENPASS_DISPLAY_USER, GENPASS_DISPLAY_BOTH))) {
|
||||
$message .= ' ' . t('Your password is: <strong class="genpass-password">!password</strong>', array('!password' => $pass));
|
||||
}
|
||||
}
|
||||
// Restricted - User was forced to receive a generated password
|
||||
elseif ($form_state['values']['genpass_mode'] == GENPASS_RESTRICTED && in_array($display, array(GENPASS_DISPLAY_USER, GENPASS_DISPLAY_BOTH))) {
|
||||
$message = t('The following password was generated for you: <strong class="genpass-password">!password</strong>', array('!password' => $pass));
|
||||
}
|
||||
|
||||
if (!empty($message)) {
|
||||
drupal_set_message($message);
|
||||
}
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of all modules which implement hook_password.
|
||||
*
|
||||
* @return array of module names.
|
||||
*/
|
||||
function genpass_algorithm_modules() {
|
||||
// Fetch a list of all modules which implement the password generation hook.
|
||||
// To be in this list, a module must implement a hook, and return random
|
||||
// passwords as strings.
|
||||
$return = array();
|
||||
foreach (module_implements('password') as $module) {
|
||||
$return[$module] = $module;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the currently activated module for generating passwords. Does some
|
||||
* validation to make sure the variable contains a valid module name.
|
||||
*
|
||||
* @return the name of the module whose implementation of hook_password is
|
||||
* currently the preferred implementation.
|
||||
*/
|
||||
function genpass_algorithm_module() {
|
||||
$modules = genpass_algorithm_modules();
|
||||
$module = variable_get('genpass_algorithm', 'genpass');
|
||||
|
||||
if (in_array($module, array_keys($modules))) {
|
||||
return $module;
|
||||
}
|
||||
else {
|
||||
return 'genpass';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds some sample passwords to each module in an array.
|
||||
*/
|
||||
function genpass_add_samples($array) {
|
||||
$return = array();
|
||||
foreach ($array as $module => $name) {
|
||||
$return[$module] = $module . ' (' . t('examples') . ': <strong>' . htmlentities(module_invoke($module, 'password')) . '</strong>, <strong>' . htmlentities(module_invoke($module, 'password')) . '</strong>)';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -0,0 +1,4 @@
|
||||
Moshe Weitzman <weitzman AT tejasa DOT com>
|
||||
ARDAS group <info AT ardas DOT dp DOT ua>
|
||||
rsvelko from segments.at
|
||||
mithy <http://drupal.org/user/258911/>
|
||||
@@ -0,0 +1,67 @@
|
||||
The Login Destination module provides a way to customize the destination that a
|
||||
user is redirected to after logging in, registering to the site, using a
|
||||
one-time login link or logging out.
|
||||
|
||||
The configuration consists of specifying so called login destination rules that
|
||||
are evaluated when the login or logout takes place. Those rules are evaluated
|
||||
against certain conditions and the user is taken to the destination specified
|
||||
by the first matching rule. If the destination is empty, no redirect is
|
||||
performed aka user is taken to the default destination. You can define pages
|
||||
from which a user logs in/out to be a matching criterion. You can also select
|
||||
certain user roles that are matched against those of a user. Note that only one
|
||||
role has to match in order for the redirect to take place. If no roles are
|
||||
selected the redirect is performed regardless of user roles. You can also
|
||||
provide your own conditions by specifying PHP snippets (the PHP Filter has to
|
||||
be enabled). The snippet should return TRUE if the condition matches and FALSE
|
||||
otherwise.
|
||||
|
||||
There are no separate triggers for login and registration; instead you can
|
||||
differentiate them by the specifying the pages that a user comes from:
|
||||
- user - the user login form.
|
||||
- user/register - the user registration form.
|
||||
- user/*/edit - one-time login link, after the user has set the password.
|
||||
- other - the login block or login forms embedded by other modules.
|
||||
Please note that a user will be redirected when they register, even though they
|
||||
may not be logged in afterwards immediately (e.g. because of email validation).
|
||||
You can use this behavior to send the user to a page that contains further
|
||||
instructions.
|
||||
|
||||
The destination you specify can be an internal page or an external URL.
|
||||
Remember to precede the url with http://. You can also use the <front> tag to
|
||||
redirect to the front page or the <current> tag to redirect to the page where
|
||||
the user was before login/logout, aka the current page. In case of
|
||||
login/register form the page from which the user entered the form is treaded as
|
||||
the current page. Note that if you provide your own login/logout links you have
|
||||
to add the 'current' GET parameter to them so Login Destination knows where
|
||||
your users come from.
|
||||
|
||||
In some cases you will also need to provide the destination in a dynamic way by
|
||||
using PHP snippets (the PHP Filter has to be enabled). The snippet's return
|
||||
variable can be a string, for straight pages and urls, or an array for more
|
||||
advanced options. The array should be in a form that the url function will
|
||||
understand, e.g. %example. For more information, see the online API entry for
|
||||
<a href="@url">url function</a>. In most cases you will use it to specify GET
|
||||
parameters and an anchor ("#"). Please study the examples below:
|
||||
|
||||
Take the user to the administration panel with underlying blog page:
|
||||
|
||||
<?php return array('blog', array('fragment' => 'overlay=admin/config', ), ); ?>
|
||||
|
||||
Take the user to the front page and specify some custom parameters:
|
||||
|
||||
<?php return array('<front>', array('query' => array('param1' => 'value1',
|
||||
'param2' => 'value2', ), ), ); ?>
|
||||
|
||||
Take the user to the default page:
|
||||
|
||||
<?php return NULL; ?>
|
||||
|
||||
It also possible to set some advanced parameters on the setting page. Every
|
||||
time in Drupal you can specify the 'destination' GET parameter in url to
|
||||
redirect the user to a custom page. If you check the option
|
||||
'Preserve the destination parameter' Login Destination will give priority to
|
||||
this parameter over its own module settings. However with this option enabled
|
||||
the redirect from the login block will not work. In some rare cases you can
|
||||
also redirect the user just after using the one-time login link, before given
|
||||
the possibility to change their password. Do this by checking the
|
||||
'Redirect immediately after using one-time login link' option.
|
||||
@@ -0,0 +1,357 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Admin page callback file for the Login Destination module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* List destination rules.
|
||||
*/
|
||||
function login_destination_overview() {
|
||||
$header = array(
|
||||
t('Destination'),
|
||||
t('Triggers'),
|
||||
t('Pages'),
|
||||
t('Roles'),
|
||||
array('data' => t('Operations'), 'colspan' => 2),
|
||||
);
|
||||
$rows = array();
|
||||
|
||||
// Get all login destination rules from the database.
|
||||
$result = db_select('login_destination', 'l')
|
||||
->fields('l', array('id', 'triggers', 'roles', 'pages_type', 'pages', 'destination'))
|
||||
->orderBy('weight')
|
||||
->execute()
|
||||
->fetchAll();
|
||||
|
||||
// Loop through the categories and add them to the table.
|
||||
foreach ($result as $data) {
|
||||
|
||||
$triggers = array_map('check_plain', unserialize($data->triggers));
|
||||
if (empty($triggers))
|
||||
$triggers = array();
|
||||
|
||||
$roles = array_map('check_plain', unserialize($data->roles));
|
||||
if (empty($roles))
|
||||
$roles = array();
|
||||
|
||||
$rows[] = array(
|
||||
theme('login_destination_destination', array('destination' => $data->destination)),
|
||||
theme('login_destination_triggers', array('items' => $triggers)),
|
||||
theme('login_destination_pages', array('pages' => $data->pages, 'pages_type' => $data->pages_type)),
|
||||
theme('login_destination_roles', array('items' => $roles)),
|
||||
l(t('Edit'), 'admin/config/people/login-destination/edit/' . $data->id),
|
||||
l(t('Delete'), 'admin/config/people/login-destination/delete/' . $data->id),
|
||||
);
|
||||
}
|
||||
|
||||
if (!$rows) {
|
||||
$rows[] = array(array(
|
||||
'data' => t('No rules available.'),
|
||||
'colspan' => 6,
|
||||
));
|
||||
}
|
||||
|
||||
$build['login-destination_table'] = array(
|
||||
'#theme' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
);
|
||||
return $build;
|
||||
}
|
||||
|
||||
function theme_login_destination_destination($variables) {
|
||||
$output = nl2br(check_plain($variables['destination']));
|
||||
|
||||
if (empty($output)) {
|
||||
$output = '<i>' . t('Empty') . '</i>';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function theme_login_destination_triggers($variables) {
|
||||
$items = array_map('check_plain', $variables['items']);
|
||||
|
||||
if (empty($items)) {
|
||||
return '<i>' . t('All triggers') . '</i>';
|
||||
}
|
||||
|
||||
$output = '';
|
||||
foreach ($items as &$item) {
|
||||
switch ($item) {
|
||||
case 'login':
|
||||
$item = 'Login';
|
||||
break;
|
||||
case 'logout':
|
||||
$item = 'Logout';
|
||||
break;
|
||||
}
|
||||
$output .= $item . "<br/>";
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function theme_login_destination_pages($variables) {
|
||||
$type = $variables['pages_type'];
|
||||
|
||||
if ($type == LOGIN_DESTINATION_REDIRECT_PHP) {
|
||||
return nl2br(check_plain($variables['pages']));
|
||||
}
|
||||
|
||||
$pages = trim($variables['pages']);
|
||||
|
||||
if (empty($pages)) {
|
||||
if ($type == LOGIN_DESTINATION_REDIRECT_NOTLISTED) {
|
||||
return '<i>' . t('All pages') . '</i>';
|
||||
}
|
||||
else {
|
||||
return '<i>' . t('No pages') . '</i>';
|
||||
}
|
||||
}
|
||||
|
||||
$pages = explode("\n", preg_replace('/\r/', '', check_plain($variables['pages'])));
|
||||
|
||||
$output = '';
|
||||
foreach ($pages as &$page) {
|
||||
if ($type == LOGIN_DESTINATION_REDIRECT_NOTLISTED) {
|
||||
$output .= "~ ";
|
||||
}
|
||||
$output .= $page . "<br/>";
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function theme_login_destination_roles($variables) {
|
||||
$items = array_values(array_intersect_key(_login_destination_role_options(), $variables['items']));
|
||||
|
||||
if (empty($items)) {
|
||||
return '<i>' . t('All roles') . '</i>';
|
||||
}
|
||||
|
||||
return theme('item_list', array('items' => $items));
|
||||
}
|
||||
|
||||
/**
|
||||
* Category edit page.
|
||||
*/
|
||||
function login_destination_edit_form($form, &$form_state, array $rule = array()) {
|
||||
// default values
|
||||
$rule += array(
|
||||
'triggers' => array(),
|
||||
'roles' => array(),
|
||||
'pages_type' => LOGIN_DESTINATION_REDIRECT_NOTLISTED,
|
||||
'pages' => '',
|
||||
'destination_type' => LOGIN_DESTINATION_STATIC,
|
||||
'destination' => '<front>',
|
||||
'id' => NULL,
|
||||
'weight' => 0,
|
||||
);
|
||||
|
||||
$access = user_access('use PHP for settings');
|
||||
|
||||
$type = $rule['destination_type'];
|
||||
|
||||
if ($type == LOGIN_DESTINATION_SNIPPET && !$access) {
|
||||
$form['destination_type'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => LOGIN_DESTINATION_SNIPPET,
|
||||
);
|
||||
$form['destination'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => $rule['destination'],
|
||||
);
|
||||
}
|
||||
else {
|
||||
$options = array(
|
||||
LOGIN_DESTINATION_STATIC => t('Internal page or external URL'),
|
||||
);
|
||||
$description = t("Specify page by using its path. Example path is %blog for the blog page. %front is the front page. %current is the current page. Precede with http:// for an external URL. Leave empty to redirect to a default page.", array('%blog' => 'blog', '%front' => '<front>', '%current' => '<current>'));
|
||||
|
||||
if (module_exists('php') && $access) {
|
||||
$options += array(LOGIN_DESTINATION_SNIPPET => t('Page returned by this PHP code (experts only)'));
|
||||
$description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. It should return either a string value or an array of params that the %function function will understand, e.g. %example. For more information, see the online API entry for <a href="@url">url function</a>. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => '<?php ?>', '%function' => 'url($path = \'\', array $options = array())', '%example' => '<?php return array(\'blog\', array(\'fragment\' => \'overlay=admin/config\', ), ); ?>', '@url' => 'http://api.drupal.org/api/drupal/includes--common.inc/function/url/7'));
|
||||
}
|
||||
|
||||
$form['destination_type'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => 'Redirect to page',
|
||||
'#default_value' => $type,
|
||||
'#options' => $options,
|
||||
);
|
||||
$form['destination'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#default_value' => $rule['destination'],
|
||||
'#description' => $description,
|
||||
);
|
||||
}
|
||||
|
||||
$triggers = array_map('check_plain', $rule['triggers']);
|
||||
if (empty($triggers)) {
|
||||
$triggers = array();
|
||||
}
|
||||
|
||||
$form['triggers'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Redirect upon triggers'),
|
||||
'#options' => array('login' => 'Login, registration, one-time login link', 'logout' => 'Logout'),
|
||||
'#default_value' => $triggers,
|
||||
'#description' => 'Redirect only upon selected trigger(s). If you select no triggers, all of them will be used.',
|
||||
);
|
||||
|
||||
$type = $rule['pages_type'];
|
||||
|
||||
if ($type == LOGIN_DESTINATION_REDIRECT_PHP && !$access) {
|
||||
$form['pages_type'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => LOGIN_DESTINATION_REDIRECT_PHP,
|
||||
);
|
||||
$form['pages'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => $rule['destination'],
|
||||
);
|
||||
}
|
||||
else {
|
||||
$options = array(
|
||||
LOGIN_DESTINATION_REDIRECT_NOTLISTED => t('All pages except those listed'),
|
||||
LOGIN_DESTINATION_REDIRECT_LISTED => t('Only the listed pages'),
|
||||
);
|
||||
$description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page. %login is the login form. %register is the registration form. %reset is the one-time login (e-mail validation).", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>', '%login' => 'user', '%register' => 'user/register', '%reset' => 'user/*/edit'));
|
||||
|
||||
if (module_exists('php') && $access) {
|
||||
$options += array(LOGIN_DESTINATION_REDIRECT_PHP => t('Pages on which this PHP code returns <code>TRUE</code> (experts only)'));
|
||||
$description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => '<?php ?>'));
|
||||
}
|
||||
|
||||
$form['pages_type'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Redirect from specific pages'),
|
||||
'#default_value' => $type,
|
||||
'#options' => $options,
|
||||
);
|
||||
$form['pages'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#default_value' => $rule['pages'],
|
||||
'#description' => $description,
|
||||
);
|
||||
}
|
||||
|
||||
$default_role_options = array_map('check_plain', $rule['roles']);
|
||||
if (empty($default_role_options)) {
|
||||
$default_role_options = array();
|
||||
}
|
||||
|
||||
$form['roles'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Redirect users with roles'),
|
||||
'#options' => _login_destination_role_options(),
|
||||
'#default_value' => $default_role_options,
|
||||
'#description' => 'Redirect only the selected role(s). If you select no roles, all users will be redirected.',
|
||||
);
|
||||
|
||||
$form['weight'] = array(
|
||||
'#type' => 'weight',
|
||||
'#title' => t('Weight'),
|
||||
'#default_value' => $rule['weight'],
|
||||
'#description' => t('When evaluating login destination rules, those with lighter (smaller) weights get evaluated before rules with heavier (larger) weights.'),
|
||||
);
|
||||
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
);
|
||||
|
||||
if ($rule['id']) {
|
||||
$form['id'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $rule['id'],
|
||||
);
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the contact category edit page form submission.
|
||||
*/
|
||||
function login_destination_edit_form_validate($form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the contact category edit page form submission.
|
||||
*/
|
||||
function login_destination_edit_form_submit($form, &$form_state) {
|
||||
$form_state['values']['triggers'] = serialize(array_filter($form_state['values']['triggers']));
|
||||
$form_state['values']['roles'] = serialize(array_filter($form_state['values']['roles']));
|
||||
|
||||
if (empty($form_state['values']['id'])) {
|
||||
drupal_write_record('login_destination', $form_state['values']);
|
||||
}
|
||||
else {
|
||||
drupal_write_record('login_destination', $form_state['values'], array('id'));
|
||||
}
|
||||
|
||||
drupal_set_message(t('Login destination to %destination has been saved.', array('%destination' => $form_state['values']['destination'])));
|
||||
|
||||
$form_state['redirect'] = 'admin/config/people/login-destination';
|
||||
}
|
||||
|
||||
/**
|
||||
* Form builder for deleting a login destination.
|
||||
*/
|
||||
function login_destination_delete_form($form, &$form_state, array $rule) {
|
||||
$form['login_destination'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => $rule,
|
||||
);
|
||||
|
||||
return confirm_form(
|
||||
$form,
|
||||
t('Are you sure you want to delete the login destination %destination ?', array('%destination' => $rule['destination'])),
|
||||
'admin/config/people/login-destination',
|
||||
t('This action cannot be undone.'),
|
||||
t('Delete'),
|
||||
t('Cancel')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit handler for the confirm delete login destination form.
|
||||
*/
|
||||
function login_destination_delete_form_submit($form, &$form_state) {
|
||||
$rule = $form['login_destination']['#value'];
|
||||
|
||||
db_delete('login_destination')
|
||||
->condition('id', $rule['id'])
|
||||
->execute();
|
||||
|
||||
drupal_set_message(t('The login destination %destination has been deleted.', array('%destination' => $rule['destination'])));
|
||||
|
||||
$form_state['redirect'] = 'admin/config/people/login-destination';
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings page.
|
||||
*/
|
||||
function login_destination_settings() {
|
||||
$form = array();
|
||||
|
||||
$form['settings']['login_destination_preserve_destination'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => variable_get('login_destination_preserve_destination', FALSE),
|
||||
'#title' => t('Preserve the destination parameter'),
|
||||
'#description' => t("The 'destination' GET parameter will have priority over the settings of this module. With this setting enabled, redirect from the user login block will not work."),
|
||||
);
|
||||
$form['settings']['login_destination_immediate_redirect'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => variable_get('login_destination_immediate_redirect', FALSE),
|
||||
'#title' => t('Redirect immediately after using one-time login link'),
|
||||
'#description' => t("User will be redirected before given the possibility to change their password."),
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
name = Login Destination
|
||||
description = Customize the destination that the user is redirected to after login.
|
||||
core = 7.x
|
||||
files[] = login_destination.module
|
||||
files[] = login_destination.admin.inc
|
||||
configure = admin/config/people/login-destination
|
||||
; Information added by drupal.org packaging script on 2012-12-18
|
||||
version = "7.x-1.1"
|
||||
core = "7.x"
|
||||
project = "login_destination"
|
||||
datestamp = "1355853150"
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the Login Destination module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_schema().
|
||||
*/
|
||||
function login_destination_schema() {
|
||||
$schema['login_destination'] = array(
|
||||
'description' => 'Login Destination rules.',
|
||||
'fields' => array(
|
||||
'id' => array(
|
||||
'type' => 'serial',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary Key: Unique ID.',
|
||||
),
|
||||
'triggers' => array(
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Triggers on which to perform redirect',
|
||||
),
|
||||
'roles' => array(
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Roles to perform redirect for',
|
||||
),
|
||||
'pages_type' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'size' => 'tiny',
|
||||
'description' => 'Flag to indicate from which pages to redirect. (0 = all pages except listed pages, 1 = only listed pages, 2 = Use custom PHP code)',
|
||||
),
|
||||
'pages' => array(
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Pages from which to redirect',
|
||||
),
|
||||
'destination_type' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'size' => 'tiny',
|
||||
'description' => 'Flag to indicate the destination type. (0 = static URL, 1 = PHP code)',
|
||||
),
|
||||
'destination' => array(
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Redirect destination',
|
||||
),
|
||||
'weight' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => "The rule's weight.",
|
||||
),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'indexes' => array(
|
||||
'list' => array('weight'),
|
||||
),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
*/
|
||||
function login_destination_install() {
|
||||
// update the alter option of 'user/logout' to TRUE (menu_save invokes necessary hooks)
|
||||
$result = db_query("SELECT mlid, menu_name FROM {menu_links} WHERE link_path = 'user/logout' OR link_path = 'user/login' OR link_path = 'user' ORDER BY mlid ASC");
|
||||
foreach($result as $res) {
|
||||
$item = menu_link_load($res->mlid);
|
||||
$item['options']['alter'] = TRUE;
|
||||
db_update('menu_links')
|
||||
->fields(array(
|
||||
'options' => serialize($item['options']),
|
||||
))
|
||||
->condition('mlid', $item['mlid'])
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_uninstall().
|
||||
*/
|
||||
function login_destination_uninstall() {
|
||||
variable_del('login_destination_preserve_destination');
|
||||
variable_del('login_destination_profile_redirect');
|
||||
}
|
||||
|
||||
function login_destination_update_7000() {
|
||||
$type = variable_get('ld_condition_type', 'always');
|
||||
$snippet = variable_get('ld_condition_snippet', '');
|
||||
|
||||
if ($type == 'snippet') {
|
||||
$form_state['values']['pages_type'] = 2;
|
||||
// We introduced php tags.
|
||||
$form_state['values']['pages'] = '<?php ' . $snippet . '?>';
|
||||
}
|
||||
elseif ($type == 'pages') {
|
||||
$form_state['values']['pages_type'] = 1;
|
||||
$form_state['values']['pages'] = $snippet;
|
||||
}
|
||||
else {
|
||||
$form_state['values']['pages_type'] = 0;
|
||||
$form_state['values']['pages'] = $snippet;
|
||||
}
|
||||
|
||||
$type = variable_get('ld_url_type', 'static');
|
||||
$snippet = variable_get('ld_url_destination', '');
|
||||
|
||||
if ($type == 'snippet') {
|
||||
$form_state['values']['destination_type'] = 1;
|
||||
// syntax for return value has changed.
|
||||
$form_state['values']['destination'] = '<?php /* ' . $snippet . ' */ ?>';
|
||||
}
|
||||
else {
|
||||
$form_state['values']['destination_type'] = 0;
|
||||
$form_state['values']['destination'] = $snippet;
|
||||
}
|
||||
|
||||
$form_state['values']['triggers'] = serialize(array('login'));
|
||||
$form_state['values']['roles'] = serialize(array());
|
||||
|
||||
drupal_write_record('login_destination', $form_state['values']);
|
||||
|
||||
variable_set('login_destination_preserve_destination', variable_get('ld_destination', 0));
|
||||
|
||||
variable_del('ld_condition_type');
|
||||
variable_del('ld_condition_snippet');
|
||||
variable_del('ld_destination');
|
||||
variable_del('ld_url_type');
|
||||
variable_del('ld_url_destination');
|
||||
}
|
||||
@@ -0,0 +1,504 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Control where users are directed to, once they login
|
||||
*/
|
||||
|
||||
// Page constants
|
||||
define('LOGIN_DESTINATION_REDIRECT_NOTLISTED', 0);
|
||||
define('LOGIN_DESTINATION_REDIRECT_LISTED', 1);
|
||||
define('LOGIN_DESTINATION_REDIRECT_PHP', 2);
|
||||
|
||||
// Destination constants
|
||||
define('LOGIN_DESTINATION_STATIC', 0);
|
||||
define('LOGIN_DESTINATION_SNIPPET', 1);
|
||||
|
||||
/**
|
||||
* Implement hook_help().
|
||||
*/
|
||||
function login_destination_help($path, $arg) {
|
||||
switch ($path) {
|
||||
case 'admin/help#login_destination':
|
||||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Login Destination module allows you to customize the destination that the user is redirected to after logging in, registering to the site, using a one-time login link or logging out. The destination can be an internal page or an external URL. You may specify certain conditions like pages or user roles and make the destination depend upon them. You may also use a PHP snippets to provide custom conditions and destinations. Note that PHP Filter module has to be enabled and you have to be granted the "Use PHP for settings" permissions to be able to enter PHP code.') . '</p>';
|
||||
return $output;
|
||||
case 'admin/config/people/login-destination':
|
||||
return '<p>' . t('Login destination rules are evaluated each time a user logs in, registers to the site, uses a one-time login link or logs out. Each rule consists of the destination, path conditions and user roles conditions. First matching rule gets executed.') . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function login_destination_menu() {
|
||||
$items['admin/config/people/login-destination'] = array(
|
||||
'title' => 'Login destinations',
|
||||
'description' => 'Customize the destination that the user is redirected to after login.',
|
||||
'page callback' => 'login_destination_overview',
|
||||
'access arguments' => array('administer users'),
|
||||
'file' => 'login_destination.admin.inc',
|
||||
'weight' => 10,
|
||||
);
|
||||
$items['admin/config/people/login-destination/add'] = array(
|
||||
'title' => 'Add login destination rule',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('login_destination_edit_form'),
|
||||
'access arguments' => array('administer users'),
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
'weight' => 1,
|
||||
'file' => 'login_destination.admin.inc',
|
||||
);
|
||||
$items['admin/config/people/login-destination/edit/%login_destination'] = array(
|
||||
'title' => 'Edit login destination rule',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('login_destination_edit_form', 5),
|
||||
'access arguments' => array('administer users'),
|
||||
'file' => 'login_destination.admin.inc',
|
||||
);
|
||||
$items['admin/config/people/login-destination/delete/%login_destination'] = array(
|
||||
'title' => 'Delete login destination rule',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('login_destination_delete_form', 5),
|
||||
'access arguments' => array('administer users'),
|
||||
'file' => 'login_destination.admin.inc',
|
||||
);
|
||||
$items['admin/config/people/login-destination/list'] = array(
|
||||
'title' => 'List',
|
||||
'type' => MENU_DEFAULT_LOCAL_TASK,
|
||||
'weight' => -10,
|
||||
);
|
||||
$items['admin/config/people/login-destination/settings'] = array(
|
||||
'title' => 'Settings',
|
||||
'description' => 'Change Login Destination settings.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('login_destination_settings'),
|
||||
'access arguments' => array('administer users'),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'file' => 'login_destination.admin.inc',
|
||||
'weight' => 10,
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a login destination.
|
||||
*/
|
||||
function login_destination_load($id) {
|
||||
$result = db_select('login_destination', 'l')
|
||||
->fields('l')
|
||||
->condition('id', $id)
|
||||
->execute()
|
||||
->fetchAssoc();
|
||||
|
||||
$result['triggers'] = unserialize($result['triggers']);
|
||||
if (empty($result['triggers'])) {
|
||||
$result['triggers'] = array();
|
||||
}
|
||||
|
||||
$result['roles'] = unserialize($result['roles']);
|
||||
if (empty($result['roles'])) {
|
||||
$result['roles'] = array();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme
|
||||
*/
|
||||
function login_destination_theme() {
|
||||
return array(
|
||||
'login_destination_destination' => array(
|
||||
'variables' => array('destination' => NULL),
|
||||
'file' => 'login_destination.admin.inc',
|
||||
),
|
||||
'login_destination_pages' => array(
|
||||
'variables' => array('pages' => NULL, 'pages_type' => 0),
|
||||
'file' => 'login_destination.admin.inc',
|
||||
),
|
||||
'login_destination_triggers' => array(
|
||||
'variables' => array('items' => NULL),
|
||||
'file' => 'login_destination.admin.inc',
|
||||
),
|
||||
'login_destination_roles' => array(
|
||||
'variables' => array('items' => NULL),
|
||||
'file' => 'login_destination.admin.inc',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter
|
||||
*/
|
||||
function login_destination_form_alter(&$form, &$form_state, $form_id) {
|
||||
// We redirect by using the drupal_goto_alter hook. If we simply
|
||||
// call drupal_goto() it may break compability with other modules. If we set
|
||||
// the $_GET['destination'] variable we will loose the possibility to redirect
|
||||
// to an external URL.
|
||||
|
||||
// Please note the the system_goto_action() calls drupal_goto()
|
||||
// More on this issue http://drupal.org/node/732542.
|
||||
|
||||
// If we add the $form_state['redirect'] here it will be overriden by the
|
||||
// user_login_submit(). So we add a submit handler instead and will set the
|
||||
// redirect later. Our submit handler will be executed after the execution
|
||||
// of user_login_submit(). This is because form_submit() functions are
|
||||
// appended to form before hook_form_alter() is executed.
|
||||
|
||||
// We will execute also after LoginToboggan's function as it replaces the
|
||||
// original submit function from user module.
|
||||
|
||||
switch ($form_id) {
|
||||
case 'user_register_form': // user register page
|
||||
case 'user_login': // user login page
|
||||
$form['#validate'][] = 'login_destination_validate';
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($form_id) {
|
||||
case 'user_profile_form': // one-time login, password reset
|
||||
if (isset($_GET['pass-reset-token'])) {
|
||||
// Redirect only from user_pass_reset
|
||||
// You have to explicitally turn on the option to always redirect from
|
||||
// the profile page. This is for constistency.
|
||||
$form['#submit'][] = 'login_destination_submit';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper submit function.
|
||||
*/
|
||||
function login_destination_validate($form, &$form_state) {
|
||||
// LoginToboggan's unified page is rendered dynamically. Fix it.
|
||||
switch ($form['#form_id']) {
|
||||
case 'user_register_form':
|
||||
if (drupal_match_path($_GET['q'], 'user')) {
|
||||
$_GET['q'] = 'user/register';
|
||||
}
|
||||
break;
|
||||
case 'user_login':
|
||||
if (drupal_match_path($_GET['q'], 'user/register')) {
|
||||
$_GET['q'] = 'user';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Fix the current page in case of 403 page.
|
||||
if ($form['#form_id'] == 'user_login') {
|
||||
if(drupal_get_http_header('Status') == '403 Forbidden') {
|
||||
$_GET['current'] = $_GET['destination'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper submit function.
|
||||
*/
|
||||
function login_destination_submit($form, &$form_state) {
|
||||
login_destination_perform_redirect('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu_link_alter
|
||||
*/
|
||||
function login_destination_menu_link_alter(&$item) {
|
||||
// Flag a link to be altered by hook_translated_menu_link_alter().
|
||||
// This is called only on menu rebuild, so we have to add this information
|
||||
// manually to the database on install. Clearing caches also helps.
|
||||
$paths = array('user/logout', 'user/login', 'user');
|
||||
if (in_array($item['link_path'], $paths)) {
|
||||
$item['options']['alter'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_translated_menu_link_alter
|
||||
*/
|
||||
function login_destination_translated_menu_link_alter(&$item, $map) {
|
||||
global $user;
|
||||
$paths = array('user/login', 'user');
|
||||
// Append the current path to URL.
|
||||
if ($item['link_path'] == 'user/logout' || (in_array($item['link_path'], $paths) && user_is_anonymous())) {
|
||||
$item['localized_options']['query'] = array('current' => $_GET['q']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_page_alter
|
||||
*/
|
||||
function login_destination_page_alter(&$page) {
|
||||
// Substitute toolbar's pre_render function to change links.
|
||||
if (isset($page['page_top']['toolbar']['#pre_render'])) {
|
||||
$page['page_top']['toolbar']['#pre_render'][0] = 'login_destination_toolbar_pre_render';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to change toolbar's links.
|
||||
*/
|
||||
function login_destination_toolbar_pre_render($toolbar) {
|
||||
$toolbar = toolbar_pre_render($toolbar);
|
||||
// Add current param to be able to evaluate previous page.
|
||||
$toolbar['toolbar_user']['#links']['logout']['query'] = array('current' => $_GET['q']);
|
||||
return $toolbar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_login
|
||||
*/
|
||||
function login_destination_user_login(&$edit, $account) {
|
||||
if (!isset($_POST['form_id']) || $_POST['form_id'] != 'user_pass_reset' || variable_get('login_destination_immediate_redirect', FALSE)) {
|
||||
login_destination_perform_redirect('login');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_insert
|
||||
*/
|
||||
function login_destination_user_insert(&$edit, $account, $category) {
|
||||
global $user;
|
||||
|
||||
if (!$user->uid) {
|
||||
// If the user is already logged in, it means probably that they create a
|
||||
// user account and not the user registers themselves.
|
||||
login_destination_perform_redirect('login');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_logout
|
||||
*/
|
||||
function login_destination_user_logout($account) {
|
||||
login_destination_perform_redirect('logout', _login_destination_get_current('logout'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_drupal_goto_alter
|
||||
*/
|
||||
function login_destination_drupal_goto_alter(&$path, &$options, &$http_response_code) {
|
||||
// Note that this functionality cannot be backported do 6.x as Drupal 6 does
|
||||
// not call drupal_alter for drupal_goto.
|
||||
|
||||
// This actually may be used also by templates.
|
||||
if (isset($GLOBALS['destination'])) {
|
||||
$destination = $GLOBALS['destination'];
|
||||
|
||||
// alter drupal_goto
|
||||
if (is_array($destination)) {
|
||||
$path = $destination[0];
|
||||
$options = array();
|
||||
if (count($destination) > 1) {
|
||||
$options = $destination[1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$path = $destination;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass destination to drupal_goto.
|
||||
*/
|
||||
function login_destination_prepare_goto($destination) {
|
||||
// Check if $_GET['destination'] should overwrite us
|
||||
if (!isset($_GET['destination']) || !variable_get('login_destination_preserve_destination', FALSE)) {
|
||||
$GLOBALS['destination'] = $destination;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate rules and perform redirect.
|
||||
* This function is intended to be used by external modules.
|
||||
* @param <type> $trigger
|
||||
* @param <type> $current if null $_GET['q'] is used
|
||||
*/
|
||||
function login_destination_perform_redirect($trigger = '', $current = NULL) {
|
||||
$destination = login_destination_get_destination($trigger, $current);
|
||||
|
||||
// Check if we redirect
|
||||
if ($destination !== FALSE) {
|
||||
login_destination_prepare_goto($destination);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process all destination rules and return destination path.
|
||||
* This function is intended to be used by external modules.
|
||||
*/
|
||||
function login_destination_get_destination($trigger = '', $current = NULL) {
|
||||
// Get all the login destination rules from the database.
|
||||
$result = db_select('login_destination', 'l')
|
||||
//->addTag('translatable')
|
||||
->fields('l', array('triggers', 'roles', 'pages_type', 'pages', 'destination_type', 'destination'))
|
||||
->orderBy('weight')
|
||||
->execute()
|
||||
->fetchAll();
|
||||
|
||||
if ($current == NULL) {
|
||||
$current = $_GET['q'];
|
||||
}
|
||||
|
||||
// examine path matches
|
||||
foreach ($result as $data) {
|
||||
// try to match the subsequent rule
|
||||
if (_login_destination_match_rule($data, $trigger, $current)) {
|
||||
// Note: Matching rule with empty destination will cancel redirect.
|
||||
return _login_destination_evaluate_rule($data, $trigger);
|
||||
}
|
||||
}
|
||||
|
||||
// no rule matched
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate the code with forms context.
|
||||
*
|
||||
* This function hides the calling function's scope from eval().
|
||||
*/
|
||||
function _login_destination_eval($code) {
|
||||
// We could use the php_eval(), but would not be able get array return value.
|
||||
// We always check for the existance of PHP Filter module for security.
|
||||
return eval('?>' . $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function to provide role options
|
||||
*/
|
||||
function _login_destination_role_options() {
|
||||
// user role selection, without anonymous and authentificated user roles.
|
||||
$role_options = array_map('check_plain', user_roles(TRUE));
|
||||
unset($role_options[DRUPAL_AUTHENTICATED_RID]);
|
||||
return $role_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current path (before trigger was invoked).
|
||||
*/
|
||||
function _login_destination_get_current($trigger = '') {
|
||||
if (isset($_GET['current'])) {
|
||||
return check_plain($_GET['current']);
|
||||
}
|
||||
|
||||
if ($trigger == 'login') {
|
||||
return $_GET['q'];
|
||||
}
|
||||
|
||||
// front by default
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function to determine whether redirection should happen.
|
||||
*
|
||||
* @return bool TRUE - apply redirect, FALSE - not to apply redirect.
|
||||
*/
|
||||
function _login_destination_match_rule($rule, $trigger = '', $current = NULL) {
|
||||
global $user;
|
||||
|
||||
$type = $rule->pages_type;
|
||||
$pages = $rule->pages;
|
||||
|
||||
$triggers = unserialize($rule->triggers);
|
||||
if (empty($triggers))
|
||||
$triggers = array();
|
||||
|
||||
$roles = unserialize($rule->roles);
|
||||
if (empty($roles))
|
||||
$roles = array();
|
||||
|
||||
// remove non-existent roles
|
||||
$roles = array_intersect_key(_login_destination_role_options(), $roles);
|
||||
|
||||
// examine trigger match
|
||||
if (!(empty($triggers) || array_key_exists($trigger, $triggers))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// examine role matches
|
||||
$roles_intersect = array_intersect_key($roles, $user->roles);
|
||||
|
||||
if (!empty($roles) && empty($roles_intersect)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($type < LOGIN_DESTINATION_REDIRECT_PHP) {
|
||||
$pages = drupal_strtolower($pages);
|
||||
$alias = drupal_strtolower(drupal_get_path_alias($current));
|
||||
|
||||
$page_match = drupal_match_path($alias, $pages);
|
||||
|
||||
if ($alias != $current) {
|
||||
$page_match = $page_match || drupal_match_path($current, $pages);
|
||||
}
|
||||
$page_match = !($type xor $page_match);
|
||||
}
|
||||
elseif (module_exists('php')) {
|
||||
// Do not execute php if the PHP Filter is off.
|
||||
$page_match = _login_destination_eval($pages);
|
||||
}
|
||||
else {
|
||||
$page_match = FALSE;
|
||||
}
|
||||
|
||||
return $page_match;
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function to evaluate destination path.
|
||||
*/
|
||||
function _login_destination_evaluate_rule($rule, $trigger = '') {
|
||||
if ($rule->destination_type == LOGIN_DESTINATION_STATIC) {
|
||||
// take only 1st line
|
||||
if (preg_match("!^(.*?)$!", $rule->destination, $matches) === 1 ) {
|
||||
$path = $matches[1];
|
||||
|
||||
if (empty($path)) {
|
||||
return FALSE;
|
||||
}
|
||||
// Current path
|
||||
elseif ($path == '<current>') {
|
||||
return _login_destination_get_current($trigger);
|
||||
}
|
||||
// External URL
|
||||
elseif (strpos($path, '://') !== FALSE) {
|
||||
return $path;
|
||||
}
|
||||
// Internal URL
|
||||
else {
|
||||
$destination = drupal_parse_url($path);
|
||||
$options = array();
|
||||
$options['query'] = $destination['query'];
|
||||
$options['fragment'] = $destination['fragment'];
|
||||
|
||||
// drupal_goto cares about <front>
|
||||
return array($destination['path'], $options);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// error - multiple lines
|
||||
return '';
|
||||
}
|
||||
}
|
||||
elseif (module_exists('php')) {
|
||||
// We cannot use the php_eval because we expect array here, but for the
|
||||
// matter of consistent UI we don't do it with the PHP Filter module off.
|
||||
$result = _login_destination_eval($rule->destination);
|
||||
|
||||
if (empty($result)) {
|
||||
return FALSE;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
// PHP code and PHP filter disabled.
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
|
||||
*******************************************************
|
||||
INSTALL.txt for logintoboggan.module for Drupal
|
||||
*******************************************************
|
||||
|
||||
INSTALLATION:
|
||||
|
||||
Place entire loggintoboggan module folder into
|
||||
(a) your sites/all/modules directory
|
||||
(b) your sites/[my site]/modules directory.
|
||||
|
||||
Enable the module at Administration » Modules
|
||||
|
||||
Configure logintoboggan settings at
|
||||
Administration » Configuration » System » LoginToboggan
|
||||
|
||||
The module changes the functionality of the login block AND provides a new
|
||||
LoginToboggan logged in block'.
|
||||
|
||||
Configure each block at Administration » Structure » Blocks as follows...
|
||||
|
||||
1. Configure the 'User login' block for LoginToboggan functionality:
|
||||
|
||||
Change title if required; using <none> can make for a very neat login system,
|
||||
when combined with the javascript functionality: clicking upon "Login/register"
|
||||
reveals the login form in sliding fashion. To select this functionality, select
|
||||
'Collapsible form' under "Block type". Selecting 'Link' under "Block type"
|
||||
sends user to a login form, returning them to original page after successful
|
||||
login.
|
||||
|
||||
2. Configure 'LoginToboggan logged in block'
|
||||
|
||||
Tip: by leaving the title blank, the 'LoginToboggan logged in block' is slim
|
||||
and neat.
|
||||
|
||||
Done!
|
||||
|
||||
CAVEATS:
|
||||
|
||||
1. Use the 'Delete unvalidated users after' feature with extreme caution!
|
||||
|
||||
This feature can be handy, but if misconfigured can cause unexpected damage
|
||||
to your user data -- specifically deleting users! Two things to guard
|
||||
against:
|
||||
|
||||
a. Be very careful when editing the 'Non-authenticated role' setting.
|
||||
If you set it to anything other than the 'authenticated user' role,
|
||||
LoginToboggan will happily start deleting any users you have in that
|
||||
role that were created prior to the purge interval. If you want to
|
||||
avoid problems, it's best to never change that setting after you've
|
||||
initially set it up.
|
||||
|
||||
b. LoginToboggan has mechanisms in place that prevent a user from being
|
||||
re-added to the Non-authenticated role after a user has been validated.
|
||||
Note that these protections are only present in core's interface -- if
|
||||
you have another module enabled which does any role manipulation
|
||||
(either via the user interface or programatically), you must find your
|
||||
own way to ensure that it doesn't add any users back into the
|
||||
Non-authenticated role.
|
||||
|
||||
Also note that the feature is only enabled if the 'Set password' option is
|
||||
also enabled.
|
||||
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -0,0 +1,40 @@
|
||||
|
||||
*******************************************************
|
||||
README.txt for logintoboggan.module for Drupal
|
||||
*******************************************************
|
||||
|
||||
Co-developed by Jeff Robbins (jjeff) and Chad Phillips (hunmonk) with several
|
||||
features added by Raven Brooks (rbrooks00).
|
||||
|
||||
The Login Toboggan module improves the Drupal login system in an external
|
||||
module by offering the following features:
|
||||
|
||||
1. Allow users to login using either their username OR their email address.
|
||||
2. Allow users to login immediately.
|
||||
3. Provide a login form on Access Denied pages for non-logged-in
|
||||
(anonymous) users.
|
||||
4. The module provides two login block options: One uses JavaScript to
|
||||
display the form within the block immediately upon clicking "log in".
|
||||
The other brings the user to a separate page, but returns the user to
|
||||
their original page upon login.
|
||||
5. Customize the registration form with two e-mail fields to ensure
|
||||
accuracy.
|
||||
6. Optionally redirect the user to a specific page when using the
|
||||
'immediate login' feature.
|
||||
7. Optionally redirect the user to a specific page upon validation of their
|
||||
e-mail address.
|
||||
8. Optionally display a user message indicating a successful login.
|
||||
9. Optionally combine both the login and registration form on one page.
|
||||
10. Optionally display a 'Request new password' link on the user login form.
|
||||
11. Optionally have unvalidated users purged from the system at a pre-defined
|
||||
interval
|
||||
(please read the CAVEATS section of INSTALL.txt for important information
|
||||
on configuringthis feature!).
|
||||
|
||||
Users who choose their own password can be automatically assigned to a selected
|
||||
'non-authenticated' role. This role could have more permissions than anonymous
|
||||
but less than authenticated - thus preventing spoof accounts and spammers. The
|
||||
user will only be removed from the non-authenticated role and granted
|
||||
authenticated permissions when they verify their account via a special email
|
||||
link, or when an administrator removes them from the non-authenticated role.
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
*******************************************************
|
||||
UPGRADING.txt for logintoboggan.module for Drupal
|
||||
*******************************************************
|
||||
|
||||
6.x to 7.x:
|
||||
|
||||
1. Core changed the way it identifies blocks internally. The update functions
|
||||
should handle the transition.
|
||||
|
||||
2. A new option for a unified login/register page has been added. See the
|
||||
'Present a unified login/registration page' setting in the 'Log in' section
|
||||
of LoginToboggan settings.
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
********************************************************************************
|
||||
README.txt for logintoboggan_content_access_integration.module for Drupal
|
||||
********************************************************************************
|
||||
Developed by Geoff Appleby (gapple - http://drupal.org/user/490940).
|
||||
|
||||
The Login Toboggan / Content Access Integration module provides information to
|
||||
Content Access module so that it is able to handle Non-validated users correctly
|
||||
when optimizing permissions.
|
||||
If you do not make use of the Non-validated user role option this module is
|
||||
not required, but will not cause any ill-effects.
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
name = "LoginToboggan Content Access Integration"
|
||||
description = "Integrates LoginToboggan with Content Access module, so that Non-validated users are handled correctly"
|
||||
core = "7.x"
|
||||
|
||||
dependencies[] = logintoboggan
|
||||
dependencies[] = content_access
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-11-09
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "logintoboggan"
|
||||
datestamp = "1320873335"
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implementation of hook_enable().
|
||||
*
|
||||
* Check if the LoginToboggan 'Non-validated' role is used, and node access
|
||||
* permissions may need to be rebuilt.
|
||||
*
|
||||
* @todo Automatically rebuild records only for content types that will need it.
|
||||
*/
|
||||
function logintoboggan_content_access_integration_enable(){
|
||||
|
||||
if (logintoboggan_validating_id() == DRUPAL_AUTHENTICATED_RID) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rebuild = array();
|
||||
foreach (content_access_get_settings() as $permission => $content_types) {
|
||||
foreach ($content_types as $content_type => $roles) {
|
||||
if (!is_array($roles)){
|
||||
// This is not actually a node access permission (e.g. per_node).
|
||||
continue;
|
||||
}
|
||||
|
||||
// If permissions were set for Anonymous and Authenticated but not
|
||||
// Non-authenticated, Non-Authenticated was erroneously given access, and
|
||||
// will be denied on next rebuild.
|
||||
$roles_set = array_diff(array(DRUPAL_AUTHENTICATED_RID, DRUPAL_ANONYMOUS_RID), $roles);
|
||||
if (empty($roles_set) && !in_array(logintoboggan_validating_id(), $roles)) {
|
||||
drupal_set_message(
|
||||
t(
|
||||
'The "@content_type" content type has the "@permission" permission set for Anonymous and Authenticated roles, but not Non-Authenticated. ' .
|
||||
'You should grant this permission to the Non-Authenticated role if all users should continue to have access. ',
|
||||
array( '@content_type' => $content_type, '@permission' => $permission)
|
||||
) .
|
||||
l(t('Go to the Access Control Settings page.'), 'admin/content/node-type/' . $content_type . '/access'),
|
||||
'warning'
|
||||
);
|
||||
}
|
||||
|
||||
if (in_array($content_type, $rebuild)) {
|
||||
// We already checked this content type for another permission.
|
||||
continue;
|
||||
}
|
||||
|
||||
// If permissions were set for Authenticated and Non-authenticated roles,
|
||||
// the Non-authenticated role would not have been added to the
|
||||
// node access records. (Except if Anonymous is set too, where in both
|
||||
// cases the permissions should be optimized to 'all').
|
||||
$roles_set = array_diff(array(DRUPAL_AUTHENTICATED_RID, logintoboggan_validating_id()), $roles);
|
||||
if (empty($roles_set) && !in_array(DRUPAL_ANONYMOUS_RID, $roles)) {
|
||||
$rebuild[] = $content_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($rebuild) {
|
||||
node_access_needs_rebuild(TRUE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implementation of hook_content_access_special_roles().
|
||||
*/
|
||||
function logintoboggan_content_access_integration_content_access_special_roles(){
|
||||
if (logintoboggan_validating_id() != DRUPAL_AUTHENTICATED_RID) {
|
||||
return array(logintoboggan_validating_id());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
Introduction
|
||||
===========
|
||||
|
||||
It is a very simple module which provides an integration between widely
|
||||
used modules "LoginToboggan" and "Rules".
|
||||
|
||||
Installation
|
||||
============
|
||||
1. Enable the module in the module listing page.
|
||||
2. In LoginToboggan settings check "Set password" option.
|
||||
3. Thats it!!
|
||||
|
||||
For best results, you may want to uncheck the "Immediate login" option on
|
||||
LoginToboggan settings. This is just for cosmetic reasons, as in most use
|
||||
cases you might want users to click on the verification link first before
|
||||
actually letting them in the site.
|
||||
|
||||
Usage
|
||||
=====
|
||||
Create a rule. You will now see "When the user account is validated"
|
||||
event under LoginToboggan category.
|
||||
In this event, the validated user's account information is available.
|
||||
Use this event to implement various automation tasks.
|
||||
|
||||
Currently maintained by Sudhir (porwal.lucky@gmail.com)
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
name = "LoginToboggan Rules Integration"
|
||||
description = "Integrates LoginToboggan with Rules module"
|
||||
core = "7.x"
|
||||
|
||||
dependencies[] = logintoboggan
|
||||
dependencies[] = rules
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-11-09
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "logintoboggan"
|
||||
datestamp = "1320873335"
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Logintoboggan Rules module
|
||||
*
|
||||
* This module provides integration of LoginToboggan module with Rules module
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Implement hook_user()
|
||||
*
|
||||
*/
|
||||
function logintoboggan_rules_user_update(&$edit, $account) {
|
||||
if (!empty($account->logintoboggan_email_validated)) {
|
||||
rules_invoke_event('logintoboggan_validated', $account);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implement hook_rules_event_info().
|
||||
* @ingroup rules
|
||||
*/
|
||||
|
||||
function logintoboggan_rules_rules_event_info() {
|
||||
return array(
|
||||
'logintoboggan_validated' => array(
|
||||
'label' => t("When the user account is validated."),
|
||||
'group' => 'LoginToboggan',
|
||||
'variables' => array(
|
||||
'account' => array(
|
||||
'type' => 'user',
|
||||
'label' => t("The validated user's account"),
|
||||
),
|
||||
),
|
||||
'group' => t('User'),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
name = "LoginToboggan Variable Integration"
|
||||
description = "Integrates LoginToboggan with Variable module"
|
||||
core = "7.x"
|
||||
|
||||
dependencies[] = logintoboggan
|
||||
dependencies[] = variable
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-11-09
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "logintoboggan"
|
||||
datestamp = "1320873335"
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_variable_info().
|
||||
*/
|
||||
function logintoboggan_variable_variable_info($options) {
|
||||
$variables = array(
|
||||
'logintoboggan_confirm_email_at_registration' => array(
|
||||
'title' => t('Use two e-mail fields on registration form', array(), $options),
|
||||
'description' => t('User will have to type the same e-mail address into both fields. This helps to confirm that they\'ve typed the correct address.', array(), $options),
|
||||
'default' => 0,
|
||||
'type' => 'boolean',
|
||||
'group' => 'user_settings',
|
||||
'localize' => FALSE,
|
||||
),
|
||||
'logintoboggan_immediate_login_on_register' => array(
|
||||
'title' => t('Immediate login', array(), $options),
|
||||
'description' => t('If set, the user will be logged in immediately after registering.', array(), $options),
|
||||
'default' => TRUE,
|
||||
'type' => 'boolean',
|
||||
'group' => 'user_settings',
|
||||
'localize' => FALSE,
|
||||
),
|
||||
'logintoboggan_login_successful_message' => array(
|
||||
'title' => t('Display login successful message', array(), $options),
|
||||
'description' => t('If enabled, users will receive a \'Log in successful\' message upon login.', array(), $options),
|
||||
'default' => 0,
|
||||
'type' => 'boolean',
|
||||
'group' => 'user_settings',
|
||||
'localize' => FALSE,
|
||||
),
|
||||
'logintoboggan_login_with_email' => array(
|
||||
'title' => t('Allow users to login using their e-mail address', array(), $options),
|
||||
'description' => t('Users will be able to enter EITHER their username OR their e-mail address to log in.', array(), $options),
|
||||
'default' => 0,
|
||||
'type' => 'boolean',
|
||||
'group' => 'user_settings',
|
||||
'localize' => FALSE,
|
||||
),
|
||||
'logintoboggan_minimum_password_length' => array(
|
||||
'title' => t('Minimum password length', array(), $options),
|
||||
'description' => t('The minimum number of password characters required on the registration form.', array(), $options),
|
||||
'default' => 0,
|
||||
'type' => 'number',
|
||||
'group' => 'user_settings',
|
||||
'localize' => FALSE,
|
||||
),
|
||||
'logintoboggan_override_destination_parameter' => array(
|
||||
'title' => t('Override destination parameter', array(), $options),
|
||||
'description' => t('Normally, when a Drupal redirect is performed, priority is given to the \'destination\' parameter from the originating URL. With this setting enabled, LoginToboggan will attempt to override this behavior.', array(), $options),
|
||||
'default' => 1,
|
||||
'type' => 'boolean',
|
||||
'group' => 'user_settings',
|
||||
'localize' => FALSE,
|
||||
),
|
||||
'logintoboggan_pre_auth_role' => array(
|
||||
'title' => t('Non-authenticated role', array(), $options),
|
||||
'description' => t('The role that is assigned to users that have supplied a password during the registration process but have not yet clicked on the link in their welcome email.', array(), $options),
|
||||
'default' => DRUPAL_AUTHENTICATED_RID,
|
||||
'type' => 'number',
|
||||
'group' => 'user_settings',
|
||||
'localize' => FALSE,
|
||||
),
|
||||
'logintoboggan_purge_unvalidated_user_interval' => array(
|
||||
'title' => t('Unvalidated user purge interval', array(), $options),
|
||||
'description' => t('The time interval in seconds after which users will be deleted who have registered but not yet clicked on the link in their welcome email.', array(), $options),
|
||||
'default' => 0,
|
||||
'type' => 'number',
|
||||
'group' => 'user_settings',
|
||||
'localize' => FALSE,
|
||||
),
|
||||
'logintoboggan_redirect_on_confirm' => array(
|
||||
'title' => t('Redirect path on confirmation', array(), $options),
|
||||
'description' => t('The path the user will be redirected to after confiming their account.', array(), $options),
|
||||
'default' => '',
|
||||
'type' => 'url',
|
||||
'group' => 'user_settings',
|
||||
'localize' => TRUE,
|
||||
),
|
||||
'logintoboggan_redirect_on_register' => array(
|
||||
'title' => t('Redirect path on registration', array(), $options),
|
||||
'description' => t('The path the user will be redirected to after registering.', array(), $options),
|
||||
'default' => '',
|
||||
'type' => 'url',
|
||||
'group' => 'user_settings',
|
||||
'localize' => TRUE,
|
||||
),
|
||||
'logintoboggan_unified_login' => array(
|
||||
'title' => t('Present a unified login/registration page', array(), $options),
|
||||
'description' => t('Use one page for both login and registration instead of Drupal\'s tabbed login/registration/password pages.', array(), $options),
|
||||
'default' => '0',
|
||||
'type' => 'boolean',
|
||||
'group' => 'user_settings',
|
||||
'localize' => FALSE,
|
||||
),
|
||||
'logintoboggan_user_email_verification' => array(
|
||||
'title' => t('Supply password when registering', array(), $options),
|
||||
'description' => t('Allows users to type in their password in the registration form.', array(), $options),
|
||||
'default' => !variable_get('user_email_verification', TRUE) ? 1 : 0,
|
||||
'type' => 'boolean',
|
||||
'group' => 'user_settings',
|
||||
'localize' => FALSE,
|
||||
),
|
||||
);
|
||||
return $variables;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
div.toboggan-login-link-container {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
div.toboggan-block-message {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
div.user-login-block {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
div.user-login-block a {
|
||||
text-align: right;
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Administration functions for LoginToboggan module.
|
||||
*/
|
||||
|
||||
function logintoboggan_main_settings() {
|
||||
|
||||
$_disabled = t('Disabled');
|
||||
$_enabled = t('Enabled');
|
||||
|
||||
$form['login'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Log in'),
|
||||
);
|
||||
|
||||
$form['login']['logintoboggan_login_with_email'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Allow users to login using their e-mail address'),
|
||||
'#default_value' => variable_get('logintoboggan_login_with_email', 0),
|
||||
'#options' => array($_disabled, $_enabled),
|
||||
'#description' => t('Users will be able to enter EITHER their username OR their e-mail address to log in.'),
|
||||
);
|
||||
|
||||
$form['login']['logintoboggan_unified_login'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Present a unified login/registration page'),
|
||||
'#default_value' => variable_get('logintoboggan_unified_login', 0),
|
||||
'#description' => t("Use one page for both login and registration instead of Drupal's tabbed login/registration/password pages."),
|
||||
);
|
||||
|
||||
$form['registration'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Registration'),
|
||||
);
|
||||
|
||||
$form['registration']['logintoboggan_confirm_email_at_registration'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Use two e-mail fields on registration form'),
|
||||
'#default_value' => variable_get('logintoboggan_confirm_email_at_registration', 0),
|
||||
'#options' => array($_disabled, $_enabled),
|
||||
'#description' => t('User will have to type the same e-mail address into both fields. This helps to confirm that they\'ve typed the correct address.'),
|
||||
);
|
||||
|
||||
if (module_exists('help')) {
|
||||
$help_text = t(" More help in writing the e-mail message can be found at <a href=\"!help\">LoginToboggan help</a>.", array('!help' => url('admin/help/logintoboggan')));
|
||||
}
|
||||
else {
|
||||
$help_text = '';
|
||||
}
|
||||
$form['registration']['logintoboggan_user_email_verification'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Set password'),
|
||||
'#default_value' => !variable_get('user_email_verification', TRUE) ? 1 : 0,
|
||||
'#description' => t("This will allow users to choose their initial password when registering (note that this setting is a mirror of the <a href=\"!settings\">Require e-mail verification when a visitor creates an account</a> setting, and is merely here for convenience). If selected, users will be assigned to the role below. They will not be assigned to the 'authenticated user' role until they confirm their e-mail address by following the link in their registration e-mail. It is HIGHLY recommended that you set up a 'pre-authorized' role with limited permissions for this purpose. <br />NOTE: If you enable this feature, you should edit the <a href=\"!settings\">Welcome (no approval required)</a> text.", array('!settings' => url('admin/config/people/accounts'))) . $help_text,
|
||||
);
|
||||
|
||||
// Grab the roles that can be used for pre-auth. Remove the anon role, as it's not a valid choice.
|
||||
$roles = user_roles(TRUE);
|
||||
|
||||
$form ['registration']['logintoboggan_pre_auth_role'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Non-authenticated role'),
|
||||
'#options' => $roles,
|
||||
'#default_value' => variable_get('logintoboggan_pre_auth_role', DRUPAL_AUTHENTICATED_RID),
|
||||
'#description' => t('If "Set password" is selected, users will be able to login before their e-mail address has been authenticated. Therefore, you must choose a role for new non-authenticated users -- you may wish to <a href="!url">add a new role</a> for this purpose. Users will be removed from this role and assigned to the "authenticated user" role once they follow the link in their welcome e-mail. <strong>WARNING: changing this setting after initial site setup can cause undesirable results, including unintended deletion of users -- change with extreme caution!</strong>', array('!url' => url('admin/people/permissions/roles'))),
|
||||
);
|
||||
|
||||
$purge_options = array(
|
||||
0 => t('Never delete'),
|
||||
86400 => t('1 Day'),
|
||||
172800 => t('2 Days'),
|
||||
259200 => t('3 Days'),
|
||||
345600 => t('4 Days'),
|
||||
432000 => t('5 Days'),
|
||||
518400 => t('6 Days'),
|
||||
604800 => t('1 Week'),
|
||||
1209600 => t('2 Weeks'),
|
||||
2592000 => t('1 Month'),
|
||||
7776000 => t('3 Months'),
|
||||
15379200 => t('6 Months'),
|
||||
30758400 => t('1 Year'),
|
||||
);
|
||||
|
||||
$form['registration']['logintoboggan_purge_unvalidated_user_interval'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Delete unvalidated users after'),
|
||||
'#options' => $purge_options,
|
||||
'#default_value' => variable_get('logintoboggan_purge_unvalidated_user_interval', 0),
|
||||
'#description' => t("If enabled, users that are still in the 'Non-authenticated role' set above will be deleted automatically from the system, if the set time interval since their initial account creation has passed. This can be used to automatically purge spambot registrations. Note: this requires cron, and also requires that the 'Set password' option above is enabled. <strong>WARNING: changing this setting after initial site setup can cause undesirable results, including unintended deletion of users -- change with extreme caution! (please read the CAVEATS section of INSTALL.txt for important information on configuring this feature)</strong>")
|
||||
);
|
||||
|
||||
$form['registration']['logintoboggan_immediate_login_on_register'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Immediate login'),
|
||||
'#default_value' => variable_get('logintoboggan_immediate_login_on_register', TRUE),
|
||||
'#description' => t("If set, the user will be logged in immediately after registering. Note this only applies if the 'Set password' option above is enabled."),
|
||||
);
|
||||
|
||||
$form['registration']['redirect'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Redirections'),
|
||||
'#collapsible' => true,
|
||||
'#collapsed' => false,
|
||||
);
|
||||
|
||||
$form['registration']['redirect']['logintoboggan_redirect_on_register'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Redirect path on registration'),
|
||||
'#default_value' => variable_get('logintoboggan_redirect_on_register', ''),
|
||||
'#description' => t('Normally, after a user registers a new account, they will be taken to the front page, or to their user page if you specify <cite>Immediate login</cite> above. Leave this setting blank if you wish to keep the default behavior. If you wish the user to go to a page of your choosing, then enter the path for it here. For instance, you may redirect them to a static page such as <cite>node/35</cite>, or to the <cite><front></cite> page. You may also use <em>%uid</em> as a variable, and the user\'s user ID will be substituted in the path.'),
|
||||
);
|
||||
|
||||
$form['registration']['redirect']['logintoboggan_redirect_on_confirm'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Redirect path on confirmation'),
|
||||
'#default_value' => variable_get('logintoboggan_redirect_on_confirm', ''),
|
||||
'#description' => t('Normally, after a user confirms their new account, they will be taken to their user page. Leave this setting blank if you wish to keep the default behavior. If you wish the user to go to a page of your choosing, then enter the path for it here. For instance, you may redirect them to a static page such as <cite>node/35</cite>, or to the <cite><front></cite> page. You may also use <em>%uid</em> as a variable, and the user\'s user ID will be substituted in the path. In the case where users are not creating their own passwords, it is suggested to use <cite>user/%uid/edit</cite> here, so the user may set their password immediately after validating their account.'),
|
||||
);
|
||||
$form['registration']['redirect']['logintoboggan_override_destination_parameter'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Override destination parameter'),
|
||||
'#default_value' => variable_get('logintoboggan_override_destination_parameter', 1),
|
||||
'#description' => t("Normally, when a Drupal redirect is performed, priority is given to the 'destination' parameter from the originating URL. With this setting enabled, LoginToboggan will attempt to override this behavior with any values set above."),
|
||||
);
|
||||
|
||||
$form['other'] = array('#type' => 'fieldset',
|
||||
'#title' => t('Other'),
|
||||
'#tree' => FALSE,
|
||||
);
|
||||
|
||||
$site403 = variable_get('site_403', '');
|
||||
if ($site403 == '') {
|
||||
$disabled = $default = '0';
|
||||
}
|
||||
elseif ($site403 == 'toboggan/denied') {
|
||||
$disabled = '0';
|
||||
$default = 'toboggan/denied';
|
||||
}
|
||||
else {
|
||||
$disabled = $default = $site403;
|
||||
}
|
||||
$options = array($disabled => $_disabled, 'toboggan/denied' => $_enabled);
|
||||
|
||||
$form['other']['logintoboggan_site_403'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Present login form on access denied (403)'),
|
||||
'#options' => $options,
|
||||
'#default_value' => $default,
|
||||
'#description' => t('Anonymous users will be presented with a login form along with an access denied message.')
|
||||
);
|
||||
$form['other']['logintoboggan_login_successful_message'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Display login successful message'),
|
||||
'#options' => array($_disabled, $_enabled),
|
||||
'#default_value' => variable_get('logintoboggan_login_successful_message', 0),
|
||||
'#description' => t('If enabled, users will receive a \'Log in successful\' message upon login.')
|
||||
);
|
||||
$min_pass_options = array(t('None'));
|
||||
for ($i = 2; $i < 30; $i++) {
|
||||
$min_pass_options[$i] = $i;
|
||||
}
|
||||
$form['other']['logintoboggan_minimum_password_length'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Minimum password length'),
|
||||
'#options' => $min_pass_options,
|
||||
'#default_value' => variable_get('logintoboggan_minimum_password_length', 0),
|
||||
'#description' => t('LoginToboggan automatically performs basic password validation for illegal characters. If you would additionally like to have a minimum password length requirement, select the length here, or set to \'None\' for no password length validation.')
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_form_logintoboggan_main_settings_alter().
|
||||
*
|
||||
* @ingroup logintoboggan_core
|
||||
*/
|
||||
function logintoboggan_form_logintoboggan_main_settings_alter(&$form, &$form_state) {
|
||||
// Ensure a valid submit array.
|
||||
$form['#submit'] = is_array($form['#submit']) ? $form['#submit'] : array();
|
||||
// Make this submit handler run first.
|
||||
array_unshift($form['#submit'], 'logintoboggan_main_settings_submit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes custom settings on the main settings page, transforms them into the
|
||||
* appropriate core setting, and cleans up the custom values.
|
||||
*/
|
||||
function logintoboggan_main_settings_submit($form, &$form_state) {
|
||||
// User email verification setting.
|
||||
$user_email_verification = $form_state['values']['logintoboggan_user_email_verification'] ? FALSE : TRUE;
|
||||
variable_set('user_email_verification', $user_email_verification);
|
||||
unset($form_state['values']['logintoboggan_user_email_verification']);
|
||||
|
||||
// Site 403 setting.
|
||||
$site_403 = $form_state['values']['logintoboggan_site_403'] == '0' ? '' : $form_state['values']['logintoboggan_site_403'];
|
||||
variable_set('site_403', $site_403);
|
||||
unset($form_state['values']['logintoboggan_site_403']);
|
||||
|
||||
// If the unified login setting has been changed, we need to rebuild the
|
||||
// menu cache.
|
||||
if ($form['login']['logintoboggan_unified_login']['#default_value'] != $form['login']['logintoboggan_unified_login']['#value']) {
|
||||
drupal_set_message(t('Unified login setting was changed, menus have been rebuilt.'));
|
||||
// For some reason, a regular menu_rebuild() still leaves the old callbacks
|
||||
// cached -- doing it in a shutdown function seems to correct that issue.
|
||||
drupal_register_shutdown_function('menu_rebuild');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
div.toboggan-container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.toboggan-login-link-container {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
div.toboggan-login-link-container a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
div.toboggan-block-message {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
div.user-login-block {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
div.user-login-block a {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Unified login */
|
||||
|
||||
.toboggan-unified #login-message {
|
||||
text-align: center;
|
||||
font-size: 2em;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.toboggan-unified #login-links {
|
||||
text-align: center;
|
||||
font-size: 1.5em;
|
||||
line-height: 2.7;
|
||||
}
|
||||
|
||||
.toboggan-unified #login-links a {
|
||||
padding: .5em;
|
||||
border: 1px #666 solid;
|
||||
background-color: #EEE;
|
||||
}
|
||||
|
||||
.toboggan-unified #login-links a:hover {
|
||||
background-color: #DDD;
|
||||
}
|
||||
|
||||
.toboggan-unified #login-links a.lt-active,
|
||||
.toboggan-unified #login-links a.lt-active:hover {
|
||||
background-color: #FFF19A;
|
||||
border: 2px #333 solid;
|
||||
}
|
||||
|
||||
.toboggan-unified.login #register-form {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.toboggan-unified.register #login-form {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
name = "LoginToboggan"
|
||||
description = "Improves Drupal's login system."
|
||||
core = "7.x"
|
||||
configure = admin/config/system/logintoboggan
|
||||
|
||||
stylesheets[all][] = logintoboggan.css
|
||||
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-11-09
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "logintoboggan"
|
||||
datestamp = "1320873335"
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the logintoboggan module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implement hook_update_last_removed().
|
||||
*/
|
||||
function logintoboggan_update_last_removed() {
|
||||
return 6001;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_disable().
|
||||
*
|
||||
*/
|
||||
function logintoboggan_disable() {
|
||||
// Clean up the custom access denied path if it's set.
|
||||
if (variable_get('site_403', '') == 'toboggan/denied') {
|
||||
variable_set('site_403', '');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove hardcoded numeric deltas from blocks.
|
||||
*/
|
||||
function logintoboggan_update_7000(&$sandbox) {
|
||||
// Get an array of the renamed block deltas, organized by module.
|
||||
$renamed_deltas = array(
|
||||
'logintoboggan' => array(
|
||||
'0' => 'logintoboggan_logged_in',
|
||||
),
|
||||
);
|
||||
|
||||
update_fix_d7_block_deltas($sandbox, $renamed_deltas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_uninstall().
|
||||
*/
|
||||
function logintoboggan_uninstall() {
|
||||
$variables = array(
|
||||
'logintoboggan_login_block_type',
|
||||
'logintoboggan_login_block_message',
|
||||
'logintoboggan_login_with_email',
|
||||
'logintoboggan_confirm_email_at_registration',
|
||||
'logintoboggan_pre_auth_role',
|
||||
'logintoboggan_purge_unvalidated_user_interval',
|
||||
'logintoboggan_redirect_on_register',
|
||||
'logintoboggan_redirect_on_confirm',
|
||||
'logintoboggan_login_successful_message',
|
||||
'logintoboggan_minimum_password_length',
|
||||
'logintoboggan_immediate_login_on_register',
|
||||
'logintoboggan_override_destination_parameter',
|
||||
'logintoboggan_denied_remove_sidebars',
|
||||
);
|
||||
foreach ($variables as $variable) {
|
||||
variable_del($variable);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
(function ($) {
|
||||
Drupal.behaviors.LoginToboggan = {
|
||||
attach: function (context, settings) {
|
||||
$('#toboggan-login', context).once('toggleboggan_setup', function () {
|
||||
$(this).hide();
|
||||
Drupal.logintoboggan_toggleboggan();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.logintoboggan_toggleboggan = function() {
|
||||
$("#toboggan-login-link").click(
|
||||
function () {
|
||||
$("#toboggan-login").slideToggle("fast");
|
||||
this.blur();
|
||||
return false;
|
||||
}
|
||||
);
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
|
||||
/**
|
||||
* This is a custom implementation of user.permissions.js, which is necessary
|
||||
* because LoginToboggan needs its pre-auth role to not be explicitly tied to
|
||||
* the auth role. The change is minor -- simply exclude the pre-auth role from
|
||||
* all the auto-checking as the anon and auth user roles are.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
|
||||
/**
|
||||
* Shows checked and disabled checkboxes for inherited permissions.
|
||||
*/
|
||||
Drupal.behaviors.permissions = {
|
||||
attach: function (context) {
|
||||
var self = this;
|
||||
$('table#permissions').once('permissions', function () {
|
||||
// On a site with many roles and permissions, this behavior initially has
|
||||
// to perform thousands of DOM manipulations to inject checkboxes and hide
|
||||
// them. By detaching the table from the DOM, all operations can be
|
||||
// performed without triggering internal layout and re-rendering processes
|
||||
// in the browser.
|
||||
var $table = $(this);
|
||||
if ($table.prev().length) {
|
||||
var $ancestor = $table.prev(), method = 'after';
|
||||
}
|
||||
else {
|
||||
var $ancestor = $table.parent(), method = 'append';
|
||||
}
|
||||
$table.detach();
|
||||
|
||||
// Create dummy checkboxes. We use dummy checkboxes instead of reusing
|
||||
// the existing checkboxes here because new checkboxes don't alter the
|
||||
// submitted form. If we'd automatically check existing checkboxes, the
|
||||
// permission table would be polluted with redundant entries. This
|
||||
// is deliberate, but desirable when we automatically check them.
|
||||
var $dummy = $('<input type="checkbox" class="dummy-checkbox" disabled="disabled" checked="checked" />')
|
||||
.attr('title', Drupal.t("This permission is inherited from the authenticated user role."))
|
||||
.hide();
|
||||
|
||||
$('input[type=checkbox]', this).not('.rid-2, .rid-1, .rid-' + Drupal.settings.LoginToboggan.preAuthID).addClass('real-checkbox').each(function () {
|
||||
$dummy.clone().insertAfter(this);
|
||||
});
|
||||
|
||||
// Initialize the authenticated user checkbox.
|
||||
$('input[type=checkbox].rid-2', this)
|
||||
.bind('click.permissions', self.toggle)
|
||||
// .triggerHandler() cannot be used here, as it only affects the first
|
||||
// element.
|
||||
.each(self.toggle);
|
||||
|
||||
// Re-insert the table into the DOM.
|
||||
$ancestor[method]($table);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggles all dummy checkboxes based on the checkboxes' state.
|
||||
*
|
||||
* If the "authenticated user" checkbox is checked, the checked and disabled
|
||||
* checkboxes are shown, the real checkboxes otherwise.
|
||||
*/
|
||||
toggle: function () {
|
||||
var authCheckbox = this, $row = $(this).closest('tr');
|
||||
// jQuery performs too many layout calculations for .hide() and .show(),
|
||||
// leading to a major page rendering lag on sites with many roles and
|
||||
// permissions. Therefore, we toggle visibility directly.
|
||||
$row.find('.real-checkbox').each(function () {
|
||||
this.style.display = (authCheckbox.checked ? 'none' : '');
|
||||
});
|
||||
$row.find('.dummy-checkbox').each(function () {
|
||||
this.style.display = (authCheckbox.checked ? '' : 'none');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Builds placeholder replacement tokens for logintoboggan-related data.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_token_info().
|
||||
*/
|
||||
function logintoboggan_token_info() {
|
||||
$info['tokens']['user']['validate-url'] = array(
|
||||
'name' => t('Validate URL'),
|
||||
'description' => t('The URL of the account validation page, provided by logintoboggan.'),
|
||||
);
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_tokens().
|
||||
*/
|
||||
function logintoboggan_tokens($type, $tokens, array $data = array(), array $options = array()) {
|
||||
$replacements = array();
|
||||
|
||||
$url_options = array('absolute' => TRUE);
|
||||
if (isset($options['language'])) {
|
||||
$url_options['language'] = $options['language'];
|
||||
}
|
||||
|
||||
if ($type == 'user' && !empty($data['user'])) {
|
||||
$account = $data['user'];
|
||||
|
||||
foreach ($tokens as $name => $original) {
|
||||
switch ($name) {
|
||||
// Validating URL.
|
||||
case 'validate-url':
|
||||
if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) == USER_REGISTER_VISITORS) {
|
||||
$replacements[$original] = logintoboggan_eml_validate_url($account, $url_options);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $replacements;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
(function ($) {
|
||||
|
||||
Drupal.behaviors.unifiedLogin = {
|
||||
|
||||
attach: function (context) {
|
||||
// Attach behaviors to the links so that they show/hide forms appropriately.
|
||||
$('.toboggan-unified #register-link').click(function() {
|
||||
$(this).addClass('lt-active').blur();
|
||||
$('.toboggan-unified #login-link').removeClass('lt-active');
|
||||
$('.toboggan-unified #register-form').show();
|
||||
$('.toboggan-unified #login-form').hide();
|
||||
return false;
|
||||
});
|
||||
$('.toboggan-unified #login-link').click(function() {
|
||||
$(this).addClass('lt-active').blur();
|
||||
$('.toboggan-unified #register-link').removeClass('lt-active');
|
||||
$('.toboggan-unified #login-form').show();
|
||||
$('.toboggan-unified #register-form').hide();
|
||||
return false;
|
||||
});
|
||||
|
||||
switch(Drupal.settings.LoginToboggan.unifiedLoginActiveForm) {
|
||||
case 'register':
|
||||
$('.toboggan-unified #register-link').click();
|
||||
break;
|
||||
case 'login':
|
||||
default:
|
||||
$('.toboggan-unified #login-link').click();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Validation functions for LoginToboggan module.
|
||||
/**
|
||||
|
||||
/**
|
||||
* Menu callback; validate the e-mail address as a one time URL, and redirects
|
||||
* to the user page on success.
|
||||
*/
|
||||
function logintoboggan_validate_email($account, $timestamp, $hashed_pass, $action = 'login') {
|
||||
global $user;
|
||||
|
||||
// Test here for a valid pre-auth -- if the pre-auth is set to the auth user, we
|
||||
// handle things a bit differently.
|
||||
$validating_id = logintoboggan_validating_id();
|
||||
$pre_auth = !variable_get('user_email_verification', TRUE) && $validating_id != DRUPAL_AUTHENTICATED_RID;
|
||||
|
||||
// No time out for first time login.
|
||||
// This conditional checks that:
|
||||
// - the user is still in the pre-auth role or didn't set
|
||||
// their own password.
|
||||
// - the hashed password is correct.
|
||||
if (((variable_get('user_email_verification', TRUE) && empty($account->login)) || ($pre_auth && array_key_exists($validating_id, $account->roles))) && $hashed_pass == logintoboggan_eml_rehash($account->pass, $timestamp, $account->mail)) {
|
||||
watchdog('user', 'E-mail validation URL used for %name with timestamp @timestamp.', array('%name' => $account->name, '@timestamp' => $timestamp));
|
||||
|
||||
_logintoboggan_process_validation($account);
|
||||
|
||||
// Where do we redirect after confirming the account?
|
||||
$redirect = _logintoboggan_process_redirect(variable_get('logintoboggan_redirect_on_confirm', ''), $account);
|
||||
|
||||
switch ($action) {
|
||||
// Proceed with normal user login, as long as it's open registration and their
|
||||
// account hasn't been blocked.
|
||||
case 'login':
|
||||
// Only show the validated message if there's a valid pre-auth role.
|
||||
if ($pre_auth) {
|
||||
drupal_set_message(t('You have successfully validated your e-mail address.'));
|
||||
}
|
||||
if (!$account->status) {
|
||||
drupal_set_message(t('Your account is currently blocked -- login cancelled.'), 'error');
|
||||
drupal_goto('');
|
||||
}
|
||||
else {
|
||||
$edit = array();
|
||||
$redirect = logintoboggan_process_login($account, $edit, $redirect);
|
||||
call_user_func_array('drupal_goto', $redirect);
|
||||
}
|
||||
break;
|
||||
// Admin validation.
|
||||
case 'admin':
|
||||
if ($pre_auth) {
|
||||
// Mail the user, letting them know their account now has auth user perms.
|
||||
_user_mail_notify('status_activated', $account);
|
||||
}
|
||||
|
||||
drupal_set_message(t('You have successfully validated %user.', array('%user' => $account->name)));
|
||||
drupal_goto("user/$account->uid/edit");
|
||||
break;
|
||||
// Catch all.
|
||||
default:
|
||||
drupal_set_message(t('You have successfully validated %user.', array('%user' => $account->name)));
|
||||
drupal_goto('');
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$message = t("Sorry, you can only use your validation link once for security reasons.");
|
||||
// No one currently logged in, go straight to user login page.
|
||||
if (empty($user->uid)) {
|
||||
$message .= t(" Please log in with your username and password instead now.");
|
||||
$goto = 'user/login';
|
||||
}
|
||||
else {
|
||||
$goto = 'user';
|
||||
}
|
||||
drupal_set_message($message, 'error');
|
||||
drupal_goto($goto);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-sends validation e-mail to user specified by $uid.
|
||||
*/
|
||||
function logintoboggan_resend_validation($account) {
|
||||
$account->password = t('If required, you may reset your password from: !url', array('!url' => url('user/password', array('absolute' => TRUE))));
|
||||
|
||||
_user_mail_notify('register_no_approval_required', $account);
|
||||
|
||||
// Notify admin or user that e-mail was sent and return to user edit form.
|
||||
if (user_access('administer users')) {
|
||||
drupal_set_message(t("A validation e-mail has been sent to the user's e-mail address."));
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('A validation e-mail has been sent to your e-mail address. You will need to follow the instructions in that message in order to gain full access to the site.'));
|
||||
}
|
||||
|
||||
drupal_goto('user/'. $account->uid .'/edit');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
Role Delegation 7.x-1.1, 2011-06-20
|
||||
-----------------------------------
|
||||
#1119192 by Andrew Schulman: fix Role Delegation tab in user profile appears as an action, not a tab.
|
||||
#1180600 by jyee: fix overwrites role attributes in forms.
|
||||
#1185796 by Andrew Schulman: fix Role delegation options appear in every profile edit form with Profile 2.
|
||||
#1193868 by Andrew Schulman: fix Unsanitized output in role_delegation_delegate_roles_action_form().
|
||||
|
||||
Role Delegation 7.x-1.0, 2010-12-21
|
||||
-----------------------------------
|
||||
#170543 by Andrew Schulman: Rename or delete 'assign role' permissions when roles are renamed or deleted.
|
||||
#811932 by Pasqualle: Use 'restrict access' parameter for labeling unsafe permissions.
|
||||
Fix wrong assertion in RoleDelegationRoleEditingTestCase::testRenameRole() in role_delegation.test.
|
||||
|
||||
Role Delegation 7.x-1.0-beta1, 2010-12-07
|
||||
-----------------------------------------
|
||||
#660640 by Pasqualle: Port to D7; add "Delegate roles" action.
|
||||
#598840 by Andrew Schulman: Add batch add and remove role operations.
|
||||
#983574 by Andrew Schulman: Add simple tests for D7.
|
||||
#946506 by spam38: Fix htmlspecialchars warning on admin/people* pages in drupal 7.x.
|
||||
@@ -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
|
||||
@@ -0,0 +1,40 @@
|
||||
|
||||
README file for the Role Delegation Drupal module.
|
||||
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
This module allows site administrators to grant some roles the authority to
|
||||
assign selected roles to users, without them needing the 'administer
|
||||
permissions' permission.
|
||||
|
||||
For each role, Role Delegation provides a new 'assign <ROLE> role' permission to
|
||||
allow the assignment of that role.
|
||||
|
||||
The module also adds an 'assign all roles' permission. Enabling this permission
|
||||
for a role is a convenient way to allow the assignment of any other role without
|
||||
having to check all the 'assign <ROLE> role' permissions in the Permissions
|
||||
page.
|
||||
|
||||
If an administrator has the 'administer users' permission, a role assignment
|
||||
widget gets displayed in the account creation or editing form, and bulk
|
||||
add/remove role operations become available on the user administration page.
|
||||
Otherwise, if s/he has at least the 'access user profiles' permission, the
|
||||
module adds its own 'Roles' tab to the user profile so that roles can be
|
||||
assigned.
|
||||
|
||||
|
||||
Installation
|
||||
************
|
||||
|
||||
1. Extract the 'role_delegation' module directory, including all its
|
||||
subdirectories, into your Drupal modules directory.
|
||||
|
||||
2. Go to the Administer > Site building > Modules page, and enable the module.
|
||||
|
||||
3. Go to the Administer > User management > Permissions and scroll down to
|
||||
the role_delegation group of permissions. Each role now has a corresponding
|
||||
'assign <ROLE> role' permission. Grant this permission to roles that shall have
|
||||
the power to assign role ROLE to users.
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
name = Role delegation
|
||||
description = Allows site administrators to grant some roles the authority to assign selected roles to users.
|
||||
core = 7.x
|
||||
files[] = role_delegation.module
|
||||
files[] = role_delegation.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-06-20
|
||||
version = "7.x-1.1"
|
||||
core = "7.x"
|
||||
project = "role_delegation"
|
||||
datestamp = "1308565019"
|
||||
|
||||
@@ -0,0 +1,401 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This module allows site administrators to grant some roles the authority to
|
||||
* change roles assigned to users, without them needing the 'administer access
|
||||
* control' permission.
|
||||
*
|
||||
* It provides its own tab in the user profile so that roles can be changed
|
||||
* without needing access to the user edit form.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
*/
|
||||
function role_delegation_help($path, $arg) {
|
||||
switch ($path) {
|
||||
case 'admin/help#role_delegation':
|
||||
$output = '<p>' . t('This module allows site administrators to grant some roles the authority to assign selected roles to users, without them needing the <em>administer permissions</em> permission.') . '</p>';
|
||||
$output .= '<p>' . t('It provides its own tab in the user profile so that roles can be assigned without needing access to the user edit form.') . '</p>';
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function role_delegation_theme() {
|
||||
return array(
|
||||
'role_delegation_delegate_roles_action_form' => array(
|
||||
'render element' => 'form',
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function role_delegation_permission() {
|
||||
$roles = _role_delegation_roles();
|
||||
$perms['assign all roles'] = array(
|
||||
'title' => t('Assign all roles'),
|
||||
'restrict access' => TRUE,
|
||||
);
|
||||
foreach ($roles as $rid => $role) {
|
||||
$perms["assign $role role"] = array(
|
||||
'title' => t('Assign %role role', array('%role' => $role)),
|
||||
);
|
||||
}
|
||||
return $perms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function role_delegation_menu() {
|
||||
$items['user/%user/roles'] = array(
|
||||
'title' => 'Roles',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('role_delegation_roles_form', 1),
|
||||
'access callback' => 'role_delegation_access',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to create the role options.
|
||||
*/
|
||||
function _role_delegation_add_roles_to_form(&$form, $account) {
|
||||
$roles_current = $account->roles;
|
||||
|
||||
$roles_delegate = array();
|
||||
$roles = _role_delegation_roles();
|
||||
foreach ($roles as $rid => $role) {
|
||||
if (user_access('assign all roles') || user_access("assign $role role")) {
|
||||
$roles_delegate[$rid] = isset($form['account']['roles']['#options'][$rid]) ? $form['account']['roles']['#options'][$rid] : $role;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($roles_delegate)) {
|
||||
// No role can be assigned.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($form['account'])) {
|
||||
$form['account'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => $account,
|
||||
);
|
||||
}
|
||||
|
||||
// Generate the form items.
|
||||
$form['account']['roles_change'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => isset($form['account']['roles']['#title']) ? $form['account']['roles']['#title'] : t('Roles'),
|
||||
'#options' => $roles_delegate,
|
||||
'#default_value' => array_keys(array_intersect_key($roles_current, $roles_delegate)),
|
||||
'#description' => isset($form['account']['roles']['#description']) ? $form['account']['roles']['#description'] : t('Change roles assigned to user.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a form for assigning roles to the current user.
|
||||
*/
|
||||
function role_delegation_roles_form($form, $form_state, $account) {
|
||||
_role_delegation_add_roles_to_form($form, $account);
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the roles assigned to the account given in the form.
|
||||
*/
|
||||
function role_delegation_roles_form_submit($form, &$form_state) {
|
||||
if (is_array($form_state['values']['roles_change']) && isset($form_state['values']['account']->uid)) {
|
||||
$uid = (int)$form_state['values']['account']->uid;
|
||||
role_delegation_save(array($uid), $form_state['values']['roles_change']);
|
||||
drupal_set_message(t('The roles have been updated.'));
|
||||
}
|
||||
}
|
||||
|
||||
function role_delegation_save($uids, $roles_change) {
|
||||
$rolenames = user_roles(TRUE);
|
||||
foreach ($roles_change as $rid => $value) {
|
||||
if (!empty($value)) {
|
||||
// Use the role name for changed roles.
|
||||
$roles_change[$rid] = $rolenames[$rid];
|
||||
}
|
||||
}
|
||||
|
||||
$accounts = user_load_multiple($uids);
|
||||
foreach ($accounts as $account) {
|
||||
$roles_current = $account->roles;
|
||||
$roles = array_filter($roles_change + $roles_current);
|
||||
user_save($account, array('roles' => $roles));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access callback for menu hook.
|
||||
*/
|
||||
function role_delegation_access() {
|
||||
// Check access to user profile page.
|
||||
if (!user_access('access user profiles')) {
|
||||
return FALSE;
|
||||
}
|
||||
// Check if they can edit users. In that case, the Roles tab is not needed.
|
||||
if (user_access('administer users')) {
|
||||
return FALSE;
|
||||
}
|
||||
// Check access to role assignment page.
|
||||
if (user_access('administer permissions')) {
|
||||
return TRUE;
|
||||
}
|
||||
$perms = array_keys(role_delegation_permission());
|
||||
foreach ($perms as $perm) {
|
||||
if (user_access($perm)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all existing roles, except anonymous and authenticated user.
|
||||
*/
|
||||
function _role_delegation_roles() {
|
||||
$roles = user_roles(TRUE);
|
||||
unset($roles[DRUPAL_AUTHENTICATED_RID]);
|
||||
// Do not allow to delegate users to administator role. Let's keep this
|
||||
// privilege to users with 'Administer permissions' permission only.
|
||||
unset($roles[variable_get('user_admin_role', 0)]);
|
||||
return $roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*/
|
||||
function role_delegation_form_alter(&$form, $form_state, $form_id) {
|
||||
// Only add role delegation options to:
|
||||
// * Registration tab of account registration form
|
||||
// * Account editing tab of account editing form
|
||||
// These are normally the only tabs present on those forms, but other tabs may be added
|
||||
// by other modules, e.g. profile editing tabs by Profile 2.
|
||||
if (!( ($form_id == 'user_register_form' && $form['#user_category'] == 'register')
|
||||
|| ($form_id == 'user_profile_form' && $form['#user_category'] == 'account' ) )) {
|
||||
return;
|
||||
}
|
||||
if (user_access('administer permissions')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$account = $form['#user'];
|
||||
_role_delegation_add_roles_to_form($form, $account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter() for user_admin_role().
|
||||
*/
|
||||
function role_delegation_form_user_admin_role_alter(&$form, $form_state) {
|
||||
$form['#submit'][] = 'role_delegation_form_user_admin_role_submit';
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit function for the user_admin_role form:
|
||||
* When a role is renamed, renames the "assign role" permission for that role.
|
||||
* We can't use hook_user_role_update() for this, because it doesn't have
|
||||
* access to the old role name.
|
||||
*/
|
||||
function role_delegation_form_user_admin_role_submit($form, $form_state) {
|
||||
$op = $form_state['values']['op'];
|
||||
if ($op != t('Save role')) {
|
||||
return;
|
||||
}
|
||||
$oldrole = $form_state['build_info']['args'][0]->name;
|
||||
$newrole = $form_state['values']['name'];
|
||||
if ($oldrole == $newrole) {
|
||||
return;
|
||||
}
|
||||
db_update('role_permission')
|
||||
->condition('permission', "assign $oldrole role")
|
||||
->fields(array('permission' => "assign $newrole role"))
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_role_delete().
|
||||
* When a role is deleted, deletes the "assign role" permission for that role.
|
||||
*/
|
||||
function role_delegation_user_role_delete($role) {
|
||||
db_delete('role_permission')
|
||||
->condition('permission', "assign {$role->name} role")
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_presave().
|
||||
*/
|
||||
function role_delegation_user_presave(&$edit, $account, $category) {
|
||||
if (isset($edit['roles_change'])) {
|
||||
$edit['roles'] = array_filter($edit['roles_change'] + $edit['roles']);
|
||||
unset($edit['roles_change']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_operations().
|
||||
*/
|
||||
function role_delegation_user_operations($form = array(), $form_state = array()) {
|
||||
// Only provide role add/remove operations when user can't assign permissions
|
||||
// without Role Delegation.
|
||||
if (user_access('administer permissions')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Provide add/remove operations for delegated roles.
|
||||
$add_roles = array();
|
||||
$remove_roles = array();
|
||||
foreach (_role_delegation_roles() as $rid => $role) {
|
||||
if (user_access('assign all roles') || user_access("assign $role role")) {
|
||||
$add_roles['role_delegation_add_role-' . $rid]['label'] = t('Add role: !role', array('!role' => $role));
|
||||
$remove_roles['role_delegation_remove_role-' . $rid]['label'] = t('Remove role: !role', array('!role' => $role));
|
||||
}
|
||||
}
|
||||
$operations = $add_roles + $remove_roles;
|
||||
|
||||
// If the form has been posted, insert the proper data for role editing.
|
||||
if (!empty($form_state['submitted'])) {
|
||||
$operation_rid = explode('-', $form_state['values']['operation']);
|
||||
$operation = $operation_rid[0];
|
||||
if ($operation == 'role_delegation_add_role' || $operation == 'role_delegation_remove_role') {
|
||||
if (array_key_exists($form_state['values']['operation'], $operations)) {
|
||||
$rid = $operation_rid[1];
|
||||
$operations[$form_state['values']['operation']] += array(
|
||||
// use the standard add_role and remove_role operations:
|
||||
'callback' => 'user_multiple_role_edit',
|
||||
'callback arguments' => array(str_replace('role_delegation_', '', $operation), $rid),
|
||||
);
|
||||
}
|
||||
else {
|
||||
watchdog('security', 'Detected malicious attempt to alter protected user fields.', array(), WATCHDOG_WARNING);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $operations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter() for user_admin_account().
|
||||
*
|
||||
* In the user bulk update form, separates out the role delegation operations
|
||||
* and groups and relabels them under 'Add a role' and 'Remove a role' optgroups.
|
||||
*/
|
||||
function role_delegation_form_user_admin_account_alter(&$form, $form_state, $form_id) {
|
||||
$options = $form['options']['operation']['#options'];
|
||||
$roles = _role_delegation_roles();
|
||||
$add_roles = array();
|
||||
$remove_roles = array();
|
||||
foreach ($options as $option => $label) {
|
||||
$operation_rid = explode('-', $option);
|
||||
$operation = $operation_rid[0];
|
||||
if ($operation == 'role_delegation_add_role') {
|
||||
$rid = $operation_rid[1];
|
||||
$add_roles[$option] = $roles[$rid];
|
||||
unset($options[$option]);
|
||||
}
|
||||
elseif ($operation == 'role_delegation_remove_role') {
|
||||
$rid = $operation_rid[1];
|
||||
$remove_roles[$option] = $roles[$rid];
|
||||
unset($options[$option]);
|
||||
}
|
||||
}
|
||||
if (count($add_roles)) {
|
||||
$form['options']['operation']['#options'] = $options + array(
|
||||
t('Add a role to the selected users') => $add_roles,
|
||||
t('Remove a role from the selected users') => $remove_roles,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_action_info().
|
||||
*/
|
||||
function role_delegation_action_info() {
|
||||
return array(
|
||||
'role_delegation_delegate_roles_action' => array(
|
||||
'type' => 'user',
|
||||
'label' => t('Delegate roles'),
|
||||
'configurable' => TRUE,
|
||||
'triggers' => array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function role_delegation_delegate_roles_action_form($context) {
|
||||
$form['#tree'] = TRUE;
|
||||
$form['#theme'] = 'role_delegation_delegate_roles_action_form';
|
||||
foreach (_role_delegation_roles() as $rid => $role_name) {
|
||||
$form['role_change'][$rid] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => check_plain($role_name),
|
||||
'#default_value' => isset($context['roles_change'][$rid]) ? $context['roles_change'][$rid] : -1,
|
||||
'#options' => array(
|
||||
-1 => t('Do not change'),
|
||||
1 => t('Add this role'),
|
||||
0 => t('Remove this role'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
function theme_role_delegation_delegate_roles_action_form($variables) {
|
||||
$form = $variables['form'];
|
||||
|
||||
$rows = array();
|
||||
$header = array(
|
||||
t('Role'),
|
||||
t('Operation'),
|
||||
);
|
||||
foreach (element_children($form['role_change']) as $key) {
|
||||
$role = $form['role_change'][$key]['#title'];
|
||||
unset($form['role_change'][$key]['#title']);
|
||||
$operation = drupal_render($form['role_change'][$key]);
|
||||
$row = array(
|
||||
array('data' => $role),
|
||||
array('data' => $operation),
|
||||
);
|
||||
$rows[] = $row;
|
||||
}
|
||||
$output = drupal_render($form['actions_label']);
|
||||
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'role-delegation-table')));
|
||||
$output .= drupal_render_children($form);
|
||||
return $output;
|
||||
}
|
||||
|
||||
function role_delegation_delegate_roles_action_submit($form, $form_state) {
|
||||
$roles_change = array();
|
||||
foreach ($form_state['values']['role_change'] as $rid => $value) {
|
||||
if ($value > -1) {
|
||||
$roles_change[$rid] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return array('roles_change' => $roles_change);
|
||||
}
|
||||
|
||||
function role_delegation_delegate_roles_action(&$user, $context) {
|
||||
$roles_current = $user->roles;
|
||||
$roles_change = $context['roles_change'];
|
||||
role_delegation_save(array($user->uid), $roles_change);
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Role Delegation module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for Role Delegation tests.
|
||||
*/
|
||||
class RoleDelegationTestCase extends DrupalWebTestCase {
|
||||
|
||||
protected $rid_high, $rid_low, $user_high, $user_low;
|
||||
|
||||
/**
|
||||
* Assign or remove one role to/from one user.
|
||||
*
|
||||
* The logged in user must have the "administer users"
|
||||
* permission in order for this function to succeed.
|
||||
*
|
||||
* @param $rid
|
||||
* The role id of the role to assign or remove.
|
||||
* @param $user
|
||||
* The user object of the user to assign/remove the role to.
|
||||
* @param $assign
|
||||
* TRUE (the default) to assign the role, or
|
||||
* FALSE to remove it.
|
||||
*
|
||||
* @return
|
||||
* TRUE or FALSE depending on whether the role was
|
||||
* successfully assigned or removed.
|
||||
*/
|
||||
protected function assignRoleToUser($rid, $user, $assign = TRUE) {
|
||||
$this->drupalGet("user/{$user->uid}/edit");
|
||||
if (count($this->xpath("//input[@name='roles[$rid]']"))) {
|
||||
$name = "roles[$rid]";
|
||||
}
|
||||
elseif (count($this->xpath("//input[@name='roles_change[$rid]']"))) {
|
||||
$name = "roles_change[$rid]";
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
$this->drupalPost(NULL, array($name => $assign), t('Save'));
|
||||
|
||||
$elements = $this->xpath("//input[@name='$name']");
|
||||
return isset($elements[0]) && ($assign XOR empty($elements[0]['checked']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign or remove one permission to/from one role, and assert
|
||||
* that the result succeeded.
|
||||
*
|
||||
* @param $permission
|
||||
* The name of the permission to assign or remove.
|
||||
* @param $rid
|
||||
* The role id of the role to assign/remove the permission to/from.
|
||||
* @param $assign
|
||||
* TRUE (the default) to assign the permission, or
|
||||
* FALSE to remove it.
|
||||
*
|
||||
* @return
|
||||
* TRUE or FALSE depending on whether the permission was
|
||||
* successfully assigned or removed.
|
||||
*/
|
||||
protected function assignPermissionToRole($permission, $rid, $assign = TRUE) {
|
||||
$name = "{$rid}[{$permission}]";
|
||||
$this->drupalPost("admin/people/permissions/$rid", array($name => $assign), t('Save permissions'));
|
||||
$elements = $this->xpath("//input[@name='$name']");
|
||||
$this->assertTrue(
|
||||
isset($elements[0]) && ($assign XOR empty($elements[0]['checked'])),
|
||||
($assign ? 'Assign' : 'Remove') . ' permission "' . $permission . '" ' . ($assign ? 'to' : 'from') . " role $rid."
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
|
||||
// Enable modules
|
||||
parent::setUp('role_delegation');
|
||||
|
||||
// Create roles
|
||||
$this->rid_high = $this->drupalCreateRole(array(), 'high');
|
||||
$this->rid_low = $this->drupalCreateRole(array(), 'low' );
|
||||
|
||||
// Create users
|
||||
$this->user_high = $this->drupalCreateUser(array('administer users'));
|
||||
$this->user_low = $this->drupalCreateUser(array('administer users'));
|
||||
|
||||
// Create privileged user and log in
|
||||
$this->drupalLogin($this->drupalCreateUser(array('administer users', 'administer permissions')));
|
||||
|
||||
// Assign permissions to roles
|
||||
$this->assignPermissionToRole('assign low role', $this->rid_high); // 'high' can assign 'low'
|
||||
|
||||
// Assign roles to users
|
||||
$this->assertTrue(
|
||||
$this->assignRoleToUser($this->rid_high, $this->user_high),
|
||||
'Assign high role to high user'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Functional tests for permissions.
|
||||
*/
|
||||
class RoleDelegationPermissionsTestCase extends RoleDelegationTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Permissions'),
|
||||
'description' => t('Check that role assignment permissions are enforced.'),
|
||||
'group' => t('Role Delegation'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that high role can assign low role.
|
||||
*/
|
||||
public function testHighLow() {
|
||||
$this->drupalLogin($this->user_high);
|
||||
$this->assertTrue(
|
||||
$this->assignRoleToUser($this->rid_low, $this->user_low), // could be any user
|
||||
t('!role1 role can assign !role2 role.', array('!role1' => 'High', '!role2' => 'low')),
|
||||
t('Role Delegation')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that high role can't assign high role.
|
||||
*/
|
||||
public function testHighHigh() {
|
||||
$this->drupalLogin($this->user_high);
|
||||
// Just check that no option is presented to the user.
|
||||
$this->assertFalse(
|
||||
$this->assignRoleToUser($this->rid_high, $this->user_high), // could be any user
|
||||
t("!role1 role can't assign !role2 role.", array('!role1' => 'High', '!role2' => 'high')),
|
||||
t('Role Delegation')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that roles can't be assigned by forgery.
|
||||
*/
|
||||
public function testRoleForgery() {
|
||||
$this->drupalLogin($this->user_high);
|
||||
|
||||
// Have the nefarious high user forge an option to assign the high role...
|
||||
$this->drupalGet("user/{$this->user_low->uid}/edit");
|
||||
$name = "roles_change[{$this->rid_low}]";
|
||||
$input = $this->xpath("//input[@name='$name']");
|
||||
$dome = dom_import_simplexml($input[0]);
|
||||
$dome->setAttribute('value', $this->rid_high);
|
||||
|
||||
// ... then submit the form, and check that he didn't get the role.
|
||||
$this->drupalPost(NULL, array($name => TRUE), t('Save'));
|
||||
$this->assertRaw(
|
||||
t('An illegal choice has been detected. Please contact the site administrator.'),
|
||||
t('Role assignment forgery is blocked.') . ' (#1)',
|
||||
t('Role Delegation')
|
||||
);
|
||||
$this->assertFieldByName(
|
||||
$name,
|
||||
$this->rid_low,
|
||||
t('Role assignment forgery is blocked.') . ' (#2)',
|
||||
t('Role Delegation')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Functional tests for operations.
|
||||
*/
|
||||
class RoleDelegationOperationsTestCase extends RoleDelegationTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Operations'),
|
||||
'description' => t('Check that role assignment bulk operations are available and work as intended.'),
|
||||
'group' => t('Role Delegation'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the right combination of Add and Remove role
|
||||
* operations is present in the user bulk update form.
|
||||
*/
|
||||
public function testOperationsExist() {
|
||||
|
||||
$this->drupalLogin($this->user_high);
|
||||
$this->drupalGet('admin/people');
|
||||
|
||||
$this->assertFieldByXPath(
|
||||
'//select[@name="operation"]//option',
|
||||
"role_delegation_add_role-{$this->rid_low}",
|
||||
t("!user user can use Add !role role operation.", array('!user' => 'High', '!role' => 'low')),
|
||||
t('Role Delegation')
|
||||
);
|
||||
$this->assertFieldByXPath(
|
||||
'//select[@name="operation"]//option',
|
||||
"role_delegation_remove_role-{$this->rid_low}",
|
||||
t("!user user can use Remove !role role operation.", array('!user' => 'High', '!role' => 'low')),
|
||||
t('Role Delegation')
|
||||
);
|
||||
$this->assertNoFieldByXPath(
|
||||
'//select[@name="operation"]//option',
|
||||
"role_delegation_add_role-{$this->rid_high}",
|
||||
t("!user user can't use Add !role role operation.", array('!user' => 'High', '!role' => 'high')),
|
||||
t('Role Delegation')
|
||||
);
|
||||
$this->assertNoFieldByXPath(
|
||||
'//select[@name="operation"]//option',
|
||||
"role_delegation_remove_role-{$this->rid_high}",
|
||||
t("!user user can't use Remove !role role operation.", array('!user' => 'High', '!role' => 'high')),
|
||||
t('Role Delegation')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that Add and Remove role operations work as intended.
|
||||
*/
|
||||
public function testOperationsWork() {
|
||||
|
||||
$uids_to_test = array($this->user_high->uid, $this->user_low->uid);
|
||||
$edit = array();
|
||||
foreach ($uids_to_test as $uid) {
|
||||
$edit["accounts[$uid]"] = TRUE;
|
||||
}
|
||||
|
||||
$this->drupalLogin($this->user_high);
|
||||
$this->drupalGet('admin/people');
|
||||
|
||||
// Add low role
|
||||
$edit['operation'] = "role_delegation_add_role-{$this->rid_low}";
|
||||
$this->drupalPost(NULL, $edit, t('Update'));
|
||||
foreach ($uids_to_test as $uid) {
|
||||
$this->assertFieldByXPath(
|
||||
"//tbody/tr[$uid]/td[4]//li",
|
||||
'low',
|
||||
t('!user user assigned !role role to user !uid.', array('!user' => 'High', '!role' => 'low', '!uid' => $uid)),
|
||||
t('Role Delegation')
|
||||
);
|
||||
}
|
||||
|
||||
// Remove low role
|
||||
$edit['operation'] = "role_delegation_remove_role-{$this->rid_low}";
|
||||
$this->drupalPost(NULL, $edit, t('Update'));
|
||||
foreach ($uids_to_test as $uid) {
|
||||
$this->assertNoFieldByXPath(
|
||||
"//tbody/tr[$uid]/td[4]//li",
|
||||
'low',
|
||||
t('!user user removed !role role from user !uid.', array('!user' => 'High', '!role' => 'low', '!uid' => $uid)),
|
||||
t('Role Delegation')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that operations can't be forged.
|
||||
*/
|
||||
public function testOperationsForgery() {
|
||||
$this->drupalLogin($this->user_high);
|
||||
$this->drupalGet('admin/people');
|
||||
|
||||
// Forge an operation to add the high role...
|
||||
$option = $this->xpath("//select[@name='operation']//option[@value='role_delegation_add_role-{$this->rid_low}']");
|
||||
if (count($option)==0) {
|
||||
return;
|
||||
}
|
||||
$dome = dom_import_simplexml($option[0]);
|
||||
$dome->setAttribute('value', "role_delegation_add_role-{$this->rid_high}");
|
||||
|
||||
// ... then submit the form, and check that it wasn't granted.
|
||||
$edit = array(
|
||||
"accounts[{$this->user_low->uid}]" => TRUE,
|
||||
"operation" => "role_delegation_add_role-{$this->rid_high}",
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Update'));
|
||||
$this->assertRaw(
|
||||
t('An illegal choice has been detected. Please contact the site administrator.'),
|
||||
t('Role assignment forgery is blocked.') . ' (#1)',
|
||||
t('Role Delegation')
|
||||
);
|
||||
$this->assertNoFieldByXPath(
|
||||
"//tbody/tr[{$this->user_high->uid}]/td[4]//li",
|
||||
'high',
|
||||
t('Role assignment forgery is blocked.') . ' (#2)',
|
||||
t('Role Delegation')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Functional tests for editing roles.
|
||||
*/
|
||||
class RoleDelegationRoleEditingTestCase extends RoleDelegationTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Role editing'),
|
||||
'description' => t('Check that role assignment permissions are updated correctly when roles are renamed or deleted.'),
|
||||
'group' => t('Role Delegation'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename a role, and check that users that had permission to assign
|
||||
* the old role now have permission to assign the new one.
|
||||
*/
|
||||
public function testRenameRole() {
|
||||
$this->drupalPost("admin/people/permissions/roles/edit/{$this->rid_low}", array('name' => 'new low'), t('Save role'));
|
||||
$this->drupalGet('admin/people/permissions');
|
||||
$this->assertFieldChecked(
|
||||
"edit-{$this->rid_high}-assign-new-low-role",
|
||||
t('Permissions are updated when role is renamed.'),
|
||||
t('Role Delegation')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a role, then create a new one with the same name.
|
||||
* Check that no users have permission to assign the new role.
|
||||
*/
|
||||
public function testDeleteRole() {
|
||||
$this->drupalPost("admin/people/permissions/roles/delete/{$this->rid_low}", NULL, t('Delete'));
|
||||
$this->drupalPost('admin/people/permissions/roles', array('name' => 'low'), t('Add role'));
|
||||
$this->drupalGet('admin/people/permissions');
|
||||
$this->assertNoFieldChecked(
|
||||
"edit-{$this->rid_high}-assign-low-role",
|
||||
t('Permissions are updated when role is deleted.'),
|
||||
t('Role Delegation')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -0,0 +1,37 @@
|
||||
-- Summary --
|
||||
The "User Details" module comes with two blocks, "User Detils: logged-in user" and "User Details: authored user".
|
||||
|
||||
-- REQUIREMENTS --
|
||||
* Basic Drupal install
|
||||
* Optional options:
|
||||
* - User points (to list the user points on either block).
|
||||
* - Panels (to list a link on the logged-in user block).
|
||||
* - Views (to list a link on the logged-in user block).
|
||||
|
||||
-- INSTALLATION --
|
||||
* Install as usual, see http://drupal.org/node/70151 for further information.
|
||||
* Enable the module in Administration » Modules.
|
||||
* Configure the module options at Administration » Configuration » User interface » User Details. (all options are turned off by default)
|
||||
|
||||
-- Updating from 7.x-2.2 -> 7.x-2.3 --
|
||||
* Upload the new files to your web server.
|
||||
* Un-install "User Details" completely (un-check the box next to "User Details". Click the un-install tab and un-install it from your database.)
|
||||
* Install "User Details" as you would normally.
|
||||
|
||||
-- CONFIGURATION --
|
||||
* Configure the module options at Administration » Configuration » User interface » User Details. (all options are turned off by default)
|
||||
|
||||
-- NOTES --
|
||||
This module was created out of a need for the end-user having to wander around
|
||||
looking for those important links. The idea came from D6 from php code in a
|
||||
block.
|
||||
|
||||
-- CONTACT --
|
||||
Current maintainers:
|
||||
* Draven Caine (http://drupal.org/user/226086)
|
||||
|
||||
This project has been sponsored by:
|
||||
* Talisman Design
|
||||
Specialized in Graphic design, and Drupal website design. All
|
||||
services are from the ground up.
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file
|
||||
* This file handles all the styling needed for the "User Details" module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Logged-in user block .css styling.
|
||||
*/
|
||||
#user-details #loggedin .name, #user-details #loggedin .user-picture {
|
||||
text-align: center;
|
||||
}
|
||||
#user-details #loggedin .joined .title, #user-details #loggedin .postcount .title, #user-details #loggedin .rank .title {
|
||||
float: left;
|
||||
margin-right: 3px;
|
||||
}
|
||||
#user-details #loggedin .userjoined .result, #user-details #loggedin .postcount .result {
|
||||
font-style: italic;
|
||||
}
|
||||
#user-details #loggedin .quick-links .title, #user-details #loggedin .content .title {
|
||||
text-decoration: underline;
|
||||
text-align: center;
|
||||
}
|
||||
/**
|
||||
* Authored by user block .css styling.
|
||||
*/
|
||||
#user-details #authored .name, #user-details #authored .user-picture {
|
||||
text-align: center;
|
||||
}
|
||||
#user-details #authored .joined .title, #user-details #authored .postcount .title, #user-details #authored .rank .title {
|
||||
float: left;
|
||||
margin-right: 3px;
|
||||
}
|
||||
#user-details #authored .userjoined .result, #user-details #authored .postcount .result {
|
||||
font-style: italic;
|
||||
}
|
||||
#user-details #authored .quick-links .title, #user-details #authored .content .title {
|
||||
text-decoration: underline;
|
||||
text-align: center;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Admin page
|
||||
*/
|
||||
#user-details-admin-settings .form-type-checkbox, #user-details-admin-settings .form-type-select {
|
||||
float: left;
|
||||
width: 25%;
|
||||
border-right: 2px solid;
|
||||
margin-right: 10px;
|
||||
}
|
||||
#user-details-admin-settings #edit-loggedin-stats .form-type-checkbox, #user-details-admin-settings .form-item-user-details-loggedin-stats-hr-display, #user-details-admin-settings .form-item-user-details-loggedin-links-hr-display, #user-details-admin-settings #edit-authored-stats .form-type-checkbox, #user-details-admin-settings .form-item-user-details-authored-stats-hr-display, #user-details-admin-settings .form-item-user-details-authored-links-hr-display {
|
||||
float: none;
|
||||
width: 100%;
|
||||
border: 0 none;
|
||||
margin: 0;
|
||||
}
|
||||
#user-details-admin-settings .form-item-user-details-loggedin-stats-hr-display, #user-details-admin-settings .form-item-user-details-loggedin-links-hr-display, #user-details-admin-settings .form-item-user-details-authored-stats-hr-display, #user-details-admin-settings .form-item-user-details-authored-links-hr-display {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
#user-details-admin-settings .form-type-textfield {
|
||||
width: 70%;
|
||||
margin-left: 27%;
|
||||
}
|
||||
#user-details-admin-settings label {
|
||||
font-weight: bold;
|
||||
}
|
||||
#user-details-admin-settings .description {
|
||||
font-style: italic;
|
||||
}
|
||||
#user-details-admin-settings #edit-custom-link-one .form-type-textfield, #user-details-admin-settings #edit-custom-link-two .form-type-textfield, #user-details-admin-settings #edit-custom-link-three .form-type-textfield, #user-details-admin-settings #edit-custom-link-four .form-type-textfield, #user-details-admin-settings #edit-custom-link-five .form-type-textfield {
|
||||
padding-bottom: 10px;
|
||||
margin-bottom: 10px;
|
||||
border-bottom: 2px solid;
|
||||
}
|
||||
#user-details-admin-settings #edit-custom-link-one .form-item-user-details-loggedin-customlinkone-imgtitle, #user-details-admin-settings #edit-custom-link-two .form-item-user-details-loggedin-customlinkone-imgtitle, #user-details-admin-settings #edit-custom-link-three .form-item-user-details-loggedin-customlinkone-imgtitle, #user-details-admin-settings #edit-custom-link-four .form-item-user-details-loggedin-customlinkone-imgtitle, #user-details-admin-settings #edit-custom-link-five .form-item-user-details-loggedin-customlinkone-imgtitle {
|
||||
padding-bottom: 0;
|
||||
margin-bottom: 0;
|
||||
border-bottom: 0 none;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file
|
||||
* This file handles all the styling needed for the "User Details: logged-in user" block.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Block Styling
|
||||
*/
|
||||
#user-details #authored .avatar {
|
||||
text-align: center;
|
||||
}
|
||||
#user-details #authored .title {
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
font-weight: bold;
|
||||
}
|
||||
#user_details #authored .result {
|
||||
font-style: italic;
|
||||
}
|
||||
#user-details #authored .user-quick-links div {
|
||||
float: left;
|
||||
padding-right: 5px;
|
||||
}
|
||||
#user-details #authored .user-quick-links div.title {
|
||||
float: none;
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
text-align: center;
|
||||
text-decoration: underline;
|
||||
}
|
||||
#user-details #authored .content {
|
||||
clear: both;
|
||||
}
|
||||
#user-details #authored .content .title {
|
||||
float: none;
|
||||
text-align: center;
|
||||
text-decoration: underline;
|
||||
}
|
||||
#user-details #authored .content ul, #user-details #authored .content ol {
|
||||
list-style: disc inside none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#user-details #authored .block-end {
|
||||
clear: both;
|
||||
float: none;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file
|
||||
* This file handles all the styling needed for the "User Details: logged-in user" block.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Block Styling
|
||||
*/
|
||||
#user-details #loggedin .avatar {
|
||||
text-align: center;
|
||||
}
|
||||
#user-details #loggedin .title {
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
font-weight: bold;
|
||||
}
|
||||
#user-details #loggedin .result {
|
||||
font-style: italic;
|
||||
}
|
||||
#user-details #loggedin .user-quick-links div {
|
||||
float: left;
|
||||
padding-right: 5px;
|
||||
}
|
||||
#user-details #loggedin .user-quick-links div.title, #user-details #loggedin .admin-quick-links div.title {
|
||||
float: none;
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
text-align: center;
|
||||
text-decoration: underline;
|
||||
}
|
||||
#user-details #loggedin .admin-quick-links div {
|
||||
float: left;
|
||||
padding-right: 5px;
|
||||
}
|
||||
#user-details #loggedin .content {
|
||||
clear: both;
|
||||
}
|
||||
#user-details #loggedin .content .title {
|
||||
float: none;
|
||||
text-align: center;
|
||||
text-decoration: underline;
|
||||
}
|
||||
#user-details #loggedin .content ul, #user-details #loggedin .content ol {
|
||||
list-style: disc inside none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#user-details #loggedin .block-end {
|
||||
clear: both;
|
||||
float: none;
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
GLOBAL $user;
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation to present all variables to the theme layer for
|
||||
* the logged-in user block of the user_details module.
|
||||
*
|
||||
* Useable variables: (syntax: <?php print variable; ?>)
|
||||
* - $user_details_authored_name (user name of the logged-in user)
|
||||
* - $user_details_authored_avatar (user avatar of the logged-in user)
|
||||
* - $user_details_authored_joined (logged-in user's account creation date)
|
||||
* - $user_details_authored_postcount (number of posts the logged-in user has created)
|
||||
* - $user_details_authored_points (number of user points the logged-in user has)
|
||||
* - $user_details_authored_rank (logged-in user's user role)
|
||||
* - $user_details_authored_content (logged-in user's 3 most recently updated pieces of content)
|
||||
* - $user_details_authored_profilelink (link to the logged-in users profile)
|
||||
* - $user_details_authored_subscriptionslink (link to the logged-in user's subscription overview tab on thier profile)
|
||||
* - $user_details_authored_createlink (link to the create content page)
|
||||
* - $user_details_authored_logoutlink (link to logout the logged-in user)
|
||||
*/
|
||||
?>
|
||||
<div id="user-details">
|
||||
<div id="authored">
|
||||
<?php if (variable_get('user_details_authored_avatar_display') != 0): ?>
|
||||
<div class="avatar"><?php print $user_details_authored_avatar; ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_authored_joined_display')!= 0): ?>
|
||||
<div class="joined">
|
||||
<div class="title"><?php print $user_details_authored_joined_title; ?>:</div>
|
||||
<div class="result"><?php print $user_details_authored_joined_result; ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_authored_postcount_display') != 0): ?>
|
||||
<div class="posts-count">
|
||||
<div class="title"><?php print $user_details_authored_postcount_title; ?>:</div>
|
||||
<div class="result"><?php print $user_details_authored_postcount_result; ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_authored_points_display') != 0 && module_exists('userpoints')): ?>
|
||||
<div class="points">
|
||||
<div class="title"><?php print $user_details_authored_points_title; ?>:</div>
|
||||
<div class="result"><?php print $user_details_authored_points_result; ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_authored_rank_display') != 0): ?>
|
||||
<div class="rank">
|
||||
<div class="title"><?php print $user_details_authored_rank_title; ?>:</div>
|
||||
<div class="result"><?php print $user_details_authored_rank_result; ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_authored_stats_hr_display') != 0): ?>
|
||||
<?php print $user_details_authored_stats_hr; ?>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_authored_profilelink_display') != 0 || variable_get('user_details_authored_privatemsglink_display') != 0 && module_exists('privatemsg')): ?>
|
||||
<div class="user-quick-links">
|
||||
<div class="title">User Links</div>
|
||||
<?php if (variable_get('user_details_authored_profilelink_display') != 0): ?>
|
||||
<div class="profile-link">
|
||||
<a href="<?php print $user_details_authored_profilelink_url; ?>"><img src="<?php print $user_details_authored_profilelink_imgsrc; ?>" title="<?php print $user_details_authored_profilelink_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_authored_privatemsglink_display') != 0): ?>
|
||||
<div class="privatemsg-link">
|
||||
<a href="<?php print $user_details_authored_privatemsglink_url; ?>"><img src="<?php print $user_details_authored_privatemsglink_imgsrc; ?>" title="<?php print $user_details_authored_privatemsglink_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="block-end"></div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_authored_links_hr_display') != 0): ?>
|
||||
<?php print $user_details_authored_links_hr; ?>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_authored_content_display') != 0 && variable_get('user_details_authored_content_amount') != 0): ?>
|
||||
<div class="content">
|
||||
<div class="title">Author's Content</div>
|
||||
<ul class="result">
|
||||
<?php print $user_details_authored_content; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="block-end"></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
GLOBAL $user;
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation to present all variables to the theme layer for
|
||||
* the logged-in user block of the user_details module.
|
||||
*
|
||||
* Useable variables: (syntax: <?php print variable; ?>)
|
||||
* - $user_details_loggedin_name (user name of the logged-in user)
|
||||
* - $user_details_loggedin_avatar (user avatar of the logged-in user)
|
||||
* - $user_details_loggedin_joined (logged-in user's account creation date)
|
||||
* - $user_details_loggedin_postcount (number of posts the logged-in user has created)
|
||||
* - $user_details_loggedin_points (number of user points the logged-in user has)
|
||||
* - $user_details_loggedin_rank (logged-in user's user role)
|
||||
* - $user_details_loggedin_content (logged-in user's 3 most recently updated pieces of content)
|
||||
* - $user_details_loggedin_profilelink (link to the logged-in users profile)
|
||||
* - $user_details_loggedin_subscriptionslink (link to the logged-in user's subscription overview tab on thier profile)
|
||||
* - $user_details_loggedin_createlink (link to the create content page)
|
||||
* - $user_details_loggedin_logoutlink (link to logout the logged-in user)
|
||||
*/
|
||||
?>
|
||||
<div id="user-details">
|
||||
<div id="loggedin">
|
||||
<?php if (variable_get('user_details_loggedin_avatar_display') != 0): ?>
|
||||
<div class="avatar"><?php print $user_details_loggedin_avatar; ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_joined_display')!= 0): ?>
|
||||
<div class="joined">
|
||||
<div class="title"><?php print $user_details_loggedin_joined_title; ?>:</div>
|
||||
<div class="result"><?php print $user_details_loggedin_joined_result; ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_postcount_display') != 0): ?>
|
||||
<div class="posts-count">
|
||||
<div class="title"><?php print $user_details_loggedin_postcount_title; ?>:</div>
|
||||
<div class="result"><?php print $user_details_loggedin_postcount_result; ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_points_display') != 0 && module_exists('userpoints')): ?>
|
||||
<div class="points">
|
||||
<div class="title"><?php print $user_details_loggedin_points_title; ?>:</div>
|
||||
<div class="result"><?php print $user_details_loggedin_points_result; ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_privatemsg_display') != 0 && module_exists('privatemsg')): ?>
|
||||
<div class="private-message-count">
|
||||
<div class="title"><?php print $user_details_loggedin_privatemsg_count_title; ?>:</div>
|
||||
<div class="result"><?php print $user_details_loggedin_privatemsg_count_result; ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_rank_display') != 0): ?>
|
||||
<div class="rank">
|
||||
<div class="title"><?php print $user_details_loggedin_rank_title; ?>:</div>
|
||||
<div class="result"><?php print $user_details_loggedin_rank_result; ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_stats_hr_display') != 0): ?>
|
||||
<?php print $user_details_loggedin_stats_hr; ?>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_frontlink_display') != 0 || variable_get('user_details_loggedin_profilelink_display') != 0 || variable_get('user_details_loggedin_profileeditlink_display') != 0 || variable_get('user_details_loggedin_privatemsglink_display') != 0 && module_exists('privatemsg') || variable_get('user_details_loggedin_createlink_display') != 0 || variable_get('user_details_loggedin_customlinkone_type') == '2' || variable_get('user_details_loggedin_customlinktwo_type') == '2' || variable_get('user_details_loggedin_customlinkthree_type') == '2' || variable_get('user_details_loggedin_customlinkfour_type') == '2' || variable_get('user_details_loggedin_customlinkfive_type') == '2'): ?>
|
||||
<div class="user-quick-links">
|
||||
<div class="title">User Links</div>
|
||||
<?php if (variable_get('user_details_loggedin_frontlink_display') != 0): ?>
|
||||
<div class="front-link">
|
||||
<a href="<?php print $user_details_loggedin_frontlink_url; ?>"><img src="<?php print $user_details_loggedin_frontlink_imgsrc; ?>" title="<?php print $user_details_loggedin_frontlink_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_profilelink_display') != 0): ?>
|
||||
<div class="profile-link">
|
||||
<a href="<?php print $user_details_loggedin_profilelink_url; ?>"><img src="<?php print $user_details_loggedin_profilelink_imgsrc; ?>" title="<?php print $user_details_loggedin_profilelink_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_profileeditlink_display') != 0): ?>
|
||||
<div class="profileedit-link">
|
||||
<a href="<?php print $user_details_loggedin_profileeditlink_url; ?>"><img src="<?php print $user_details_loggedin_profileeditlink_imgsrc; ?>" title="<?php print $user_details_loggedin_profileeditlink_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_privatemsglink_display') != 0): ?>
|
||||
<div class="privatemsg-link">
|
||||
<a href="<?php print $user_details_loggedin_privatemsglink_url; ?>"><img src="<?php print $user_details_loggedin_privatemsglink_imgsrc; ?>" title="<?php print $user_details_loggedin_privatemsglink_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_createlink_display') != 0): ?>
|
||||
<div class="create-link">
|
||||
<a href="<?php print $user_details_loggedin_createlink_url; ?>"><img src="<?php print $user_details_loggedin_createlink_imgsrc; ?>" title="<?php print $user_details_loggedin_createlink_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_logoutlink_display') != 0): ?>
|
||||
<div class="logout-link">
|
||||
<a href="<?php print $user_details_loggedin_logoutlink_url; ?>"><img src="<?php print $user_details_loggedin_logoutlink_imgsrc; ?>" title="<?php print $user_details_loggedin_logoutlink_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_customlinkone_type') == '2'): ?>
|
||||
<div class="custom-link-one">
|
||||
<a href="<?php print $user_details_loggedin_customlinkone_url; ?>"><img src="<?php print $user_details_loggedin_customlinkone_imgsrc; ?>" title="<?php print $user_details_loggedin_customlinkone_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_customlinktwo_type') == '2'): ?>
|
||||
<div class="custom-link-two">
|
||||
<a href="<?php print $user_details_loggedin_customlinktwo_url; ?>"><img src="<?php print $user_details_loggedin_customlinktwo_imgsrc; ?>" title="<?php print $user_details_loggedin_customlinktwo_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_customlinkthree_type') == '2'): ?>
|
||||
<div class="custom-link-three">
|
||||
<a href="<?php print $user_details_loggedin_customlinkthree_url; ?>"><img src="<?php print $user_details_loggedin_customlinkthree_imgsrc; ?>" title="<?php print $user_details_loggedin_customlinkthree_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_customlinkfour_type') == '2'): ?>
|
||||
<div class="custom-link-four">
|
||||
<a href="<?php print $user_details_loggedin_customlinkfour_url; ?>"><img src="<?php print $user_details_loggedin_customlinkfour_imgsrc; ?>" title="<?php print $user_details_loggedin_customlinkfour_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_customlinkfive_type') == '2'): ?>
|
||||
<div class="custom-link-five">
|
||||
<a href="<?php print $user_details_loggedin_customlinkfive_url; ?>"><img src="<?php print $user_details_loggedin_customlinkfive_imgsrc; ?>" title="<?php print $user_details_loggedin_customlinkfive_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="block-end"></div>
|
||||
<?php endif; ?>
|
||||
<?php if (user_access('administor content')): ?>
|
||||
<?php if (variable_get('user_details_loggedin_adminlink_display') !=0 || variable_get('user_details_loggedin_panelslink_display') != 0 && module_exists('panels') || variable_get('user_details_loggedin_viewslink_display') && module_exists('views') || variable_get('user_details_loggedin customlinkone_type') == '3' || variable_get('user_details_loggedin customlinktwo_type') == '3' || variable_get('user_details_loggedin customlinkthree_type') == '3' || variable_get('user_details_loggedin customlinkfour_type') == '3' || variable_get('user_details_loggedin customlinkfive_type') == '3'): ?>
|
||||
<div class="admin-quick-links">
|
||||
<div class="title">Admin Links</div>
|
||||
<?php if (variable_get('user_details_loggedin_adminlink_display') != 0): ?>
|
||||
<div class="admin-link">
|
||||
<a href="<?php print $user_details_loggedin_adminlink_url; ?>"><img src="<?php print $user_details_loggedin_adminlink_imgsrc; ?>" title="<?php print $user_details_loggedin_adminlink_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_panelslink_display') != 0 && module_exists('panels')): ?>
|
||||
<div class="panels-link">
|
||||
<a href="<?php print $user_details_loggedin_panelslink_url; ?>"><img src="<?php print $user_details_loggedin_panelslink_imgsrc; ?>" title="<?php print $user_details_loggedin_panelslink_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_viewslink_display') != 0 && module_exists('views')): ?>
|
||||
<div class="views-link">
|
||||
<a href="<?php print $user_details_loggedin_viewslink_url; ?>"><img src="<?php print $user_details_loggedin_viewslink_imgsrc; ?>" title="<?php print $user_details_loggedin_viewslink_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_performancelink_display') != 0): ?>
|
||||
<div class="performance-link">
|
||||
<a href="<?php print $user_details_loggedin_performancelink_url; ?>"><img src="<?php print $user_details_loggedin_performancelink_imgsrc; ?>" title="<?php print $user_details_loggedin_performancelink_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_customlinkone_type') == '3'): ?>
|
||||
<div class="custom-link-one">
|
||||
<a href="<?php print $user_details_loggedin_customlinkone_url; ?>"><img src="<?php print $user_details_loggedin_customlinkone_imgsrc; ?>" title="<?php print $user_details_loggedin_customlinkone_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_customlinktwo_type') == '3'): ?>
|
||||
<div class="custom-link-two">
|
||||
<a href="<?php print $user_details_loggedin_customlinktwo_url; ?>"><img src="<?php print $user_details_loggedin_customlinktwo_imgsrc; ?>" title="<?php print $user_details_loggedin_customlinktwo_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_customlinkthree_type') == '3'): ?>
|
||||
<div class="custom-link-three">
|
||||
<a href="<?php print $user_details_loggedin_customlinkthree_url; ?>"><img src="<?php print $user_details_loggedin_customlinkthree_imgsrc; ?>" title="<?php print $user_details_loggedin_customlinkthree_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_customlinkfour_type') == '3'): ?>
|
||||
<div class="custom-link-four">
|
||||
<a href="<?php print $user_details_loggedin_customlinkfour_url; ?>"><img src="<?php print $user_details_loggedin_customlinkfour_imgsrc; ?>" title="<?php print $user_details_loggedin_customlinkfour_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_customlinkfive_type') == '3'): ?>
|
||||
<div class="custom-link-one">
|
||||
<a href="<?php print $user_details_loggedin_customlinkfive_url; ?>"><img src="<?php print $user_details_loggedin_customlinkfive_imgsrc; ?>" title="<?php print $user_details_loggedin_customlinkfive_imgtitle; ?>" width="20px" height="20px" /></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="block-end"></div>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_links_hr_display') != 0): ?>
|
||||
<?php print $user_details_loggedin_links_hr; ?>
|
||||
<?php endif; ?>
|
||||
<?php if (variable_get('user_details_loggedin_content_display') != 0 && variable_get('user_details_loggedin_content_amount') != 0): ?>
|
||||
<div class="content">
|
||||
<div class="title">My Content</div>
|
||||
<ul class="result">
|
||||
<?php print $user_details_loggedin_content; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="block-end"></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
name = User Details
|
||||
description = Uses the user variables to create a block of stats and links.
|
||||
|
||||
core = 7.x
|
||||
stylesheets[all][] = user_details.css
|
||||
package = "User interface"
|
||||
configure = admin/config/user-interface/user-details
|
||||
help = admin/help#user_details
|
||||
; Information added by drupal.org packaging script on 2012-03-14
|
||||
version = "7.x-2.5"
|
||||
core = "7.x"
|
||||
project = "user_details"
|
||||
datestamp = "1331742945"
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installation file for User Details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function user_details_uninstall() {
|
||||
variable_del('user_details_loggedin_avatar_display');
|
||||
variable_del('user_details_loggedin_points_display');
|
||||
variable_del('user_details_loggedin_joined_display');
|
||||
variable_del('user_details_loggedin_postcount_display');
|
||||
variable_del('user_details_loggedin_rank_display');
|
||||
variable_del('user_details_loggedin_stats_hr_display');
|
||||
variable_del('user_details_loggedin_privatemsg_display');
|
||||
variable_del('user_details_loggedin_frontlink_display');
|
||||
variable_del('user_details_loggedin_frontlink_imgsrc');
|
||||
variable_del('user_details_loggedin_profilelink_display');
|
||||
variable_del('user_details_loggedin_profilelink_imgsrc');
|
||||
variable_del('user_details_loggedin_profileeditlink_display');
|
||||
variable_del('user_details_loggedin_profileeditlink_imgsrc');
|
||||
variable_del('user_details_loggedin_privatemsglink_display');
|
||||
variable_del('user_details_loggedin_privatemsglink_imgsrc');
|
||||
variable_del('user_details_loggedin_createlink_display');
|
||||
variable_del('user_details_loggedin_createlink_imgsrc');
|
||||
variable_del('user_details_loggedin_adminlink_display');
|
||||
variable_del('user_details_loggedin_adminlink_imgsrc');
|
||||
variable_del('user_details_loggedin_panelslink_display');
|
||||
variable_del('user_details_loggedin_panelslink_imgsrc');
|
||||
variable_del('user_details_loggedin_viewslink_display');
|
||||
variable_del('user_details_loggedin_viewslink_imgsrc');
|
||||
variable_del('user_details_loggedin_performancelink_display');
|
||||
variable_del('user_details_loggedin_performancelink_imgsrc');
|
||||
variable_del('user_details_loggedin_logoutlink_display');
|
||||
variable_del('user_details_loggedin_logoutlink_imgsrc');
|
||||
variable_del('user_details_loggedin_customlinkone_type');
|
||||
variable_del('user_details_loggedin_customlinkone_url');
|
||||
variable_del('user_details_loggedin_customlinkone_imgsrc');
|
||||
variable_del('user_details_loggedin_customlinkone_imgtitle');
|
||||
variable_del('user_details_loggedin_customlinktwo_type');
|
||||
variable_del('user_details_loggedin_customlinktwo_url');
|
||||
variable_del('user_details_loggedin_customlinktwo_imgsrc');
|
||||
variable_del('user_details_loggedin_customlinkthree_type');
|
||||
variable_del('user_details_loggedin_customlinkthree_url');
|
||||
variable_del('user_details_loggedin_customlinkthree_imgsrc');
|
||||
variable_del('user_details_loggedin_customlinkthree_imgtitle');
|
||||
variable_del('user_details_loggedin_customlinkfour_type');
|
||||
variable_del('user_details_loggedin_customlinkfour_url');
|
||||
variable_del('user_details_loggedin_customlinkfour_imgsrc');
|
||||
variable_del('user_details_loggedin_customlinkfour_imgtitle');
|
||||
variable_del('user_details_loggedin_customlinkfive_type');
|
||||
variable_del('user_details_loggedin_customlinkfive_url');
|
||||
variable_del('user_details_loggedin_customlinkfive_imgsrc');
|
||||
variable_del('user_details_loggedin_customlinkfive_imgtitle');
|
||||
variable_del('user_details_loggedin_links_hr_display');
|
||||
variable_del('user_details_loggedin_content_display');
|
||||
variable_del('user_details_loggedin_content_amount');
|
||||
variable_del('user_details_authored_avatar_display');
|
||||
variable_del('user_details_authored_points_display');
|
||||
variable_del('user_details_authored_joined_display');
|
||||
variable_del('user_details_authored_postcount_display');
|
||||
variable_del('user_details_authored_rank_display');
|
||||
variable_del('user_details_authored_stats_hr_display');
|
||||
variable_del('user_details_authored_profilelink_display');
|
||||
variable_del('user_details_authored_profilelink_imgsrc');
|
||||
variable_del('user_details_authored_privatemsglink_display');
|
||||
variable_del('user_details_authored_privatemsglink_imgsrc');
|
||||
variable_del('user_details_authored_links_hr_display');
|
||||
variable_del('user_details_authored_content_display');
|
||||
variable_del('user_details_authored_content_amount');
|
||||
/** removing old variables **/
|
||||
variable_del('user_details_loggedin_visibility');
|
||||
variable_del('user_details_loggedin_subscriptionslink');
|
||||
variable_del('user_details_loggedin_profilelink_reset');
|
||||
variable_del('user_details_loggedin_profileeditlink');
|
||||
variable_del('user_details_loggedin_privatemsg_count');
|
||||
variable_del('user_details_loggedin_privatemsglink');
|
||||
variable_del('user_details_loggedin_iconcolor');
|
||||
variable_del('user_details_loggedin_customlinktwo_user');
|
||||
variable_del('user_details_loggedin_customlinktwo_imgtitle');
|
||||
variable_del('user_details_loggedin_customlinktwo');
|
||||
variable_del('user_details_loggedin_customlinkthree');
|
||||
variable_del('user_details_loggedin_customlinkone');
|
||||
variable_del('user_details_loggedin_customlinkfour');
|
||||
variable_del('user_details_loggedin_customlinkfive');
|
||||
variable_del('user_details_loggedin_contentamount');
|
||||
variable_del('user_details_loggedin_adminlink');
|
||||
variable_del('user_details_loggedin_rank');
|
||||
variable_del('user_details_loggedin_profilelink');
|
||||
variable_del('user_details_authored_rank');
|
||||
variable_del('user_details_authored_profilelink');
|
||||
variable_del('user_details_authored_privatemsglink');
|
||||
variable_del('user_details_authored_postcount');
|
||||
variable_del('user_details_authored_points');
|
||||
variable_del('user_details_authored_joined');
|
||||
variable_del('user_details_authored_contentamount');
|
||||
variable_del('user_details_authored_content');
|
||||
variable_del('user_details_authored_avatar');
|
||||
}
|
||||
@@ -0,0 +1,637 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Block functions.
|
||||
*
|
||||
* Contains all the functions to run the "User Details" blocks.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Implements of hook_help().
|
||||
*
|
||||
* Creates a basic help page(accessible from the modules page).
|
||||
*/
|
||||
function user_details_help($path, $arg) {
|
||||
$output = '';
|
||||
switch ($path) {
|
||||
case "admin/help#user_details":
|
||||
require_once drupal_get_path('module', 'user_details') .'/user_details_help.inc';
|
||||
$output = drupal_render(drupal_get_form('user_details_help_form'));
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function user_details_menu() {
|
||||
$items['admin/config/user-interface/user-details'] = array(
|
||||
'title' => 'User Details',
|
||||
'description' => 'Configure user Details.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('user_details_admin_settings'),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
'file' => 'user_details_admin_settings.inc',
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*
|
||||
* Adds the template and variables needed to have the blocks run through a
|
||||
* template file.
|
||||
*/
|
||||
function user_details_theme() {
|
||||
return array(
|
||||
'user_details_loggedin' => array(
|
||||
'template' => 'templates/user-details-loggedin',
|
||||
'variables' => array(
|
||||
'user_details_loggedin_avatar' => NULL,
|
||||
'user_details_loggedin_points_title' => NULL,
|
||||
'user_details_loggedin_points_result' => NULL,
|
||||
'user_details_loggedin_joined_title' => NULL,
|
||||
'user_details_loggedin_joined_result' => NULL,
|
||||
'user_details_loggedin_postcount_title' => NULL,
|
||||
'user_details_loggedin_postcount_result' => NULL,
|
||||
'user_details_loggedin_rank_title' => NULL,
|
||||
'user_details_loggedin_rank_result' => NULL,
|
||||
'user_details_loggedin_privatemsg_title' => NULL,
|
||||
'user_details_loggedin_privatemsg_result' => NULL,
|
||||
'user_details_loggedin_stats_hr' => NULL,
|
||||
'user_details_loggedin_frontlink_url' => NULL,
|
||||
'user_details_loggedin_frontlink_imgsrc' => NULL,
|
||||
'user_details_loggedin_frontlink_imgtitle' => NULL,
|
||||
'user_details_loggedin_profilelink_url' => NULL,
|
||||
'user_details_loggedin_profilelink_imgsrc' => NULL,
|
||||
'user_details_loggedin_profilelink_imgtitle' => NULL,
|
||||
'user_details_loggedin_profileeditlink_url' => NULL,
|
||||
'user_details_loggedin_profileeditlink_imgsrc' => NULL,
|
||||
'user_details_loggedin_profileeditlink_imgtitle' => NULL,
|
||||
'user_details_loggedin_privatemsglink_url' => NULL,
|
||||
'user_details_loggedin_privatemsglink_imgsrc' => NULL,
|
||||
'user_details_loggedin_privatemsglink_imgtitle' => NULL,
|
||||
'user_details_loggedin_createlink_url' => NULL,
|
||||
'user_details_loggedin_createlink_imgsrc' => NULL,
|
||||
'user_details_loggedin_createlink_imgtitle' => NULL,
|
||||
'user_details_loggedin_adminlink_url' => NULL,
|
||||
'user_details_loggedin_adminlink_imgsrc' => NULL,
|
||||
'user_details_loggedin_adminlink_imgtitle' => NULL,
|
||||
'user_details_loggedin_panelslink_url' => NULL,
|
||||
'user_details_loggedin_panelslink_imgsrc' => NULL,
|
||||
'user_details_loggedin_panelslink_imgtitle' => NULL,
|
||||
'user_details_loggedin_viewslink_url' => NULL,
|
||||
'user_details_loggedin_viewslink_imgsrc' => NULL,
|
||||
'user_details_loggedin_viewslink_imgtitle' => NULL,
|
||||
'user_details_loggedin_performancelink_url' => NULL,
|
||||
'user_details_loggedin_performancelink_imgsrc' => NULL,
|
||||
'user_details_loggedin_performancelink_imgtitle' => NULL,
|
||||
'user_details_loggedin_logoutlink_url' => NULL,
|
||||
'user_details_loggedin_logoutlink_imgsrc' => NULL,
|
||||
'user_details_loggedin_logoutlink_imgtitle' => NULL,
|
||||
'user_details_loggedin_customlinkone_type' => NULL,
|
||||
'user_details_loggedin_customlinkone_url' => NULL,
|
||||
'user_details_loggedin_customlinkone_imgsrc' => NULL,
|
||||
'user_details_loggedin_customlinkone_imgtitle' => NULL,
|
||||
'user_details_loggedin_customlinktwo_url' => NULL,
|
||||
'user_details_loggedin_customlinktwo_imgsrc' => NULL,
|
||||
'user_details_loggedin_customlinktwo_imgtitle' => NULL,
|
||||
'user_details_loggedin_customlinkthree_url' => NULL,
|
||||
'user_details_loggedin_customlinkthree_imgsrc' => NULL,
|
||||
'user_details_loggedin_customlinkthree_imgtitle' => NULL,
|
||||
'user_details_loggedin_customlinkfour_url' => NULL,
|
||||
'user_details_loggedin_customlinkfour_imgsrc' => NULL,
|
||||
'user_details_loggedin_customlinkfour_imgtitle' => NULL,
|
||||
'user_details_loggedin_customlinkfive_url' => NULL,
|
||||
'user_details_loggedin_customlinkfive_imgsrc' => NULL,
|
||||
'user_details_loggedin_customlinkfive_imgtitle' => NULL,
|
||||
'user_details_loggedin_links_hr' => NULL,
|
||||
'user_details_loggedin_content' => NULL,
|
||||
),
|
||||
),
|
||||
'user_details_authored' => array(
|
||||
'template' => 'templates/user-details-authored',
|
||||
'variables' => array(
|
||||
'user_details_authored_avatar' => NULL,
|
||||
'user_details_authored_joined_title' => NULL,
|
||||
'user_details_authored_joined_result' => NULL,
|
||||
'user_details_loggedin_postcount_title' => NULL,
|
||||
'user_details_loggedin_postcount_result' => NULL,
|
||||
'user_details_authored_points_title' => NULL,
|
||||
'user_details_authored_points_result' => NULL,
|
||||
'user_details_authored_rank_title' => NULL,
|
||||
'user_details_authored_rank_result' => NULL,
|
||||
'user_details_authored_stats_hr' => NULL,
|
||||
'user_details_authored_profilelink_url' => NULL,
|
||||
'user_details_authored_profilelink_imgsrc' => NULL,
|
||||
'user_details_authored_profilelink_imgtitle' => NULL,
|
||||
'user_details_authored_privatemsglink_url' => NULL,
|
||||
'user_details_authored_privatemsglink_imgsrc' => NULL,
|
||||
'user_details_authored_privatemsglink_imgtitle' => NULL,
|
||||
'user_details_authored_links_hr' => NULL,
|
||||
'user_details_authored_content' => NULL,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Implements hook_block_save().
|
||||
*
|
||||
* Sends all the checkbox(options) variables to the database to be stored.
|
||||
*/
|
||||
function user_details_block_save($delta = '', $edit = array()) {
|
||||
if ($delta == 'loggedin') {
|
||||
variable_set('user_details_loggedin_avatar_display', $edit['user_details_loggedin_avatar_display']);
|
||||
variable_set('user_details_loggedin_points_display', $edit['user_details_loggedin_points_display']);
|
||||
variable_set('user_details_loggedin_joined_display', $edit['user_details_loggedin_joined_display']);
|
||||
variable_set('user_details_loggedin_postcount_display', $edit['user_details_loggedin_postcount_display']);
|
||||
variable_set('user_details_loggedin_rank_display', $edit['user_details_loggedin_rank_display']);
|
||||
variable_set('user_details_loggedin_stats_hr_display', $edit['user_details_loggedin_stats_hr_display']);
|
||||
variable_set('user_details_loggedin_privatemsg_display', $edit['user_details_loggedin_privatemsg_display']);
|
||||
variable_set('user_details_loggedin_frontlink_display', $edit['user_details_loggedin_frontlink_display']);
|
||||
variable_set('user_details_loggedin_frontlink_imgsrc', $edit['user_details_loggedin_frontlink_imgsrc']);
|
||||
variable_set('user_details_loggedin_profilelink_display', $edit['user_details_loggedin_profilelink_display']);
|
||||
variable_set('user_details_loggedin_profilelink_imgsrc', $edit['user_details_loggedin_profilelink_imgsrc']);
|
||||
variable_set('user_details_loggedin_profileeditlink_display', $edit['user_details_loggedin_profileeditlink_display']);
|
||||
variable_set('user_details_loggedin_profileeditlink_imgsrc', $edit['user_details_loggedin_profileeditlink_imgsrc']);
|
||||
variable_set('user_details_loggedin_privatemsglink_display', $edit['user_details_loggedin_privatemsglink_display']);
|
||||
variable_set('user_details_loggedin_privatemsglink_imgsrc', $edit['user_details_loggedin_privatemsglink_imgsrc']);
|
||||
variable_set('user_details_loggedin_createlink_display', $edit['user_details_loggedin_createlink_display']);
|
||||
variable_set('user_details_loggedin_createlink_imgsrc', $edit['user_details_loggedin_createlink_imgsrc']);
|
||||
variable_set('user_details_loggedin_adminlink_display', $edit['user_details_loggedin_adminlink_display']);
|
||||
variable_set('user_details_loggedin_adminlink_imgsrc', $edit['user_details_loggedin_adminlink_imgsrc']);
|
||||
variable_set('user_details_loggedin_panelslink_display', $edit['user_details_loggedin_panelslink_display']);
|
||||
variable_set('user_details_loggedin_panelslink_imgsrc', $edit['user_details_loggedin_panelslink_imgsrc']);
|
||||
variable_set('user_details_loggedin_viewslink_display', $edit['user_details_loggedin_panelslink_display']);
|
||||
variable_set('user_details_loggedin_viewslink_imgsrc', $edit['user_details_loggedin_panelslink_imgsrc']);
|
||||
variable_set('user_details_loggedin_performancelink_display', $edit['user_details_loggedin_performancelink_display']);
|
||||
variable_set('user_details_loggedin_performancelink_imgsrc', $edit['user_details_loggedin_performancelink_imgsrc']);
|
||||
variable_set('user_details_loggedin_logoutlink_display', $edit['user_details_loggedin_logoutlink_display']);
|
||||
variable_set('user_details_loggedin_logoutlink_imgsrc', $edit['user_details_loggedin_logoutlink_imgsrc']);
|
||||
variable_set('user_details_loggedin_customlinkone_type', $edit['user_details_loggedin_customlinkone_type']);
|
||||
variable_set('user_details_loggedin_customlinkone_url', $edit['user_details_loggedin_customlinkone_url']);
|
||||
variable_set('user_details_loggedin_customlinkone_imgsrc', $edit['user_details_loggedin_customlinkone_imgsrc']);
|
||||
variable_set('user_details_loggedin_customlinkone_imgtitle', $edit['user_details_loggedin_customlinkone_imgtitle']);
|
||||
variable_set('user_details_loggedin_customlinktwo_type', $edit['user_details_loggedin_customlinktwo_type']);
|
||||
variable_set('user_details_loggedin_customlinktwo_url', $edit['user_details_loggedin_customlinktwo_url']);
|
||||
variable_set('user_details_loggedin_customlinktwo_imgsrc', $edit['user_details_loggedin_customlinktwo_imgsrc']);
|
||||
variable_set('user_details_loggedin_customlinkthree_type', $edit['user_details_loggedin_customlinkthree_type']);
|
||||
variable_set('user_details_loggedin_customlinkthree_url', $edit['user_details_loggedin_customlinkthree_url']);
|
||||
variable_set('user_details_loggedin_customlinkthree_imgsrc', $edit['user_details_loggedin_customlinkthree_imgsrc']);
|
||||
variable_set('user_details_loggedin_customlinkthree_imgtitle', $edit['user_details_loggedin_customlinkthree_imgtitle']);
|
||||
variable_set('user_details_loggedin_customlinkfour_type', $edit['user_details_loggedin_customlinkfour_type']);
|
||||
variable_set('user_details_loggedin_customlinkfour_url', $edit['user_details_loggedin_customlinkfour_url']);
|
||||
variable_set('user_details_loggedin_customlinkfour_imgsrc', $edit['user_details_loggedin_customlinkfour_imgsrc']);
|
||||
variable_set('user_details_loggedin_customlinkfour_imgtitle', $edit['user_details_loggedin_customlinkfour_imgtitle']);
|
||||
variable_set('user_details_loggedin_customlinkfive_type', $edit['user_details_loggedin_customlinkfive_type']);
|
||||
variable_set('user_details_loggedin_customlinkfive_url', $edit['user_details_loggedin_customlinkfive_url']);
|
||||
variable_set('user_details_loggedin_customlinkfive_imgsrc', $edit['user_details_loggedin_customlinkfive_imgsrc']);
|
||||
variable_set('user_details_loggedin_customlinkfive_imgtitle', $edit['user_details_loggedin_customlinkfive_imgtitle']);
|
||||
variable_set('user_details_loggedin_links_hr_display', $edit['user_details_loggedin_links_hr_display']);
|
||||
variable_set('user_details_loggedin_content_display', $edit['user_details_loggedin_content_display']);
|
||||
variable_set('user_details_loggedin_content_amount', $edit['user_details_loggedin_content_amount']);
|
||||
}
|
||||
if ($delta == 'authored') {
|
||||
variable_set('user_details_authored_avatar_display', $edit['user_details_authored_avatar_display']);
|
||||
variable_set('user_details_authored_points_display', $edit['user_details_authored_points_display']);
|
||||
variable_set('user_details_authored_joined_display', $edit['user_details_authored_joined_display']);
|
||||
variable_set('user_details_authored_postcount_display', $edit['user_details_authored_postcount_display']);
|
||||
variable_set('user_details_authored_rank_display', $edit['user_details_authored_rank_display']);
|
||||
variable_set('user_details_authored_stats_hr_display', $edit['user_details_authored_stats_hr_display']);
|
||||
variable_set('user_details_authored_profilelink_display', $edit['user_details_authored_profilelink_display']);
|
||||
variable_set('user_details_authored_profilelink_imgsrc', $edit['user_details_authored_profilelink_imgsrc']);
|
||||
variable_set('user_details_authored_privatemsglink_display', $edit['user_details_authored_privatemsglink_display']);
|
||||
variable_set('user_details_authored_privatemsglink_imgsrc', $edit['user_details_authored_privatemsglink_imgsrc']);
|
||||
variable_set('user_details_authored_links_hr_display', $edit['user_details_authored_links_hr_display']);
|
||||
variable_set('user_details_authored_content_display', $edit['user_details_authored_content_display']);
|
||||
variable_set('user_details_authored_content_amount', $edit['user_details_authored_content_amount']);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_info().
|
||||
*
|
||||
* Creates the title of the block for the block list page.
|
||||
*/
|
||||
function user_details_block_info() {
|
||||
$blocks['loggedin']['info'] = t('User Details: logged-in user');
|
||||
$blocks['authored']['info'] = t('User Details: authored user');
|
||||
return $blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_view().
|
||||
*
|
||||
* Creates the block title and content.
|
||||
*/
|
||||
function user_details_block_view($delta = '') {
|
||||
global $user;
|
||||
if (arg(0) == 'node' && is_numeric(arg(1))) {
|
||||
$node_load = node_load(arg(1));
|
||||
$uid = $node_load->uid;
|
||||
$user_load = user_load($uid);
|
||||
}
|
||||
if (arg(0) == 'user' && is_numeric(arg(1))) {
|
||||
$user_arg = user_load(arg(1));
|
||||
$uid = $user_arg->uid;
|
||||
$user_load = user_load($uid);
|
||||
}
|
||||
switch ($delta) {
|
||||
case 'loggedin':
|
||||
if ($user->uid != 0) {
|
||||
$block['subject'] = t('%name', array('%name' => $user->name));
|
||||
$block['content'] = user_details_loggedin_block_content();
|
||||
return $block;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
case 'authored':
|
||||
$block['subject'] = t('%name', array('%name' => $user_load->name));
|
||||
$block['content'] = user_details_authored_block_content();
|
||||
return $block;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process variables for user-details-loggedin.tpl.php.
|
||||
*
|
||||
* This function takes the result of the stored variable(options checkbox) and
|
||||
* creates a variable result from it.
|
||||
*/
|
||||
function template_preprocess_user_details_loggedin(&$variables) {
|
||||
global $user;
|
||||
$co = $output = NULL;
|
||||
drupal_add_css(drupal_get_path('module', 'user_details') . '/css/user_details_loggedin.css');
|
||||
|
||||
if (variable_get('user_details_loggedin_avatar_display') !=0) {
|
||||
$variables['user_details_loggedin_avatar'] = theme('user_picture', array('account' => $user));
|
||||
}
|
||||
if (variable_get('user_details_loggedin_joined_display') != 0) {
|
||||
$user_details_loggedin_date = date('c', $user->created);
|
||||
$variables['user_details_loggedin_joined_title'] = t('Joined');
|
||||
$variables['user_details_loggedin_joined_result'] = date('M j, Y', strtotime($user_details_loggedin_date));
|
||||
}
|
||||
if (variable_get('user_details_loggedin_postcount_display') != 0) {
|
||||
$user_details_loggedin_postcount_query = db_select('node', 'n');
|
||||
$user_details_loggedin_postcount_query
|
||||
->condition('n.uid', $user->uid, '=')
|
||||
->fields('n', array('uid'));
|
||||
$variables['user_details_loggedin_postcount_title'] = t('Posts');
|
||||
$variables['user_details_loggedin_postcount_result'] = t('%postcount', array('%postcount' => $user_details_loggedin_postcount_query->countQuery()->execute()->fetchField()));
|
||||
}
|
||||
if (variable_get('user_details_loggedin_points_display') !=0 && module_exists('userpoints')) {
|
||||
$variables['user_details_loggedin_points_title'] = t('!Points', userpoints_translation());
|
||||
$variables['user_details_loggedin_points_result'] = userpoints_get_current_points($user->uid, 'all');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_rank_display') != 0) {
|
||||
$user_details_loggedin_rank_query = db_select('users_roles');
|
||||
$user_details_loggedin_rank_query
|
||||
->condition('uid', $user->uid, '=')
|
||||
->fields('users_roles', array('rid'));
|
||||
$user_details_loggedin_rank_fetchfield = $user_details_loggedin_rank_query->execute()->fetchField();
|
||||
if (($user_details_loggedin_rank_fetchfield) == NULL) {
|
||||
$user_details_loggedin_rank_fetchfield = 2;
|
||||
}
|
||||
$user_details_loggedin_rankname_query = db_select('role', 'r');
|
||||
$user_details_loggedin_rankname_query
|
||||
->condition('rid', $user_details_loggedin_rank_fetchfield, '=')
|
||||
->fields('r', array('name'));
|
||||
$user_details_loggedin_rankname_fetchfield = $user_details_loggedin_rankname_query->execute()->fetchField();
|
||||
$variables['user_details_loggedin_rank_title'] = t('Rank');
|
||||
$variables['user_details_loggedin_rank_result'] = t('%rank', array('%rank' => $user_details_loggedin_rankname_fetchfield));
|
||||
}
|
||||
if (variable_get('user_details_loggedin_privatemsg_display') != 0 && module_exists('privatemsg')) {
|
||||
$count = privatemsg_unread_count();
|
||||
$variables['user_details_loggedin_privatemsg_count_title'] = t('New messages');
|
||||
$variables['user_details_loggedin_privatemsg_count_result'] = t('%rank', array('%rank' => $count));
|
||||
}
|
||||
if (variable_get('user_details_loggedin_avatar_display') !=0 && variable_get('user_details_loggedin_stats_hr_display') != 0 || variable_get('user_details_loggedin_joined_display') != 0 && variable_get('user_details_loggedin_stats_hr_display') != 0 || variable_get('user_details_loggedin_postcount_display') != 0 && variable_get('user_details_loggedin_stats_hr_display') != 0 || variable_get('user_details_loggedin_points_display') !=0 && module_exists('userpoints') && variable_get('user_details_loggedin_stats_hr_display') != 0 || variable_get('user_details_loggedin_rank_display') != 0 && variable_get('user_details_loggedin_stats_hr_display') != 0) {
|
||||
$variables['user_details_loggedin_stats_hr'] = '<hr>';
|
||||
}
|
||||
if (variable_get('user_details_loggedin_frontlink_display') != 0) {
|
||||
$variables['user_details_loggedin_frontlink_url'] = t('/');
|
||||
$variables['user_details_loggedin_frontlink_imgsrc'] = variable_get('user_details_loggedin_frontlink_imgsrc');
|
||||
$variables['user_details_loggedin_frontlink_imgtitle'] = t('Front page');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_profilelink_display') != 0) {
|
||||
$variables['user_details_loggedin_profilelink_url'] = t('/user/' . $user->uid);
|
||||
$variables['user_details_loggedin_profilelink_imgsrc'] = variable_get('user_details_loggedin_profilelink_imgsrc');
|
||||
$variables['user_details_loggedin_profilelink_imgtitle'] = t('My profile');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_profileeditlink_display') != 0) {
|
||||
$variables['user_details_loggedin_profileeditlink_url'] = t('/user/' . $user->uid . '/edit');
|
||||
$variables['user_details_loggedin_profileeditlink_imgsrc'] = variable_get('user_details_loggedin_profileeditlink_imgsrc');
|
||||
$variables['user_details_loggedin_profileeditlink_imgtitle'] = t('Edit my profile');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_privatemsglink_display') != 0 && module_exists('privatemsg')) {
|
||||
$variables['user_details_loggedin_privatemsglink_url'] = t('/messages/' . $user->uid);
|
||||
$variables['user_details_loggedin_privatemsglink_imgsrc'] = variable_get('user_details_loggedin_privatemsglink_imgsrc');
|
||||
$variables['user_details_loggedin_privatemsglink_imgtitle'] = t('My private messages');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_createlink_display') != 0) {
|
||||
$variables['user_details_loggedin_createlink_url'] = t('/node/add');
|
||||
$variables['user_details_loggedin_createlink_imgsrc'] = variable_get('user_details_loggedin_createlink_imgsrc');
|
||||
$variables['user_details_loggedin_createlink_imgtitle'] = t('Create content');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_adminlink_display') != 0 && user_access('administor content')) {
|
||||
$variables['user_details_loggedin_adminlink_url'] = t('/admin');
|
||||
$variables['user_details_loggedin_adminlink_imgsrc'] = variable_get('user_details_loggedin_adminlink_imgsrc');
|
||||
$variables['user_details_loggedin_adminlink_imgtitle'] = t('Admin');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_panelslink_display') != 0 && module_exists('panels') && user_access('administor content')) {
|
||||
$variables['user_details_loggedin_panelslink_url'] = t('/admin/structure/panels');
|
||||
$variables['user_details_loggedin_panelslink_imgsrc'] = variable_get('user_details_loggedin_panelslink_imgsrc');
|
||||
$variables['user_details_loggedin_panelslink_imgtitle'] = t('Panels');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_viewslink_display') != 0 && module_exists('views') && user_access('administor content')) {
|
||||
$variables['user_details_loggedin_viewslink_url'] = t('/admin/structure/views');
|
||||
$variables['user_details_loggedin_viewslink_imgsrc'] = variable_get('user_details_loggedin_viewslink_imgsrc');
|
||||
$variables['user_details_loggedin_viewslink_imgtitle'] = t('Views');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_performancelink_display') != 0 && user_access('administor content')) {
|
||||
$variables['user_details_loggedin_performancelink_url'] = t('/admin/config/development/performance');
|
||||
$variables['user_details_loggedin_performancelink_imgsrc'] = variable_get('user_details_loggedin_performancelink_imgsrc');
|
||||
$variables['user_details_loggedin_performancelink_imgtitle'] = t('Performance');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_logoutlink_display') != 0) {
|
||||
$variables['user_details_loggedin_logoutlink_url'] = t('/user/logout');
|
||||
$variables['user_details_loggedin_logoutlink_imgsrc'] = variable_get('user_details_loggedin_logoutlink_imgsrc');
|
||||
$variables['user_details_loggedin_logoutlink_imgtitle'] = t('Logout');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_customlinkone_type') != 0) {
|
||||
$variables['user_details_loggedin_customlinkone_url'] = variable_get('user_details_loggedin_customlinkone_url');
|
||||
$variables['user_details_loggedin_customlinkone_imgsrc'] = variable_get('user_details_loggedin_customlinkone_imgsrc');
|
||||
$variables['user_details_loggedin_customlinkone_imgtitle'] = variable_get('user_details_loggedin_customlinkone_imgtitle');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_customlinktwo_type') != 0) {
|
||||
$variables['user_details_loggedin_customlinktwo_url'] = variable_get('user_details_loggedin_customlinktwo_url');
|
||||
$variables['user_details_loggedin_customlinktwo_imgsrc'] = variable_get('user_details_loggedin_customlinktwo_imgsrc');
|
||||
$variables['user_details_loggedin_customlinktwo_imgtitle'] = variable_get('user_details_loggedin_customlinktwo_imgtitle');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_customlinkthree_type') != 0) {
|
||||
$variables['user_details_loggedin_customlinkthree_url'] = variable_get('user_details_loggedin_customlinkthree_url');
|
||||
$variables['user_details_loggedin_customlinkthree_imgsrc'] = variable_get('user_details_loggedin_customlinkthree_imgsrc');
|
||||
$variables['user_details_loggedin_customlinkthree_imgtitle'] = variable_get('user_details_loggedin_customlinkthree_imgtitle');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_customlinkfour_type') != 0) {
|
||||
$variables['user_details_loggedin_customlinkfour_url'] = variable_get('user_details_loggedin_customlinkfour_url');
|
||||
$variables['user_details_loggedin_customlinkfour_imgsrc'] = variable_get('user_details_loggedin_customlinkfour_imgsrc');
|
||||
$variables['user_details_loggedin_customlinkfour_imgtitle'] = variable_get('user_details_loggedin_customlinkfour_imgtitle');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_customlinkfive_type') != 0) {
|
||||
$variables['user_details_loggedin_customlinkfive_url'] = variable_get('user_details_loggedin_customlinkfive_url');
|
||||
$variables['user_details_loggedin_customlinkfive_imgsrc'] = variable_get('user_details_loggedin_customlinkfive_imgsrc');
|
||||
$variables['user_details_loggedin_customlinkfive_imgtitle'] = variable_get('user_details_loggedin_customlinkfive_imgtitle');
|
||||
}
|
||||
// User links HR
|
||||
if (variable_get('user_details_loggedin_frontlink_display') != 0 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_profilelink_display') != 0 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_profileeditlink_display') != 0 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_privatemsglink_display') != 0 && module_exists('privatemsg') && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_createlink_display') != 0 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_logoutlink_display') != 0 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_customlinkone_type') == 2 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_customlinktwo_type') == 2 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_customlinkthree_type') == 2 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_customlinkfour_type') == 2 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_customlinkfive_type') == 2 && variable_get('user_details_loggedin_links_hr_display') != 0) {
|
||||
$variables['user_details_loggedin_links_hr'] = '<hr>';
|
||||
}
|
||||
// Admin links HR
|
||||
if (variable_get('user_details_loggedin_adminlink_display') != 0 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_panelslink_display') != 0 && module_exists('panels') && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_viewslink_display') != 0 && module_exists('views') && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_performancelink_display') != 0 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_customlinkone_type') == 3 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_customlinktwo_type') == 3 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_customlinkthree_type') == 3 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_customlinkfour_type') == 3 && variable_get('user_details_loggedin_links_hr_display') != 0 || variable_get('user_details_loggedin_customlinkfive_type') == 3 && variable_get('user_details_loggedin_links_hr_display') != 0) {
|
||||
$variables['user_details_loggedin_links_hr'] = '<hr>';
|
||||
}
|
||||
if (variable_get('user_details_loggedin_content_amount') !=0 && variable_get('user_details_loggedin_content_display') != 0) {
|
||||
$user_details_loggedin_content_amount = variable_get('user_details_loggedin_content_amount');
|
||||
}
|
||||
if (variable_get('user_details_loggedin_content_display') != 0 && variable_get('user_details_loggedin_content_amount') != 0) {
|
||||
unset($output);
|
||||
if ($user->uid) {
|
||||
// Sql query.
|
||||
$user_details_loggedin_content_query = db_select('node', 'n');
|
||||
$user_details_loggedin_content_query
|
||||
->condition('n.uid', $user->uid, '=')
|
||||
->fields('n', array('created', 'title', 'nid', 'changed', 'type', 'status'))
|
||||
->range(0, $user_details_loggedin_content_amount)
|
||||
->orderBy('changed', 'DESC');
|
||||
$user_details_loggedin_content_fetchfield = $user_details_loggedin_content_query->execute();
|
||||
$output = '';
|
||||
foreach ($user_details_loggedin_content_fetchfield as $user_details_loggedin_content_node ) {
|
||||
$co++;
|
||||
$output .= '<li>';
|
||||
$output .= l($user_details_loggedin_content_node->title, "node/$user_details_loggedin_content_node->nid");
|
||||
$output .= '</li>';
|
||||
}
|
||||
$output .= '';
|
||||
// Show only if user have made some content.
|
||||
if ($co>0) {
|
||||
$variables['user_details_loggedin_content'] = $output;
|
||||
}
|
||||
if ($co == 0) {
|
||||
$variables['user_details_loggedin_content'] = t('No content to list.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process variables for user-details-authored.tpl.php.
|
||||
*
|
||||
* This function takes the result of the stored variable(options checkbox) and
|
||||
* creates a variable result from it.
|
||||
*/
|
||||
function template_preprocess_user_details_authored(&$variables) {
|
||||
drupal_add_css(drupal_get_path('module', 'user_details') . '/css/user_details_authored.css');
|
||||
$img_dir = drupal_get_path('module', 'user_details') . "/images/";
|
||||
// If the page is a node we need to load the user data from the node ID(nid)
|
||||
// profile.
|
||||
$co = $output = NULL;
|
||||
if (arg(0) == 'node') {
|
||||
$node_load = node_load(arg(1));
|
||||
$uid = $node_load->uid;
|
||||
$user_load = user_load($uid);
|
||||
}
|
||||
// If the page is a user profile we need to load the user data from the user profile.
|
||||
if (arg(0) == 'user') {
|
||||
$user_arg = user_load(arg(1));
|
||||
$uid = $user_arg->uid;
|
||||
$user_load = user_load($uid);
|
||||
}
|
||||
if (variable_get('user_details_authored_avatar_display') !=0) {
|
||||
$variables['user_details_authored_avatar'] = theme('user_picture', array('account' => $user_load));
|
||||
}
|
||||
if (variable_get('user_details_authored_joined_display') != 0) {
|
||||
$user_details_authored_date = date('c', $user_load->created);
|
||||
$user_details_authored_dateconvert = date('M j, Y', strtotime($user_details_authored_date));
|
||||
$variables['user_details_authored_joined_title'] = t('Joined');
|
||||
$variables['user_details_authored_joined_result'] = t(' %joined', array('%joined' => $user_details_authored_dateconvert));
|
||||
}
|
||||
if (variable_get('user_details_authored_postcount_display') != 0) {
|
||||
$user_details_authored_postcount_query = db_select('node', 'n');
|
||||
$user_details_authored_postcount_query
|
||||
->condition('n.uid', $user_load->uid, '=')
|
||||
->fields('n', array('uid'));
|
||||
$user_details_authored_postcount_fetchfield = $user_details_authored_postcount_query->countQuery()->execute()->fetchField();
|
||||
$variables['user_details_authored_postcount_title'] = t('Posts');
|
||||
$variables['user_details_authored_postcount_result'] = t('%postcount', array('%postcount' => $user_details_authored_postcount_fetchfield));
|
||||
}
|
||||
if (variable_get('user_details_authored_points_display') !=0 && module_exists('userpoints')) {
|
||||
$variables['user_details_authored_points_title'] = t('!Points', userpoints_translation());
|
||||
$variables['user_details_authored_points_result'] = userpoints_get_current_points($user_load->uid, 'all');
|
||||
}
|
||||
if (variable_get('user_details_authored_rank_display') != 0) {
|
||||
$user_details_authored_rank_query = db_select('users_roles');
|
||||
$user_details_authored_rank_query
|
||||
->condition('uid', $user_load->uid, '=')
|
||||
->fields('users_roles', array('rid'));
|
||||
$user_details_authored_rank_fetchfield = $user_details_authored_rank_query->execute()->fetchField();
|
||||
if (($user_details_authored_rank_fetchfield) == NULL) {
|
||||
$user_details_authored_rank_fetchfield = 2;
|
||||
}
|
||||
$user_details_authored_rankname_query = db_select('role', 'r');
|
||||
$user_details_authored_rankname_query
|
||||
->condition('rid', $user_details_authored_rank_fetchfield, '=')
|
||||
->fields('r', array('name'));
|
||||
$user_details_authored_rankname_fetchfield = $user_details_authored_rankname_query->execute()->fetchField();
|
||||
$variables['user_details_authored_rank_title'] = t('Role');
|
||||
$variables['user_details_authored_rank_result'] = t('%rank', array('%rank' => $user_details_authored_rankname_fetchfield));
|
||||
}
|
||||
if (variable_get('user_details_authored_avatar_display') !=0 && variable_get('user_details_authored_stats_hr_display') != 0 || variable_get('user_details_authored_joined_display') != 0 && variable_get('user_details_authored_stats_hr_display') != 0 || variable_get('user_details_authored_postcount_display') != 0 && variable_get('user_details_authored_stats_hr_display') != 0 || variable_get('user_details_authored_points_display') !=0 && module_exists('userpoints') && variable_get('user_details_authored_stats_hr_display') != 0 || variable_get('user_details_authored_rank_display') != 0 && variable_get('user_details_authored_stats_hr_display') != 0) {
|
||||
$variables['user_details_authored_stats_hr'] = '<hr>';
|
||||
}
|
||||
if (variable_get('user_details_authored_profilelink_display') != 0) {
|
||||
$variables['user_details_authored_profilelink_url'] = t('/user/' . $user_load->uid);
|
||||
$variables['user_details_authored_profilelink_imgsrc'] = variable_get('user_details_loggedin_profilelink_imgsrc');
|
||||
$variables['user_details_authored_profilelink_imgtitle'] = t('Author\'s profile');
|
||||
}
|
||||
if (variable_get('user_details_authored_privatemsglink_display') != 0 && module_exists('privatemsg')) {
|
||||
$variables['user_details_authored_privatemsglink_url'] = t('/messages/new/' . $user_load->uid);
|
||||
$variables['user_details_authored_privatemsglink_imgsrc'] = variable_get('user_details_loggedin_privatemsglink_imgsrc');
|
||||
$variables['user_details_authored_privatemsglink_imgtitle'] = t('Private message the author');
|
||||
}
|
||||
if (variable_get('user_details_authored_profilelink_display') != 0 && variable_get('user_details_authored_links_hr_display') != 0 || variable_get('user_details_authored_privatemsglink_display') != 0 && module_exists('privatemsg') && variable_get('user_details_authored_links_hr_display') != 0) {
|
||||
$variables['user_details_authored_links_hr'] = '<hr>';
|
||||
}
|
||||
if (variable_get('user_details_authored_content_amount') !=0 && variable_get('user_details_authored_content_display') !=0) {
|
||||
$user_details_authored_content_amount = variable_get('user_details_authored_content_amount');
|
||||
}
|
||||
if (variable_get('user_details_authored_content_display') != 0 && variable_get('user_details_authored_content_amount') != 0) {
|
||||
unset($output);
|
||||
if ($user_load->uid) {
|
||||
// Sql query.
|
||||
$user_details_authored_content_query = db_select('node', 'n');
|
||||
$user_details_authored_content_query
|
||||
->condition('n.uid', $user_load->uid, '=')
|
||||
->fields('n', array('created', 'title', 'nid', 'changed', 'type', 'status'))
|
||||
->range(0, 3)
|
||||
->orderBy('changed', 'DESC');
|
||||
$user_details_authored_content_fetchfield = $user_details_authored_content_query->execute();
|
||||
$output = '';
|
||||
foreach ($user_details_authored_content_fetchfield as $user_details_authored_content_node ) {
|
||||
$co++;
|
||||
$output .= '<li>';
|
||||
$output .= l($user_details_authored_content_node->title, "node/$user_details_authored_content_node->nid");
|
||||
$output .= '</li>';
|
||||
}
|
||||
$output .= '';
|
||||
if ($co>0) {
|
||||
$variables['user_details_authored_content'] = $output;
|
||||
}
|
||||
if ($co == 0) {
|
||||
$variables['user_details_authored_content'] = t('No content to list.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to push the variables to the theme layer for the "logged-in" block.
|
||||
*/
|
||||
function user_details_loggedin_block_content() {
|
||||
$content = array(
|
||||
$user_details_loggedin_avatar = 'user_details_loggedin_avatar',
|
||||
$user_details_loggedin_points_title = 'user_details_loggedin_points_title',
|
||||
$user_details_loggedin_points_result = 'user_details_loggedin_points_result',
|
||||
$user_details_loggedin_joined_title = 'user_details_loggedin_joined_title',
|
||||
$user_details_loggedin_joined_result = 'user_details_loggedin_joined_result',
|
||||
$user_details_loggedin_postcount_title = 'user_details_loggedin_postcount_title',
|
||||
$user_details_loggedin_postcount_result = 'user_details_loggedin_postcount_result',
|
||||
$user_details_loggedin_rank_title = 'user_details_loggedin_rank_title',
|
||||
$user_details_loggedin_rank_result = 'user_details_loggedin_rank_result',
|
||||
$user_details_loggedin_privatemsg_count_title = 'user_details_loggedin_privatemsg_title',
|
||||
$user_details_loggedin_privatemsg_count_result = 'user_details_loggedin_privatemsg_result',
|
||||
$user_details_loggedin_stats_hr = 'user_details_loggedin_stats_hr',
|
||||
$user_details_loggedin_frontlink_url = 'user_details_loggedin_profilelink_url',
|
||||
$user_details_loggedin_frontlink_imgsrc = 'user_details_loggedin_profilelink_imgsrc',
|
||||
$user_details_loggedin_frontlink_imgtitle = 'user_details_loggedin_profilelink_imgtitle',
|
||||
$user_details_loggedin_profilelink_url = 'user_details_loggedin_profilelink_url',
|
||||
$user_details_loggedin_profilelink_imgsrc = 'user_details_loggedin_profilelink_imgsrc',
|
||||
$user_details_loggedin_profilelink_imgtitle = 'user_details_loggedin_profilelink_imgtitle',
|
||||
$user_details_loggedin_profileeditlink_url = 'user_details_loggedin_profilelink_url',
|
||||
$user_details_loggedin_profileeditlink_imgsrc = 'user_details_loggedin_profileeditlink_imgsrc',
|
||||
$user_details_loggedin_profileeditlink_imgtitle = 'user_details_loggedin_profilelink_imgtitle',
|
||||
$user_details_loggedin_privatemsglink_url = 'user_details_loggedin_privatemsglink',
|
||||
$user_details_loggedin_privatemsglink_imgsrc = 'user_details_loggedin_privatemsglink_imgsrc',
|
||||
$user_details_loggedin_privatemsglink_imgtitle = 'user_details_loggedin_privatemsglinkimgtitle',
|
||||
$user_details_loggedin_createlink_url = 'user_details_loggedin_createlink_url',
|
||||
$user_details_loggedin_createlink_imgsrc = 'user_details_loggedin_createlink_imgsrc',
|
||||
$user_details_loggedin_createlink_imgtitle = 'user_details_loggedin_createlink_imgtitle',
|
||||
$user_details_loggedin_adminlink_url = 'user_details_loggedin_adminlink_url',
|
||||
$user_details_loggedin_adminlink_imgsrc = 'user_details_loggedin_adminlink_imgsrc',
|
||||
$user_details_loggedin_adminlink_imgtitle = 'user_details_loggedin_adminlink_imgtitle',
|
||||
$user_details_loggedin_panelslink_url = 'user_details_loggedin_panelslink_url',
|
||||
$user_details_loggedin_panelslink_imgsrc = 'user_details_loggedin_panelslink_imgsrc',
|
||||
$user_details_loggedin_panelslink_imgtitle = 'user_details_loggedin_panelslink_imgtitle',
|
||||
$user_details_loggedin_viewslink_url = 'user_details_loggedin_viewslink_url',
|
||||
$user_details_loggedin_viewslink_imgsrc = 'user_details_loggedin_viewslink_imgsrc',
|
||||
$user_details_loggedin_viewslink_imgtitle = 'user_details_loggedin_viewslink_imgtitle',
|
||||
$user_details_loggedin_performancelink_url = 'user_details_loggedin_performancelink_url',
|
||||
$user_Details_loggedin_performancelink_imgsrc = 'user_details_loggedin_performancelink_imgsrc',
|
||||
$user_details_loggedin_performancelink_imgtitle = 'user_details_loggedin_performancelink_imgtitle',
|
||||
$user_details_loggedin_logoutlink_url = 'user_details_loggedin_logoutlink_url',
|
||||
$user_details_loggedin_logoutlink_imgsrc = 'user_details_loggedin_logoutlink_imgsrc',
|
||||
$user_details_loggedin_logoutlink_imgtitle = 'user_details_loggedin_logoutlink_imgtitle',
|
||||
$user_details_loggedin_customlinkone_url = 'user_details_loggedin_customlinkone_url',
|
||||
$user_details_loggedin_customlinkone_imgsrc = 'user_details_loggedin_customlinkone_imgsrc',
|
||||
$user_details_loggedin_customlinkone_imgtitle = 'user_details_loggedin_customlinkone_imgtitle',
|
||||
$user_details_loggedin_customlinktwo_url = 'user_details_loggedin_customlinktwo_url',
|
||||
$user_details_loggedin_customlinktwo_imgsrc = 'user_details_loggedin_customlinktwo_imgsrc',
|
||||
$user_details_loggedin_customlinktwo_imgtitle = 'user_details_loggedin_customlinktwo_imgtitle',
|
||||
$user_details_loggedin_customlinkthree_url = 'user_details_loggedin_customlinkthree_url',
|
||||
$user_details_loggedin_customlinkthree_imgsrc = 'user_details_loggedin_customlinkthree_imgsrc',
|
||||
$user_details_loggedin_customlinkthree_imgtitle = 'user_details_loggedin_customlinkthree_imgtitle',
|
||||
$user_details_loggedin_customlinkfour_url = 'user_details_loggedin_customlinkfour_url',
|
||||
$user_details_loggedin_customlinkfour_imgsrc = 'user_details_loggedin_customlinkfour_imgsrc',
|
||||
$user_details_loggedin_customlinkfour_imgtitle = 'user_details_loggedin_customlinkfour_imgtitle',
|
||||
$user_details_loggedin_customlinkfive_url = 'user_details_loggedin_customlinkfive_url',
|
||||
$user_details_loggedin_customlinkfive_imgsrc = 'user_details_loggedin_customlinkfive_imgsrc',
|
||||
$user_details_loggedin_customlinkfive_imgtitle = 'user_details_loggedin_customlinkfive_imgtitle',
|
||||
$user_details_loggedin_links_hr = 'user_details_loggedin_links_hr',
|
||||
$user_details_loggedin_content = 'user_details_loggedin_content',
|
||||
);
|
||||
$output = theme('user_details_loggedin', $content);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to push the variables to the theme layer for the "Authored by" block.
|
||||
*/
|
||||
function user_details_authored_block_content() {
|
||||
$content = array(
|
||||
$user_details_authored_avatar = 'user_details_authored_avatar',
|
||||
$user_details_authored_joined = 'user_details_authored_joined',
|
||||
$user_details_authored_postcount_title = 'user_details_authored_postcount_title',
|
||||
$user_details_authored_postcount_result = 'user_details_authored_postcount_result',
|
||||
$user_details_authored_points_title = 'user_details_authored_points_title',
|
||||
$user_details_authored_points_result = 'user_details_authored_points_result',
|
||||
$user_details_authored_rank_title = 'user_details_authored_rank_title',
|
||||
$user_details_authored_rank_result = 'user_details_authored_rank_result',
|
||||
$user_details_authored_stats_hr = 'user_details_authored_stats_hr',
|
||||
$user_details_authored_profilelink_url = 'user_details_authored_profilelink_url',
|
||||
$user_details_authored_profilelink_imgsrc = 'user_details_authored_profilelink_imgsrc',
|
||||
$user_details_authored_profilelink_imgtitle = 'user_details_authored_profilelink_imgtitle',
|
||||
$user_details_authored_privatemsglink_url = 'user_details_authored_privatemsglink',
|
||||
$user_details_authored_privatemsglink_imgsrc = 'user_details_authored_privatemsglink_imgsrc',
|
||||
$user_details_authored_privatemsglink_imgtitle = 'user_details_authored_privatemsglinkimgtitle',
|
||||
$user_details_authored_links_hr = 'user_details_authored_links_hr',
|
||||
$user_details_authored_content = 'user_details_authored_content',
|
||||
);
|
||||
$output = theme('user_details_authored', $content);
|
||||
return $output;
|
||||
}
|
||||
@@ -0,0 +1,767 @@
|
||||
<?php
|
||||
function user_details_admin_settings() {
|
||||
// Add the css that is needed for the admin form
|
||||
drupal_add_css(drupal_get_path('module', 'user_details') . '/css/user_details_admin.css');
|
||||
|
||||
$overview = t('The User Details module is a simple module to help the end-user find thier way around a website by adding a central location for important link, stats, and thier content.');
|
||||
$overview .= '<br/>';
|
||||
$overview .= t('The User Details module is broken up into two blocks: logged-in and authored by. For a more detailed overview please visit the ') . '<a href="/admin/help/user_details">' . t('User Details help page') . '</a>';
|
||||
|
||||
$loggedin_header = '<hr>';
|
||||
$loggedin_header .= '<h3>' . t('User Details: logged-in user settings') . '</h3>';
|
||||
|
||||
$authored_header = '<hr>';
|
||||
$authored_header .= '<h3>' . t('User Details: authored user settings') . '</h3>';
|
||||
|
||||
$hr = '<hr>';
|
||||
|
||||
$form['overview'] = array(
|
||||
'#markup' => $overview,
|
||||
);
|
||||
$form['loggedin_header'] = array(
|
||||
'#markup' => $loggedin_header,
|
||||
);
|
||||
$form['loggedin_stats'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'User Stats.',
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_stats']['user_details_loggedin_avatar_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the "User Avatar".'),
|
||||
'#default_value' => variable_get('user_details_loggedin_avatar_display', FALSE),
|
||||
'#description' => t('Displays the Avatar of the user, if any is available.')
|
||||
);
|
||||
$form['loggedin_stats']['user_details_loggedin_joined_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the "Joined Date".'),
|
||||
'#default_value' => variable_get('user_details_loggedin_joined_display', FALSE),
|
||||
'#description' => t('Displays the account creation date of the user.')
|
||||
);
|
||||
$form['loggedin_stats']['user_details_loggedin_postcount_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the "Post count"'),
|
||||
'#default_value' => variable_get('user_details_loggedin_postcount_display', FALSE),
|
||||
'#description' => t('Displays the user\'s current number of posts.'),
|
||||
);
|
||||
if (module_exists('userpoints')) {
|
||||
$form['loggedin_stats']['user_details_loggedin_points_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the "User Points".'),
|
||||
'#default_value' => variable_get('user_details_loggedin_points_display', FALSE),
|
||||
'#description' => t('Displays the user\'s "User Points" amount.'),
|
||||
'#disabled' => FALSE,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['loggedin_stats']['user_details_loggedin_points_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the "User Points".'),
|
||||
'#default_value' => variable_get('user_details_loggedin_points_display', FALSE),
|
||||
'#description' => t('Please install <a href="http://drupal.org/project/userpoints">User Points</a>'),
|
||||
'#disabled' => TRUE,
|
||||
);
|
||||
}
|
||||
$form['loggedin_stats']['user_details_loggedin_rank_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the role.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_rank_display', FALSE),
|
||||
'#description' => t('Displays the user\'s role name.'),
|
||||
);
|
||||
if (module_exists('privatemsg')) {
|
||||
$form['loggedin_stats']['user_details_loggedin_privatemsg_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the unread message amount.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_privatemsg_display', FALSE),
|
||||
'#description' => t('Displays the unread message amount from the "Private Messages" module.'),
|
||||
'#disabled' => FALSE,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['loggedin_stats']['user_details_loggedin_privatemsg_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the unread message amount.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_privatemsg_display', FALSE),
|
||||
'#description' => t('Please install <a href="http://drupal.org/project/privatemsg">Private Messages</a>'),
|
||||
'#disabled' => TRUE,
|
||||
);
|
||||
}
|
||||
|
||||
$form['loggedin_stats_hr'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Horizontal Ruler.',
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_stats_hr']['user_details_loggedin_stats_hr_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display "HR"'),
|
||||
'#default_value' => variable_get('user_details_loggedin_stats_hr_display', FALSE),
|
||||
'#description' => t('Displays a hortizontal ruler html enity seprating the stats and links sections.'),
|
||||
);
|
||||
|
||||
//Links Options
|
||||
$form['loggedin_links'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Links.',
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['front_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Front Link'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['front_link']['user_details_loggedin_frontlink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_frontlink_display', FALSE),
|
||||
'#description' => t('Displays an icon link leading to the site\'s front page.'),
|
||||
);
|
||||
$form['loggedin_links']['front_link']['user_details_loggedin_frontlink_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image source.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_frontlink_imgsrc', "/" . drupal_get_path('module', 'user_details') . "/images/front-icon.png"),
|
||||
'#description' => t('default value: <i>/' . drupal_get_path('module', 'user_details') . '/images/front-icon.png</i>'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['profile_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Profile Link'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['profile_link']['user_details_loggedin_profilelink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_profilelink_display', FALSE),
|
||||
'#description' => t('Displays an icon link leading to the user\'s profile page.'),
|
||||
);
|
||||
$form['loggedin_links']['profile_link']['user_details_loggedin_profilelink_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image source.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_profilelink_imgsrc', "/" . drupal_get_path('module', 'user_details') . "/images/profile-icon.png"),
|
||||
'#description' => t('default value: <i>/' . drupal_get_path('module', 'user_details') . '/images/profile-icon.png</i>'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['profile_edit_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Profile Edit Link'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['profile_edit_link']['user_details_loggedin_profileeditlink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_profileeditlink_display', FALSE),
|
||||
'#description' => t('Displays an icon link leading to the user\'s edit profile page.')
|
||||
);
|
||||
$form['loggedin_links']['profile_edit_link']['user_details_loggedin_profileeditlink_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image source.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_profileeditlink_imgsrc', "/" . drupal_get_path('module', 'user_details') . "/images/profileedit-icon.png"),
|
||||
'#description' => t('default value: <i>/' . drupal_get_path('module', 'user_details') . '/images/profileedit-icon.png</i>'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['privatemsg_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Private Message Link'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
if (module_exists('privatemsg')) {
|
||||
$form['loggedin_links']['privatemsg_link']['user_details_loggedin_privatemsglink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_privatemsglink_display', FALSE),
|
||||
'#description' => t('Displays an icon link leading to the user\'s private message profile page.'),
|
||||
'#disabled' => FALSE,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['loggedin_links']['privatemsg_link']['user_details_loggedin_privatemsglink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_privatemsglink_display', FALSE),
|
||||
'#description' => t('please install <a href="http://drupal.org/project/privatemsg">Private Message</a>.'),
|
||||
'#disabled' => TRUE,
|
||||
);
|
||||
}
|
||||
if (module_exists('privatemsg')) {
|
||||
$form['loggedin_links']['privatemsg_link']['user_details_loggedin_privatemsglink_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image source.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_privatemsg_imgsrc', "/" . drupal_get_path('module', 'user_details') . "/images/privatemsg-icon.png"),
|
||||
'#description' => t('default value: <i>/' . drupal_get_path('module', 'user_details') . '/images/privatemsg-icon.png</i>'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
}
|
||||
$form['loggedin_links']['create_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Create Link'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['create_link']['user_details_loggedin_createlink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_createlink_display', FALSE),
|
||||
'#description' => t('Displays an icon link to the /node/add page'),
|
||||
);
|
||||
$form['loggedin_links']['create_link']['user_details_loggedin_createlink_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image source.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_createlink_imgsrc', "/" . drupal_get_path('module', 'user_details') . "/images/create-icon.png"),
|
||||
'#description' => t('default value: <i>/' . drupal_get_path('module', 'user_details') . '/images/create-icon.png</i>'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['admin_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Admin Link'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['admin_link']['user_details_loggedin_adminlink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_adminlink_display', FALSE),
|
||||
'#description' => t('Displays an icon link to the admin page.')
|
||||
);
|
||||
$form['loggedin_links']['admin_link']['user_details_loggedin_adminlink_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image source.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_adminlink_imgsrc', "/" . drupal_get_path('module', 'user_details') . "/images/admin-icon.png"),
|
||||
'#description' => t('default value: <i>/' . drupal_get_path('module', 'user_details') . '/images/admin-icon.png</i>'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['panels_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Panels Link'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
if (module_exists('panels')) {
|
||||
$form['loggedin_links']['panels_link']['user_details_loggedin_panelslink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_panelslink_display', FALSE),
|
||||
'#description' => t('Displays an icon link to the admin section of the "Panels" module.')
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['loggedin_links']['panels_link']['user_details_loggedin_panelslink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_panelslink_display', FALSE),
|
||||
'#description' => t('Please install <a href="http://drupal.org/project/panels">Panels</a>'),
|
||||
'#disabled' => TRUE,
|
||||
);
|
||||
}
|
||||
if (module_exists('panels')) {
|
||||
$form['loggedin_links']['panels_link']['user_details_loggedin_panelslink_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image source.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_panelslink_imgsrc', "/" . drupal_get_path('module', 'user_details') . "/images/panels-icon.png"),
|
||||
'#description' => t('default value: <i>/' . drupal_get_path('module', 'user_details') . '/images/panels-icon.png</i>'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
}
|
||||
$form['loggedin_links']['views_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Views Link'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
if (module_exists('views')) {
|
||||
$form['loggedin_links']['views_link']['user_details_loggedin_viewslink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_viewslink_display', FALSE),
|
||||
'#description' => t('Displays an icon link to the admin section of the "Views" module.')
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['loggedin_links']['views_link']['user_details_loggedin_viewslink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_viewslink_display', FALSE),
|
||||
'#description' => t('Please install <a href="http://drupal.org/project/views">Panels</a>'),
|
||||
'#disabled' => TRUE,
|
||||
);
|
||||
}
|
||||
if (module_exists('views')) {
|
||||
$form['loggedin_links']['views_link']['user_details_loggedin_viewslink_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image source.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_viewslink_imgsrc', "/" . drupal_get_path('module', 'user_details') . "/images/views-icon.png"),
|
||||
'#description' => t('default value: <i>/' . drupal_get_path('module', 'user_details') . '/images/views-icon.png</i>'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
}
|
||||
$form['loggedin_links']['performance_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Performance Link'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['performance_link']['user_details_loggedin_performancelink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_performancelink_display', FALSE),
|
||||
'#description' => t('Displays an icon link to the admin section of the "Views" module.')
|
||||
);
|
||||
$form['loggedin_links']['performance_link']['user_details_loggedin_performancelink_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image source.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_performancelink_imgsrc', "/" . drupal_get_path('module', 'user_details') . "/images/performance-icon.png"),
|
||||
'#description' => t('default value: <i>/' . drupal_get_path('module', 'user_details') . '/images/performance-icon.png</i>'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['logout_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Logout Link'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['logout_link']['user_details_loggedin_logoutlink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_loggedin_logoutlink_display', FALSE),
|
||||
'#description' => t('Displays an icon link to allow the user to logout.')
|
||||
);
|
||||
$form['loggedin_links']['logout_link']['user_details_loggedin_logoutlink_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image source.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_logoutlink_imgsrc', "/" . drupal_get_path('module', 'user_details') . "/images/logout-icon.png"),
|
||||
'#description' => t('It is the URL relative to your drupal install. Do not include your domain name.(http://www.example.com)'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
|
||||
//Custom Link One Options
|
||||
$form['loggedin_links']['custom_link_one'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Custom Link One'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['custom_link_one']['user_details_loggedin_customlinkone_type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Link Type'),
|
||||
'#options' => array(
|
||||
0 => t('Disabled'),
|
||||
2 => t('User Link'),
|
||||
3 => t('Admin Link'),
|
||||
),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkone_type', '0'),
|
||||
'#description' => t('Choose which type of link this link is.'),
|
||||
);
|
||||
$form['loggedin_links']['custom_link_one']['user_details_loggedin_customlinkone_url'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('URL path.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkone_url', ''),
|
||||
'#description' => t('the url of the page you want this link to refer to. (example: /admin/structure/pages)'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['custom_link_one']['user_details_loggedin_customlinkone_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image path.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkone_imgsrc', ''),
|
||||
'#description' => t('the path to your image. (example: /sites/all/themes/my-theme/custom-link-one.png)'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['custom_link_one']['user_details_loggedin_customlinkone_imgtitle'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image title.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkone_imgtitle', ''),
|
||||
'#description' => t('The image title, or mouse-over tooltip, of the image.'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
//Custom Link Two Options
|
||||
$form['loggedin_links']['custom_link_two'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Custom Link Two'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['custom_link_two']['user_details_loggedin_customlinktwo_type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Link Type'),
|
||||
'#options' => array(
|
||||
0 => t('Disabled'),
|
||||
2 => t('User Link'),
|
||||
3 => t('Admin Link'),
|
||||
),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinktwo_type', '0'),
|
||||
'#description' => t('Choose which type of link this link is.'),
|
||||
);
|
||||
$form['loggedin_links']['custom_link_two']['user_details_loggedin_customlinktwo_url'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('URL path.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinktwo_url', ''),
|
||||
'#description' => t('the url of the page you want this link to refer to. (example: /admin/structure/pages)'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['custom_link_two']['user_details_loggedin_customlinktwo_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image path.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinktwo_imgsrc', ''),
|
||||
'#description' => t('the path to your image. (example: /sites/all/themes/my-theme/custom-link-two.png)'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['custom_link_two']['user_details_loggedin_customlinktwo_imgtitle'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image title.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinktwo_imgtitle', ''),
|
||||
'#description' => t('The image title, or mouse-over tooltip, of the image.'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
//Custom Link Three Options
|
||||
$form['loggedin_links']['custom_link_three'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Custom Link Three'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['custom_link_three']['user_details_loggedin_customlinkthree_type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Link Type'),
|
||||
'#options' => array(
|
||||
0 => t('Disabled'),
|
||||
2 => t('User Link'),
|
||||
3 => t('Admin Link'),
|
||||
),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkthree_type', '0'),
|
||||
'#description' => t('Choose which type of link this link is.'),
|
||||
);
|
||||
$form['loggedin_links']['custom_link_three']['user_details_loggedin_customlinkthree_url'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('URL path.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkthree_url', ''),
|
||||
'#description' => t('the url of the page you want this link to refer to. (example: /admin/structure/pages)'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['custom_link_three']['user_details_loggedin_customlinkthree_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image path.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkthree_imgsrc', ''),
|
||||
'#description' => t('the path to your image. (example: /sites/all/themes/my-theme/custom-link-three.png)'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['custom_link_three']['user_details_loggedin_customlinkthree_imgtitle'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image title.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkthree_imgtitle', ''),
|
||||
'#description' => t('The image title, or mouse-over tooltip, of the image.'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
|
||||
//Custom Link Four Options
|
||||
$form['loggedin_links']['custom_link_four'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Custom Link Four'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['custom_link_four']['user_details_loggedin_customlinkfour_type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Link Type'),
|
||||
'#options' => array(
|
||||
0 => t('Disabled'),
|
||||
2 => t('User Link'),
|
||||
3 => t('Admin Link'),
|
||||
),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkfour_type', '0'),
|
||||
'#description' => t('Choose which type of link this link is.'),
|
||||
);
|
||||
$form['loggedin_links']['custom_link_four']['user_details_loggedin_customlinkfour_url'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('URL path.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkfour_url', ''),
|
||||
'#description' => t('the url of the page you want this link to refer to. (example: /admin/structure/pages)'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['custom_link_four']['user_details_loggedin_customlinkfour_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image path.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkfour_imgsrc', ''),
|
||||
'#description' => t('the path to your image. (example: /sites/all/themes/my-theme/custom-link-four.png)'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['custom_link_four']['user_details_loggedin_customlinkfour_imgtitle'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image title.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkfour_imgtitle', ''),
|
||||
'#description' => t('The image title, or mouse-over tooltip, of the image.'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
|
||||
//Custom Link Five Options
|
||||
$form['loggedin_links']['custom_link_five'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Custom Link Five'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links']['custom_link_five']['user_details_loggedin_customlinkfive_type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Link Type'),
|
||||
'#options' => array(
|
||||
0 => t('Disabled'),
|
||||
2 => t('User Link'),
|
||||
3 => t('Admin Link'),
|
||||
),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkfive_type', '0'),
|
||||
'#description' => t('Choose which type of link this link is.'),
|
||||
);
|
||||
$form['loggedin_links']['custom_link_five']['user_details_loggedin_customlinkfive_url'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('URL path.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkfive_url', ''),
|
||||
'#description' => t('the url of the page you want this link to refer to. (example: /admin/structure/pages)'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['custom_link_five']['user_details_loggedin_customlinkfive_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image path.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkfive_imgsrc', ''),
|
||||
'#description' => t('the path to your image. (example: /sites/all/themes/my-theme/custom-link-five.png)'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['loggedin_links']['custom_link_five']['user_details_loggedin_customlinkfive_imgtitle'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image title.'),
|
||||
'#default_value' => variable_get('user_details_loggedin_customlinkfive_imgtitle', ''),
|
||||
'#description' => t('The image title, or mouse-over tooltip, of the image.'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
|
||||
$form['loggedin_links_hr'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Horizontal Ruler.',
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_links_hr']['user_details_loggedin_links_hr_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display "HR"'),
|
||||
'#default_value' => variable_get('user_details_loggedin_links_hr_display', FALSE),
|
||||
'#description' => t('Displays a hortizontal ruler html enity seprating the links and content sections.'),
|
||||
);
|
||||
|
||||
//Content Options
|
||||
$form['loggedin_content'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Content.',
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['loggedin_content']['user_details_loggedin_content_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display "Content"'),
|
||||
'#default_value' => variable_get('user_details_loggedin_content_display', FALSE),
|
||||
'#description' => t('Lists the last X updated nodes authored by the user.')
|
||||
);
|
||||
$form['loggedin_content']['user_details_loggedin_content_amount'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('User content amount'),
|
||||
'#default_value' => variable_get('user_details_loggedin_content_amount', 3),
|
||||
'#size' => 2,
|
||||
'#maxlength' => 2,
|
||||
'#description' => t('Changes the number of recent items listed for the "Content" list. (<b>if set to 0 it renders this list null.</b>)')
|
||||
);
|
||||
|
||||
/**
|
||||
* Authored options
|
||||
*
|
||||
* the authored by block settings.
|
||||
*/
|
||||
$form['authored_header'] = array(
|
||||
'#markup' => $authored_header,
|
||||
);
|
||||
$form['authored_stats'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'User Stats.',
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['authored_stats']['user_details_authored_avatar_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the "User Avatar".'),
|
||||
'#default_value' => variable_get('user_details_authored_avatar_display', FALSE),
|
||||
'#description' => t('Displays the Avatar of the user, if any is available.')
|
||||
);
|
||||
$form['authored_stats']['user_details_authored_joined_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the "Joined Date".'),
|
||||
'#default_value' => variable_get('user_details_authored_joined_display', FALSE),
|
||||
'#description' => t('Displays the account creation date of the user.')
|
||||
);
|
||||
$form['authored_stats']['user_details_authored_postcount_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the "Post count"'),
|
||||
'#default_value' => variable_get('user_details_authored_postcount_display', FALSE),
|
||||
'#description' => t('Displays the user\'s current number of posts.'),
|
||||
);
|
||||
if (module_exists('userpoints')) {
|
||||
$form['authored_stats']['user_details_authored_points_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the "User Points".'),
|
||||
'#default_value' => variable_get('user_details_authored_points_display', FALSE),
|
||||
'#description' => t('Displays the user\'s "User Points" amount.'),
|
||||
'#disabled' => FALSE,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['authored_stats']['user_details_authored_points_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the "User Points".'),
|
||||
'#default_value' => variable_get('user_details_authored_points_display', FALSE),
|
||||
'#description' => t('Please install <a href="http://drupal.org/project/userpoints">User Points</a>'),
|
||||
'#disabled' => TRUE,
|
||||
);
|
||||
}
|
||||
$form['authored_stats']['user_details_authored_rank_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display the role.'),
|
||||
'#default_value' => variable_get('user_details_authored_rank_display', FALSE),
|
||||
'#description' => t('Displays the user\'s role name.'),
|
||||
);
|
||||
|
||||
$form['authored_stats_hr'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Horizontal Ruler.',
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['authored_stats_hr']['user_details_authored_stats_hr_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display "HR"'),
|
||||
'#default_value' => variable_get('user_details_authored_stats_hr_display', FALSE),
|
||||
'#description' => t('Displays a hortizontal ruler html enity seprating the stats and links sections.'),
|
||||
);
|
||||
|
||||
$form['authored_links'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Links.',
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['authored_links']['profile_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Profile Link'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['authored_links']['profile_link']['user_details_authored_profilelink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_authored_profilelink_display', FALSE),
|
||||
'#description' => t('Displays an icon link leading to the user\'s profile page.'),
|
||||
);
|
||||
$form['authored_links']['profile_link']['user_details_authored_profilelink_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image source.'),
|
||||
'#default_value' => variable_get('user_details_authored_profilelink_imgsrc', "/" . drupal_get_path('module', 'user_details') . "/images/profile-icon.png"),
|
||||
'#description' => t('default value: <i>/' . drupal_get_path('module', 'user_details') . '/images/profile-icon.png</i>'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
$form['authored_links']['privatemsg_link'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Private Message Link'),
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
if (module_exists('privatemsg')) {
|
||||
$form['authored_links']['privatemsg_link']['user_details_authored_privatemsglink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_authored_privatemsglink_display', FALSE),
|
||||
'#description' => t('Displays an icon link leading to the user\'s private message profile page.'),
|
||||
'#disabled' => FALSE,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['authored_links']['privatemsg_link']['user_details_authored_privatemsglink_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display'),
|
||||
'#default_value' => variable_get('user_details_authored_privatemsglink_display', FALSE),
|
||||
'#description' => t('please install <a href="http://drupal.org/project/privatemsg">Private Message</a>.'),
|
||||
'#disabled' => TRUE,
|
||||
);
|
||||
}
|
||||
if (module_exists('privatemsg')) {
|
||||
$form['authored_links']['privatemsg_link']['user_details_authored_privatemsglink_imgsrc'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Image source.'),
|
||||
'#default_value' => variable_get('user_details_authored_privatemsg_imgsrc', "/" . drupal_get_path('module', 'user_details') . "/images/privatemsg-icon.png"),
|
||||
'#description' => t('default value: <i>/' . drupal_get_path('module', 'user_details') . '/images/privatemsg-icon.png</i>'),
|
||||
'#size' => 75,
|
||||
'#maxlength' => 500,
|
||||
);
|
||||
}
|
||||
|
||||
$form['authored_links_hr'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Horizontal Ruler.',
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['authored_links_hr']['user_details_authored_links_hr_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display "HR"'),
|
||||
'#default_value' => variable_get('user_details_authored_links_hr_display', FALSE),
|
||||
'#description' => t('Displays a hortizontal ruler html enity seprating the links and content sections.'),
|
||||
);
|
||||
|
||||
//Content Options
|
||||
$form['authored_content'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Content.',
|
||||
'#collapsible' => 'true',
|
||||
'#collapsed' => 'true',
|
||||
);
|
||||
$form['authored_content']['user_details_authored_content_display'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display "Content"'),
|
||||
'#default_value' => variable_get('user_details_authored_content_display', FALSE),
|
||||
'#description' => t('Lists the last X updated nodes authored by the user.')
|
||||
);
|
||||
$form['authored_content']['user_details_authored_content_amount'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('User content amount'),
|
||||
'#default_value' => variable_get('user_details_authored_content_amount', 3),
|
||||
'#size' => 2,
|
||||
'#maxlength' => 2,
|
||||
'#description' => t('Changes the number of recent items listed for the "Content" list. (<b>if set to 0 it renders this list null.</b>)')
|
||||
);
|
||||
return system_settings_form($form);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
function user_details_help_form($form) {
|
||||
$intro = t('The "User Details" module comes with two blocks, "User Detils: logged-in user" and "User Details: authored user".');
|
||||
$intro .= '<br/><br/>';
|
||||
|
||||
$background = '<h3>' . t('Background') . '</h3>';
|
||||
$background .= t('The idea for "User Details" started as a request from an end-user, to have a centreal place for quick links to important locations on the website.') . '<br>';
|
||||
$background .= t('For Drupal 6 this was just some <a href="http://drupal.org/node/395578">custom code</a> you could add to a custom block.') . '<br/>';
|
||||
$background .= t('For Drupal 7 the "User Details" module has expanded to its own module, which allows non-coders to alter and customize to thier liking.');
|
||||
$background .= '<br/><br/>';
|
||||
|
||||
$overview = '<h3>' . t('Overview') . '</h3>';
|
||||
$overview .= t('The "User Details" module is a basic collection of user data (or variables) and commonly used links in a block. In no way is this a required part of any website, only for the ease of naviagtion.') . '<br/>';
|
||||
$overview .= t('Below is a list of all the stats and links that can be turned on as part of the "User Details" blocks.');
|
||||
$overview .= t('The links come with some default images, but you can change these by uploading an image to your web server and typing in the location for each image.');
|
||||
$overview .= '<br/><br/>';
|
||||
$overview_loggedin = '<div class="overview-loggedin" style="width: 48%; float: left;">';
|
||||
$overview_loggedin .= '<h3>' . t('User Details: loggedin user') . '</h3>';
|
||||
$overview_loggedin .= '<ul>';
|
||||
$overview_loggedin .= '<li>' . t('User avatar') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Joined date') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Post count') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('User points') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Role') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Unread private messeges') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Homepage link') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Profile link') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Profile edit link') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Private message link') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Create link') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Admin link') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Panels link') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Views link') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Performance link') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Logout link') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Custom link one') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Custom link two') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Custom link three') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Custom link four') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Custom link five') . '</li>';
|
||||
$overview_loggedin .= '<li>' . t('Recent Content') . '</li>';
|
||||
$overview_loggedin .= '</ul>';
|
||||
$overview_loggedin .= '</div>';
|
||||
$overview_authored = '<div class="overview-authored" style="width: 48%; float: left;">';
|
||||
$overview_authored .= '<h3>' . t('User Details: authored user') . '</h3>';
|
||||
$overview_authored .= '<ul>';
|
||||
$overview_authored .= '<li>' . t('User avatar') . '</li>';
|
||||
$overview_authored .= '<li>' . t('Joined date') . '</li>';
|
||||
$overview_authored .= '<li>' . t('Post count') . '</li>';
|
||||
$overview_authored .= '<li>' . t('User points') . '</li>';
|
||||
$overview_authored .= '<li>' . t('Role') . '</li>';
|
||||
$overview_authored .= '<li>' . t('Profile link') . '</li>';
|
||||
$overview_authored .= '<li>' . t('Private message link') . '</li>';
|
||||
$overview_authored .= '<li>' . t('Recent Content') . '</li>';
|
||||
$overview_authored .= '</ul>';
|
||||
$overview_authored .= '</div>';
|
||||
$closing = '<div style="float: none; clear: both;">';
|
||||
$closing .= '<br/><br/>';
|
||||
$closing .= t('NOTE:') . '<br/>';
|
||||
$closing .= t('*All users will be able to see: stats, user links content list.') . '<br/>';
|
||||
$closing .= t('*All admin will be able to see: stats, user links, content list and admin links.') . '<br/>';
|
||||
$closing .= t('*The custom links have a dropdown menu to determine which type of user will be able to view them.');
|
||||
$closing .= '<br/><br/>';
|
||||
$closing .= t('This module is under active development. Any feature request, bug report or issue you might find, please make a new issue in the ') . '<a href="http://drupal.org/project/issues/user_details?categories=All">' . t('"User Details" issue queue') . '</a>.';
|
||||
$closing .= '</div>';
|
||||
$hr = '<hr>';
|
||||
|
||||
$form['intro']['markup'] = array(
|
||||
'#markup' => $intro,
|
||||
);
|
||||
$form['background']['markup'] = array(
|
||||
'#markup' => $background,
|
||||
);
|
||||
$form['overview']['markup'] = array(
|
||||
'#markup' => $overview,
|
||||
);
|
||||
$form['overview_loggedin']['markup'] = array(
|
||||
'#markup' => $overview_loggedin,
|
||||
);
|
||||
$form['overview_authored']['markup'] = array(
|
||||
'#markup' => $overview_authored,
|
||||
);
|
||||
$form['closing']['markup'] = array(
|
||||
'#markup' => $closing,
|
||||
);
|
||||
$form['hr']['markup'] = array(
|
||||
'#markup' => $hr,
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
?>
|
||||