protected function afterSave() { if (!empty($this->__issue_to_user)) { $this->issue(); } parent::afterSave(); }
protected function fetchConditions() { parent::fetchConditions(); $filter_user_session = $this->getState('filter.user_session'); if (strlen($filter_user_session)) { $this->setCondition('session_id_user', $filter_user_session); } $filter_admin_session = $this->getState('filter.admin_session'); if (strlen($filter_admin_session)) { $this->setCondition('session_id_admin', $filter_admin_session); } $filter_user_id = $this->getState('filter.user_id'); if (strlen($filter_user_id)) { $this->setCondition('user_id', $filter_user_id); } $filter_admin_id = $this->getState('filter.admin_id'); if (strlen($filter_admin_id)) { $this->setCondition('admin_id', $filter_admin_id); } $filter_status = $this->getState('filter.status'); if (strlen($filter_status)) { $this->setCondition('status', $filter_status); } return $this; }
protected function afterCreate() { parent::afterCreate(); if (!empty($this->__send_email)) { $this->sendEmailNewInvite(); } \Affiliates\Models\Referrals::calcAffiliateTotals($this->affiliate_id); }
protected function beforeValidate() { if (empty($this->key)) { throw new \Exception('Key Can Not Be Empty'); } if (empty($this->content)) { throw new \Exception('Content can not be empty'); } return parent::beforeValidate(); }
protected function beforeSave() { if (!empty($this->tags) && !is_array($this->tags)) { $this->tags = trim($this->tags); if (!empty($this->tags)) { $this->tags = array_map(function ($el) { return strtolower($el); }, \Base::instance()->split((string) $this->tags)); } } elseif (empty($this->tags) && !is_array($this->tags)) { $this->tags = array(); } return parent::beforeSave(); }
protected function fetchConditions() { parent::fetchConditions(); $filter_keyword = $this->getState('filter.keyword'); if ($filter_keyword && is_string($filter_keyword)) { $key = new \MongoRegex('/' . $filter_keyword . '/i'); $where = array(); $regex = '/^[0-9a-z]{24}$/'; if (preg_match($regex, (string) $filter_keyword)) { $where[] = array('_id' => new \MongoId((string) $filter_keyword)); } $where[] = array('metadata.creator.name' => $key); $this->setCondition('$or', $where); } return $this; }
public function validate() { if (empty($this->name)) { $this->setError('Addresses must have an addressee'); } if (empty($this->line_1)) { $this->setError('Addresses must have the first street line'); } if (empty($this->city)) { $this->setError('Addresses must have a city'); } if (empty($this->region)) { $this->setError('Addresses must have a region/state'); } if (empty($this->country)) { $this->setError('Addresses must have a country'); } if (empty($this->postal_code)) { $this->setError('Addresses must have a postal code'); } return parent::validate(); }
protected function afterUpdate() { if (!empty($this->__options['update_children'])) { if ($children = (new static())->setState('filter.parent', $this->_id)->getItems()) { foreach ($children as $child) { $child->ancestors = array(); $child->path = null; $child->update(array(), array('update_children' => true)); } } } parent::afterUpdate(); }
protected function beforeSave() { $this->publishableBeforeSave(); $this->description = strip_tags(str_replace('\\n', '<br>', $this->description), '<br><p>'); $this->images = array_values(array_filter($this->images)); $this->rating = (double) $this->rating; return parent::beforeSave(); }
protected function afterUpdate() { if ($this->__oldNode->tree != $this->tree) { // update the tree value for this node and all descendants $result = $this->collection()->update(array('lft' => array('$gte' => $this->__oldNode->lft, '$lte' => $this->__oldNode->rgt), 'tree' => $this->__oldNode->tree), array('$set' => array('tree' => $this->tree)), array('multiple' => true)); } if ($this->__update_children) { if ($children = (new static())->setState('filter.parent', $this->id)->getList()) { foreach ($children as $child) { $child->tree = $this->tree; $child->path = null; $child->__update_children = true; $child->save(); } } } if (!empty($this->__isMoving)) { $this->rebuildTree($this->tree); // if we just removed a leaf/branch to a new tree, rebuild the old tree too if (!empty($this->__oldNode) && $this->tree != $this->__oldNode->tree) { $this->rebuildTree($this->__oldNode->tree); } } return parent::afterUpdate(); }
protected function beforeCreate() { if (class_exists('\\Shop\\Models\\Orders')) { // shop exists, do the integration $settings = \Affiliates\Models\Settings::fetch(); $referral_credit = (double) $settings->{'shop.store_credit_per_referral'}; if ($referral_credit && $this->type == self::TYPE_REFERRAL) { // affiliate earns a shop.credit for the referral, so push it into the actions stack $this->actions[] = (new \Affiliates\Models\CommissionActions())->bind(array('amount' => $referral_credit, 'type' => 'shop.credit', 'issued' => false))->cast(); } $conversion_credit = (double) $settings->{'shop.store_credit_per_conversion'}; $conversion_credit_type = (double) $settings->{'shop.store_credit_per_conversion_type'}; // flat-rate or percentage if ($conversion_credit && $this->type == self::TYPE_CONVERSION) { $amount = $conversion_credit_type == 'flat-rate' ? $conversion_credit : $conversion_credit / 100 * $this->shop_order_amount; // affiliate earns a shop.credit for the referral, so push it into the actions stack $this->actions[] = (new \Affiliates\Models\CommissionActions())->bind(array('amount' => (double) $amount, 'type' => 'shop.credit', 'issued' => false))->cast(); } } parent::beforeCreate(); }
protected function afterSave() { parent::afterSave(); // cart has been updated, // so delete all scheduled abandoned cart notifications \Shop\Models\CartsAbandoned::deleteQueuedEmails($this); // and reset its array of email notifications $this->abandoned_notifications = array(); $this->store(); }
protected function beforeSave() { $this->items_count = count($this->items); return parent::beforeSave(); }
public function beforeSave() { if (isset($this->url) && is_array($this->url)) { $this->url['alias'] = $this->inputFilter()->clean($this->url['alias'], 'string'); $this->url['redirect'] = $this->inputFilter()->clean($this->url['redirect'], 'string'); } else { $this->setError('Missing information about redirection'); } if (strpos($this->{'url.alias'}, '/') === 0) { $this->{'url.alias'} = substr($this->{'url.alias'}, 1); } if (strpos($this->{'url.redirect'}, '/') === 0) { $this->{'url.redirect'} = substr($this->{'url.redirect'}, 1); } return parent::beforeSave(); }
protected function afterCreate() { if (!empty($this->__email_recipient)) { \Dsc\Queue::task('\\Shop\\Models\\OrderedGiftCards::queueEmailNewGiftCard', array('card_id' => $this->id, 'recipients' => array($this->__email_recipient))); } parent::afterCreate(); }
protected function beforeSave() { return parent::beforeSave(); }
protected function afterDelete() { $this->calcAffiliateTotals($this->affiliate_id); parent::afterDelete(); }
protected function afterSave() { parent::afterSave(); $this->compressOrdering(); }