Changeset 1550

Show
Ignore:
Timestamp:
02/11/08 02:51:42 (6 months ago)
Author:
dramirez
Message:

Remove all the code related to the river plugin to make it a selfcontained functionality

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/mod/blog/lib.php

    r1524 r1550  
    250250   
    251251  //$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; 
    309252} 
    310253 
     
    712655    return isset($type) ? $type : $default; 
    713656} 
     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 */ 
     664function 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 */ 
     685function 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 
    714699?> 
  • devel/mod/commentwall/do_action.php

    r1539 r1550  
    3636                        if ($displaymode=="xml")  
    3737                                $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 owner 
    47                                 $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 owner 
    56                                 $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                         } 
    6738                } 
    6839                else 
  • devel/mod/commentwall/lib.php

    r1549 r1550  
    104104                notify_user($wall_id, __gettext("Someone has posted to your comment wall"), __gettext("Check it out") . ": " . $CFG->wwwroot . user_info("username", $wall_id) . "/profile/"); 
    105105            } 
     106                        $newcomment = plugin_hook("commentwall","publish",$newcomment);  
    106107            return $newcomment->ident; 
    107108        } 
    108109                 
    109                 return insert_record("commentwall", $newcomment); 
     110        $newcomment->ident = insert_record("commentwall", $newcomment); 
     111                $newcomment = plugin_hook("commentwall","publish",$newcomment);  
     112        return $newcomment->ident; 
    110113        } 
    111114         
     
    126129                { 
    127130                        if (!delete_records("commentwall", "ident", $comment->ident)) 
     131                                plugin_hook('commentwall','delete',$comment); 
    128132                                return false; 
    129133                                 
  • devel/mod/community/lib.php

    r1483 r1550  
    211211        listen_for_event("user","delete","community_user_delete"); 
    212212         
    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  
    222213        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; 
    264214} 
    265215 
  • devel/mod/community/lib/communities_actions.php

    r1541 r1550  
    111111                         $f->owner = $request->owner; 
    112112                         $f->friend = $request->friend; 
    113                          if (insert_record('friends',$f)) { 
     113                         if ($f->ident = insert_record('friends',$f)) { 
    114114                             delete_records('friends_requests','ident',$request_id); 
     115                             plugin_hook("community:member","publish",$f); 
    115116                             $messages[] = sprintf(__gettext("You approved the membership request. %s is now a member of this community."),stripslashes($request->name)); 
    116117                         } else { 
  • devel/mod/community/lib/community_member_add.php

    r1539 r1550  
    11<?php 
    2  
    3  
    42/* 
    53 * community_member_add.php 
     
    75 * Created on May 7, 2007 
    86 * 
    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> 
    118 */ 
    129global $USER; 
     
    1411if (isset ($parameter)) { 
    1512    $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    } 
    1622    $run_result= array (); 
    1723    if (!empty ($friend_id) && logged_on) { 
     
    2531                        $title= sprintf(__gettext("New %s member"), $friend->name); 
    2632                        notify_user($owner->ident, $title, $message_body); 
     33                        plugin_hook("community:member","publish",$f); 
    2734                    } 
    2835                } else 
  • devel/mod/community/lib/community_member_remove.php

    r1539 r1550  
    11<?php 
    2  
    3  
    42/* 
    53 * community_member_remove.php 
     
    75 * Created on May 7, 2007 
    86 * 
    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> 
    118 */ 
    129global $USER; 
     
    2522      case "separate" : 
    2623        $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); 
    2825        if (delete_records("friends", "owner", $friend_id, "friend", $user_id)) { 
     26          plugin_hook("community:member","delete",$f);  
    2927          if ($action == "leave") { 
    3028            $run_result[]= sprintf(__gettext("You left %s"), $community_name); 
  • devel/mod/file/lib.php

    r1506 r1550  
    148148        // Register a display object function 
    149149        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         } 
    159150} 
    160151 
     
    168159        } 
    169160        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; 
    205161} 
    206162         
  • devel/mod/friend/lib/friends_actions.php

    r1539 r1550  
    2020                $f->friend = $friend_id; 
    2121                if ($friend->moderation == 'no') { 
    22                     if (insert_record('friends',$f)) { 
     22                    if ($f->ident = insert_record('friends',$f)) { 
    2323                        if (user_info("user_type",$friend_id) == "person") { 
    2424                            $messages[] = sprintf(__gettext("%s was added to your friends list."),$friend->name); 
     
    2727                            $title = sprintf(__gettext("New %s friend"), $CFG->sitename); 
    2828                            notify_user($u,$title,$message_body); 
     29                            plugin_hook('friends','publish',$f); 
    2930                        } 
    3031                    } else { 
     
    6263                 if (user_info("user_type",$friend_id) == "person") { 
    6364                     $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); 
    6468                 } 
    6569             } else { 
     
    8791                         $title = sprintf(__gettext("%s friend request approved!"), $CFG->sitename); 
    8892                         notify_user($request->owner,$title,$message_body); 
     93                         plugin_hook('friends','publish',$f); 
    8994                     } else { 
    9095                         $messages[] = __gettext("An error occurred: couldn't add you as a friend"); 
  • devel/mod/template/templates/Default_Template/frontpage_loggedin

    r1388 r1550  
    1212    <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. 
    1313</p> 
     14