当前位置: 首页>>代码示例>>PHP>>正文


PHP PhabricatorPolicyFilter::hasCapability方法代码示例

本文整理汇总了PHP中PhabricatorPolicyFilter::hasCapability方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorPolicyFilter::hasCapability方法的具体用法?PHP PhabricatorPolicyFilter::hasCapability怎么用?PHP PhabricatorPolicyFilter::hasCapability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhabricatorPolicyFilter的用法示例。


在下文中一共展示了PhabricatorPolicyFilter::hasCapability方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFileVisibility

 public function testFileVisibility()
 {
     $engine = new PhabricatorTestStorageEngine();
     $data = Filesystem::readRandomCharacters(64);
     $author = $this->generateNewTestUser();
     $viewer = $this->generateNewTestUser();
     $users = array($author, $viewer);
     $params = array('name' => 'test.dat', 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 'authorPHID' => $author->getPHID(), 'storageEngines' => array($engine));
     $file = PhabricatorFile::newFromFileData($data, $params);
     $filter = new PhabricatorPolicyFilter();
     // Test bare file policies.
     $this->assertEqual(array(true, false), $this->canViewFile($users, $file), pht('File Visibility'));
     // Create an object and test object policies.
     $object = ManiphestTask::initializeNewTask($author);
     $object->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy());
     $object->save();
     $this->assertTrue($filter->hasCapability($author, $object, PhabricatorPolicyCapability::CAN_VIEW), pht('Object Visible to Author'));
     $this->assertTrue($filter->hasCapability($viewer, $object, PhabricatorPolicyCapability::CAN_VIEW), pht('Object Visible to Others'));
     // Attach the file to the object and test that the association opens a
     // policy exception for the non-author viewer.
     $file->attachToObject($object->getPHID());
     // Test the attached file's visibility.
     $this->assertEqual(array(true, true), $this->canViewFile($users, $file), pht('Attached File Visibility'));
     // Create a "thumbnail" of the original file.
     $params = array('name' => 'test.thumb.dat', 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 'storageEngines' => array($engine));
     $xform = PhabricatorFile::newFromFileData($data, $params);
     id(new PhabricatorTransformedFile())->setOriginalPHID($file->getPHID())->setTransform('test-thumb')->setTransformedPHID($xform->getPHID())->save();
     // Test the thumbnail's visibility.
     $this->assertEqual(array(true, true), $this->canViewFile($users, $xform), pht('Attached Thumbnail Visibility'));
     // Detach the object and make sure it affects the thumbnail.
     $file->detachFromObject($object->getPHID());
     // Test the detached thumbnail's visibility.
     $this->assertEqual(array(true, false), $this->canViewFile($users, $xform), pht('Detached Thumbnail Visibility'));
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:34,代码来源:PhabricatorFileTestCase.php

示例2: buildActionView

 private function buildActionView(PhabricatorEditEngineConfiguration $config)
 {
     $viewer = $this->getViewer();
     $engine = $config->getEngine();
     $engine_key = $engine->getEngineKey();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $config, PhabricatorPolicyCapability::CAN_EDIT);
     $view = id(new PhabricatorActionListView())->setUser($viewer);
     $form_key = $config->getIdentifier();
     $base_uri = "/transactions/editengine/{$engine_key}";
     $is_concrete = (bool) $config->getID();
     if (!$is_concrete) {
         $save_uri = "{$base_uri}/save/{$form_key}/";
         $view->addAction(id(new PhabricatorActionView())->setName(pht('Make Editable'))->setIcon('fa-pencil')->setDisabled(!$can_edit)->setWorkflow(true)->setHref($save_uri));
         $can_edit = false;
     } else {
         $edit_uri = "{$base_uri}/edit/{$form_key}/";
         $view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Form Configuration'))->setIcon('fa-pencil')->setDisabled(!$can_edit)->setWorkflow(!$can_edit)->setHref($edit_uri));
     }
     $use_uri = $engine->getEditURI(null, "form/{$form_key}/");
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Use Form'))->setIcon('fa-th-list')->setHref($use_uri));
     $defaults_uri = "{$base_uri}/defaults/{$form_key}/";
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Change Default Values'))->setIcon('fa-paint-brush')->setHref($defaults_uri)->setWorkflow(!$can_edit)->setDisabled(!$can_edit));
     $reorder_uri = "{$base_uri}/reorder/{$form_key}/";
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Change Field Order'))->setIcon('fa-sort-alpha-asc')->setHref($reorder_uri)->setWorkflow(true)->setDisabled(!$can_edit));
     $lock_uri = "{$base_uri}/lock/{$form_key}/";
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Lock / Hide Fields'))->setIcon('fa-lock')->setHref($lock_uri)->setWorkflow(true)->setDisabled(!$can_edit));
     return $view;
 }
