本文整理汇总了PHP中AphrontDialogView::setUser方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontDialogView::setUser方法的具体用法?PHP AphrontDialogView::setUser怎么用?PHP AphrontDialogView::setUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AphrontDialogView
的用法示例。
在下文中一共展示了AphrontDialogView::setUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processRequest
public function processRequest()
{
$phid = $this->getClientPHID();
$title = 'Delete OAuth Client';
$request = $this->getRequest();
$current_user = $request->getUser();
$client = id(new PhabricatorOAuthServerClient())->loadOneWhere('phid = %s', $phid);
if (empty($client)) {
return new Aphront404Response();
}
if ($client->getCreatorPHID() != $current_user->getPHID()) {
$message = 'Access denied to client with phid ' . $phid . '. ' . 'Only the user who created the client has permission to ' . 'delete the client.';
return id(new Aphront403Response())->setForbiddenText($message);
}
if ($request->isFormPost()) {
$client->delete();
return id(new AphrontRedirectResponse())->setURI('/oauthserver/client/?deleted=1');
}
$client_name = phutil_escape_html($client->getName());
$title .= ' ' . $client_name;
$dialog = new AphrontDialogView();
$dialog->setUser($current_user);
$dialog->setTitle($title);
$dialog->appendChild('<p>Are you sure you want to delete this client?</p>');
$dialog->addSubmitButton();
$dialog->addCancelButton($client->getEditURI());
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例2: processRequest
public function processRequest()
{
$request = $this->getRequest();
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$user = $request->getUser();
$question_id = $request->getInt('question_id');
$question = PonderQuestionQuery::loadSingle($user, $question_id);
if (!$question) {
return new Aphront404Response();
}
$target = $request->getStr('target');
$objects = id(new PhabricatorObjectHandleData(array($target)))->loadHandles();
if (!$objects) {
return new Aphront404Response();
}
$content = $request->getStr('content');
if (!strlen(trim($content))) {
$dialog = new AphrontDialogView();
$dialog->setUser($request->getUser());
$dialog->setTitle('Empty comment');
$dialog->appendChild('<p>Your comment must not be empty.</p>');
$dialog->addCancelButton('/Q' . $question_id);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$res = new PonderComment();
$res->setContent($content)->setAuthorPHID($user->getPHID())->setTargetPHID($target);
id(new PonderCommentEditor())->setQuestion($question)->setComment($res)->setTargetPHID($target)->setUser($user)->save();
return id(new AphrontRedirectResponse())->setURI(id(new PhutilURI('/Q' . $question->getID())));
}
示例3: processRequest
public function processRequest()
{
$rule = id(new HeraldRule())->load($this->id);
if (!$rule) {
return new Aphront404Response();
}
$request = $this->getRequest();
$user = $request->getUser();
// Anyone can delete a global rule, but only the rule owner can delete a
// personal one.
if ($rule->getRuleType() == HeraldRuleTypeConfig::RULE_TYPE_PERSONAL) {
if ($user->getPHID() != $rule->getAuthorPHID()) {
return new Aphront400Response();
}
}
if ($request->isFormPost()) {
$rule->openTransaction();
$rule->logEdit($user->getPHID(), 'delete');
$rule->delete();
$rule->saveTransaction();
return id(new AphrontReloadResponse())->setURI('/herald/');
}
$dialog = new AphrontDialogView();
$dialog->setUser($request->getUser());
$dialog->setTitle('Really delete this rule?');
$dialog->appendChild("Are you sure you want to delete the rule " . "'<strong>" . phutil_escape_html($rule->getName()) . "</strong>'?");
$dialog->addSubmitButton('Delete');
$dialog->addCancelButton('/herald/');
$dialog->setSubmitURI($request->getPath());
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例4: renderExample
public function renderExample()
{
$request = $this->getRequest();
$user = $request->getUser();
$notices = array();
if ($request->isFormPost()) {
$notices[] = 'You just submitted a valid form POST.';
}
if ($request->isJavelinWorkflow()) {
$notices[] = 'You just submitted a Workflow request.';
}
if ($notices) {
$notices = id(new AphrontErrorView())->setSeverity(AphrontErrorView::SEVERITY_NOTICE)->setErrors($notices);
} else {
$notices = null;
}
if ($request->isJavelinWorkflow()) {
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle('Request Information');
$dialog->appendChild($notices);
$dialog->addCancelButton($request->getRequestURI(), 'Close');
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$view = new PhabricatorActionListView();
$view->setUser($user);
$view->addAction(id(new PhabricatorActionView())->setUser($user)->setHref($request->getRequestURI())->setName('Normal Action')->setIcon('file'));
$view->addAction(id(new PhabricatorActionView())->setUser($user)->setHref($request->getRequestURI())->setDisabled(true)->setName('Disabled Action')->setIcon('file'));
$view->addAction(id(new PhabricatorActionView())->setUser($user)->setHref($request->getRequestURI())->setRenderAsForm(true)->setName('Form Action')->setIcon('file'));
$view->addAction(id(new PhabricatorActionView())->setUser($user)->setHref($request->getRequestURI())->setRenderAsForm(true)->setDisabled(true)->setName('Disabled Form Action')->setIcon('file'));
$view->addAction(id(new PhabricatorActionView())->setUser($user)->setHref($request->getRequestURI())->setWorkflow(true)->setName('Workflow Action')->setIcon('file'));
$view->addAction(id(new PhabricatorActionView())->setUser($user)->setHref($request->getRequestURI())->setRenderAsForm(true)->setWorkflow(true)->setName('Form + Workflow Action')->setIcon('file'));
return array($view, '<div style="clear: both;"></div>', $notices);
}
示例5: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$provider = $this->provider;
if ($provider->isProviderLinkPermanent()) {
throw new Exception("You may not unlink accounts from this OAuth provider.");
}
$provider_key = $provider->getProviderKey();
$oauth_info = id(new PhabricatorUserOAuthInfo())->loadOneWhere('userID = %d AND oauthProvider = %s', $user->getID(), $provider_key);
if (!$oauth_info) {
return new Aphront400Response();
}
if (!$request->isDialogFormPost()) {
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle('Really unlink account?');
$dialog->appendChild('<p><strong>You will not be able to login</strong> using this account ' . 'once you unlink it. Continue?</p>');
$dialog->addSubmitButton('Unlink Account');
$dialog->addCancelButton('/settings/page/' . $provider_key . '/');
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$oauth_info->delete();
return id(new AphrontRedirectResponse())->setURI('/settings/page/' . $provider_key . '/');
}
示例6: processRequest
public function processRequest()
{
$request = $this->getRequest();
$chrono_key = $request->getStr('chronoKey');
$user = $request->getUser();
if ($request->isDialogFormPost()) {
$table = new PhabricatorFeedStoryNotification();
queryfx($table->establishConnection('w'), 'UPDATE %T SET hasViewed = 1 ' . 'WHERE userPHID = %s AND hasViewed = 0 and chronologicalKey <= %s', $table->getTableName(), $user->getPHID(), $chrono_key);
return id(new AphrontReloadResponse())->setURI('/notification/');
}
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->addCancelButton('/notification/');
if ($chrono_key) {
$dialog->setTitle(pht('Really mark all notifications as read?'));
$dialog->addHiddenInput('chronoKey', $chrono_key);
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
if ($is_serious) {
$dialog->appendChild(pht('All unread notifications will be marked as read. You can not ' . 'undo this action.'));
} else {
$dialog->appendChild(pht("You can't ignore your problems forever, you know."));
}
$dialog->addSubmitButton(pht('Mark All Read'));
} else {
$dialog->setTitle(pht('No notifications to mark as read.'));
$dialog->appendChild(pht('You have no unread notifications.'));
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例7: processRequest
public function processRequest()
{
$rule = id(new HeraldRule())->load($this->id);
if (!$rule) {
return new Aphront404Response();
}
$request = $this->getRequest();
$user = $request->getUser();
if ($user->getPHID() != $rule->getAuthorPHID()) {
return new Aphront400Response();
}
if ($request->isFormPost()) {
$rule->delete();
if ($request->isAjax()) {
return new AphrontRedirectResponse();
} else {
return id(new AphrontRedirectResponse())->setURI('/herald/');
}
}
$dialog = new AphrontDialogView();
$dialog->setUser($request->getUser());
$dialog->setTitle('Really delete this rule?');
$dialog->appendChild("Are you sure you want to delete the rule " . "'<strong>" . phutil_escape_html($rule->getName()) . "</strong>'?");
$dialog->addSubmitButton('Delete');
$dialog->addCancelButton('/herald/');
$dialog->setSubmitURI($request->getPath());
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例8: processRequest
public function processRequest()
{
$request = $this->getRequest();
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$user = $request->getUser();
$question_id = $request->getInt('question_id');
$question = PonderQuestionQuery::loadSingle($user, $question_id);
if (!$question) {
return new Aphront404Response();
}
$answer = $request->getStr('answer');
// Only want answers with some non whitespace content
if (!strlen(trim($answer))) {
$dialog = new AphrontDialogView();
$dialog->setUser($request->getUser());
$dialog->setTitle('Empty answer');
$dialog->appendChild('<p>Your answer must not be empty.</p>');
$dialog->addCancelButton('/Q' . $question_id);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_WEB, array('ip' => $request->getRemoteAddr()));
$res = new PonderAnswer();
$res->setContent($answer)->setAuthorPHID($user->getPHID())->setVoteCount(0)->setQuestionID($question_id)->setContentSource($content_source);
id(new PonderAnswerEditor())->setUser($user)->setQuestion($question)->setAnswer($res)->saveAnswer();
return id(new AphrontRedirectResponse())->setURI(id(new PhutilURI('/Q' . $question->getID())));
}
示例9: buildResponseString
public function buildResponseString()
{
if ($this->shouldStopForDebugging()) {
$request = $this->getRequest();
$viewer = $request->getUser();
$view = new PhabricatorStandardPageView();
$view->setRequest($this->getRequest());
$view->setApplicationName(pht('Debug'));
$view->setTitle(pht('Stopped on Redirect'));
$dialog = new AphrontDialogView();
$dialog->setUser($viewer);
$dialog->setTitle(pht('Stopped on Redirect'));
$dialog->appendParagraph(pht('You were stopped here because %s is set in your configuration.', phutil_tag('tt', array(), 'debug.stop-on-redirect')));
$dialog->appendParagraph(pht('You are being redirected to: %s', phutil_tag('tt', array(), $this->getURI())));
$dialog->addCancelButton($this->getURI(), pht('Continue'));
$dialog->appendChild(phutil_tag('br'));
$dialog->appendChild(id(new AphrontStackTraceView())->setUser($viewer)->setTrace($this->stackWhenCreated));
$dialog->setIsStandalone(true);
$dialog->setWidth(AphrontDialogView::WIDTH_FULL);
$box = id(new PHUIBoxView())->addMargin(PHUI::MARGIN_LARGE)->appendChild($dialog);
$view->appendChild($box);
return $view->render();
}
return '';
}
示例10: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$capabilities = array(PhabricatorPolicyCapability::CAN_VIEW);
$process_action = false;
switch ($this->action) {
case 'join':
$capabilities[] = PhabricatorPolicyCapability::CAN_JOIN;
$process_action = $request->isFormPost();
break;
case 'leave':
$process_action = $request->isDialogFormPost();
break;
default:
return new Aphront404Response();
}
$project = id(new PhabricatorProjectQuery())->setViewer($user)->withIDs(array($this->id))->needMembers(true)->requireCapabilities($capabilities)->executeOne();
if (!$project) {
return new Aphront404Response();
}
$project_uri = '/project/view/' . $project->getID() . '/';
if ($process_action) {
$edge_action = null;
switch ($this->action) {
case 'join':
$edge_action = '+';
break;
case 'leave':
$edge_action = '-';
break;
}
$type_member = PhabricatorEdgeConfig::TYPE_PROJ_MEMBER;
$member_spec = array($edge_action => array($user->getPHID() => $user->getPHID()));
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $type_member)->setNewValue($member_spec);
$editor = id(new PhabricatorProjectTransactionEditor($project))->setActor($user)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($project, $xactions);
return id(new AphrontRedirectResponse())->setURI($project_uri);
}
$dialog = null;
switch ($this->action) {
case 'leave':
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle(pht('Really leave project?'));
$dialog->appendChild(phutil_tag('p', array(), pht('Your tremendous contributions to this project will be sorely ' . 'missed. Are you sure you want to leave?')));
$dialog->addCancelButton($project_uri);
$dialog->addSubmitButton(pht('Leave Project'));
break;
default:
return new Aphront404Response();
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例11: processRequest
public function processRequest()
{
$arc_project = id(new PhabricatorRepositoryArcanistProject())->load($this->id);
if (!$arc_project) {
return new Aphront404Response();
}
$request = $this->getRequest();
if ($request->isDialogFormPost()) {
$arc_project->delete();
return id(new AphrontRedirectResponse())->setURI('/repository/');
}
$dialog = new AphrontDialogView();
$dialog->setUser($request->getUser())->setTitle('Really delete this arcanist project?')->appendChild(hsprintf('<p>Really delete the "%s" arcanist project? ' . 'This operation can not be undone.</p>', $arc_project->getName()))->setSubmitURI('/repository/project/delete/' . $this->id . '/')->addSubmitButton('Delete Arcanist Project')->addCancelButton('/repository/');
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例12: processRequest
public function processRequest()
{
$macro = id(new PhabricatorFileImageMacro())->load($this->id);
if (!$macro) {
return new Aphront404Response();
}
$request = $this->getRequest();
if ($request->isDialogFormPost()) {
$macro->delete();
return id(new AphrontRedirectResponse())->setURI('/file/macro/');
}
$dialog = new AphrontDialogView();
$dialog->setUser($request->getUser())->setTitle('Really delete macro?')->appendChild('<p>Really delete the much-beloved image macro "' . phutil_escape_html($macro->getName()) . '"? It will be sorely missed.' . '</p>')->setSubmitURI('/file/macro/delete/' . $this->id . '/')->addSubmitButton('Delete')->addCancelButton('/file/macro/');
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例13: processRequest
public function processRequest()
{
$repository = id(new PhabricatorRepository())->load($this->id);
if (!$repository) {
return new Aphront404Response();
}
$request = $this->getRequest();
if ($request->isDialogFormPost()) {
$repository->delete();
return id(new AphrontRedirectResponse())->setURI('/repository/');
}
$dialog = new AphrontDialogView();
$dialog->setUser($request->getUser())->setTitle('Really delete repository?')->appendChild('<p>Really delete the "' . phutil_escape_html($repository->getName()) . '" (' . phutil_escape_html($repository->getCallsign()) . ') repository? ' . 'This operation can not be undone.</p>')->setSubmitURI('/repository/delete/' . $this->id . '/')->addSubmitButton('Delete Repository')->addCancelButton('/repository/');
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例14: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$capabilities = array(PhabricatorPolicyCapability::CAN_VIEW);
$process_action = false;
switch ($this->action) {
case 'join':
$capabilities[] = PhabricatorPolicyCapability::CAN_JOIN;
$process_action = $request->isFormPost();
break;
case 'leave':
$process_action = $request->isDialogFormPost();
break;
default:
return new Aphront404Response();
}
$project = id(new PhabricatorProjectQuery())->setViewer($user)->withIDs(array($this->id))->needMembers(true)->requireCapabilities($capabilities)->executeOne();
if (!$project) {
return new Aphront404Response();
}
$project_uri = '/project/view/' . $project->getID() . '/';
if ($process_action) {
switch ($this->action) {
case 'join':
PhabricatorProjectEditor::applyJoinProject($project, $user);
break;
case 'leave':
PhabricatorProjectEditor::applyLeaveProject($project, $user);
break;
}
return id(new AphrontRedirectResponse())->setURI($project_uri);
}
$dialog = null;
switch ($this->action) {
case 'leave':
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle('Really leave project?');
$dialog->appendChild('<p>Your tremendous contributions to this project will be sorely ' . 'missed. Are you sure you want to leave?</p>');
$dialog->addCancelButton($project_uri);
$dialog->addSubmitButton('Leave Project');
break;
default:
return new Aphront404Response();
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例15: processRequest
public function processRequest()
{
$request = $this->getRequest();
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$revision_id = $request->getInt('revision_id');
$revision = id(new DifferentialRevision())->load($revision_id);
if (!$revision) {
return new Aphront400Response();
}
$comment = $request->getStr('comment');
$action = $request->getStr('action');
$reviewers = $request->getArr('reviewers');
$ccs = $request->getArr('ccs');
$editor = new DifferentialCommentEditor($revision, $request->getUser()->getPHID(), $action);
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_WEB, array('ip' => $request->getRemoteAddr()));
try {
$editor->setMessage($comment)->setContentSource($content_source)->setAttachInlineComments(true)->setAddedReviewers($reviewers)->setAddedCCs($ccs)->save();
} catch (DifferentialActionHasNoEffectException $no_effect) {
$has_inlines = id(new DifferentialInlineComment())->loadAllWhere('authorPHID = %s AND revisionID = %d AND commentID IS NULL', $request->getUser()->getPHID(), $revision->getID());
$dialog = new AphrontDialogView();
$dialog->setUser($request->getUser());
$dialog->addCancelButton('/D' . $revision_id);
$dialog->addHiddenInput('revision_id', $revision_id);
$dialog->addHiddenInput('action', 'none');
$dialog->addHiddenInput('reviewers', $reviewers);
$dialog->addHiddenInput('ccs', $ccs);
$dialog->addHiddenInput('comment', $comment);
$dialog->setTitle('Action Has No Effect');
$dialog->appendChild('<p>' . phutil_escape_html($no_effect->getMessage()) . '</p>');
if (strlen($comment) || $has_inlines) {
$dialog->addSubmitButton('Post as Comment');
$dialog->appendChild('<br />');
$dialog->appendChild('<p>Do you want to post your feedback anyway, as a normal ' . 'comment?</p>');
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
// TODO: Diff change detection?
$draft = id(new PhabricatorDraft())->loadOneWhere('authorPHID = %s AND draftKey = %s', $request->getUser()->getPHID(), 'differential-comment-' . $revision->getID());
if ($draft) {
$draft->delete();
}
return id(new AphrontRedirectResponse())->setURI('/D' . $revision->getID());
}