Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

initial commit of 6.x-2.1 code, pre modification

  • Loading branch information...
commit be1a3cdc2a50faacd9fba3a744067e24b89ff804 0 parents
Ryan Eby eby authored
274 LICENSE.txt
... ... @@ -0,0 +1,274 @@
  1 +GNU GENERAL PUBLIC LICENSE
  2 +
  3 + Version 2, June 1991
  4 +
  5 +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
  6 +Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
  7 +verbatim copies of this license document, but changing it is not allowed.
  8 +
  9 + Preamble
  10 +
  11 +The licenses for most software are designed to take away your freedom to
  12 +share and change it. By contrast, the GNU General Public License is
  13 +intended to guarantee your freedom to share and change free software--to
  14 +make sure the software is free for all its users. This General Public License
  15 +applies to most of the Free Software Foundation's software and to any other
  16 +program whose authors commit to using it. (Some other Free Software
  17 +Foundation software is covered by the GNU Library General Public License
  18 +instead.) You can apply it to your programs, too.
  19 +
  20 +When we speak of free software, we are referring to freedom, not price. Our
  21 +General Public Licenses are designed to make sure that you have the
  22 +freedom to distribute copies of free software (and charge for this service if
  23 +you wish), that you receive source code or can get it if you want it, that you
  24 +can change the software or use pieces of it in new free programs; and that
  25 +you know you can do these things.
  26 +
  27 +To protect your rights, we need to make restrictions that forbid anyone to
  28 +deny you these rights or to ask you to surrender the rights. These restrictions
  29 +translate to certain responsibilities for you if you distribute copies of the
  30 +software, or if you modify it.
  31 +
  32 +For example, if you distribute copies of such a program, whether gratis or for
  33 +a fee, you must give the recipients all the rights that you have. You must make
  34 +sure that they, too, receive or can get the source code. And you must show
  35 +them these terms so they know their rights.
  36 +
  37 +We protect your rights with two steps: (1) copyright the software, and (2)
  38 +offer you this license which gives you legal permission to copy, distribute
  39 +and/or modify the software.
  40 +
  41 +Also, for each author's protection and ours, we want to make certain that
  42 +everyone understands that there is no warranty for this free software. If the
  43 +software is modified by someone else and passed on, we want its recipients
  44 +to know that what they have is not the original, so that any problems
  45 +introduced by others will not reflect on the original authors' reputations.
  46 +
  47 +Finally, any free program is threatened constantly by software patents. We
  48 +wish to avoid the danger that redistributors of a free program will individually
  49 +obtain patent licenses, in effect making the program proprietary. To prevent
  50 +this, we have made it clear that any patent must be licensed for everyone's
  51 +free use or not licensed at all.
  52 +
  53 +The precise terms and conditions for copying, distribution and modification
  54 +follow.
  55 +
  56 + GNU GENERAL PUBLIC LICENSE
  57 + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
  58 + MODIFICATION
  59 +
  60 +0. This License applies to any program or other work which contains a notice
  61 +placed by the copyright holder saying it may be distributed under the terms
  62 +of this General Public License. The "Program", below, refers to any such
  63 +program or work, and a "work based on the Program" means either the
  64 +Program or any derivative work under copyright law: that is to say, a work
  65 +containing the Program or a portion of it, either verbatim or with
  66 +modifications and/or translated into another language. (Hereinafter, translation
  67 +is included without limitation in the term "modification".) Each licensee is
  68 +addressed as "you".
  69 +
  70 +Activities other than copying, distribution and modification are not covered
  71 +by this License; they are outside its scope. The act of running the Program is
  72 +not restricted, and the output from the Program is covered only if its contents
  73 +constitute a work based on the Program (independent of having been made
  74 +by running the Program). Whether that is true depends on what the Program
  75 +does.
  76 +
  77 +1. You may copy and distribute verbatim copies of the Program's source
  78 +code as you receive it, in any medium, provided that you conspicuously and
  79 +appropriately publish on each copy an appropriate copyright notice and
  80 +disclaimer of warranty; keep intact all the notices that refer to this License
  81 +and to the absence of any warranty; and give any other recipients of the
  82 +Program a copy of this License along with the Program.
  83 +
  84 +You may charge a fee for the physical act of transferring a copy, and you
  85 +may at your option offer warranty protection in exchange for a fee.
  86 +
  87 +2. You may modify your copy or copies of the Program or any portion of it,
  88 +thus forming a work based on the Program, and copy and distribute such
  89 +modifications or work under the terms of Section 1 above, provided that you
  90 +also meet all of these conditions:
  91 +
  92 +a) You must cause the modified files to carry prominent notices stating that
  93 +you changed the files and the date of any change.
  94 +
  95 +b) You must cause any work that you distribute or publish, that in whole or in
  96 +part contains or is derived from the Program or any part thereof, to be
  97 +licensed as a whole at no charge to all third parties under the terms of this
  98 +License.
  99 +
  100 +c) If the modified program normally reads commands interactively when run,
  101 +you must cause it, when started running for such interactive use in the most
  102 +ordinary way, to print or display an announcement including an appropriate
  103 +copyright notice and a notice that there is no warranty (or else, saying that
  104 +you provide a warranty) and that users may redistribute the program under
  105 +these conditions, and telling the user how to view a copy of this License.
  106 +(Exception: if the Program itself is interactive but does not normally print such
  107 +an announcement, your work based on the Program is not required to print
  108 +an announcement.)
  109 +
  110 +These requirements apply to the modified work as a whole. If identifiable
  111 +sections of that work are not derived from the Program, and can be
  112 +reasonably considered independent and separate works in themselves, then
  113 +this License, and its terms, do not apply to those sections when you distribute
  114 +them as separate works. But when you distribute the same sections as part
  115 +of a whole which is a work based on the Program, the distribution of the
  116 +whole must be on the terms of this License, whose permissions for other
  117 +licensees extend to the entire whole, and thus to each and every part
  118 +regardless of who wrote it.
  119 +
  120 +Thus, it is not the intent of this section to claim rights or contest your rights to
  121 +work written entirely by you; rather, the intent is to exercise the right to
  122 +control the distribution of derivative or collective works based on the
  123 +Program.
  124 +
  125 +In addition, mere aggregation of another work not based on the Program
  126 +with the Program (or with a work based on the Program) on a volume of a
  127 +storage or distribution medium does not bring the other work under the scope
  128 +of this License.
  129 +
  130 +3. You may copy and distribute the Program (or a work based on it, under
  131 +Section 2) in object code or executable form under the terms of Sections 1
  132 +and 2 above provided that you also do one of the following:
  133 +
  134 +a) Accompany it with the complete corresponding machine-readable source
  135 +code, which must be distributed under the terms of Sections 1 and 2 above
  136 +on a medium customarily used for software interchange; or,
  137 +
  138 +b) Accompany it with a written offer, valid for at least three years, to give
  139 +any third party, for a charge no more than your cost of physically performing
  140 +source distribution, a complete machine-readable copy of the corresponding
  141 +source code, to be distributed under the terms of Sections 1 and 2 above on
  142 +a medium customarily used for software interchange; or,
  143 +
  144 +c) Accompany it with the information you received as to the offer to distribute
  145 +corresponding source code. (This alternative is allowed only for
  146 +noncommercial distribution and only if you received the program in object
  147 +code or executable form with such an offer, in accord with Subsection b
  148 +above.)
  149 +
  150 +The source code for a work means the preferred form of the work for
  151 +making modifications to it. For an executable work, complete source code
  152 +means all the source code for all modules it contains, plus any associated
  153 +interface definition files, plus the scripts used to control compilation and
  154 +installation of the executable. However, as a special exception, the source
  155 +code distributed need not include anything that is normally distributed (in
  156 +either source or binary form) with the major components (compiler, kernel,
  157 +and so on) of the operating system on which the executable runs, unless that
  158 +component itself accompanies the executable.
  159 +
  160 +If distribution of executable or object code is made by offering access to
  161 +copy from a designated place, then offering equivalent access to copy the
  162 +source code from the same place counts as distribution of the source code,
  163 +even though third parties are not compelled to copy the source along with the
  164 +object code.
  165 +
  166 +4. You may not copy, modify, sublicense, or distribute the Program except as
  167 +expressly provided under this License. Any attempt otherwise to copy,
  168 +modify, sublicense or distribute the Program is void, and will automatically
  169 +terminate your rights under this License. However, parties who have received
  170 +copies, or rights, from you under this License will not have their licenses
  171 +terminated so long as such parties remain in full compliance.
  172 +
  173 +5. You are not required to accept this License, since you have not signed it.
  174 +However, nothing else grants you permission to modify or distribute the
  175 +Program or its derivative works. These actions are prohibited by law if you
  176 +do not accept this License. Therefore, by modifying or distributing the
  177 +Program (or any work based on the Program), you indicate your acceptance
  178 +of this License to do so, and all its terms and conditions for copying,
  179 +distributing or modifying the Program or works based on it.
  180 +
  181 +6. Each time you redistribute the Program (or any work based on the
  182 +Program), the recipient automatically receives a license from the original
  183 +licensor to copy, distribute or modify the Program subject to these terms and
  184 +conditions. You may not impose any further restrictions on the recipients'
  185 +exercise of the rights granted herein. You are not responsible for enforcing
  186 +compliance by third parties to this License.
  187 +
  188 +7. If, as a consequence of a court judgment or allegation of patent
  189 +infringement or for any other reason (not limited to patent issues), conditions
  190 +are imposed on you (whether by court order, agreement or otherwise) that
  191 +contradict the conditions of this License, they do not excuse you from the
  192 +conditions of this License. If you cannot distribute so as to satisfy
  193 +simultaneously your obligations under this License and any other pertinent
  194 +obligations, then as a consequence you may not distribute the Program at all.
  195 +For example, if a patent license would not permit royalty-free redistribution
  196 +of the Program by all those who receive copies directly or indirectly through
  197 +you, then the only way you could satisfy both it and this License would be to
  198 +refrain entirely from distribution of the Program.
  199 +
  200 +If any portion of this section is held invalid or unenforceable under any
  201 +particular circumstance, the balance of the section is intended to apply and
  202 +the section as a whole is intended to apply in other circumstances.
  203 +
  204 +It is not the purpose of this section to induce you to infringe any patents or
  205 +other property right claims or to contest validity of any such claims; this
  206 +section has the sole purpose of protecting the integrity of the free software
  207 +distribution system, which is implemented by public license practices. Many
  208 +people have made generous contributions to the wide range of software
  209 +distributed through that system in reliance on consistent application of that
  210 +system; it is up to the author/donor to decide if he or she is willing to
  211 +distribute software through any other system and a licensee cannot impose
  212 +that choice.
  213 +
  214 +This section is intended to make thoroughly clear what is believed to be a
  215 +consequence of the rest of this License.
  216 +
  217 +8. If the distribution and/or use of the Program is restricted in certain
  218 +countries either by patents or by copyrighted interfaces, the original copyright
  219 +holder who places the Program under this License may add an explicit
  220 +geographical distribution limitation excluding those countries, so that
  221 +distribution is permitted only in or among countries not thus excluded. In such
  222 +case, this License incorporates the limitation as if written in the body of this
  223 +License.
  224 +
  225 +9. The Free Software Foundation may publish revised and/or new versions
  226 +of the General Public License from time to time. Such new versions will be
  227 +similar in spirit to the present version, but may differ in detail to address new
  228 +problems or concerns.
  229 +
  230 +Each version is given a distinguishing version number. If the Program specifies
  231 +a version number of this License which applies to it and "any later version",
  232 +you have the option of following the terms and conditions either of that
  233 +version or of any later version published by the Free Software Foundation. If
  234 +the Program does not specify a version number of this License, you may
  235 +choose any version ever published by the Free Software Foundation.
  236 +
  237 +10. If you wish to incorporate parts of the Program into other free programs
  238 +whose distribution conditions are different, write to the author to ask for
  239 +permission. For software which is copyrighted by the Free Software
  240 +Foundation, write to the Free Software Foundation; we sometimes make
  241 +exceptions for this. Our decision will be guided by the two goals of
  242 +preserving the free status of all derivatives of our free software and of
  243 +promoting the sharing and reuse of software generally.
  244 +
  245 + NO WARRANTY
  246 +
  247 +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
  248 +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
  249 +PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
  250 +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
  251 +OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
  252 +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
  253 +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  254 +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  255 +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
  256 +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
  257 +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
  258 +NECESSARY SERVICING, REPAIR OR CORRECTION.
  259 +
  260 +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
  261 +AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
  262 +ANY OTHER PARTY WHO MAY MODIFY AND/OR
  263 +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
  264 +LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
  265 +SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
  266 +ARISING OUT OF THE USE OR INABILITY TO USE THE
  267 +PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
  268 +OR DATA BEING RENDERED INACCURATE OR LOSSES
  269 +SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
  270 +PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
  271 +IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
  272 +THE POSSIBILITY OF SUCH DAMAGES.
  273 +
  274 + END OF TERMS AND CONDITIONS