开发者ID:Escalation,项目名称:phabricator,代码行数:28,代码来源:PhabricatorEditEngineConfigurationViewController.php

示例3: buildActionView

 private function buildActionView(PhabricatorUser $viewer, PhabricatorPaste $paste, PhabricatorFile $file)
 {
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $paste, PhabricatorPolicyCapability::CAN_EDIT);
     $can_fork = $viewer->isLoggedIn();
     $fork_uri = $this->getApplicationURI('/create/?parent=' . $paste->getID());
     return id(new PhabricatorActionListView())->setUser($viewer)->setObject($paste)->setObjectURI($this->getRequest()->getRequestURI())->addAction(id(new PhabricatorActionView())->setName(pht('Edit Paste'))->setIcon('fa-pencil')->setDisabled(!$can_edit)->setWorkflow(!$can_edit)->setHref($this->getApplicationURI('/edit/' . $paste->getID() . '/')))->addAction(id(new PhabricatorActionView())->setName(pht('Fork This Paste'))->setIcon('fa-code-fork')->setDisabled(!$can_fork)->setWorkflow(!$can_fork)->setHref($fork_uri))->addAction(id(new PhabricatorActionView())->setName(pht('View Raw File'))->setIcon('fa-file-text-o')->setHref($file->getBestURI()));
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:7,代码来源:PhabricatorPasteViewController.php

示例4: renderSettingsWidgetPaneContent

 private function renderSettingsWidgetPaneContent()
 {
     $viewer = $this->getViewer();
     $conpherence = $this->getConpherence();
     $participant = $conpherence->getParticipantIfExists($viewer->getPHID());
     if (!$participant) {
         $can_join = PhabricatorPolicyFilter::hasCapability($viewer, $conpherence, PhabricatorPolicyCapability::CAN_JOIN);
         if ($can_join) {
             $text = pht('Notification settings are available after joining the room.');
         } else {
             if ($viewer->isLoggedIn()) {
                 $text = pht('Notification settings not applicable to rooms you can not join.');
             } else {
                 $text = pht('Notification settings are available after logging in and joining ' . 'the room.');
             }
         }
         return phutil_tag('div', array('class' => 'no-settings'), $text);
     }
     $default = ConpherenceSettings::EMAIL_ALWAYS;
     $preference = $this->getUserPreferences();
     if ($preference) {
         $default = $preference->getPreference(PhabricatorUserPreferences::PREFERENCE_CONPH_NOTIFICATIONS, ConpherenceSettings::EMAIL_ALWAYS);
     }
     $settings = $participant->getSettings();
     $notifications = idx($settings, 'notifications', $default);
     $options = id(new AphrontFormRadioButtonControl())->addButton(ConpherenceSettings::EMAIL_ALWAYS, ConpherenceSettings::getHumanString(ConpherenceSettings::EMAIL_ALWAYS), '')->addButton(ConpherenceSettings::NOTIFICATIONS_ONLY, ConpherenceSettings::getHumanString(ConpherenceSettings::NOTIFICATIONS_ONLY), '')->setName('notifications')->setValue($notifications);
     $layout = array($options, phutil_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'notifications')), phutil_tag('button', array('type' => 'submit', 'class' => 'notifications-update'), pht('Save')));
     return phabricator_form($viewer, array('method' => 'POST', 'action' => $this->getWidgetURI(), 'sigil' => 'notifications-update'), $layout);
 }
