Commit 46079799 authored by redflo's avatar redflo

[FIX] Make Tiki search work again (wrong include path, missing utf-8

preg check)
[FIX] Show Add Page to structures field
[FIX] Stray Pear auth settings replaced with ldap settings
parent b1170d87
...@@ -263,6 +263,13 @@ class TikiLdapLib { ...@@ -263,6 +263,13 @@ class TikiLdapLib {
public function get_groups() { public function get_groups() {
if(empty($this->user_attributes)) $this->get_user_attributes(); if(empty($this->user_attributes)) $this->get_user_attributes();
// ensure we have a connection to the ldap server
if(!$this->bind()) {
$this->add_log('ldap','Reuse of ldap connection failed: '.$this->ldaplink->getMessage().' at line '.__LINE__.' in '.__FILE__);
return false;
}
$filter1=Net_LDAP2_Filter::create('objectClass','equals',$this->options['groupoc']); $filter1=Net_LDAP2_Filter::create('objectClass','equals',$this->options['groupoc']);
if(!empty($this->options['groupmemberattr'])) { if(!empty($this->options['groupmemberattr'])) {
...@@ -308,7 +315,7 @@ class TikiLdapLib { ...@@ -308,7 +315,7 @@ class TikiLdapLib {
return false; return false;
} }
$this->add_log('ldap','Searching for group entries with filter: '.$filter->asString().' at line '.__LINE__.' in '.__FILE__); $this->add_log('ldap','Searching for group entries with filter: '.$filter->asString().' base '.$this->groupbase_dn().'at line '.__LINE__.' in '.__FILE__);
$searchoptions=array('scope' => $this->options['scope']); $searchoptions=array('scope' => $this->options['scope']);
$searchresult = $this->ldaplink->search($this->groupbase_dn(),$filter,$searchoptions); $searchresult = $this->ldaplink->search($this->groupbase_dn(),$filter,$searchoptions);
...@@ -316,6 +323,7 @@ class TikiLdapLib { ...@@ -316,6 +323,7 @@ class TikiLdapLib {
$this->add_log('ldap','Search failed: '.$searchresult->getMessage().' at line '.__LINE__.' in '.__FILE__); $this->add_log('ldap','Search failed: '.$searchresult->getMessage().' at line '.__LINE__.' in '.__FILE__);
return false; return false;
} }
$this->add_log('ldap','Found '.$searchresult->count().' entries. Extracting entries now.');
while($entry=$searchresult->shiftEntry()) { while($entry=$searchresult->shiftEntry()) {
if (Net_LDAP2::isError($entry)) { if (Net_LDAP2::isError($entry)) {
......
...@@ -193,6 +193,8 @@ function refresh_index_oldest() { ...@@ -193,6 +193,8 @@ function refresh_index_oldest() {
function &search_index($data) { function &search_index($data) {
$preg_utf8_support=preg_match('/\p{Lu}/u', "A" );
// Be sure we will parse UTF-8 data // Be sure we will parse UTF-8 data
if ( function_exists('mb_check_encoding') if ( function_exists('mb_check_encoding')
&& function_exists('iconv') && function_exists('iconv')
...@@ -203,8 +205,8 @@ function &search_index($data) { ...@@ -203,8 +205,8 @@ function &search_index($data) {
} }
// Clean the UTF-8 string using HTML Purifier // Clean the UTF-8 string using HTML Purifier
@ require_once('lib/htmlpurifier/HTMLPurifier.auto.php'); @ include_once('lib/htmlpurifier/HTMLPurifier.auto.php');
@ require_once('lib/htmlpurifier/HTMLPurifier/Encoder.php'); @ include_once('lib/htmlpurifier/HTMLPurifier/Encoder.php');
if ( class_exists('HTMLPurifier_Encoder') ) { if ( class_exists('HTMLPurifier_Encoder') ) {
$data = HTMLPurifier_Encoder::cleanUTF8($data); $data = HTMLPurifier_Encoder::cleanUTF8($data);
} }
...@@ -225,7 +227,11 @@ function &search_index($data) { ...@@ -225,7 +227,11 @@ function &search_index($data) {
$data = function_exists('mb_convert_case') ? mb_convert_case($data, MB_CASE_LOWER, 'UTF-8') : strtolower($data); $data = function_exists('mb_convert_case') ? mb_convert_case($data, MB_CASE_LOWER, 'UTF-8') : strtolower($data);
// Convert punctuations to spaces // Convert punctuations to spaces
$data = preg_replace('/[\pP\pZ\pS]/u', ' ', $data); if ($preg_utf8_support) {
$data = preg_replace('/[\pP\pZ\pS]/u', ' ', $data);
} else {
$data = preg_replace('/[\s\.,!\?\(\)\[\]\{\}\/\\\]/', ' ', $data);
}
if ( $data != '' ) { if ( $data != '' ) {
// Split into words (do NOT use the split function that doesn't correctly handle some characters !) // Split into words (do NOT use the split function that doesn't correctly handle some characters !)
...@@ -233,7 +239,7 @@ function &search_index($data) { ...@@ -233,7 +239,7 @@ function &search_index($data) {
foreach ( $sstrings as $value ) { foreach ( $sstrings as $value ) {
// Keep only alpha-num words // Keep only alpha-num words
if ( preg_match('/^[\pL\pN]+$/u', $value) ) { if ( preg_match('/^[\pL\pN]+$/u', $value) || !$preg_utf8_support ) {
if ( isset($words[$value]) ) { if ( isset($words[$value]) ) {
$words[$value]++; // count words $words[$value]++; // count words
} else { } else {
......
...@@ -18,9 +18,10 @@ function refresh_search_index() { ...@@ -18,9 +18,10 @@ function refresh_search_index() {
list($usec, $sec) = explode(" ",microtime()); list($usec, $sec) = explode(" ",microtime());
srand (ceil($sec+100*$usec)); srand (ceil($sec+100*$usec));
if($prefs['search_refresh_rate'] > 0 && rand(1,$prefs['search_refresh_rate'])==1) { if($prefs['search_refresh_rate'] > 0 && rand(1,$prefs['search_refresh_rate'])==1) {
// print "<pre>refreshing</pre>\n"; // print "<pre>refreshing</pre>\n";
require_once(dirname(__FILE__).'/refresh-functions.php');
// require_once('lib/search/refresh-functions.php');
// get a random location // get a random location
$locs=array(); $locs=array();
if ($prefs['feature_wiki'] == 'y') $locs[]="random_refresh_index_wiki"; if ($prefs['feature_wiki'] == 'y') $locs[]="random_refresh_index_wiki";
......
...@@ -927,9 +927,6 @@ function get_default_prefs() { ...@@ -927,9 +927,6 @@ function get_default_prefs() {
'generate_password' => 'n', 'generate_password' => 'n',
'auth_method' => 'tiki', 'auth_method' => 'tiki',
'auth_pear' => 'tiki', 'auth_pear' => 'tiki',
'auth_create_user_tiki' => 'n',
'auth_create_user_auth' => 'n',
'auth_skip_admin' => 'y',
'auth_ldap_url' => '', 'auth_ldap_url' => '',
'auth_pear_host' => "localhost", 'auth_pear_host' => "localhost",
'auth_pear_port' => "389", 'auth_pear_port' => "389",
......
...@@ -134,7 +134,7 @@ class WikiRenderer ...@@ -134,7 +134,7 @@ class WikiRenderer
$structs_with_perm[] = $t_structs; $structs_with_perm[] = $t_structs;
} }
} }
if ($tikilib->user_has_perm_on_object($this->user,$navigation_info['home']['pageName'],'wiki page','tiki_p_edit','tiki_p_edit_categorized')) if ($tikilib->user_has_perm_on_object($this->user,$navigation_info['home']['pageName'],'wiki page','tiki_p_edit','tiki_p_edit_structures'))
$this->smartyassign('struct_editable', 'y'); $this->smartyassign('struct_editable', 'y');
else else
$this->smartyassign('struct_editable', 'n'); $this->smartyassign('struct_editable', 'n');
......
...@@ -323,7 +323,7 @@ ...@@ -323,7 +323,7 @@
<div class="adminoptionbox"> <div class="adminoptionbox">
<div class="adminoption"><input type="checkbox" id="ldap_create_user_tiki" name="ldap_create_user_tiki" {if $prefs.ldap_create_user_tiki eq 'y'}checked="checked"{/if} /></div> <div class="adminoption"><input type="checkbox" id="ldap_create_user_tiki" name="ldap_create_user_tiki" {if $prefs.ldap_create_user_tiki eq 'y'}checked="checked"{/if} /></div>
<div class="adminoptionlabel"><label for="auth_create_user_tiki">{tr}Create user if not in Tiki{/tr}.</label></div> <div class="adminoptionlabel"><label for="ldap_create_user_tiki">{tr}Create user if not in Tiki{/tr}.</label></div>
</div> </div>
<div class="adminoptionbox"> <div class="adminoptionbox">
......
...@@ -344,14 +344,14 @@ ...@@ -344,14 +344,14 @@
No need to specify user password or to ask him to change it, if : No need to specify user password or to ask him to change it, if :
--> Tiki is using the Tiki + PEAR Auth systems --> Tiki is using the Tiki + PEAR Auth systems
--> AND Tiki won't create the user in the Tiki auth system --> AND Tiki won't create the user in the Tiki auth system
--> AND Tiki won't create the user in the PEAR Auth system --> AND Tiki won't create the user in the ldap
*} *}
{if $prefs.auth_method eq 'auth' and ( $prefs.auth_create_user_tiki eq 'n' or $prefs.auth_skip_admin eq 'y' ) and $prefs.auth_create_user_auth eq 'n' and $userinfo.login neq 'admin'} {if $prefs.auth_method eq 'ldap' and ( $prefs.ldap_create_user_tiki eq 'n' or $prefs.ldap_skip_admin eq 'y' ) and $prefs.ldap_create_user_ldap eq 'n' and $userinfo.login neq 'admin' and $auth_ldap_permit_tiki_users eq 'n'}
<tr class="formcolor"> <tr class="formcolor">
<td colspan="2"> <td colspan="2">
<b>{tr}No password is required{/tr}</b> <b>{tr}No password is required{/tr}</b>
<br /> <br />
<i>{tr}Tikiwiki is configured to delegate the password managment to LDAP through PEAR Auth.{/tr}</i> <i>{tr}Tikiwiki is configured to delegate the password managment to LDAP.{/tr}</i>
</td> </td>
</tr> </tr>
{elseif empty($userinfo) || $tiki_p_admin_users eq 'y' || $userinfo.login eq $user} {elseif empty($userinfo) || $tiki_p_admin_users eq 'y' || $userinfo.login eq $user}
...@@ -370,7 +370,7 @@ ...@@ -370,7 +370,7 @@
{if $prefs.pass_chr_num eq 'y'} {if $prefs.pass_chr_num eq 'y'}
<em>{tr}Password must contain both letters and numbers{/tr}</em>. <em>{tr}Password must contain both letters and numbers{/tr}</em>.
{/if} {/if}
{if ! ( $prefs.auth_method eq 'auth' and ( $prefs.auth_create_user_tiki eq 'n' or $prefs.auth_skip_admin eq 'y' ) and $prefs.auth_create_user_auth eq 'n' ) } {if ! ( $prefs.auth_method eq 'ldap' and ( $prefs.ldap_create_user_tiki eq 'n' or $prefs.ldap_skip_admin eq 'y' ) and $prefs.ldap_create_user_ldap eq 'n' ) }
<p> <p>
<div> <div>
{button href="#" _onclick="genPass('genepass','pass1','pass2');runPassword(document.RegForm.genpass.value, 'mypassword');" _text="{tr}Generate a password{/tr}"} {button href="#" _onclick="genPass('genepass','pass1','pass2');runPassword(document.RegForm.genpass.value, 'mypassword');" _text="{tr}Generate a password{/tr}"}
......
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
</div> </div>
<div style="float: left;"> <div style="float: left;">
{if $tiki_p_edit_structures eq 'y' and $tiki_p_edit_structures eq 'y' and $struct_editable eq 'y'} {if $struct_editable eq 'y'}
<form action="tiki-editpage.php" method="post"> <form action="tiki-editpage.php" method="post">
<input type="hidden" name="current_page_id" value="{$page_info.page_ref_id}" /> <input type="hidden" name="current_page_id" value="{$page_info.page_ref_id}" />
<input type="text" name="page" /> <input type="text" name="page" />
......
...@@ -73,5 +73,6 @@ if ( substr($tikipath,-1,1) != '/' ) $tikipath .= '/'; ...@@ -73,5 +73,6 @@ if ( substr($tikipath,-1,1) != '/' ) $tikipath .= '/';
require_once('lib/init/initlib.php'); require_once('lib/init/initlib.php');
TikiInit::prependIncludePath($tikipath.'lib/pear'); TikiInit::prependIncludePath($tikipath.'lib/pear');
TikiInit::appendIncludePath($tikipath.'lib/core/lib'); TikiInit::appendIncludePath($tikipath.'lib/core/lib');
TikiInit::appendIncludePath($tikipath);
require_once('lib/core/lib/DeclFilter.php'); require_once('lib/core/lib/DeclFilter.php');
require_once('lib/core/lib/JitFilter.php'); require_once('lib/core/lib/JitFilter.php');
...@@ -72,7 +72,10 @@ if ($prefs['feature_debug_console'] == 'y') { ...@@ -72,7 +72,10 @@ if ($prefs['feature_debug_console'] == 'y') {
if ($prefs['feature_integrator'] == 'y') require_once ('lib/setup/integrator.php'); if ($prefs['feature_integrator'] == 'y') require_once ('lib/setup/integrator.php');
if ($prefs['feature_search'] == 'y' && $prefs['feature_search_fulltext'] != 'y' && $prefs['search_refresh_index_mode'] == 'random') { if ($prefs['feature_search'] == 'y' && $prefs['feature_search_fulltext'] != 'y' && $prefs['search_refresh_index_mode'] == 'random') {
include_once ('lib/search/refresh.php'); include_once ('lib/search/refresh.php');
include_once('lib/search/refresh-functions.php');
register_shutdown_function('refresh_search_index'); register_shutdown_function('refresh_search_index');
} }
if (isset($_REQUEST['comzone'])) require_once ('lib/setup/comments_zone.php'); if (isset($_REQUEST['comzone'])) require_once ('lib/setup/comments_zone.php');
if ($prefs['feature_lastup'] == 'y') require_once ('lib/setup/last_update.php'); if ($prefs['feature_lastup'] == 'y') require_once ('lib/setup/last_update.php');
......
...@@ -158,7 +158,7 @@ if ($prefs['feature_userPreferences'] == 'y' && isset($_REQUEST["new_prefs"])) { ...@@ -158,7 +158,7 @@ if ($prefs['feature_userPreferences'] == 'y' && isset($_REQUEST["new_prefs"])) {
foreach($customfields as $custpref => $prefvalue) { foreach($customfields as $custpref => $prefvalue) {
if (isset($_REQUEST[$customfields[$custpref]['prefName']])) $tikilib->set_user_preference($userwatch, $customfields[$custpref]['prefName'], $_REQUEST[$customfields[$custpref]['prefName']]); if (isset($_REQUEST[$customfields[$custpref]['prefName']])) $tikilib->set_user_preference($userwatch, $customfields[$custpref]['prefName'], $_REQUEST[$customfields[$custpref]['prefName']]);
} }
if (isset($_REQUEST["realName"]) && ($prefs['auth_ldap_nameattr'] == '' || $prefs['auth_method'] != 'auth')) $tikilib->set_user_preference($userwatch, 'realName', $_REQUEST["realName"]); if (isset($_REQUEST["realName"]) && ($prefs['auth_ldap_nameattr'] == '' || $prefs['auth_method'] != 'ldap')) $tikilib->set_user_preference($userwatch, 'realName', $_REQUEST["realName"]);
if ($prefs['feature_community_gender'] == 'y') { if ($prefs['feature_community_gender'] == 'y') {
if (isset($_REQUEST["gender"])) $tikilib->set_user_preference($userwatch, 'gender', $_REQUEST["gender"]); if (isset($_REQUEST["gender"])) $tikilib->set_user_preference($userwatch, 'gender', $_REQUEST["gender"]);
} }
...@@ -253,7 +253,7 @@ if ($prefs['feature_userPreferences'] == 'y' && isset($_REQUEST["new_prefs"])) { ...@@ -253,7 +253,7 @@ if ($prefs['feature_userPreferences'] == 'y' && isset($_REQUEST["new_prefs"])) {
$userlib->interSendUserInfo($prefs['interlist'][$prefs['feature_intertiki_mymaster']], $userwatch); $userlib->interSendUserInfo($prefs['interlist'][$prefs['feature_intertiki_mymaster']], $userwatch);
} }
} }
if ($prefs['auth_method'] == 'auth' && $user == 'admin' && $prefs['auth_skip_admin'] == 'y') { if ($prefs['auth_method'] == 'ldap' && $user == 'admin' && $prefs['ldap_skip_admin'] == 'y') {
$change_password = 'y'; $change_password = 'y';
$smarty->assign('change_password', $change_password); $smarty->assign('change_password', $change_password);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment