public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $chrono_key = $request->getStr('chronoKey');
     if ($request->isDialogFormPost()) {
         $table = new PhabricatorFeedStoryNotification();
         queryfx($table->establishConnection('w'), 'UPDATE %T SET hasViewed = 1 ' . 'WHERE userPHID = %s AND hasViewed = 0 and chronologicalKey <= %s', $table->getTableName(), $viewer->getPHID(), $chrono_key);
         PhabricatorUserCache::clearCache(PhabricatorUserNotificationCountCacheType::KEY_COUNT, $viewer->getPHID());
         return id(new AphrontReloadResponse())->setURI('/notification/');
     }
     $dialog = new AphrontDialogView();
     $dialog->setUser($viewer);
     $dialog->addCancelButton('/notification/');
     if ($chrono_key) {
         $dialog->setTitle(pht('Really mark all notifications as read?'));
         $dialog->addHiddenInput('chronoKey', $chrono_key);
         $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
         if ($is_serious) {
             $dialog->appendChild(pht('All unread notifications will be marked as read. You can not ' . 'undo this action.'));
         } else {
             $dialog->appendChild(pht("You can't ignore your problems forever, you know."));
         }
         $dialog->addSubmitButton(pht('Mark All Read'));
     } else {
         $dialog->setTitle(pht('No notifications to mark as read.'));
         $dialog->appendChild(pht('You have no unread notifications.'));
     }
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 public function markUpToDate(ConpherenceThread $conpherence, ConpherenceTransaction $xaction)
 {
     if (!$this->isUpToDate($conpherence)) {
         $this->setParticipationStatus(ConpherenceParticipationStatus::UP_TO_DATE);
         $this->setBehindTransactionPHID($xaction->getPHID());
         $this->setSeenMessageCount($conpherence->getMessageCount());
         $this->save();
         PhabricatorUserCache::clearCache(PhabricatorUserMessageCountCacheType::KEY_COUNT, $this->getParticipantPHID());
     }
     return $this;
 }
 public static function updateObjectNotificationViews(PhabricatorUser $user, $object_phid)
 {
     if (PhabricatorEnv::isReadOnly()) {
         return;
     }
     $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
     $notification_table = new PhabricatorFeedStoryNotification();
     $conn = $notification_table->establishConnection('w');
     queryfx($conn, 'UPDATE %T
    SET hasViewed = 1
    WHERE userPHID = %s
      AND primaryObjectPHID = %s
      AND hasViewed = 0', $notification_table->getTableName(), $user->getPHID(), $object_phid);
     unset($unguarded);
     $count_key = PhabricatorUserNotificationCountCacheType::KEY_COUNT;
     PhabricatorUserCache::clearCache($count_key, $user->getPHID());
     $user->clearCacheData($count_key);
 }
 protected function applyFinalEffects(PhabricatorLiskDAO $object, array $xactions)
 {
     $user_phid = $object->getUserPHID();
     if ($user_phid) {
         PhabricatorUserCache::clearCache(PhabricatorUserPreferencesCacheType::KEY_PREFERENCES, $user_phid);
     } else {
         PhabricatorUserCache::clearCacheForAllUsers(PhabricatorUserPreferencesCacheType::KEY_PREFERENCES);
     }
     return $xactions;
 }