From 0b27b3d760c6636d471428fe83dafa3dbdbf0c09 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 22 Mar 2016 11:42:05 -0700 Subject: [PATCH] Membersonly enhancement.(option to redirect to login page or membersonly splash page). User Login page minor HTML cleanup. PHP Notice removal. --- class2.php | 1 + e107_admin/prefs.php | 13 +- e107_admin/users_extended.php | 379 +++++++++++++++++- .../shortcodes/batch/login_shortcodes.php | 22 + e107_core/templates/login_template.php | 8 +- e107_core/templates/membersonly_template.php | 2 +- e107_handlers/redirection_class.php | 13 +- e107_handlers/user_extended_class.php | 5 + e107_handlers/user_handler.php | 4 +- e107_languages/English/admin/lan_prefs.php | 6 + e107_themes/bootstrap3/admin_style.css | 2 +- membersonly.php | 2 +- 12 files changed, 422 insertions(+), 35 deletions(-) diff --git a/class2.php b/class2.php index b38d58041..a4b6d3e9a 100644 --- a/class2.php +++ b/class2.php @@ -1737,6 +1737,7 @@ function init_session() define('USERCLASS', ''); define('USEREMAIL', ''); define('USERSIGNATURE', ''); + define('ADMINPERMS', false); if($user->hasSessionError()) { diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index 20cc2a17b..354944cab 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -944,7 +944,7 @@ $text .= " "; */ - + $membersOnlyRedirectOptions = array( 'login'=>PRFLAN_264, 'splash'=>PRFLAN_265); $text .= " @@ -956,9 +956,16 @@ $text .= " $text .= $frm->radio_switch('membersonly_enabled', $pref['membersonly_enabled'],'', '', 'class=e-expandit')."
".PRFLAN_59."
-
". +
+
+ ". + $frm->select('membersonly_redirect',$membersOnlyRedirectOptions,$pref['membersonly_redirect'], array('size'=>'xxlarge'))." +
".PRFLAN_266."
+
+
". $frm->textarea('membersonly_exceptions', $pref['membersonly_exceptions'], 3, 1, 'placeholder='.PRFLAN_206)." -
".PRFLAN_207."
+
".PRFLAN_207."
+
diff --git a/e107_admin/users_extended.php b/e107_admin/users_extended.php index e393b37a0..bc36c5595 100755 --- a/e107_admin/users_extended.php +++ b/e107_admin/users_extended.php @@ -96,9 +96,10 @@ if (isset($_POST['cancel_cat'])) -if(E107_DEBUG_LEVEL > 0) +if(E107_DEBUG_LEVEL > 0 ) { + e107::getMessage()->addDebug("DEBUG is active. These pages are experimental"); class user_extended_adminArea extends e_admin_dispatcher @@ -113,23 +114,54 @@ if(E107_DEBUG_LEVEL > 0) 'uipath' => null ), + 'cat' => array( + 'controller' => 'user_extended_category_struct_ui', + 'path' => null, + 'ui' => 'user_extended_struct_form_ui', + 'uipath' => null + ), + ); protected $adminMenu = array( - 'main/list' => array('caption'=> LAN_MANAGE, 'perm' => 'P'), - 'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'), + 'main/list' => array('caption'=> LAN_MANAGE, 'perm' => '0'), + 'main/add' => array('caption'=> EXTLAN_45, 'perm' => '0'), + 'main/create' => array('caption'=> 'Add Custom Field', 'perm' => '0'), + 'cat/list' => array('caption'=> LAN_CATEGORIES, 'perm' => '0'), + 'cat/create' => array('caption'=> LAN_CREATE_CATEGORY, 'perm' => '0'), + // 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P') ); + /* + * } + $var['main']['text'] = EXTLAN_34; + $var['main']['link'] = e_SELF; + + $var['pre']['text'] = EXTLAN_45; + $var['pre']['link'] = e_SELF."?pre"; + + $var['editext']['text'] = "Add Custom Field"; + $var['editext']['link'] = e_SELF."?editext"; + + $var['cat']['text'] = EXTLAN_35; + $var['cat']['link'] = e_SELF."?cat"; + + + + show_admin_menu(EXTLAN_9, $action, $var); + } + */ + protected $adminMenuAliases = array( 'main/edit' => 'main/list' ); - protected $menuTitle = 'user_extended'; + protected $menuTitle = EXTLAN_9; } @@ -139,7 +171,7 @@ if(E107_DEBUG_LEVEL > 0) class user_extended_struct_ui extends e_admin_ui { - protected $pluginTitle = 'user_extended'; + protected $pluginTitle = EXTLAN_9; protected $pluginName = 'user_extended'; // protected $eventName = 'user_extended-user_extended_struct'; // remove comment to enable event triggers in admin. protected $table = 'user_extended_struct'; @@ -149,26 +181,34 @@ if(E107_DEBUG_LEVEL > 0) // protected $batchCopy = true; // protected $sortField = 'somefield_order'; // protected $orderStep = 10; - // protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable. + protected $tabs = array(LAN_BASIC,LAN_ADVANCED); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable. protected $listQry = "SELECT * FROM `#user_extended_struct` WHERE user_extended_struct_type != 0 AND user_extended_struct_text != '_system_' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit. protected $listOrder = 'user_extended_struct_order ASC'; - protected $fields = array ( 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ), - 'user_extended_struct_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), - 'user_extended_struct_name' => array ( 'title' => LAN_NAME, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => 'pre=user_', 'class' => 'left', 'thclass' => 'left', ), + protected $fields = array ( + 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ), + 'user_extended_struct_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'user_extended_struct_name' => array ( 'title' => LAN_NAME, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => 'tdClassRight=form-inline&pre=user_ ', 'class' => 'left', 'thclass' => 'left', ), 'user_extended_struct_text' => array ( 'title' => EXTLAN_79, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => 'constant=1', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'user_extended_struct_type' => array ( 'title' => EXTLAN_2, 'type' => 'method', 'data' => 'int', 'width' => 'auto', 'batch' => true, 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), - 'user_extended_struct_values' => array ( 'title' => LAN_VALUES, 'type' => 'method', 'nolist'=>true, 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'user_extended_struct_values' => array ( 'title' => "Values", 'type' => 'method', 'nolist'=>true, 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'user_extended_struct_default' => array ( 'title' => LAN_DEFAULT, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), - 'user_extended_struct_parent' => array ( 'title' => LAN_CATEGORY, 'type' => 'dropdown', 'data' => 'int', 'width' => 'auto', 'batch' => true, 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), - 'user_extended_struct_required' => array ( 'title' => EXTLAN_4, 'type' => 'boolean', 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'field_include' => array('title'=> EXTLAN_15, 'tab'=>1, 'type'=>'textarea', 'data'=>false, 'help'=>EXTLAN_51), + 'field_regex' => array('title'=> EXTLAN_52, 'tab'=>1, 'type'=>'text', 'data'=>false, 'help'=> EXTLAN_53), + 'field_regexfail' => array('title'=> EXTLAN_54, 'tab'=>1, 'type'=>'text', 'data'=>false, 'help'=>EXTLAN_55), + 'field_placeholder' => array('title'=>'Placeholder', 'tab'=>1, 'type'=>'text', 'data'=>false, 'writeParms'=>array('size'=>'xlarge')), + + + + + 'user_extended_struct_parent' => array ( 'title' => LAN_CATEGORY, 'type' => 'dropdown', 'data' => 'int', 'width' => 'auto', 'batch' => true, 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => array('size'=>'xxlarge'), 'class' => 'left', 'thclass' => 'left', ), + 'user_extended_struct_required' => array ( 'title' => EXTLAN_4, 'type' => 'method', 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'user_extended_struct_applicable' => array ( 'title' => EXTLAN_5, 'type' => 'userclass', 'data' => 'int', 'width' => '10%', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), - - 'user_extended_struct_parms' => array ( 'title' => LAN_PARMS, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), - 'user_extended_struct_default' => array ( 'title' => LAN_DEFAULT, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'user_extended_struct_parms' => array ( 'title' => "Params", 'type' => 'hidden', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'user_extended_struct_read' => array ( 'title' =>EXTLAN_6, 'type' => 'userclass', 'data' => 'int', 'width' => '10%', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'user_extended_struct_write' => array ( 'title' => 'Write Access', 'type' => 'userclass', 'data' => 'int', 'width' => '10%', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'user_extended_struct_signup' => array ( 'title' => 'Signup', 'type' => 'boolean', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), @@ -192,14 +232,36 @@ if(E107_DEBUG_LEVEL > 0) $this->fields['user_extended_struct_type']['title'] = LAN_TYPE; } - $this->fields['user_extended_struct_parent']['writeParms'] = array('user_extended_struct_parent_0','user_extended_struct_parent_1', 'user_extended_struct_parent_2'); // Example Drop-down array. + + + + + + + + // $this->fields['user_extended_struct_parent']['writeParms']['optArray'] = array('user_extended_struct_parent_0','user_extended_struct_parent_1', 'user_extended_struct_parent_2'); // Example Drop-down array. + $data = e107::getDb()->retrieve("user_extended_struct", "*", "user_extended_struct_type = 0 ORDER BY user_extended_struct_order ASC", true); + // $catList = e107::getUserExt()->user_extended_get_categories(); + + $opts = array(); + $opts[0] = EXTLAN_36; + + foreach($data as $row) + { + $id = $row['user_extended_struct_id']; + $opts[$id] = $row['user_extended_struct_name']; + } + + + $this->fields['user_extended_struct_parent']['writeParms']['optArray'] = $opts; + } // ------- Customize Create -------- - public function beforeCreate($new_data) + public function beforeCreate($new_data, $old_data) { return $new_data; } @@ -232,6 +294,161 @@ if(E107_DEBUG_LEVEL > 0) // do something } + function addPageActivate() + { + $ue = e107::getUserExt(); + $tp = e107::getParser(); + $ret = ""; + $preList = $ue->parse_extended_xml('getfile'); + $tmp = $preList; + + foreach(array_keys($_POST['activate']) as $f) + { + + $tmp[$f]['parms'] = $tp->toDB($tmp[$f]['parms']); + if($ue->user_extended_add($tmp[$f])) + { + $ret .= EXTLAN_68." $f ".EXTLAN_69."
"; + + if ($tmp[$f]['type']=="db field") + { + if (is_readable(e_CORE.'sql/extended_'.$f.'.php')) + { + // $ret .= ($this->process_sql($f)) ? LAN_CREATED." user_extended_{$f}
" : LAN_CREATED_FAILED." user_extended_{$f}
"; + } + else + { + $ret .= str_replace('--FILE--',e_CORE.'sql/extended_'.$f.'.php',EXTLAN_78); + } + } + } + else + { + $ret .= EXTLAN_70." $f ".EXTLAN_71."
"; + } + } + + e107::getLog()->add('EUF_11',implode(', ',$_POST['activate']),E_LOG_INFORMATIVE,''); + e107::getMessage()->addSuccess($ret); + return $ret; + } + + + + + + + function addPage() + { + + $ns = e107::getRender(); + $ue = e107::getUserExt(); + + $this->addPageActivate(); + + + // Get list of current extended fields + $curList = $ue->user_extended_get_fieldlist(); + foreach($curList as $c) + { + $curNames[] = $c['user_extended_struct_name']; + } + + //Get list of predefined fields. + $preList = $ue->parse_extended_xml('getfile'); + ksort($preList); + + $txt = " +
+ + + + + + + + + + + + + + + + + + + + "; + + foreach($preList as $k=>$a) + { + if($k !='version') // don't know why this is appearing in the array. + { + $active = (in_array($a['name'], $curNames)) ? TRUE : FALSE; + $txt .= $this->show_predefined_field($a,$active); + } + } + + $txt .= "
".UE_LAN_21."".EXTLAN_79."".EXTLAN_2."".UE_LAN_22."".EXTLAN_57."".LAN_OPTIONS."
"; + + $emessage = e107::getMessage(); + + + return $txt; + $ns->tablerender(EXTLAN_9.SEP.EXTLAN_56,$emessage->render(). $txt); + + } + + + + + function show_predefined_field($var, $active) + { + + static $head_shown; + $txt = ""; + $tp = e107::getParser(); + $ue = e107::getUserExt(); + $frm = e107::getForm(); + + foreach($var as $key=>$val) // convert predefined xml to default array format + { + $var['user_extended_struct_'.$key] = $val; + } + + $var['user_extended_struct_type'] = $ue->typeArray[$var['user_extended_struct_type']]; + $var['user_extended_struct_parms'] = $var['include_text']; + + $txt .= " + + {$var['user_extended_struct_name']} + ".constant(strtoupper($var['user_extended_struct_text'])."_DESC")." + ".$ue->user_extended_edit($var,$uVal)." + ".$tp->toHTML($var['type'], false, 'defs')." + ".($active ? ADMIN_TRUE_ICON : " ")." + "; + // $txt .= constant("UE_LAN_".strtoupper($var['text'])."DESC")."
"; + // foreach($showlist as $f) + // { + // if($var[$f] != "" && $f != 'type' && $f !='text') + // { + // $txt .= "{$f}: ".$tp->toHTML($var[$f], false, 'defs')."
"; + // } + // } + $val = (!$active) ? EXTLAN_59 : EXTLAN_60; + $type = (!$active) ? 'activate' : 'deactivate'; + $style = (!$active) ? 'other' : 'delete'; + + $txt .= " + "; + $txt .= $frm->admin_button($type."[".$var['user_extended_struct_name']."]", $val, $style ); + $txt .= " + "; + return $txt; + } + + /* // optional - a custom page. @@ -255,13 +472,13 @@ if(E107_DEBUG_LEVEL > 0) // Custom Method/Function function user_extended_struct_type($curVal,$mode) { - $frm = e107::getForm(); switch($mode) { case 'read': // List Page $ext = $this->getController()->getListModel()->getData(); - return e107::getUserExt()->user_extended_edit($ext,$uVal); + + return e107::getUserExt()->user_extended_edit($ext,$ext['user_extended_struct_default']); // reutrn e107::getParser()>toHTML(deftrue($ext['user_extended_struct_text'], $ext['user_extended_struct_text']), FALSE, "defs") break; @@ -290,7 +507,31 @@ if(E107_DEBUG_LEVEL > 0) } + function user_extended_struct_required($curVal, $mode) + { + $opts = array('0' => EXTLAN_65, '1' => EXTLAN_66, '2' => EXTLAN_67); + switch($mode) + { + case 'read': // List Page + return $opts[$curVal]; + break; + + case 'write': // Edit Page + + + return $this->select('user_required',$opts, varset($curVal,1),'size=xxlarge'); + break; + + case 'filter': + case 'batch': + return array(); + break; + } + + + + } @@ -298,8 +539,6 @@ if(E107_DEBUG_LEVEL > 0) // Custom Method/Function function user_extended_struct_values($curVal,$mode) { - $frm = e107::getForm(); - switch($mode) { case 'read': // List Page @@ -322,6 +561,7 @@ if(E107_DEBUG_LEVEL > 0) function renderStructValues($curVal) { $sql = e107::getDb(); + $frm = e107::getForm(); $current = $this->getController()->getModel()->getData(); @@ -424,6 +664,8 @@ if(E107_DEBUG_LEVEL > 0) $text .= "
"; // --------------------------------------------------------- + $text .= "
".$frm->checkbox('sort_user_values',1, false, "Sort values")."
"; + return $text; @@ -434,6 +676,101 @@ if(E107_DEBUG_LEVEL > 0) + class user_extended_category_struct_ui extends e_admin_ui + { + + protected $pluginTitle = EXTLAN_9; + protected $pluginName = 'user_extended'; + // protected $eventName = 'user_extended-user_extended_struct'; // remove comment to enable event triggers in admin. + protected $table = 'user_extended_struct'; + protected $pid = 'user_extended_struct_id'; + protected $perPage = 10; + protected $batchDelete = true; + // protected $batchCopy = true; + // protected $sortField = 'somefield_order'; + // protected $orderStep = 10; + // protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable. + + protected $listQry = "SELECT * FROM `#user_extended_struct` WHERE user_extended_struct_type = 0 AND user_extended_struct_text != '_system_' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit. + + protected $listOrder = 'user_extended_struct_order ASC'; + + protected $fields = array ( + 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ), + 'user_extended_struct_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'user_extended_struct_name' => array ( 'title' => LAN_NAME, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'user_extended_struct_text' => array ( 'title' => EXTLAN_79, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => 'constant=1', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'user_extended_struct_type' => array ( 'title' => EXTLAN_2, 'type' => 'hidden', 'nolist'=>true, 'data' => 'int', 'width' => 'auto', 'batch' => true, 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => array('default'=>0), 'class' => 'left', 'thclass' => 'left', ), + // 'user_extended_struct_values' => array ( 'title' => "Values", 'type' => 'method', 'nolist'=>true, 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + // 'user_extended_struct_default' => array ( 'title' => LAN_DEFAULT, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + + // 'user_extended_struct_parent' => array ( 'title' => LAN_CATEGORY, 'type' => 'dropdown', 'data' => 'int', 'width' => 'auto', 'batch' => true, 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => array('size'=>'xxlarge'), 'class' => 'left', 'thclass' => 'left', ), + // 'user_extended_struct_required' => array ( 'title' => EXTLAN_4, 'type' => 'method', 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'user_extended_struct_applicable' => array ( 'title' => EXTLAN_5, 'type' => 'userclass', 'data' => 'int', 'width' => '15%', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + + + // 'user_extended_struct_parms' => array ( 'title' => "Params", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'user_extended_struct_read' => array ( 'title' =>EXTLAN_6, 'type' => 'userclass', 'data' => 'int', 'width' => '15%', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'user_extended_struct_write' => array ( 'title' => 'Write Access', 'type' => 'userclass', 'data' => 'int', 'width' => '15%', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + // 'user_extended_struct_signup' => array ( 'title' => 'Signup', 'type' => 'boolean', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'user_extended_struct_order' => array ( 'title' => LAN_ORDER, 'type' => 'number', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'right', 'thclass' => 'right', ), + 'options' => array ( 'title' => LAN_OPTIONS, 'type' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', 'readParms'=>'sort=0' ), + ); + + protected $fieldpref = array('user_extended_struct_name', 'user_extended_struct_text', 'user_extended_struct_read', 'user_extended_struct_write', 'user_extended_struct_applicable'); + + + protected $prefs = array( + ); + + + public function init() + { + // Set drop-down values (if any). + + + + } + + + // ------- Customize Create -------- + + public function beforeCreate($new_data, $old_data) + { + return $new_data; + } + + public function afterCreate($new_data, $old_data, $id) + { + // do something + } + + public function onCreateError($new_data, $old_data) + { + // do something + } + + + // ------- Customize Update -------- + + public function beforeUpdate($new_data, $old_data, $id) + { + return $new_data; + } + + public function afterUpdate($new_data, $old_data, $id) + { + // do something + } + + public function onUpdateError($new_data, $old_data, $id) + { + // do something + } + + + + } diff --git a/e107_core/shortcodes/batch/login_shortcodes.php b/e107_core/shortcodes/batch/login_shortcodes.php index 64b72b5c6..a5328d506 100644 --- a/e107_core/shortcodes/batch/login_shortcodes.php +++ b/e107_core/shortcodes/batch/login_shortcodes.php @@ -177,6 +177,28 @@ class login_shortcodes extends e_shortcode return $text; } + + function sc_login_table_signup_link($parm='') + { + if(empty($this->userReg)) + { + return null; + } + + return "".LAN_LOGIN_11.""; + + + } + + function sc_login_table_fpw_link($parm='') + { + if(empty($this->userReg)) + { + return null; + } + + return "".LAN_LOGIN_12.""; + } } diff --git a/e107_core/templates/login_template.php b/e107_core/templates/login_template.php index 4fb716984..bf59fd9c7 100644 --- a/e107_core/templates/login_template.php +++ b/e107_core/templates/login_template.php @@ -91,7 +91,7 @@ $LOGIN_TEMPLATE['page']['header'] = " $LOGIN_TEMPLATE['page']['body'] = '

'.LAN_LOGIN_4.'

'; - if ($pref['password_CHAP'] == 2) + if (e107::pref('core', 'password_CHAP') == 2) { $LOGIN_TEMPLATE['page']['body'] .= "
"."Javascript must be enabled in your browser if you wish to log into this site"." @@ -110,6 +110,7 @@ $LOGIN_WRAPPER['page']['LOGIN_TABLE_SECIMG_TEXTBOC'] = "
$LOGIN_WRAPPER['page']['LOGIN_TABLE_REMEMBERME'] = "
{---}
"; $LOGIN_WRAPPER['page']['LOGIN_TABLE_SUBMIT'] = "
{---}
"; $LOGIN_WRAPPER['page']['LOGIN_TABLE_FOOTER_USERREG'] = "
{---}
"; +// $LOGIN_WRAPPER['page']['LOGIN_TABLE_FPW_LINK'] = "
{---}
"; $LOGIN_TEMPLATE['page']['body'] .= ' {LOGIN_TABLE_USERNAME} @@ -122,8 +123,9 @@ $LOGIN_TEMPLATE['page']['body'] .= ' '; $LOGIN_TEMPLATE['page']['footer'] = " -
-
{LOGIN_TABLE_FOOTER_USERREG}
+
+

{LOGIN_TABLE_SIGNUP_LINK}

+

{LOGIN_TABLE_FPW_LINK}

"; diff --git a/e107_core/templates/membersonly_template.php b/e107_core/templates/membersonly_template.php index e2010fe27..408495e7e 100755 --- a/e107_core/templates/membersonly_template.php +++ b/e107_core/templates/membersonly_template.php @@ -29,7 +29,7 @@ $MEMBERSONLY_END = "
"; $MEMBERSONLY_TEMPLATE['default']['caption'] = LAN_MEMBERS_0; $MEMBERSONLY_TEMPLATE['default']['header'] = "


"; - $MEMBERSONLY_TEMPLATE['default']['body'] = "
+ $MEMBERSONLY_TEMPLATE['default']['body'] = "
{MEMBERSONLY_RESTRICTED_AREA} {MEMBERSONLY_LOGIN} {MEMBERSONLY_SIGNUP}

{MEMBERSONLY_RETURNTOHOME} diff --git a/e107_handlers/redirection_class.php b/e107_handlers/redirection_class.php index e931fbd9d..8291b983c 100644 --- a/e107_handlers/redirection_class.php +++ b/e107_handlers/redirection_class.php @@ -50,9 +50,11 @@ class redirection */ function __construct() { - $this->self_exceptions = array(e_SIGNUP, SITEURL, SITEURL.'index.php', SITEURL.'fpw.php', e_LOGIN, SITEURL.'membersonly.php'); - $this->page_exceptions = array('e_ajax.php', 'e_js.php', 'e_jslib.php', 'sitedown.php',e_LOGIN); + $this->self_exceptions = array(e_SIGNUP, SITEURL.'fpw.php', e_LOGIN, SITEURL.'membersonly.php'); + $this->page_exceptions = array('e_ajax.php', 'e_js.php', 'e_jslib.php', 'sitedown.php',e_LOGIN, 'secimg.php'); $this->query_exceptions = array('logout'); + + // Remove from self_exceptions: SITEURL, SITEURL.'index.php', // allows a custom frontpage to be viewed while logged out and membersonly active. } /** @@ -280,7 +282,12 @@ class redirection */ $this->saveMembersOnlyUrl(); - $this->redirect(e_HTTP.'membersonly.php'); + + $redirectType = e107::getPref('membersonly_redirect'); + + $redirectURL = ($redirectType == 'splash') ? 'membersonly.php' : 'login.php'; + + $this->redirect(e_HTTP.$redirectURL); } diff --git a/e107_handlers/user_extended_class.php b/e107_handlers/user_extended_class.php index 2d4140ae3..79f2eb80f 100644 --- a/e107_handlers/user_extended_class.php +++ b/e107_handlers/user_extended_class.php @@ -958,6 +958,11 @@ class e107_user_extended } + /** + * @param $contents + * @param bool|false $no_cache + * @return array + */ function parse_extended_xml($contents, $no_cache = FALSE) { if($no_cache == FALSE && $this->extended_xml) diff --git a/e107_handlers/user_handler.php b/e107_handlers/user_handler.php index 7bf50ee4e..ec0f9c112 100644 --- a/e107_handlers/user_handler.php +++ b/e107_handlers/user_handler.php @@ -64,7 +64,7 @@ class UserHandler public function __construct() { $pref = e107::getPref(); - + e107::lan('core','user'); /** Table of vetting methods for user data - lists every field whose value could be set manually. Valid 'vetMethod' values (use comma separated list for multiple vetting): @@ -88,7 +88,7 @@ class UserHandler 'enablePref' - value is processed only if the named $pref evaluates to true; otherwise any input is discarded without error */ $this->userVettingInfo = array( - 'user_name' => array('niceName'=> LAN_USER_01, 'fieldType' => 'string', 'vetMethod' => '1,2', 'vetParam' => 'signup_disallow_text', 'srcName' => 'username', 'stripTags' => TRUE, 'stripChars' => '/ |\#|\=|\$/', fixedBlock => 'anonymous', 'minLength' => 2, 'maxLength' => varset($pref['displayname_maxlength'],15)), // Display name + 'user_name' => array('niceName'=> LAN_USER_01, 'fieldType' => 'string', 'vetMethod' => '1,2', 'vetParam' => 'signup_disallow_text', 'srcName' => 'username', 'stripTags' => TRUE, 'stripChars' => '/ |\#|\=|\$/', 'fixedBlock' => 'anonymous', 'minLength' => 2, 'maxLength' => varset($pref['displayname_maxlength'],15)), // Display name 'user_loginname' => array('niceName'=> LAN_USER_02, 'fieldType' => 'string', 'vetMethod' => '1', 'vetParam' => '', 'srcName' => 'loginname', 'stripTags' => TRUE, 'stripChars' => '#[^a-z0-9_\.]#i', 'minLength' => 2, 'maxLength' => varset($pref['loginname_maxlength'],30)), // User name 'user_login' => array('niceName'=> LAN_USER_03, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'realname', 'dbClean' => 'toDB'), // Real name (no real vetting) 'user_customtitle' => array('niceName'=> LAN_USER_04, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'customtitle', 'dbClean' => 'toDB', 'enablePref' => 'signup_option_customtitle'), // No real vetting diff --git a/e107_languages/English/admin/lan_prefs.php b/e107_languages/English/admin/lan_prefs.php index 500458aeb..1d9d3f8fc 100644 --- a/e107_languages/English/admin/lan_prefs.php +++ b/e107_languages/English/admin/lan_prefs.php @@ -280,4 +280,10 @@ define("PRFLAN_261", "Field options"); define("PRFLAN_262", "Password in Email Confirmation"); define("PRFLAN_263", "Should be unique to this website"); +define("PRFLAN_264", "Frontpage is login page (login.php)"); +define("PRFLAN_265", "Frontpage is splash page (membersonly.php)"); +define("PRFLAN_266", "When logged out, which page should the user be directed to?"); + + + ?> \ No newline at end of file diff --git a/e107_themes/bootstrap3/admin_style.css b/e107_themes/bootstrap3/admin_style.css index a97e19734..0de5b2d9c 100644 --- a/e107_themes/bootstrap3/admin_style.css +++ b/e107_themes/bootstrap3/admin_style.css @@ -1236,7 +1236,7 @@ li.rssRow > div { .alert-warning pre { color: white } - +.xdebug-error { color: black; font-size:1.5em } /* diff --git a/membersonly.php b/membersonly.php index f75eb8026..317d4fa96 100644 --- a/membersonly.php +++ b/membersonly.php @@ -61,7 +61,7 @@ class membersonly function sc_membersonly_returntohome() { - return "".LAN_MEMBERS_4.""; + return "".LAN_MEMBERS_4.""; } function sc_membersonly_restricted_area()