Exemple #1
0
function joinGroup($group_id, $privacy)
{
    global $db, $current_user, $main_smarty, $the_template, $my_base_url, $my_pligg_base;
    if (!is_numeric($group_id)) {
        die;
    }
    $privacy = $db->get_var("SELECT group_privacy FROM " . table_groups . " WHERE group_id = {$group_id}");
    if ($privacy == '') {
        $member_status = 'active';
    } else {
        $member_status = 'inactive';
    }
    $sql = "INSERT INTO " . table_group_member . " ( `member_user_id` , `member_group_id`, `member_role`,`member_status` ) VALUES ('" . $current_user->user_id . "', '" . $group_id . "','normal','" . $member_status . "' ) ";
    $db->query($sql);
    //member count update increase
    if (isMemberActive($group_id) == 'active') {
        $member_count = get_group_members($group_id);
        $member_update = "update " . table_groups . " set group_members = '" . $member_count . "' where group_id = '" . $group_id . "'";
        $db->query($member_update);
    }
    if ($privacy == 'restricted') {
        $my_base_url = $my_base_url;
        $my_pligg_base = $my_pligg_base;
        if (phpnum() == 4) {
            require_once 'class.phpmailer4.php';
        } else {
            require_once 'class.phpmailer5.php';
        }
        //$site_mail = $main_smarty->get_config_vars('PLIGG_Comment_mail_from');
        $from = "*****@*****.**";
        $activate = my_base_url . my_pligg_base . "/join_group.php?activate=true&group_id=" . $group_id . "&user_id=" . $current_user->user_id . "";
        $inactivate = my_base_url . my_pligg_base . "/join_group.php?activate=false";
        $str .= "Hello Admin<br />A new member has requested to join your group.<br/>To activate click link below<br/><a href='" . my_base_url . my_pligg_base . "/join_group.php?activate=true&group_id=" . $group_id . "&user_id=" . $current_user->user_id . "'>Activate</a><br />";
        $str .= "To deactivate click link below<br/><a href='" . my_base_url . my_pligg_base . "/join_group.php?activate=false&group_id=" . $group_id . "&user_id=" . $current_user->user_id . "'>Deactivate</a><br />";
        $subject = "Request to join group";
        $creator_id = get_group_creator($group_id);
        $to = get_group_user_email($creator_id);
        //$to = $creator_id;
        $message = $str;
        echo $message . ":" . $to . ":" . $from . ":" . $subject;
        $mail = new PHPMailer();
        $mail->From = $from;
        $mail->FromName = "Administrator";
        $mail->AddAddress($to);
        $mail->AddReplyTo($from);
        $mail->IsHTML(true);
        $mail->Subject = $subject;
        $mail->Body = $message;
        $mail->Send();
    }
}
Exemple #2
0
function joinGroup($group_id, $privacy)
{
    global $db, $current_user, $main_smarty, $the_template, $my_base_url, $my_pligg_base;
    if (!is_numeric($group_id)) {
        die;
    }
    if (!$current_user->user_id) {
        die;
    }
    // Enforce "Max Joinable Groups" config option
    if (reached_max_joinable_groups($db, $current_user)) {
        return;
    }
    $privacy = $db->get_var("SELECT group_privacy FROM " . table_groups . " WHERE group_id = {$group_id}");
    if ($privacy == 'public') {
        $member_status = 'active';
    } else {
        $member_status = 'inactive';
    }
    if (isMember($group_id)) {
        return;
    }
    $sql = "INSERT IGNORE INTO " . table_group_member . " ( `member_user_id` , `member_group_id`, `member_role`,`member_status` ) VALUES ('" . $current_user->user_id . "', '" . $group_id . "','normal','" . $member_status . "' ) ";
    $db->query($sql);
    //member count update increase
    if (isMemberActive($group_id) == 'active') {
        $member_count = get_group_members($group_id);
        $member_update = "update " . table_groups . " set group_members = '" . $member_count . "' where group_id = '" . $group_id . "'";
        $db->query($member_update);
    }
    if ($privacy != 'public') {
        $creator_id = get_group_creator($group_id);
        $to = get_group_user_email($creator_id);
        $subject = $main_smarty->get_config_vars('PLIGG_Visual_Group_Email_Subject');
        $body = sprintf($main_smarty->get_config_vars('PLIGG_Visual_Group_Email_Body'), my_base_url . getmyurl("user", $current_user->user_login), $current_user->user_login, my_base_url . my_pligg_base . "/join_group.php?activate=true&group_id=" . $group_id . "&user_id=" . $current_user->user_id, my_base_url . my_pligg_base . "/join_group.php?activate=false&group_id=" . $group_id . "&user_id=" . $current_user->user_id);
        $headers = 'From: ' . $main_smarty->get_config_vars("PLIGG_PassEmail_From") . "\r\n";
        $headers .= "Content-type: text/html; charset=utf-8\r\n";
        mail($to, $subject, $body, $headers);
    }
}