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


PHP UrlManager::getForAjaxProjectRemoveUser方法代码示例

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


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

示例1: project_addUser

    public static function project_addUser()
    {
        SystemEvent::raise(SystemEvent::DEBUG, "Called.", __METHOD__);
        if (!isset($GLOBALS['project']) || !$GLOBALS['project'] instanceof Project) {
            $msg = 'Invalid request';
            SystemEvent::raise(SystemEvent::INFO, $msg, __METHOD__);
            echo json_encode(array('success' => false, 'error' => $msg));
            exit;
        }
        if (!$GLOBALS['project']->userHasAccessLevel($GLOBALS['user'], Access::WRITE) && !$GLOBALS['user']->hasCos(UserCos::ROOT)) {
            SystemEvent::raise(SystemEvent::INFO, "Not authorized. [USER={$GLOBALS['user']->getUsername()}]", __METHOD__);
            echo json_encode(array('success' => false, 'error' => 'Not authorized'));
            exit;
        }
        $user = User::getByUsername($_GET['username']);
        if (!$user instanceof User) {
            SystemEvent::raise(SystemEvent::INFO, "Username not found. [USERNAME={$_GET['username']}]", __METHOD__);
            echo json_encode(array('success' => false, 'error' => 'Not found'));
            exit;
        }
        $GLOBALS['project']->addToUsers($user);
        $accessLevels = Access::getList();
        $html = <<<EOT
            <li id="{$user->getUsername()}">
              <div class="avatar40"><img src="{$user->getAvatarUrl()}" width="40" height="40"></div>
              <div class="username"><h3>{$user->getUsername()}</h3></div>
              <div class="actionItems">
EOT;
        if (!$GLOBALS['project']->userHasAccessLevel($user, Access::OWNER)) {
            $removeLink = UrlManager::getForAjaxProjectRemoveUser($user->getUsername());
            $html .= <<<EOT
                <div class="remove"><a class="{$user->getUsername()} btn danger" href="{$removeLink}">Remove</a></div>
                <div class="access"><a class="{$user->getUsername()} btn" href="#">Access</a></div>
                <div class="popover-wrapper">
                  <div id="accessLevelPaneLevels_{$user->getUsername()}" class="accessLevelPopover popover above">
                    <div class="arrow"></div>
                    <div class="inner">
                      <h3 class="title">Access level</h3>
                      <div class="content">
                        <ul class="inputs-list">
EOT;
            foreach ($accessLevels as $accessLevel => $accessName) {
                if ($accessLevel !== 0) {
                    $checked = '';
                    if ($GLOBALS['project']->getAccessLevelFromUser($user) == $accessLevel) {
                        $checked = ' checked';
                    }
                    $accessName = ucfirst($accessName);
                    $html .= <<<EOT
                          <li>
                            <input type="radio" value="{$user->getUsername()}_{$accessLevel}" name="accessLevel_{$user->getUsername()}" id="{$accessLevel}"{$checked} />
                            <span>{$accessName}</span>
                          </li>
EOT;
                }
            }
            $html .= "\n                        </ul>\n                      </div>\n                    </div>\n                  </div>\n                </div>";
        } else {
            $html .= '
                <div class="noChanges">Owner (no changes allowed)</div>';
        }
        $html .= "\n              </div>\n            </li>";
        echo json_encode(array('success' => true, 'html' => $html));
        exit;
    }
开发者ID:rasismeiro,项目名称:cintient,代码行数:65,代码来源:AjaxManager.php


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