@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.

Support export of feed transactions to CSV/Excel/etc

Summary: Depends on D20534. Ref T13294. Add export support so you can dump these out, print them on paper, notarize them, and store them in a box under a tree or whatever.

Test Plan: Exported transactions to a flat file, read the file.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13294

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

+84
+8
src/applications/feed/query/PhabricatorFeedTransactionQuery.php
··· 30 30 return $this; 31 31 } 32 32 33 + public function newResultObject() { 34 + // Return an arbitrary valid transaction object. The actual query may 35 + // return objects of any subclass of "ApplicationTransaction" when it is 36 + // executed, but we need to pick something concrete here to make some 37 + // integrations work (like automatic handling of PHIDs in data export). 38 + return new PhabricatorUserTransaction(); 39 + } 40 + 33 41 protected function loadPage() { 34 42 $queries = $this->newTransactionQueries(); 35 43
+76
src/applications/feed/query/PhabricatorFeedTransactionSearchEngine.php
··· 151 151 ->setTable($table); 152 152 } 153 153 154 + protected function newExportFields() { 155 + $fields = array( 156 + id(new PhabricatorPHIDExportField()) 157 + ->setKey('authorPHID') 158 + ->setLabel(pht('Author PHID')), 159 + id(new PhabricatorStringExportField()) 160 + ->setKey('author') 161 + ->setLabel(pht('Author')), 162 + id(new PhabricatorStringExportField()) 163 + ->setKey('objectType') 164 + ->setLabel(pht('Object Type')), 165 + id(new PhabricatorPHIDExportField()) 166 + ->setKey('objectPHID') 167 + ->setLabel(pht('Object PHID')), 168 + id(new PhabricatorStringExportField()) 169 + ->setKey('objectName') 170 + ->setLabel(pht('Object Name')), 171 + id(new PhabricatorStringExportField()) 172 + ->setKey('description') 173 + ->setLabel(pht('Description')), 174 + ); 175 + 176 + return $fields; 177 + } 178 + 179 + protected function newExportData(array $xactions) { 180 + $viewer = $this->requireViewer(); 181 + 182 + $phids = array(); 183 + foreach ($xactions as $xaction) { 184 + $phids[] = $xaction->getAuthorPHID(); 185 + $phids[] = $xaction->getObjectPHID(); 186 + } 187 + $handles = $viewer->loadHandles($phids); 188 + 189 + $export = array(); 190 + foreach ($xactions as $xaction) { 191 + $xaction_phid = $xaction->getPHID(); 192 + 193 + $author_phid = $xaction->getAuthorPHID(); 194 + if ($author_phid) { 195 + $author_name = $handles[$author_phid]->getName(); 196 + } else { 197 + $author_name = null; 198 + } 199 + 200 + $object_phid = $xaction->getObjectPHID(); 201 + if ($object_phid) { 202 + $object_name = $handles[$object_phid]->getName(); 203 + } else { 204 + $object_name = null; 205 + } 206 + 207 + $old_target = $xaction->getRenderingTarget(); 208 + try { 209 + $description = $xaction 210 + ->setRenderingTarget(PhabricatorApplicationTransaction::TARGET_TEXT) 211 + ->getTitle(); 212 + } catch (Exception $ex) { 213 + $description = null; 214 + } 215 + $xaction->setRenderingTarget($old_target); 216 + 217 + $export[] = array( 218 + 'authorPHID' => $author_phid, 219 + 'author' => $author_name, 220 + 'objectType' => phid_get_subtype($xaction_phid), 221 + 'objectPHID' => $object_phid, 222 + 'objectName' => $object_name, 223 + 'description' => $description, 224 + ); 225 + } 226 + 227 + return $export; 228 + } 229 + 154 230 }