public function systemEventsNotify(iUmiEventPoint $event)
 {
     $eventId = $event->getEventId();
     $titleLabel = $titleLabel = 'event-' . $eventId . '-title';
     $contentLabel = 'event-' . $eventId . '-content';
     $title = getLabel($titleLabel, 'common/content/config');
     $content = getLabel($contentLabel, 'common/content/config');
     if ($titleLabel == $title) {
         return;
     }
     if ($element = $event->getRef('element')) {
         $hierarchy = umiHierarchy::getInstance();
         $oldbForce = $hierarchy->forceAbsolutePath(true);
         $params = array('%page-name%' => $element->name, '%page-link%' => $element->link);
         $hierarchy->forceAbsolutePath($oldbForce);
     } else {
         $params = array();
     }
     if ($object = $event->getRef('object')) {
         $params['%object-name%'] = $object->name;
         $objectTypes = umiObjectTypesCollection::getInstance();
         $objectType = $objectTypes->getType($object->getTypeId());
         if ($hierarchyTypeId = $objectType->getHierarchyTypeId()) {
             $hierarchyTypes = umiHierarchyTypesCollection::getInstance();
             $hierarchyType = $hierarchyTypes->getType($hierarchyTypeId);
             $params['%object-type%'] = $hierarchyType->getTitle();
         }
     }
     $title = str_replace(array_keys($params), array_values($params), $title);
     $content = str_replace(array_keys($params), array_values($params), $content);
     $this->dispatchSystemEvent($title, $content);
 }
 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();
         }
     }
 }
