Beispiel #1
0
         $this_group_data = $group_data;
     }
     $is_autogroup_enable = $this_group_data['group_count'] <= $user->data['user_posts'] && $this_group_data['group_count_max'] > $user->data['user_posts'] ? true : false;
     // Check if the group is open or we are "autojoining"
     if ($this_group_data['group_type'] != GROUP_OPEN && empty($is_autogroup_enable)) {
         $redirect_url = append_sid(CMS_PAGE_FORUM);
         meta_refresh(3, $redirect_url);
         $message = $lang['This_closed_group'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid(CMS_PAGE_GROUP_CP . '?' . POST_GROUPS_URL . '=' . $group_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(CMS_PAGE_FORUM) . '">', '</a>');
         message_die(GENERAL_MESSAGE, $message);
     }
 } else {
     // The group doesn't exist!
     message_die(GENERAL_MESSAGE, $lang['No_groups_exist']);
 }
 // Check if the user is already a member
 $user_groups_data = get_groups_data_user($user->data['user_id'], false, false, array($group_id));
 if (!empty($user_groups_data)) {
     $redirect_url = append_sid(CMS_PAGE_FORUM);
     meta_refresh(3, $redirect_url);
     $message = $lang['Already_member_group'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid(CMS_PAGE_GROUP_CP . '?' . POST_GROUPS_URL . '=' . $group_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(CMS_PAGE_FORUM) . '">', '</a>');
     message_die(GENERAL_MESSAGE, $message);
 }
 $ug_add_result = group_user_add($group_id, $user->data['user_id'], false);
 $db->clear_cache();
 if (!$is_autogroup_enable) {
     $sql = "SELECT u.user_email, u.username, u.user_lang, g.group_name\n\t\t\tFROM " . USERS_TABLE . " u, " . GROUPS_TABLE . " g\n\t\t\tWHERE u.user_id = g.group_moderator\n\t\t\t\tAND g.group_id = '" . $group_id . "'";
     $result = $db->sql_query($sql);
     $moderator = $db->sql_fetchrow($result);
     include IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT;
     $emailer = new emailer();
     $emailer->use_template('group_request', $moderator['user_lang']);
}
// Custom Profile Fields - END
// GROUPS - BEGIN
$groups_display_block = $user->data['user_level'] == ADMIN ? true : false;
$viewer_groups_list = array();
if ($user->data['session_logged_in']) {
    $viewer_groups_data = get_groups_data_user($user->data['user_id'], false, false, array());
    if (!empty($viewer_groups_data)) {
        foreach ($viewer_groups_data as $group_data) {
            if (empty($group_data['user_pending'])) {
                $viewer_groups_list[] = $group_data['group_id'];
            }
        }
    }
}
$profile_groups_data = get_groups_data_user($profiledata['user_id'], true, true, array());
if (!empty($profile_groups_data)) {
    foreach ($profile_groups_data as $group_data) {
        $group_display = true;
        if ($user->data['user_level'] != ADMIN) {
            if ($group_data['group_type'] == GROUP_HIDDEN && empty($group_data['user_pending'])) {
                if (!$user->data['session_logged_in'] || empty($viewer_groups_list)) {
                    $group_display = false;
                } else {
                    $group_display = in_array($group_data['group_id'], $viewer_groups_list) ? true : false;
                }
            }
        }
        if (!empty($group_display)) {
            $groups_display_block = true;
            $group_name = $group_data['group_name'];
/**
* Creates a list with all the groups a member subscribed.
*
* @param => user_id
* @return => array
*/
function build_groups_user($user_id, $show_hidden = true)
{
    global $db, $cache, $config, $lang;
    $groups_data_user = get_groups_data_user($user_id, true, true, array());
    $groups_list = array();
    foreach ($groups_data_user as $group_data) {
        if (empty($group_data['user_pending'])) {
            $show_this = true;
            if (empty($show_hidden) && $group_data['group_type'] == GROUP_HIDDEN) {
                $show_this = false;
            }
            if (!empty($show_this)) {
                $tmp_group_color = check_valid_color($group_data['group_color']);
                $groups_list[] = array('group_id' => $group_data['group_id'], 'group_name' => $group_data['group_name'], 'group_url' => append_sid(CMS_PAGE_GROUP_CP . '?' . POST_GROUPS_URL . '=' . $group_data['group_id']), 'group_color' => $tmp_group_color, 'group_color_style' => $tmp_group_color ? ' style="color: ' . $group_data['group_color'] . '; font-weight: bold;"' : ' style="font-weight: bold;"');
            }
        }
    }
    return $groups_list;
}