开发者ID:kalbasit,项目名称:phabricator,代码行数:29,代码来源:ConpherenceWidgetController.php

示例5: buildActionList

 private function buildActionList(HarbormasterBuildable $buildable)
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $id = $buildable->getID();
     $list = id(new PhabricatorActionListView())->setUser($viewer)->setObject($buildable)->setObjectURI($buildable->getMonogram());
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $buildable, PhabricatorPolicyCapability::CAN_EDIT);
     $can_restart = false;
     $can_resume = false;
     $can_pause = false;
     $can_abort = false;
     foreach ($buildable->getBuilds() as $build) {
         if ($build->canRestartBuild()) {
             $can_restart = true;
         }
         if ($build->canResumeBuild()) {
             $can_resume = true;
         }
         if ($build->canPauseBuild()) {
             $can_pause = true;
         }
         if ($build->canAbortBuild()) {
             $can_abort = true;
         }
     }
     $restart_uri = "buildable/{$id}/restart/";
     $pause_uri = "buildable/{$id}/pause/";
     $resume_uri = "buildable/{$id}/resume/";
     $abort_uri = "buildable/{$id}/abort/";
     $list->addAction(id(new PhabricatorActionView())->setIcon('fa-repeat')->setName(pht('Restart All Builds'))->setHref($this->getApplicationURI($restart_uri))->setWorkflow(true)->setDisabled(!$can_restart || !$can_edit));
     $list->addAction(id(new PhabricatorActionView())->setIcon('fa-pause')->setName(pht('Pause All Builds'))->setHref($this->getApplicationURI($pause_uri))->setWorkflow(true)->setDisabled(!$can_pause || !$can_edit));
     $list->addAction(id(new PhabricatorActionView())->setIcon('fa-play')->setName(pht('Resume All Builds'))->setHref($this->getApplicationURI($resume_uri))->setWorkflow(true)->setDisabled(!$can_resume || !$can_edit));
     $list->addAction(id(new PhabricatorActionView())->setIcon('fa-exclamation-triangle')->setName(pht('Abort All Builds'))->setHref($this->getApplicationURI($abort_uri))->setWorkflow(true)->setDisabled(!$can_abort || !$can_edit));
     return $list;
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:35,代码来源:HarbormasterBuildableViewController.php

示例6: buildActionView

 private function buildActionView(PhabricatorDashboard $dashboard)
 {
     $viewer = $this->getRequest()->getUser();
     $id = $dashboard->getID();
     $actions = id(new PhabricatorActionListView())->setObjectURI($this->getApplicationURI('view/' . $dashboard->getID() . '/'))->setObject($dashboard)->setUser($viewer);
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $dashboard, PhabricatorPolicyCapability::CAN_EDIT);
     $actions->addAction(id(new PhabricatorActionView())->setName(pht('View Dashboard'))->setIcon('fa-columns')->setHref($this->getApplicationURI("view/{$id}/")));
     $actions->addAction(id(new PhabricatorActionView())->setName(pht('Edit Dashboard'))->setIcon('fa-pencil')->setHref($this->getApplicationURI("edit/{$id}/"))->setDisabled(!$can_edit));
     if ($dashboard->isArchived()) {
         $actions->addAction(id(new PhabricatorActionView())->setName(pht('Activate Dashboard'))->setIcon('fa-check')->setHref($this->getApplicationURI("archive/{$id}/"))->setDisabled(!$can_edit)->setWorkflow($can_edit));
     } else {
         $actions->addAction(id(new PhabricatorActionView())->setName(pht('Archive Dashboard'))->setIcon('fa-ban')->setHref($this->getApplicationURI("archive/{$id}/"))->setDisabled(!$can_edit)->setWorkflow($can_edit));
     }
     $actions->addAction(id(new PhabricatorActionView())->setName(pht('Copy Dashboard'))->setIcon('fa-files-o')->setHref($this->getApplicationURI("copy/{$id}/"))->setWorkflow(true));
     $installed_dashboard = id(new PhabricatorDashboardInstall())->loadOneWhere('objectPHID = %s AND applicationClass = %s', $viewer->getPHID(), 'PhabricatorHomeApplication');
     if ($installed_dashboard && $installed_dashboard->getDashboardPHID() == $dashboard->getPHID()) {
         $title_install = pht('Uninstall Dashboard');
         $href_install = "uninstall/{$id}/";
     } else {
         $title_install = pht('Install Dashboard');
         $href_install = "install/{$id}/";
     }
     $actions->addAction(id(new PhabricatorActionView())->setName($title_install)->setIcon('fa-wrench')->setHref($this->getApplicationURI($href_install))->setWorkflow(true));
     $actions->addAction(id(new PhabricatorActionView())->setName(pht('View History'))->setIcon('fa-history')->setHref($this->getApplicationURI("history/{$id}/")));
     return $actions;
 }