43 README.txt
... ... @@ -0,0 +1,43 @@
  1 +$Id
  2 +
  3 +-- SUMMARY --
  4 +
  5 +The Drupal Remember me module adds a "Remember me" checkbox to login forms.
  6 +
  7 +For a full description of the module, visit the project page:
  8 + http://drupal.org/project/remember_me
  9 +
  10 +To submit bug reports and feature suggestions, or to track changes:
  11 + http://drupal.org/project/issues/remember_me
  12 +
  13 +
  14 +-- REQUIREMENTS --
  15 +
  16 +None.
  17 +
  18 +
  19 +-- INSTALLATION --
  20 +
  21 +* Install as usual, see http://drupal.org/node/70151 for further information.
  22 +
  23 +
  24 +-- CONFIGURATION --
  25 +
  26 +
  27 +
  28 +-- CUSTOMIZATION --
  29 +
  30 +
  31 +
  32 +-- TROUBLESHOOTING --
  33 +
  34 +
  35 +
  36 +-- FAQ --
  37 +
  38 +
  39 +
  40 +-- CONTACT --
  41 +
  42 +Current maintainers:
  43 +* Nick Lombard - http://drupal.org/user/71563
132 includes/remember_me.admin.inc
... ... @@ -0,0 +1,132 @@
  1 +<?php
  2 +// $Id: remember_me.admin.inc,v 1.1.2.1 2009/05/25 15:09:03 nickl Exp $
  3 +
  4 +/**
  5 + * @file
  6 + * Menu callback include file for admin/settings pages.
  7 + */
  8 +
  9 +/**
  10 + * Implementation of menu callback.
  11 + */
  12 +function remember_me_admin_settings() {
  13 + global $user;
  14 + $options = drupal_map_assoc(
  15 + array(3600, 10800, 21600, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200),
  16 + 'format_interval'
  17 + );
  18 + $dependency = array();
  19 + if (function_exists('ctools_include')) {
  20 + ctools_include('modal');
  21 + ctools_include('ajax');
  22 + ctools_include('dependent');
  23 + ctools_modal_add_js();
  24 + drupal_add_js('misc/collapse.js');
  25 +
  26 + $link = ctools_modal_text_button(
  27 + t('Configure Who\'s online settings'),
  28 + 'remember_me/ajax/users/online',
  29 + t('Who\'s online settings.'),
  30 + 'remember-me-users-online'
  31 + );
  32 + $dependency = array(
  33 + '#process' => array('ctools_dependent_process'),
  34 + '#dependency' => array('edit-remember-me-managed' => array(1)),
  35 + );
  36 + }
  37 + else {
  38 + $link = l(
  39 + t('Configure Who\'s online settings'),
  40 + 'admin/settings/remember_me/users/online',
  41 + array(
  42 + 'attributes' => array(
  43 + 'title' => t('Who\'s online settings.'),
  44 + 'class' => 'remember-me-users-online',
  45 + ),
  46 + 'query' => array(
  47 + 'destination' => 'admin/settings/remember_me',
  48 + ),
  49 + )
  50 + );
  51 + }
  52 +
  53 + $vars = array(
  54 + 'remember' => array(
  55 + '#type' => 'item',
  56 + '#title' => t('Remember me'),
  57 + '#value' => $user->remember_me ? t('Yes') : t('No'),
  58 + '#description' => t("Current user chose at log in."),
  59 + ),
  60 + 'session' => array(
  61 + '#type' => 'item',
  62 + '#title' => t('Session lifetime'),
  63 + '#value' => format_interval(ini_get('session.cookie_lifetime')),
  64 + '#description' => t("Currently configured session cookie lifetime."),
  65 + ),
  66 + 'activity' => array(
  67 + '#type' => 'item',
  68 + '#title' => t('User activity'),
  69 + '#value' => '<span id="remember-me-timeout">'.
  70 + format_interval(variable_get('user_block_seconds_online', 900))
  71 + .'</span>',
  72 + '#description' => t("Period a user is considered to be online for after they have last viewed a page."),
  73 + ),
  74 + );
  75 + $form['legend'] = array(
  76 + '#type' => 'markup',
  77 + '#value' => theme('remember_me_settings_display', $vars),
  78 + );
  79 +
  80 + $form['remember_me_phantom_session'] = array(
  81 + '#type' => 'checkbox',
  82 + '#title' => t('Manage phantom sessions'),
  83 + '#default_value' => variable_get('remember_me_phantom_session', 0),
  84 + '#description' => t("Prevent phantom sessions from causing duplicate entries on the Who's online list."),
  85 + );
  86 + $form['user_activity'] = array(
  87 + '#type' => 'item',
  88 + '#value' => $link,
  89 + '#description' => t("Decrease the likelihood of trapping phantom sessions by shortening the Who's online user activity period."),
  90 + );
  91 + $form['remember_me_managed'] = array(
  92 + '#type' => 'checkbox',
  93 + '#title' => t('Manage session lifetime'),
  94 + '#default_value' => variable_get('remember_me_managed', 0),
  95 + '#description' => t('Choose to manually overwrite the configuration value from settings.php.'),
  96 + );
  97 + $form['remember_me_lifetime'] = array(
  98 + '#type' => 'select',
  99 + '#title' => t('Lifetime'),
  100 + '#default_value' => variable_get('remember_me_lifetime', 604800),
  101 + '#options' => $options,
  102 + '#description' => t('Duration a user will be remembered for. This setting is ignored if Manage session lifetime (above) is disabled.'),
  103 + ) + $dependency;
  104 + $form['remember_me_checkbox'] = array(
  105 + '#type' => 'checkbox',
  106 + '#title' => t('Remember me field'),
  107 + '#default_value' => variable_get('remember_me_checkbox', 1),
  108 + '#description' => t('Default state of the "Remember me" field on the login forms.'),
  109 + );
  110 +
  111 + return system_settings_form($form);
  112 +}
  113 +
  114 +
  115 +function theme_remember_me_settings_display($vars) {
  116 + $rows = array();
  117 + foreach($vars as $var) {
  118 + $desc = $var['#description'];
  119 + unset($var['#description']);
  120 + $output = '<div class="container-inline">'. theme('item', $var) .'</div>';
  121 + $output .= '<div class="description">'. $desc .'</div>';
  122 + $rows[] = $output;
  123 + if(is_array($rows[0])) {
  124 + $rows[1] = array($rows[1]);
  125 + }
  126 + else if(sizeof($rows) == 2) {
  127 + $rows = array(array('data' => $rows, 'class' => 'even'));
  128 + }
  129 + }
  130 +
  131 + return theme('table', array(), $rows);
  132 +}
