コード例 #1
0
    /**
     * View all the users subscribed to a particular subscription.
     *
     * - Requires the admin_forum permission.
     * - Accessed from ?action=admin;area=paidsubscribe;sa=viewsub.
     * - Subscription ID is required, in the form of $_GET['sid'].
     */
    public function action_viewsub()
    {
        global $context, $txt, $scripturl;
        require_once SUBSDIR . '/PaidSubscriptions.subs.php';
        // Setup the template.
        $context['page_title'] = $txt['viewing_users_subscribed'];
        // ID of the subscription.
        $context['sub_id'] = (int) $_REQUEST['sid'];
        // Load the subscription information.
        $context['subscription'] = getSubscriptionDetails($context['sub_id']);
        // Are we searching for people?
        $search_string = isset($_POST['ssearch']) && !empty($_POST['sub_search']) ? ' AND IFNULL(mem.real_name, {string:guest}) LIKE {string:search}' : '';
        $search_vars = empty($_POST['sub_search']) ? array() : array('search' => '%' . $_POST['sub_search'] . '%', 'guest' => $txt['guest']);
        $listOptions = array('id' => 'subscribed_users_list', 'title' => sprintf($txt['view_users_subscribed'], $context['subscription']['name']), 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id'], 'default_sort_col' => 'name', 'get_items' => array('function' => array($this, 'getSubscribedUsers'), 'params' => array($context['sub_id'], $search_string, $search_vars)), 'get_count' => array('function' => array($this, 'getSubscribedUserCount'), 'params' => array($context['sub_id'], $search_string, $search_vars)), 'no_items_label' => $txt['no_subscribers'], 'columns' => array('name' => array('header' => array('value' => $txt['who_member'], 'style' => 'width: 20%;'), 'data' => array('function' => create_function('$rowData', '
							global $txt, $scripturl;

							return $rowData[\'id_member\'] == 0 ? $txt[\'guest\'] : \'<a href="\' . $scripturl . \'?action=profile;u=\' . $rowData[\'id_member\'] . \'">\' . $rowData[\'name\'] . \'</a>\';
						')), 'sort' => array('default' => 'name', 'reverse' => 'name DESC')), 'status' => array('header' => array('value' => $txt['paid_status'], 'style' => 'width: 10%;'), 'data' => array('db_htmlsafe' => 'status_text'), 'sort' => array('default' => 'status', 'reverse' => 'status DESC')), 'payments_pending' => array('header' => array('value' => $txt['paid_payments_pending'], 'style' => 'width: 15%;'), 'data' => array('db_htmlsafe' => 'pending'), 'sort' => array('default' => 'payments_pending', 'reverse' => 'payments_pending DESC')), 'start_time' => array('header' => array('value' => $txt['start_date'], 'style' => 'width: 20%;'), 'data' => array('db_htmlsafe' => 'start_date', 'class' => 'smalltext'), 'sort' => array('default' => 'start_time', 'reverse' => 'start_time DESC')), 'end_time' => array('header' => array('value' => $txt['end_date'], 'style' => 'width: 20%;'), 'data' => array('db_htmlsafe' => 'end_date', 'class' => 'smalltext'), 'sort' => array('default' => 'end_time', 'reverse' => 'end_time DESC')), 'modify' => array('header' => array('style' => 'width: 10%;', 'class' => 'nowrap', 'value' => $txt['edit_subscriber']), 'data' => array('function' => create_function('$rowData', '
							global $txt, $scripturl;

							return \'<a href="\' . $scripturl . \'?action=admin;area=paidsubscribe;sa=modifyuser;lid=\' . $rowData[\'id\'] . \'">\' . $txt[\'modify\'] . \'</a>\';
						'), 'class' => 'centertext')), 'delete' => array('header' => array('style' => 'width: 4%;', 'class' => 'centertext'), 'data' => array('function' => create_function('$rowData', '
							return \'<input type="checkbox" name="delsub[\' . $rowData[\'id\'] . \']" class="input_check" />\';
						'), 'class' => 'centertext'))), 'form' => array('href' => $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;sid=' . $context['sub_id']), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '
						<input type="submit" name="add" value="' . $txt['add_subscriber'] . '" class="right_submit" />
						<input type="submit" name="finished" value="' . $txt['complete_selected'] . '" onclick="return confirm(\'' . $txt['complete_are_sure'] . '\');" class="right_submit" />
						<input type="submit" name="delete" value="' . $txt['delete_selected'] . '" onclick="return confirm(\'' . $txt['delete_are_sure'] . '\');" class="right_submit" />
					'), array('position' => 'top_of_list', 'value' => '
						<div class="flow_auto">
							<input type="submit" name="ssearch" value="' . $txt['search_sub'] . '" class="right_submit" />
							<input type="text" name="sub_search" value="" class="input_text floatright" />
						</div>
					')));
        require_once SUBSDIR . '/GenericList.class.php';
        createList($listOptions);
        $context['sub_template'] = 'show_list';
        $context['default_list'] = 'subscribed_users_list';
    }
コード例 #2
0
/**
 * Removes a subscription from the system
 * Updates members group subscriptions for members whose group associations
 * were related to the subscription
 *
 * @param int $id
 */
function deleteSubscription($id)
{
    $db = database();
    // Removing it, first lets see if anyone is subscribed
    $members = loadAllSubsctiptions($id);
    if (!empty($members)) {
        $changes = array();
        // Get the specifics of this subscription
        $sub_detail = getSubscriptionDetails($id);
        // Do we need to reset the primary group?
        if (!empty($sub_detail['prim_group'])) {
            // If this subscription changed the primary group, change it back
            foreach ($members as $id_member => $member_data) {
                if ($member_data['old_id_group'] != $member_data['id_group'] && $member_data['id_group'] == $sub_detail['prim_group']) {
                    $changes[$id_member]['id_group'] = $member_data['old_id_group'];
                }
            }
        }
        // Did the subscription add secondary groups that we now must remove?
        if (!empty($sub_detail['add_groups'])) {
            foreach ($members as $id_member => $member_data) {
                $current_groups = explode(',', $member_data['additional_groups']);
                $non_sub_groups = array_diff($current_groups, $sub_detail['add_groups']);
                // If they have any of the subscription groups, remove them
                if (implode(',', $non_sub_groups) != $member_data['additional_groups']) {
                    $changes[$id_member]['additional_groups'] = $non_sub_groups;
                }
            }
        }
        // Apply the group changes, if there are any
        if (!empty($changes)) {
            foreach ($changes as $id_member => $new_values) {
                updateMemberData($id_member, $new_values);
            }
        }
    }
    // Remove the subscription as well
    $db->query('', '
		DELETE FROM {db_prefix}subscriptions
		WHERE id_subscribe = {int:current_subscription}', array('current_subscription' => $id));
}