initial commit of starter install drupal 7
@@ -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 2014-07-08
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "logintoboggan"
|
||||
datestamp = "1404818634"
|
||||
|
||||
@@ -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 2014-07-08
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "logintoboggan"
|
||||
datestamp = "1404818634"
|
||||
|
||||
@@ -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 2014-07-08
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "logintoboggan"
|
||||
datestamp = "1404818634"
|
||||
|
||||
@@ -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 2014-07-08
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "logintoboggan"
|
||||
datestamp = "1404818634"
|
||||
|
||||
@@ -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,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,64 @@
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Profile2
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Maintainers:
|
||||
* Wolfgang Ziegler (fago), nuppla@zites.net
|
||||
* Joachim Noreiko (joachim), joachim.n+drupal@gmail.com
|
||||
|
||||
|
||||
This modules is designed to be the successor of the core profile module. In
|
||||
contrast to the core module this module provides a new, fieldable 'profile'
|
||||
entity - leverage the power of fields!
|
||||
|
||||
|
||||
Installation
|
||||
-------------
|
||||
|
||||
* Copy the whole profile2 directory to your modules directory and
|
||||
activate the module.
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
* Go to /admin/structure/profiles for managing profile types.
|
||||
* By default users may view their profile at /user and edit them at
|
||||
'user/X/edit'.
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Profile pages
|
||||
--------------------------------------------------------------------------------
|
||||
Maintainers:
|
||||
* Wolfgang Ziegler (fago), nuppla@zites.net
|
||||
|
||||
This module provides an alternative way for your users to edit their profiles.
|
||||
Instead of integrating with the user account page, it generates a separate page
|
||||
allowing your users to view and edit their profile.
|
||||
|
||||
|
||||
Installation
|
||||
-------------
|
||||
|
||||
* Once profile2 is installed, just active the profile pages module.
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
* The module may be enabled per profile-type by checking the checkbox
|
||||
"Provide a separate page for editing profiles." in the profile type's
|
||||
settings.
|
||||
* Users with sufficient permissions (check user permissions) receive a menu
|
||||
item in their user menu, just beside the "My account" menu item.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
General notes
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
* Automatic profile labels can be easily generated based upon a pre-configured
|
||||
pattern using the Rules module. See http://drupal.org/node/1392716 for more
|
||||
details.
|
||||
@@ -0,0 +1,13 @@
|
||||
name = Profile2 translation
|
||||
description = Translate profile2 types.
|
||||
dependencies[] = profile2
|
||||
dependencies[] = i18n_string
|
||||
package = Multilingual - Internationalization
|
||||
core = 7.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-05-24
|
||||
version = "7.x-1.2+7-dev"
|
||||
core = "7.x"
|
||||
project = "profile2"
|
||||
datestamp = "1337819774"
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Profile2 i18n integration module via entity API i18n support.
|
||||
*
|
||||
* @see EntityDefaultI18nController
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_entity_info_alter().
|
||||
*/
|
||||
function profile2_i18n_entity_info_alter(&$info) {
|
||||
// Enable i18n support via the entity API.
|
||||
$info['profile2_type']['i18n controller class'] = 'EntityDefaultI18nStringController';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_entity_property_info_alter().
|
||||
*/
|
||||
function profile2_i18n_entity_property_info_alter(&$info) {
|
||||
// Mark some properties as translatable, but also denote that translation
|
||||
// works with i18n_string.
|
||||
foreach (array('label') as $name) {
|
||||
$info['profile2_type']['properties'][$name]['translatable'] = TRUE;
|
||||
$info['profile2_type']['properties'][$name]['i18n string'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_insert().
|
||||
*/
|
||||
function profile2_i18n_profile2_type_insert($profile_type) {
|
||||
i18n_string_object_update('profile2_type', $profile_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_update().
|
||||
*/
|
||||
function profile2_i18n_profile2_type_update($profile_type) {
|
||||
// Account for name changes.
|
||||
if ($profile_type->original->type != $profile_type->type) {
|
||||
i18n_string_update_context("profile2:profile2_type:{$profile_type->original->type}:*", "profile2:profile2_type:{$profile_type->type}:*");
|
||||
}
|
||||
i18n_string_object_update('profile2_type', $profile_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_delete().
|
||||
*/
|
||||
function profile2_i18n_profile2_type_delete($profile_type) {
|
||||
i18n_string_object_remove('profile2_type', $profile_type);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
name = Profile2 group access
|
||||
description = Adds Organic groups permissions to control profile access on the group level.
|
||||
core = 7.x
|
||||
dependencies[] = profile2
|
||||
dependencies[] = og
|
||||
package = "Organic groups"
|
||||
; Information added by drupal.org packaging script on 2012-05-24
|
||||
version = "7.x-1.2+7-dev"
|
||||
core = "7.x"
|
||||
project = "profile2"
|
||||
datestamp = "1337819774"
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Profile2 og access integration module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_og_permission().
|
||||
*/
|
||||
function profile2_og_access_og_permission() {
|
||||
$permissions = array();
|
||||
// Generate per profile type permissions.
|
||||
foreach (profile2_get_types() as $type) {
|
||||
$type_name = check_plain($type->type);
|
||||
$permissions += array(
|
||||
"edit any $type_name profile" => array(
|
||||
'title' => t('%type_name: Edit any profile', array('%type_name' => $type->label)),
|
||||
),
|
||||
"view any $type_name profile" => array(
|
||||
'title' => t('%type_name: View any profile', array('%type_name' => $type->label)),
|
||||
),
|
||||
);
|
||||
}
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_access().
|
||||
*
|
||||
* @see profile2_profile2_access()
|
||||
*/
|
||||
function profile2_og_access_profile2_access($op, $profile = NULL, $account = NULL) {
|
||||
if (isset($profile) && ($type_name = $profile->type) && $profile->identifier() && $op != 'delete') {
|
||||
// Only return TRUE if og grants access. So other modules may still grant
|
||||
// access in case og does not.
|
||||
if (og_user_access_entity("$op any $type_name profile", 'profile2', $profile, $account)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Adds separate pages for viewing and editing profiles.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Shows the profile page for the current user.
|
||||
*
|
||||
* @see user_page()
|
||||
*/
|
||||
function profile2_page_own($base_path) {
|
||||
global $user;
|
||||
if ($user->uid) {
|
||||
menu_set_active_item($base_path . '/' . $user->uid);
|
||||
return menu_execute_active_handler(NULL, FALSE);
|
||||
}
|
||||
else {
|
||||
return drupal_get_form('user_login');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile view page.
|
||||
*/
|
||||
function profile2_page_view($profile) {
|
||||
return $profile->view('page');
|
||||
}
|
||||
|
||||
/**
|
||||
* The profile edit form.
|
||||
*/
|
||||
function profile2_form($form, &$form_state, $profile) {
|
||||
if (empty($form_state['profiles'])) {
|
||||
$form_state['profiles'][$profile->type] = $profile;
|
||||
}
|
||||
// Prevent invoking the same hooks twice, so tell profile2_attach_form() to
|
||||
// skip invoking the hooks.
|
||||
$form_state['profile2_skip_hook'] = TRUE;
|
||||
profile2_attach_form($form, $form_state);
|
||||
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
'#weight' => 40,
|
||||
);
|
||||
if (empty($profile->is_new) && user_access('administer profiles')) {
|
||||
$form['actions']['delete'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Delete profile'),
|
||||
'#weight' => 45,
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array('profile2_form_submit_delete')
|
||||
);
|
||||
}
|
||||
$form['#submit'][] = 'profile2_form_submit';
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile form submit handler.
|
||||
*/
|
||||
function profile2_form_submit($form, &$form_state) {
|
||||
// The profile is being saved by profile2_form_submit_handler().
|
||||
drupal_set_message(t('The changes have been saved.'));
|
||||
$form_state['redirect'] = $form_state['profile2']->path();
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile form submit handler for the delete button.
|
||||
*/
|
||||
function profile2_form_submit_delete($form, &$form_state) {
|
||||
$form_state['redirect'] = $form_state['profile2']->path() . '/delete';
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm form for deleting a profile.
|
||||
*/
|
||||
function profile2_page_delete_confirm_form($form, &$form_state, $profile) {
|
||||
$form_state += array('profile2' => $profile);
|
||||
$confirm_question = t('Are you sure you want to delete profile %label?', array('%label' => $profile->label()));
|
||||
return confirm_form($form, $confirm_question, $profile->path());
|
||||
}
|
||||
|
||||
function profile2_page_delete_confirm_form_submit($form, &$form_state) {
|
||||
$profile = $form_state['profile2'];
|
||||
$profile->delete();
|
||||
drupal_set_message(t('Deleted %label.', array('%label' => $profile->label)));
|
||||
$form_state['redirect'] = 'user/' . $profile->uid;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
name = Profile2 pages
|
||||
description = Adds separate pages for viewing and editing profiles.
|
||||
core = 7.x
|
||||
dependencies[] = profile2
|
||||
; Information added by drupal.org packaging script on 2012-05-24
|
||||
version = "7.x-1.2+7-dev"
|
||||
core = "7.x"
|
||||
project = "profile2"
|
||||
datestamp = "1337819774"
|
||||
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Adds separate pages for viewing and editing profiles.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function profile2_page_menu() {
|
||||
$items = array();
|
||||
|
||||
// Bugfix for uninstalling the module, see http://drupal.org/node/1008346.
|
||||
if (!module_exists('profile2')) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (profile2_get_types() as $type_name => $type) {
|
||||
if (!empty($type->data['use_page'])) {
|
||||
$path = profile2_page_get_base_path($type);
|
||||
$count = count(explode('/', $path));
|
||||
|
||||
$items[$path] = array(
|
||||
'title callback' => 'profile2_page_title',
|
||||
'title arguments' => array($type_name),
|
||||
'page callback' => 'profile2_page_own',
|
||||
'page arguments' => array($path),
|
||||
'access callback' => 'user_access',
|
||||
'access arguments' => array("edit own $type_name profile"),
|
||||
'file' => 'profile2_page.inc',
|
||||
'menu_name' => 'user-menu',
|
||||
);
|
||||
|
||||
$items[$path . '/%profile2_by_uid'] = array(
|
||||
'title callback' => 'profile2_page_title',
|
||||
'title arguments' => array($type_name, $count),
|
||||
'page callback' => 'profile2_page_view',
|
||||
'page arguments' => array($count),
|
||||
'load arguments' => array($type_name),
|
||||
'access callback' => 'profile2_access',
|
||||
'access arguments' => array('view', $count),
|
||||
'file' => 'profile2_page.inc',
|
||||
// Copied over the following hack from user_menu() to avoid $path
|
||||
// appearing in the breadcrumb:
|
||||
//
|
||||
// By assigning a different menu name, this item (and all registered
|
||||
// child paths) are no longer considered as children of 'user'. When
|
||||
// accessing the user account pages, the preferred menu link that is
|
||||
// used to build the active trail (breadcrumb) will be found in this
|
||||
// menu (unless there is more specific link), so the link to 'user' will
|
||||
// not be in the breadcrumb.
|
||||
'menu_name' => 'navigation',
|
||||
);
|
||||
$items[$path . '/%profile2_by_uid/view'] = array(
|
||||
'title' => 'View',
|
||||
'type' => MENU_DEFAULT_LOCAL_TASK,
|
||||
'load arguments' => array($type_name),
|
||||
'weight' => -10,
|
||||
);
|
||||
$items[$path . '/%profile2_by_uid/edit'] = array(
|
||||
'page callback' => 'entity_ui_get_form',
|
||||
'page arguments' => array('profile2', $count),
|
||||
'load arguments' => array($type_name),
|
||||
'access callback' => 'profile2_access',
|
||||
'access arguments' => array('edit', $count),
|
||||
'title' => 'Edit',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
|
||||
'file' => 'profile2_page.inc',
|
||||
);
|
||||
$items[$path . '/%profile2_by_uid/delete'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('profile2_page_delete_confirm_form', $count),
|
||||
'load arguments' => array($type_name),
|
||||
'access callback' => 'profile2_access',
|
||||
'access arguments' => array('delete', $count),
|
||||
'title' => 'Delete',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'context' => MENU_CONTEXT_INLINE,
|
||||
'file' => 'profile2_page.inc',
|
||||
);
|
||||
// Devel integration.
|
||||
if (module_exists('devel')) {
|
||||
$devel_path = drupal_get_path('module', 'devel');
|
||||
$items[$path . '/%profile2_by_uid/devel'] = array(
|
||||
'title' => 'Devel',
|
||||
'page callback' => 'devel_load_object',
|
||||
'file' => 'devel.pages.inc',
|
||||
'file path' => $devel_path,
|
||||
'page arguments' => array('profile2', $count),
|
||||
'access arguments' => array('access devel information'),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 100,
|
||||
);
|
||||
$items[$path . '/%profile2_by_uid/devel/load'] = array(
|
||||
'title' => 'Load',
|
||||
'type' => MENU_DEFAULT_LOCAL_TASK,
|
||||
);
|
||||
$items[$path . '/%profile2_by_uid/devel/render'] = array(
|
||||
'title' => 'Render',
|
||||
'page callback' => 'devel_render_object',
|
||||
'page arguments' => array('profile2', $count),
|
||||
'access arguments' => array('access devel information'),
|
||||
'file' => 'devel.pages.inc',
|
||||
'file path' => $devel_path,
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 100,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu load callback.
|
||||
*
|
||||
* Returns the profile object for the given user. If there is none yet, a new
|
||||
* object is created.
|
||||
*/
|
||||
function profile2_by_uid_load($uid, $type_name) {
|
||||
if ($uid && is_numeric($uid) && ($account = user_load($uid))) {
|
||||
$profile = profile2_load_by_user($account, $type_name);
|
||||
if (!$profile) {
|
||||
$profile = profile2_create(array('type' => $type_name));
|
||||
$profile->setUser($account);
|
||||
$profile->is_new = TRUE;
|
||||
}
|
||||
return $profile;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base path to use as profile page.
|
||||
*/
|
||||
function profile2_page_get_base_path($profile_type) {
|
||||
// Allow for an easy customization of the page's base path.
|
||||
if (!empty($profile_type->data['page_path'])) {
|
||||
return $profile_type->data['page_path'];
|
||||
}
|
||||
return 'profile-' . $profile_type->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_forms().
|
||||
*/
|
||||
function profile2_page_forms($form_id, $args) {
|
||||
// For efficiency, only act if the third argument is 'profile2'.
|
||||
if (isset($args[2]) && is_string($args[2]) && $args[2] == 'profile2') {
|
||||
$info = entity_get_info('profile2');
|
||||
// Translate bundle form ids to the base form id 'profile2_form'.
|
||||
foreach ($info['bundles'] as $bundle => $bundle_info) {
|
||||
$forms['profile2_edit_' . $bundle . '_form']['callback'] = 'profile2_form';
|
||||
$forms['profile2_edit_' . $bundle . '_form']['wrapper callback'] = 'entity_ui_form_defaults';
|
||||
}
|
||||
return $forms;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_load().
|
||||
*/
|
||||
function profile2_page_profile2_type_load($types) {
|
||||
foreach ($types as $type) {
|
||||
if (!empty($type->data['use_page'])) {
|
||||
// Disable user categories and the user account view.
|
||||
$type->userCategory = FALSE;
|
||||
$type->userView = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_entity_info_alter().
|
||||
*/
|
||||
function profile2_page_entity_info_alter(&$entity_info) {
|
||||
// Add new view modes for the page.
|
||||
$entity_info['profile2']['view modes']['page'] = array(
|
||||
'label' => t('Profile page'),
|
||||
'custom settings' => FALSE,
|
||||
);
|
||||
$entity_info['profile2']['view modes']['teaser'] = array(
|
||||
'label' => t('Teaser'),
|
||||
'custom settings' => FALSE,
|
||||
);
|
||||
$entity_info['profile2']['uri callback'] = 'profile2_page_uri_callback';
|
||||
$entity_info['profile2']['form callback'] = 'profile2_page_form_callback';
|
||||
}
|
||||
|
||||
/**
|
||||
* URI callback pointing to the profile page.
|
||||
*
|
||||
* @see profile2_pages_entity_info_alter()
|
||||
*/
|
||||
function profile2_page_uri_callback($profile) {
|
||||
$type = $profile->type();
|
||||
if (!empty($type->data['use_page'])) {
|
||||
return array('path' => profile2_page_get_base_path($type) . '/' . $profile->uid);
|
||||
}
|
||||
// Fall back to the default callback.
|
||||
return $profile->defaultUri();
|
||||
}
|
||||
|
||||
/**
|
||||
* Form callback for entity_form().
|
||||
*/
|
||||
function profile2_page_form_callback($profile) {
|
||||
// Pre-populate the form-state with the right form include.
|
||||
$form_state = form_state_defaults();
|
||||
form_load_include($form_state, 'inc', 'profile2_page');
|
||||
return entity_ui_get_form('profile2', $profile, 'edit', $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu title callback.
|
||||
*/
|
||||
function profile2_page_title($type_name, $profile2 = NULL) {
|
||||
$type = profile2_get_types($type_name);
|
||||
// If no profile is given, we are at the general path pointing to the own
|
||||
// profile.
|
||||
if (!isset($profile2)) {
|
||||
return t('My @profile-label', array('@profile-label' => drupal_strtolower($type->getTranslation('label'))));
|
||||
}
|
||||
return drupal_ucfirst($profile2->label());
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter() for the profile2 type form..
|
||||
*/
|
||||
function profile2_page_form_profile2_type_form_alter(&$form, &$form_state) {
|
||||
$type = $form_state['profile2_type'];
|
||||
$form['data']['use_page'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Provide a separate page for editing profiles.'),
|
||||
'#description' => t('If enabled, a separate menu item for editing the profile is generated and the profile is hidden from the user account page.'),
|
||||
'#default_value' => !empty($type->is_new) || !empty($type->data['use_page']),
|
||||
);
|
||||
$form['data']['#tree'] = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_insert().
|
||||
*/
|
||||
function profile2_page_profile2_type_insert(ProfileType $type) {
|
||||
// Do not directly issue menu rebuilds here to avoid potentially multiple
|
||||
// rebuilds. Instead, let menu_get_item() issue the rebuild on the next page.
|
||||
if (!empty($type->data['use_page'])) {
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_update().
|
||||
*/
|
||||
function profile2_page_profile2_type_update(ProfileType $type) {
|
||||
// Rebuild the menu if use_page or the type name has been changed.
|
||||
// @see profile2_page_profile2_type_insert()
|
||||
if (empty($type->data['use_page']) != empty($type->original->data['use_page']) || ($type->data['use_page'] && $type->type != $type->original->type)) {
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_delete()
|
||||
*/
|
||||
function profile2_page_profile2_type_delete($type) {
|
||||
// Do not directly issue menu rebuilds here to avoid potentially multiple
|
||||
// rebuilds. Instead, let menu_get_item() issue the rebuild on the next page.
|
||||
if (!empty($type->data['use_page'])) {
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Profile type editing UI.
|
||||
*/
|
||||
|
||||
/**
|
||||
* UI controller.
|
||||
*/
|
||||
class Profile2TypeUIController extends EntityDefaultUIController {
|
||||
|
||||
/**
|
||||
* Overrides hook_menu() defaults.
|
||||
*/
|
||||
public function hook_menu() {
|
||||
$items = parent::hook_menu();
|
||||
$items[$this->path]['description'] = 'Manage profiles, including fields.';
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the profile type editing form.
|
||||
*/
|
||||
function profile2_type_form($form, &$form_state, $profile_type, $op = 'edit') {
|
||||
|
||||
if ($op == 'clone') {
|
||||
$profile_type->label .= ' (cloned)';
|
||||
$profile_type->type = '';
|
||||
}
|
||||
|
||||
$form['label'] = array(
|
||||
'#title' => t('Label'),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $profile_type->label,
|
||||
'#description' => t('The human-readable name of this profile type.'),
|
||||
'#required' => TRUE,
|
||||
'#size' => 30,
|
||||
);
|
||||
// Machine-readable type name.
|
||||
$form['type'] = array(
|
||||
'#type' => 'machine_name',
|
||||
'#default_value' => isset($profile_type->type) ? $profile_type->type : '',
|
||||
'#maxlength' => 32,
|
||||
'#disabled' => $profile_type->isLocked() && $op != 'clone',
|
||||
'#machine_name' => array(
|
||||
'exists' => 'profile2_get_types',
|
||||
'source' => array('label'),
|
||||
),
|
||||
'#description' => t('A unique machine-readable name for this profile type. It must only contain lowercase letters, numbers, and underscores.'),
|
||||
);
|
||||
|
||||
$form['data']['#tree'] = TRUE;
|
||||
$form['data']['registration'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show during user account registration.'),
|
||||
'#default_value' => !empty($profile_type->data['registration']),
|
||||
);
|
||||
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save profile type'),
|
||||
'#weight' => 40,
|
||||
);
|
||||
|
||||
if (!$profile_type->isLocked() && $op != 'add' && $op != 'clone') {
|
||||
$form['actions']['delete'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Delete profile type'),
|
||||
'#weight' => 45,
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array('profile2_type_form_submit_delete')
|
||||
);
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form API submit callback for the type form.
|
||||
*/
|
||||
function profile2_type_form_submit(&$form, &$form_state) {
|
||||
$profile_type = entity_ui_form_submit_build_entity($form, $form_state);
|
||||
// Save and go back.
|
||||
$profile_type->save();
|
||||
$form_state['redirect'] = 'admin/structure/profiles';
|
||||
}
|
||||
|
||||
/**
|
||||
* Form API submit callback for the delete button.
|
||||
*/
|
||||
function profile2_type_form_submit_delete(&$form, &$form_state) {
|
||||
$form_state['redirect'] = 'admin/structure/profiles/manage/' . $form_state['profile2_type']->type . '/delete';
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file contains no working PHP code; it exists to provide additional
|
||||
* documentation for doxygen as well as to document hooks in the standard
|
||||
* Drupal manner.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup hooks
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Act on profiles being loaded from the database.
|
||||
*
|
||||
* This hook is invoked during profile loading, which is handled by
|
||||
* entity_load(), via the EntityCRUDController.
|
||||
*
|
||||
* @param $entities
|
||||
* An array of profile2 entities being loaded, keyed by id.
|
||||
*
|
||||
* @see hook_entity_load()
|
||||
*/
|
||||
function hook_profile2_load($entities) {
|
||||
$result = db_query('SELECT pid, foo FROM {mytable} WHERE pid IN(:ids)', array(':ids' => array_keys($entities)));
|
||||
foreach ($result as $record) {
|
||||
$entities[$record->pid]->foo = $record->foo;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond when a profile is inserted.
|
||||
*
|
||||
* This hook is invoked after the profile is inserted into the database.
|
||||
*
|
||||
* @param profile
|
||||
* The profile that is being inserted.
|
||||
*
|
||||
* @see hook_entity_insert()
|
||||
*/
|
||||
function hook_profile2_insert($profile) {
|
||||
db_insert('mytable')
|
||||
->fields(array(
|
||||
'pid' => $profile->pid,
|
||||
'extra' => $profile->extra,
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Act on a profile being inserted or updated.
|
||||
*
|
||||
* This hook is invoked before the profile is saved to the database.
|
||||
*
|
||||
* @param $profile
|
||||
* The profile that is being inserted or updated.
|
||||
*
|
||||
* @see hook_entity_presave()
|
||||
*/
|
||||
function hook_profile2_presave($profile) {
|
||||
$profile->extra = 'foo';
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond to a profile being updated.
|
||||
*
|
||||
* This hook is invoked after the profile has been updated in the database.
|
||||
*
|
||||
* @param $profile
|
||||
* The $profile that is being updated.
|
||||
*
|
||||
* @see hook_entity_update()
|
||||
*/
|
||||
function hook_profile2_update($profile) {
|
||||
db_update('mytable')
|
||||
->fields(array('extra' => $profile->extra))
|
||||
->condition('pid', $profile->pid)
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond to profile deletion.
|
||||
*
|
||||
* This hook is invoked after the profile has been removed from the database.
|
||||
*
|
||||
* @param $profile
|
||||
* The profile that is being deleted.
|
||||
*
|
||||
* @see hook_entity_delete()
|
||||
*/
|
||||
function hook_profile2_delete($profile) {
|
||||
db_delete('mytable')
|
||||
->condition('pid', $profile->pid)
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Act on a profile that is being assembled before rendering.
|
||||
*
|
||||
* @param $profile
|
||||
* The profile entity.
|
||||
* @param $view_mode
|
||||
* The view mode the profile is rendered in.
|
||||
* @param $langcode
|
||||
* The language code used for rendering.
|
||||
*
|
||||
* The module may add elements to $profile->content prior to rendering. The
|
||||
* structure of $profile->content is a renderable array as expected by
|
||||
* drupal_render().
|
||||
*
|
||||
* @see hook_entity_prepare_view()
|
||||
* @see hook_entity_view()
|
||||
*/
|
||||
function hook_profile2_view($profile, $view_mode, $langcode) {
|
||||
$profile->content['my_additional_field'] = array(
|
||||
'#markup' => $additional_field,
|
||||
'#weight' => 10,
|
||||
'#theme' => 'mymodule_my_additional_field',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter the results of entity_view() for profiles.
|
||||
*
|
||||
* @param $build
|
||||
* A renderable array representing the profile content.
|
||||
*
|
||||
* This hook is called after the content has been assembled in a structured
|
||||
* array and may be used for doing processing which requires that the complete
|
||||
* profile content structure has been built.
|
||||
*
|
||||
* If the module wishes to act on the rendered HTML of the profile rather than
|
||||
* the structured content array, it may use this hook to add a #post_render
|
||||
* callback. Alternatively, it could also implement hook_preprocess_profile2().
|
||||
* See drupal_render() and theme() documentation respectively for details.
|
||||
*
|
||||
* @see hook_entity_view_alter()
|
||||
*/
|
||||
function hook_profile2_view_alter($build) {
|
||||
if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
|
||||
// Change its weight.
|
||||
$build['an_additional_field']['#weight'] = -10;
|
||||
|
||||
// Add a #post_render callback to act on the rendered HTML of the entity.
|
||||
$build['#post_render'][] = 'my_module_post_render';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Act on profile type being loaded from the database.
|
||||
*
|
||||
* This hook is invoked during profile type loading, which is handled by
|
||||
* entity_load(), via the EntityCRUDController.
|
||||
*
|
||||
* @param $types
|
||||
* An array of profiles being loaded, keyed by profile type names.
|
||||
*/
|
||||
function hook_profile2_type_load($types) {
|
||||
if (isset($types['main'])) {
|
||||
$types['main']->userCategory = FALSE;
|
||||
$types['main']->userView = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond when a profile type is inserted.
|
||||
*
|
||||
* This hook is invoked after the profile type is inserted into the database.
|
||||
*
|
||||
* @param $type
|
||||
* The profile type that is being inserted.
|
||||
*/
|
||||
function hook_profile2_type_insert($type) {
|
||||
db_insert('mytable')
|
||||
->fields(array(
|
||||
'id' => $type->id,
|
||||
'extra' => $type->extra,
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Act on a profile type being inserted or updated.
|
||||
*
|
||||
* This hook is invoked before the profile type is saved to the database.
|
||||
*
|
||||
* @param $type
|
||||
* The profile type that is being inserted or updated.
|
||||
*/
|
||||
function hook_profile2_type_presave($type) {
|
||||
$type->extra = 'foo';
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond to updates to a profile.
|
||||
*
|
||||
* This hook is invoked after the profile type has been updated in the database.
|
||||
*
|
||||
* @param $type
|
||||
* The profile type that is being updated.
|
||||
*/
|
||||
function hook_profile2_type_update($type) {
|
||||
db_update('mytable')
|
||||
->fields(array('extra' => $type->extra))
|
||||
->condition('id', $type->id)
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond to profile type deletion.
|
||||
*
|
||||
* This hook is invoked after the profile type has been removed from the
|
||||
* database.
|
||||
*
|
||||
* @param $type
|
||||
* The profile type that is being deleted.
|
||||
*/
|
||||
function hook_profile2_type_delete($type) {
|
||||
db_delete('mytable')
|
||||
->condition('id', $type->id)
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define default profile type configurations.
|
||||
*
|
||||
* @return
|
||||
* An array of default profile types, keyed by profile type names.
|
||||
*/
|
||||
function hook_default_profile2_type() {
|
||||
$types['main'] = new ProfileType(array(
|
||||
'type' => 'main',
|
||||
'label' => t('Profile'),
|
||||
'weight' => 0,
|
||||
'locked' => TRUE,
|
||||
));
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter default profile type configurations.
|
||||
*
|
||||
* @param $defaults
|
||||
* An array of default profile types, keyed by type names.
|
||||
*
|
||||
* @see hook_default_profile2_type()
|
||||
*/
|
||||
function hook_default_profile2_type_alter(&$defaults) {
|
||||
$defaults['main']->label = 'custom label';
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter profile2 forms.
|
||||
*
|
||||
* Modules may alter the profile2 entity form regardless to which form it is
|
||||
* attached by making use of this hook or the profile type specifiy
|
||||
* hook_form_profile2_edit_PROFILE_TYPE_form_alter(). #entity_builders may be
|
||||
* used in order to copy the values of added form elements to the entity, just
|
||||
* as described by entity_form_submit_build_entity().
|
||||
*
|
||||
* @param $form
|
||||
* Nested array of form elements that comprise the form.
|
||||
* @param $form_state
|
||||
* A keyed array containing the current state of the form.
|
||||
*
|
||||
* @see profile2_attach_form()
|
||||
*/
|
||||
function hook_form_profile2_form_alter(&$form, &$form_state) {
|
||||
// Your alterations.
|
||||
}
|
||||
|
||||
/**
|
||||
* Control access to profiles.
|
||||
*
|
||||
* Modules may implement this hook if they want to have a say in whether or not
|
||||
* a given user has access to perform a given operation on a profile.
|
||||
*
|
||||
* @param $op
|
||||
* The operation being performed. One of 'view', 'edit' (being the same as
|
||||
* 'create' or 'update') and 'delete'.
|
||||
* @param $profile
|
||||
* (optional) A profile to check access for. If nothing is given, access for
|
||||
* all profiles is determined.
|
||||
* @param $account
|
||||
* (optional) The user to check for. If no account is passed, access is
|
||||
* determined for the global user.
|
||||
* @return boolean
|
||||
* Return TRUE to grant access, FALSE to explicitly deny access. Return NULL
|
||||
* or nothing to not affect the operation.
|
||||
* Access is granted as soon as a module grants access and no one denies
|
||||
* access. Thus if no module explicitly grants access, access will be denied.
|
||||
*
|
||||
* @see profile2_access()
|
||||
*/
|
||||
function hook_profile2_access($op, $profile = NULL, $account = NULL) {
|
||||
if (isset($profile)) {
|
||||
// Explicitly deny access for a 'secret' profile type.
|
||||
if ($profile->type == 'secret' && !user_access('custom permission')) {
|
||||
return FALSE;
|
||||
}
|
||||
// For profiles other than the default profile grant access.
|
||||
if ($profile->type != 'main' && user_access('custom permission')) {
|
||||
return TRUE;
|
||||
}
|
||||
// In other cases do not alter access.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,14 @@
|
||||
name = Profile2
|
||||
description = Supports configurable user profiles.
|
||||
core = 7.x
|
||||
files[] = profile2.admin.inc
|
||||
files[] = profile2.info.inc
|
||||
files[] = profile2.test
|
||||
dependencies[] = entity
|
||||
configure = admin/structure/profiles
|
||||
; Information added by drupal.org packaging script on 2012-05-24
|
||||
version = "7.x-1.2+7-dev"
|
||||
core = "7.x"
|
||||
project = "profile2"
|
||||
datestamp = "1337819774"
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides Entity metadata integration.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extend the defaults.
|
||||
*/
|
||||
class Profile2MetadataController extends EntityDefaultMetadataController {
|
||||
|
||||
public function entityPropertyInfo() {
|
||||
$info = parent::entityPropertyInfo();
|
||||
$properties = &$info[$this->type]['properties'];
|
||||
|
||||
$properties['label'] = array(
|
||||
'label' => t('Label'),
|
||||
'description' => t('The profile label.'),
|
||||
'setter callback' => 'entity_property_verbatim_set',
|
||||
'setter permission' => 'administer profiles',
|
||||
'schema field' => 'label',
|
||||
);
|
||||
|
||||
$properties['type'] = array(
|
||||
'type' => 'profile2_type',
|
||||
'getter callback' => 'entity_property_getter_method',
|
||||
'setter callback' => 'entity_property_verbatim_set',
|
||||
'setter permission' => 'administer profiles',
|
||||
'required' => TRUE,
|
||||
'description' => t('The profile type.'),
|
||||
) + $properties['type'];
|
||||
|
||||
unset($properties['uid']);
|
||||
|
||||
$properties['user'] = array(
|
||||
'label' => t("User"),
|
||||
'type' => 'user',
|
||||
'description' => t("The owner of the profile."),
|
||||
'getter callback' => 'entity_property_getter_method',
|
||||
'setter callback' => 'entity_property_setter_method',
|
||||
'setter permission' => 'administer profiles',
|
||||
'required' => TRUE,
|
||||
'schema field' => 'uid',
|
||||
);
|
||||
|
||||
$properties['created'] = array(
|
||||
'label' => t("Date created"),
|
||||
'type' => 'date',
|
||||
'description' => t("The date the profile was created."),
|
||||
'setter callback' => 'entity_property_verbatim_set',
|
||||
'setter permission' => 'administer profiles',
|
||||
'schema field' => 'created',
|
||||
);
|
||||
$properties['changed'] = array(
|
||||
'label' => t("Date changed"),
|
||||
'type' => 'date',
|
||||
'schema field' => 'changed',
|
||||
'description' => t("The date the profile was most recently updated."),
|
||||
);
|
||||
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_entity_property_info_alter().
|
||||
*/
|
||||
function profile2_entity_property_info_alter(&$info) {
|
||||
// Add related profiles to the user object.
|
||||
$properties = &$info['user']['properties'];
|
||||
foreach (profile2_get_types() as $type_name => $type) {
|
||||
$properties['profile_' . $type_name] = array(
|
||||
'type' => 'profile2',
|
||||
'label' => t('@type_name profile', array('@type_name' => drupal_ucfirst($type->label))),
|
||||
'description' => t("The users's @type_name profile.", array('@type_name' => $type->label)),
|
||||
'getter callback' => 'profile2_user_get_properties',
|
||||
'bundle' => $type_name,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the profile module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function profile2_install() {
|
||||
// Add an initial profile type, but only if installed manually. In case the
|
||||
// module is installed via an installation profile, skip that.
|
||||
if (!drupal_installation_attempted()) {
|
||||
$type = entity_create('profile2_type', array(
|
||||
'type' => 'main',
|
||||
'label' => t('Main profile'),
|
||||
'weight' => 0,
|
||||
'data' => array('registration' => TRUE, 'use_page' => TRUE),
|
||||
));
|
||||
$type->save();
|
||||
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('edit own main profile', 'view own main profile'));
|
||||
drupal_set_message(t('A main profile type has been created and assigned to all users. Go to the <a href="!url">Profile types</a> page to add some fields or to configure further profile types.', array('!url' => url('admin/structure/profiles'))));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_schema().
|
||||
*/
|
||||
function profile2_schema() {
|
||||
$schema['profile'] = array(
|
||||
'description' => 'Stores profile items.',
|
||||
'fields' => array(
|
||||
'pid' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary Key: Unique profile item ID.',
|
||||
),
|
||||
'type' => array(
|
||||
'description' => 'The {profile_type}.type of this profile.',
|
||||
'type' => 'varchar',
|
||||
'length' => 32,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'uid' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => FALSE,
|
||||
'default' => NULL,
|
||||
'description' => "The {users}.uid of the associated user.",
|
||||
),
|
||||
'label' => array(
|
||||
'description' => 'A human-readable label for this profile.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'created' => array(
|
||||
'description' => 'The Unix timestamp when the profile was created.',
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'changed' => array(
|
||||
'description' => 'The Unix timestamp when the profile was most recently saved.',
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'uid' => array('uid'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'uid' => array(
|
||||
'table' => 'users',
|
||||
'columns' => array('uid' => 'uid'),
|
||||
),
|
||||
'type' => array(
|
||||
'table' => 'profile_type',
|
||||
'columns' => array('type' => 'type'),
|
||||
),
|
||||
),
|
||||
'primary key' => array('pid'),
|
||||
);
|
||||
|
||||
$schema['profile_type'] = array(
|
||||
'description' => 'Stores information about all defined profile types.',
|
||||
'fields' => array(
|
||||
'id' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary Key: Unique profile type ID.',
|
||||
),
|
||||
'type' => array(
|
||||
'description' => 'The machine-readable name of this profile type.',
|
||||
'type' => 'varchar',
|
||||
'length' => 32,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'label' => array(
|
||||
'description' => 'The human-readable name of this profile type.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'weight' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'size' => 'tiny',
|
||||
'description' => 'The weight of this profile type in relation to others.',
|
||||
),
|
||||
'data' => array(
|
||||
'type' => 'text',
|
||||
'not null' => FALSE,
|
||||
'size' => 'big',
|
||||
'serialize' => TRUE,
|
||||
'description' => 'A serialized array of additional data related to this profile type.',
|
||||
),
|
||||
'status' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
// Set the default to ENTITY_CUSTOM without using the constant as it is
|
||||
// not safe to use it at this point.
|
||||
'default' => 0x01,
|
||||
'size' => 'tiny',
|
||||
'description' => 'The exportable status of the entity.',
|
||||
),
|
||||
'module' => array(
|
||||
'description' => 'The name of the providing module if the entity has been defined in code.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
'type' => array('type'),
|
||||
),
|
||||
);
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add in the exportable entity db columns as required by the entity API.
|
||||
*/
|
||||
function profile2_update_7100() {
|
||||
db_add_field('profile_type', 'status', array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => ENTITY_CUSTOM,
|
||||
'size' => 'tiny',
|
||||
'description' => 'The exportable status of the entity.',
|
||||
));
|
||||
db_add_field('profile_type', 'module', array(
|
||||
'description' => 'The name of the providing module if the entity has been defined in code.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a label column to profiles.
|
||||
*/
|
||||
function profile2_update_7101() {
|
||||
db_add_field('profile', 'label', array(
|
||||
'description' => 'A human-readable label for this profile.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
));
|
||||
$types = db_select('profile_type', 'p')
|
||||
->fields('p')
|
||||
->execute()
|
||||
->fetchAllAssoc('type');
|
||||
|
||||
// Initialize with the type label.
|
||||
foreach ($types as $type_name => $type) {
|
||||
db_update('profile')
|
||||
->fields(array(
|
||||
'label' => $type->label,
|
||||
))
|
||||
->condition('type', $type_name)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a created and a changed column to profiles.
|
||||
*/
|
||||
function profile2_update_7102() {
|
||||
db_add_field('profile', 'created', array(
|
||||
'description' => 'The Unix timestamp when the profile was created.',
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
));
|
||||
db_add_field('profile', 'changed', array(
|
||||
'description' => 'The Unix timestamp when the profile was most recently saved.',
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
));
|
||||
}
|
||||
@@ -0,0 +1,881 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Support for configurable user profiles.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_entity_info().
|
||||
*/
|
||||
function profile2_entity_info() {
|
||||
$return = array(
|
||||
'profile2' => array(
|
||||
'label' => t('Profile'),
|
||||
'plural label' => t('Profiles'),
|
||||
'description' => t('Profile2 user profiles.'),
|
||||
'entity class' => 'Profile',
|
||||
'controller class' => 'EntityAPIController',
|
||||
'base table' => 'profile',
|
||||
'fieldable' => TRUE,
|
||||
'view modes' => array(
|
||||
'account' => array(
|
||||
'label' => t('User account'),
|
||||
'custom settings' => FALSE,
|
||||
),
|
||||
),
|
||||
'entity keys' => array(
|
||||
'id' => 'pid',
|
||||
'bundle' => 'type',
|
||||
'label' => 'label',
|
||||
),
|
||||
'bundles' => array(),
|
||||
'bundle keys' => array(
|
||||
'bundle' => 'type',
|
||||
),
|
||||
'label callback' => 'entity_class_label',
|
||||
'uri callback' => 'entity_class_uri',
|
||||
'access callback' => 'profile2_access',
|
||||
'module' => 'profile2',
|
||||
'metadata controller class' => 'Profile2MetadataController'
|
||||
),
|
||||
);
|
||||
|
||||
// Add bundle info but bypass entity_load() as we cannot use it here.
|
||||
$types = db_select('profile_type', 'p')
|
||||
->fields('p')
|
||||
->execute()
|
||||
->fetchAllAssoc('type');
|
||||
|
||||
foreach ($types as $type => $info) {
|
||||
$return['profile2']['bundles'][$type] = array(
|
||||
'label' => $info->label,
|
||||
'admin' => array(
|
||||
'path' => 'admin/structure/profiles/manage/%profile2_type',
|
||||
'real path' => 'admin/structure/profiles/manage/' . $type,
|
||||
'bundle argument' => 4,
|
||||
'access arguments' => array('administer profiles'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Support entity cache module.
|
||||
if (module_exists('entitycache')) {
|
||||
$return['profile2']['field cache'] = FALSE;
|
||||
$return['profile2']['entity cache'] = TRUE;
|
||||
}
|
||||
|
||||
$return['profile2_type'] = array(
|
||||
'label' => t('Profile type'),
|
||||
'plural label' => t('Profile types'),
|
||||
'description' => t('Profiles types of Profile2 user profiles.'),
|
||||
'entity class' => 'ProfileType',
|
||||
'controller class' => 'EntityAPIControllerExportable',
|
||||
'base table' => 'profile_type',
|
||||
'fieldable' => FALSE,
|
||||
'bundle of' => 'profile2',
|
||||
'exportable' => TRUE,
|
||||
'entity keys' => array(
|
||||
'id' => 'id',
|
||||
'name' => 'type',
|
||||
'label' => 'label',
|
||||
),
|
||||
'access callback' => 'profile2_type_access',
|
||||
'module' => 'profile2',
|
||||
// Enable the entity API's admin UI.
|
||||
'admin ui' => array(
|
||||
'path' => 'admin/structure/profiles',
|
||||
'file' => 'profile2.admin.inc',
|
||||
'controller class' => 'Profile2TypeUIController',
|
||||
),
|
||||
);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu argument loader; Load a profile type by string.
|
||||
*
|
||||
* @param $type
|
||||
* The machine-readable name of a profile type to load.
|
||||
* @return
|
||||
* A profile type array or FALSE if $type does not exist.
|
||||
*/
|
||||
function profile2_type_load($type) {
|
||||
return profile2_get_types($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function profile2_permission() {
|
||||
$permissions = array(
|
||||
'administer profile types' => array(
|
||||
'title' => t('Administer profile types'),
|
||||
'description' => t('Create and delete fields on user profiles, and set their permissions.'),
|
||||
),
|
||||
'administer profiles' => array(
|
||||
'title' => t('Administer profiles'),
|
||||
'description' => t('Edit and view all user profiles.'),
|
||||
),
|
||||
);
|
||||
// Generate per profile type permissions.
|
||||
foreach (profile2_get_types() as $type) {
|
||||
$type_name = check_plain($type->type);
|
||||
$permissions += array(
|
||||
"edit own $type_name profile" => array(
|
||||
'title' => t('%type_name: Edit own profile', array('%type_name' => $type->getTranslation('label'))),
|
||||
),
|
||||
"edit any $type_name profile" => array(
|
||||
'title' => t('%type_name: Edit any profile', array('%type_name' => $type->getTranslation('label'))),
|
||||
),
|
||||
"view own $type_name profile" => array(
|
||||
'title' => t('%type_name: View own profile', array('%type_name' => $type->getTranslation('label'))),
|
||||
),
|
||||
"view any $type_name profile" => array(
|
||||
'title' => t('%type_name: View any profile', array('%type_name' => $type->getTranslation('label'))),
|
||||
),
|
||||
);
|
||||
}
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of all profile types, keyed by the type name.
|
||||
*
|
||||
* @param $type_name
|
||||
* If set, the type with the given name is returned.
|
||||
* @return ProfileType[]
|
||||
* Depending whether $type isset, an array of profile types or a single one.
|
||||
*/
|
||||
function profile2_get_types($type_name = NULL) {
|
||||
$types = entity_load_multiple_by_name('profile2_type', isset($type_name) ? array($type_name) : FALSE);
|
||||
return isset($type_name) ? reset($types) : $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a profile object.
|
||||
*
|
||||
* @param $pid
|
||||
* Integer specifying the profile id.
|
||||
* @param $reset
|
||||
* A boolean indicating that the internal cache should be reset.
|
||||
* @return
|
||||
* A fully-loaded $profile object or FALSE if it cannot be loaded.
|
||||
*
|
||||
* @see profile2_load_multiple()
|
||||
*/
|
||||
function profile2_load($pid, $reset = FALSE) {
|
||||
$profiles = profile2_load_multiple(array($pid), array(), $reset);
|
||||
return reset($profiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load multiple profiles based on certain conditions.
|
||||
*
|
||||
* @param $pids
|
||||
* An array of profile IDs.
|
||||
* @param $conditions
|
||||
* An array of conditions to match against the {profile} table.
|
||||
* @param $reset
|
||||
* A boolean indicating that the internal cache should be reset.
|
||||
* @return
|
||||
* An array of profile objects, indexed by pid.
|
||||
*
|
||||
* @see entity_load()
|
||||
* @see profile2_load()
|
||||
* @see profile2_load_by_user()
|
||||
*/
|
||||
function profile2_load_multiple($pids = array(), $conditions = array(), $reset = FALSE) {
|
||||
return entity_load('profile2', $pids, $conditions, $reset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch profiles by account.
|
||||
*
|
||||
* @param $account
|
||||
* The user account to load profiles for, or its uid.
|
||||
* @param $type_name
|
||||
* To load a single profile, pass the type name of the profile to load.
|
||||
* @return
|
||||
* Either a single profile or an array of profiles keyed by profile type.
|
||||
*
|
||||
* @see profile2_load_multiple()
|
||||
* @see profile2_profile2_delete()
|
||||
* @see Profile::save()
|
||||
*/
|
||||
function profile2_load_by_user($account, $type_name = NULL) {
|
||||
// Use a separate query to determine all profile ids per user and cache them.
|
||||
// That way we can look up profiles by id and benefit from the static cache
|
||||
// of the entity loader.
|
||||
$cache = &drupal_static(__FUNCTION__, array());
|
||||
$uid = is_object($account) ? $account->uid : $account;
|
||||
|
||||
if (!isset($cache[$uid])) {
|
||||
if (empty($type_name)) {
|
||||
$profiles = profile2_load_multiple(FALSE, array('uid' => $uid));
|
||||
// Cache ids for further lookups.
|
||||
$cache[$uid] = array();
|
||||
foreach ($profiles as $pid => $profile) {
|
||||
$cache[$uid][$profile->type] = $pid;
|
||||
}
|
||||
return $profiles ? array_combine(array_keys($cache[$uid]), $profiles) : array();
|
||||
}
|
||||
$cache[$uid] = db_select('profile', 'p')
|
||||
->fields('p', array('type', 'pid'))
|
||||
->condition('uid', $uid)
|
||||
->execute()
|
||||
->fetchAllKeyed();
|
||||
}
|
||||
if (isset($type_name)) {
|
||||
return isset($cache[$uid][$type_name]) ? profile2_load($cache[$uid][$type_name]) : FALSE;
|
||||
}
|
||||
// Return an array containing profiles keyed by profile type.
|
||||
return $cache[$uid] ? array_combine(array_keys($cache[$uid]), profile2_load_multiple($cache[$uid])) : $cache[$uid];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_delete().
|
||||
*/
|
||||
function profile2_profile2_delete($profile) {
|
||||
// Clear the static cache from profile2_load_by_user().
|
||||
$cache = &drupal_static('profile2_load_by_user', array());
|
||||
unset($cache[$profile->uid][$profile->type]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a profile.
|
||||
*/
|
||||
function profile2_delete(Profile $profile) {
|
||||
$profile->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete multiple profiles.
|
||||
*
|
||||
* @param $pids
|
||||
* An array of profile IDs.
|
||||
*/
|
||||
function profile2_delete_multiple(array $pids) {
|
||||
entity_get_controller('profile2')->delete($pids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_delete().
|
||||
*/
|
||||
function profile2_user_delete($account) {
|
||||
foreach (profile2_load_by_user($account) as $profile) {
|
||||
profile2_delete($profile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new profile object.
|
||||
*/
|
||||
function profile2_create(array $values) {
|
||||
return new Profile($values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated. Use profile2_create().
|
||||
*/
|
||||
function profile_create(array $values) {
|
||||
return new Profile($values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a profile to the database.
|
||||
*
|
||||
* @param $profile
|
||||
* The profile object.
|
||||
*/
|
||||
function profile2_save(Profile $profile) {
|
||||
return $profile->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a profile type to the db.
|
||||
*/
|
||||
function profile2_type_save(ProfileType $type) {
|
||||
$type->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a profile type from.
|
||||
*/
|
||||
function profile2_type_delete(ProfileType $type) {
|
||||
$type->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_delete()
|
||||
*/
|
||||
function profile2_profile2_type_delete(ProfileType $type) {
|
||||
// Delete all profiles of this type but only if this is not a revert.
|
||||
if (!$type->hasStatus(ENTITY_IN_CODE)) {
|
||||
$pids = array_keys(profile2_load_multiple(FALSE, array('type' => $type->type)));
|
||||
if ($pids) {
|
||||
profile2_delete_multiple($pids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_view().
|
||||
*/
|
||||
function profile2_user_view($account, $view_mode, $langcode) {
|
||||
foreach (profile2_get_types() as $type => $profile_type) {
|
||||
if ($profile_type->userView && $profile = profile2_load_by_user($account, $type)) {
|
||||
if (profile2_access('view', $profile)) {
|
||||
$account->content['profile_' . $type] = array(
|
||||
'#type' => 'user_profile_category',
|
||||
'#title' => t($profile->label),
|
||||
'#prefix' => '<a id="profile-' . $profile->type . '"></a>',
|
||||
);
|
||||
$account->content['profile_' . $type]['view'] = $profile->view('account');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter() for the user edit form.
|
||||
*
|
||||
* @see profile2_form_validate_handler
|
||||
* @see profile2_form_submit_handler
|
||||
*/
|
||||
function profile2_form_user_profile_form_alter(&$form, &$form_state) {
|
||||
if (($type = profile2_get_types($form['#user_category'])) && $type->userCategory) {
|
||||
if (empty($form_state['profiles'])) {
|
||||
$profile = profile2_load_by_user($form['#user'], $form['#user_category']);
|
||||
if (empty($profile)) {
|
||||
$profile = profile2_create(array('type' => $form['#user_category'], 'uid' => $form['#user']->uid));
|
||||
}
|
||||
$form_state['profiles'][$profile->type] = $profile;
|
||||
}
|
||||
profile2_attach_form($form, $form_state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter() for the registration form.
|
||||
*/
|
||||
function profile2_form_user_register_form_alter(&$form, &$form_state) {
|
||||
foreach (profile2_get_types() as $type_name => $profile_type) {
|
||||
if (!empty($profile_type->data['registration'])) {
|
||||
if (empty($form_state['profiles'][$type_name])) {
|
||||
$form_state['profiles'][$type_name] = profile2_create(array('type' => $type_name));
|
||||
}
|
||||
profile2_attach_form($form, $form_state);
|
||||
// Wrap each profile form in a fieldset.
|
||||
$form['profile_' . $type_name] += array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => check_plain($profile_type->getTranslation('label')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the profile forms of the profiles set in
|
||||
* $form_state['profiles'].
|
||||
*
|
||||
* Modules may alter the profile2 entity form regardless to which form it is
|
||||
* attached by making use of hook_form_profile2_form_alter().
|
||||
*
|
||||
* @param $form
|
||||
* The form to which to attach the profile2 form. For each profile the form
|
||||
* is added to @code $form['profile_' . $profile->type] @endcode. This helper
|
||||
* also adds in a validation and a submit handler caring for the attached
|
||||
* profile forms.
|
||||
*
|
||||
* @see hook_form_profile2_form_alter()
|
||||
* @see profile2_form_validate_handler()
|
||||
* @see profile2_form_submit_handler()
|
||||
*/
|
||||
function profile2_attach_form(&$form, &$form_state) {
|
||||
foreach ($form_state['profiles'] as $type => $profile) {
|
||||
$form['profile_' . $profile->type]['#tree'] = TRUE;
|
||||
$form['profile_' . $profile->type]['#parents'] = array('profile_' . $profile->type);
|
||||
field_attach_form('profile2', $profile, $form['profile_' . $profile->type], $form_state);
|
||||
|
||||
if (count(field_info_instances('profile2', $profile->type)) == 0) {
|
||||
$form['profile_' . $profile->type]['message'] = array(
|
||||
'#access' => user_access('administer profile types'),
|
||||
'#markup' => t('No fields have been associated with this profile type. Go to the <a href="!url">Profile types</a> page to add some fields.', array('!url' => url('admin/structure/profiles'))),
|
||||
);
|
||||
}
|
||||
|
||||
// Provide a central place for modules to alter the profile forms, but
|
||||
// skip that in case the caller cares about invoking the hooks.
|
||||
// @see profile2_form().
|
||||
if (!isset($form_state['profile2_skip_hook'])) {
|
||||
$hooks[] = 'form_profile2_edit_' . $type . '_form';
|
||||
$hooks[] = 'form_profile2_form';
|
||||
drupal_alter($hooks, $form, $form_state);
|
||||
}
|
||||
}
|
||||
$form['#validate'][] = 'profile2_form_validate_handler';
|
||||
$form['#submit'][] = 'profile2_form_submit_handler';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation handler for the profile form.
|
||||
*
|
||||
* @see profile2_attach_form()
|
||||
*/
|
||||
function profile2_form_validate_handler(&$form, &$form_state) {
|
||||
foreach ($form_state['profiles'] as $type => $profile) {
|
||||
if (isset($form_state['values']['profile_' . $profile->type])) {
|
||||
// @see entity_form_field_validate()
|
||||
$pseudo_entity = (object) $form_state['values']['profile_' . $profile->type];
|
||||
$pseudo_entity->type = $type;
|
||||
field_attach_form_validate('profile2', $pseudo_entity, $form['profile_' . $profile->type], $form_state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit handler that builds and saves all profiles in the form.
|
||||
*
|
||||
* @see profile2_attach_form()
|
||||
*/
|
||||
function profile2_form_submit_handler(&$form, &$form_state) {
|
||||
profile2_form_submit_build_profile($form, $form_state);
|
||||
// This is needed as some submit callbacks like user_register_submit() rely on
|
||||
// clean form values.
|
||||
profile2_form_submit_cleanup($form, $form_state);
|
||||
|
||||
foreach ($form_state['profiles'] as $type => $profile) {
|
||||
// During registration set the uid field of the newly created user.
|
||||
if (empty($profile->uid) && isset($form_state['user']->uid)) {
|
||||
$profile->uid = $form_state['user']->uid;
|
||||
}
|
||||
profile2_save($profile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit builder. Extracts the form values and updates the profile entities.
|
||||
*
|
||||
* @see profile2_attach_form()
|
||||
*/
|
||||
function profile2_form_submit_build_profile(&$form, &$form_state) {
|
||||
foreach ($form_state['profiles'] as $type => $profile) {
|
||||
// @see entity_form_submit_build_entity()
|
||||
if (isset($form['profile_' . $type]['#entity_builders'])) {
|
||||
foreach ($form['profile_' . $type]['#entity_builders'] as $function) {
|
||||
$function('profile2', $profile, $form['profile_' . $type], $form_state);
|
||||
}
|
||||
}
|
||||
field_attach_submit('profile2', $profile, $form['profile_' . $type], $form_state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up the form values as the user modules relies on clean values.
|
||||
*
|
||||
* @see profile2_attach_form()
|
||||
*/
|
||||
function profile2_form_submit_cleanup(&$form, &$form_state) {
|
||||
foreach ($form_state['profiles'] as $type => $profile) {
|
||||
unset($form_state['values']['profile_' . $type]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_categories().
|
||||
*/
|
||||
function profile2_user_categories() {
|
||||
$data = array();
|
||||
foreach (profile2_get_types() as $type => $info) {
|
||||
if ($info->userCategory) {
|
||||
$data[] = array(
|
||||
'name' => $type,
|
||||
'title' => $info->getTranslation('label'),
|
||||
// Add an offset so a weight of 0 appears right of the account category.
|
||||
'weight' => $info->weight + 3,
|
||||
'access callback' => 'profile2_category_access',
|
||||
'access arguments' => array(1, $type)
|
||||
);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu item access callback - check if a user has access to a profile category.
|
||||
*/
|
||||
function profile2_category_access($account, $type_name) {
|
||||
// As there might be no profile yet, create a new object for being able to run
|
||||
// a proper access check.
|
||||
$profile = profile2_create(array('type' => $type_name, 'uid' => $account->uid));
|
||||
return ($account->uid > 0 && $profile->type()->userCategory && profile2_access('edit', $profile));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the given user has access to a profile.
|
||||
*
|
||||
* @param $op
|
||||
* The operation being performed. One of 'view', 'update', 'create', 'delete'
|
||||
* or just 'edit' (being the same as 'create' or 'update').
|
||||
* @param $profile
|
||||
* (optional) A profile to check access for. If nothing is given, access for
|
||||
* all profiles is determined.
|
||||
* @param $account
|
||||
* The user to check for. Leave it to NULL to check for the global user.
|
||||
* @return boolean
|
||||
* Whether access is allowed or not.
|
||||
*
|
||||
* @see hook_profile2_access()
|
||||
* @see profile2_profile2_access()
|
||||
*/
|
||||
function profile2_access($op, $profile = NULL, $account = NULL) {
|
||||
if (user_access('administer profiles', $account)) {
|
||||
return TRUE;
|
||||
}
|
||||
if ($op == 'create' || $op == 'update') {
|
||||
$op = 'edit';
|
||||
}
|
||||
// Allow modules to grant / deny access.
|
||||
$access = module_invoke_all('profile2_access', $op, $profile, $account);
|
||||
|
||||
// Only grant access if at least one module granted access and no one denied
|
||||
// access.
|
||||
if (in_array(FALSE, $access, TRUE)) {
|
||||
return FALSE;
|
||||
}
|
||||
elseif (in_array(TRUE, $access, TRUE)) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_access().
|
||||
*/
|
||||
function profile2_profile2_access($op, $profile = NULL, $account = NULL) {
|
||||
// Don't grant access for users to delete their profile.
|
||||
if (isset($profile) && ($type_name = $profile->type) && $op != 'delete') {
|
||||
if (user_access("$op any $type_name profile", $account)) {
|
||||
return TRUE;
|
||||
}
|
||||
$account = isset($account) ? $account : $GLOBALS['user'];
|
||||
if (isset($profile->uid) && $profile->uid == $account->uid && user_access("$op own $type_name profile", $account)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
// Do not explicitly deny access so others may still grant access.
|
||||
}
|
||||
|
||||
/**
|
||||
* Access callback for the entity API.
|
||||
*/
|
||||
function profile2_type_access($op, $type = NULL, $account = NULL) {
|
||||
return user_access('administer profile types', $account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function profile2_theme() {
|
||||
return array(
|
||||
'profile2' => array(
|
||||
'render element' => 'elements',
|
||||
'template' => 'profile2',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class used for profile entities.
|
||||
*/
|
||||
class Profile extends Entity {
|
||||
|
||||
/**
|
||||
* The profile id.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $pid;
|
||||
|
||||
/**
|
||||
* The name of the profile type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* The profile label.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $label;
|
||||
|
||||
/**
|
||||
* The user id of the profile owner.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $uid;
|
||||
|
||||
/**
|
||||
* The Unix timestamp when the profile was created.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $created;
|
||||
|
||||
/**
|
||||
* The Unix timestamp when the profile was most recently saved.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $changed;
|
||||
|
||||
|
||||
public function __construct($values = array()) {
|
||||
if (isset($values['user'])) {
|
||||
$this->setUser($values['user']);
|
||||
unset($values['user']);
|
||||
}
|
||||
if (isset($values['type']) && is_object($values['type'])) {
|
||||
$values['type'] = $values['type']->type;
|
||||
}
|
||||
if (!isset($values['label']) && isset($values['type']) && $type = profile2_get_types($values['type'])) {
|
||||
// Initialize the label with the type label, so newly created profiles
|
||||
// have that as interim label.
|
||||
$values['label'] = $type->label;
|
||||
}
|
||||
parent::__construct($values, 'profile2');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user owning this profile.
|
||||
*/
|
||||
public function user() {
|
||||
return user_load($this->uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new user owning this profile.
|
||||
*
|
||||
* @param $account
|
||||
* The user account object or the user account id (uid).
|
||||
*/
|
||||
public function setUser($account) {
|
||||
$this->uid = is_object($account) ? $account->uid : $account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated profile type object.
|
||||
*
|
||||
* @return ProfileType
|
||||
*/
|
||||
public function type() {
|
||||
return profile2_get_types($this->type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full url() for the profile.
|
||||
*/
|
||||
public function url() {
|
||||
$uri = $this->uri();
|
||||
return url($uri['path'], $uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the drupal path to this profile.
|
||||
*/
|
||||
public function path() {
|
||||
$uri = $this->uri();
|
||||
return $uri['path'];
|
||||
}
|
||||
|
||||
public function defaultUri() {
|
||||
return array(
|
||||
'path' => 'user/' . $this->uid,
|
||||
'options' => array('fragment' => 'profile-' . $this->type),
|
||||
);
|
||||
}
|
||||
|
||||
public function defaultLabel() {
|
||||
if (module_exists('profile2_i18n')) {
|
||||
// Run the label through i18n_string() using the profile2_type label
|
||||
// context, so the default label (= the type's label) gets translated.
|
||||
return entity_i18n_string('profile2:profile2_type:' . $this->type . ':label', $this->label);
|
||||
}
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function buildContent($view_mode = 'full', $langcode = NULL) {
|
||||
$content = array();
|
||||
// Assume newly create objects are still empty.
|
||||
if (!empty($this->is_new)) {
|
||||
$content['empty']['#markup'] = '<em class="profile2-no-data">' . t('There is no profile data yet.') . '</em>';
|
||||
}
|
||||
return entity_get_controller($this->entityType)->buildContent($this, $view_mode, $langcode, $content);
|
||||
}
|
||||
|
||||
public function save() {
|
||||
// Care about setting created and changed values. But do not automatically
|
||||
// set a created values for already existing profiles.
|
||||
if (empty($this->created) && (!empty($this->is_new) || !$this->pid)) {
|
||||
$this->created = REQUEST_TIME;
|
||||
}
|
||||
$this->changed = REQUEST_TIME;
|
||||
|
||||
parent::save();
|
||||
// Update the static cache from profile2_load_by_user().
|
||||
$cache = &drupal_static('profile2_load_by_user', array());
|
||||
if (isset($cache[$this->uid])) {
|
||||
$cache[$this->uid][$this->type] = $this->pid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a separate class for profile types so we can specify some defaults
|
||||
* modules may alter.
|
||||
*/
|
||||
class ProfileType extends Entity {
|
||||
|
||||
/**
|
||||
* Whether the profile type appears in the user categories.
|
||||
*/
|
||||
public $userCategory = TRUE;
|
||||
|
||||
/**
|
||||
* Whether the profile is displayed on the user account page.
|
||||
*/
|
||||
public $userView = TRUE;
|
||||
|
||||
public $type;
|
||||
public $label;
|
||||
public $weight = 0;
|
||||
|
||||
public function __construct($values = array()) {
|
||||
parent::__construct($values, 'profile2_type');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the profile type is locked, thus may not be deleted or renamed.
|
||||
*
|
||||
* Profile types provided in code are automatically treated as locked, as well
|
||||
* as any fixed profile type.
|
||||
*/
|
||||
public function isLocked() {
|
||||
return isset($this->status) && empty($this->is_new) && (($this->status & ENTITY_IN_CODE) || ($this->status & ENTITY_FIXED));
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden, to introduce the method for old entity API versions (BC).
|
||||
*
|
||||
* @todo Remove once we bump the required entity API version.
|
||||
*/
|
||||
public function getTranslation($property, $langcode = NULL) {
|
||||
if (module_exists('profile2_i18n')) {
|
||||
return parent::getTranslation($property, $langcode);
|
||||
}
|
||||
return $this->$property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Entity::save().
|
||||
*/
|
||||
public function save() {
|
||||
parent::save();
|
||||
// Clear field info caches such that any changes to extra fields get
|
||||
// reflected.
|
||||
field_info_cache_clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* View a profile.
|
||||
*
|
||||
* @see Profile::view()
|
||||
*/
|
||||
function profile2_view($profile, $view_mode = 'full', $langcode = NULL, $page = NULL) {
|
||||
return $profile->view($view_mode, $langcode, $page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORMID_alter().
|
||||
*
|
||||
* Adds a checkbox for controlling field view access to fields added to
|
||||
* profiles.
|
||||
*/
|
||||
function profile2_form_field_ui_field_edit_form_alter(&$form, &$form_state) {
|
||||
if ($form['instance']['entity_type']['#value'] == 'profile2') {
|
||||
$form['field']['settings']['profile2_private'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Make the content of this field private.'),
|
||||
'#default_value' => !empty($form['#field']['settings']['profile2_private']),
|
||||
'#description' => t('If checked, the content of this field is only shown to the profile owner and administrators.'),
|
||||
);
|
||||
}
|
||||
else {
|
||||
// Add the value to the form so it isn't lost.
|
||||
$form['field']['settings']['profile2_private'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => !empty($form['#field']['settings']['profile2_private']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_access().
|
||||
*/
|
||||
function profile2_field_access($op, $field, $entity_type, $profile = NULL, $account = NULL) {
|
||||
if ($entity_type == 'profile2' && $op == 'view' && !empty($field['settings']['profile2_private']) && !user_access('administer profiles', $account)) {
|
||||
// For profiles, deny general view access for private fields.
|
||||
if (!isset($profile)) {
|
||||
return FALSE;
|
||||
}
|
||||
// Also deny view access, if someone else views a private field.
|
||||
$account = isset($account) ? $account : $GLOBALS['user'];
|
||||
if ($account->uid != $profile->uid) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_extra_fields().
|
||||
*
|
||||
* We need to add pseudo fields for profile types to allow for weight settings
|
||||
* when viewing a user or filling in the profile types while registrating.
|
||||
*/
|
||||
function profile2_field_extra_fields() {
|
||||
$extra = array();
|
||||
foreach (profile2_get_types() as $type_name => $type) {
|
||||
// Appears on: admin/config/people/accounts/display
|
||||
if (!empty($type->userView)) {
|
||||
$extra['user']['user']['display']['profile_' . $type_name] = array(
|
||||
'label' => t('Profile: @profile', array('@profile' => $type->label)),
|
||||
'weight' => $type->weight,
|
||||
);
|
||||
}
|
||||
// Appears on: admin/config/people/accounts/fields
|
||||
if (!empty($type->data['registration'])) {
|
||||
$extra['user']['user']['form']['profile_' . $type_name] = array(
|
||||
'label' => t('Profile: @profile', array('@profile' => $type->label)),
|
||||
'description' => t('Appears during registration only.'),
|
||||
'weight' => $type->weight,
|
||||
);
|
||||
}
|
||||
}
|
||||
return $extra;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity metadata callback to load profiles for the given user account.
|
||||
*/
|
||||
function profile2_user_get_properties($account, array $options, $name) {
|
||||
// Remove the leading 'profile_' from the property name to get the type name.
|
||||
$profile = profile2_load_by_user($account, substr($name, 8));
|
||||
return $profile ? $profile : NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Test basic CRUD functionality.
|
||||
*/
|
||||
class Profile2CRUDTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Editing profiles',
|
||||
'description' => 'Tests basic CRUD and editing of Profile2 profiles.',
|
||||
'group' => 'Profile2',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('profile2', 'locale');
|
||||
|
||||
profile2_type_save(new ProfileType(array(
|
||||
'type' => 'test',
|
||||
'label' => 'label',
|
||||
'weight' => 0
|
||||
)));
|
||||
profile2_type_save(new ProfileType(array(
|
||||
'type' => 'test2',
|
||||
'label' => 'label2',
|
||||
'weight' => 2
|
||||
)));
|
||||
profile2_load_multiple(FALSE, array(), TRUE);
|
||||
|
||||
// Add a field to main type, which is created during module installation.
|
||||
$field = array(
|
||||
'field_name' => 'profile_fullname',
|
||||
'type' => 'text',
|
||||
'cardinality' => 1,
|
||||
'translatable' => FALSE,
|
||||
);
|
||||
field_create_field($field);
|
||||
$instance = array(
|
||||
'entity_type' => 'profile2',
|
||||
'field_name' => 'profile_fullname',
|
||||
'bundle' => 'main',
|
||||
'label' => 'Full name',
|
||||
'description' => 'Specify your first and last name.',
|
||||
'widget' => array(
|
||||
'type' => 'text_textfield',
|
||||
'weight' => 0,
|
||||
),
|
||||
);
|
||||
field_create_instance($instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests CRUD for a profile related to a user and one unrelated to a user.
|
||||
*/
|
||||
function testCRUD() {
|
||||
$user1 = $this->drupalCreateUser();
|
||||
// Create profiles for the user1 and unrelated to a user.
|
||||
profile2_save(profile2_create(array('type' => 'test', 'uid' => $user1->uid)));
|
||||
profile2_save(profile2_create(array('type' => 'test2', 'uid' => $user1->uid)));
|
||||
$profile = profile2_create(array('type' => 'test', 'uid' => NULL));
|
||||
profile2_save($profile);
|
||||
|
||||
$profiles = profile2_load_by_user($user1);
|
||||
$this->assertEqual($profiles['test']->label(), 'label', 'Created and loaded profile 1.');
|
||||
$this->assertEqual($profiles['test2']->label(), 'label2', 'Created and loaded profile 2.');
|
||||
|
||||
// Test looking up from static cache works also.
|
||||
$profiles = profile2_load_by_user($user1);
|
||||
$this->assertEqual($profiles['test']->label, 'label', 'Looked up profiles again.');
|
||||
|
||||
$loaded = profile2_load($profile->pid);
|
||||
$this->assertEqual($loaded->pid, $profile->pid, 'Loaded profile unrelated to a user.');
|
||||
|
||||
profile2_delete($profiles['test']);
|
||||
$profiles2 = profile2_load_by_user($user1);
|
||||
$this->assertEqual(array_keys($profiles2), array('test2'), 'Profile successfully deleted.');
|
||||
|
||||
profile2_save($profiles2['test2']);
|
||||
$this->assertEqual($profiles['test2']->pid, $profiles2['test2']->pid, 'Profile successfully updated.');
|
||||
|
||||
// Delete a profile type.
|
||||
profile2_type_delete(profile2_get_types('test'));
|
||||
// Try deleting multiple profiles by deleting all existing profiles.
|
||||
$pids = array_keys(profile2_load_multiple(FALSE));
|
||||
profile2_delete_multiple($pids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test registration integration.
|
||||
*/
|
||||
function testRegistrationIntegration() {
|
||||
// Allow registration by site visitors without administrator approval.
|
||||
variable_set('user_register', 1);
|
||||
$edit = array();
|
||||
$edit['name'] = $name = $this->randomName();
|
||||
$edit['mail'] = $mail = $edit['name'] . '@example.com';
|
||||
$edit['profile_main[profile_fullname][und][0][value]'] = $this->randomName();
|
||||
$this->drupalPost('user/register', $edit, t('Create new account'));
|
||||
$this->assertText(t('A welcome message with further instructions has been sent to your e-mail address.'), t('User registered successfully.'));
|
||||
$return = user_load_multiple(array(), array('name' => $name, 'mail' => $mail));
|
||||
$new_user = reset($return);
|
||||
$this->assertTrue($new_user->status, t('New account is active after registration.'));
|
||||
$this->assertEqual(profile2_load_by_user($new_user, 'main')->profile_fullname[LANGUAGE_NONE][0]['value'], $edit['profile_main[profile_fullname][und][0][value]'], 'Profile created.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic edit and display.
|
||||
*/
|
||||
function testEditAndDisplay() {
|
||||
user_role_revoke_permissions(DRUPAL_AUTHENTICATED_RID, array('edit own main profile', 'view own main profile'));
|
||||
$user1 = $this->drupalCreateUser();
|
||||
$this->drupalLogin($user1);
|
||||
// Make sure access is denied to the profile.
|
||||
$this->drupalGet('user/' . $user1->uid . '/edit/main');
|
||||
$this->assertText(t('Access denied'), 'Access has been denied.');
|
||||
|
||||
// Test creating a profile manually (e.g. by an admin) and ensure the user
|
||||
// may not see it.
|
||||
profile2_create(array('type' => 'main', 'uid' => $user1->uid))->save();
|
||||
$this->drupalGet('user/' . $user1->uid);
|
||||
$this->assertNoText(t('Main profile'), 'Profile data is not visible to the owner.');
|
||||
|
||||
$user2 = $this->drupalCreateUser(array('edit own main profile', 'view own main profile'));
|
||||
$this->drupalLogin($user2);
|
||||
|
||||
// Create profiles for the user2.
|
||||
$edit['profile_main[profile_fullname][und][0][value]'] = $this->randomName();
|
||||
$this->drupalPost('user/' . $user2->uid . '/edit/main', $edit, t('Save'));
|
||||
$this->assertText(t('The changes have been saved.'), 'Profile saved.');
|
||||
$this->assertEqual(profile2_load_by_user($user2, 'main')->profile_fullname[LANGUAGE_NONE][0]['value'], $edit['profile_main[profile_fullname][und][0][value]'], 'Profile edited.');
|
||||
|
||||
$this->drupalGet('user/' . $user2->uid);
|
||||
$this->assertText(check_plain($edit['profile_main[profile_fullname][und][0][value]']), 'Profile displayed.');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation for profiles.
|
||||
*
|
||||
* Available variables:
|
||||
* - $content: An array of comment items. Use render($content) to print them all, or
|
||||
* print a subset such as render($content['field_example']). Use
|
||||
* hide($content['field_example']) to temporarily suppress the printing of a
|
||||
* given element.
|
||||
* - $title: The (sanitized) profile type label.
|
||||
* - $url: The URL to view the current profile.
|
||||
* - $page: TRUE if this is the main view page $url points too.
|
||||
* - $classes: String of classes that can be used to style contextually through
|
||||
* CSS. It can be manipulated through the variable $classes_array from
|
||||
* preprocess functions. By default the following classes are available, where
|
||||
* the parts enclosed by {} are replaced by the appropriate values:
|
||||
* - entity-profile
|
||||
* - profile-{TYPE}
|
||||
*
|
||||
* Other variables:
|
||||
* - $classes_array: Array of html class attribute values. It is flattened
|
||||
* into a string within the variable $classes.
|
||||
*
|
||||
* @see template_preprocess()
|
||||
* @see template_preprocess_entity()
|
||||
* @see template_process()
|
||||
*/
|
||||
?>
|
||||
<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
|
||||
|
||||
<?php if (!$page): ?>
|
||||
<h2<?php print $title_attributes; ?>>
|
||||
<a href="<?php print $url; ?>"><?php print $title; ?></a>
|
||||
</h2>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="content"<?php print $content_attributes; ?>>
|
||||
<?php
|
||||
print render($content);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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,12 @@
|
||||
name = Profile2 Sync Email
|
||||
description = Create a link between a profile email field and the user account field
|
||||
dependencies[] = profile2
|
||||
dependencies[] = email
|
||||
core = 7.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-04-06
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "profile_sync_email"
|
||||
datestamp = "1333740077"
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_permission()
|
||||
*/
|
||||
function profile_sync_email_permission() {
|
||||
return array(
|
||||
'administer profile sync email' => array(
|
||||
'title' => t('Administer Profile2 sync email'),
|
||||
'description' => t('Select profile email field to sync to user account email.'),
|
||||
),
|
||||
);
|
||||
} // profile_sync_email_permission()
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter()
|
||||
*/
|
||||
function profile_sync_email_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
|
||||
// if this is an email field on a profile
|
||||
if ($form['#field']['type'] == 'email' && $form['instance']['entity_type']['#value'] == 'profile2') {
|
||||
$sync_field = variable_get('profile_sync_email_instance', -1);
|
||||
$form['profile_sync_email'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Sync this email field to the user account'),
|
||||
'#description' => t('When checked, this field will update the user account email and vice versa.'),
|
||||
'#default_value' => ($sync_field == $form['#instance']['id'])? 1 : 0,
|
||||
);
|
||||
$form['#submit'][] = 'profile_sync_email_submit';
|
||||
} // if email on a profile
|
||||
} // profile_sync_email_form_alter()
|
||||
|
||||
/**
|
||||
* form submit
|
||||
*/
|
||||
function profile_sync_email_submit($form, &$form_state) {
|
||||
if (isset($form_state['values']['profile_sync_email']) && $form_state['values']['profile_sync_email'] == 1) {
|
||||
variable_set('profile_sync_email_instance', $form['#instance']['id']);
|
||||
} // if
|
||||
} // profile_sync_email_submit()
|
||||
|
||||
/**
|
||||
* hook_form_alter()
|
||||
*/
|
||||
function profile_sync_email_form_alter(&$form, &$form_state, $form_id) {
|
||||
// get the sync field info
|
||||
$instance_info = profile_sync_email_instance_info();
|
||||
|
||||
// if this form is for the profile
|
||||
if (isset($instance_info->bundle) && isset($instance_info->field_name) && isset($form['profile_' . $instance_info->bundle][$instance_info->field_name])) {
|
||||
|
||||
if (!isset($form_state['build_info']['args'][0]->uid) || !is_numeric($form_state['build_info']['args'][0]->uid)) return; // no user, end here
|
||||
|
||||
// load the user and set the email field
|
||||
$user = user_load($form_state['build_info']['args'][0]->uid);
|
||||
$field = &$form['profile_' . $instance_info->bundle][$instance_info->field_name];
|
||||
$field[$field['#language']][0]['email']['#default_value'] = $user->mail;
|
||||
|
||||
// add validation on the email field
|
||||
$field[$field['#language']][0]['email']['#element_validate'][] = 'profile_sync_email_validate_email';
|
||||
|
||||
} // if field exists
|
||||
} // profile_sync_email_form_alter()
|
||||
|
||||
/**
|
||||
* validation callback
|
||||
*/
|
||||
function profile_sync_email_validate_email($element, &$form_state, $form) {
|
||||
if (!empty($element['#value'])) {
|
||||
$email_user = user_load_by_mail($element['#value']);
|
||||
if (isset($email_user->uid) && $email_user->uid != $form_state['build_info']['args'][0]->uid) {
|
||||
form_error($element, t('The email address %email is being used by another user', array('%email' => $element['#value'])));
|
||||
}
|
||||
}
|
||||
} // profile_sync_email_validate_email()
|
||||
|
||||
|
||||
/**
|
||||
* hook_profile2_insert(), hook_profile2_update()
|
||||
*/
|
||||
function profile_sync_email_profile2_insert($profile) {
|
||||
profile_sync_email_profile2($profile);
|
||||
} // profile_sync_email_profile2_insert()
|
||||
function profile_sync_email_profile2_update($profile) {
|
||||
profile_sync_email_profile2($profile);
|
||||
} // profile_sync_email_profile2_update()
|
||||
|
||||
function profile_sync_email_profile2($profile) {
|
||||
$sync_field = profile_sync_email_instance_info();
|
||||
$user = user_load($profile->uid);
|
||||
if (isset($profile->{$sync_field->field_name}[LANGUAGE_NONE][0]['email'])) {
|
||||
$email = $profile->{$sync_field->field_name}[LANGUAGE_NONE][0]['email'];
|
||||
} else {
|
||||
$email = '';
|
||||
}
|
||||
if ($user->mail != $email && !empty($email) && (!isset($_SESSION['profile_sync_email_profile']) || !$_SESSION['profile_sync_email_profile'])) {
|
||||
$user->mail = $email;
|
||||
|
||||
$_SESSION['profile_sync_email_profile'] = TRUE;
|
||||
user_save($user);
|
||||
$_SESSION['profile_sync_email_profile'] = FALSE;
|
||||
}
|
||||
} // profile_sync_email_profile2()
|
||||
|
||||
/**
|
||||
* Update the profile whenever the user is updated
|
||||
* hook_user_insert(), hook_user_update()
|
||||
*/
|
||||
function profile_sync_email_user_insert(&$edit, $account, $category) {
|
||||
// test for a profile
|
||||
$sync_field = profile_sync_email_instance_info();
|
||||
profile_sync_email_create_profile($account, $sync_field->bundle);
|
||||
// sync the profile
|
||||
profile_sync_email_user($edit, $account, $category);
|
||||
} // profile_sync_email_user_insert()
|
||||
function profile_sync_email_user_update(&$edit, $account, $category) {
|
||||
// test for a profile
|
||||
$sync_field = profile_sync_email_instance_info();
|
||||
profile_sync_email_create_profile($account, $sync_field->bundle);
|
||||
// sync the profile
|
||||
profile_sync_email_user($edit, $account, $category);
|
||||
} // profile_sync_email_user_update()
|
||||
|
||||
function profile_sync_email_user(&$edit, $account, $category) {
|
||||
$sync_field = profile_sync_email_instance_info();
|
||||
$profile = profile2_load_by_user($account, $sync_field->bundle);
|
||||
if ($profile) {
|
||||
if (isset($profile->{$sync_field->field_name}[LANGUAGE_NONE][0]['email'])) {
|
||||
$email = &$profile->{$sync_field->field_name}[LANGUAGE_NONE][0]['email'];
|
||||
} else {
|
||||
$email = '';
|
||||
}
|
||||
if (isset($edit['mail']) && $email != $edit['mail'] && !empty($edit['mail']) && (!isset($_SESSION['profile_sync_email_user']) || !$_SESSION['profile_sync_email_user'])) {
|
||||
$email = $edit['mail'];
|
||||
|
||||
$_SESSION['profile_sync_email_user'] = TRUE; // set lock
|
||||
profile2_save($profile);
|
||||
$_SESSION['profile_sync_email_user'] = FALSE; // remove lock
|
||||
}
|
||||
} // if $profile
|
||||
} // profile_sync_email_user()
|
||||
|
||||
/**
|
||||
* create a profile for the user
|
||||
*/
|
||||
function profile_sync_email_create_profile($user, $bundle) {
|
||||
// get the user profile
|
||||
$profile = profile2_load_by_user($user, $bundle);
|
||||
|
||||
// if a profile exists, exit here
|
||||
if ($profile) return;
|
||||
|
||||
// no profile exists, check for an anonymous profile with a matching email
|
||||
$sync_field = profile_sync_email_instance_info();
|
||||
$pid_query = db_select('profile', 'p')
|
||||
->fields('p', array('pid'))
|
||||
->condition('p.uid', 0)
|
||||
->condition('fd.' . $sync_field->field_name . '_email', $user->mail);
|
||||
$pid_query->join('field_data_' . $sync_field->field_name, 'fd',
|
||||
'fd.entity_id = p.pid AND fd.entity_type = :entity_type AND fd.bundle = :bundle',
|
||||
array(':entity_type' => $sync_field->entity_type, ':bundle' => $sync_field->bundle));
|
||||
$pid = $pid_query->execute()->fetchField();
|
||||
if ($pid) {
|
||||
$profile = profile2_load($pid);
|
||||
$profile->uid = $user->uid;
|
||||
profile2_save($profile);
|
||||
return;
|
||||
}
|
||||
|
||||
// build the profile
|
||||
$profile_values = array(
|
||||
'type' => $bundle,
|
||||
'uid' => $user->uid,
|
||||
);
|
||||
$fields = field_info_instances('profile2', $bundle);
|
||||
foreach (array_keys($fields) as $field_name) {
|
||||
$profile_values[$field_name] = array();
|
||||
}
|
||||
$profile = profile_create($profile_values);
|
||||
profile2_save($profile);
|
||||
} // profile_sync_email_create_profile()
|
||||
|
||||
|
||||
/**
|
||||
* helper function to return info about the sync field
|
||||
*/
|
||||
function profile_sync_email_instance_info() {
|
||||
$sync_field = variable_get('profile_sync_email_instance', -1);
|
||||
$instance_info = FALSE;
|
||||
if ($sync_field) {
|
||||
$instance_info = db_select('field_config_instance', 'fci')
|
||||
->fields('fci', array('field_name', 'entity_type', 'bundle'))
|
||||
->condition('id', $sync_field)
|
||||
->execute()
|
||||
->fetch();
|
||||
}
|
||||
return $instance_info;
|
||||
} // profile_sync_email_instance_info()
|
||||
@@ -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;
|
||||
}
|
||||
?>
|
||||
@@ -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,10 @@
|
||||
This module allows you to specify role specific fields. When creating
|
||||
a new field, you specify for what roles this field is enabled.
|
||||
|
||||
Fields are only visible and editable if an account has a specific
|
||||
role.
|
||||
|
||||
This role does not determine access controls for visible fields, use
|
||||
the field permissions module for that. When a field is visible, it can
|
||||
be edited. If a field is not visible, it cannot be edited, not even by
|
||||
the administrator.
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Alter the field settings form.
|
||||
*/
|
||||
function _user_role_field_field_settings_form_alter(&$form, $form_state, $form_id) {
|
||||
// Try to obtain the field name from the form itself.
|
||||
if ($form_id == 'field_ui_field_settings_form') {
|
||||
$field_name = $form['field']['field_name']['#value'];
|
||||
}
|
||||
elseif ($form_id == 'field_ui_field_edit_form') {
|
||||
$field_name = $form['instance']['field_name']['#value'];
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to obtain information about this field.
|
||||
$field = field_info_field($field_name);
|
||||
if (empty($field)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Enhance the field settings form with role visibility, but without
|
||||
// the anonymouse user.
|
||||
$roles = user_roles ();
|
||||
$form['field']['settings']['user_role_field'] = array(
|
||||
'#title' => t('Apply only to'),
|
||||
'#type' => 'checkboxes',
|
||||
'#checkall' => TRUE,
|
||||
'#options' => $roles,
|
||||
'#default_value' => _user_role_field_roles($field),
|
||||
'#description' => t('Use these options to make a field visible for a specific role. If no role is set, the field is visible to all roles. If "Display on user registration form" is ticked and some roles have been set here, make sure to set the anonymous user role as well, else the field will not be shown.'),
|
||||
'#weight' => -1,
|
||||
);
|
||||
|
||||
// Hide the option to non-privileged users.
|
||||
if (!user_access('administer user field roles')) {
|
||||
$form['field']['settings']['user_role_field']['#type'] = 'value';
|
||||
$form['field']['settings']['user_role_field']['#value'] = $form['field']['settings']['user_role_field']['#default_value'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
name = User role field
|
||||
description = Define user fields by role
|
||||
dependencies[] = field_ui
|
||||
package = Fields
|
||||
core = 7.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-08-24
|
||||
version = "7.x-1.1"
|
||||
core = "7.x"
|
||||
project = "user_role_field"
|
||||
datestamp = "1345799288"
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Hook into field edit form, user registration form and profile2 forms.
|
||||
*/
|
||||
function user_role_field_form_alter(&$form, $form_state, $form_id) {
|
||||
if (isset($form['instance']) && ($form['instance']['entity_type']['#value'] == 'user' || $form['instance']['entity_type']['#value'] == 'profile2') && $form_id == 'field_ui_field_edit_form' && isset($form['field'])) {
|
||||
module_load_include('inc', 'user_role_field', 'user_role_field.admin');
|
||||
return _user_role_field_field_settings_form_alter($form, $form_state, $form_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom permissions.
|
||||
*/
|
||||
function user_role_field_permission() {
|
||||
return array(
|
||||
'administer user field roles' => array(
|
||||
'title' => t('Administer user field roles'),
|
||||
'description' => t('Manage user field roles.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function _user_role_field_roles($field) {
|
||||
return (isset($field['settings']['user_role_field']) && is_array($field['settings']['user_role_field']) ? array_filter($field['settings']['user_role_field']) : array());
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure only appropriate roles have access
|
||||
*/
|
||||
function user_role_field_field_access($op, $field, $obj_type, $object, $account) {
|
||||
// We only handle user fields and profile2 fields
|
||||
if (($obj_type != 'user') && ($obj_type != 'profile2'))
|
||||
return true;
|
||||
|
||||
// Admin user can see all fields when creating a new user.
|
||||
if (arg(2) == 'create' && arg(0) == 'admin' && user_access ('administer permissions'))
|
||||
return true;
|
||||
|
||||
// If the object type is profile2, we need to load the user owning profile2 object
|
||||
if ($obj_type == 'profile2' && !empty($object->uid))
|
||||
$object = user_load ($object->uid);
|
||||
|
||||
// Ignore the request if roles have not been enabled for this field.
|
||||
$roles = _user_role_field_roles ($field);
|
||||
if (empty($roles)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the user object doesn't have the roles property, we get here through
|
||||
// the views module for example. In that case we want the data to display.
|
||||
// To revisit in case there are other cases.
|
||||
if (!isset ($object->roles))
|
||||
return true;
|
||||
|
||||
$matching_roles = array_intersect_key ($object->roles, $roles);
|
||||
return !empty ($matching_roles);
|
||||
}
|
||||