Changeset 1390

Show
Ignore:
Timestamp:
12/06/07 13:51:52 (10 months ago)
Author:
misja
Message:

Misja Hoebe <misja@curverider.co.uk> Addresses #160, community owners now have an option to search and invite users to a community

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/htaccess-dist

    r1365 r1390  
    124124RewriteRule ^([A-Za-z0-9]+)\/community\/separate\/([0-9]+)$ mod/community/members.php?profile_name=$1&friend_id=$2&action=separate 
    125125RewriteRule ^community\/([0-9]+)\/?$ mod/communities/community.php?community_id=$1 
    126  
     126RewriteRule ^([A-Za-z0-9]+)\/community\/invite$ mod/community/invite.php?profile_name=$1 
     127RewriteRule ^([A-Za-z0-9]+)\/communities\/invitations$ mod/community/user_community_invitations.php?profile_name=$1 
    127128 
    128129# Files 
  • devel/mod/community/lib.php

    r1281 r1390  
    8585                                         'html' => a_href("{$CFG->wwwroot}{$username}/community/requests", 
    8686                                                           __gettext("View membership requests"))); 
    87             } 
     87 
     88              $PAGE->menu_sub[] = array( 'name' => 'community:invite', 
     89                                         'html' => a_href("{$CFG->wwwroot}{$username}/community/invite", 
     90                                                           __gettext("Invite people"))); 
     91              } 
    8892        } 
    8993         
     
    105109            } 
    106110        } 
    107          
    108111    } else if ($usertype == "person") { 
    109112 
     
    138141                                  'user_type' => 'community'); 
    139142 
     143    // Add membership requests to the personal network page 
     144    if (defined("context") && context == "network") { 
     145          $PAGE->menu_sub[] = array( 'name' => 'membership:invites', 
     146                                   'html' => a_href( "{$CFG->wwwroot}{$username}/communities/invitations", 
     147                                                      __gettext("Membership invitations"))); 
     148    } 
    140149} 
    141150 
     
    210219                river_register_friendlyname_hook('community::community', 'community_get_friendly_name'); 
    211220        } 
    212          
    213221} 
    214222 
  • devel/mod/community/lib/communities_actions.php

    r1345 r1390  
    1212 
    1313if (isloggedin()) { 
    14  
    1514    switch($action) { 
    1615 
     
    141140             break; 
    142141 
     142         case "community:approve:invitation": 
     143         $request_id = optional_param('request_id',0,PARAM_INT); 
     144         if (!empty($request_id) && logged_on && user_type($page_owner) == "person") {  
     145             if ($request = get_record_sql('SELECT u.name, fr.owner, fr.friend FROM '.$CFG->prefix.'friends_requests fr 
     146                                    LEFT JOIN '.$CFG->prefix.'users u ON u.ident = fr.owner  
     147                                    WHERE fr.ident = ?',array($request_id))) { 
     148                 if (run("permissions:check",array("userdetails:change", $page_owner))) { 
     149                     $f = new StdClass; 
     150                     $f->owner = $request->owner; 
     151                     $f->friend = $request->friend; 
     152                     if (insert_record('friends',$f)) { 
     153                         delete_records('friends_requests','ident',$request_id); 
     154                         $messages[] = sprintf(__gettext("You accepted the community invitation. You are now a member of the community %s."),stripslashes($request->name)); 
     155                         $message_body = sprintf(__gettext("%s has approved your community invitation!\n\nRegards,\n\nThe %s team."),user_name($request->friend), $CFG->sitename); 
     156                         $title = __gettext("Community invitation accepted!"); 
     157                         notify_user($request->owner,$title,$message_body); 
     158                     } else { 
     159                         $messages[] = __gettext("An error occurred: couldn't add you as a community member"); 
     160                     } 
     161                 } else { 
     162                     $messages[] = __gettext("Error: you do not have authority to accept this membership invitation."); 
     163                 } 
     164             } else { 
     165                 $messages[] = __gettext("An error occurred: the invitation could not be found."); 
     166             } 
     167              
     168         } 
     169         break; 
     170     case "community:decline:invitation": 
     171         $request_id = optional_param('request_id',0,PARAM_INT); 
     172         if (!empty($request_id) && logged_on && user_type($page_owner) == "person") { 
     173             if ($request = get_record_sql('SELECT u.name, fr.owner, fr.friend FROM '.$CFG->prefix.'friends_requests fr 
     174                                    LEFT JOIN '.$CFG->prefix.'users u ON u.ident = fr.owner  
     175                                    WHERE fr.ident = ?',array($request_id))) { 
     176                 if (run("permissions:check",array("userdetails:change", $page_owner))) { 
     177                     delete_records('friends_requests','ident',$request_id); 
     178                     $messages[] = sprintf(__gettext("You declined the community invitation. You are not a member of community %s."),stripslashes($request->name)); 
     179                     $message_body = sprintf(__gettext("%s has denied your community invitation.\n\nRegards,\n\nThe %s team."),user_name($request->friend), $CFG->sitename); 
     180                     $title = sprintf(__gettext("%s friend request denied"), $CFG->sitename); 
     181                     notify_user($request->owner,$title,$message_body); 
     182                 } else { 
     183                     $messages[] = __gettext("Error: you do not have authority to modify this membership invitation."); 
     184                 } 
     185             } else { 
     186                 $messages[] = __gettext("An error occurred: the invitation could not be found."); 
     187             } 
     188              
     189         } 
     190         break; 
    143191    } 
    144192 
  • devel/mod/friend/lib/user_friendship_requests.php

    r1369 r1390  
    1313            if ($pending_requests = get_records_sql('SELECT fr.ident AS request_id,u.* 
    1414                                                     FROM '.$CFG->prefix.'friends_requests fr LEFT JOIN '.$CFG->prefix.'users u ON u.ident = fr.owner 
    15                                                      WHERE fr.friend = ? ORDER BY u.name ASC',array($page_owner))) { 
     15                                                     WHERE fr.friend = ? AND u.user_type = \'person\' ORDER BY u.name ASC',array($page_owner))) { 
    1616                $body = "<p>" . __gettext("The following users would like to add you as a friend. They need your approval to do this (to change this setting, visit the 'account settings' page).") . "</p>"; 
    1717 
     
    5151                $body = "<p>" . __gettext("You have no pending friendship requests.") . "</p>"; 
    5252            } 
    53                         
    54             $run_result .= $body; 
     53 
     54            $run_result = templates_draw(array( 
     55                        'context' => 'contentholder', 
     56                        'title' => $title, 
     57                        'body' => $body 
     58                    ) 
     59                    ); 
    5560 
    5661        }