本文整理汇总了PHP中PhabricatorPolicyQuery类的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorPolicyQuery类的具体用法?PHP PhabricatorPolicyQuery怎么用?PHP PhabricatorPolicyQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PhabricatorPolicyQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildProperties
private function buildProperties(PhabricatorProject $project)
{
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($project);
if ($project->isMilestone()) {
$icon_key = PhabricatorProjectIconSet::getMilestoneIconKey();
$icon = PhabricatorProjectIconSet::getIconIcon($icon_key);
$target = PhabricatorProjectIconSet::getIconName($icon_key);
$note = pht('Members of the parent project are members of this project.');
$show_join = false;
} else {
if ($project->getHasSubprojects()) {
$icon = 'fa-sitemap';
$target = pht('Parent Project');
$note = pht('Members of all subprojects are members of this project.');
$show_join = false;
} else {
if ($project->getIsMembershipLocked()) {
$icon = 'fa-lock';
$target = pht('Locked Project');
$note = pht('Users with access may join this project, but may not leave.');
$show_join = true;
} else {
$icon = 'fa-briefcase';
$target = pht('Normal Project');
$note = pht('Users with access may join and leave this project.');
$show_join = true;
}
}
}
$item = id(new PHUIStatusItemView())->setIcon($icon)->setTarget(phutil_tag('strong', array(), $target))->setNote($note);
$status = id(new PHUIStatusListView())->addItem($item);
$view->addProperty(pht('Membership'), $status);
if ($show_join) {
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $project);
$view->addProperty(pht('Joinable By'), $descriptions[PhabricatorPolicyCapability::CAN_JOIN]);
}
$viewer_phid = $viewer->getPHID();
if ($project->isUserWatcher($viewer_phid)) {
$watch_item = id(new PHUIStatusItemView())->setIcon('fa-eye green')->setTarget(phutil_tag('strong', array(), pht('Watching')))->setNote(pht('You will receive mail about changes made to any related ' . 'object.'));
$watch_status = id(new PHUIStatusListView())->addItem($watch_item);
$view->addProperty(pht('Watching'), $watch_status);
}
if ($project->isUserMember($viewer_phid)) {
$is_silenced = $this->isProjectSilenced($project);
if ($is_silenced) {
$mail_icon = 'fa-envelope-o grey';
$mail_target = pht('Disabled');
$mail_note = pht('When mail is sent to project members, you will not receive ' . 'a copy.');
} else {
$mail_icon = 'fa-envelope-o green';
$mail_target = pht('Enabled');
$mail_note = pht('You will receive mail that is sent to project members.');
}
$mail_item = id(new PHUIStatusItemView())->setIcon($mail_icon)->setTarget(phutil_tag('strong', array(), $mail_target))->setNote($mail_note);
$mail_status = id(new PHUIStatusListView())->addItem($mail_item);
$view->addProperty(pht('Mail to Members'), $mail_status);
}
return $view;
}
示例2: getOptions
protected function getOptions()
{
$capability = $this->capability;
$policies = $this->policies;
// Exclude object policies which don't make sense here. This primarily
// filters object policies associated from template capabilities (like
// "Default Task View Policy" being set to "Task Author") so they aren't
// made available on non-template capabilities (like "Can Bulk Edit").
foreach ($policies as $key => $policy) {
if ($policy->getType() != PhabricatorPolicyType::TYPE_OBJECT) {
continue;
}
$rule = PhabricatorPolicyQuery::getObjectPolicyRule($policy->getPHID());
if (!$rule) {
continue;
}
$target = nonempty($this->templateObject, $this->object);
if (!$rule->canApplyToObject($target)) {
unset($policies[$key]);
continue;
}
}
$options = array();
foreach ($policies as $policy) {
if ($policy->getPHID() == PhabricatorPolicies::POLICY_PUBLIC) {
// Never expose "Public" for capabilities which don't support it.
$capobj = PhabricatorPolicyCapability::getCapabilityByKey($capability);
if (!$capobj || !$capobj->shouldAllowPublicPolicySetting()) {
continue;
}
}
$policy_short_name = id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(28)->truncateString($policy->getName());
$options[$policy->getType()][$policy->getPHID()] = array('name' => $policy_short_name, 'full' => $policy->getName(), 'icon' => $policy->getIcon());
}
// If we were passed several custom policy options, throw away the ones
// which aren't the value for this capability. For example, an object might
// have a custom view pollicy and a custom edit policy. When we render
// the selector for "Can View", we don't want to show the "Can Edit"
// custom policy -- if we did, the menu would look like this:
//
// Custom
// Custom Policy
// Custom Policy
//
// ...where one is the "view" custom policy, and one is the "edit" custom
// policy.
$type_custom = PhabricatorPolicyType::TYPE_CUSTOM;
if (!empty($options[$type_custom])) {
$options[$type_custom] = array_select_keys($options[$type_custom], array($this->getValue()));
}
// If there aren't any custom policies, add a placeholder policy so we
// render a menu item. This allows the user to switch to a custom policy.
if (empty($options[$type_custom])) {
$placeholder = new PhabricatorPolicy();
$placeholder->setName(pht('Custom Policy...'));
$options[$type_custom][$this->getCustomPolicyPlaceholder()] = array('name' => $placeholder->getName(), 'full' => $placeholder->getName(), 'icon' => $placeholder->getIcon());
}
$options = array_select_keys($options, array(PhabricatorPolicyType::TYPE_GLOBAL, PhabricatorPolicyType::TYPE_OBJECT, PhabricatorPolicyType::TYPE_USER, PhabricatorPolicyType::TYPE_CUSTOM, PhabricatorPolicyType::TYPE_PROJECT));
return $options;
}
示例3: buildPropertyView
private function buildPropertyView(PhameBlog $blog)
{
$viewer = $this->getViewer();
require_celerity_resource('aphront-tooltip-css');
Javelin::initBehavior('phabricator-tooltips');
$properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($blog);
$domain = $blog->getDomain();
if (!$domain) {
$domain = phutil_tag('em', array(), pht('No external domain'));
}
$properties->addProperty(pht('Domain'), $domain);
$feed_uri = PhabricatorEnv::getProductionURI($this->getApplicationURI('blog/feed/' . $blog->getID() . '/'));
$properties->addProperty(pht('Atom URI'), javelin_tag('a', array('href' => $feed_uri, 'sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Atom URI does not support custom domains.'), 'size' => 320)), $feed_uri));
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $blog);
$properties->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
$engine = id(new PhabricatorMarkupEngine())->setViewer($viewer)->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)->process();
$properties->invokeWillRenderEvent();
$description = $blog->getDescription();
if (strlen($description)) {
$description = new PHUIRemarkupView($viewer, $description);
$properties->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
$properties->addTextContent($description);
}
return $properties;
}
示例4: buildPropertyView
private function buildPropertyView(PhabricatorApplication $application, PhabricatorActionListView $actions)
{
$viewer = $this->getRequest()->getUser();
$properties = id(new PHUIPropertyListView());
$properties->setActionList($actions);
$properties->addProperty(pht('Description'), $application->getShortDescription());
if ($application->getFlavorText()) {
$properties->addProperty(null, phutil_tag('em', array(), $application->getFlavorText()));
}
if ($application->isPrototype()) {
$proto_href = PhabricatorEnv::getDoclink('User Guide: Prototype Applications');
$learn_more = phutil_tag('a', array('href' => $proto_href, 'target' => '_blank'), pht('Learn More'));
$properties->addProperty(pht('Prototype'), pht('This application is a prototype. %s', $learn_more));
}
$overview = $application->getOverview();
if (strlen($overview)) {
$overview = new PHUIRemarkupView($viewer, $overview);
$properties->addSectionHeader(pht('Overview'), PHUIPropertyListView::ICON_SUMMARY);
$properties->addTextContent($overview);
}
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $application);
$properties->addSectionHeader(pht('Policies'), 'fa-lock');
foreach ($application->getCapabilities() as $capability) {
$properties->addProperty($application->getCapabilityLabel($capability), idx($descriptions, $capability));
}
return $properties;
}
示例5: buildPropertyList
private function buildPropertyList(DivinerLiveBook $book)
{
$viewer = $this->getRequest()->getUser();
$view = id(new PHUIPropertyListView())->setUser($viewer);
$policies = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $book);
$view->addProperty(pht('Updated'), phabricator_datetime($book->getDateModified(), $viewer));
return $view;
}
示例6: buildPropertyView
private function buildPropertyView(PhabricatorDashboard $dashboard)
{
$viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView())->setUser($viewer);
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $dashboard);
$properties->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
$properties->addProperty(pht('Panels'), $viewer->renderHandleList($dashboard->getPanelPHIDs()));
return id(new PHUIObjectBoxView())->setHeaderText(pht('Details'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->addPropertyList($properties);
}
示例7: buildPropertyView
private function buildPropertyView(PhabricatorDashboard $dashboard)
{
$viewer = $this->getRequest()->getUser();
$properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($dashboard);
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $dashboard);
$properties->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
$properties->addProperty(pht('Panels'), $viewer->renderHandleList($dashboard->getPanelPHIDs()));
return $properties;
}
示例8: buildPropertyView
private function buildPropertyView(NuanceSource $source, PhabricatorActionListView $actions)
{
$viewer = $this->getRequest()->getUser();
$properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($source)->setActionList($actions);
$definition = $source->requireDefinition();
$properties->addProperty(pht('Source Type'), $definition->getName());
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $source);
$properties->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
return $properties;
}
示例9: buildPropertyView
private function buildPropertyView(PhabricatorProjectColumn $column, PhabricatorActionListView $actions)
{
$viewer = $this->getRequest()->getUser();
$properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($column)->setActionList($actions);
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $column);
$properties->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
$limit = $column->getPointLimit();
$properties->addProperty(pht('Point Limit'), $limit ? $limit : pht('No Limit'));
return $properties;
}
示例10: buildPolicyView
private function buildPolicyView(PhabricatorApplication $application)
{
$viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView());
$header = id(new PHUIHeaderView())->setHeader(pht('POLICIES'))->setHeaderIcon('fa-lock');
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $application);
foreach ($application->getCapabilities() as $capability) {
$properties->addProperty($application->getCapabilityLabel($capability), idx($descriptions, $capability));
}
return id(new PHUIObjectBoxView())->setHeader($header)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->appendChild($properties);
}
示例11: buildPropertyListView
private function buildPropertyListView(PhabricatorProject $project, PhabricatorActionListView $actions)
{
$request = $this->getRequest();
$viewer = $request->getUser();
$view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($project)->setActionList($actions);
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $project);
$this->loadHandles(array($project->getPHID()));
$view->addProperty(pht('Looks Like'), $this->getHandle($project->getPHID())->renderTag());
$view->addProperty(pht('Visible To'), $descriptions[PhabricatorPolicyCapability::CAN_VIEW]);
$view->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
$view->addProperty(pht('Joinable By'), $descriptions[PhabricatorPolicyCapability::CAN_JOIN]);
return $view;
}
示例12: buildPropertyView
private function buildPropertyView(PhabricatorPaste $paste, array $child_phids, PhabricatorActionListView $actions)
{
$viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($paste)->setActionList($actions);
$properties->addProperty(pht('Author'), $viewer->renderHandle($paste->getAuthorPHID()));
$properties->addProperty(pht('Created'), phabricator_datetime($paste->getDateCreated(), $viewer));
if ($paste->getParentPHID()) {
$properties->addProperty(pht('Forked From'), $viewer->renderHandle($paste->getParentPHID()));
}
if ($child_phids) {
$properties->addProperty(pht('Forks'), $viewer->renderHandleList($child_phids));
}
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $paste);
return $properties;
}
示例13: buildPropertyListView
private function buildPropertyListView(PhabricatorSpacesNamespace $space)
{
$viewer = $this->getRequest()->getUser();
$list = id(new PHUIPropertyListView())->setUser($viewer);
$list->addProperty(pht('Default Space'), $space->getIsDefaultNamespace() ? pht('Yes') : pht('No'));
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $space);
$list->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
$description = $space->getDescription();
if (strlen($description)) {
$description = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($description), 'default', $viewer);
$list->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
$list->addTextContent($description);
}
return $list;
}
示例14: buildPropertyView
private function buildPropertyView(PhabricatorPaste $paste, array $child_phids)
{
$user = $this->getRequest()->getUser();
$properties = new PhabricatorPropertyListView();
$properties->addProperty(pht('Author'), $this->getHandle($paste->getAuthorPHID())->renderLink());
$properties->addProperty(pht('Created'), phabricator_datetime($paste->getDateCreated(), $user));
if ($paste->getParentPHID()) {
$properties->addProperty(pht('Forked From'), $this->getHandle($paste->getParentPHID())->renderLink());
}
if ($child_phids) {
$properties->addProperty(pht('Forks'), $this->renderHandlesForPHIDs($child_phids));
}
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($user, $paste);
$properties->addProperty(pht('Visible To'), $descriptions[PhabricatorPolicyCapability::CAN_VIEW]);
return $properties;
}
示例15: renderProperties
private function renderProperties(PhameBlog $blog, PhabricatorUser $user, PhabricatorActionListView $actions)
{
require_celerity_resource('aphront-tooltip-css');
Javelin::initBehavior('phabricator-tooltips');
$properties = new PHUIPropertyListView();
$properties->setActionList($actions);
$properties->addProperty(pht('Skin'), $blog->getSkin());
$properties->addProperty(pht('Domain'), $blog->getDomain());
$feed_uri = PhabricatorEnv::getProductionURI($this->getApplicationURI('blog/feed/' . $blog->getID() . '/'));
$properties->addProperty(pht('Atom URI'), javelin_tag('a', array('href' => $feed_uri, 'sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Atom URI does not support custom domains.'), 'size' => 320)), $feed_uri));
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($user, $blog);
$properties->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
$properties->addProperty(pht('Joinable By'), $descriptions[PhabricatorPolicyCapability::CAN_JOIN]);
$engine = id(new PhabricatorMarkupEngine())->setViewer($user)->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)->process();
$properties->addTextContent(phutil_tag('div', array('class' => 'phabricator-remarkup'), $engine->getOutput($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)));
return $properties;
}