Changeset 1390
- Timestamp:
- 12/06/07 13:51:52 (10 months ago)
- Files:
-
- devel/htaccess-dist (modified) (1 diff)
- devel/mod/community/invite.php (added)
- devel/mod/community/lib.php (modified) (4 diffs)
- devel/mod/community/lib/communities_actions.php (modified) (2 diffs)
- devel/mod/community/lib/community_membership_invitations.php (added)
- devel/mod/friend/lib/user_friendship_requests.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/htaccess-dist
r1365 r1390 124 124 RewriteRule ^([A-Za-z0-9]+)\/community\/separate\/([0-9]+)$ mod/community/members.php?profile_name=$1&friend_id=$2&action=separate 125 125 RewriteRule ^community\/([0-9]+)\/?$ mod/communities/community.php?community_id=$1 126 126 RewriteRule ^([A-Za-z0-9]+)\/community\/invite$ mod/community/invite.php?profile_name=$1 127 RewriteRule ^([A-Za-z0-9]+)\/communities\/invitations$ mod/community/user_community_invitations.php?profile_name=$1 127 128 128 129 # Files devel/mod/community/lib.php
r1281 r1390 85 85 'html' => a_href("{$CFG->wwwroot}{$username}/community/requests", 86 86 __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 } 88 92 } 89 93 … … 105 109 } 106 110 } 107 108 111 } else if ($usertype == "person") { 109 112 … … 138 141 'user_type' => 'community'); 139 142 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 } 140 149 } 141 150 … … 210 219 river_register_friendlyname_hook('community::community', 'community_get_friendly_name'); 211 220 } 212 213 221 } 214 222 devel/mod/community/lib/communities_actions.php
r1345 r1390 12 12 13 13 if (isloggedin()) { 14 15 14 switch($action) { 16 15 … … 141 140 break; 142 141 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; 143 191 } 144 192 devel/mod/friend/lib/user_friendship_requests.php
r1369 r1390 13 13 if ($pending_requests = get_records_sql('SELECT fr.ident AS request_id,u.* 14 14 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))) { 16 16 $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>"; 17 17 … … 51 51 $body = "<p>" . __gettext("You have no pending friendship requests.") . "</p>"; 52 52 } 53 54 $run_result .= $body; 53 54 $run_result = templates_draw(array( 55 'context' => 'contentholder', 56 'title' => $title, 57 'body' => $body 58 ) 59 ); 55 60 56 61 }
