本文整理汇总了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;
}