89 includes/remember_me.inc
... ... @@ -0,0 +1,89 @@
  1 +<?php
  2 +// $Id: remember_me.inc,v 1.1.2.1 2009/05/25 15:09:03 nickl Exp $
  3 +
  4 +/**
  5 + * @file
  6 + * Functions that are not needed at all times can be included when required.
  7 + */
  8 +
  9 +/**
  10 + * Manage phantom sessions.
  11 + *
  12 + * When a user closes their browser their session cookie expires. If the user
  13 + * chose to be forgotten they will not be allowed to use the old session.
  14 + * These phantom sessions still appear in Who's online block and will show duplicate
  15 + * names. If configured to do so, via settings page, set phantom session's timeout period
  16 + * outside of the Who's online block's display period.
  17 + */
  18 +function remember_me_manage_phantom_sessions() {
  19 + global $user;
  20 + $interval = time() - variable_get('user_block_seconds_online', 900);
  21 + $count = db_result(
  22 + db_query("SELECT COUNT(uid) FROM {sessions} WHERE uid = %d AND timestamp >= %d",
  23 + $user->uid,
  24 + $interval
  25 + )
  26 + );
  27 + if ($count > 0) {
  28 + watchdog('remember_me',
  29 + t('Phantom session managed for %user, session trapped within %time timeout.'),
  30 + array(
  31 + '%user' => $user->name,
  32 + '%id' => $user-uid,
  33 + '%time' => format_interval(variable_get('user_block_seconds_online', 900))
  34 + ),
  35 + WATCHDOG_NOTICE
  36 + );
  37 + db_query("UPDATE {sessions} SET timestamp = %d WHERE uid = %d AND timestamp >= %d",
  38 + $interval - 1,
  39 + $user->uid,
  40 + $interval
  41 + );
  42 + }
  43 +}
  44 +
  45 +/**
  46 + * Try to insert 'Remember me' checkbox between 'Username', 'Password' and
  47 + * 'Log in' form elements.
  48 + */
  49 +function remember_me_insert_checkbox(&$form) {
  50 + $form1['remember_me'] = array(
  51 + '#title' => t('Remember me'),
  52 + '#type' => 'checkbox',
  53 + '#default_value' => variable_get('remember_me_checkbox', 0),
  54 + );
  55 + _remember_me_array_insert_after_key('pass', $form, $form1);
  56 + $form['name']['#attributes']['tabindex'] = '1';
  57 + $form['pass']['#attributes']['tabindex'] = '2';
  58 + $form['remember_me']['#attributes']['tabindex'] = '3';
  59 + $form['submit']['#attributes']['tabindex'] = '4';
  60 +}
  61 +
  62 +/**
  63 + * Insert elements into array after the element with $searck_key key and
  64 + * maintain index association.
  65 + *
  66 + * @param $search_key
  67 + * Key of array element to insert elements after.
  68 + * @param $array
  69 + * Given array.
  70 + * @param $elements_to_insert
  71 + * Array of elements to be inserted.
  72 + */
  73 +function _remember_me_array_insert_after_key($search_key, &$array, $elements_to_insert) {
  74 + // Split array into two arrays: prior $search_key element including
  75 + // $search_key element and after $search_key element.
  76 + $array1 = array();
  77 + $array2 = array();
  78 + $curr_array = &$array1;
  79 + foreach ($array as $key => $value) {
  80 + $curr_array[$key] = $value;
  81 + if ($search_key == $key) {
  82 + $curr_array = &$array2;
  83 + }
  84 + }
  85 +
  86 + // Add $elements_to_insert to the end of the first array.
  87 + $array1 = $array1 + $elements_to_insert;
  88 + $array = $array1 + $array2;
  89 +}
