Changeset 1519

Show
Ignore:
Timestamp:
01/20/08 00:09:19 (11 months ago)
Author:
ewout
Message:

Fix a problem with community membership aprovals. Resolves #245.

Files:

Legend:

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

    r1481 r1519  
    1010 * @copyright Corporaciᅵn Somos mᅵs - 2007 
    1111 */ 
    12  global $USER; 
     12global $USER; 
    1313 
    1414if (isset ($parameter)) { 
    15   $friend_id= $parameter[0]; 
    16   if(!record_exists('friends','friend',$friend_id,'owner',$USER->ident)){ 
    17     $f = new StdClass; 
    18     $f->owner = $USER->ident; 
    19     $f->friend = $friend_id; 
    20     insert_record('friends',$f); 
    21   } 
    22   $run_result= array (); 
    23   if (!empty ($friend_id) && logged_on) { 
    24     if (user_info("user_type", $friend_id) == "community") { 
    25       if ($friend= get_record('users', 'ident', $friend_id)) { 
    26         $owner= get_record('users', 'ident', $friend->owner); 
    27         if ($friend->moderation == "no") { 
    28           $run_result[]= sprintf(__gettext("You joined %s."), stripslashes($friend->name)); 
    29           if (user_flag_get("emailnotifications", $owner->ident)) { 
    30             $message_body= sprintf(__gettext("%s has joined %s!\n\nTo visit this user's profile, click on the following link:\n\n\t" . 
    31             "%s\n\nTo view all community members, click here:\n\n\t%s\n\nRegards,\n\nThe %s team."), $_SESSION['name'], $friend->name, $CFG->wwwroot . user_info("username", $USER->ident) . "/", $CFG->wwwroot . $friend->username . "/community/members", $CFG->sitename); 
    32             $title= sprintf(__gettext("New %s member"), $friend->name); 
    33             notify_user($owner->ident, $title, $message_body); 
    34           } 
    35         } else 
    36           if ($friend->moderation == "yes") { 
    37             $run_result[]= sprintf(__gettext("Membership of %s needs to be approved. Your request has been added to the list."), stripslashes($friend->name)); 
    38             if (user_flag_get("emailnotifications", $owner->ident)) { 
    39               $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" . 
    40               "%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."), $_SESSION['name'], $friend->name, $CFG->wwwroot . user_info("username", $USER->ident) . "/", $CFG->wwwroot . $friend->username . "/community/members", $CFG->sitename); 
    41               $title= sprintf(__gettext("New %s member request"), $friend->name); 
    42               notify_user($owner->ident, $title, $message_body); 
     15    $friend_id= $parameter[0]; 
     16    $run_result= array (); 
     17    if (!empty ($friend_id) && logged_on) { 
     18        if (user_info("user_type", $friend_id) == "community") { 
     19            if ($friend= get_record('users', 'ident', $friend_id)) { 
     20                $owner= get_record('users', 'ident', $friend->owner); 
     21                if ($friend->moderation == "no") { 
     22                    $run_result[]= sprintf(__gettext("You joined %s."), stripslashes($friend->name)); 
     23                    if (user_flag_get("emailnotifications", $owner->ident)) { 
     24                        $message_body= sprintf(__gettext("%s has joined %s!\n\nTo visit this user's profile, click on the following link:\n\n\t%s\n\nTo view all community members, click here:\n\n\t%s\n\nRegards,\n\nThe %s team."), $_SESSION['name'], $friend->name, $CFG->wwwroot . user_info("username", $USER->ident) . "/", $CFG->wwwroot . $friend->username . "/community/members", $CFG->sitename); 
     25                        $title= sprintf(__gettext("New %s member"), $friend->name); 
     26                        notify_user($owner->ident, $title, $message_body); 
     27                    } 
     28                } else 
     29                    if ($friend->moderation == "yes") { 
     30                        $run_result[]= sprintf(__gettext("Membership of %s needs to be approved. Your request has been added to the list."), stripslashes($friend->name)); 
     31                        if (user_flag_get("emailnotifications", $owner->ident)) { 
     32                            $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" . 
     33                                "%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."), $_SESSION['name'], $friend->name, $CFG->wwwroot . user_info("username", $USER->ident) . "/", $CFG->wwwroot . $friend->username . "/community/members", $CFG->sitename); 
     34                            $title= sprintf(__gettext("New %s member request"), $friend->name); 
     35                            notify_user($owner->ident, $title, $message_body); 
     36                        } 
     37                    } else 
     38                        if ($friend->moderation == "priv") { 
     39                            $run_result[]= sprintf(__gettext("%s is a private community. Your membership request has been declined."), stripslashes($friend->name)); 
     40                        } 
    4341            } 
    44           } else 
    45             if ($friend->moderation == "priv") { 
    46               $run_result[]= sprintf(__gettext("%s is a private community. Your membership request has been declined."), stripslashes($friend->name)); 
    47             } 
    48       } 
     42        } 
    4943    } 
    50   } 
    5144} 
    5245?>