Changeset 1550
- Timestamp:
- 02/11/08 02:51:42 (6 months ago)
- Files:
-
- devel/mod/blog/lib.php (modified) (2 diffs)
- devel/mod/commentwall/do_action.php (modified) (1 diff)
- devel/mod/commentwall/lib.php (modified) (2 diffs)
- devel/mod/community/lib.php (modified) (1 diff)
- devel/mod/community/lib/communities_actions.php (modified) (1 diff)
- devel/mod/community/lib/community_member_add.php (modified) (4 diffs)
- devel/mod/community/lib/community_member_remove.php (modified) (3 diffs)
- devel/mod/file/lib.php (modified) (2 diffs)
- devel/mod/friend/lib/friends_actions.php (modified) (4 diffs)
- devel/mod/template/templates/Default_Template/frontpage_loggedin (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/mod/blog/lib.php
r1524 r1550 250 250 251 251 //$CFG->weblog_extensions['weblog']= array (); 252 253 // Register file river hook (if there)254 if (function_exists('river_save_event'))255 {256 listen_for_event('weblog_post','publish', 'blog_river_hook');257 listen_for_event('weblog_post','delete', 'blog_river_hook');258 259 river_register_friendlyname_hook('weblog_post::post', 'blog_get_friendly_name');260 }261 }262 263 function blog_get_friendly_name($object_type, $object_id)264 {265 global $CFG;266 267 if ($object_type == 'weblog_post::post')268 {269 $record = get_record_sql("SELECT * from {$CFG->prefix}weblog_posts where ident=$object_id");270 271 if ($record)272 {273 $blog = user_info("username", $record->weblog);274 $url = river_get_userurl($record->weblog);275 276 return sprintf(__gettext("a post in <a href=\"$url\">%s</a>'s weblog"), $blog);277 }278 }279 280 return "";281 }282 283 function blog_river_hook( $object_type, $event, $object)284 {285 global $CFG;286 287 $userid = ($_SESSION['userid'] == "" ? -1 : $_SESSION['userid']);288 $object_id = $object->ident;289 $object_owner = $object->owner;290 $title = trim($object->title);291 $weblogid = $object->weblog;292 293 $username = user_info("username", $userid);294 $weblogname = "<a href=\"" . river_get_userurl($weblogid) . "\">". user_info("username", $weblogid) . "</a>'s";295 if ($userid == $weblogid) $weblogname = __gettext("their");296 297 $entryurl = $CFG->wwwroot . $username . "/weblog/" . $object->ident . ".html";298 299 $titletxt = "";300 if ($title!="")301 $titletxt = sprintf( __gettext(" called '%s'"), $title);302 303 if ($username == false) $username = __gettext("Anonymous user");304 305 if ($event == "publish")306 river_save_event($userid, $object_id, $object_owner, $object_type, "<a href=\"" . river_get_userurl($userid) . "\">$username</a> left a <a href=\"$entryurl\">post$titletxt</a> in $weblogname blog.",$object->access);307 308 return $object;309 252 } 310 253 … … 712 655 return isset($type) ? $type : $default; 713 656 } 657 658 /** 659 * Returns the extension context given a weblog_post object 660 * 661 * @param object $object A weblog_post object 662 * @return string The object extension context 663 */ 664 function blog_get_context($object){ 665 global $CFG; 666 if(empty($object->extra_value)) { 667 return "weblog"; 668 } 669 670 if(!empty($CFG->weblog_extensions)){ 671 foreach($CFG->weblog_extensions as $extension => $config){ 672 if(array_key_exists('values',$config) && in_array($object->extra_value,$config['values'])){ 673 return strtolower($extension); 674 } 675 } 676 } 677 } 678 679 /** 680 * Returns the context type given an weblog_post object 681 * 682 * @param object $object Weblog_post object 683 * @return string The object's extension context type 684 */ 685 function blog_get_context_type($object){ 686 global $CFG; 687 if(empty($object->extra_value)) { 688 return __gettext("Blog post"); 689 } 690 691 if(!empty($CFG->weblog_extensions)){ 692 $context = blog_get_context($object); 693 if(array_key_exists('type',$CFG->weblog_extensions[$context])){ 694 return $CFG->weblog_extensions[$context]['type']; 695 } 696 } 697 } 698 714 699 ?> devel/mod/commentwall/do_action.php
r1539 r1550 36 36 if ($displaymode=="xml") 37 37 $messages[] = __gettext(" Click here to see."); 38 39 // Hook for the river plugin (if installed)40 if (function_exists('river_save_event'))41 {42 $verb = __gettext("left");43 if ($reply!="")44 $verb = __gettext("replied to");45 46 // Wall owner47 $string = sprintf(__gettext("<a href=\"%s\">%s</a> $verb a message on <a href=\"%s\">%s's comment wall</a>"),48 river_get_userurl($comment_owner),49 user_info("name", $comment_owner),50 river_get_userurl($wallowner),51 user_info("name", $wallowner)52 );53 river_save_event($wallowner, $success, $comment_owner, "commentwall::post", $string);54 55 // Comment owner56 $noun = __gettext("A message");57 if ($reply!="")58 $noun = __gettext("A reply");59 $string = sprintf(__gettext("$noun was left by <a href=\"%s\">%s</a> in <a href=\"%s\">%s's comment wall</a>"),60 river_get_userurl($comment_owner),61 user_info("name", $comment_owner),62 river_get_userurl($wallowner),63 user_info("name", $wallowner)64 );65 river_save_event($comment_owner, $success, $comment_owner, "commentwall::post", $string);66 }67 38 } 68 39 else devel/mod/commentwall/lib.php
r1549 r1550 104 104 notify_user($wall_id, __gettext("Someone has posted to your comment wall"), __gettext("Check it out") . ": " . $CFG->wwwroot . user_info("username", $wall_id) . "/profile/"); 105 105 } 106 $newcomment = plugin_hook("commentwall","publish",$newcomment); 106 107 return $newcomment->ident; 107 108 } 108 109 109 return insert_record("commentwall", $newcomment); 110 $newcomment->ident = insert_record("commentwall", $newcomment); 111 $newcomment = plugin_hook("commentwall","publish",$newcomment); 112 return $newcomment->ident; 110 113 } 111 114 … … 126 129 { 127 130 if (!delete_records("commentwall", "ident", $comment->ident)) 131 plugin_hook('commentwall','delete',$comment); 128 132 return false; 129 133 devel/mod/community/lib.php
r1483 r1550 211 211 listen_for_event("user","delete","community_user_delete"); 212 212 213 // Register file river hook (if there)214 if (function_exists('river_save_event'))215 {216 listen_for_event('community','publish', 'community_river_hook');217 listen_for_event('community','delete', 'community_river_hook');218 219 river_register_friendlyname_hook('community::community', 'community_get_friendly_name');220 }221 222 213 register_user_type('community'); 223 }224 225 function community_get_friendly_name($object_type, $object_id)226 {227 global $CFG;228 229 if ($object_type == 'community::community')230 {231 $record = get_record_sql("SELECT * from {$CFG->prefix}users where ident=$object_id and user_type = 'community'");232 233 if ($record)234 {235 $community = user_info("name", $record->ident);236 $url = river_get_userurl($record->ident);237 238 return sprintf(__gettext("the community <a href=\"$url\">%s</a>"), $community);239 }240 }241 242 return "";243 }244 245 function community_river_hook( $object_type, $event, $object)246 {247 global $CFG;248 249 $userid = ($_SESSION['userid'] == "" ? -1 : $_SESSION['userid']);250 $object_id = $object->ident;251 $object_owner = $object->owner;252 $title = trim($object->name);253 254 $username = user_info("name", $userid);255 $weblogname = "<a href=\"" . river_get_userurl($userid) . "\">". user_info("name", $object_id) . "</a>'s";256 if ($userid == $object_owner) $weblogname = __gettext("their");257 258 if ($username == false) $username = __gettext("Anonymous user");259 260 if ($event == "publish")261 river_save_event($userid, $object_id, $object_owner, $object_type, "<a href=\"" . river_get_userurl($userid) . "\">$username</a> created the community <a href=\"{$CFG->wwwroot}{$object->username}\">{$object->name}</a>.");262 263 return $object;264 214 } 265 215 devel/mod/community/lib/communities_actions.php
r1541 r1550 111 111 $f->owner = $request->owner; 112 112 $f->friend = $request->friend; 113 if ( insert_record('friends',$f)) {113 if ($f->ident = insert_record('friends',$f)) { 114 114 delete_records('friends_requests','ident',$request_id); 115 plugin_hook("community:member","publish",$f); 115 116 $messages[] = sprintf(__gettext("You approved the membership request. %s is now a member of this community."),stripslashes($request->name)); 116 117 } else { devel/mod/community/lib/community_member_add.php
r1539 r1550 1 1 <?php 2 3 4 2 /* 5 3 * community_member_add.php … … 7 5 * Created on May 7, 2007 8 6 * 9 * @author Diego Andrᅵs Ramᅵrez Aragᅵn <diego@somosmas.org> 10 * @copyright Corporaciᅵn Somos mᅵs - 2007 7 * @author Diego Andrés RamÃrez Aragón <diego@somosmas.org> 11 8 */ 12 9 global $USER; … … 14 11 if (isset ($parameter)) { 15 12 $friend_id= $parameter[0]; 13 if(!record_exists('friends','friend',$friend_id,'owner',$USER->ident)){ 14 $f = new StdClass; 15 $f->owner = $USER->ident; 16 $f->friend = $friend_id; 17 $f->ident = insert_record('friends',$f); 18 } 19 else{ 20 $f = get_record('friends','friend',$friend_id,'owner',$USER->ident); 21 } 16 22 $run_result= array (); 17 23 if (!empty ($friend_id) && logged_on) { … … 25 31 $title= sprintf(__gettext("New %s member"), $friend->name); 26 32 notify_user($owner->ident, $title, $message_body); 33 plugin_hook("community:member","publish",$f); 27 34 } 28 35 } else devel/mod/community/lib/community_member_remove.php
r1539 r1550 1 1 <?php 2 3 4 2 /* 5 3 * community_member_remove.php … … 7 5 * Created on May 7, 2007 8 6 * 9 * @author Diego Andrés Ramírez Aragón <diego@somosmas.org> 10 * @copyright Corporación Somos más - 2007 7 * @author Diego Andrés RamÃrez Aragón <diego@somosmas.org> 11 8 */ 12 9 global $USER; … … 25 22 case "separate" : 26 23 $community_name= user_info('username', $user_id); 27 error_log("Eliminando owner = $friend_id friend=$user_id");24 $f = get_record('friends','owner',$friend_id,'friend',$user_id); 28 25 if (delete_records("friends", "owner", $friend_id, "friend", $user_id)) { 26 plugin_hook("community:member","delete",$f); 29 27 if ($action == "leave") { 30 28 $run_result[]= sprintf(__gettext("You left %s"), $community_name); devel/mod/file/lib.php
r1506 r1550 148 148 // Register a display object function 149 149 display_set_display_function('file', 'file_displayobject'); 150 151 // Register file river hook (if there)152 if (function_exists('river_save_event'))153 {154 river_register_friendlyname_hook('file::file', 'file_get_friendly_name');155 156 listen_for_event('file','publish', 'file_river_hook');157 listen_for_event('file','delete', 'file_river_hook');158 }159 150 } 160 151 … … 168 159 } 169 160 return $run_result; 170 }171 172 function file_get_friendly_name($object_type, $object_id)173 {174 global $CFG;175 176 $result = get_record_sql("select * from {$CFG->prefix}files where ident = $object_id");177 178 $filepath = $CFG->wwwroot . user_info("username", $result->owner) . "/files/{$result->folder}/{$result->ident}/" . urlencode($result->originalname);179 180 return "<a href=\"$filepath\">" . $result->originalname . "</a>";181 }182 183 function file_river_hook( $object_type, $event, $object)184 {185 global $CFG;186 187 $userid = ($_SESSION['userid'] == "" ? -1 : $_SESSION['userid']);188 $object_id = $object->ident;189 $object_owner = $object->owner;190 191 $filepath = $CFG->wwwroot . user_info("username", $userid) . "/files/{$object->folder}/{$object->ident}/" . urlencode($object->originalname);192 $name = $object->originalname;193 194 $username = user_info("username", $userid);195 if ($userid == false)196 $username = __gettext("Anonymous user");197 198 if ($event == "publish")199 river_save_event($userid, $object_id, $object_owner, $object_type, "<a href=\"" . river_get_userurl($userid) . "\">$username</a> uploaded '<a href=\"$filepath\">$name</a>'", $object->access);200 201 if ($event == "delete")202 river_save_event($userid, $object_id, $object_owner, $object_type, "<a href=\"" . river_get_userurl($userid) . "\">$username</a> deleted '$name'", $object->access);203 204 return $object;205 161 } 206 162 devel/mod/friend/lib/friends_actions.php
r1539 r1550 20 20 $f->friend = $friend_id; 21 21 if ($friend->moderation == 'no') { 22 if ( insert_record('friends',$f)) {22 if ($f->ident = insert_record('friends',$f)) { 23 23 if (user_info("user_type",$friend_id) == "person") { 24 24 $messages[] = sprintf(__gettext("%s was added to your friends list."),$friend->name); … … 27 27 $title = sprintf(__gettext("New %s friend"), $CFG->sitename); 28 28 notify_user($u,$title,$message_body); 29 plugin_hook('friends','publish',$f); 29 30 } 30 31 } else { … … 62 63 if (user_info("user_type",$friend_id) == "person") { 63 64 $messages[] = $friend->name . __gettext(" was removed from your friends."); 65 $friend->owner=$USER->ident; 66 $friend->friend=$friend_id; 67 plugin_hook('friends','delete',$friend); 64 68 } 65 69 } else { … … 87 91 $title = sprintf(__gettext("%s friend request approved!"), $CFG->sitename); 88 92 notify_user($request->owner,$title,$message_body); 93 plugin_hook('friends','publish',$f); 89 94 } else { 90 95 $messages[] = __gettext("An error occurred: couldn't add you as a friend"); devel/mod/template/templates/Default_Template/frontpage_loggedin
r1388 r1550 12 12 <a href="{{url}}{{username}}">View your profile</a>! Your portfolio is the main way people find out about you. You can edit your details and choose exactly what you want to share with whom. 13 13 </p> 14
