/** * If confirmation link in email was clicked * Make entry in s_articles_notification table * @static * @param Enlight_Event_EventArgs $args * @return */ public static function onNotifyConfirmAction(Enlight_Event_EventArgs $args) { $args->setProcessed(true); $action = $args->getSubject(); $action->View()->NotifyValid = false; $action->View()->NotifyInvalid = false; if (!empty($action->Request()->sNotificationConfirmation) && !empty($action->Request()->sNotify)) { $getConfirmation = Shopware()->Db()->fetchRow(' SELECT * FROM s_core_optin WHERE hash = ? ', array($action->Request()->sNotificationConfirmation)); $notificationConfirmed = false; if (!empty($getConfirmation['hash'])) { $notificationConfirmed = true; $json_data = unserialize($getConfirmation['data']); Shopware()->Db()->query('DELETE FROM s_core_optin WHERE hash=?', array($action->Request()->sNotificationConfirmation)); } if ($notificationConfirmed) { $sql = ' INSERT INTO `s_articles_notification` ( `ordernumber` , `date` , `mail` , `language` , `shopLink` , `send` ) VALUES ( ?, NOW(), ?, ?, ?, 0 ); '; Shopware()->Db()->query($sql, array($json_data['notifyOrdernumber'], $json_data['sNotificationEmail'], $json_data['sLanguage'], $json_data['sShopPath'])); $action->View()->NotifyValid = true; Shopware()->Session()->sNotifcationArticleWaitingForOptInApprovement[$json_data['notifyOrdernumber']] = false; } else { $action->View()->NotifyInvalid = true; } } return $action->forward('index'); }
/** * Event which is fired to collect plugin parameters * to register additionally application components or configurations. * * @param $event * @param ArrayCollection $collection * @param null $eventArgs * * @throws Enlight_Event_Exception * @return ArrayCollection|null */ public function collect($event, ArrayCollection $collection, $eventArgs = null) { if (!$this->hasListeners($event)) { return $collection; } if (isset($eventArgs) && is_array($eventArgs)) { $eventArgs = new Enlight_Event_EventArgs($eventArgs); } elseif (!isset($eventArgs)) { $eventArgs = new Enlight_Event_EventArgs(); } elseif (!$eventArgs instanceof Enlight_Event_EventArgs) { throw new Enlight_Event_Exception('Parameter "eventArgs" must be an instance of "Enlight_Event_EventArgs"'); } $eventArgs->setName($event); $eventArgs->setProcessed(false); foreach ($this->getListeners($event) as $listener) { $listenerCollection = $listener->execute($eventArgs); if ($listenerCollection instanceof ArrayCollection) { foreach ($listenerCollection->getValues() as $value) { $collection->add($value); } } elseif ($listenerCollection !== null) { $collection->add($listenerCollection); } } $eventArgs->setProcessed(true); return $collection; }
/** * Checks if the event has registered listeners. * If the event has listeners this listeners will be executed with the given event arguments. * The event arguments have to been an array or an instance of the Enlight_Event_EventArgs class. * If the given arguments not an array or an instance of the Enlight_Event_EventArgs class enlight * throw an Enlight_Event_Exception. * Before the listener will be executed the the flag "processed" will be set to false in the event arguments. * After all event listeners has been executed the "processed" flag will be set to true. * * The return value of the execute method will be set in the event arguments return value. * * @throws Enlight_Event_Exception * @param string $event * @param mixed $value * @param Enlight_Event_EventArgs|array|null $eventArgs * @return mixed */ public function filter($event, $value, $eventArgs = null) { if (!$this->hasListeners($event)) { return $value; } if (isset($eventArgs) && is_array($eventArgs)) { $eventArgs = new Enlight_Event_EventArgs($eventArgs); } elseif (!isset($eventArgs)) { $eventArgs = new Enlight_Event_EventArgs(); } elseif (!$eventArgs instanceof Enlight_Event_EventArgs) { throw new Enlight_Event_Exception('Parameter "eventArgs" must be an instance of "Enlight_Event_EventArgs"'); } $eventArgs->setReturn($value); $eventArgs->setName($event); $eventArgs->setProcessed(false); foreach ($this->getListeners($event) as $listener) { if (null !== ($return = $listener->execute($eventArgs))) { $eventArgs->setReturn($return); } } $eventArgs->setProcessed(true); return $eventArgs->getReturn(); }