當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。