本文整理汇总了PHP中AphrontFormView::setUser方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontFormView::setUser方法的具体用法?PHP AphrontFormView::setUser怎么用?PHP AphrontFormView::setUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AphrontFormView
的用法示例。
在下文中一共展示了AphrontFormView::setUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render()
{
$question = $this->question;
$viewer = $this->user;
$authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
if (isset($authors[$viewer->getPHID()])) {
$view = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setTitle(pht('Already Answered'))->appendChild(pht('You have already answered this question. You can not answer ' . 'twice, but you can edit your existing answer.'));
return phutil_tag_div('ponder-add-answer-view', $view);
}
$info_panel = null;
if ($question->getStatus() != PonderQuestionStatus::STATUS_OPEN) {
$info_panel = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->appendChild(pht('This question has been marked as closed,
but you can still leave a new answer.'));
}
$box_style = null;
$header = id(new PHUIHeaderView())->setHeader(pht('New Answer'))->addClass('ponder-add-answer-header');
$form = new AphrontFormView();
$form->setUser($this->user)->setAction($this->actionURI)->setWorkflow(true)->addHiddenInput('question_id', $question->getID())->appendChild(id(new PhabricatorRemarkupControl())->setName('answer')->setLabel(pht('Answer'))->setError(true)->setID('answer-content')->setUser($this->user))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Add Answer')));
if (!$viewer->isLoggedIn()) {
$login_href = id(new PhutilURI('/auth/start/'))->setQueryParam('next', '/Q' . $question->getID());
$form = id(new PHUIFormLayoutView())->addClass('login-to-participate')->appendChild(id(new PHUIButtonView())->setTag('a')->setText(pht('Login to Answer'))->setHref((string) $login_href));
}
$box = id(new PHUIObjectBoxView())->appendChild($form)->setHeaderText('Answer')->addClass('ponder-add-answer-view');
if ($info_panel) {
$box->setInfoView($info_panel);
}
return array($header, $box);
}
示例2: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
if ($request->isFormPost()) {
$receiver = PhabricatorMetaMTAReceivedMail::loadReceiverObject($request->getStr('obj'));
if (!$receiver) {
throw new Exception("No such task or revision!");
}
$hash = PhabricatorMetaMTAReceivedMail::computeMailHash($receiver->getMailKey(), $user->getPHID());
$received = new PhabricatorMetaMTAReceivedMail();
$received->setHeaders(array('to' => $request->getStr('obj') . '+' . $user->getID() . '+' . $hash . '@'));
$received->setBodies(array('text' => $request->getStr('body')));
$received->save();
$received->processReceivedMail();
$phid = $receiver->getPHID();
$handles = $this->loadViewerHandles(array($phid));
$uri = $handles[$phid]->getURI();
return id(new AphrontRedirectResponse())->setURI($uri);
}
$form = new AphrontFormView();
$form->setUser($request->getUser());
$form->setAction($this->getApplicationURI('/receive/'));
$form->appendChild('<p class="aphront-form-instructions">This form will simulate ' . 'sending mail to an object.</p>')->appendChild(id(new AphrontFormTextControl())->setLabel('To')->setName('obj')->setCaption('e.g. <tt>D1234</tt> or <tt>T1234</tt>'))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Body')->setName('body'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Receive Mail'));
$panel = new AphrontPanelView();
$panel->setHeader('Receive Email');
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$nav = $this->buildSideNavView();
$nav->selectFilter('receive');
$nav->appendChild($panel);
return $this->buildApplicationPage($nav, array('title' => 'Receive Test'));
}
示例3: processRequest
public function processRequest(AphrontRequest $request)
{
$user = $request->getUser();
$ldap_info = id(new PhabricatorUserLDAPInfo())->loadOneWhere('userID = %d', $user->getID());
$forms = array();
if (!$ldap_info) {
$unlink = 'Link LDAP Account';
$unlink_form = new AphrontFormView();
$unlink_form->setUser($user)->setAction('/ldap/login/')->appendChild('<p class="aphront-form-instructions">There is currently no ' . 'LDAP account linked to your Phabricator account. You can link an ' . 'account, which will allow you to use it to log into Phabricator</p>')->appendChild(id(new AphrontFormTextControl())->setLabel('LDAP username')->setName('username'))->appendChild(id(new AphrontFormPasswordControl())->setLabel('Password')->setName('password'))->appendChild(id(new AphrontFormSubmitControl())->setValue("Link LDAP Account »"));
$forms['Link Account'] = $unlink_form;
} else {
$unlink = 'Unlink LDAP Account';
$unlink_form = new AphrontFormView();
$unlink_form->setUser($user)->appendChild('<p class="aphront-form-instructions">You may unlink this account ' . 'from your LDAP account. This will prevent you from logging in with ' . 'your LDAP credentials.</p>')->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/ldap/unlink/', $unlink));
$forms['Unlink Account'] = $unlink_form;
}
$panel = new AphrontPanelView();
$panel->setHeader('LDAP Account Settings');
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
foreach ($forms as $name => $form) {
if ($name) {
$panel->appendChild('<br /><h1>' . $name . '</h1><br />');
}
$panel->appendChild($form);
}
return array($panel);
}
示例4: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$editable = $this->getAccountEditable();
// There's no sense in showing a change password panel if the user
// can't change their password
if (!$editable || !PhabricatorEnv::getEnvConfig('auth.password-auth-enabled')) {
return new Aphront400Response();
}
$errors = array();
if ($request->isFormPost()) {
if ($user->comparePassword($request->getStr('old_pw'))) {
$pass = $request->getStr('new_pw');
$conf = $request->getStr('conf_pw');
if ($pass === $conf) {
if (strlen($pass)) {
$user->setPassword($pass);
// This write is unguarded because the CSRF token has already
// been checked in the call to $request->isFormPost() and
// the CSRF token depends on the password hash, so when it
// is changed here the CSRF token check will fail.
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$user->save();
unset($unguarded);
return id(new AphrontRedirectResponse())->setURI('/settings/page/password/?saved=true');
} else {
$errors[] = 'Your new password is too short.';
}
} else {
$errors[] = 'New password and confirmation do not match.';
}
} else {
$errors[] = 'The old password you entered is incorrect.';
}
}
$notice = null;
if (!$errors) {
if ($request->getStr('saved')) {
$notice = new AphrontErrorView();
$notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$notice->setTitle('Changes Saved');
$notice->appendChild('<p>Your password has been updated.</p>');
}
} else {
$notice = new AphrontErrorView();
$notice->setTitle('Error Changing Password');
$notice->setErrors($errors);
}
$form = new AphrontFormView();
$form->setUser($user)->appendChild(id(new AphrontFormPasswordControl())->setLabel('Old Password')->setName('old_pw'));
$form->appendChild(id(new AphrontFormPasswordControl())->setLabel('New Password')->setName('new_pw'));
$form->appendChild(id(new AphrontFormPasswordControl())->setLabel('Confirm Password')->setName('conf_pw'));
$form->appendChild(id(new AphrontFormSubmitControl())->setValue('Save'));
$panel = new AphrontPanelView();
$panel->setHeader('Change Password');
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->appendChild($form);
return id(new AphrontNullView())->appendChild(array($notice, $panel));
}
示例5: processRequest
public function processRequest(AphrontRequest $request)
{
$user = $request->getUser();
$username = $user->getUsername();
$pref_time = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT;
$pref_date = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT;
$pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY;
$preferences = $user->loadPreferences();
$errors = array();
if ($request->isFormPost()) {
$new_timezone = $request->getStr('timezone');
if (in_array($new_timezone, DateTimeZone::listIdentifiers(), true)) {
$user->setTimezoneIdentifier($new_timezone);
} else {
$errors[] = pht('The selected timezone is not a valid timezone.');
}
$preferences->setPreference($pref_time, $request->getStr($pref_time))->setPreference($pref_date, $request->getStr($pref_date))->setPreference($pref_week_start, $request->getStr($pref_week_start));
if (!$errors) {
$preferences->save();
$user->save();
return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?saved=true'));
}
}
$timezone_ids = DateTimeZone::listIdentifiers();
$timezone_id_map = array_fuse($timezone_ids);
$form = new AphrontFormView();
$form->setUser($user)->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Timezone'))->setName('timezone')->setOptions($timezone_id_map)->setValue($user->getTimezoneIdentifier()))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Time-of-Day Format'))->setName($pref_time)->setOptions(array('g:i A' => pht('12-hour (2:34 PM)'), 'H:i' => pht('24-hour (14:34)')))->setCaption(pht('Format used when rendering a time of day.'))->setValue($preferences->getPreference($pref_time)))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Date Format'))->setName($pref_date)->setOptions(array('Y-m-d' => pht('ISO 8601 (2000-02-28)'), 'n/j/Y' => pht('US (2/28/2000)'), 'd-m-Y' => pht('European (28-02-2000)')))->setCaption(pht('Format used when rendering a date.'))->setValue($preferences->getPreference($pref_date)))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Week Starts On'))->setOptions($this->getWeekDays())->setName($pref_week_start)->setCaption(pht('Calendar weeks will start with this day.'))->setValue($preferences->getPreference($pref_week_start, 0)))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Account Settings')));
$form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Date and Time Settings'))->setFormSaved($request->getStr('saved'))->setFormErrors($errors)->setForm($form);
return array($form_box);
}
示例6: processRequest
public function processRequest()
{
if ($this->id) {
$macro = id(new PhabricatorFileImageMacro())->load($this->id);
if (!$macro) {
return new Aphront404Response();
}
} else {
$macro = new PhabricatorFileImageMacro();
}
$errors = array();
$e_name = true;
$request = $this->getRequest();
$user = $request->getUser();
if ($request->isFormPost()) {
$macro->setName($request->getStr('name'));
if (!strlen($macro->getName())) {
$errors[] = 'Macro name is required.';
$e_name = 'Required';
} else {
if (!preg_match('/^[a-z0-9_-]{3,}$/', $macro->getName())) {
$errors[] = 'Macro must be at least three characters long and contain ' . 'only lowercase letters, digits, hyphen and underscore.';
$e_name = 'Invalid';
} else {
$e_name = null;
}
}
if (!$errors) {
$file = PhabricatorFile::newFromPHPUpload(idx($_FILES, 'file'), array('name' => $request->getStr('name'), 'authorPHID' => $user->getPHID()));
$macro->setFilePHID($file->getPHID());
try {
$macro->save();
return id(new AphrontRedirectResponse())->setURI('/file/macro/');
} catch (AphrontQueryDuplicateKeyException $ex) {
$errors[] = 'Macro name is not unique!';
$e_name = 'Duplicate';
}
}
}
if ($errors) {
$error_view = new AphrontErrorView();
$error_view->setTitle('Form Errors');
$error_view->setErrors($errors);
} else {
$error_view = null;
}
$form = new AphrontFormView();
$form->setAction('/file/macro/edit/');
$form->setUser($request->getUser());
$form->setEncType('multipart/form-data')->appendChild(id(new AphrontFormTextControl())->setLabel('Name')->setName('name')->setValue($macro->getName())->setCaption('This word or phrase will be replaced with the image.')->setError($e_name))->appendChild(id(new AphrontFormFileControl())->setLabel('File')->setName('file')->setError(true))->appendChild(id(new AphrontFormSubmitControl())->setValue('Save Image Macro')->addCancelButton('/file/macro/'));
$panel = new AphrontPanelView();
if ($macro->getID()) {
$panel->setHeader('Edit Image Macro');
} else {
$panel->setHeader('Create Image Macro');
}
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Edit Image Macro'));
}
示例7: processRequest
public function processRequest()
{
$event = id(new PhabricatorTimelineEvent('NULL'))->load($this->id);
if (!$event) {
return new Aphront404Response();
}
$request = $this->getRequest();
$user = $request->getUser();
if ($event->getDataID()) {
$data = id(new PhabricatorTimelineEventData())->load($event->getDataID());
}
if ($data) {
$data = json_encode($data->getEventData());
} else {
$data = 'null';
}
$form = new AphrontFormView();
$form->setUser($user)->appendChild(id(new AphrontFormStaticControl())->setLabel('ID')->setValue($event->getID()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Type')->setValue($event->getType()))->appendChild(id(new AphrontFormTextAreaControl())->setDisabled(true)->setLabel('Data')->setValue($data))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/daemon/timeline/'));
$panel = new AphrontPanelView();
$panel->setHeader('Event');
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->appendChild($form);
$nav = $this->buildSideNavView();
$nav->selectFilter('timeline');
$nav->appendChild($panel);
return $this->buildApplicationPage($nav, array('title' => 'Timeline Event'));
}
示例8: processRequest
public function processRequest()
{
$request = $this->getRequest();
$phids = $request->getStrList('phids');
if ($phids) {
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
$rows = array();
foreach ($handles as $handle) {
if ($handle->getURI()) {
$link = phutil_render_tag('a', array('href' => $handle->getURI()), phutil_escape_html($handle->getURI()));
} else {
$link = null;
}
$rows[] = array(phutil_escape_html($handle->getPHID()), phutil_escape_html($handle->getType()), phutil_escape_html($handle->getName()), $link);
}
$table = new AphrontTableView($rows);
$table->setHeaders(array('PHID', 'Type', 'Name', 'URI'));
$table->setColumnClasses(array(null, null, null, 'wide'));
$panel = new AphrontPanelView();
$panel->setHeader('PHID Handles');
$panel->appendChild($table);
return $this->buildStandardPageResponse($panel, array('title' => 'PHID Lookup Results'));
}
$lookup_form = new AphrontFormView();
$lookup_form->setUser($request->getUser());
$lookup_form->setAction('/phid/')->appendChild(id(new AphrontFormTextAreaControl())->setName('phids')->setCaption('Enter PHIDs separated by spaces or commas.'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Lookup PHIDs'));
$lookup_panel = new AphrontPanelView();
$lookup_panel->setHeader('Lookup PHIDs');
$lookup_panel->appendChild($lookup_form);
$lookup_panel->setWidth(AphrontPanelView::WIDTH_WIDE);
return $this->buildStandardPageResponse(array($lookup_panel), array('title' => 'PHID Lookup'));
}
示例9: render
public function render()
{
$question = $this->question;
$viewer = $this->user;
$authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
if (isset($authors[$viewer->getPHID()])) {
return id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setTitle(pht('Already Answered'))->appendChild(pht('You have already answered this question. You can not answer ' . 'twice, but you can edit your existing answer.'));
}
$info_panel = null;
if ($question->getStatus() != PonderQuestionStatus::STATUS_OPEN) {
$info_panel = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->appendChild(pht('This question has been marked as closed,
but you can still leave a new answer.'));
}
$box_style = null;
$own_question = null;
$hide_action_id = celerity_generate_unique_node_id();
$show_action_id = celerity_generate_unique_node_id();
if ($question->getAuthorPHID() == $viewer->getPHID()) {
$box_style = 'display: none;';
$open_link = javelin_tag('a', array('sigil' => 'reveal-content', 'class' => 'mml', 'id' => $hide_action_id, 'href' => '#', 'meta' => array('showIDs' => array($show_action_id), 'hideIDs' => array($hide_action_id))), pht('Add an answer.'));
$own_question = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_WARNING)->setID($hide_action_id)->appendChild(pht('This is your own question. You are welcome to provide
an answer if you have found a resolution.'))->appendChild($open_link);
}
$header = id(new PHUIHeaderView())->setHeader(pht('Add Answer'));
$form = new AphrontFormView();
$form->setUser($this->user)->setAction($this->actionURI)->setWorkflow(true)->addHiddenInput('question_id', $question->getID())->appendChild(id(new PhabricatorRemarkupControl())->setName('answer')->setLabel(pht('Answer'))->setError(true)->setID('answer-content')->setUser($this->user))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Add Answer')));
$box = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($form);
if ($info_panel) {
$box->setInfoView($info_panel);
}
$box = phutil_tag('div', array('style' => $box_style, 'class' => 'mlt', 'id' => $show_action_id), $box);
return array($own_question, $box);
}
示例10: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$project = new PhabricatorProject();
$project->setAuthorPHID($user->getPHID());
$profile = new PhabricatorProjectProfile();
$e_name = true;
$errors = array();
if ($request->isFormPost()) {
try {
$editor = new PhabricatorProjectEditor($project);
$editor->setUser($user);
$editor->setName($request->getStr('name'));
$editor->save();
} catch (PhabricatorProjectNameCollisionException $ex) {
$e_name = 'Not Unique';
$errors[] = $ex->getMessage();
}
$project->setStatus(PhabricatorProjectStatus::ONGOING);
$profile->setBlurb($request->getStr('blurb'));
if (!$errors) {
$project->save();
$profile->setProjectPHID($project->getPHID());
$profile->save();
id(new PhabricatorProjectAffiliation())->setUserPHID($user->getPHID())->setProjectPHID($project->getPHID())->setRole('Owner')->setIsOwner(true)->save();
if ($request->isAjax()) {
return id(new AphrontAjaxResponse())->setContent(array('phid' => $project->getPHID(), 'name' => $project->getName()));
} else {
return id(new AphrontRedirectResponse())->setURI('/project/view/' . $project->getID() . '/');
}
}
}
$error_view = null;
if ($errors) {
$error_view = new AphrontErrorView();
$error_view->setTitle('Form Errors');
$error_view->setErrors($errors);
}
if ($request->isAjax()) {
$form = new AphrontFormLayoutView();
} else {
$form = new AphrontFormView();
$form->setUser($user);
}
$form->appendChild(id(new AphrontFormTextControl())->setLabel('Name')->setName('name')->setValue($project->getName())->setError($e_name))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Blurb')->setName('blurb')->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)->setValue($profile->getBlurb()));
if ($request->isAjax()) {
if ($error_view) {
$error_view->setWidth(AphrontErrorView::WIDTH_DIALOG);
}
$dialog = id(new AphrontDialogView())->setUser($user)->setWidth(AphrontDialogView::WIDTH_FORM)->setTitle('Create a New Project')->appendChild($error_view)->appendChild($form)->addSubmitButton('Create Project')->addCancelButton('/project/');
return id(new AphrontDialogResponse())->setDialog($dialog);
} else {
$form->appendChild(id(new AphrontFormSubmitControl())->setValue('Create')->addCancelButton('/project/'));
$panel = new AphrontPanelView();
$panel->setWidth(AphrontPanelView::WIDTH_FORM)->setHeader('Create a New Project')->appendChild($form);
return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Create new Project'));
}
}
示例11: render
public function render()
{
$question = $this->question;
$header = id(new PHUIHeaderView())->setHeader(pht('Add Answer'));
$form = new AphrontFormView();
$form->setUser($this->user)->setAction($this->actionURI)->setWorkflow(true)->addHiddenInput('question_id', $question->getID())->appendChild(id(new PhabricatorRemarkupControl())->setName('answer')->setLabel(pht('Answer'))->setError(true)->setID('answer-content')->setUser($this->user))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Add Answer')));
return id(new PHUIObjectBoxView())->setHeader($header)->appendChild($form);
}
示例12: renderExample
public function renderExample()
{
$filter = new AphrontListFilterView();
$form = new AphrontFormView();
$form->setUser($this->getRequest()->getUser());
$form->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Query')))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Search')));
$filter->appendChild($form);
return $filter;
}
示例13: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$e_name = true;
$e_callsign = true;
$repository = new PhabricatorRepository();
$type_map = PhabricatorRepositoryType::getAllRepositoryTypes();
$errors = array();
if ($request->isFormPost()) {
$repository->setName($request->getStr('name'));
$repository->setCallsign($request->getStr('callsign'));
$repository->setVersionControlSystem($request->getStr('type'));
if (!strlen($repository->getName())) {
$e_name = 'Required';
$errors[] = 'Repository name is required.';
} else {
$e_name = null;
}
if (!strlen($repository->getCallsign())) {
$e_callsign = 'Required';
$errors[] = 'Callsign is required.';
} else {
if (!preg_match('/^[A-Z]+$/', $repository->getCallsign())) {
$e_callsign = 'Invalid';
$errors[] = 'Callsign must be ALL UPPERCASE LETTERS.';
} else {
$e_callsign = null;
}
}
if (empty($type_map[$repository->getVersionControlSystem()])) {
$errors[] = 'Invalid version control system.';
}
if (!$errors) {
try {
$repository->save();
return id(new AphrontRedirectResponse())->setURI('/repository/edit/' . $repository->getID() . '/');
} catch (AphrontQueryDuplicateKeyException $ex) {
$e_callsign = 'Duplicate';
$errors[] = 'Callsign must be unique. Another repository already ' . 'uses that callsign.';
}
}
}
$error_view = null;
if ($errors) {
$error_view = new AphrontErrorView();
$error_view->setErrors($errors);
$error_view->setTitle('Form Errors');
}
$form = new AphrontFormView();
$form->setUser($user)->setAction('/repository/create/')->appendChild(id(new AphrontFormTextControl())->setLabel('Name')->setName('name')->setValue($repository->getName())->setError($e_name)->setCaption('Human-readable repository name.'))->appendChild('<p class="aphront-form-instructions">Select a "Callsign" — a ' . 'short, uppercase string to identify revisions in this repository. If ' . 'you choose "EX", revisions in this repository will be identified ' . 'with the prefix "rEX".</p>')->appendChild(id(new AphrontFormTextControl())->setLabel('Callsign')->setName('callsign')->setValue($repository->getCallsign())->setError($e_callsign)->setCaption('Short, UPPERCASE identifier. Once set, it can not be changed.'))->appendChild(id(new AphrontFormSelectControl())->setLabel('Type')->setName('type')->setOptions($type_map)->setValue($repository->getVersionControlSystem()))->appendChild(id(new AphrontFormSubmitControl())->setValue('Create Repository')->addCancelButton('/repository/'));
$panel = new AphrontPanelView();
$panel->setHeader('Create Repository');
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Create Repository'));
}
示例14: processRequest
public function processRequest()
{
if ($this->id) {
$item = id(new PhabricatorDirectoryItem())->load($this->id);
if (!$item) {
return new Aphront404Response();
}
} else {
$item = new PhabricatorDirectoryItem();
}
$e_name = true;
$e_href = true;
$errors = array();
$request = $this->getRequest();
if ($request->isFormPost()) {
$item->setName($request->getStr('name'));
$item->setHref($request->getStr('href'));
$item->setDescription($request->getStr('description'));
$item->setCategoryID($request->getStr('categoryID'));
$item->setSequence($request->getStr('sequence'));
if (!strlen($item->getName())) {
$errors[] = 'Item name is required.';
$e_name = 'Required';
}
if (!strlen($item->getHref())) {
$errors[] = 'Item link is required.';
$e_href = 'Required';
}
if (!$errors) {
$item->save();
return id(new AphrontRedirectResponse())->setURI('/directory/item/');
}
}
$error_view = null;
if ($errors) {
$error_view = id(new AphrontErrorView())->setTitle('Form Errors')->setErrors($errors);
}
$form = new AphrontFormView();
$form->setUser($request->getUser());
if ($item->getID()) {
$form->setAction('/directory/item/edit/' . $item->getID() . '/');
} else {
$form->setAction('/directory/item/edit/');
}
$categories = id(new PhabricatorDirectoryCategory())->loadAll();
$category_map = mpull($categories, 'getName', 'getID');
$form->appendChild(id(new AphrontFormTextControl())->setLabel('Name')->setName('name')->setValue($item->getName())->setError($e_name))->appendChild(id(new AphrontFormSelectControl())->setLabel('Category')->setName('categoryID')->setOptions($category_map)->setValue($item->getCategoryID()))->appendChild(id(new AphrontFormTextControl())->setLabel('Link')->setName('href')->setValue($item->getHref())->setError($e_href))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Description')->setName('description')->setValue($item->getDescription()))->appendChild(id(new AphrontFormTextControl())->setLabel('Order')->setName('sequence')->setCaption('Items in a category are sorted by "order", then by name.')->setValue((int) $item->getSequence()))->appendChild(id(new AphrontFormSubmitControl())->setValue('Save')->addCancelButton('/directory/item/'));
$panel = new AphrontPanelView();
if ($item->getID()) {
$panel->setHeader('Edit Directory Item');
} else {
$panel->setHeader('Create New Directory Item');
}
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Edit Directory Item'));
}
示例15: processRequest
public function processRequest()
{
$request = $this->getRequest();
if (!PhabricatorEnv::getEnvConfig('auth.password-auth-enabled')) {
return new Aphront400Response();
}
$token = $this->token;
$email = $request->getStr('email');
$target_user = id(new PhabricatorUser())->loadOneWhere('email = %s', $email);
if (!$target_user || !$target_user->validateEmailToken($token)) {
$view = new AphrontRequestFailureView();
$view->setHeader('Unable to Login');
$view->appendChild('<p>The authentication information in the link you clicked is ' . 'invalid or out of date. Make sure you are copy-and-pasting the ' . 'entire link into your browser. You can try again, or request ' . 'a new email.</p>');
$view->appendChild('<div class="aphront-failure-continue">' . '<a class="button" href="/login/email/">Send Another Email</a>' . '</div>');
return $this->buildStandardPageResponse($view, array('title' => 'Email Sent'));
}
if ($request->getUser()->getPHID() != $target_user->getPHID()) {
$session_key = $target_user->establishSession('web');
$request->setCookie('phusr', $target_user->getUsername());
$request->setCookie('phsid', $session_key);
}
$errors = array();
$e_pass = true;
$e_confirm = true;
if ($request->isFormPost()) {
$e_pass = 'Error';
$e_confirm = 'Error';
$pass = $request->getStr('password');
$confirm = $request->getStr('confirm');
if (strlen($pass) < 3) {
$errors[] = 'That password is ridiculously short.';
}
if ($pass !== $confirm) {
$errors[] = "Passwords do not match.";
}
if (!$errors) {
$target_user->setPassword($pass);
$target_user->save();
return id(new AphrontRedirectResponse())->setURI('/');
}
}
if ($errors) {
$error_view = new AphrontErrorView();
$error_view->setTitle('Password Reset Failed');
$error_view->setErrors($errors);
} else {
$error_view = null;
}
$form = new AphrontFormView();
$form->setUser($target_user)->setAction('/login/etoken/' . $token . '/')->addHiddenInput('email', $email)->appendChild(id(new AphrontFormPasswordControl())->setLabel('New Password')->setName('password')->setError($e_pass))->appendChild(id(new AphrontFormPasswordControl())->setLabel('Confirm Password')->setName('confirm')->setError($e_confirm))->appendChild(id(new AphrontFormSubmitControl())->setValue('Reset Password')->addCancelButton('/', 'Skip'));
$panel = new AphrontPanelView();
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->setHeader('Reset Password');
$panel->appendChild($form);
return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Create New Account'));
}