b2evolution PHP Cross Reference Blogging Systems

Source: /inc/users/registration.ctrl.php - 198 lines - 8517 bytes - Text - Print

Description: This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file is part of the evoCore framework - {@link http://evocore.net/}
   4   * See also {@link http://sourceforge.net/projects/evocms/}.
   5   *
   6   * @copyright (c)2009-2014 by Francois PLANQUE - {@link http://fplanque.net/}
   7   * Parts of this file are copyright (c)2009 by The Evo Factory - {@link http://www.evofactory.com/}.
   8   *
   9   * {@internal License choice
  10   * - If you have received this file as part of a package, please find the license.txt file in
  11   *   the same folder or the closest folder above for complete license terms.
  12   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  13   *   then you must choose one of the following licenses before using the file:
  14   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  15   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  16   * }}
  17   *
  18   * {@internal Open Source relicensing agreement:
  19   * The Evo Factory grants Francois PLANQUE the right to license
  20   * The Evo Factory's contributions to this file and the b2evolution project
  21   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  22   * }}
  23   *
  24   * @package evocore
  25   *
  26   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  27   * @author efy-bogdan: Evo Factory / Bogdan.
  28   * @author fplanque: Francois PLANQUE
  29   *
  30   * @version $Id: registration.ctrl.php 6136 2014-03-08 07:59:48Z manuel $
  31   */
  32  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  33  
  34  // Check minimum permission:
  35  $current_User->check_perm( 'users', 'view', true );
  36  
  37  $AdminUI->set_path( 'users', 'usersettings', 'registration' );
  38  
  39  param_action();
  40  
  41  switch ( $action )
  42  {
  43      case 'update':
  44          // Check that this action request is not a CSRF hacked request:
  45          $Session->assert_received_crumb( 'registration' );
  46  
  47          // Check permission:
  48          $current_User->check_perm( 'users', 'edit', true );
  49  
  50          // keep old newusers_canregister setting value to check if we need to invalidate pagecaches
  51          $old_newusers_canregister = $Settings->get( 'newusers_canregister' );
  52  
  53          // UPDATE general settings:
  54          param( 'newusers_canregister', 'integer', 0 );
  55          param( 'newusers_grp_ID', 'integer', true );
  56  
  57          param_integer_range( 'newusers_level', 0, 9, T_('User level must be between %d and %d.') );
  58  
  59          // UPDATE default user settings
  60          param( 'enable_PM', 'integer', 0 );
  61          param( 'enable_email', 'integer', 0 );
  62          param( 'notify_messages', 'integer', 0 );
  63          param( 'notify_unread_messages', 'integer', 0 );
  64          param( 'notify_published_comments', 'integer', 0 );
  65          param( 'notify_comment_moderation', 'integer', 0 );
  66          param( 'notify_post_moderation', 'integer', 0 );
  67          param( 'newsletter_news', 'integer', 0 );
  68          param( 'newsletter_ads', 'integer', 0 );
  69          param_integer_range( 'notification_email_limit', 0, 999, T_('Notificaiton email limit must be between %d and %d.') );
  70          param_integer_range( 'newsletter_limit', 0, 999, T_('Newsletter limit must be between %d and %d.') );
  71  
  72          // UPDATE account activation by email
  73          param( 'newusers_mustvalidate', 'integer', 0 );
  74          param( 'newusers_revalidate_emailchg', 'integer', 0 );
  75          param( 'validation_process', 'string', true );
  76          $activate_requests_limit = param_duration( 'activate_requests_limit' );
  77          param( 'newusers_findcomments', 'integer', 0 );
  78  
  79          $after_email_validation = param( 'after_email_validation', 'string', 'return_to_original' );
  80          if( $after_email_validation != 'return_to_original' )
  81          {
  82              $after_email_validation = param( 'specific_after_validation_url', 'string', NULL );
  83              param_check_url( 'specific_after_validation_url', 'email_validation' );
  84          }
  85  
  86          $after_registration = param( 'after_registration', 'string', 'return_to_original' );
  87          if( $after_registration != 'return_to_original' )
  88          {
  89              $after_registration = param( 'specific_after_registration_url', 'string', NULL );
  90              param_check_url( 'specific_after_registration_url', 'after_registration' );
  91          }
  92  
  93          param_integer_range( 'user_minpwdlen', 1, 32, T_('Minimum password length must be between %d and %d.') );
  94  
  95          param( 'js_passwd_hashing', 'integer', 0 );
  96          param( 'passwd_special', 'integer', 0 );
  97          param( 'strict_logins', 'integer', 0 );
  98          param( 'registration_require_country', 'integer', 0 );
  99          param( 'registration_require_firstname', 'integer', 0 );
 100          param( 'registration_ask_locale', 'integer', 0 );
 101          param( 'registration_require_gender', 'string', '' );
 102  
 103          // We are about to allow non-ASCII logins
 104          // Let's check if there are users with logins starting with reserved prefix usr_
 105          if( ! $strict_logins && $invalid_users = find_logins_with_reserved_prefix() )
 106          {
 107              // Enforce strict logins until all invalid logins are changed
 108              $strict_logins = true;
 109  
 110              $user_edit_url = regenerate_url( 'ctrl,action', 'ctrl=user&amp;user_tab=profile&amp;user_ID=' );
 111              foreach( $invalid_users as $inv_user )
 112              {
 113                  $msg[] = '<li>'.action_icon( T_('Edit this user...'), 'edit', $user_edit_url.$inv_user->user_ID, 5, 0 ).' [ '.$inv_user->user_login.' ]</li>';
 114              }
 115  
 116              if( !empty($msg) )
 117              {
 118                  $Messages->add( T_('The following user logins must be changed in order for you to disable "Require strict logins" setting:')
 119                              .'<ol style="list-style-type:decimal; list-style-position: inside">'.implode( "\n", $msg ).'</ol>', 'note' );
 120              }
 121          }
 122  
 123          $Settings->set_array( array(
 124                       array( 'newusers_canregister', $newusers_canregister ),
 125                       array( 'newusers_grp_ID', $newusers_grp_ID ),
 126                       array( 'newusers_level', $newusers_level ),
 127                       array( 'def_enable_PM', $enable_PM ),
 128                       array( 'def_enable_email', $enable_email ),
 129                       array( 'def_notify_messages', $notify_messages ),
 130                       array( 'def_notify_unread_messages', $notify_unread_messages ),
 131                       array( 'def_notify_published_comments', $notify_published_comments ),
 132                       array( 'def_notify_comment_moderation', $notify_comment_moderation ),
 133                       array( 'def_notify_post_moderation', $notify_post_moderation ),
 134                       array( 'def_newsletter_news', $newsletter_news ),
 135                       array( 'def_newsletter_ads', $newsletter_ads ),
 136                       array( 'def_notification_email_limit', $notification_email_limit ),
 137                       array( 'def_newsletter_limit', $newsletter_limit ),
 138                       array( 'newusers_mustvalidate', $newusers_mustvalidate ),
 139                       array( 'newusers_revalidate_emailchg', $newusers_revalidate_emailchg ),
 140                       array( 'activate_requests_limit', $activate_requests_limit ),
 141                       array( 'validation_process', $validation_process ),
 142                       array( 'newusers_findcomments', $newusers_findcomments ),
 143                       array( 'after_email_validation', $after_email_validation ),
 144                       array( 'after_registration', $after_registration ),
 145                       array( 'user_minpwdlen', $user_minpwdlen ),
 146                       array( 'js_passwd_hashing', $js_passwd_hashing ),
 147                       array( 'passwd_special', $passwd_special ),
 148                       array( 'strict_logins', $strict_logins ),
 149                       array( 'registration_require_country', $registration_require_country ),
 150                       array( 'registration_require_firstname', $registration_require_firstname ),
 151                       array( 'registration_ask_locale', $registration_ask_locale ),
 152                       array( 'registration_require_gender', $registration_require_gender )
 153                  ) );
 154  
 155          if( ! $Messages->has_errors() )
 156          {
 157              if( $Settings->dbupdate() )
 158              { // update was successful
 159                  if( $old_newusers_canregister != $newusers_canregister )
 160                  { // invalidate all PageCaches
 161                      invalidate_pagecaches();
 162                  }
 163                  $Messages->add( T_('General settings updated.'), 'success' );
 164                  // Redirect so that a reload doesn't write to the DB twice:
 165                  header_redirect( '?ctrl=registration', 303 ); // Will EXIT
 166                  // We have EXITed already at this point!!
 167              }
 168          }
 169  
 170          break;
 171  }
 172  
 173  
 174  $AdminUI->breadcrumbpath_init( false );  // fp> I'm playing with the idea of keeping the current blog in the path here...
 175  $AdminUI->breadcrumbpath_add( T_('Users'), '?ctrl=users' );
 176  $AdminUI->breadcrumbpath_add( T_('Settings'), '?ctrl=usersettings' );
 177  $AdminUI->breadcrumbpath_add( T_('Registration'), '?ctrl=registration' );
 178  
 179  
 180  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
 181  $AdminUI->disp_html_head();
 182  
 183  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
 184  $AdminUI->disp_body_top();
 185  
 186  // Begin payload block:
 187  $AdminUI->disp_payload_begin();
 188  
 189  // Display VIEW:
 190  $AdminUI->disp_view( 'users/views/_registration.form.php' );
 191  
 192  // End payload block:
 193  $AdminUI->disp_payload_end();
 194  
 195  // Display body bottom, debug info and close </html>:
 196  $AdminUI->disp_global_footer();
 197  
 198  ?>

title

Description

title

Description

title

Description

title

title

Body