开发者ID:fuding,项目名称:phabricator,代码行数:26,代码来源:PhabricatorDashboardManageController.php

示例7: buildActionList

 private function buildActionList(PhabricatorProject $project, array $milestones, array $subprojects)
 {
     $viewer = $this->getViewer();
     $id = $project->getID();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $project, PhabricatorPolicyCapability::CAN_EDIT);
     $allows_milestones = $project->supportsMilestones();
     $allows_subprojects = $project->supportsSubprojects();
     $view = id(new PhabricatorActionListView())->setUser($viewer);
     if ($allows_milestones && $milestones) {
         $milestone_text = pht('Create Next Milestone');
     } else {
         $milestone_text = pht('Create Milestone');
     }
     $can_milestone = $can_edit && $allows_milestones;
     $milestone_href = "/project/edit/?milestone={$id}";
     $view->addAction(id(new PhabricatorActionView())->setName($milestone_text)->setIcon('fa-plus')->setHref($milestone_href)->setDisabled(!$can_milestone)->setWorkflow(!$can_milestone));
     $can_subproject = $can_edit && $allows_subprojects;
     // If we're offering to create the first subproject, we're going to warn
     // the user about the effects before moving forward.
     if ($can_subproject && !$subprojects) {
         $subproject_href = "/project/warning/{$id}/";
         $subproject_disabled = false;
         $subproject_workflow = true;
     } else {
         $subproject_href = "/project/edit/?parent={$id}";
         $subproject_disabled = !$can_subproject;
         $subproject_workflow = !$can_subproject;
     }
     $view->addAction(id(new PhabricatorActionView())->setName(pht('Create Subproject'))->setIcon('fa-plus')->setHref($subproject_href)->setDisabled($subproject_disabled)->setWorkflow($subproject_workflow));
     return $view;
 }
开发者ID:truSense,项目名称:phabricator,代码行数:31,代码来源:PhabricatorProjectSubprojectsController.php

