/** * */ public function onPostAdded(iUmiEventPoint $event) { if ($event->getMode() == 'after') { $postId = $event->getParam('id'); antiSpamHelper::checkForSpam($postId); } }
public function onCloneElement(iUmiEventPoint $oEventPoint) { if ($oEventPoint->getMode() == 'after') { /** * @var umiHierarchy */ $hierarchy = umiHierarchy::getInstance(); $elementId = $oEventPoint->getParam('newElementId'); /** * @var umiHierarchyElement */ $element = $hierarchy->getElement($elementId); if ($element && $element->getTypeId() == umiHierarchyTypesCollection::getInstance()->getTypeByName('vote', 'poll')->getId()) { $collection = umiObjectsCollection::getInstance(); $answersIDs = $element->getValue('answers'); $newAnswers = array(); foreach ($answersIDs as $answerId) { if ($newAnswerId = $collection->cloneObject($answerId)) { $newAnswers[] = $newAnswerId; $answer = $collection->getObject($newAnswerId); $answer->setValue('poll_rel', $elementId); $answer->setValue('count', 0); $answer->commit(); } } $element->setValue('answers', $newAnswers); $element->commit(); } } }
public function runGarbageCollector(iUmiEventPoint $e) { if ($e->getMode() == "process") { $gc = new garbageCollector(); $gc->run(); } }
public function onQuestionPost(iUmiEventPoint $event) { if ($event->getMode() == 'after') { $questionId = $event->getParam('element_id'); antiSpamHelper::checkForSpam($questionId, 'question'); } }
public function onElementAppend(iUmiEventPoint $oEventPoint) { if ($oEventPoint->getMode() === 'after') { $o_element = $oEventPoint->getRef('element'); if ($o_element instanceof umiHierarchyElement) { $i_element_type = intval($o_element->getTypeId()); if ($i_element_type && ($i_element_type === $this->getHTypeByName('topic') || $i_element_type === $this->getHTypeByName('message'))) { // increase $this->recalcCounts($o_element); // publish_time $publish_time = new umiDate(time()); $o_element->setValue("publish_time", $publish_time); $o_element->commit(); } } } }
public function onPopularRefresh(iUmiEventPoint $event) { static $price = false, $element = false; if ($event->getMode() == "before") { $order_item = $event->getRef('orderItem'); $element = $order_item->getItemElement(); $price = $order_item->getTotalActualPrice(); } else { if ($price && $element) { $new_price = $event->getRef('totalActualPrice'); if ($new_price > $price) { $visits = $element->getValue('popular'); if ($visits) { $element->setValue('popular', $visits + 1); } else { $element->setValue('popular', 1); } $element->commit(); } } } }
public function onDeliveryStatusChanged(iUmiEventPoint $event) { if($event->getMode() == "after" && $event->getParam("old-status-id") != $event->getParam("new-status-id")) { $order = $event->getRef("order"); $this->notifyOrderStatusChange($order, "delivery_status_id"); } }
public function onWebformsPost(iUmiEventPoint $event) { if ($event->getMode() == "after") { $formId = $event->getParam("form_id"); $messageId = $event->getParam("message_id"); if (!$formId || !$messageId) { return false; } $form = umiObjectTypesCollection::getInstance()->getType($formId); $module = cmsController::getInstance()->getModule('webforms'); $formLinks = $module->getObjectTypeEditLink($formId); $messageLink = $module->getObjectEditLink($messageId, 'message'); if (isset($formLinks['edit-link']) && $messageLink) { $this->registerEvent('webforms-message-add', array($messageLink, $formLinks['edit-link'], $form->getName()), null, $messageId); } } }
public function onWebformsPost(iUmiEventPoint $v4119639092e62c55ea8be348e4d9260d) { if ($v4119639092e62c55ea8be348e4d9260d->getMode() == "after") { $v307b98da43f9d6c6fb4d231412b42631 = $v4119639092e62c55ea8be348e4d9260d->getParam("form_id"); $v009bc6ca542405d9097ae589731691fb = $v4119639092e62c55ea8be348e4d9260d->getParam("message_id"); if (!$v307b98da43f9d6c6fb4d231412b42631 || !$v009bc6ca542405d9097ae589731691fb) { return false; } $v3fcdb73d36d54f2cc22d0f68e6b6e182 = umiObjectTypesCollection::getInstance()->getType($v307b98da43f9d6c6fb4d231412b42631); $v22884db148f0ffb0d830ba431102b0b5 = cmsController::getInstance()->getModule('webforms'); $ve55b78733a88e875f1c45e59838c3bdb = $v22884db148f0ffb0d830ba431102b0b5->getObjectTypeEditLink($v307b98da43f9d6c6fb4d231412b42631); $v8b323a6bd1ca04e74fe7a34e68a9bb2b = $v22884db148f0ffb0d830ba431102b0b5->getObjectEditLink($v009bc6ca542405d9097ae589731691fb, 'message'); if (isset($ve55b78733a88e875f1c45e59838c3bdb['edit-link']) && $v8b323a6bd1ca04e74fe7a34e68a9bb2b) { $this->registerEvent('webforms-message-add', array($v8b323a6bd1ca04e74fe7a34e68a9bb2b, $ve55b78733a88e875f1c45e59838c3bdb['edit-link'], $v3fcdb73d36d54f2cc22d0f68e6b6e182->getName()), null, $v009bc6ca542405d9097ae589731691fb); } } }
public function onOrderDelete(iUmiEventPoint $e) { if ($e->getMode() != 'before') { return; } $object = $e->getRef('object'); if ($object instanceof iUmiObject) { $type = selector::get('object-type')->id($object->getTypeId()); if ($type && $type->getMethod() == 'order') { $order = order::get($object->id); $order->unreserve(); $order->commit(); } } }
public function onRegisterAdminMail(iUmiEventPoint $oEventPoint) { $regedit = regedit::getInstance(); $template = "default"; if($oEventPoint->getMode() == "after") { list($template_mail, $template_mail_subject) = def_module::loadTemplatesForMail("users/register/".$template, "mail_admin_registrated", "mail_admin_registrated_subject"); $email_to = $regedit->getVal("//settings/admin_email"); $email_from = $regedit->getVal("//settings/email_from"); $fio_from = $regedit->getVal("//settings/fio_from"); $object_id = $oEventPoint->getParam('user_id'); $login = $oEventPoint->getParam('login'); $mail_arr = Array(); $mail_arr['user_id'] = $object_id; if($login) { $mail_arr['login'] = $login; } $mail_subject = def_module::parseTemplateForMail($template_mail_subject, $mail_arr, false, $object_id); $mail_content = def_module::parseTemplateForMail($template_mail, $mail_arr, false, $object_id); $someMail = new umiMail(); $someMail->addRecipient($email_to, $fio_from); $someMail->setFrom($email_from, $fio_from); $someMail->setSubject($mail_subject); $someMail->setContent($mail_content); $someMail->commit(); $someMail->send(); } }
public function onModifyElementAntispam(iUmiEventPoint $event) { static $cache = array(); $element = $event->getRef("element"); if (!$element) { return; } if ($event->getMode() == "before") { $data = getRequest("data"); if (isset($data[$element->getId()])) { $oldValue = getArrayKey($data[$element->getId()], 'is_spam'); if ($oldValue != $element->getValue("is_spam")) { $cache[$element->getId()] = true; } } } else { if (isset($cache[$element->getId()])) { $type = umiHierarchyTypesCollection::getInstance()->getTypeByName("faq", "question"); $contentField = $type->getId() == $element->getTypeId() ? 'question' : 'content'; antiSpamHelper::report($element->getId(), $contentField); } } }