Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14351512
D16217.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D16217.diff
View Options
diff --git a/src/applications/phame/controller/blog/PhameBlogHeaderPictureController.php b/src/applications/phame/controller/blog/PhameBlogHeaderPictureController.php
--- a/src/applications/phame/controller/blog/PhameBlogHeaderPictureController.php
+++ b/src/applications/phame/controller/blog/PhameBlogHeaderPictureController.php
@@ -53,12 +53,25 @@
if (!$errors) {
if ($delete_header) {
- $blog->setHeaderImagePHID(null);
+ $new_value = null;
} else {
- $blog->setHeaderImagePHID($file->getPHID());
$file->attachToObject($blog->getPHID());
+ $new_value = $file->getPHID();
}
- $blog->save();
+
+ $xactions = array();
+ $xactions[] = id(new PhameBlogTransaction())
+ ->setTransactionType(PhameBlogTransaction::TYPE_HEADERIMAGE)
+ ->setNewValue($new_value);
+
+ $editor = id(new PhameBlogEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnMissingFields(true)
+ ->setContinueOnNoEffect(true);
+
+ $editor->applyTransactions($blog, $xactions);
+
return id(new AphrontRedirectResponse())->setURI($blog_uri);
}
}
diff --git a/src/applications/phame/controller/blog/PhameBlogProfilePictureController.php b/src/applications/phame/controller/blog/PhameBlogProfilePictureController.php
--- a/src/applications/phame/controller/blog/PhameBlogProfilePictureController.php
+++ b/src/applications/phame/controller/blog/PhameBlogProfilePictureController.php
@@ -68,12 +68,25 @@
if (!$errors) {
if ($is_default) {
- $blog->setProfileImagePHID(null);
+ $new_value = null;
} else {
- $blog->setProfileImagePHID($xformed->getPHID());
$xformed->attachToObject($blog->getPHID());
+ $new_value = $xformed->getPHID();
}
- $blog->save();
+
+ $xactions = array();
+ $xactions[] = id(new PhameBlogTransaction())
+ ->setTransactionType(PhameBlogTransaction::TYPE_PROFILEIMAGE)
+ ->setNewValue($new_value);
+
+ $editor = id(new PhameBlogEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnMissingFields(true)
+ ->setContinueOnNoEffect(true);
+
+ $editor->applyTransactions($blog, $xactions);
+
return id(new AphrontRedirectResponse())->setURI($blog_uri);
}
}
diff --git a/src/applications/phame/editor/PhameBlogEditor.php b/src/applications/phame/editor/PhameBlogEditor.php
--- a/src/applications/phame/editor/PhameBlogEditor.php
+++ b/src/applications/phame/editor/PhameBlogEditor.php
@@ -21,6 +21,9 @@
$types[] = PhameBlogTransaction::TYPE_PARENTSITE;
$types[] = PhameBlogTransaction::TYPE_PARENTDOMAIN;
$types[] = PhameBlogTransaction::TYPE_STATUS;
+ $types[] = PhameBlogTransaction::TYPE_HEADERIMAGE;
+ $types[] = PhameBlogTransaction::TYPE_PROFILEIMAGE;
+
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
@@ -44,6 +47,10 @@
return $object->getParentSite();
case PhameBlogTransaction::TYPE_PARENTDOMAIN:
return $object->getParentDomain();
+ case PhameBlogTransaction::TYPE_PROFILEIMAGE:
+ return $object->getProfileImagePHID();
+ case PhameBlogTransaction::TYPE_HEADERIMAGE:
+ return $object->getHeaderImagePHID();
case PhameBlogTransaction::TYPE_STATUS:
return $object->getStatus();
}
@@ -59,7 +66,8 @@
case PhameBlogTransaction::TYPE_DESCRIPTION:
case PhameBlogTransaction::TYPE_STATUS:
case PhameBlogTransaction::TYPE_PARENTSITE:
- case PhameBlogTransaction::TYPE_PARENTDOMAIN:
+ case PhameBlogTransaction::TYPE_PROFILEIMAGE:
+ case PhameBlogTransaction::TYPE_HEADERIMAGE:
return $xaction->getNewValue();
case PhameBlogTransaction::TYPE_FULLDOMAIN:
$domain = $xaction->getNewValue();
@@ -92,6 +100,10 @@
}
$object->setDomainFullURI($new_value);
return;
+ case PhameBlogTransaction::TYPE_PROFILEIMAGE:
+ return $object->setProfileImagePHID($xaction->getNewValue());
+ case PhameBlogTransaction::TYPE_HEADERIMAGE:
+ return $object->setHeaderImagePHID($xaction->getNewValue());
case PhameBlogTransaction::TYPE_STATUS:
return $object->setStatus($xaction->getNewValue());
case PhameBlogTransaction::TYPE_PARENTSITE:
@@ -114,6 +126,8 @@
case PhameBlogTransaction::TYPE_FULLDOMAIN:
case PhameBlogTransaction::TYPE_PARENTSITE:
case PhameBlogTransaction::TYPE_PARENTDOMAIN:
+ case PhameBlogTransaction::TYPE_HEADERIMAGE:
+ case PhameBlogTransaction::TYPE_PROFILEIMAGE:
case PhameBlogTransaction::TYPE_STATUS:
return;
}
diff --git a/src/applications/phame/storage/PhameBlogTransaction.php b/src/applications/phame/storage/PhameBlogTransaction.php
--- a/src/applications/phame/storage/PhameBlogTransaction.php
+++ b/src/applications/phame/storage/PhameBlogTransaction.php
@@ -3,13 +3,15 @@
final class PhameBlogTransaction
extends PhabricatorApplicationTransaction {
- const TYPE_NAME = 'phame.blog.name';
- const TYPE_SUBTITLE = 'phame.blog.subtitle';
- const TYPE_DESCRIPTION = 'phame.blog.description';
- const TYPE_FULLDOMAIN = 'phame.blog.full.domain';
- const TYPE_STATUS = 'phame.blog.status';
- const TYPE_PARENTSITE = 'phame.blog.parent.site';
- const TYPE_PARENTDOMAIN = 'phame.blog.parent.domain';
+ const TYPE_NAME = 'phame.blog.name';
+ const TYPE_SUBTITLE = 'phame.blog.subtitle';
+ const TYPE_DESCRIPTION = 'phame.blog.description';
+ const TYPE_FULLDOMAIN = 'phame.blog.full.domain';
+ const TYPE_STATUS = 'phame.blog.status';
+ const TYPE_PARENTSITE = 'phame.blog.parent.site';
+ const TYPE_PARENTDOMAIN = 'phame.blog.parent.domain';
+ const TYPE_PROFILEIMAGE = 'phame.blog.header.image';
+ const TYPE_HEADERIMAGE = 'phame.blog.profile.image';
const MAILTAG_DETAILS = 'phame-blog-details';
const MAILTAG_SUBSCRIBERS = 'phame-blog-subscribers';
@@ -34,6 +36,22 @@
return parent::shouldHide();
}
+ public function getRequiredHandlePHIDs() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ $req_phids = array();
+ switch ($this->getTransactionType()) {
+ case self::TYPE_PROFILEIMAGE:
+ case self::TYPE_HEADERIMAGE:
+ $req_phids[] = $old;
+ $req_phids[] = $new;
+ break;
+ }
+
+ return array_merge($req_phids, parent::getRequiredHandlePHIDs());
+ }
+
public function getIcon() {
$old = $this->getOldValue();
$new = $this->getNewValue();
@@ -48,6 +66,10 @@
case self::TYPE_DESCRIPTION:
case self::TYPE_FULLDOMAIN:
return 'fa-pencil';
+ case self::TYPE_HEADERIMAGE:
+ return 'fa-image';
+ case self::TYPE_PROFILEIMAGE:
+ return 'fa-star';
case self::TYPE_STATUS:
if ($new == PhameBlog::STATUS_ARCHIVED) {
return 'fa-ban';
@@ -88,6 +110,8 @@
case self::TYPE_FULLDOMAIN:
case self::TYPE_PARENTSITE:
case self::TYPE_PARENTDOMAIN:
+ case self::TYPE_PROFILEIMAGE:
+ case self::TYPE_HEADERIMAGE:
$tags[] = self::MAILTAG_DETAILS;
break;
default:
@@ -172,6 +196,42 @@
$new);
}
break;
+ case self::TYPE_HEADERIMAGE:
+ if (!$old) {
+ return pht(
+ "%s set this blog's header image to %s.",
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($new));
+ } else if (!$new) {
+ return pht(
+ "%s removed this blog's header image.",
+ $this->renderHandleLink($author_phid));
+ } else {
+ return pht(
+ "%s updated this blog's header image from %s to %s.",
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($old),
+ $this->renderHandleLink($new));
+ }
+ break;
+ case self::TYPE_PROFILEIMAGE:
+ if (!$old) {
+ return pht(
+ "%s set this blog's profile image to %s.",
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($new));
+ } else if (!$new) {
+ return pht(
+ "%s removed this blog's profile image.",
+ $this->renderHandleLink($author_phid));
+ } else {
+ return pht(
+ "%s updated this blog's profile image from %s to %s.",
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($old),
+ $this->renderHandleLink($new));
+ }
+ break;
case self::TYPE_STATUS:
switch ($new) {
case PhameBlog::STATUS_ACTIVE:
@@ -248,6 +308,18 @@
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
break;
+ case self::TYPE_HEADERIMAGE:
+ return pht(
+ '%s updated the header image for %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($object_phid));
+ break;
+ case self::TYPE_PROFILEIMAGE:
+ return pht(
+ '%s updated the profile image for %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($object_phid));
+ break;
case self::TYPE_STATUS:
switch ($new) {
case PhameBlog::STATUS_ACTIVE:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 7:52 AM (20 h, 55 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6909925
Default Alt Text
D16217.diff (9 KB)
Attached To
Mode
D16217: Make Phame Header and Profile Image Transactional
Attached
Detach File
Event Timeline
Log In to Comment