@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Give AphrontTagView a `getViewer()`, deprecate `getUser()`

Summary:
Two minor changes here:

- Replace `get/setUser()` with `get/setViewer()` for consistency with everything else.
- `getViewer()` now throws if no viewer is set. We had a lot of code that either "should" check this but didn't, or did check it in an identical way, duplicating work. In contrast, very little code checks for a viewer but works if one is not present.

Test Plan:
- Grepped for `->user`.
- Attempted to fix all callsites inside `*View` classes.
- Browsed around a bunch of applications, particularly Calendar, Differential and Diffusion, which seemed most heavily affected.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D15412

+133 -125
+1 -2
src/applications/badges/view/PhabricatorBadgesRecipientsListView.php
··· 16 16 } 17 17 18 18 public function render() { 19 - 20 - $viewer = $this->user; 19 + $viewer = $this->getViewer(); 21 20 22 21 $badge = $this->badge; 23 22 $handles = $this->handles;
+3 -6
src/applications/daemon/view/PhabricatorDaemonLogEventsView.php
··· 24 24 } 25 25 26 26 public function render() { 27 + $viewer = $this->getViewer(); 27 28 $rows = array(); 28 - 29 - if (!$this->user) { 30 - throw new PhutilInvalidStateException('setUser'); 31 - } 32 29 33 30 foreach ($this->events as $event) { 34 31 ··· 83 80 84 81 $row = array( 85 82 $event->getLogType(), 86 - phabricator_date($event->getEpoch(), $this->user), 87 - phabricator_time($event->getEpoch(), $this->user), 83 + phabricator_date($event->getEpoch(), $viewer), 84 + phabricator_time($event->getEpoch(), $viewer), 88 85 array( 89 86 $message, 90 87 $more,
+3 -5
src/applications/daemon/view/PhabricatorDaemonLogListView.php
··· 11 11 } 12 12 13 13 public function render() { 14 - $rows = array(); 14 + $viewer = $this->getViewer(); 15 15 16 - if (!$this->user) { 17 - throw new PhutilInvalidStateException('setUser'); 18 - } 16 + $rows = array(); 19 17 20 18 $list = new PHUIObjectItemListView(); 21 19 $list->setFlush(true); ··· 27 25 ->setObjectName(pht('Daemon %s', $id)) 28 26 ->setHeader($log->getDaemon()) 29 27 ->setHref("/daemon/log/{$id}/") 30 - ->addIcon('none', phabricator_datetime($epoch, $this->user)); 28 + ->addIcon('none', phabricator_datetime($epoch, $viewer)); 31 29 32 30 $status = $log->getStatus(); 33 31 switch ($status) {
+3 -2
src/applications/differential/view/DifferentialAddCommentView.php
··· 50 50 } 51 51 52 52 public function render() { 53 + $viewer = $this->getViewer(); 53 54 54 55 $this->requireResource('differential-revision-add-comment-css'); 55 56 $revision = $this->revision; ··· 73 74 $form = new AphrontFormView(); 74 75 $form 75 76 ->setWorkflow(true) 76 - ->setUser($this->user) 77 + ->setViewer($viewer) 77 78 ->setAction($this->actionURI) 78 79 ->addHiddenInput('revision_id', $revision->getID()) 79 80 ->appendChild( ··· 108 109 ->setID('comment-content') 109 110 ->setLabel(pht('Comment')) 110 111 ->setValue($this->draft ? $this->draft->getDraft() : null) 111 - ->setUser($this->user)) 112 + ->setViewer($viewer)) 112 113 ->appendChild( 113 114 id(new AphrontFormSubmitControl()) 114 115 ->setValue(pht('Submit')));
+8 -6
src/applications/differential/view/DifferentialChangesetListView.php
··· 113 113 } 114 114 115 115 public function render() { 116 + $viewer = $this->getViewer(); 117 + 116 118 $this->requireResource('differential-changeset-view-css'); 117 119 118 120 $changesets = $this->changesets; ··· 148 150 )); 149 151 150 152 $renderer = DifferentialChangesetParser::getDefaultRendererForViewer( 151 - $this->getUser()); 153 + $viewer); 152 154 153 155 $output = array(); 154 156 $ids = array(); ··· 163 165 $ref = $this->references[$key]; 164 166 165 167 $detail = id(new DifferentialChangesetDetailView()) 166 - ->setUser($this->getUser()); 168 + ->setUser($viewer); 167 169 168 170 $uniq_id = 'diff-'.$changeset->getAnchorName(); 169 171 $detail->setID($uniq_id); ··· 261 263 DifferentialChangesetDetailView $detail, 262 264 $ref, 263 265 DifferentialChangeset $changeset) { 266 + $viewer = $this->getViewer(); 264 267 265 268 $meta = array(); 266 269 ··· 280 283 try { 281 284 $meta['diffusionURI'] = 282 285 (string)$repository->getDiffusionBrowseURIForPath( 283 - $this->user, 286 + $viewer, 284 287 $changeset->getAbsoluteRepositoryPath($repository, $this->diff), 285 288 idx($changeset->getMetadata(), 'line:first'), 286 289 $this->getBranch()); ··· 308 311 } 309 312 } 310 313 311 - $user = $this->user; 312 - if ($user && $repository) { 314 + if ($viewer && $repository) { 313 315 $path = ltrim( 314 316 $changeset->getAbsoluteRepositoryPath($repository, $this->diff), 315 317 '/'); 316 318 $line = idx($changeset->getMetadata(), 'line:first', 1); 317 - $editor_link = $user->loadEditorLink($path, $line, $repository); 319 + $editor_link = $viewer->loadEditorLink($path, $line, $repository); 318 320 if ($editor_link) { 319 321 $meta['editor'] = $editor_link; 320 322 } else {
+2 -5
src/applications/differential/view/DifferentialLocalCommitsView.php
··· 17 17 } 18 18 19 19 public function render() { 20 - $user = $this->user; 21 - if (!$user) { 22 - throw new PhutilInvalidStateException('setUser'); 23 - } 20 + $viewer = $this->getViewer(); 24 21 25 22 $local = $this->localCommits; 26 23 if (!$local) { ··· 94 91 idx($commit, 'date'), 95 92 idx($commit, 'time')); 96 93 if ($date) { 97 - $date = phabricator_datetime($date, $user); 94 + $date = phabricator_datetime($date, $viewer); 98 95 } 99 96 $row[] = $date; 100 97
+4 -7
src/applications/differential/view/DifferentialRevisionListView.php
··· 57 57 } 58 58 59 59 public function render() { 60 - $user = $this->user; 61 - if (!$user) { 62 - throw new PhutilInvalidStateException('setUser'); 63 - } 60 + $viewer = $this->getViewer(); 64 61 65 62 $fresh = PhabricatorEnv::getEnvConfig('differential.days-fresh'); 66 63 if ($fresh) { ··· 83 80 84 81 foreach ($this->revisions as $revision) { 85 82 $item = id(new PHUIObjectItemView()) 86 - ->setUser($user); 83 + ->setUser($viewer); 87 84 88 85 $icons = array(); 89 86 90 87 $phid = $revision->getPHID(); 91 - $flag = $revision->getFlag($user); 88 + $flag = $revision->getFlag($viewer); 92 89 if ($flag) { 93 90 $flag_class = PhabricatorFlagColor::getCSSClass($flag->getColor()); 94 91 $icons['flag'] = phutil_tag( ··· 99 96 ''); 100 97 } 101 98 102 - if ($revision->getDrafts($user)) { 99 + if ($revision->getDrafts($viewer)) { 103 100 $icons['draft'] = true; 104 101 } 105 102
+1 -1
src/applications/diffusion/view/DiffusionTagListView.php
··· 100 100 $build, 101 101 $author, 102 102 $description, 103 - phabricator_datetime($tag->getEpoch(), $this->user), 103 + phabricator_datetime($tag->getEpoch(), $this->getViewer()), 104 104 ); 105 105 } 106 106
-6
src/applications/phame/view/PhameBlogListView.php
··· 3 3 final class PhameBlogListView extends AphrontTagView { 4 4 5 5 private $blogs; 6 - private $viewer; 7 6 8 7 public function setBlogs($blogs) { 9 8 assert_instances_of($blogs, 'PhameBlog'); 10 9 $this->blogs = $blogs; 11 - return $this; 12 - } 13 - 14 - public function setViewer($viewer) { 15 - $this->viewer = $viewer; 16 10 return $this; 17 11 } 18 12
-6
src/applications/phame/view/PhameDraftListView.php
··· 4 4 5 5 private $posts; 6 6 private $blogs; 7 - private $viewer; 8 7 9 8 public function setPosts($posts) { 10 9 assert_instances_of($posts, 'PhamePost'); ··· 15 14 public function setBlogs($blogs) { 16 15 assert_instances_of($blogs, 'PhameBlog'); 17 16 $this->blogs = $blogs; 18 - return $this; 19 - } 20 - 21 - public function setViewer($viewer) { 22 - $this->viewer = $viewer; 23 17 return $this; 24 18 } 25 19
+1 -7
src/applications/phame/view/PhamePostListView.php
··· 4 4 5 5 private $posts; 6 6 private $nodata; 7 - private $viewer; 8 7 private $showBlog = false; 9 8 private $isExternal; 10 9 private $isLive; ··· 22 21 23 22 public function showBlog($show) { 24 23 $this->showBlog = $show; 25 - return $this; 26 - } 27 - 28 - public function setViewer($viewer) { 29 - $this->viewer = $viewer; 30 24 return $this; 31 25 } 32 26 ··· 53 47 } 54 48 55 49 protected function getTagContent() { 56 - $viewer = $this->viewer; 50 + $viewer = $this->getViewer(); 57 51 $posts = $this->posts; 58 52 $nodata = $this->nodata; 59 53
+3 -3
src/applications/ponder/view/PonderAddAnswerView.php
··· 18 18 19 19 public function render() { 20 20 $question = $this->question; 21 - $viewer = $this->user; 21 + $viewer = $this->getViewer(); 22 22 23 23 $authors = mpull($question->getAnswers(), null, 'getAuthorPHID'); 24 24 if (isset($authors[$viewer->getPHID()])) { ··· 49 49 50 50 $form = new AphrontFormView(); 51 51 $form 52 - ->setUser($this->user) 52 + ->setViewer($viewer) 53 53 ->setAction($this->actionURI) 54 54 ->setWorkflow(true) 55 55 ->addHiddenInput('question_id', $question->getID()) ··· 59 59 ->setLabel(pht('Answer')) 60 60 ->setError(true) 61 61 ->setID('answer-content') 62 - ->setUser($this->user)) 62 + ->setViewer($viewer)) 63 63 ->appendChild( 64 64 id(new AphrontFormSubmitControl()) 65 65 ->setValue(pht('Add Answer')));
+1 -1
src/applications/project/view/PhabricatorProjectUserListView.php
··· 45 45 abstract protected function getHeaderText(); 46 46 47 47 public function render() { 48 - $viewer = $this->getUser(); 48 + $viewer = $this->getViewer(); 49 49 $project = $this->getProject(); 50 50 $user_phids = $this->getUserPHIDs(); 51 51
+3 -4
src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php
··· 78 78 if (!$this->uri) { 79 79 throw new PhutilInvalidStateException('setSubmitURI'); 80 80 } 81 - if (!$this->user) { 82 - throw new PhutilInvalidStateException('setUser'); 83 - } 81 + 82 + $viewer = $this->getViewer(); 84 83 85 84 $content = phabricator_form( 86 - $this->user, 85 + $viewer, 87 86 array( 88 87 'action' => $this->uri, 89 88 'method' => 'POST',
+4 -4
src/view/AphrontDialogView.php
··· 236 236 $this->cancelText); 237 237 } 238 238 239 - if (!$this->user) { 239 + if (!$this->hasViewer()) { 240 240 throw new Exception( 241 241 pht( 242 242 'You must call %s when rendering an %s.', 243 - 'setUser()', 243 + 'setViewer()', 244 244 __CLASS__)); 245 245 } 246 246 ··· 308 308 if (!$this->renderAsForm) { 309 309 $buttons = array( 310 310 phabricator_form( 311 - $this->user, 311 + $this->getViewer(), 312 312 $form_attributes, 313 313 array_merge($hidden_inputs, $buttons)), 314 314 ); ··· 376 376 377 377 if ($this->renderAsForm) { 378 378 return phabricator_form( 379 - $this->user, 379 + $this->getViewer(), 380 380 $form_attributes + $attributes, 381 381 array($hidden_inputs, $content)); 382 382 } else {
+50 -4
src/view/AphrontView.php
··· 6 6 abstract class AphrontView extends Phobject 7 7 implements PhutilSafeHTMLProducerInterface { 8 8 9 - protected $user; 9 + private $viewer; 10 10 protected $children = array(); 11 11 12 12 ··· 14 14 15 15 16 16 /** 17 + * Set the user viewing this element. 18 + * 19 + * @param PhabricatorUser Viewing user. 20 + * @return this 21 + */ 22 + public function setViewer(PhabricatorUser $viewer) { 23 + $this->viewer = $viewer; 24 + return $this; 25 + } 26 + 27 + 28 + /** 29 + * Get the user viewing this element. 30 + * 31 + * Throws an exception if no viewer has been set. 32 + * 33 + * @return PhabricatorUser Viewing user. 34 + */ 35 + public function getViewer() { 36 + if (!$this->viewer) { 37 + throw new PhutilInvalidStateException('setViewer'); 38 + } 39 + 40 + return $this->viewer; 41 + } 42 + 43 + 44 + /** 45 + * Test if a viewer has been set on this elmeent. 46 + * 47 + * @return bool True if a viewer is available. 48 + */ 49 + public function hasViewer() { 50 + return (bool)$this->viewer; 51 + } 52 + 53 + 54 + /** 55 + * Deprecated, use @{method:setViewer}. 56 + * 17 57 * @task config 58 + * @deprecated 18 59 */ 19 60 public function setUser(PhabricatorUser $user) { 20 - $this->user = $user; 21 - return $this; 61 + return $this->setViewer($user); 22 62 } 23 63 24 64 25 65 /** 66 + * Deprecated, use @{method:getViewer}. 67 + * 26 68 * @task config 69 + * @deprecated 27 70 */ 28 71 protected function getUser() { 29 - return $this->user; 72 + if (!$this->hasViewer()) { 73 + return null; 74 + } 75 + return $this->getViewer(); 30 76 } 31 77 32 78
+4 -4
src/view/form/AphrontFormView.php
··· 85 85 86 86 public function appendRemarkupInstructions($remarkup) { 87 87 return $this->appendInstructions( 88 - new PHUIRemarkupView($this->getUser(), $remarkup)); 88 + new PHUIRemarkupView($this->getViewer(), $remarkup)); 89 89 90 90 } 91 91 92 92 public function buildLayoutView() { 93 93 foreach ($this->controls as $control) { 94 - $control->setUser($this->getUser()); 94 + $control->setViewer($this->getViewer()); 95 95 $control->willRender(); 96 96 } 97 97 ··· 123 123 124 124 $layout = $this->buildLayoutView(); 125 125 126 - if (!$this->user) { 126 + if (!$this->hasViewer()) { 127 127 throw new Exception( 128 128 pht( 129 129 'You must pass the user to %s.', ··· 136 136 } 137 137 138 138 return phabricator_form( 139 - $this->user, 139 + $this->getViewer(), 140 140 array( 141 141 'class' => $this->shaded ? 'phui-form-shaded' : null, 142 142 'action' => $this->action,
+6 -9
src/view/form/control/AphrontFormDateControl.php
··· 137 137 } 138 138 139 139 private function getTimeFormat() { 140 - return $this->getUser() 140 + return $this->getViewer() 141 141 ->getPreference(PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT); 142 142 } 143 143 144 144 private function getDateFormat() { 145 - return $this->getUser() 145 + return $this->getViewer() 146 146 ->getPreference(PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT); 147 147 } 148 148 ··· 153 153 private function formatTime($epoch, $fmt) { 154 154 return phabricator_format_local_time( 155 155 $epoch, 156 - $this->user, 156 + $this->getViewer(), 157 157 $fmt); 158 158 } 159 159 ··· 259 259 ), 260 260 $time_sel); 261 261 262 - $preferences = $this->user->loadPreferences(); 262 + $preferences = $this->getViewer()->loadPreferences(); 263 263 $pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY; 264 264 $week_start = $preferences->getPreference($pref_week_start, 0); 265 265 ··· 300 300 return $this->zone; 301 301 } 302 302 303 - $user = $this->getUser(); 304 - if (!$this->getUser()) { 305 - throw new PhutilInvalidStateException('setUser'); 306 - } 303 + $viewer = $this->getViewer(); 307 304 308 - $user_zone = $user->getTimezoneIdentifier(); 305 + $user_zone = $viewer->getTimezoneIdentifier(); 309 306 $this->zone = new DateTimeZone($user_zone); 310 307 return $this->zone; 311 308 }
+2 -2
src/view/form/control/AphrontFormTokenizerControl.php
··· 90 90 } 91 91 92 92 $username = null; 93 - if ($this->user) { 94 - $username = $this->user->getUsername(); 93 + if ($this->hasViewer()) { 94 + $username = $this->getViewer()->getUsername(); 95 95 } 96 96 97 97 $datasource_uri = $datasource->getDatasourceURI();
-3
src/view/layout/AphrontSideNavFilterView.php
··· 199 199 } 200 200 201 201 private function renderFlexNav() { 202 - 203 - $user = $this->user; 204 - 205 202 require_celerity_resource('phabricator-nav-view-css'); 206 203 207 204 $nav_classes = array();
+3 -5
src/view/layout/PhabricatorActionListView.php
··· 22 22 } 23 23 24 24 public function render() { 25 - if (!$this->user) { 26 - throw new PhutilInvalidStateException('setUser'); 27 - } 25 + $viewer = $this->getViewer(); 28 26 29 27 $event = new PhabricatorEvent( 30 28 PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS, ··· 32 30 'object' => $this->object, 33 31 'actions' => $this->actions, 34 32 )); 35 - $event->setUser($this->user); 33 + $event->setUser($viewer); 36 34 PhutilEventEngine::dispatchEvent($event); 37 35 38 36 $actions = $event->getValue('actions'); ··· 41 39 } 42 40 43 41 foreach ($actions as $action) { 44 - $action->setUser($this->user); 42 + $action->setViewer($viewer); 45 43 } 46 44 47 45 require_celerity_resource('phabricator-action-list-view-css');
+3 -3
src/view/layout/PhabricatorActionView.php
··· 125 125 $sigils = $sigils ? implode(' ', $sigils) : null; 126 126 127 127 if ($this->renderAsForm) { 128 - if (!$this->user) { 128 + if (!$this->hasViewer()) { 129 129 throw new Exception( 130 130 pht( 131 131 'Call %s when rendering an action as a form.', 132 - 'setUser()')); 132 + 'setViewer()')); 133 133 } 134 134 135 135 $item = javelin_tag( ··· 140 140 array($icon, $this->name)); 141 141 142 142 $item = phabricator_form( 143 - $this->user, 143 + $this->getViewer(), 144 144 array( 145 145 'action' => $this->getHref(), 146 146 'method' => 'POST',
+3 -3
src/view/page/menu/PhabricatorMainMenuSearchView.php
··· 24 24 } 25 25 26 26 public function render() { 27 - $user = $this->user; 27 + $viewer = $this->getViewer(); 28 28 29 29 $target_id = celerity_generate_unique_node_id(); 30 30 $search_id = $this->getID(); ··· 86 86 $selector = $this->buildModeSelector($selector_id, $application_id); 87 87 88 88 $form = phabricator_form( 89 - $user, 89 + $viewer, 90 90 array( 91 91 'action' => '/search/', 92 92 'method' => 'POST', ··· 109 109 } 110 110 111 111 private function buildModeSelector($selector_id, $application_id) { 112 - $viewer = $this->getUser(); 112 + $viewer = $this->getViewer(); 113 113 114 114 $items = array(); 115 115 $items[] = array(
+14 -14
src/view/page/menu/PhabricatorMainMenuView.php
··· 24 24 } 25 25 26 26 public function render() { 27 - $user = $this->user; 27 + $viewer = $this->getViewer(); 28 28 29 29 require_celerity_resource('phabricator-main-menu-view'); 30 30 ··· 35 35 $app_button = ''; 36 36 $aural = null; 37 37 38 - if ($user->isLoggedIn() && $user->isUserActivated()) { 38 + if ($viewer->isLoggedIn() && $viewer->isUserActivated()) { 39 39 list($menu, $dropdowns, $aural) = $this->renderNotificationMenu(); 40 40 if (array_filter($menu)) { 41 41 $alerts[] = $menu; ··· 77 77 $controller = $this->getController(); 78 78 foreach ($applications as $application) { 79 79 $app_actions = $application->buildMainMenuItems( 80 - $user, 80 + $viewer, 81 81 $controller); 82 82 $app_extra = $application->buildMainMenuExtraNodes( 83 - $user, 83 + $viewer, 84 84 $controller); 85 85 86 86 foreach ($app_actions as $action) { ··· 97 97 98 98 $extensions = PhabricatorMainMenuBarExtension::getAllEnabledExtensions(); 99 99 foreach ($extensions as $extension) { 100 - $extension->setViewer($user); 100 + $extension->setViewer($viewer); 101 101 102 102 $controller = $this->getController(); 103 103 if ($controller) { ··· 158 158 } 159 159 160 160 private function renderSearch() { 161 - $user = $this->user; 161 + $viewer = $this->getViewer(); 162 162 163 163 $result = null; 164 164 ··· 166 166 'helpURI' => '/help/keyboardshortcut/', 167 167 ); 168 168 169 - if ($user->isLoggedIn()) { 170 - $show_search = $user->isUserActivated(); 169 + if ($viewer->isLoggedIn()) { 170 + $show_search = $viewer->isUserActivated(); 171 171 } else { 172 172 $show_search = PhabricatorEnv::getEnvConfig('policy.allow-public'); 173 173 } 174 174 175 175 if ($show_search) { 176 176 $search = new PhabricatorMainMenuSearchView(); 177 - $search->setUser($user); 177 + $search->setViewer($viewer); 178 178 179 179 $application = null; 180 180 $controller = $this->getController(); ··· 188 188 $result = $search; 189 189 190 190 $pref_shortcut = PhabricatorUserPreferences::PREFERENCE_SEARCH_SHORTCUT; 191 - if ($user->loadPreferences()->getPreference($pref_shortcut, true)) { 191 + if ($viewer->loadPreferences()->getPreference($pref_shortcut, true)) { 192 192 $keyboard_config['searchID'] = $search->getID(); 193 193 } 194 194 } ··· 230 230 } 231 231 232 232 private function renderApplicationMenu(array $bar_items) { 233 - $user = $this->getUser(); 233 + $viewer = $this->getViewer(); 234 234 235 235 $view = $this->getApplicationMenu(); 236 236 ··· 302 302 $logo_uri = $cache->getKey($cache_key_logo); 303 303 if (!$logo_uri) { 304 304 $file = id(new PhabricatorFileQuery()) 305 - ->setViewer($this->getUser()) 305 + ->setViewer($this->getViewer()) 306 306 ->withPHIDs(array($custom_header)) 307 307 ->executeOne(); 308 308 if ($file) { ··· 355 355 } 356 356 357 357 private function renderNotificationMenu() { 358 - $user = $this->user; 358 + $viewer = $this->getViewer(); 359 359 360 360 require_celerity_resource('phabricator-notification-css'); 361 361 require_celerity_resource('phabricator-notification-menu-css'); ··· 364 364 $aural = array(); 365 365 366 366 $dropdown_query = id(new AphlictDropdownDataQuery()) 367 - ->setViewer($user); 367 + ->setViewer($viewer); 368 368 $dropdown_data = $dropdown_query->execute(); 369 369 370 370 $message_tag = '';
+2 -2
src/view/phui/PHUIFeedStoryView.php
··· 172 172 if ($this->epoch) { 173 173 // TODO: This is really bad; when rendering through Conduit and via 174 174 // renderText() we don't have a user. 175 - if ($this->user) { 176 - $foot = phabricator_datetime($this->epoch, $this->user); 175 + if ($this->hasViewer()) { 176 + $foot = phabricator_datetime($this->epoch, $this->getViewer()); 177 177 } else { 178 178 $foot = null; 179 179 }
+3 -3
src/view/phui/calendar/PHUICalendarDayView.php
··· 278 278 ->addClass('calendar-day-view-sidebar'); 279 279 280 280 $list = id(new PHUICalendarListView()) 281 - ->setUser($this->user) 281 + ->setUser($this->getViewer()) 282 282 ->setView('day'); 283 283 284 284 if (count($events) == 0) { ··· 304 304 305 305 $box_start_time = clone $display_start_day; 306 306 307 - $today_time = PhabricatorTime::getTodayMidnightDateTime($this->user); 307 + $today_time = PhabricatorTime::getTodayMidnightDateTime($this->getViewer()); 308 308 $tomorrow_time = clone $today_time; 309 309 $tomorrow_time->modify('+1 day'); 310 310 ··· 437 437 } 438 438 439 439 private function getDateTime() { 440 - $user = $this->user; 440 + $user = $this->getViewer(); 441 441 $timezone = new DateTimeZone($user->getTimezoneIdentifier()); 442 442 443 443 $day = $this->day;
+6 -8
src/view/phui/calendar/PHUICalendarMonthView.php
··· 51 51 } 52 52 53 53 public function render() { 54 - if (empty($this->user)) { 55 - throw new PhutilInvalidStateException('setUser'); 56 - } 54 + $viewer = $this->getViewer(); 57 55 58 56 $events = msort($this->events, 'getEpochStart'); 59 57 $days = $this->getDatesInMonth(); ··· 93 91 $counter = 0; 94 92 95 93 $list = new PHUICalendarListView(); 96 - $list->setUser($this->user); 94 + $list->setViewer($viewer); 97 95 foreach ($all_day_events as $item) { 98 96 if ($counter <= $max_daily) { 99 97 $list->addEvent($item); ··· 495 493 * @return list List of DateTimes, one for each day. 496 494 */ 497 495 private function getDatesInMonth() { 498 - $user = $this->user; 496 + $viewer = $this->getViewer(); 499 497 500 - $timezone = new DateTimeZone($user->getTimezoneIdentifier()); 498 + $timezone = new DateTimeZone($viewer->getTimezoneIdentifier()); 501 499 502 500 $month = $this->month; 503 501 $year = $this->year; ··· 575 573 } 576 574 577 575 private function getWeekStartAndEnd() { 578 - $preferences = $this->user->loadPreferences(); 576 + $preferences = $this->getViewer()->loadPreferences(); 579 577 $pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY; 580 578 581 579 $week_start = $preferences->getPreference($pref_week_start, 0); ··· 585 583 } 586 584 587 585 private function getDateTime() { 588 - $user = $this->user; 586 + $user = $this->getViewer(); 589 587 $timezone = new DateTimeZone($user->getTimezoneIdentifier()); 590 588 591 589 $month = $this->month;