当前位置: 首页>>代码示例>>PHP>>正文


PHP Members::toggle方法代码示例

本文整理汇总了PHP中Members::toggle方法的典型用法代码示例。如果您正苦于以下问题:PHP Members::toggle方法的具体用法?PHP Members::toggle怎么用?PHP Members::toggle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Members的用法示例。


在下文中一共展示了Members::toggle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: elseif

    Logger::error(i18n::s('No item has been found.'));
    // permission denied
} elseif (!$permitted) {
    // anonymous users are invited to log in or to register
    if (!Surfer::is_logged()) {
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Categories::get_url($member, 'select')));
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // build a form to associates some categories to this item
} else {
    // actual update
    if (isset($_REQUEST['anchor']) && isset($_REQUEST['member'])) {
        // on error display the form again
        if ($error = Members::toggle($_REQUEST['anchor'], $_REQUEST['member'], isset($_REQUEST['father']) ? $_REQUEST['father'] : '')) {
            Logger::error($error);
        }
    }
    // the current list of linked categories
    $categories =& Members::list_categories_by_title_for_member($member, 0, CATEGORIES_LIST_SIZE, 'raw');
    // the form to link additional categories
    if (!is_array($categories) || count($categories) < CATEGORIES_LIST_SIZE) {
        $context['text'] .= '<form method="post" action="' . $context['script_url'] . '"><div style="margin-bottom: 2em;">' . i18n::s('Select a category') . ' <select name="anchor">' . Categories::get_options($categories) . '</select>' . ' ' . Skin::build_submit_button(i18n::s('Categorize')) . '<input type="hidden" name="member" value="' . encode_field($member) . '">' . '</div></form>' . "\n";
    }
    // the current list of linked categories
    if (count($categories)) {
        // display attached categories with unlink buttons
        $context['text'] .= '<p>' . i18n::s('All categories that have been associated to this page:') . '</p>';
        // browse the list
        foreach ($categories as $category_id => $attributes) {
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:select.php

示例2: elseif

}
// the title of the page
$context['page_title'] = i18n::s('Watch list');
// not found
if (!$item['id']) {
    include '../error.php';
    // operation is restricted to logged users
} elseif (!Surfer::get_id()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // you cannot watch yourself
} elseif ($track == 'user:' . Surfer::get_id()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // toggle membership status
} elseif ($error = Members::toggle($track, 'user:' . Surfer::get_id())) {
    Logger::error($error);
    // post-processing tasks
} else {
    // successful operation reflected into page title
    if (!strncmp($track, 'user:', 5)) {
        $context['page_title'] = i18n::s('The list of persons that you follow has been updated');
    } else {
        $context['page_title'] = i18n::s('Your watch list has been updated');
    }
    // follow-up commands
    $menu = array();
    if (is_object($anchor) && $anchor->is_viewable()) {
        $menu[] = Skin::build_link($anchor->get_url(), i18n::s('Done'), 'button');
    }
    // the page now appears in the watch list
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:track.php


注:本文中的Members::toggle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。