Skip to content
This repository
Browse code

Fixes #2339 - removes social library and deprecates its two functions…

… (put it output.php for lack of a better location)

git-svn-id: http://code.elgg.org/elgg/trunk@7078 36083f99-b078-4883-b0ff-0f9b5a30f544
  • Loading branch information...
commit 06b1e918d5b47be44536981876ce8a11edfa31e8 1 parent 79527ef
Cash Costello authored October 14, 2010
11  engine/lib/elgglib.php
@@ -2265,6 +2265,17 @@ function elgg_init() {
2265 2265
 
2266 2266
 	// Trigger the shutdown:system event upon PHP shutdown.
2267 2267
 	register_shutdown_function('__elgg_shutdown_hook');
  2268
+
  2269
+	// Sets a blacklist of words in the current language.
  2270
+	// This is a comma separated list in word:blacklist.
  2271
+	// @todo possibly deprecate
  2272
+	$CONFIG->wordblacklist = array();
  2273
+	$list = explode(',', elgg_echo('word:blacklist'));
  2274
+	if ($list) {
  2275
+		foreach ($list as $l) {
  2276
+			$CONFIG->wordblacklist[] = trim($l);
  2277
+		}
  2278
+	}
2268 2279
 }
2269 2280
 
2270 2281
 /**
57  engine/lib/output.php
@@ -263,3 +263,60 @@ function elgg_strip_tags($string) {
263 263
 
264 264
 	return $string;
265 265
 }
  266
+
  267
+/**
  268
+  * Filters a string into an array of significant words
  269
+  *
  270
+  * @deprecated 1.8
  271
+  * @param string $string
  272
+  * @return array
  273
+  */
  274
+function filter_string($string) {
  275
+	elgg_deprecated_notice('filter_string() was deprecated!', 1.8);
  276
+
  277
+	// Convert it to lower and trim
  278
+	$string = strtolower($string);
  279
+	$string = trim($string);
  280
+
  281
+	// Remove links and email addresses
  282
+	// match protocol://address/path/file.extension?some=variable&another=asf%
  283
+	$string = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu"," ", $string);
  284
+	// match www.something.domain/path/file.extension?some=variable&another=asf%
  285
+	$string = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu"," ", $string);
  286
+	// match name@address
  287
+	$string = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/iu"," ", $string);
  288
+
  289
+	// Sanitise the string; remove unwanted characters
  290
+	$string = preg_replace('/\W/ui', ' ', $string);
  291
+
  292
+	// Explode it into an array
  293
+	$terms = explode(' ',$string);
  294
+
  295
+	// Remove any blacklist terms
  296
+	//$terms = array_filter($terms, 'remove_blacklist');
  297
+
  298
+	return $terms;
  299
+}
  300
+
  301
+/**
  302
+ * Returns true if the word in $input is considered significant
  303
+ *
  304
+ * @deprecated 1.8
  305
+ * @param string $input
  306
+ * @return true|false
  307
+ */
  308
