Changeset 530
- Timestamp:
- 09/06/06 22:53:51 (2 years ago)
- Files:
-
- devel/lib/db/mysql.php (modified) (1 diff)
- devel/lib/db/mysql.sql (modified) (1 diff)
- devel/lib/db/postgres7.php (modified) (1 diff)
- devel/lib/db/postgres7.sql (modified) (1 diff)
- devel/lib/userlib.php (modified) (1 diff)
- devel/units/communities/communities_actions.php (modified) (2 diffs)
- devel/units/friends/friends_actions.php (modified) (5 diffs)
- devel/units/weblogs/weblogs_actions.php (modified) (1 diff)
- devel/version.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/lib/db/mysql.php
r529 r530 361 361 362 362 if ($oldversion < 2006090600) { 363 execute_sql("ALTER TABLE `{$CFG->prefix}users` CHANGE `username` `username` VARCHAR(128) NOT NULL DEFAULT '' ;",false); 363 execute_sql("ALTER TABLE `{$CFG->prefix}users` CHANGE `username` `username` VARCHAR(128) NOT NULL DEFAULT '' ",false); 364 } 365 366 if ($oldversion < 2006090601) { 367 modify_database('',"CREATE TABLE `{$CFG->prefix}messages` (`ident` int(11) NOT NULL auto_increment, `title` text NOT NULL default '', `body` text NOT NULL default '', `from` int(11) NOT NULL, `to` int(11) NOT NULL, `posted` int(11) NOT NULL, `status` enum('read','unread') NOT NULL default 'unread', PRIMARY KEY (`ident`), KEY `from` (`from`,`to`,`posted`)) TYPE=MyISAM;",false); 364 368 } 365 369 devel/lib/db/mysql.sql
r529 r530 501 501 KEY `tagline` (`tagline`) 502 502 ) ; 503 504 505 -- 506 -- Table structure for table `messages` 507 -- 508 509 CREATE TABLE `prefix_messages` ( 510 `ident` int(11) NOT NULL auto_increment, 511 `title` text NOT NULL default '', 512 `body` text NOT NULL default '', 513 `from` int(11) NOT NULL, 514 `to` int(11) NOT NULL, 515 `posted` int(11) NOT NULL, 516 `status` enum('read','unread') NOT NULL default 'unread', 517 PRIMARY KEY (`ident`), 518 KEY `from` (`from`,`to`,`posted`) 519 ) TYPE=MyISAM ; devel/lib/db/postgres7.php
r529 r530 323 323 324 324 if ($oldversion < 2006090600) { 325 execute_sql("ALTER TABLE `{$CFG->prefix}users` CHANGE `username` `username` VARCHAR(128) NOT NULL DEFAULT '' ;",false); 325 execute_sql("ALTER TABLE `{$CFG->prefix}users` CHANGE `username` `username` VARCHAR(128) NOT NULL DEFAULT '' ",false); 326 } 327 328 if ($oldversion < 2006090601) { 329 execute_sql("CREATE TABLE `{$CFG->prefix}messages` (`ident` SERIAL PRIMARY KEY, `title` text NOT NULL default '', `body` text NOT NULL default '', `from` int(11) NOT NULL default -1, `to` int(11) NOT NULL default -1, `posted` int(11) NOT NULL default 0, `status` enum('read','unread') NOT NULL default 'unread')",false); 330 execute_sql("CREATE INDEX {$CFG->prefix}messages_to_idx ON {$CFG->prefix}messages (from,to)"); 326 331 } 327 332 devel/lib/db/postgres7.sql
r529 r530 358 358 CREATE INDEX prefix_feeds_siteurl_idx ON prefix_feeds (siteurl); 359 359 CREATE INDEX prefix_feeds_tagline_idx ON prefix_feeds (tagline); 360 361 362 -- 363 -- Table structure for table `messages` 364 -- 365 366 CREATE TABLE `prefix_messages` ( 367 `ident` SERIAL PRIMARY KEY, 368 `title` text NOT NULL default '', 369 `body` text NOT NULL default '', 370 `from` int(11) NOT NULL default -1, 371 `to` int(11) NOT NULL default -1, 372 `posted` int(11) NOT NULL default 0, 373 `status` enum('read','unread') NOT NULL default 'unread', 374 ); 375 376 CREATE INDEX prefix_messages_to_idx ON prefix_messages (from,to); devel/lib/userlib.php
r503 r530 139 139 } 140 140 } 141 142 // NOTIFICATIONS AND MESSAGING ///////////////////////////////////////////////// 143 144 // Send a message to a user 145 146 function message_user($to, $from, $title, $message) { 147 148 global $messages; 149 150 $notifications = user_flag_get("emailnotifications",$to); 151 if ($notifications) { 152 $from = new StdClass; 153 $from->email = $CFG->noreplyaddress; 154 $from->name = $CFG->sitename; 155 email_to_user($u,$from,$title,$message); 156 } 157 158 $m = new StdClass; 159 $m->title = $title; 160 $m->body = $message; 161 $m->from_id = $from; 162 $m->to_id = $to; 163 $m->posted = time(); 164 $m->status = 'unread'; 165 if (!insert_record('messages',$m)) { 166 $messages[] = gettext("Failed to send message. An unknown error occurred."); 167 } 168 169 } 170 171 // Send a notification to a user, both using the notifications table and 172 // - potentially - email, depending on a user's preferences 173 174 function notify_user($user_id, $title, $message) { 175 176 message_user($user_id, -1, $title, $message); 177 178 } 141 179 142 180 // STATISTICS ////////////////////////////////////////////////////////////////// devel/units/communities/communities_actions.php
r454 r530 52 52 case "friend": 53 53 if (!empty($friend_id) && logged_on) { 54 if ( run("users:type:get",$friend_id) == "community") {54 if (user_info("user_type",$friend_id) == "community") { 55 55 if ($friend = get_record('users','ident',$friend_id)) { 56 56 $owner = get_record('users','ident',$friend->owner); … … 58 58 $messages[] = sprintf(gettext("You joined %s."), stripslashes($friend->name)); 59 59 if (run("users:flags:get",array("emailnotifications",$owner->ident))) { 60 $ email_message= sprintf(gettext("%s has joined %s!\n\nTo visit this user's profile, click on the following link:\n\n\t".60 $message_body = sprintf(gettext("%s has joined %s!\n\nTo visit this user's profile, click on the following link:\n\n\t". 61 61 "%s\n\nTo view all community members, click here:\n\n\t%s\n\nRegards,\n\nThe %s team."), 62 $_SESSION['name'], $friend->name, $CFG->wwwroot . run("users:id_to_name",$USER->ident) . "/", $CFG->wwwroot . "_communities/members.php?owner=" . $friend_id,$CFG->sitename); 63 email_to_user($owner,null,sprintf(gettext("New %s member"), $friend->name),$email_message); 62 $_SESSION['name'], $friend->name, $CFG->wwwroot . user_info("username",$USER->ident) . "/", $CFG->wwwroot . "_communities/members.php?owner=" . $friend_id,$CFG->sitename); 63 $title = sprintf(gettext("New %s member"), $friend->name); 64 notify_user($owner->ident,$title,$message_body); 64 65 } 65 66 } else if ($friend->moderation == "yes") { 66 67 $messages[] = sprintf(gettext("Membership of %s needs to be approved. Your request has been added to the list."), stripslashes($friend->name)); 67 68 if (run("users:flags:get",array("emailnotifications",$owner->ident))) { 68 $ email_message= sprintf(gettext("%s has applied to join %s!\n\nTo visit this user's profile, click on the following link:\n\n\t".69 $message_body = sprintf(gettext("%s has applied to join %s!\n\nTo visit this user's profile, click on the following link:\n\n\t". 69 70 "%s\n\nTo view all membership requests and approve or deny this user, click here:\n\n\t%s\n\nRegards,\n\nThe %s team."), 70 $_SESSION['name'], $friend->name, $CFG->wwwroot . run("users:id_to_name",$USER->ident) . "/", $CFG->wwwroot . "_communities/members.php?owner=" . $friend_id,$CFG->sitename); 71 email_to_user($owner,null,sprintf(gettext("New %s member"), $friend->name),$email_message); 71 $_SESSION['name'], $friend->name, $CFG->wwwroot . user_info("username",$USER->ident) . "/", $CFG->wwwroot . "_communities/members.php?owner=" . $friend_id,$CFG->sitename); 72 $title = sprintf(gettext("New %s member request"), $friend->name); 73 notify_user($owner->ident,$title,$message_body); 72 74 } 73 75 } else if ($friend->moderation == "priv") { devel/units/friends/friends_actions.php
r432 r530 21 21 if ($friend->moderation == 'no') { 22 22 if (insert_record('friends',$f)) { 23 if ( run("users:type:get",$friend_id) == "person") {23 if (user_info("user_type",$friend_id) == "person") { 24 24 $messages[] = sprintf(gettext("%s was added to your friends list."),$friend->name); 25 25 if (run("users:flags:get",array("emailnotifications",$friend_id))) { 26 26 $u = get_record('users','ident',$friend_id); 27 $ email_message= sprintf(gettext("%s has added you as a friend!\n\nTo visit this user's profile, click on the following link:\n\n\t".27 $message_body = sprintf(gettext("%s has added you as a friend!\n\nTo visit this user's profile, click on the following link:\n\n\t". 28 28 "%s\n\nTo view all your friends, click here:\n\n\t%s\n\nRegards,\n\nThe %s team."), 29 $_SESSION['name'], $CFG->wwwroot . run("users:id_to_name",$USER->ident) . "/", $CFG->wwwroot . run("users:id_to_name",$friend_id) . "/friends/",$CFG->sitename); 30 email_to_user($u,null,sprintf(gettext("New %s friend"), $CFG->sitename),$email_message); 29 $_SESSION['name'], $CFG->wwwroot . user_info("username",$USER->ident) . "/", $CFG->wwwroot . user_info("username",$friend_id) . "/friends/",$CFG->sitename); 30 $title = sprintf(gettext("New %s friend"), $CFG->sitename); 31 notify_user($u,$title,$message_body); 31 32 } 32 33 } 33 34 } else { 34 if ( run("users:type:get",$friend_id) == "person") {35 if (user_info("user_type",$friend_id) == "person") { 35 36 $messages[] = sprintf(gettext("%s couldn't be added to your friends list."),$friend->name); 36 37 } … … 38 39 } else if ($friend->moderation == 'yes') { 39 40 if (insert_record('friends_requests',$f)) { 40 if ( run("users:type:get",$friend_id) == "person") {41 if (user_info("user_type",$friend_id) == "person") { 41 42 $messages[] = sprintf(gettext("%s has elected to moderate friendship requests. Your request has been added to their moderation queue."),$friend->name); 42 43 if (run("users:flags:get",array("emailnotifications",$friend_id))) { 43 44 $u = get_record('users','ident',$friend_id); 44 $ email_message= sprintf(gettext("%s has requested to add you as a friend!\n\nTo visit this user's profile, click on the following link:\n\n\t".45 $message_body = sprintf(gettext("%s has requested to add you as a friend!\n\nTo visit this user's profile, click on the following link:\n\n\t". 45 46 "%s\n\nTo view all your friends requests and approve or deny this user, click here:\n\n\t%s\n\nRegards,\n\nThe %s team."), 46 $_SESSION['name'], $CFG->wwwroot . run("users:id_to_name",$USER->ident) . "/", $CFG->wwwroot . "_friends/requests.php?owner=" . $friend_id,$CFG->sitename); 47 email_to_user($u,null,sprintf(gettext("New %s friend request"), $CFG->sitename),$email_message); 47 $_SESSION['name'], $CFG->wwwroot . user_info("username",$USER->ident) . "/", $CFG->wwwroot . "_friends/requests.php?owner=" . $friend_id,$CFG->sitename); 48 $title = sprintf(gettext("New %s friend request"), $CFG->sitename); 49 notify_user($u,$title,$message_body); 48 50 } 49 51 } 50 52 } else { 51 if ( run("users:type:get",$friend_id) == "person") {53 if (user_info("user_type",$friend_id) == "person") { 52 54 $messages[] = sprintf(gettext("%s has elected to moderate friendship requests, but your friend request couldn't be added to their moderation queue."),$friend->name); 53 55 } 54 56 } 55 } else if ($friend->moderation == 'priv' && run("users:type:get",$friend_id) == "person") {57 } else if ($friend->moderation == 'priv' && user_info("user_type",$friend_id) == "person") { 56 58 $messages[] = sprintf(gettext("%s has decided not to allow any new friendship requests at this time. Your friendship request has been declined."),$friend->name); 57 59 } … … 63 65 if (!empty($friend) && logged_on) { 64 66 if (delete_records('friends','owner',$USER->ident,'friend',$friend_id)) { 65 if ( run("users:type:get",$friend_id) == "person") {67 if (user_info("user_type",$friend_id) == "person") { 66 68 $messages[] = $friend->name . gettext(" was removed from your friends."); 67 69 } 68 70 } else { 69 if ( run("users:type:get",$friend_id) == "person") {71 if (user_info("user_type",$friend_id) == "person") { 70 72 $messages[] = $friend->name . gettext(" couldn't be removed from your friends."); 71 73 } … … 87 89 delete_records('friends_requests','ident',$request_id); 88 90 $messages[] = sprintf(gettext("You approved the friendship request. %s now lists you as a friend."),stripslashes($request->name)); 91 $message_body = sprintf(gettext("%s has approved your friendship request!\n\nTo visit this user's profile, click on the following link:\n\n\t". 92 "%s\n\nTo view all your friends, click here:\n\n\t%s\n\nRegards,\n\nThe %s team."), 93 user_info("name",$request->friend), $CFG->wwwroot . user_info("username",$request->friend) . "/", $CFG->wwwroot . user_info("username",$request->owner) . "/friends/",$CFG->sitename); 94 $title = sprintf(gettext("%s friend request approved!"), $CFG->sitename); 95 notify_user($request->owner,$title,$message_body); 89 96 } else { 90 97 $messages[] = gettext("An error occurred: couldn't add you as a friend"); … … 109 116 delete_records('friends_requests','ident',$request_id); 110 117 $messages[] = sprintf(gettext("You declined the friendship request. %s does not list you as a friend."),stripslashes($request->name)); 118 $message_body = sprintf(gettext("%s has denied your friendship request.\n\nTo visit this user's profile, click on the following link:\n\n\t". 119 "%s\n\nTo view all your existing friends, click here:\n\n\t%s\n\nRegards,\n\nThe %s team."), 120 user_info("name",$request->friend), $CFG->wwwroot . user_info("username",$request->friend) . "/", $CFG->wwwroot . user_info("username",$request->owner) . "/friends/",$CFG->sitename); 121 $title = sprintf(gettext("%s friend request denied"), $CFG->sitename); 122 notify_user($request->owner,$title,$message_body); 111 123 } else { 112 124 $messages[] = gettext("Error: you do not have authority to modify this friendship request."); devel/units/weblogs/weblogs_actions.php
r436 r530 131 131 if (run("users:flags:get",array("emailreplies",$post->owner))) { 132 132 if ($email = get_record('users','ident',$post->owner)) { 133 $username = $email->username;134 133 $message = gettext(sprintf("You have received a comment from %s on your blog post '%s'. It reads as follows:", $comment->postedname, stripslashes($post->title))); 135 134 $message .= "\n\n\n" . stripslashes($comment->body) . "\n\n\n"; 136 135 $message .= gettext(sprintf("To reply and see other comments on this blog post, click here: %s", url . $username . "/weblog/" . $post->ident . ".html")); 137 136 $message = wordwrap($message); 138 $from = new StdClass; 139 $from->email = $CFG->noreplyaddress; 140 $from->name = $comment->postedname; 141 email_to_user($email,$from,stripslashes($post->title),$message); 137 notify_user($post->owner,stripslashes($post->title),$message); 142 138 } 143 139 } devel/version.php
r529 r530 7 7 // whether upgrades should be performed (see lib/db/*.php) 8 8 9 $version = 200609060 0; // YYYYMMDD = Elgg Date9 $version = 2006090601; // YYYYMMDD = Elgg Date 10 10 // X = Elgg Point release (0,1,2...) 11 11 // Y = Interim incrementer