72 includes/remember_me.users.inc
... ... @@ -0,0 +1,72 @@
  1 +<?php
  2 +// $Id: remember_me.users.inc,v 1.1.2.1 2009/05/25 15:09:03 nickl Exp $
  3 +
  4 +/**
  5 + * @file
  6 + * Menu callback include file for url branch remember_me/ajax/users.
  7 + */
  8 +
  9 +/**
  10 + * Implementation of menu callback.
  11 + * Prepare $form_state and wrap form in modal.
  12 + */
  13 +function remember_me_ajax_users_online() {
  14 + if (function_exists('ctools_include')) {
  15 + ctools_include('ajax');
  16 + ctools_include('modal');
  17 +
  18 + $form_state = array(
  19 + 'title' => t("'Who's online' settings"),
  20 + 'ajax' => TRUE,
  21 + );
  22 + $output = ctools_modal_form_wrapper(
  23 + 'remember_me_ajax_users_online_form',
  24 + $form_state
  25 + );
  26 + if (empty($output)) {
  27 +
  28 + $output = array();
  29 + $output[] = ctools_ajax_command_remove( 'div.messages');
  30 + $output[] = ctools_ajax_command_before(
  31 + 'form#remember-me-admin-settings',
  32 + theme('status_messages')
  33 + );
  34 + $output[] = ctools_ajax_command_html(
  35 + 'span#remember-me-timeout',
  36 + format_interval(variable_get('user_block_seconds_online', 900))
  37 + );
  38 +
  39 + $output[] = ctools_modal_command_dismiss();
  40 + }
  41 +
  42 + ctools_ajax_render($output);
  43 + }
  44 + else {
  45 + return t('!chaos is required for this ajax implementation, install it today.',
  46 + array(
  47 + '!chaos' => l(t('Chaos tool suite'), 'http://drupal.org/project/ctools'),
  48 + )
  49 + );
  50 + }
  51 +}
  52 +
  53 +/**
  54 + * Who's online form callback.
  55 + * Extract form from user_block method and add buttons.
  56 + */
  57 +function remember_me_ajax_users_online_form(&$form_state) {
  58 + $form['conf'] = array();
  59 + $form['conf'] += user_block('configure', 3);
  60 + $form['disp'] = array(
  61 + '#type' => 'fieldset',
  62 + '#title' => t("'Who's online' block preview"),
  63 + '#collapsible' => TRUE,
  64 + '#collapsed' => TRUE,
  65 + );
  66 + $view = user_block('view', 3);
  67 + $form['disp']['items'] = array(
  68 + '#type' => 'markup',
  69 + '#value' => '<div>'. $view['content'] .'</div>'
  70 + );
  71 + return system_settings_form($form);
  72 +}