示例8: renderPreface

 private function renderPreface()
 {
     $viewer = $this->getRequest()->getUser();
     $branch = $this->getBranch();
     $id = $branch->getID();
     $header = id(new PHUIHeaderView())->setHeader($branch->getDisplayName())->setUser($viewer)->setPolicyObject($branch);
     if ($branch->getIsActive()) {
         $header->setStatus('fa-check', 'bluegrey', pht('Active'));
     } else {
         $header->setStatus('fa-ban', 'dark', pht('Closed'));
     }
     $actions = id(new PhabricatorActionListView())->setUser($viewer)->setObject($branch)->setObjectURI($this->getRequest()->getRequestURI());
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $branch, PhabricatorPolicyCapability::CAN_EDIT);
     $edit_uri = $this->getApplicationURI("branch/edit/{$id}/");
     $close_uri = $this->getApplicationURI("branch/close/{$id}/");
     $reopen_uri = $this->getApplicationURI("branch/re-open/{$id}/");
     $history_uri = $this->getApplicationURI("branch/{$id}/history/");
     $actions->addAction(id(new PhabricatorActionView())->setName(pht('Edit Branch'))->setHref($edit_uri)->setIcon('fa-pencil')->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     if ($branch->getIsActive()) {
         $actions->addAction(id(new PhabricatorActionView())->setName(pht('Close Branch'))->setHref($close_uri)->setIcon('fa-times')->setDisabled(!$can_edit)->setWorkflow(true));
     } else {
         $actions->addAction(id(new PhabricatorActionView())->setName(pht('Reopen Branch'))->setHref($reopen_uri)->setIcon('fa-plus')->setUser($viewer)->setDisabled(!$can_edit)->setWorkflow(true));
     }
     $actions->addAction(id(new PhabricatorActionView())->setName(pht('View History'))->setHref($history_uri)->setIcon('fa-list'));
     $properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($branch)->setActionList($actions);
     $properties->addProperty(pht('Branch'), $branch->getName());
     return id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:28,代码来源:ReleephBranchViewController.php

示例9: buildActionView

 private function buildActionView(PhabricatorUser $user, DivinerLiveBook $book)
 {
     $can_edit = PhabricatorPolicyFilter::hasCapability($user, $book, PhabricatorPolicyCapability::CAN_EDIT);
     $action_view = id(new PhabricatorActionListView())->setUser($user)->setObject($book)->setObjectURI($this->getRequest()->getRequestURI());
     $action_view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Book'))->setIcon('fa-pencil')->setHref('/book/' . $book->getName() . '/edit/')->setDisabled(!$can_edit));
     return $action_view;
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:7,代码来源:DivinerBookController.php

示例10: renderActions

 private function renderActions(PhamePost $post, PhabricatorUser $viewer)
 {
     $actions = id(new PhabricatorActionListView())->setObject($post)->setObjectURI($this->getRequest()->getRequestURI())->setUser($viewer);
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $post, PhabricatorPolicyCapability::CAN_EDIT);
     $id = $post->getID();
     $actions->addAction(id(new PhabricatorActionView())->setIcon('fa-pencil')->setHref($this->getApplicationURI('post/edit/' . $id . '/'))->setName(pht('Edit Post'))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $actions->addAction(id(new PhabricatorActionView())->setIcon('fa-arrows')->setHref($this->getApplicationURI('post/move/' . $id . '/'))->setName(pht('Move Post'))->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $actions->addAction(id(new PhabricatorActionView())->setIcon('fa-history')->setHref($this->getApplicationURI('post/history/' . $id . '/'))->setName(pht('View History')));
     if ($post->isDraft()) {
         $actions->addAction(id(new PhabricatorActionView())->setIcon('fa-eye')->setHref($this->getApplicationURI('post/publish/' . $id . '/'))->setDisabled(!$can_edit)->setName(pht('Publish'))->setWorkflow(true));
         $actions->addAction(id(new PhabricatorActionView())->setIcon('fa-eye')->setHref($this->getApplicationURI('post/preview/' . $id . '/'))->setDisabled(!$can_edit)->setName(pht('Preview in Skin')));
     } else {
         $actions->addAction(id(new PhabricatorActionView())->setIcon('fa-eye-slash')->setHref($this->getApplicationURI('post/unpublish/' . $id . '/'))->setName(pht('Unpublish'))->setDisabled(!$can_edit)->setWorkflow(true));
     }
     $blog = $post->getBlog();
     $can_view_live = $blog && !$post->isDraft();
     if ($can_view_live) {
         $live_uri = $blog->getLiveURI($post);
     } else {
         $live_uri = 'post/notlive/' . $post->getID() . '/';
         $live_uri = $this->getApplicationURI($live_uri);
     }
     $actions->addAction(id(new PhabricatorActionView())->setUser($viewer)->setIcon('fa-globe')->setHref($live_uri)->setName(pht('View Live'))->setDisabled(!$can_view_live)->setWorkflow(!$can_view_live));
     return $actions;
 }
开发者ID:miaokuan,项目名称:phabricator,代码行数:25,代码来源:PhamePostViewController.php

示例11: hasAutomaticCapability

 public function hasAutomaticCapability($capability, PhabricatorUser $viewer)
 {
     if ($this->isMilestone()) {
         return $this->getParentProject()->hasAutomaticCapability($capability, $viewer);
     }
     $can_edit = PhabricatorPolicyCapability::CAN_EDIT;
     switch ($capability) {
         case PhabricatorPolicyCapability::CAN_VIEW:
             if ($this->isUserMember($viewer->getPHID())) {
                 // Project members can always view a project.
                 return true;
             }
             break;
         case PhabricatorPolicyCapability::CAN_EDIT:
             $parent = $this->getParentProject();
             if ($parent) {
                 $can_edit_parent = PhabricatorPolicyFilter::hasCapability($viewer, $parent, $can_edit);
                 if ($can_edit_parent) {
                     return true;
                 }
             }
             break;
         case PhabricatorPolicyCapability::CAN_JOIN:
             if (PhabricatorPolicyFilter::hasCapability($viewer, $this, $can_edit)) {
                 // Project editors can always join a project.
                 return true;
             }
             break;
     }
     return false;
 }
开发者ID:themarios,项目名称:phabricator,代码行数:31,代码来源:PhabricatorProject.php

示例12: 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;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:25,代码来源:PhabricatorApplicationDetailViewController.php

示例13: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $username = $request->getURIData('username');
     $user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withUsernames(array($username))->needBadges(true)->needProfileImage(true)->needAvailability(true)->executeOne();
     if (!$user) {
         return new Aphront404Response();
     }
     $this->setUser($user);
     $profile = $user->loadUserProfile();
     $picture = $user->getProfileImageURI();
     $profile_icon = PhabricatorPeopleIconSet::getIconIcon($profile->getIcon());
     $profile_icon = id(new PHUIIconView())->setIcon($profile_icon);
     $profile_title = $profile->getDisplayTitle();
     $header = id(new PHUIHeaderView())->setHeader($user->getFullName())->setSubheader(array($profile_icon, $profile_title))->setImage($picture)->setProfileHeader(true);
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $user, PhabricatorPolicyCapability::CAN_EDIT);
     if ($can_edit) {
         $id = $user->getID();
         $header->setImageEditURL($this->getApplicationURI("picture/{$id}/"));
     }
     $properties = $this->buildPropertyView($user);
     $name = $user->getUsername();
     $feed = $this->buildPeopleFeed($user, $viewer);
     $feed = phutil_tag_div('project-view-feed', $feed);
     $projects = $this->buildProjectsView($user);
     $badges = $this->buildBadgesView($user);
     $columns = id(new PHUITwoColumnView())->addClass('project-view-badges')->setMainColumn(array($properties, $feed))->setSideColumn(array($projects, $badges));
     $nav = $this->getProfileMenu();
     $nav->selectFilter(PhabricatorPeopleProfilePanelEngine::PANEL_PROFILE);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->setBorder(true);
     require_celerity_resource('project-view-css');
     $home = phutil_tag('div', array('class' => 'project-view-home'), array($header, $columns));
     return $this->newPage()->setTitle($user->getUsername())->setNavigation($nav)->setCrumbs($crumbs)->appendChild(array($home));
 }
开发者ID:kalsolio,项目名称:phabricator,代码行数:35,代码来源:PhabricatorPeopleProfileViewController.php

示例14: render

 public function render()
 {
     require_celerity_resource('conpherence-menu-css');
     require_celerity_resource('conpherence-message-pane-css');
     require_celerity_resource('conpherence-participant-pane-css');
     $layout_id = 'conpherence-main-layout';
     $selected_id = null;
     $selected_thread_id = null;
     $selected_thread_phid = null;
     $can_edit_selected = null;
     $nux = null;
     if ($this->thread) {
         $selected_id = $this->thread->getPHID() . '-nav-item';
         $selected_thread_id = $this->thread->getID();
         $selected_thread_phid = $this->thread->getPHID();
         $can_edit_selected = PhabricatorPolicyFilter::hasCapability($this->getUser(), $this->thread, PhabricatorPolicyCapability::CAN_EDIT);
     } else {
         $nux = $this->buildNUXView();
     }
     $this->initBehavior('conpherence-menu', array('baseURI' => $this->baseURI, 'layoutID' => $layout_id, 'selectedID' => $selected_id, 'selectedThreadID' => $selected_thread_id, 'selectedThreadPHID' => $selected_thread_phid, 'canEditSelectedThread' => $can_edit_selected, 'latestTransactionID' => $this->latestTransactionID, 'role' => $this->role, 'hasThreadList' => (bool) $this->threadView, 'hasThread' => (bool) $this->messages, 'hasWidgets' => false));
     $classes = array();
     if (!$this->getUser()->isLoggedIn()) {
         $classes[] = 'conpherence-logged-out';
     }
     if (!$this->getWidgetColumnVisible()) {
         $classes[] = 'hide-widgets';
     }
     $this->initBehavior('conpherence-participant-pane');
     return javelin_tag('div', array('id' => $layout_id, 'sigil' => 'conpherence-layout', 'class' => 'conpherence-layout ' . implode(' ', $classes) . ' conpherence-role-' . $this->role), array(javelin_tag('div', array('id' => 'conpherence-menu-pane', 'class' => 'conpherence-menu-pane phabricator-side-menu', 'sigil' => 'conpherence-menu-pane'), $this->threadView), javelin_tag('div', array('class' => 'conpherence-content-pane'), array(javelin_tag('div', array('class' => 'conpherence-header-pane', 'id' => 'conpherence-header-pane', 'sigil' => 'conpherence-header-pane'), nonempty($this->header, '')), javelin_tag('div', array('class' => 'conpherence-no-threads', 'sigil' => 'conpherence-no-threads', 'style' => 'display: none;'), $nux), javelin_tag('div', array('class' => 'conpherence-participant-pane', 'id' => 'conpherence-participant-pane', 'sigil' => 'conpherence-participant-pane'), array(phutil_tag('div', array('class' => 'widgets-loading-mask'), ''), javelin_tag('div', array('sigil' => 'conpherence-widgets-holder'), ''))), javelin_tag('div', array('class' => 'conpherence-message-pane', 'id' => 'conpherence-message-pane', 'sigil' => 'conpherence-message-pane'), array(javelin_tag('div', array('class' => 'conpherence-messages', 'id' => 'conpherence-messages', 'sigil' => 'conpherence-messages'), nonempty($this->messages, '')), phutil_tag('div', array('class' => 'messages-loading-mask'), ''), javelin_tag('div', array('id' => 'conpherence-form', 'sigil' => 'conpherence-form'), nonempty($this->replyForm, ''))))))));
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:30,代码来源:ConpherenceLayoutView.php

示例15: buildLocalNavigation

 protected function buildLocalNavigation(PhabricatorProject $project)
 {
     $id = $project->getID();
     $nav_view = new AphrontSideNavFilterView();
     $uri = new PhutilURI('/project/view/' . $id . '/');
     $nav_view->setBaseURI($uri);
     $external_arrow = "↗";
     $tasks_uri = '/maniphest/view/all/?projects=' . $project->getPHID();
     $slug = PhabricatorSlug::normalize($project->getName());
     $phriction_uri = '/w/projects/' . $slug;
     $edit_uri = '/project/edit/' . $id . '/';
     $members_uri = '/project/members/' . $id . '/';
     $nav_view->addFilter('dashboard', 'Dashboard');
     $nav_view->addSpacer();
     $nav_view->addFilter('feed', 'Feed');
     $nav_view->addFilter(null, 'Tasks ' . $external_arrow, $tasks_uri);
     $nav_view->addFilter(null, 'Wiki ' . $external_arrow, $phriction_uri);
     $nav_view->addFilter('people', 'People');
     $nav_view->addFilter('about', 'About');
     $user = $this->getRequest()->getUser();
     $can_edit = PhabricatorPolicyCapability::CAN_EDIT;
     $nav_view->addSpacer();
     if (PhabricatorPolicyFilter::hasCapability($user, $project, $can_edit)) {
         $nav_view->addFilter('edit', "Edit Project…", $edit_uri);
         $nav_view->addFilter('members', "Edit Members…", $members_uri);
     } else {
         $nav_view->addFilter('edit', "Edit Project…", $edit_uri, $relative = false, 'disabled');
         $nav_view->addFilter('members', "Edit Members…", $members_uri, $relative = false, 'disabled');
     }
     return $nav_view;
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:31,代码来源:PhabricatorProjectController.php


注:本文中的PhabricatorPolicyFilter::hasCapability方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。