...
 
Commits (2)
......@@ -204,7 +204,7 @@ class blog implements Interfaces\Api
}
if (isset($_POST['tags']) && $_POST['tags'] !== '') {
$tags = !is_array($_POST['tags']) ? explode(',', $_POST['tags']) : $_POST['tags'];
$tags = !is_array($_POST['tags']) ? json_decode($_POST['tags']) : $_POST['tags'];
$blog->setTags($tags);
}
......@@ -213,7 +213,8 @@ class blog implements Interfaces\Api
}
if (isset($_POST['wire_threshold'])) {
$blog->setWireThreshold($_POST['wire_threshold']);
$threshold = is_string($_POST['wire_threshold']) ? json_decode($_POST['wire_threshold']) : $_POST['wire_threshold'];
$blog->setWireThreshold($threshold);
}
if (isset($_POST['published'])) {
......@@ -228,8 +229,12 @@ class blog implements Interfaces\Api
$blog->setSlug($_POST['slug']);
}
if (isset($_POST['custom_meta']) && is_array($_POST['custom_meta'])) {
$blog->setCustomMeta($_POST['custom_meta']);
if (isset($_POST['custom_meta'])) {
$meta = is_string($_POST['custom_meta']) ? json_decode($_POST['custom_meta'], true) : $_POST['custom_meta'];
if (is_array($meta)) {
$blog->setCustomMeta($meta);
}
}
//draft
......
......@@ -381,6 +381,8 @@ class Blog extends RepositoryEntity
'author' => FILTER_SANITIZE_SPECIAL_CHARS
]);
$this->markAsDirty('customMeta');
return $this;
}
......
......@@ -42,7 +42,9 @@ class CreateActivity
->setThumbnail($blog->getIconUrl())
->setFromEntity($blog)
->setMature($blog->isMature())
->setOwner($owner->export());
->setOwner($owner->export())
->setWireThreshold($blog->getWireThreshold())
->setPaywall($blog->isPaywall());
$activity->container_guid = $owner->guid;
$activity->owner_guid = $owner->guid;
......
......@@ -28,7 +28,8 @@ class Thresholds
}
$isPaywall = false;
if (method_exists($entity, 'isPaywall') && $entity->isPaywall()) {
if ((MagicAttributes::getterExists($entity, 'isPaywall') || method_exists($entity, 'isPaywall')) && $entity->isPaywall()) {
$isPaywall = true;
} elseif (method_exists($entity, 'getFlag') && $entity->getFlag('paywall')) {
$isPaywall = true;
......@@ -48,9 +49,15 @@ class Thresholds
$amount = 0;
if (MagicAttributes::getterExists($entity, 'getOwnerGuid')) {
$ownerGuid = $entity->getOwnerGuid();
} else {
$ownerGuid = $entity->getOwnerGUID();
}
/** @var Sums $sums */
$sums = Di::_()->get('Wire\Sums');
$sums->setReceiver($entity->getOwnerGUID())
$sums->setReceiver($ownerGuid)
->setSender($user->guid)
->setFrom((new \DateTime('midnight'))->modify("-30 days")->getTimestamp());
......@@ -76,10 +83,8 @@ class Thresholds
return true;
}
}
return false;
}
return true;
}
}
......@@ -40,7 +40,7 @@ class MagicAttributes
*/
public static function getterExists($class, $getter)
{
$prop = lcfirst(preg_replace('/^get/', '', $getter));
$prop = lcfirst(preg_replace('/^(get|is)/', '', $getter));
return method_exists($class, $getter) || (static::used($class) && property_exists($class, $prop));
}
}
......@@ -56,6 +56,14 @@ class CreateActivitySpec extends ObjectBehavior
->shouldBeCalled()
->willReturn(false);
$blog->getWireThreshold()
->shouldBeCalled()
->willReturn(null);
$blog->isPaywall()
->shouldBeCalled()
->willReturn(false);
$user->export()
->shouldBeCalled()
->willReturn([]);
......