本文整理汇总了PHP中PhabricatorApplication类的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorApplication类的具体用法?PHP PhabricatorApplication怎么用?PHP PhabricatorApplication使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PhabricatorApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildActionView
private function buildActionView(PhabricatorUser $user, PhabricatorApplication $selected)
{
$view = id(new PhabricatorActionListView())->setUser($user)->setObjectURI($this->getRequest()->getRequestURI());
if ($selected->getHelpURI()) {
$view->addAction(id(new PhabricatorActionView())->setName(pht('Help / Documentation'))->setIcon('fa-life-ring')->setHref($selected->getHelpURI()));
}
$can_edit = PhabricatorPolicyFilter::hasCapability($user, $selected, PhabricatorPolicyCapability::CAN_EDIT);
$edit_uri = $this->getApplicationURI('edit/' . get_class($selected) . '/');
$view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Policies'))->setIcon('fa-pencil')->setDisabled(!$can_edit)->setWorkflow(!$can_edit)->setHref($edit_uri));
if ($selected->canUninstall()) {
if ($selected->isInstalled()) {
$view->addAction(id(new PhabricatorActionView())->setName(pht('Uninstall'))->setIcon('fa-times')->setDisabled(!$can_edit)->setWorkflow(true)->setHref($this->getApplicationURI(get_class($selected) . '/uninstall/')));
} else {
$action = id(new PhabricatorActionView())->setName(pht('Install'))->setIcon('fa-plus')->setDisabled(!$can_edit)->setWorkflow(true)->setHref($this->getApplicationURI(get_class($selected) . '/install/'));
$beta_enabled = PhabricatorEnv::getEnvConfig('phabricator.show-beta-applications');
if ($selected->isBeta() && !$beta_enabled) {
$action->setDisabled(true);
}
$view->addAction($action);
}
} else {
$view->addAction(id(new PhabricatorActionView())->setName(pht('Uninstall'))->setIcon('fa-times')->setWorkflow(true)->setDisabled(true)->setHref($this->getApplicationURI(get_class($selected) . '/uninstall/')));
}
return $view;
}
示例2: canAcceptApplicationMail
protected final function canAcceptApplicationMail(PhabricatorApplication $app, PhabricatorMetaMTAReceivedMail $mail)
{
$application_emails = id(new PhabricatorMetaMTAApplicationEmailQuery())->setViewer($this->getViewer())->withApplicationPHIDs(array($app->getPHID()))->execute();
foreach ($mail->getToAddresses() as $to_address) {
foreach ($application_emails as $application_email) {
$create_address = $application_email->getAddress();
if ($this->matchAddresses($create_address, $to_address)) {
$this->setApplicationEmail($application_email);
return true;
}
}
}
return false;
}
示例3: loadForRevision
public static function loadForRevision($revision)
{
$app_legalpad = 'PhabricatorLegalpadApplication';
if (!PhabricatorApplication::isClassInstalled($app_legalpad)) {
return array();
}
if (!$revision->getPHID()) {
return array();
}
$phids = PhabricatorEdgeQuery::loadDestinationPHIDs($revision->getPHID(), LegalpadObjectNeedsSignatureEdgeType::EDGECONST);
if ($phids) {
// NOTE: We're bypassing permissions to pull these. We have to expose
// some information about signature status in order to implement this
// field meaningfully (otherwise, we could not tell reviewers that they
// can't accept the revision yet), but that's OK because the only way to
// require signatures is with a "Global" Herald rule, which requires a
// high level of access.
$signatures = id(new LegalpadDocumentSignatureQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withDocumentPHIDs($phids)->withSignerPHIDs(array($revision->getAuthorPHID()))->execute();
$signatures = mpull($signatures, null, 'getDocumentPHID');
$phids = array_fuse($phids);
foreach ($phids as $phid) {
$phids[$phid] = isset($signatures[$phid]);
}
}
return $phids;
}
示例4: execute
public function execute()
{
$viewer = $this->getViewer();
$conpherence_app = 'PhabricatorConpherenceApplication';
$is_c_installed = PhabricatorApplication::isClassInstalledForViewer($conpherence_app, $viewer);
$raw_message_count_number = null;
$message_count_number = null;
if ($is_c_installed) {
$unread_status = ConpherenceParticipationStatus::BEHIND;
$unread = id(new ConpherenceParticipantCountQuery())->withParticipantPHIDs(array($viewer->getPHID()))->withParticipationStatus($unread_status)->execute();
$raw_message_count_number = idx($unread, $viewer->getPHID(), 0);
$message_count_number = $this->formatNumber($raw_message_count_number);
}
$conpherence_data = array('isInstalled' => $is_c_installed, 'countType' => 'messages', 'count' => $message_count_number, 'rawCount' => $raw_message_count_number);
$this->setConpherenceData($conpherence_data);
$notification_app = 'PhabricatorNotificationsApplication';
$is_n_installed = PhabricatorApplication::isClassInstalledForViewer($notification_app, $viewer);
$notification_count_number = null;
$raw_notification_count_number = null;
if ($is_n_installed) {
$raw_notification_count_number = id(new PhabricatorFeedStoryNotification())->countUnread($viewer);
$notification_count_number = $this->formatNumber($raw_notification_count_number);
}
$notification_data = array('isInstalled' => $is_n_installed, 'countType' => 'notifications', 'count' => $notification_count_number, 'rawCount' => $raw_notification_count_number);
$this->setNotificationData($notification_data);
return array($notification_app => $this->getNotificationData(), $conpherence_app => $this->getConpherenceData());
}
示例5: publishNotifications
public function publishNotifications()
{
$cursor = $this->getCursor();
$now = PhabricatorTime::getNow();
if ($cursor > $now) {
return;
}
$calendar_class = 'PhabricatorCalendarApplication';
if (!PhabricatorApplication::isClassInstalled($calendar_class)) {
return;
}
try {
$lock = PhabricatorGlobalLock::newLock('calendar.notify')->lock(5);
} catch (PhutilLockException $ex) {
return;
}
$caught = null;
try {
$this->sendNotifications();
} catch (Exception $ex) {
$caught = $ex;
}
$lock->unlock();
// Wait a little while before checking for new notifications to send.
$this->setCursor($cursor + phutil_units('1 minute in seconds'));
if ($caught) {
throw $caught;
}
}
示例6: buildMainResponse
private function buildMainResponse(array $projects)
{
assert_instances_of($projects, 'PhabricatorProject');
$viewer = $this->getRequest()->getUser();
$has_maniphest = PhabricatorApplication::isClassInstalledForViewer('PhabricatorManiphestApplication', $viewer);
$has_audit = PhabricatorApplication::isClassInstalledForViewer('PhabricatorAuditApplication', $viewer);
$has_differential = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDifferentialApplication', $viewer);
if ($has_maniphest) {
$unbreak_panel = $this->buildUnbreakNowPanel();
$triage_panel = $this->buildNeedsTriagePanel($projects);
$tasks_panel = $this->buildTasksPanel();
} else {
$unbreak_panel = null;
$triage_panel = null;
$tasks_panel = null;
}
if ($has_audit) {
$audit_panel = $this->buildAuditPanel();
$commit_panel = $this->buildCommitPanel();
} else {
$audit_panel = null;
$commit_panel = null;
}
if (PhabricatorEnv::getEnvConfig('welcome.html') !== null) {
$welcome_panel = $this->buildWelcomePanel();
} else {
$welcome_panel = null;
}
if ($has_differential) {
$revision_panel = $this->buildRevisionPanel();
} else {
$revision_panel = null;
}
return array($welcome_panel, $unbreak_panel, $triage_panel, $revision_panel, $tasks_panel, $audit_panel, $commit_panel, $this->minipanels);
}
示例7: buildMainResponse
private function buildMainResponse()
{
require_celerity_resource('phabricator-dashboard-css');
$viewer = $this->getViewer();
$has_maniphest = PhabricatorApplication::isClassInstalledForViewer('PhabricatorManiphestApplication', $viewer);
$has_diffusion = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDiffusionApplication', $viewer);
$has_differential = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDifferentialApplication', $viewer);
$revision_panel = null;
if ($has_differential) {
$revision_panel = $this->buildRevisionPanel();
}
$tasks_panel = null;
if ($has_maniphest) {
$tasks_panel = $this->buildTasksPanel();
}
$repository_panel = null;
if ($has_diffusion) {
$repository_panel = $this->buildRepositoryPanel();
}
$feed_panel = $this->buildFeedPanel();
$dashboard = id(new AphrontMultiColumnView())->setFluidlayout(true)->setGutter(AphrontMultiColumnView::GUTTER_LARGE);
$main_panel = phutil_tag('div', array('class' => 'homepage-panel'), array($revision_panel, $tasks_panel, $repository_panel));
$dashboard->addColumn($main_panel, 'thirds');
$side_panel = phutil_tag('div', array('class' => 'homepage-side-panel'), array($feed_panel));
$dashboard->addColumn($side_panel, 'third');
$view = id(new PHUIBoxView())->addClass('dashboard-view')->appendChild($dashboard);
return $view;
}
示例8: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$selected = PhabricatorApplication::getByClass($this->application);
if (!$selected) {
return new Aphront404Response();
}
$view_uri = $this->getApplicationURI('view/' . $this->application);
$beta_enabled = PhabricatorEnv::getEnvConfig('phabricator.show-beta-applications');
$dialog = id(new AphrontDialogView())->setUser($user)->addCancelButton($view_uri);
if ($selected->isBeta() && !$beta_enabled) {
$dialog->setTitle(pht('Beta Applications Not Enabled'))->appendChild(pht('To manage beta applications, enable them by setting %s in your ' . 'Phabricator configuration.', phutil_tag('tt', array(), 'phabricator.show-beta-applications')));
return id(new AphrontDialogResponse())->setDialog($dialog);
}
if ($request->isDialogFormPost()) {
$this->manageApplication();
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
if ($this->action == 'install') {
if ($selected->canUninstall()) {
$dialog->setTitle('Confirmation')->appendChild('Install ' . $selected->getName() . ' application?')->addSubmitButton('Install');
} else {
$dialog->setTitle('Information')->appendChild('You cannot install an installed application.');
}
} else {
if ($selected->canUninstall()) {
$dialog->setTitle('Confirmation')->appendChild('Really Uninstall ' . $selected->getName() . ' application?')->addSubmitButton('Uninstall');
} else {
$dialog->setTitle('Information')->appendChild('This application cannot be uninstalled,
because it is required for Phabricator to work.');
}
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例9: executeManiphestFieldChecks
private function executeManiphestFieldChecks()
{
$maniphest_appclass = 'PhabricatorManiphestApplication';
if (!PhabricatorApplication::isClassInstalled($maniphest_appclass)) {
return;
}
$capabilities = array(ManiphestEditAssignCapability::CAPABILITY, ManiphestEditPoliciesCapability::CAPABILITY, ManiphestEditPriorityCapability::CAPABILITY, ManiphestEditProjectsCapability::CAPABILITY, ManiphestEditStatusCapability::CAPABILITY);
// Check for any of these capabilities set to anything other than
// "All Users".
$any_set = false;
$app = new PhabricatorManiphestApplication();
foreach ($capabilities as $capability) {
$setting = $app->getPolicy($capability);
if ($setting != PhabricatorPolicies::POLICY_USER) {
$any_set = true;
break;
}
}
if (!$any_set) {
return;
}
$issue_summary = pht('Maniphest is currently configured with deprecated policy settings ' . 'which will be removed in a future version of Phabricator.');
$message = pht('Some policy settings in Maniphest are now deprecated and will be ' . 'removed in a future version of Phabricator. You are currently using ' . 'at least one of these settings.' . "\n\n" . 'The deprecated settings are "Can Assign Tasks", ' . '"Can Edit Task Policies", "Can Prioritize Tasks", ' . '"Can Edit Task Projects", and "Can Edit Task Status". You can ' . 'find these settings in Applications, or follow the link below.' . "\n\n" . 'You can find discussion of this change (including rationale and ' . 'recommendations on how to configure similar features) in the upstream, ' . 'at the link below.' . "\n\n" . 'To resolve this issue, set all of these policies to "All Users" after ' . 'making any necessary form customization changes.');
$more_href = 'https://secure.phabricator.com/T10003';
$edit_href = '/applications/view/PhabricatorManiphestApplication/';
$issue = $this->newIssue('maniphest.T10003-per-field-policies')->setShortName(pht('Deprecated Policies'))->setName(pht('Deprecated Maniphest Field Policies'))->setSummary($issue_summary)->setMessage($message)->addLink($more_href, pht('Learn More: Upstream Discussion'))->addLink($edit_href, pht('Edit These Settings'));
}
示例10: execute
public function execute()
{
$viewer = $this->getViewer();
$conpherence_app = 'PhabricatorConpherenceApplication';
$is_c_installed = PhabricatorApplication::isClassInstalledForViewer($conpherence_app, $viewer);
if ($is_c_installed) {
$raw_message_count_number = $viewer->getUnreadMessageCount();
$message_count_number = $this->formatNumber($raw_message_count_number);
} else {
$raw_message_count_number = null;
$message_count_number = null;
}
$conpherence_data = array('isInstalled' => $is_c_installed, 'countType' => 'messages', 'count' => $message_count_number, 'rawCount' => $raw_message_count_number);
$this->setConpherenceData($conpherence_data);
$notification_app = 'PhabricatorNotificationsApplication';
$is_n_installed = PhabricatorApplication::isClassInstalledForViewer($notification_app, $viewer);
if ($is_n_installed) {
$raw_notification_count_number = $viewer->getUnreadNotificationCount();
$notification_count_number = $this->formatNumber($raw_notification_count_number);
} else {
$notification_count_number = null;
$raw_notification_count_number = null;
}
$notification_data = array('isInstalled' => $is_n_installed, 'countType' => 'notifications', 'count' => $notification_count_number, 'rawCount' => $raw_notification_count_number);
$this->setNotificationData($notification_data);
return array($notification_app => $this->getNotificationData(), $conpherence_app => $this->getConpherenceData());
}
示例11: buildIconNavView
public function buildIconNavView(PhabricatorUser $user)
{
$viewer = $this->getViewer();
$picture = $user->getProfileImageURI();
$name = $user->getUsername();
$nav = new AphrontSideNavFilterView();
$nav->setIconNav(true);
$nav->setBaseURI(new PhutilURI('/p/'));
$nav->addIcon("{$name}/", $name, null, $picture);
$class = 'PhabricatorCalendarApplication';
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
$nav->addIcon("{$name}/calendar/", pht('Calendar'), 'fa-calendar');
}
$class = 'PhabricatorManiphestApplication';
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
$phid = $user->getPHID();
$view_uri = sprintf('/maniphest/?statuses=open()&assigned=%s#R', $phid);
$nav->addIcon('maniphest', pht('Open Tasks'), 'fa-anchor', null, $view_uri);
}
$class = 'PhabricatorDifferentialApplication';
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
$username = phutil_escape_uri($name);
$view_uri = '/differential/?authors=' . $username;
$nav->addIcon('differential', pht('Revisions'), 'fa-cog', null, $view_uri);
}
$class = 'PhabricatorAuditApplication';
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
$username = phutil_escape_uri($name);
$view_uri = '/audit/?authors=' . $username;
$nav->addIcon('audit', pht('Commits'), 'fa-code', null, $view_uri);
}
return $nav;
}
示例12: handleRequestException
public function handleRequestException(AphrontRequest $request, Exception $ex)
{
$viewer = $this->getViewer($request);
if (!$viewer->isLoggedIn()) {
// If the user isn't logged in, just give them a login form. This is
// probably a generally more useful response than a policy dialog that
// they have to click through to get a login form.
//
// Possibly we should add a header here like "you need to login to see
// the thing you are trying to look at".
$auth_app_class = 'PhabricatorAuthApplication';
$auth_app = PhabricatorApplication::getByClass($auth_app_class);
return id(new PhabricatorAuthStartController())->setRequest($request)->setCurrentApplication($auth_app)->handleRequest($request);
}
$content = array(phutil_tag('div', array('class' => 'aphront-policy-rejection'), $ex->getRejection()));
$list = null;
if ($ex->getCapabilityName()) {
$list = $ex->getMoreInfo();
foreach ($list as $key => $item) {
$list[$key] = $item;
}
$content[] = phutil_tag('div', array('class' => 'aphront-capability-details'), pht('Users with the "%s" capability:', $ex->getCapabilityName()));
}
$dialog = id(new AphrontDialogView())->setTitle($ex->getTitle())->setClass('aphront-access-dialog')->setUser($viewer)->appendChild($content);
if ($list) {
$dialog->appendList($list);
}
if ($request->isAjax()) {
$dialog->addCancelButton('/', pht('Close'));
} else {
$dialog->addCancelButton('/', pht('OK'));
}
return $dialog;
}
示例13: buildIconNavView
public function buildIconNavView(PhabricatorProject $project)
{
$this->setProject($project);
$viewer = $this->getViewer();
$id = $project->getID();
$picture = $project->getProfileImageURI();
$name = $project->getName();
$columns = id(new PhabricatorProjectColumnQuery())->setViewer($viewer)->withProjectPHIDs(array($project->getPHID()))->execute();
if ($columns) {
$board_icon = 'fa-columns';
} else {
$board_icon = 'fa-columns grey';
}
$nav = new AphrontSideNavFilterView();
$nav->setIconNav(true);
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
$nav->addIcon("profile/{$id}/", $name, null, $picture);
$class = 'PhabricatorManiphestApplication';
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
$phid = $project->getPHID();
$nav->addIcon("board/{$id}/", pht('Workboard'), $board_icon);
$query_uri = urisprintf('/maniphest/?statuses=open()&projects=%s#R', $phid);
$nav->addIcon(null, pht('Open Tasks'), 'fa-anchor', null, $query_uri);
}
$nav->addIcon("feed/{$id}/", pht('Feed'), 'fa-newspaper-o');
$nav->addIcon("members/{$id}/", pht('Members'), 'fa-group');
$nav->addIcon("details/{$id}/", pht('Edit Details'), 'fa-pencil');
return $nav;
}
示例14: renderView
public function renderView()
{
$view = $this->newStoryView();
$handle = $this->getHandle($this->getPrimaryObjectPHID());
$view->setHref($handle->getURI());
$type = phid_get_type($handle->getPHID());
$phid_types = PhabricatorPHIDType::getAllTypes();
$icon = null;
if (!empty($phid_types[$type])) {
$phid_type = $phid_types[$type];
$class = $phid_type->getPHIDTypeApplicationClass();
if ($class) {
$application = PhabricatorApplication::getByClass($class);
$icon = $application->getIcon();
}
}
$view->setAppIcon($icon);
$xaction_phids = $this->getValue('transactionPHIDs');
$xaction = $this->getPrimaryTransaction();
$xaction->setHandles($this->getHandles());
$view->setTitle($xaction->getTitleForFeed());
foreach ($xaction_phids as $xaction_phid) {
$secondary_xaction = $this->getObject($xaction_phid);
$secondary_xaction->setHandles($this->getHandles());
$body = $secondary_xaction->getBodyForFeed($this);
if (nonempty($body)) {
$view->appendChild($body);
}
}
$view->setImage($this->getHandle($xaction->getAuthorPHID())->getImageURI());
return $view;
}
示例15: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$applications = PhabricatorApplication::getAllInstalledApplications();
foreach ($applications as $key => $application) {
if (!$application->shouldAppearInLaunchView()) {
unset($applications[$key]);
}
}
$groups = PhabricatorApplication::getApplicationGroups();
$applications = msort($applications, 'getApplicationOrder');
$applications = mgroup($applications, 'getApplicationGroup');
$applications = array_select_keys($applications, array_keys($groups));
$view = array();
foreach ($applications as $group => $application_list) {
$status = array();
foreach ($application_list as $key => $application) {
$status[$key] = $application->loadStatus($user);
}
$views = array();
foreach ($application_list as $key => $application) {
$views[] = id(new PhabricatorApplicationLaunchView())->setApplication($application)->setApplicationStatus(idx($status, $key, array()))->setUser($user);
}
$view[] = id(new PhabricatorHeaderView())->setHeader($groups[$group]);
$view[] = phutil_render_tag('div', array('class' => 'phabricator-application-list'), id(new AphrontNullView())->appendChild($views)->render());
}
return $this->buildApplicationPage($view, array('title' => 'Applications', 'device' => true));
}