function shd_profile_theme_wrapper($memID)
{
    global $txt, $context, $user_profile, $modSettings, $settings, $user_info, $smcFunc, $sourcedir, $profile_fields;
    loadTemplate('Profile');
    loadTemplate('sd_template/SimpleDesk-Profile');
    $lang_strings = array('current_time', 'theme_info', 'date_format', 'return_to_post', 'timeformat_default', 'theme_forum_default', 'theme_forum_default_desc');
    // Replace the standard profile strings with SD specific ones.
    foreach ($lang_strings as $str) {
        $txt[$str] = $txt['shd_' . $str];
    }
    loadThemeOptions($memID);
    if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) {
        loadCustomFields($memID, 'theme');
    }
    $context['sub_template'] = 'edit_options';
    $context['page_desc'] = $txt['theme_info'];
    $opts = array('id_theme', 'smiley_set', 'hr', 'time_format', 'time_offset', 'hr', 'theme_settings');
    if (!empty($modSettings['shd_display_avatar'])) {
        $opts = array_merge(array('avatar_choice', 'hr'), $opts);
    }
    setupProfileContext($opts);
    $context['profile_fields']['theme_settings']['callback_func'] = 'shd_theme_settings';
}
Esempio n. 2
0
function rememberPostData()
{
    global $context, $scripturl, $txt, $modSettings, $ID_MEMBER, $user_profile, $user_info;
    // Overwrite member settings with the ones you selected.
    $context['member'] = array('is_owner' => $_REQUEST['userID'] == $ID_MEMBER, 'username' => $user_profile[$_REQUEST['userID']]['memberName'], 'name' => !isset($_POST['realName']) || $_POST['realName'] == '' ? $user_profile[$_REQUEST['userID']]['memberName'] : stripslashes($_POST['realName']), 'id' => (int) $_REQUEST['userID'], 'title' => !isset($_POST['usertitle']) || $_POST['usertitle'] == '' ? '' : stripslashes($_POST['usertitle']), 'email' => isset($_POST['emailAddress']) ? $_POST['emailAddress'] : '', 'hide_email' => empty($_POST['hideEmail']) ? 0 : 1, 'show_online' => empty($_POST['showOnline']) ? 0 : 1, 'registered' => empty($_POST['dateRegistered']) || $_POST['dateRegistered'] == '0001-01-01' ? $txt[470] : strftime('%Y-%m-%d', $_POST['dateRegistered']), 'blurb' => !isset($_POST['personalText']) ? '' : str_replace(array('<', '>', '&amp;#039;'), array('&lt;', '&gt;', '&#039;'), stripslashes($_POST['personalText'])), 'gender' => array('name' => empty($_POST['gender']) ? '' : ($_POST['gender'] == 2 ? 'f' : 'm')), 'website' => array('title' => !isset($_POST['websiteTitle']) ? '' : stripslashes($_POST['websiteTitle']), 'url' => !isset($_POST['websiteUrl']) ? '' : stripslashes($_POST['websiteUrl'])), 'birth_date' => array('month' => empty($_POST['bday1']) ? '00' : (int) $_POST['bday1'], 'day' => empty($_POST['bday2']) ? '00' : (int) $_POST['bday2'], 'year' => empty($_POST['bday3']) ? '0000' : (int) $_POST['bday3']), 'signature' => !isset($_POST['signature']) ? '' : str_replace(array('<', '>'), array('&lt;', '&gt;'), $_POST['signature']), 'location' => !isset($_POST['location']) ? '' : stripslashes($_POST['location']), 'icq' => array('name' => !isset($_POST['icq']) ? '' : stripslashes($_POST['ICQ'])), 'aim' => array('name' => empty($_POST['aim']) ? '' : str_replace('+', ' ', $_POST['AIM'])), 'yim' => array('name' => empty($_POST['yim']) ? '' : stripslashes($_POST['YIM'])), 'msn' => array('name' => empty($_POST['msn']) ? '' : stripslashes($_POST['MSN'])), 'posts' => empty($_POST['posts']) ? 0 : (int) $_POST['posts'], 'avatar' => array('name' => &$_POST['avatar'], 'href' => empty($user_profile[$_REQUEST['userID']]['ID_ATTACH']) ? '' : (empty($user_profile[$_REQUEST['userID']]['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $user_profile[$_REQUEST['userID']]['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $user_profile[$_REQUEST['userID']]['filename']), 'custom' => stristr($_POST['avatar'], 'http://') ? $_POST['avatar'] : 'http://', 'selection' => $_POST['avatar'] == '' || stristr($_POST['avatar'], 'http://') ? '' : $_POST['avatar'], 'choice' => empty($_POST['avatar_choice']) ? 'server_stored' : $_POST['avatar_choice'], 'external' => empty($_POST['userpicpersonal']) ? 'http://' : $_POST['userpicpersonal'], 'ID_ATTACH' => empty($_POST['ID_ATTACH']) ? '0' : $_POST['ID_ATTACH'], 'allow_server_stored' => allowedTo('profile_server_avatar') || !$context['user']['is_owner'], 'allow_upload' => allowedTo('profile_upload_avatar') || !$context['user']['is_owner'], 'allow_external' => allowedTo('profile_remote_avatar') || !$context['user']['is_owner']), 'karma' => array('good' => empty($_POST['karmaGood']) ? '0' : $_POST['karmaGood'], 'bad' => empty($_POST['karmaBad']) ? '0' : $_POST['karmaBad']), 'time_format' => !isset($_POST['timeFormat']) ? '' : stripslashes($_POST['timeFormat']), 'time_offset' => empty($_POST['timeOffset']) ? '0' : $_POST['timeOffset'], 'secret_question' => !isset($_POST['secretQuestion']) ? '' : stripslashes($_POST['secretQuestion']), 'theme' => array('id' => isset($context['member']['theme']['id']) ? $context['member']['theme']['id'] : 0, 'name' => isset($context['member']['theme']['name']) ? $context['member']['theme']['name'] : ''), 'notify_announcements' => empty($_POST['notifyAnnouncements']) ? 0 : 1, 'notify_once' => empty($_POST['notifyOnce']) ? 0 : 1, 'notify_send_body' => empty($_POST['notifySendBody']) ? 0 : (int) $_POST['notifySendBody'], 'notify_types' => empty($_POST['notifyTypes']) ? 0 : (int) $_POST['notifyTypes'], 'group' => isset($_POST['ID_GROUP']) ? $_POST['ID_GROUP'] : 0, 'smiley_set' => array('id' => isset($_POST['smileySet']) ? $_POST['smileySet'] : (isset($context['member']['smiley_set']) ? $context['member']['smiley_set']['id'] : ''), 'name' => isset($context['member']['smiley_set']) ? $context['member']['smiley_set']['name'] : ''));
    // Overwrite the currently set membergroups with those you just selected.
    if (allowedTo('manage_membergroups') && isset($_POST['ID_GROUP'])) {
        foreach ($context['member_groups'] as $ID_GROUP => $dummy) {
            $context['member_groups'][$ID_GROUP]['is_primary'] = $ID_GROUP == $_POST['ID_GROUP'];
            $context['member_groups'][$ID_GROUP]['is_additional'] = !empty($_POST['additionalGroups']) && in_array($ID_GROUP, $_POST['additionalGroups']);
        }
    }
    loadThemeOptions((int) $_REQUEST['userID']);
}
function pictures($memID)
{
    global $context, $modSettings, $smcFunc, $txt, $sourcedir;
    loadTemplate('ProfilePictures');
    require_once $sourcedir . '/Profile-Modify.php';
    loadThemeOptions($memID);
    if ((@$context['member']['options']['pictures_budd_only'] == 1 || @$context['member']['options']['customized_private'] == 1) && @$modSettings['enable_buddylist'] == 1) {
        if (is_buddy($memID, $context['user']['id']) || allowedTo('edit_Maximum_Maximum_any') || $context['user']['is_owner']) {
            $context['can_view_pics'] = true;
        } else {
            $context['can_view_pics'] = false;
        }
    } else {
        $context['can_view_pics'] = true;
    }
    if ($modSettings['Maximum_enable_pictures'] != 1 || !$context['can_view_pics']) {
        fatal_error($txt['Maximum_picture_not_allowed'], false);
    }
    // Permisions
    $allowed_edit = false;
    $allowed_add = false;
    $allowed_album_modify = false;
    if (allowedTo('edit_Maximum_Maximum_any')) {
        $allowed_edit = true;
        $allowed_add = true;
        $allowed_album_modify = true;
    } elseif ($context['user']['is_owner'] && allowedTo('edit_Maximum_Maximum_own')) {
        $allowed_add = true;
        $allowed_album_modify = true;
        // Are you editing picture that is on your own profile?
        $temp_id = isset($_GET['view']) ? $_GET['view'] : (isset($_GET['edit']) ? $_GET['edit'] : (isset($_GET['edit2']) ? $_GET['edit2'] : (isset($_GET['delete']) ? $_GET['delete'] : '')));
        $request = $smcFunc['db_query']('', '
			SELECT id_member 
			FROM {db_prefix}Maximum_pictures 
			WHERE id_picture = {int:id_picture}', array('id_picture' => (int) $temp_id));
        list($user_id) = $smcFunc['db_fetch_row']($request);
        if ($context['user']['id'] == $user_id) {
            $allowed_edit = true;
        }
        // What about albums?
        $temp_id2 = isset($_GET['album']) ? $_GET['album'] : (isset($_GET['editalb']) ? $_GET['editalb'] : (isset($_GET['editalb2']) ? $_GET['editalb2'] : (isset($_GET['deletealb']) ? $_GET['deletealb'] : '')));
        if ($temp_id2 !== '') {
            $request = $smcFunc['db_query']('', '
				SELECT id_member 
				FROM {db_prefix}Maximum_albums 
				WHERE id_album = {int:id_album}', array('id_album' => (int) $temp_id2));
            list($user_id) = $smcFunc['db_fetch_row']($request);
            if ($context['user']['id'] == $user_id) {
                $allowed_album_modify = true;
            }
        }
    }
    if (isset($_GET['add']) || isset($_GET['add2'])) {
        if ($modSettings['Maximum_pictures_number'] > 0) {
            // 0 means unlimited :D.
            $request = $smcFunc['db_query']('', '
				SELECT COUNT(id_picture) 
				FROM {db_prefix}Maximum_pictures 
				WHERE id_member = {int:id_member}', array('id_member' => $memID));
            list($pic_count) = $smcFunc['db_fetch_row']($request);
            if ($pic_count >= $modSettings['Maximum_pictures_number']) {
                fatal_error($txt['Maximum_pictures_over'], false);
            }
        }
    }
    $context['can_add'] = $allowed_add;
    // I can't use switch($_GET) here so I'm stuck with elseifs... It will work :)
    if (isset($_GET['add'])) {
        AddPicture($allowed_add);
    } elseif (isset($_GET['add2'])) {
        AddPicture2($allowed_add);
    } elseif (isset($_GET['edit'])) {
        EditPicture($allowed_edit);
    } elseif (isset($_GET['edit2'])) {
        EditPicture2($allowed_edit);
    } elseif (isset($_GET['delete'])) {
        DeletePicture($allowed_edit);
    } elseif (isset($_GET['addalb'])) {
        AddAlbum($allowed_album_modify);
    } elseif (isset($_GET['addalb2'])) {
        AddAlbum2($allowed_album_modify);
    } elseif (isset($_GET['editalb'])) {
        EditAlbum($allowed_album_modify);
    } elseif (isset($_GET['editalb2'])) {
        EditAlbum2($allowed_album_modify);
    } elseif (isset($_GET['deletealb'])) {
        DeleteAlbum($allowed_album_modify);
    } elseif (isset($_GET['comment'])) {
        AddPictureComment();
    } elseif (isset($_GET['delcomment'])) {
        DeletePictureComment();
    } elseif (isset($_GET['view'])) {
        ViewPicture($allowed_edit);
    } else {
        ShowAlbum($allowed_album_modify);
    }
}
Esempio n. 4
0
function ignoreboards($memID)
{
    global $txt, $user_info, $context, $modSettings, $smcFunc, $cur_profile;
    // Have the admins enabled this option?
    if (empty($modSettings['allow_ignore_boards'])) {
        fatal_lang_error('ignoreboards_disallowed', 'user');
    }
    // Find all the boards this user is allowed to see.
    $request = $smcFunc['db_query']('order_by_board_order', '
		SELECT b.id_cat, c.name AS cat_name, b.id_board, b.name, b.child_level,
			' . (!empty($cur_profile['ignore_boards']) ? 'b.id_board IN ({array_int:ignore_boards})' : '0') . ' AS is_ignored
		FROM {db_prefix}boards AS b
			LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
		WHERE {query_see_board}
			AND redirect = {string:empty_string}', array('ignore_boards' => !empty($cur_profile['ignore_boards']) ? explode(',', $cur_profile['ignore_boards']) : array(), 'empty_string' => ''));
    $context['num_boards'] = $smcFunc['db_num_rows']($request);
    $context['categories'] = array();
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        // This category hasn't been set up yet..
        if (!isset($context['categories'][$row['id_cat']])) {
            $context['categories'][$row['id_cat']] = array('id' => $row['id_cat'], 'name' => $row['cat_name'], 'boards' => array());
        }
        // Set this board up, and let the template know when it's a child.  (indent them..)
        $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array('id' => $row['id_board'], 'name' => $row['name'], 'child_level' => $row['child_level'], 'selected' => $row['is_ignored']);
    }
    $smcFunc['db_free_result']($request);
    // Now, let's sort the list of categories into the boards for templates that like that.
    $temp_boards = array();
    foreach ($context['categories'] as $category) {
        // Include a list of boards per category for easy toggling.
        $context['categories'][$category['id']]['child_ids'] = array_keys($category['boards']);
        $temp_boards[] = array('name' => $category['name'], 'child_ids' => array_keys($category['boards']));
        $temp_boards = array_merge($temp_boards, array_values($category['boards']));
    }
    $max_boards = ceil(count($temp_boards) / 2);
    if ($max_boards == 1) {
        $max_boards = 2;
    }
    // Now, alternate them so they can be shown left and right ;).
    $context['board_columns'] = array();
    for ($i = 0; $i < $max_boards; $i++) {
        $context['board_columns'][] = $temp_boards[$i];
        if (isset($temp_boards[$i + $max_boards])) {
            $context['board_columns'][] = $temp_boards[$i + $max_boards];
        } else {
            $context['board_columns'][] = array();
        }
    }
    loadThemeOptions($memID);
}
 /**
  * Allows the user to see the list of their ignored boards.
  * (and un-ignore them)
  *
  */
 public function action_ignoreboards()
 {
     global $context, $modSettings, $cur_profile;
     $memID = currentMemberID();
     // Have the admins enabled this option?
     if (empty($modSettings['allow_ignore_boards'])) {
         fatal_lang_error('ignoreboards_disallowed', 'user');
     }
     loadTemplate('ProfileOptions');
     $context['sub_template'] = 'ignoreboards';
     require_once SUBSDIR . '/Boards.subs.php';
     $context += getBoardList(array('not_redirection' => true, 'ignore' => !empty($cur_profile['ignore_boards']) ? explode(',', $cur_profile['ignore_boards']) : array()));
     // Include a list of boards per category for easy toggling.
     foreach ($context['categories'] as $cat => &$category) {
         $context['boards_in_category'][$cat] = count($category['boards']);
         $category['child_ids'] = array_keys($category['boards']);
     }
     loadThemeOptions($memID);
 }