Changeset 1251
- Timestamp:
- 11/05/07 19:53:44 (1 year ago)
- Files:
-
- devel/_groups (deleted)
- devel/_invite (deleted)
- devel/_rss (deleted)
- devel/includes_system.php (modified) (1 diff)
- devel/lib/elgglib.php (modified) (3 diffs)
- devel/lib/php-getttext/gettext.inc (modified) (1 diff)
- devel/lib/setup.php (modified) (1 diff)
- devel/lib/templates.php (modified) (5 diffs)
- devel/lib/userlib.php (modified) (14 diffs)
- devel/lib/xmllib.php (added)
- devel/mod/blog/README (modified) (5 diffs)
- devel/mod/blog/interesting.php (modified) (1 diff)
- devel/mod/blog/lib.php (modified) (15 diffs)
- devel/mod/blog/lib/permissions_check.php (modified) (1 diff)
- devel/mod/blog/lib/weblogs_actions.php (modified) (3 diffs)
- devel/mod/blog/lib/weblogs_posts_add.php (modified) (4 diffs)
- devel/mod/blog/lib/weblogs_posts_edit.php (modified) (6 diffs)
- devel/mod/blog/lib/weblogs_posts_view.php (modified) (6 diffs)
- devel/mod/blog/lib/weblogs_user_info_menu.php (modified) (1 diff)
- devel/mod/blog/rss2.php (modified) (1 diff)
- devel/mod/groups (added)
- devel/mod/groups/INSTALL (added)
- devel/mod/groups/LICENSE (added)
- devel/mod/groups/index.php (added)
- devel/mod/groups/lib (added)
- devel/mod/groups/lib.php (added)
- devel/mod/groups/lib/function_access_level_sql_where.php (added)
- devel/mod/groups/lib/get_groups.php (added)
- devel/mod/groups/lib/get_groups_external.php (added)
- devel/mod/groups/lib/get_groups_membership.php (added)
- devel/mod/groups/lib/group_access_level_check.php (added)
- devel/mod/groups/lib/groups_access_levels.php (added)
- devel/mod/groups/lib/groups_actions.php (added)
- devel/mod/groups/lib/groups_create.php (added)
- devel/mod/groups/lib/groups_display_membership.php (added)
- devel/mod/groups/lib/groups_edit_display.php (added)
- devel/mod/groups/lib/groups_edit_existing.php (added)
- devel/mod/groups/lib/groups_editpage.php (added)
- devel/mod/groups/lib/groups_explanation.php (added)
- devel/mod/groups/lib/groups_help.php (added)
- devel/mod/invite (added)
- devel/mod/invite/INSTALL (added)
- devel/mod/invite/forgotten_password.php (added)
- devel/mod/invite/index.php (added)
- devel/mod/invite/join.php (added)
- devel/mod/invite/languages (added)
- devel/mod/invite/languages/es_CO (added)
- devel/mod/invite/languages/es_CO/LC_MESSAGES (added)
- devel/mod/invite/languages/es_CO/LC_MESSAGES/elgg.mo (added)
- devel/mod/invite/languages/es_CO/LC_MESSAGES/es_CO.po (added)
- devel/mod/invite/languages/es_CO/LC_MESSAGES/strings.txt (added)
- devel/mod/invite/lib (added)
- devel/mod/invite/lib.php (added)
- devel/mod/invite/lib/invite.php (added)
- devel/mod/invite/lib/invite_actions.php (added)
- devel/mod/invite/lib/invite_config.php (added)
- devel/mod/invite/lib/invite_join.php (added)
- devel/mod/invite/lib/invite_join_footer.php (added)
- devel/mod/invite/lib/invite_join_mailwithoutpass.php (added)
- devel/mod/invite/lib/invite_join_mailwithpass.php (added)
- devel/mod/invite/lib/invite_join_welcome.php (added)
- devel/mod/invite/lib/invite_register_welcome.php (added)
- devel/mod/invite/lib/join_noinvite.php (added)
- devel/mod/invite/lib/new_password.php (added)
- devel/mod/invite/lib/password_request.php (added)
- devel/mod/invite/logout.php (added)
- devel/mod/invite/new_password.php (added)
- devel/mod/invite/register.php (added)
- devel/mod/invite/wrongpassword.php (added)
- devel/mod/newsclient/INSTALL (added)
- devel/mod/newsclient/LICENSE (added)
- devel/mod/newsclient/NOTES (added)
- devel/mod/newsclient/blog.php (added)
- devel/mod/newsclient/index.php (added)
- devel/mod/newsclient/individual.php (added)
- devel/mod/newsclient/lib (added)
- devel/mod/newsclient/lib.php (modified) (2 diffs)
- devel/mod/newsclient/lib/default_template.php (added)
- devel/mod/newsclient/lib/function_actions.php (added)
- devel/mod/newsclient/lib/function_get.php (added)
- devel/mod/newsclient/lib/function_get_subscriptions.php (added)
- devel/mod/newsclient/lib/function_init.php (added)
- devel/mod/newsclient/lib/function_is_subscribed.php (added)
- devel/mod/newsclient/lib/function_prune.php (added)
- devel/mod/newsclient/lib/function_subscriptions.php (added)
- devel/mod/newsclient/lib/function_subscriptions_popular.php (added)
- devel/mod/newsclient/lib/function_subscriptions_publish_to_blog.php (added)
- devel/mod/newsclient/lib/function_update.php (added)
- devel/mod/newsclient/lib/function_update_all.php (added)
- devel/mod/newsclient/lib/function_update_all_cron.php (added)
- devel/mod/newsclient/lib/function_view.php (added)
- devel/mod/newsclient/lib/function_view_individual.php (added)
- devel/mod/newsclient/lib/function_view_post.php (added)
- devel/mod/newsclient/lib/library.php (added)
- devel/mod/newsclient/lib/magpie_notes.txt (added)
- devel/mod/newsclient/lib/menu_sub.php (added)
- devel/mod/newsclient/lib/permissions_check.php (added)
- devel/mod/newsclient/lib/rss_cache.inc (added)
- devel/mod/newsclient/lib/rss_fetch.inc (added)
- devel/mod/newsclient/lib/rss_parse.inc (added)
- devel/mod/newsclient/lib/rss_utils.inc (added)
- devel/mod/newsclient/mistake-high.png (added)
- devel/mod/newsclient/mistake.png (added)
- devel/mod/newsclient/opml.php (added)
- devel/mod/newsclient/popular.php (added)
- devel/mod/newsclient/static.php (added)
- devel/mod/newsclient/styles.php (added)
- devel/mod/newsclient/subscribe-high.png (added)
- devel/mod/newsclient/subscribe.png (added)
- devel/mod/newsclient/subscriptions.php (added)
- devel/mod/search (added)
- devel/mod/search/INSTALL (added)
- devel/mod/search/LICENSE (added)
- devel/mod/search/NOTES (added)
- devel/mod/search/lib (added)
- devel/mod/search/lib.php (added)
- devel/mod/search/lib/function_display.php (added)
- devel/mod/search/lib/function_search_all_display.php (added)
- devel/mod/search/lib/function_search_all_display_ecl.php (added)
- devel/mod/search/lib/function_search_all_display_rss.php (added)
- devel/mod/search/lib/groups_delete.php (added)
- devel/mod/search/lib/search_suggest_rss.php (added)
- devel/mod/search/lib/search_suggest_rss_ecl.php (added)
- devel/mod/search/lib/search_suggest_tags.php (added)
- devel/mod/search/lib/search_suggest_users.php (added)
- devel/mod/search/lib/search_user_info_menu.php (added)
- devel/mod/search/lib/tags_display.php (added)
- devel/mod/search/lib/tags_display_personal.php (added)
- devel/units/groups (deleted)
- devel/units/invite (deleted)
- devel/units/magpie (deleted)
- devel/units/search (deleted)
- devel/units/xml (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/includes_system.php
r1250 r1251 20 20 include($CFG->dirroot . "units/profile/main.php"); 21 21 22 // Friend groups23 include($CFG->dirroot . "units/groups/main.php");24 25 // Search26 require($CFG->dirroot . "units/search/main.php");27 28 // Invite-a-friend29 require($CFG->dirroot . "units/invite/main.php");30 31 22 // XML parsing 32 require($CFG->dirroot . "units/xml/main.php"); 33 34 // Your Resources 35 require($CFG->dirroot . "units/magpie/main.php"); 36 23 require($CFG->dirroot . "lib/xmllib.php"); 24 37 25 ?> devel/lib/elgglib.php
r1243 r1251 4 4 * Library of functions for handling input validation 5 5 * and some HTML generation 6 * This library is a combination of bits of lib/weblib.php 6 * 7 * This library incorporates portions of bits of lib/weblib.php 7 8 * and lib/moodlelib.php from moodle 8 9 * http://moodle.org || http://sourceforge.net/projects/moodle 9 * Copyright (C) 2001-2003 Martin Dougiamas http://dougiamas.com 10 * 11 * @copyright Copyright (C) 2001-2003 Martin Dougiamas http://dougiamas.com 12 * @author Curverider Ltd 10 13 * @author Martin Dougiamas and many others 14 * @link http://elgg.org/ 11 15 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 16 * @package elgg 17 * @subpackage elgg.lib 12 18 */ 13 19 … … 373 379 //} 374 380 //called from setup.php, so gettext module hasn't been loaded yet 375 376 // make sure the session has really terminated 377 session_destroy(); 378 379 redirect($FULLME, '', 1); 381 redirect($FULLME, '', 1); 380 382 } 381 383 … … 4216 4218 } 4217 4219 4220 /** 4221 * Returns whether or not the current logged in user has permission to edit 4222 * a resource owned by a given account. 4223 * @param string $objecttype The type of object 4224 * @param int $owner The owning account's ident 4225 * @return boolean $permissions True or false 4226 */ 4227 4228 function permissions_check($objecttype, $owner) { 4229 4230 static $permissions_check; 4231 4232 if (isset($permissions_check[$objecttype][$owner])) { 4233 return $permissions_check[$objecttype][$owner]; 4234 } 4235 4236 if ($allmods = get_list_of_plugins('mod')) { 4237 foreach ($allmods as $mod) { 4238 $mod_permissions_check = $mod . "_permissions_check"; 4239 if (function_exists($mod_permissions_check)) { 4240 if ($value = $mod_permissions_check($objecttype, $owner)) { 4241 $permissions_check[$objecttype][$owner] = $value; 4242 return $value; 4243 } 4244 } 4245 } 4246 } 4247 4248 return false; 4249 4250 } 4251 4218 4252 ?> devel/lib/php-getttext/gettext.inc
r659 r1251 129 129 $ret = 0; 130 130 if (function_exists('setlocale')) // I don't know if this ever happens ;) 131 $ret = setlocale($category, $locale); 131 error_log($categori,$locale); 132 $ret = setlocale($category, $locale); 132 133 if (($ret and $locale == '') or ($ret == $locale)) { 133 134 $EMULATEGETTEXT = 0; devel/lib/setup.php
r990 r1251 469 469 } 470 470 471 471 472 /*** 472 473 *** init_performance_info() { devel/lib/templates.php
r1244 r1251 117 117 <div style="float: left; width: 70px"><a href="{{profileurl}}">{{usericon}}</a></div> 118 118 <div style="margin-left: 75px; margin-top: 0px; padding-top: 0px; text-align: left" ><p> 119 <span class="userdetails">{{name}}<br /><a href="{{profileurl}}rss/"> <img src="{{url}}mod/template/icons/rss.png" alt="RSS" /></a> | <a href="{{profileurl}}tags/">$tags</a> | <a href="{{profileurl}}newsclient/">$resources</a></span></p>119 <span class="userdetails">{{name}}<br /><a href="{{profileurl}}rss/">RSS</a> | <a href="{{profileurl}}tags/">$tags</a> | <a href="{{profileurl}}newsclient/">$resources</a></span></p> 120 120 <p>{{tagline}}</p> 121 121 <p>{{lmshosts}}</p> … … 447 447 //'html' => a_href("{$CFG->wwwroot}_admin/", 448 448 // "Administration")); 449 'html' => "<li><a href=\"" . $CFG->wwwroot . " _admin/\">" . __gettext("Administration") . "</a></li>");449 'html' => "<li><a href=\"" . $CFG->wwwroot . "mod/admin/\">" . __gettext("Administration") . "</a></li>"); 450 450 } 451 451 … … 463 463 'html' => "<li><a href=\"" . $CFG->wwwroot . "login/logout.php\">" . __gettext("Log off") . "</a></li>"); 464 464 }; 465 466 if (defined("context") && context == "account") {467 $PAGE->menu_sub[] = array(468 'name' => 'user:edit',469 'html' => a_href("{$CFG->wwwroot}_userdetails/",470 __gettext("Edit user details")));471 $PAGE->menu_sub[] = array(472 'name' => 'user:icon',473 'html' => a_href("{$CFG->wwwroot}_icons/",474 __gettext("Your site picture")));475 }476 477 if (defined("context") && context == "admin" && logged_on && user_flag_get("admin", $_SESSION['userid'])) {478 $PAGE->menu_sub[] = array(479 'name' => 'admin',480 'html' => a_href("{$CFG->wwwroot}_admin/",481 __gettext("Main")));482 483 $PAGE->menu_sub[] = array(484 'name' => 'admin:useradd',485 'html' => a_href("{$CFG->wwwroot}_admin/users_add.php",486 __gettext("Add users")));487 488 $PAGE->menu_sub[] = array(489 'name' => 'admin:users',490 'html' => a_href("{$CFG->wwwroot}_admin/users.php",491 __gettext("Manage users")));492 493 $PAGE->menu_sub[] = array(494 'name' => 'admin:users',495 'html' => a_href("{$CFG->wwwroot}_admin/users.php?flag=banned",496 __gettext("Banned users")));497 498 $PAGE->menu_sub[] = array(499 'name' => 'admin:users',500 'html' => a_href("{$CFG->wwwroot}_admin/users.php?flag=admin",501 __gettext("Admin users")));502 503 $PAGE->menu_sub[] = array(504 'name' => 'admin:flaggedcontent',505 'html' => a_href("{$CFG->wwwroot}_admin/flags.php",506 __gettext("Manage flagged content")));507 508 $PAGE->menu_sub[] = array(509 'name' => 'admin:spam',510 'html' => a_href("{$CFG->wwwroot}_admin/antispam.php",511 __gettext("Spam control")));512 513 }514 465 515 466 … … 1330 1281 if (!empty($template_name)) { 1331 1282 // use a defined style 1332 $result = '<link href="' . $CFG->wwwroot . '_templates/css .php?template=' . $template_name. '" rel="stylesheet" type="text/css" />' . "\n";1283 $result = '<link href="' . $CFG->wwwroot . '_templates/css/' . $template_name. '" rel="stylesheet" type="text/css" />' . "\n"; 1333 1284 } else { 1334 1285 // use whatever's in $template['css'] … … 1456 1407 case "populartags": 1457 1408 $result = ""; 1458 if (isset($vars[1])) { 1459 $vars[1] = (int) $vars[1]; 1460 } else { 1461 $vars[1] = "20"; 1462 } 1463 if ($tags = get_records_sql("SELECT tag, count(ident) as numtags FROM `".$CFG->prefix."tags` WHERE access = 'public' and tag!='' group by tag having numtags > 1 order by ident desc limit " . $vars[1])) { 1409 if ($tags = get_records_sql("SELECT tag, count(ident) as numtags FROM `".$CFG->prefix."tags` WHERE access = 'public' and tag!='' group by tag having numtags > 1 order by ident desc limit 20")) { 1464 1410 $max = 0; 1465 1411 foreach($tags as $tag) { devel/lib/userlib.php
r1046 r1251 1 1 <?php 2 2 3 /** 4 * Library of functions for user polling and manipulation. 5 * Largely taken from the old /units/users/ 6 * Copyright (C) 2004-2006 Ben Werdmuller and David Tosh 7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 8 */ 9 10 3 /** 4 * Library of functions for user polling and manipulation. 5 * 6 * @copyright Copyright (C) 2004-2006 Ben Werdmuller and David Tosh 7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 8 * @package elgg 9 * @subpackage elgg.lib 10 */ 11 11 12 // INITIALISATION ////////////////////////////////////////////////////////////// 12 13 … … 26 27 define('AUTH_MSG_MISSING', __gettext("Either the username or password were not specified. The system could not log you on.")); 27 28 28 // USER INFORMATION RETRIEVAL ////////////////////////////////////////////////// 29 30 // Given a user ID number, returns the specified field 31 // Returns false if the user doesn't exist. 29 /** 30 * User information value by id 31 * 32 * Returns a specified field by user id 33 * 34 * @param string $fieldname the specific field 35 * @param integer $user_id the user id 36 * @return mixed string if success else false if the user doesn't exist 37 * @author Ben WerdMuller <ben@curverider.co.uk> 38 */ 32 39 function user_info($fieldname, $user_id) { 33 40 … … 57 64 } 58 65 59 // Given a username, returns the specified field 60 // Returns false if the user doesn't exist. 66 /** 67 * User information value by username 68 * 69 * Returns a specified field by username 70 * 71 * @param string $fieldname the specific field 72 * @param integer $user_id the user id 73 * @return mixed string if success else false if the user doesn't exist 74 * @author Ben WerdMuller <ben@curverider.co.uk> 75 */ 61 76 function user_info_username($fieldname, $username) { 62 77 … … 81 96 } 82 97 83 // Gets the type of a particular user 98 /** 99 * Gets the type of a particular user 100 * 101 * @param integer $user_id the user id 102 * @return mixed string the user type or false if the user doesn't exist 103 * @author Ben WerdMuller <ben@curverider.co.uk> 104 */ 84 105 function user_type($user_id) { 85 86 106 return user_info('user_type', $user_id); 87 88 107 } 89 108 … … 96 115 * @param integer $user_id The unique ID of the user we want to find the name for. 97 116 * @return string Returns the user's name, or a blank string if something went wrong (eg the user didn't exist). 117 * @author Ben WerdMuller <ben@curverider.co.uk> 98 118 */ 99 119 function user_name($user_id) { … … 114 134 * containing the elements 'html', 'icon' (being the icon ID), 'size', 'owner' and 'url'. 115 135 * 116 * @uses $CFG 136 * @todo TODO refactor, separate display code 137 * @global CFG global configuration 117 138 * @param integer $user_id The unique ID of the user we want to display the icon for. 118 139 * @param integer $size The size of the icon we want to display (max: 100). 119 140 * @param boolean $urlonly If true, returns the URL of the icon rather than the full HTML. 120 141 * @return string Returns the icon HTML, or the default icon if something went wrong (eg the user didn't exist). 142 * @author Ben WerdMuller <ben@curverider.co.uk> 121 143 */ 122 144 function user_icon_html($user_id, $size = 100, $urlonly = false) { … … 194 216 $currentaccess += 1000; 195 217 } 218 error_log($currentaccess); 196 219 197 220 return $currentaccess; … … 201 224 function protect($level, $owner = -1) { 202 225 global $CFG; 226 227 error_log($level); 228 error_log($owner); 203 229 if (accesslevel($owner) < $level) { 204 230 echo '<a href="' . $CFG->wwwroot . '">' . __gettext("Access Denied") . '</a>'; … … 209 235 // NOTIFICATIONS AND MESSAGING ///////////////////////////////////////////////// 210 236 211 // Send a message to a user 212 237 // 238 239 /** 240 * Send a message to a user 241 * 242 * @param integer $to the receiving user id 243 * @param integer $from the sending user id 244 * @param string $message the message body 245 * @return boolean 246 * @author Ben WerdMuller <ben@curverider.co.uk> 247 * @author Misja Hoebe <misja@curverider.co.uk> 248 */ 213 249 function message_user($to, $from, $title, $message) { 214 250 … … 224 260 $email_from->email = $CFG->noreplyaddress; 225 261 $email_from->name = $CFG->sitename; 226 227 if ($email_to = get_record _sql("select * from ".$CFG->prefix."users where ident = " . $to)) {228 262 263 if ($email_to = get_record('users', 'ident', $to)) 264 { 229 265 if (!email_to_user($email_to,$email_from,$title,$message . "\n\n\n" . __gettext("You cannot reply to this message by email."))) { 230 266 $messages[] = __gettext("Failed to send email. An unknown error occurred."); … … 242 278 243 279 if (!insert_record('messages',$m)) { 280 trigger_error(__FUNCTION__.": Failed to send message from $from to $to. An unknown error occurred.", E_ERROR); 281 244 282 $messages[] = __gettext("Failed to send message. An unknown error occurred."); 245 } 246 247 } 248 249 // Get user $user_id's messages; optionally limit the number or the timeframe 250 283 } else { 284 plugin_hook("message", "publish", $m); 285 return true; 286 } 287 288 } 289 290 /** 291 * Get user's messages 292 * 293 * Get the user's messages, optionally limit the number or the timeframe 294 * 295 * @param integer $user_id the user id 296 * @param integer $number the number of messages to retrieve 297 * @param integer $timeframe the timeframe 298 * @return mixed an ADODB RecordSet object with the results or false 299 * @author Ben WerdMuller <ben@curverider.co.uk> 300 */ 251 301 function get_messages($user_id, $number = null, $timeframe = null) { 252 302 … … 266 316 } 267 317 268 // Return the basic HTML for a message (given its database row), where the 269 // title is a heading 2 and the body is in a paragraph. 270 318 /** 319 * Return the basic HTML for a message (given its database row), 320 * where the title is a heading 2 and the body is in a paragraph. 321 * 322 * @param string $message the message body 323 * @return string HTML output 324 * @todo TODO refactor, separate display and logic 325 * @author Ben WerdMuller <ben@curverider.co.uk> 326 */ 271 327 function display_message($message) { 272 328 … … 300 356 301 357 } 302 303 // Send a notification to a user, both using the notifications table and 304 // - potentially - email, depending on a user's preferences 305 358 359 /** 360 * Send a notification to a user 361 * 362 * Could be a notifications or email, 363 * depending on a user's preferences 364 * 365 * @param integer $user_id the user id 366 * @param string $title the message title 367 * @param string $message the message body 368 * @return boolean 369 * @todo TODO fix return type 370 * @author Ben WerdMuller <ben@curverider.co.uk> 371 */ 306 372 function notify_user($user_id, $title, $message) { 307 373 308 374 message_user($user_id, -1, $title, $message); 309 310 } 311 312 // Mark a user's messages as read 313 375 } 376 377 /** 378 * Mark a user's messages as read 379 * 380 * @param integer $user_id the user's id 381 * @return mixed An ADODB RecordSet object with the results from the SQL call or false. 382 * @author Ben WerdMuller <ben@curverider.co.uk> 383 */ 314 384 function messages_read($user_id) { 315 385 316 386 global $CFG; 317 //execute_sql("update ".$CFG->prefix."messages set status = 'read' where to_id = $user_id",false); 318 set_field('messages', 'status', 'read', 'to_id', $user_id); 319 320 } 321 322 // Cleanup messages - this should be relatively temporary 323 387 388 $result = set_field('messages', 'status', 'read', 'to_id', $user_id); 389 390 return $result; 391 } 392 393 /** 394 * Clean up user messages 395 * 396 * @global CFG global configuration 397 * @param integer $older_than 398 * @return boolean 399 * @todo TODO this should be relatively temporary (Ben?) 400 * @author Ben WerdMuller <ben@curverider.co.uk> 401 * @author Misja Hoebe <misja@curverider.co.uk> 402 */ 324 403 function cleanup_messages($older_than) { 325 404 326 global $CFG, $messages; 327 execute_sql("delete from ".$CFG->prefix."messages where posted < " . $older_than,false); 328 329 405 global $CFG; 406 407 $result = execute_sql("delete from ".$CFG->prefix."messages where posted < " . $older_than,false); 408 409 return $result; 330 410 } 331 411 332 412 // STATISTICS ////////////////////////////////////////////////////////////////// 333 413 334 // Count number of users 335 // Optional: the user_type (eg 'person') and the minimum last time they 336 // performed an action 337 414 /** 415 * Count number of users 416 * 417 * @global CFG global configuration 418 * @param string $type the user_type (eg 'person') 419 * @param integer $last_action the minimum last time they performed an action 420 * @return integer the number of users 421 * @author Ben WerdMuller <ben@curverider.co.uk> 422 */ 338 423 function count_users($type = '', $last_action = 0) { 339 424 … … 367 452 * Delete a user. 368 453 * 369 * @ uses $CFG454 * @global CFG global configuration 370 455 * @param integer $user_id The unique ID of the user to delete. 371 456 * @return true|false Returns true if the user was deleted; false otherwise. 372 */ 373 function user_delete($user_id) { 374 375 global $CFG; 376 377 // Verify that the user exists 378 if ($user = get_record_sql("select * from {$CFG->prefix}users where ident = {$user_id}")) { 457 * @author Ben WerdMuller <ben@curverider.co.uk> 458 */ 459 function user_delete($user_id) { 460 461 global $CFG; 462 463 // Verify that the user exists 464 if ($user = get_record_sql("select * from {$CFG->prefix}users where ident = {$user_id}")) { 379 465 380 // Call the event hook for all plugins to do their worst with the user's data381 $user = plugin_hook("user","delete",$user);466 // Call the event hook for all plugins to do their worst with the user's data 467 $user = plugin_hook("user","delete",$user); 382 468 383 // If all went well ...384 if (!empty($user)) {469 // If all went well ... 470 if (!empty($user)) { 385 471 386 // Remove any icons and icon folders387 if ($icons = get_records_sql("select * from {$CFG->prefix}icons where owner = {$user->ident}")) {388 foreach($icons as $icon) {389 $filepath = $CFG->dataroot . "icons/" . substr($user->username,0,1) . "/" . $user->username . "/" . $icon->filename;390 @unlink($filepath);391 }392 @rmdir($filepath = $CFG->dataroot . "icons/" . substr($user->username,0,1) . "/" . $user->username . "/");393 }472 // Remove any icons and icon folders 473 if ($icons = get_records_sql("select * from {$CFG->prefix}icons where owner = {$user->ident}")) { 474 foreach($icons as $icon) { 475 $filepath = $CFG->dataroot . "icons/" . substr($user->username,0,1) . "/" . $user->username . "/" . $icon->filename; 476 @unlink($filepath); 477 } 478 @rmdir($filepath = $CFG->dataroot . "icons/" . substr($user->username,0,1) . "/" . $user->username . "/"); 479 } 394 480 395 // Remove the user from the database!396 delete_records("users","ident",$user->ident);397 delete_records("user_flags","user_id",$user->ident);398 delete_records("messages","to_id",$user->ident);399 delete_records("messages","from_id",$user->ident);400 return true;401 402 }481 // Remove the user from the database! 482 delete_records("users","ident",$user->ident); 483 delete_records("user_flags","user_id",$user->ident); 484 delete_records("messages","to_id",$user->ident); 485 delete_records("messages","from_id",$user->ident); 486 return true; 487 488 } 403 489 404 return false; 405 } 406 407 } 408 490 return false; 491 } 492 } 493 494 /** 495 * Get the user's friends 496 * 497 * @global CFG global configuration 498 * @param integer $user_id the user id 499 * @return mixed a result set packed in an array or empty 500 * @author Misja Hoebe <misja@curverider.co.uk> 501 */ 502 function user_friends($user_id) { 503 global $CFG; 504 505 $result = get_records_sql('SELECT f.friend AS user_id,u.name FROM '.$CFG->prefix.'friends f 506 JOIN '.$CFG->prefix.'users u ON u.ident = f.friend 507 WHERE f.owner = ? ORDER BY u.name', array($user_id)); 508 509 return $result; 510 } 511 512 /** 513 * Get the users who have marked this user as a friend (sorted by the friends latest activity) 514 * 515 * @global CFG global configuration 516 * @param integer $user_id the user id 517 * @return mixed a result set packed in an array or empty 518 * @author Misja Hoebe <misja@curverider.co.uk> 519 */ 520 function user_friends_of($user_id) { 521 global $CFG; 522 523 $result = get_records_sql('SELECT u.ident, u.username FROM '.$CFG->prefix.'friends f 524 JOIN '.$CFG->prefix.'users u ON u.ident = f.owner 525 WHERE friend = ? AND u.user_type = ? order by u.last_action desc', array($user_id, 'person')); 526 527 return $result; 528 } 529 530 /** 531 * Add the a user to a friends list 532 * 533 * @param integer $user_id the user id 534 * @param integer $friend_id the friend id 535 * @param boolean $moderate is this a moderated friendship request 536 * @param string $type the type, used for being able to reuse functionality for communities 537 * @return boolean 538 * @author Misja Hoebe <misja@curverider.co.uk> 539 */ 540 function user_friend_add($user_id, $friend_id, $moderate = false, $type = 'friendship') { 541 if (empty($user_id) || empty($friend_id)) { 542 trigger_error(__FUNCTION__.": invalid arguments (user id: $user_id, friend id: $friend_id)", E_ERROR); 543 } 544 545 if (record_exists('friends', 'owner', $user_id, 'friend', $friend_id)) { 546 $obj = new StdClass; 547 $obj->owner = $user_id; 548 $obj->friend = $friend_id; 549 550 // Type check 551 if ($type != 'friendship' || $type != 'membership') { 552 trigger_error("user_friend_add(): only type 'friendship' or 'membership' is accepted but '$type' was passed.", E_ERROR); 553 return false; 554 } 555 556 if ($moderation == false) { 557 // Regular friendship/membership 558 if (insert_record('friends', $obj)) { 559 plugin_hook($type, "publish", $obj); 560 return true; 561 } else { 562 return false; 563 } 564 } else { 565 // Moderated friendship/membership 566 if (insert_record('friends_requests', $obj)) { 567 plugin_hook($type, "request", $obj); 568 return true; 569 } else { 570 return false; 571 } 572 } 573 } else { 574 return false; 575 } 576 } 577 578 /** 579 * Delete a user from a friends list 580 * 581 * @param integer $user_id the user id 582 * @param integer $friend_id the friend id 583 * @return mixed an ADODB RecordSet object with the results or false 584 * @author Misja Hoebe <misja@curverider.co.uk> 585 */ 586 function user_friend_delete($user_id, $friend_id) { 587 if (empty($user_id) || empty($community_id)) { 588 trigger_error(__FUNCTION__.": invalid arguments (user id: $user_id, friend id: $friend_id)", E_ERROR); 589 } 590 591 $result = delete_records('friends', 'owner', $user_id, 'friend', $friend_id); 592 593 if ($result != false) { 594 plugin_hook("friendship", "delete", $result); 595 } 596 597 return $result; 598 } 409 599 ?> devel/mod/blog/README
r1077 r1251 7 7 8 8 POSTS_PER_PAGE (default value: 10) 9 To configure the max number of posts per page in (view blog, archive, friends posts,10 interesting posts, all posts) you can change the constant 'POSTS_PER_PAGE' in11 'blog/lib/weblogs_init.php'.9 To configure the max number of posts per page in (view blog, archive, friends posts, 10 interesting posts, all posts) you can change the constant 'POSTS_PER_PAGE' in 11 'blog/lib/weblogs_init.php'. 12 12 13 13 Extension points … … 20 20 ------------------ 21 21 22 display:icon:select 23 File(s): 24 - blog/lib/weblogs_posts_add.php 25 - blog/lib/weblogs_posts_edit.php 26 Action: 27 Allow plugins to add an icon selection box 28 Know implementations: 29 The 'posticon' plug-in 22 weblogs:posts:add:fields:before 23 File(s): 24 - blog/lib/weblogs_posts_add.php 25 - blog/lib/weblogs_posts_edit.php 26 Action: 27 Allow plugins to add extra fields before the post textarea 28 and behind the 'extrafield' field 30 29