10 remember_me.info
... ... @@ -0,0 +1,10 @@
  1 +; $Id: remember_me.info,v 1.7.2.1 2009/05/25 15:09:03 nickl Exp $
  2 +name = Remember me
  3 +description = "Adds a ''Remember me'' checkbox to login forms."
  4 +core = 6.x
  5 +; Information added by drupal.org packaging script on 2009-05-25
  6 +version = "6.x-2.1"
  7 +core = "6.x"
  8 +project = "remember_me"
  9 +datestamp = "1243275270"
  10 +
31 remember_me.install
... ... @@ -0,0 +1,31 @@
  1 +<?php
  2 +// $Id: remember_me.install,v 1.2.2.1 2009/05/25 15:09:03 nickl Exp $
  3 +
  4 +/**
  5 + * @file
  6 + * Contains install and update functions for remember_me.
  7 + */
  8 +
  9 +/**
  10 + * Implementation of hook_install().
  11 + */
  12 +function remember_me_install() {
  13 + // Place session management first in the module queue
  14 + db_query("UPDATE {system} SET weight = -99 WHERE name = 'remember_me'");
  15 +}
  16 +
  17 +/**
  18 + * Implementation of hook_disable().
  19 + */
  20 +function remember_me_disable() {
  21 + // Remove record from system table when disabling the module
  22 + db_query("DELETE FROM {system} WHERE name = 'remember_me'");
  23 + // User object data field will have 'remember_me' key forever after you disable the module, lets remove that.
  24 + $result = db_query("SELECT uid FROM {users} WHERE data LIKE '%%remember_me%%'");
  25 + while ($user = db_fetch_object($result)) {
  26 + user_save($user, array('remember_me' => NULL), NULL);
  27 + }
  28 + // also clear the session store
  29 + sess_gc(0);
  30 + drupal_set_message(t('Successfully removed the remember_me key from all user objects.'));
  31 +}
