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

Make Phame Header and Profile Image Transactional

Summary: Ref T9360. This makes these transactional.

Test Plan: Set new header, delete header. Set new profile image, reset profile image.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9360

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

+126 -14
+16 -3
src/applications/phame/controller/blog/PhameBlogHeaderPictureController.php
··· 53 53 54 54 if (!$errors) { 55 55 if ($delete_header) { 56 - $blog->setHeaderImagePHID(null); 56 + $new_value = null; 57 57 } else { 58 - $blog->setHeaderImagePHID($file->getPHID()); 59 58 $file->attachToObject($blog->getPHID()); 59 + $new_value = $file->getPHID(); 60 60 } 61 - $blog->save(); 61 + 62 + $xactions = array(); 63 + $xactions[] = id(new PhameBlogTransaction()) 64 + ->setTransactionType(PhameBlogTransaction::TYPE_HEADERIMAGE) 65 + ->setNewValue($new_value); 66 + 67 + $editor = id(new PhameBlogEditor()) 68 + ->setActor($viewer) 69 + ->setContentSourceFromRequest($request) 70 + ->setContinueOnMissingFields(true) 71 + ->setContinueOnNoEffect(true); 72 + 73 + $editor->applyTransactions($blog, $xactions); 74 + 62 75 return id(new AphrontRedirectResponse())->setURI($blog_uri); 63 76 } 64 77 }
+16 -3
src/applications/phame/controller/blog/PhameBlogProfilePictureController.php
··· 68 68 69 69 if (!$errors) { 70 70 if ($is_default) { 71 - $blog->setProfileImagePHID(null); 71 + $new_value = null; 72 72 } else { 73 - $blog->setProfileImagePHID($xformed->getPHID()); 74 73 $xformed->attachToObject($blog->getPHID()); 74 + $new_value = $xformed->getPHID(); 75 75 } 76 - $blog->save(); 76 + 77 + $xactions = array(); 78 + $xactions[] = id(new PhameBlogTransaction()) 79 + ->setTransactionType(PhameBlogTransaction::TYPE_PROFILEIMAGE) 80 + ->setNewValue($new_value); 81 + 82 + $editor = id(new PhameBlogEditor()) 83 + ->setActor($viewer) 84 + ->setContentSourceFromRequest($request) 85 + ->setContinueOnMissingFields(true) 86 + ->setContinueOnNoEffect(true); 87 + 88 + $editor->applyTransactions($blog, $xactions); 89 + 77 90 return id(new AphrontRedirectResponse())->setURI($blog_uri); 78 91 } 79 92 }
+15 -1
src/applications/phame/editor/PhameBlogEditor.php
··· 21 21 $types[] = PhameBlogTransaction::TYPE_PARENTSITE; 22 22 $types[] = PhameBlogTransaction::TYPE_PARENTDOMAIN; 23 23 $types[] = PhameBlogTransaction::TYPE_STATUS; 24 + $types[] = PhameBlogTransaction::TYPE_HEADERIMAGE; 25 + $types[] = PhameBlogTransaction::TYPE_PROFILEIMAGE; 26 + 24 27 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 25 28 $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; 26 29 ··· 44 47 return $object->getParentSite(); 45 48 case PhameBlogTransaction::TYPE_PARENTDOMAIN: 46 49 return $object->getParentDomain(); 50 + case PhameBlogTransaction::TYPE_PROFILEIMAGE: 51 + return $object->getProfileImagePHID(); 52 + case PhameBlogTransaction::TYPE_HEADERIMAGE: 53 + return $object->getHeaderImagePHID(); 47 54 case PhameBlogTransaction::TYPE_STATUS: 48 55 return $object->getStatus(); 49 56 } ··· 59 66 case PhameBlogTransaction::TYPE_DESCRIPTION: 60 67 case PhameBlogTransaction::TYPE_STATUS: 61 68 case PhameBlogTransaction::TYPE_PARENTSITE: 62 - case PhameBlogTransaction::TYPE_PARENTDOMAIN: 69 + case PhameBlogTransaction::TYPE_PROFILEIMAGE: 70 + case PhameBlogTransaction::TYPE_HEADERIMAGE: 63 71 return $xaction->getNewValue(); 64 72 case PhameBlogTransaction::TYPE_FULLDOMAIN: 65 73 $domain = $xaction->getNewValue(); ··· 92 100 } 93 101 $object->setDomainFullURI($new_value); 94 102 return; 103 + case PhameBlogTransaction::TYPE_PROFILEIMAGE: 104 + return $object->setProfileImagePHID($xaction->getNewValue()); 105 + case PhameBlogTransaction::TYPE_HEADERIMAGE: 106 + return $object->setHeaderImagePHID($xaction->getNewValue()); 95 107 case PhameBlogTransaction::TYPE_STATUS: 96 108 return $object->setStatus($xaction->getNewValue()); 97 109 case PhameBlogTransaction::TYPE_PARENTSITE: ··· 114 126 case PhameBlogTransaction::TYPE_FULLDOMAIN: 115 127 case PhameBlogTransaction::TYPE_PARENTSITE: 116 128 case PhameBlogTransaction::TYPE_PARENTDOMAIN: 129 + case PhameBlogTransaction::TYPE_HEADERIMAGE: 130 + case PhameBlogTransaction::TYPE_PROFILEIMAGE: 117 131 case PhameBlogTransaction::TYPE_STATUS: 118 132 return; 119 133 }
+79 -7
src/applications/phame/storage/PhameBlogTransaction.php
··· 3 3 final class PhameBlogTransaction 4 4 extends PhabricatorApplicationTransaction { 5 5 6 - const TYPE_NAME = 'phame.blog.name'; 7 - const TYPE_SUBTITLE = 'phame.blog.subtitle'; 8 - const TYPE_DESCRIPTION = 'phame.blog.description'; 9 - const TYPE_FULLDOMAIN = 'phame.blog.full.domain'; 10 - const TYPE_STATUS = 'phame.blog.status'; 11 - const TYPE_PARENTSITE = 'phame.blog.parent.site'; 12 - const TYPE_PARENTDOMAIN = 'phame.blog.parent.domain'; 6 + const TYPE_NAME = 'phame.blog.name'; 7 + const TYPE_SUBTITLE = 'phame.blog.subtitle'; 8 + const TYPE_DESCRIPTION = 'phame.blog.description'; 9 + const TYPE_FULLDOMAIN = 'phame.blog.full.domain'; 10 + const TYPE_STATUS = 'phame.blog.status'; 11 + const TYPE_PARENTSITE = 'phame.blog.parent.site'; 12 + const TYPE_PARENTDOMAIN = 'phame.blog.parent.domain'; 13 + const TYPE_PROFILEIMAGE = 'phame.blog.header.image'; 14 + const TYPE_HEADERIMAGE = 'phame.blog.profile.image'; 13 15 14 16 const MAILTAG_DETAILS = 'phame-blog-details'; 15 17 const MAILTAG_SUBSCRIBERS = 'phame-blog-subscribers'; ··· 34 36 return parent::shouldHide(); 35 37 } 36 38 39 + public function getRequiredHandlePHIDs() { 40 + $old = $this->getOldValue(); 41 + $new = $this->getNewValue(); 42 + 43 + $req_phids = array(); 44 + switch ($this->getTransactionType()) { 45 + case self::TYPE_PROFILEIMAGE: 46 + case self::TYPE_HEADERIMAGE: 47 + $req_phids[] = $old; 48 + $req_phids[] = $new; 49 + break; 50 + } 51 + 52 + return array_merge($req_phids, parent::getRequiredHandlePHIDs()); 53 + } 54 + 37 55 public function getIcon() { 38 56 $old = $this->getOldValue(); 39 57 $new = $this->getNewValue(); ··· 48 66 case self::TYPE_DESCRIPTION: 49 67 case self::TYPE_FULLDOMAIN: 50 68 return 'fa-pencil'; 69 + case self::TYPE_HEADERIMAGE: 70 + return 'fa-image'; 71 + case self::TYPE_PROFILEIMAGE: 72 + return 'fa-star'; 51 73 case self::TYPE_STATUS: 52 74 if ($new == PhameBlog::STATUS_ARCHIVED) { 53 75 return 'fa-ban'; ··· 88 110 case self::TYPE_FULLDOMAIN: 89 111 case self::TYPE_PARENTSITE: 90 112 case self::TYPE_PARENTDOMAIN: 113 + case self::TYPE_PROFILEIMAGE: 114 + case self::TYPE_HEADERIMAGE: 91 115 $tags[] = self::MAILTAG_DETAILS; 92 116 break; 93 117 default: ··· 172 196 $new); 173 197 } 174 198 break; 199 + case self::TYPE_HEADERIMAGE: 200 + if (!$old) { 201 + return pht( 202 + "%s set this blog's header image to %s.", 203 + $this->renderHandleLink($author_phid), 204 + $this->renderHandleLink($new)); 205 + } else if (!$new) { 206 + return pht( 207 + "%s removed this blog's header image.", 208 + $this->renderHandleLink($author_phid)); 209 + } else { 210 + return pht( 211 + "%s updated this blog's header image from %s to %s.", 212 + $this->renderHandleLink($author_phid), 213 + $this->renderHandleLink($old), 214 + $this->renderHandleLink($new)); 215 + } 216 + break; 217 + case self::TYPE_PROFILEIMAGE: 218 + if (!$old) { 219 + return pht( 220 + "%s set this blog's profile image to %s.", 221 + $this->renderHandleLink($author_phid), 222 + $this->renderHandleLink($new)); 223 + } else if (!$new) { 224 + return pht( 225 + "%s removed this blog's profile image.", 226 + $this->renderHandleLink($author_phid)); 227 + } else { 228 + return pht( 229 + "%s updated this blog's profile image from %s to %s.", 230 + $this->renderHandleLink($author_phid), 231 + $this->renderHandleLink($old), 232 + $this->renderHandleLink($new)); 233 + } 234 + break; 175 235 case self::TYPE_STATUS: 176 236 switch ($new) { 177 237 case PhameBlog::STATUS_ACTIVE: ··· 245 305 case self::TYPE_PARENTDOMAIN: 246 306 return pht( 247 307 '%s updated the parent domain for %s.', 308 + $this->renderHandleLink($author_phid), 309 + $this->renderHandleLink($object_phid)); 310 + break; 311 + case self::TYPE_HEADERIMAGE: 312 + return pht( 313 + '%s updated the header image for %s.', 314 + $this->renderHandleLink($author_phid), 315 + $this->renderHandleLink($object_phid)); 316 + break; 317 + case self::TYPE_PROFILEIMAGE: 318 + return pht( 319 + '%s updated the profile image for %s.', 248 320 $this->renderHandleLink($author_phid), 249 321 $this->renderHandleLink($object_phid)); 250 322 break;