Commit f362a7db authored by Mark Harding's avatar Mark Harding
Browse files

(feat): introduces published flag

parent e34c30c4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ class HydrateSettingsDelegate
            error_log($e);
        }

        $settings->setPublished($user->isProPublished());
        return $settings;
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -322,6 +322,13 @@ class Manager
                ->setCustomHead($values['custom_head']);
        }

        if (isset($values['published'])) {
            $this->user->setProPublished($values['published']);
        	$this->saveAction
            	->setEntity($this->user)
                ->save();
		}

        $this->setupRoutingDelegate
            ->onUpdate($settings);

+6 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ use Minds\Traits\MagicAttributes;
 * @method Settings setFeaturedContent(array $featuredContent)
 * @method string getCustomHead()
 * @method Settings setCustomHead(string $customHead)
 * @method bool isPublished()
 * @method Settings setPublished(bool $published)
 */
class Settings implements JsonSerializable
{
@@ -120,6 +122,9 @@ class Settings implements JsonSerializable
    /** @var string */
    protected $customHead = '';

    /** @var bool */
    protected $published;

    /**
     * @return string
     */
@@ -158,6 +163,7 @@ class Settings implements JsonSerializable
            'custom_head' => $this->customHead,
            'one_line_headline' => $this->getOneLineHeadline(),
            'styles' => $this->buildStyles(),
            'published' => $this->published,
        ];
    }

+31 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ class User extends \ElggUser
        $this->attributes['plus'] = 0; //TODO: REMOVE
        $this->attributes['plus_expires'] = 0;
        $this->attributes['pro_expires'] = 0;
        $this->attributes['pro_published'] = 0;
        $this->attributes['verified'] = 0;
        $this->attributes['founder'] = 0;
        $this->attributes['disabled_boost'] = 0;
@@ -824,6 +825,7 @@ class User extends \ElggUser
        $export['programs'] = $this->getPrograms();
        $export['plus'] = (bool) $this->isPlus();
        $export['pro'] = (bool) $this->isPro();
        $export['pro_published'] = (bool) $this->isProPublished();
        $export['verified'] = (bool) $this->verified;
        $export['founder'] = (bool) $this->founder;
        $export['disabled_boost'] = (bool) $this->disabled_boost;
@@ -945,6 +947,35 @@ class User extends \ElggUser
        return $this->getProExpires() >= time();
    }

    /**
     * Set if pro is published
     * @param bool $published
     * @return self
     */
    public function setProPublished(bool $published): self
    {
        $this->pro_published = $published ? 1 : 0;
        return $this;
    }

	/**
     * Return if is published
     * @return bool
     */
    public function getProPublished(): bool
    {
        return (bool) $this->pro_published;
    }

    /**
     * Return if is published
     * @return bool
     */
    public function isProPublished(): bool
    {
        return (bool) $this->pro_published;
    }

    /**
     * Gets the categories to which the user is subscribed.
     *