+function remove_blacklist($input) {
  309
+	elgg_deprecated_notice('remove_blacklist() was deprecated!', 1.8);
  310
+
  311
+	global $CONFIG;
  312
+
  313
+	if (!is_array($CONFIG->wordblacklist)) {
  314
+		return $input;
  315
+	}
  316
+
  317
+	if (strlen($input) < 3 || in_array($input,$CONFIG->wordblacklist)) {
  318
+		return false;
  319
+	}
  320
+
  321
+	return true;
  322
+}
119  engine/lib/social.php
... ...
@@ -1,119 +0,0 @@
1  
-<?php
2  
-/**
3  
- * Elgg Social
4  
- * Functions and objects which provide powerful social aspects within Elgg
5  
- *
6  
- * @package Elgg
7  
- * @subpackage Core
8  
- * @author Curverider
9  
- * @link http://elgg.org/
10  
-
11  
-/**
12  
-  * Filters a string into an array of significant words
13  
-  *
14  
-  * @param string $string
15  
-  * @return array
16  
-  */
17  
-function filter_string($string) {
18  
-	// Convert it to lower and trim
19  
-	$string = strtolower($string);
20  
-	$string = trim($string);
21  
-
22  
-	// Remove links and email addresses
23  
-	// match protocol://address/path/file.extension?some=variable&another=asf%
24  
-	$string = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu"," ", $string);
25  
-	// match www.something.domain/path/file.extension?some=variable&another=asf%
26  
-	$string = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu"," ", $string);
27  
-	// match name@address
28  
-	$string = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/iu"," ", $string);
29  
-
30  
-	// Sanitise the string; remove unwanted characters
31  
-	$string = preg_replace('/\W/ui', ' ', $string);
32  
-
33  
-	// Explode it into an array
34  
-	$terms = explode(' ',$string);
35  
-
36  
-	// Remove any blacklist terms
37  
-	//$terms = array_filter($terms, 'remove_blacklist');
38  
-
39  
-	return $terms;
40  
-}
41  
-
42  
-/**
43  
- * Returns true if the word in $input is considered significant
44  
- *
45  
- * @param string $input
46  
- * @return true|false
47  
- */
48  
-function remove_blacklist($input) {
49  
-	global $CONFIG;
50  
-
51  
-	if (!is_array($CONFIG->wordblacklist)) {
52  
-		return $input;
53  
-	}
54  
-
55  
-	if (strlen($input) < 3 || in_array($input,$CONFIG->wordblacklist)) {
56  
-		return false;
57  
-	}
58  
-
59  
-	return true;
60  
-}
61  
-
62  
-
63  
-/**
64  
- * Initialise.
65  
- *
66  
- * Sets a blacklist of words in the current language. This is a comma separated list in word:blacklist.
67  
- */
68  
-function social_init() {
69  
-	global $CONFIG;
70  
-
71  
-	$CONFIG->wordblacklist = array();
72  
-
73  
-	$list = explode(',', elgg_echo('word:blacklist'));
74  
-	if ($list) {
75  
-		foreach ($list as $l) {
76  
-			$CONFIG->wordblacklist[] = trim($l);
77  
-		}
78  
-	} else {
79  
-		// Fallback - shouldn't happen
80  
-		$CONFIG->wordblacklist = array(
81  
-			'and',
82  
-			'the',
83  
-			'then',
84  
-			'but',
85  
-			'she',
86  
-			'his',
87  
-			'her',
88  
-			'him',
89  
-			'one',
90  
-			'not',
91  
-			'also',
92  
-			'about',
93  
-			'now',
94  
-			'hence',
95  
-			'however',
96  
-			'still',
97  
-			'likewise',
98  
-			'otherwise',
99  
-			'therefore',
100  
-			'conversely',
101  
-			'rather',
102  
-			'consequently',
103  
-			'furthermore',
104  
-			'nevertheless',
105  
-			'instead',
106  
-			'meanwhile',
107  
-			'accordingly',
108  
-			'this',
109  
-			'seems',
110  
-			'what',
111  
-			'whom',
112  
-			'whose',
113  
-			'whoever',
114  
-			'whomever',
115  
-		);
116  
-	}
117  
-}
118  
-
119  
-register_elgg_event_handler("init","system","social_init");
2  engine/start.php
@@ -98,7 +98,7 @@
98 98
 	'memcache.php', 'metadata.php', 'metastrings.php', 'notification.php',
99 99
 	'objects.php', 'opendd.php', 'pagehandler.php',
100 100
 	'pageowner.php', 'pam.php', 'plugins.php', 'query.php',
101  
-	'relationships.php', 'river.php', 'sites.php', 'social.php',
  101
+	'relationships.php', 'river.php', 'sites.php',
102 102
 	'statistics.php', 'system_log.php', 'tags.php', 'usersettings.php',
103 103
 	'users.php', 'version.php', 'widgets.php', 'xml.php', 'xml-rpc.php'
104 104
 );
2  install/ElggInstaller.php
@@ -708,7 +708,7 @@ protected function finishBootstraping($step) {
708 708
 				'memcache.php', 'metadata.php', 'metastrings.php', 'notification.php',
709 709
 				'objects.php', 'opendd.php', 'pagehandler.php',
710 710
 				'pageowner.php', 'pam.php', 'plugins.php', 'query.php',
711  
-				'relationships.php', 'river.php', 'sites.php', 'social.php',
  711
+				'relationships.php', 'river.php', 'sites.php',
712 712
 				'statistics.php', 'tags.php', 'usersettings.php',
713 713
 				'users.php', 'version.php', 'widgets.php', 'xml.php', 'xml-rpc.php'
714 714
 			);

0 notes on commit 06b1e91

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