示例#3
0
 public function runGarbageCollector(iUmiEventPoint $e)
 {
     if ($e->getMode() == "process") {
         $gc = new garbageCollector();
         $gc->run();
     }
 }
 public function onAddTopicToDispatch(iUmiEventPoint $oEvent)
 {
     $iDispatchId = regedit::getInstance()->getVal("//modules/forum/dispatch_id");
     if (!$iDispatchId) {
         return false;
     }
     $dispatches_module = cmsController::getInstance()->getModule('dispatches');
     if (!$dispatches_module) {
         return false;
     }
     $iTopicId = (int) $oEvent->getParam('topic_id');
     $oTopicElement = umiHierarchy::getInstance()->getElement($iTopicId);
     if ($oTopicElement instanceof umiHierarchyElement) {
         $sTitle = (string) getRequest('title');
         $sMessage = (string) getRequest('body');
         $iHierarchyTypeId = umiHierarchyTypesCollection::getInstance()->getTypeByName("dispatches", "message")->getId();
         $iMsgTypeId = umiObjectTypesCollection::getInstance()->getTypeByHierarchyTypeId($iHierarchyTypeId);
         $oMsgType = umiObjectTypesCollection::getInstance()->getType($iMsgTypeId);
         $iMsgObjId = umiObjectsCollection::getInstance()->addObject($sTitle, $iMsgTypeId);
         $oMsgObj = umiObjectsCollection::getInstance()->getObject($iMsgObjId);
         if ($oMsgObj instanceof umiObject) {
             $iReleaseId = $dispatches_module->getNewReleaseInstanceId($iDispatchId);
             $oMsgObj->setValue('release_reference', $iReleaseId);
             $oMsgObj->setValue('header', $sTitle);
             $oMsgObj->setValue('body', $sMessage);
             $oMsgObj->commit();
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 public function callEvent(iUmiEventPoint $v70e8822b2e035fa3777d666207aeafa8, $vd1540c8092fdc7e9a4b4b1160ba22465 = array())
 {
     $v53cc4db543d7a569e51c1d76ac6f278e = $v70e8822b2e035fa3777d666207aeafa8->getEventId();
     $v89885eff552e13893a0dade8efb1b731 = $this->searchEventListeners($v53cc4db543d7a569e51c1d76ac6f278e);
     $v89885eff552e13893a0dade8efb1b731 = $this->sortCallbacksByPriority($v89885eff552e13893a0dade8efb1b731);
     $v2165e4fa5bddb65a31f6a0c495c2fa37 = array('executed' => array(), 'failed' => array(), 'breaked' => array());
     foreach ($v89885eff552e13893a0dade8efb1b731 as $v924a8ceeac17f54d3be3f8cdf1c04eb2) {
         if (!empty($vd1540c8092fdc7e9a4b4b1160ba22465) && !in_array($v924a8ceeac17f54d3be3f8cdf1c04eb2->getCallbackModule(), $vd1540c8092fdc7e9a4b4b1160ba22465)) {
             continue;
         }
         try {
             $this->executeCallback($v924a8ceeac17f54d3be3f8cdf1c04eb2, $v70e8822b2e035fa3777d666207aeafa8);
             $v2165e4fa5bddb65a31f6a0c495c2fa37['executed'][] = $v924a8ceeac17f54d3be3f8cdf1c04eb2;
         } catch (baseException $ve1671797c52e15f763380b45e841ec32) {
             $v2165e4fa5bddb65a31f6a0c495c2fa37['failed'][] = $v924a8ceeac17f54d3be3f8cdf1c04eb2;
             if ($v924a8ceeac17f54d3be3f8cdf1c04eb2->getIsCritical()) {
                 throw $ve1671797c52e15f763380b45e841ec32;
             } else {
                 continue;
             }
         } catch (breakException $ve1671797c52e15f763380b45e841ec32) {
             $v2165e4fa5bddb65a31f6a0c495c2fa37['breaked'][] = $v924a8ceeac17f54d3be3f8cdf1c04eb2;
             break;
         }
     }
     return $v2165e4fa5bddb65a31f6a0c495c2fa37;
 }
 public function onQuestionPost(iUmiEventPoint $event)
 {
     if ($event->getMode() == 'after') {
         $questionId = $event->getParam('element_id');
         antiSpamHelper::checkForSpam($questionId, 'question');
     }
 }
示例#7
0
文件: __custom.php 项目: sd-studio/nz
 public function onPageCreate(iUmiEventPoint $event)
 {
     if (!$event->getRef('element') instanceof umiHierarchyElement) {
         return;
     }
     $pageId = $event->getRef('element')->getId();
     $hierarchy = umiHierarchy::getInstance();
     $page = $hierarchy->getElement($pageId);
     $postparams = http_build_query(array('message' => $page->content, 'title' => $page->name, 'link' => 'http://netizenhostels.com' . $hierarchy->getPathById($page->id) . '?media=mobile'));
     $options = array("http" => array("method" => "POST", "header" => "Content-type: application/x-www-form-urlencoded", "content" => $postparams));
     $context = stream_context_create($options);
     $result = file_get_contents('http://netizen.octopod.com/push/send_message.php', false, $context);
     //	        if ($page->getIsActive()) {
     //	        file_get_contents('http://netizen.octopod.com/push/send_message.php?message='.$page->altName);
     /*
     				file_put_contents(
     					sys_get_temp_dir().'/zzzzzy',print_r(array(
     						'id' => $page->id,
     						'name' => $page->name,
     						'permalink' => $page->altName,
     						'anons' => $page->anons,
     						'content' => $page->content,
     						'url' => $hierarchy->getPathById($page->id)
     					),true)
     				);
     */
     //	        }
 }
示例#8
0
文件: __custom.php 项目: sd-studio/nz
 public function onAddCommentForum(iUmiEventPoint $oEventPoint)
 {
     $iCommentId = $oEventPoint->getParam("message_id");
     $recipient = '*****@*****.**';
     //regedit::getInstance()->getVal('//settings/admin_email');
     $subject = 'Поступил новый вопрос в FAQ';
     $from = 'netizenhostels.com';
     $from_mail = "*****@*****.**";
     $content = "\n\t\t\t<html>\n\t\t\t\t<body>\n\t\t\t\t\t<div>\n\t\t\t\t\t<p> В раздел FAQ сайта netizenhostels.com был добавлен новый вопрос. </p>\n\t\t\t\t\t</div>\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t\t";
     $mail = new umiMail();
     $mail->addRecipient($recipient);
     $mail->setFrom($from_mail, $from);
     $mail->setSubject($subject);
     $mail->setContent($content);
     $mail->commit();
     $mail->send();
 }
示例#9
0
文件: class.php 项目: ziL318/moon
 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 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 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();
         }
     }
 }
示例#12
0
		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();
			}
		}
示例#13
0
 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);
         }
     }
 }
示例#14
0
		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 $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 onCommentAdded(iUmiEventPoint $event)
 {
     $commentId = $event->getParam('id');
     antiSpamHelper::checkForSpam($commentId);
 }
 public function onMessagePost(iUmiEventPoint $event)
 {
     $messageId = $event->getParam("message_id");
     antiSpamHelper::checkForSpam($messageId);
 }