示例#1
0
/**
 * @param $memID	int member ID
 * 
 * show the settings to customize opt-outs for activity entries and notifications
 * to receive.
 * 
 * todo: we need to find a way to filter out notifications that are for
 * admins/mods only. probably needs a db scheme change...
 */
function showActivitiesProfileSettings($memID)
{
    global $modSettings, $context, $user_info, $txt, $user_profile, $scripturl;
    loadLanguage('Activities-Profile');
    if (empty($modSettings['astream_active']) || $user_info['id'] != $memID && !$user_info['is_admin']) {
        fatal_lang_error('no_access');
    }
    Eos_Smarty::getConfigInstance()->registerHookTemplate('profile_content_area', 'profile/astream_settings');
    $context['submiturl'] = $scripturl . '?action=profile;area=activities;sa=settings;save;u=' . $memID;
    $context['page_title'] = $txt['showActivities'] . ' - ' . $user_profile[$memID]['real_name'];
    $context[$context['profile_menu_name']]['tab_data'] = array('title' => $txt['showActivitiesSettings'], 'description' => $txt['showActivitiesSettings_desc'], 'tabs' => array());
    $result = smf_db_query('SELECT * FROM {db_prefix}activity_types ORDER BY id_type ASC');
    if ($user_info['id'] == $memID) {
        $my_act_optout = empty($user_info['act_optout']) ? array(0) : explode(',', $user_info['act_optout']);
        $my_notify_optout = empty($user_info['notify_optout']) ? array(0) : explode(',', $user_info['notify_optout']);
    } else {
        loadMemberData($memID, false, 'minimal');
        $my_act_optout = empty($user_profile[$memID]['act_optout']) ? array(0) : explode(',', $user_profile[$memID]['act_optout']);
        $my_notify_optout = empty($user_profile[$memID]['notify_optout']) ? array(0) : explode(',', $user_profile[$memID]['notify_optout']);
    }
    $context['activity_types'] = array();
    while ($row = mysql_fetch_assoc($result)) {
        $context['activity_types'][] = array('id' => $row['id_type'], 'shortdesc' => $row['id_desc'], 'longdesc_act' => $txt['actdesc_' . trim($row['id_desc'])], 'longdesc_not' => isset($txt['ndesc_' . trim($row['id_desc'])]) ? $txt['ndesc_' . trim($row['id_desc'])] : '', 'act_optout' => in_array($row['id_type'], $my_act_optout), 'notify_optout' => in_array($row['id_type'], $my_notify_optout));
    }
    mysql_free_result($result);
    if (isset($_GET['save'])) {
        $new_not_optout = array();
        $new_act_optout = array();
        $update_array = array();
        foreach ($context['activity_types'] as $t) {
            $_id = trim($t['id']);
            if (!empty($t['longdesc_act']) && (!isset($_REQUEST['act_check_' . $_id]) || empty($_REQUEST['act_check_' . $_id]))) {
                $new_act_optout[] = $_id;
            }
            if (!empty($t['longdesc_not']) && (!isset($_REQUEST['not_check_' . $_id]) || empty($_REQUEST['not_check_' . $_id]))) {
                $new_not_optout[] = $_id;
            }
        }
        //if(count(array_unique($new_act_optout)) > 0)
        $update_array['act_optout'] = implode(',', array_unique($new_act_optout));
        //if(count(array_unique($new_not_optout)) > 0)
        $update_array['notify_optout'] = implode(',', array_unique($new_not_optout));
        if (count($update_array)) {
            updateMemberData($memID, $update_array);
        }
        redirectexit($scripturl . '?action=profile;area=activities;sa=settings;u=' . $memID);
    }
}
示例#2
0
文件: Reports.php 项目: norv/EosAlpha
function ReportsMain()
{
    global $txt, $modSettings, $context, $scripturl;
    // Only admins, only EVER admins!
    isAllowedTo('admin_forum');
    // Let's get our things running...
    //loadTemplate('Reports');
    Eos_Smarty::setActive();
    loadLanguage('Reports');
    $context['page_title'] = $txt['generate_reports'];
    // These are the types of reports which exist - and the functions to generate them.
    $context['report_types'] = array('boards' => 'BoardReport', 'board_perms' => 'BoardPermissionsReport', 'member_groups' => 'MemberGroupsReport', 'group_perms' => 'GroupPermissionsReport', 'staff' => 'StaffReport');
    $is_first = 0;
    foreach ($context['report_types'] as $k => $temp) {
        $context['report_types'][$k] = array('id' => $k, 'title' => isset($txt['gr_type_' . $k]) ? $txt['gr_type_' . $k] : $type['id'], 'description' => isset($txt['gr_type_desc_' . $k]) ? $txt['gr_type_desc_' . $k] : null, 'function' => $temp, 'is_first' => $is_first++ == 0);
    }
    // If they haven't choosen a report type which is valid, send them off to the report type chooser!
    if (empty($_REQUEST['rt']) || !isset($context['report_types'][$_REQUEST['rt']])) {
        $context['sub_template'] = 'report_type';
        Eos_Smarty::loadTemplate('reports/base');
        Eos_Smarty::getConfigInstance()->registerHookTemplate('reports_content_area', 'reports/choose_type');
        return;
    }
    $context['report_type'] = $_REQUEST['rt'];
    $context['report_buttons'] = array('generate_reports' => array('text' => 'generate_reports', 'image' => 'print.gif', 'lang' => true, 'url' => $scripturl . '?action=admin;area=reports', 'active' => true), 'print' => array('text' => 'print', 'image' => 'print.gif', 'lang' => true, 'url' => $scripturl . '?action=admin;area=reports;rt=' . $context['report_type'] . ';st=print', 'custom' => 'target="_blank"'));
    // What are valid templates for showing reports?
    $reportTemplates = array('main' => array('layers' => null), 'print' => array('layers' => array('print')));
    // Specific template? Use that instead of main!
    if (isset($_REQUEST['st']) && isset($reportTemplates[$_REQUEST['st']])) {
        // Are we disabling the other layers - print friendly for example?
        if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) {
            Eos_Smarty::loadTemplate('reports/print');
            $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers'];
        }
    } else {
        Eos_Smarty::loadTemplate('reports/base');
        Eos_Smarty::getConfigInstance()->registerHookTemplate('reports_content_area', 'reports/main');
    }
    // Make the page title more descriptive.
    $context['page_title'] .= ' - ' . (isset($txt['gr_type_' . $context['report_type']]) ? $txt['gr_type_' . $context['report_type']] : $context['report_type']);
    // Now generate the data.
    $context['report_types'][$context['report_type']]['function']();
    // Finish the tables before exiting - this is to help the templates a little more.
    finishTables();
}