172 remember_me.module
... ... @@ -0,0 +1,172 @@
  1 +<?php
  2 +// $Id: remember_me.module,v 1.13.2.1 2009/05/25 15:09:03 nickl Exp $
  3 +
  4 +/**
  5 + * @file
  6 + * Adds a "Remember me" checkbox to login forms.
  7 + *
  8 + */
  9 +
  10 +/**
  11 + * Implementation of hook_init().
  12 + */
  13 +function remember_me_init() {
  14 + global $user;
  15 +
  16 + // If we have a user logged in, then we have a session.
  17 + if ($user->uid) {
  18 + if ($user->remember_me && variable_get('remember_me_managed', 0) != 0) {
  19 + // Set lifetime as configured via admin settings.
  20 + if (variable_get('remember_me_lifetime', 604800) != ini_get('session.cookie_lifetime')) {
  21 + _remember_me_set_lifetime(variable_get('remember_me_lifetime', 604800));
  22 + }
  23 + }
  24 + else if (!$user->remember_me) {
  25 + // If we have cookie lifetime set already then unset it.
  26 + if (0 != ini_get('session.cookie_lifetime')) {
  27 + _remember_me_set_lifetime(0);
  28 + }
  29 + }
  30 + }
  31 +}
  32 +
  33 +/**
  34 + * remember_me_init() callback helper function.
  35 + */
  36 +function _remember_me_set_lifetime($cookie_lifetime) {
  37 + // We have session started.
  38 + // Lets close the session, change php cookie lifetime variable, and start
  39 + // session again.
  40 + // Prevent sess_write from persisting the session object at this time,
  41 + // it will happen on shutdown.
  42 + session_save_session(FALSE);
  43 + session_write_close();
  44 + session_save_session(TRUE);
  45 +
  46 + ini_set('session.cookie_lifetime', $cookie_lifetime);
  47 +
  48 + // Use remember_me_sess_read() to avoid reloading of user object, because
  49 + // it might be once more reloaded in some other hook_init().
  50 + session_set_save_handler(
  51 + "sess_open",
  52 + "sess_close",
  53 + "remember_me_sess_read",
  54 + "sess_write",
  55 + "sess_destroy_sid",
  56 + "sess_gc"
  57 + );
  58 + session_start();
  59 +}
  60 +
  61 +/**
  62 + * Session handler 'read' callback.
  63 + */
  64 +function remember_me_sess_read() {
  65 + global $user;
  66 + static $run = FALSE;
  67 + if (!$run) {
  68 + $run = TRUE;
  69 + return !empty($user->session) ? $user->session : '';
  70 + }
  71 + $args = func_get_args();
  72 + return call_user_func_array('sess_read', $args);
  73 +}
  74 +
  75 +/**
  76 + * Implementation of hook_user().
  77 + */
  78 +function remember_me_user($op, &$edit, &$user, $category = NULL) {
  79 + if ($category === NULL && $op == 'login') {
  80 + $remember_me = isset($edit['remember_me']) ? $edit['remember_me'] : NULL;
  81 + if (isset($remember_me)) {
  82 + if ($user->uid) {
  83 + $user = user_save($user, array(
  84 + 'remember_me' => (bool) $remember_me,
  85 + ), NULL);
  86 + }
  87 + }
  88 + if (variable_get('remember_me_phantom_session', 0)) {
  89 + module_load_include('inc', 'remember_me', 'includes/remember_me');
  90 + remember_me_manage_phantom_sessions();
  91 + }
  92 + }
  93 +}
  94 +
  95 +/**
  96 + * Implementation of hook_form_alter().
  97 + */
  98 +function remember_me_form_alter(&$form, $form_state, $form_id) {
  99 + $user_login_forms = array('user_login', 'user_login_block');
  100 +
  101 + if (in_array($form_id, $user_login_forms)) {
  102 + module_load_include('inc', 'remember_me', 'includes/remember_me');
  103 + remember_me_insert_checkbox($form);
  104 + }
  105 +}
  106 +
  107 +/**
  108 + * Implementation of hook_theme().
  109 + */
  110 +function remember_me_theme() {
  111 + return array(
  112 + 'remember_me_settings_display' => array(
  113 + 'arguments' => array('vars' => array()),
  114 + 'file' => 'includes/remember_me.admin.inc',
  115 + ),
  116 + );
  117 +}
  118 +
  119 +/**
  120 + * Implementation of hook_menu().
  121 + */
  122 +function remember_me_menu() {
  123 + $items = array();
  124 + $items['admin/settings/remember_me'] = array(
  125 + 'title' => 'Remember me settings',
  126 + 'description' => 'Configure settings like session time out for remember_me module.',
  127 + 'page callback' => 'drupal_get_form',
  128 + 'page arguments' => array('remember_me_admin_settings'),
  129 + 'access arguments' => array('administer site configuration'),
  130 + 'file' => 'includes/remember_me.admin.inc',
  131 + 'type' => MENU_NORMAL_ITEM
  132 + );
  133 +
  134 + $base = array(
  135 + 'type' => MENU_CALLBACK,
  136 + 'access arguments' => array('administer site configuration'),
  137 + 'file' => 'includes/remember_me.users.inc',
  138 + );
  139 +
  140 + $items['remember_me/ajax/users/online'] = array(
  141 + 'page callback' => 'remember_me_ajax_users_online',
  142 + ) + $base;
  143 +
  144 + $items['admin/settings/remember_me/users/online'] = array(
  145 + 'page callback' => 'drupal_get_form',
  146 + 'page arguments' => array('remember_me_ajax_users_online_form'),
  147 + 'title' => "'Who's online' settings",
  148 + ) + $base;
  149 +
  150 + $base = array(
  151 + 'type' => MENU_CALLBACK,
  152 + 'access arguments' => array('administer site configuration'),
  153 + 'file' => 'includes/remember_me.test.inc',
  154 + );
  155 +
  156 + $items['remember_me/test'] = array(
  157 + 'page callback' => 'drupal_get_form',
  158 + 'page arguments' => array('test_fapi_edit'),
  159 + ) + $base;
  160 +
  161 + return $items;
  162 +}
  163 +
  164 +/**
  165 + * Implementation of hook_help().
  166 + */
  167 +function remember_me_help($path, $arg) {
  168 + switch ($path) {
  169 + case 'admin/help#remember_me' :
  170 + return t('Allows users to have persistent sessions via a checkbox "Remember me" on the login form.');
  171 + }
  172 +}

0 comments on commit be1a3cd

Please sign in to comment.
Something went wrong with that request. Please try again.