public function __construct(BASE_CLASS_WidgetParameter $params) { parent::__construct(); $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCmpViewDir() . 'users_widget.html'); $randId = UTIL_HtmlTag::generateAutoId('base_users_widget'); $this->assign('widgetId', $randId); $data = $this->getData($params); $menuItems = array(); $dataToAssign = array(); if (!empty($data)) { foreach ($data as $key => $item) { $contId = "{$randId}_users_widget_{$key}"; $toolbarId = !empty($item['toolbar']) ? "{$randId}_toolbar_{$key}" : false; $menuItems[$key] = array('label' => $item['menu-label'], 'id' => "{$randId}_users_widget_menu_{$key}", 'contId' => $contId, 'active' => !empty($item['menu_active']), 'toolbarId' => $toolbarId); $usersCmp = $this->getUsersCmp($item['userIds']); $dataToAssign[$key] = array('users' => $usersCmp->render(), 'active' => !empty($item['menu_active']), 'toolbar' => !empty($item['toolbar']) ? $item['toolbar'] : array(), 'toolbarId' => $toolbarId, 'contId' => $contId); } } $this->assign('data', $dataToAssign); $displayMenu = true; if (count($data) == 1 && !$this->forceDisplayMenu) { $displayMenu = false; } if (!$params->customizeMode && (count($data) != 1 || $this->forceDisplayMenu)) { $menu = $this->getMenuCmp($menuItems); if (!empty($menu)) { $this->addComponent('menu', $menu); } } }
public function logMsg() { $service = AJAXIM_BOL_Service::getInstance(); if ($errorMessage = $service->checkPermissions()) { exit(json_encode(array('error' => $errorMessage))); } if (empty($_POST['to'])) { exit(json_encode(array('error' => "Receiver is not defined"))); } if (empty($_POST['message'])) { exit(json_encode(array('error' => "Message is empty"))); } $message = UTIL_HtmlTag::stripTags(UTIL_HtmlTag::stripJs($_POST['message'])); $dto = new AJAXIM_BOL_Message(); $dto->setFrom(OW::getUser()->getId()); $dto->setTo($_POST['to']); $dto->setMessage($message); $dto->setTimestamp(time()); $dto->setRead(0); AJAXIM_BOL_Service::getInstance()->save($dto); //$message = AJAXIM_BOL_Service::getInstance()->splitLongMessages($message); //$dto->setMessage(UTIL_HtmlTag::autoLink($message)); $dto->setTimestamp($dto->getTimestamp() * 1000); exit(json_encode($dto)); }
public function addVideo($userId, $embed, $title, $description, $thumbnailUrl, $text, $addToFeed = true) { if (!$this->isActive()) { return null; } $title = empty($title) ? $text : $title; $title = empty($title) ? '' : $title; $description = empty($description) ? '' : $description; $clipService = VIDEO_BOL_ClipService::getInstance(); $clip = new VIDEO_BOL_Clip(); $clip->title = $title; $description = UTIL_HtmlTag::stripJs($description); $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true); $clip->description = $description; $clip->userId = $userId; $clip->code = UTIL_HtmlTag::stripJs($embed); $prov = new VideoProviders($clip->code); $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video')); $clip->provider = $prov->detectProvider(); $clip->addDatetime = time(); $clip->status = 'approved'; $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody'; $thumbUrl = empty($thumbnailUrl) ? $prov->getProviderThumbUrl($clip->provider) : $thumbnailUrl; if ($thumbUrl != VideoProviders::PROVIDER_UNDEFINED) { $clip->thumbUrl = $thumbUrl; } $clip->thumbCheckStamp = time(); $clipId = $clipService->addClip($clip); if ($addToFeed) { // Newsfeed $event = new OW_Event('feed.action', array('pluginKey' => 'video', 'entityType' => 'video_comments', 'entityId' => $clipId, 'userId' => $clip->userId), array("content" => array("vars" => array("status" => $text)))); OW::getEventManager()->trigger($event); } return $clipId; }
/** * User list * * @param array $params * integer count * string boxType */ function __construct(array $params = array()) { parent::__construct(); $this->countUsers = !empty($params['count']) ? (int) $params['count'] : self::DEFAULT_USERS_COUNT; $boxType = !empty($params['boxType']) ? $params['boxType'] : ""; // init users short list $randId = UTIL_HtmlTag::generateAutoId('base_users_cmp'); $data = $this->getData($this->countUsers); $menuItems = array(); $dataToAssign = array(); foreach ($data as $key => $item) { $contId = "{$randId}_users_cmp_{$key}"; $toolbarId = !empty($item['toolbar']) ? "{$randId}_toolbar_{$key}" : false; $menuItems[$key] = array('label' => $item['menu-label'], 'id' => "{$randId}_users_cmp_menu_{$key}", 'contId' => $contId, 'active' => !empty($item['menu_active']), 'toolbarId' => $toolbarId, 'display' => 1); $usersCmp = $this->getUsersCmp($item['userIds']); $dataToAssign[$key] = array('users' => $usersCmp->render(), 'active' => !empty($item['menu_active']), 'toolbar' => !empty($item['toolbar']) ? $item['toolbar'] : array(), 'toolbarId' => $toolbarId, 'contId' => $contId); } $menu = $this->getMenuCmp($menuItems); if (!empty($menu)) { $this->addComponent('menu', $menu); } // assign view variables $this->assign('widgetId', $randId); $this->assign('data', $dataToAssign); $this->assign('boxType', $boxType); }
public function beforeContentAdd(OW_Event $event) { $params = $event->getParams(); $data = $event->getData(); if (!empty($data)) { return; } if (empty($params["status"]) && empty($params["data"])) { $event->setData(false); return; } $attachId = null; $content = array(); if (!empty($params["data"])) { $content = $params["data"]; if ($content['type'] == 'photo' && !empty($content['genId'])) { $content['url'] = $content['href'] = OW::getEventManager()->call('base.attachment_save_image', array('genId' => $content['genId'])); $attachId = $content['genId']; } if ($content['type'] == 'video') { $content['html'] = BOL_TextFormatService::getInstance()->validateVideoCode($content['html']); } } $status = UTIL_HtmlTag::autoLink($params["status"]); $out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $params['feedType'], $params['feedId'], $params['visibility'], $status, array("content" => $content, "attachmentId" => $attachId)); $event->setData($out); }
public function renderInput($params = null) { $defaultAgeFrom = isset($this->value['from']) ? (int) $this->value['from'] : $this->minAge; $defaultAgeTo = isset($this->value['to']) ? (int) $this->value['to'] : $this->maxAge; $fromAgeAttrs = $this->attributes; $fromAgeAttrs['name'] = $this->getAttribute('name') . '[from]'; $fromAgeAttrs['type'] = 'text'; $fromAgeAttrs['maxlength'] = 3; $fromAgeAttrs['style'] = 'width: 40px;'; $fromAgeAttrs['value'] = $defaultAgeFrom; if (isset($fromAgeAttrs['id'])) { unset($fromAgeAttrs['id']); } $toAgeAttrs = $this->attributes; $toAgeAttrs['name'] = $this->getAttribute('name') . '[to]'; $toAgeAttrs['type'] = 'text'; $toAgeAttrs['maxlength'] = 3; $toAgeAttrs['style'] = 'width: 40px;'; $toAgeAttrs['value'] = $defaultAgeTo; if (isset($toAgeAttrs['id'])) { unset($toAgeAttrs['id']); } $language = OW::getLanguage(); $result = '<span id="' . $this->getAttribute('id') . '"class="' . $this->getAttribute('name') . '"> ' . UTIL_HtmlTag::generateTag('input', $fromAgeAttrs) . ' ' . $language->text('base', 'form_element_to') . ' ' . UTIL_HtmlTag::generateTag('input', $toAgeAttrs) . '</span>'; return $result; }
public function __construct($conversationId, $opponentId) { parent::__construct('newMailMessageForm'); $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA); $field = new TextField('newMessageText'); $field->setValue(OW::getLanguage()->text('mailbox', 'text_message_invitation')); $field->setId('newMessageText'); $this->addElement($field); $field = new HiddenField('attachment'); $this->addElement($field); $field = new HiddenField('conversationId'); $field->setValue($conversationId); $this->addElement($field); $field = new HiddenField('opponentId'); $field->setValue($opponentId); $this->addElement($field); $field = new HiddenField('uid'); $field->setValue(UTIL_HtmlTag::generateAutoId('mailbox_conversation_' . $conversationId . '_' . $opponentId)); $this->addElement($field); $submit = new Submit('newMessageSendBtn'); $submit->setId('newMessageSendBtn'); $submit->setName('newMessageSendBtn'); $submit->setValue(OW::getLanguage()->text('mailbox', 'add_button')); $this->addElement($submit); if (!OW::getRequest()->isAjax()) { $js = UTIL_JsGenerator::composeJsString(' owForms["newMailMessageForm"].bind( "submit", function( r ) { $("#newmessage-mail-send-btn").addClass("owm_preloader_circle"); });'); OW::getDocument()->addOnloadScript($js); } $this->setAction(OW::getRouter()->urlFor('MAILBOX_MCTRL_Messages', 'newmessage')); }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { parent::renderInput($params); if ($this->options === null || empty($this->options)) { return ''; } $columnWidth = floor(100 / $this->columnsCount); $renderedString = '<ul class="ow_checkbox_group clearfix">'; $noValue = true; foreach ($this->options as $key => $value) { if ($this->value !== null && is_array($this->value) && in_array($key, $this->value)) { $this->addAttribute(FormElement::ATTR_CHECKED, 'checked'); $noValue = false; } $this->setId(UTIL_HtmlTag::generateAutoId('input')); $this->addAttribute('value', $key); $renderedString .= '<li style="width:' . $columnWidth . '%">' . UTIL_HtmlTag::generateTag('input', $this->attributes) . ' <label for="' . $this->getId() . '">' . $value . '</label></li>'; $this->removeAttribute(FormElement::ATTR_CHECKED); } $language = OW::getLanguage(); $attributes = $this->attributes; $attributes['id'] = $this->getName() . '_unimportant'; $attributes['name'] = $this->getName() . '_unimportant'; if ($noValue) { $attributes[FormElement::ATTR_CHECKED] = 'checked'; } $renderedString .= '<li class="matchmaking_unimportant_checkbox" style="display:block;border-top: 1px solid #bbb; margin-top: 12px;padding-top:6px; width:100%">' . UTIL_HtmlTag::generateTag('input', $attributes) . ' <label for="' . $this->getId() . '">' . $language->text('matchmaking', 'this_is_unimportant') . '</label></li>'; return $renderedString . '</ul>'; }
public function __construct(BASE_CLASS_WidgetParameter $param) { parent::__construct(); $userId = $param->additionalParamList['entityId']; if (isset($param->customParamList['content'])) { $content = $param->customParamList['content']; } else { $settings = BOL_ComponentEntityService::getInstance()->findSettingList($param->widgetDetails->uniqName, $userId, array('content')); $content = empty($settings['content']) ? null : $settings['content']; } if ($param->additionalParamList['entityId'] == OW::getUser()->getId()) { $this->assign('ownerMode', true); $this->assign('noContent', $content === null); $this->addForm(new AboutMeForm($param->widgetDetails->uniqName, $content)); } else { if (empty($content)) { $this->setVisible(false); return; } $this->assign('ownerMode', false); $content = htmlspecialchars($content); $content = UTIL_HtmlTag::autoLink($content); $this->assign('contentText', $content); } }
/** * Adds video clip * * @return boolean */ public function process() { $values = $this->getValues(); $clipService = VIDEO_BOL_ClipService::getInstance(); $clip = new VIDEO_BOL_Clip(); $clip->title = htmlspecialchars($values['title']); $description = UTIL_HtmlTag::stripJs($values['description']); $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true); $description = nl2br($description, true); $clip->description = $description; $clip->userId = OW::getUser()->getId(); $clip->code = '<iframe src="' . (OW::getRouter()->getBaseUrl() . 'spvideo/proxy/Allmyvideos/pending/') . $values['token'] . '" width="540" height="315" frameborder="0"></iframe>'; $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video')); $clip->provider = 'allmyvideos'; $clip->addDatetime = time(); $clip->status = 'approved'; $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody'; $eventParams = array('pluginKey' => 'video', 'action' => 'add_video'); if (OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) { OW::getEventManager()->call('usercredits.track_action', $eventParams); } if ($clipService->addClip($clip)) { SPVIDEOLITE_PRO_ALLMYVIDEOS_CLASS_Processing::processTemporaryUpload($values['token'], $values['filename']); BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $values['tags']); return array('result' => true, 'id' => $clip->id); } return false; }
/** * @return Jevix */ private static function getJevix($tagList = null, $attrList = null, $blackListMode = false, $mediaSrcValidate = true) { if (self::$jevix === null) { require_once OW_DIR_LIB . 'jevix' . DS . 'jevix.class.php'; self::$jevix = new Jevix(); } $tagRules = array(); $commonAttrs = array(); if (!empty($tagList)) { foreach ($tagList as $tag) { $tagRules[$tag] = array(Jevix::TR_TAG_LIST => true); } } if ($attrList !== null) { foreach ($attrList as $attr) { if (strstr($attr, '.')) { $parts = explode('.', $attr); $tag = trim($parts[0]); $param = trim($parts[1]); if (!strlen($tag) || !strlen($attr)) { continue; } if ($tag === '*') { $commonAttrs[] = $param; continue; } if (!isset($tagRules[$tag])) { $tagRules[$tag] = array(Jevix::TR_TAG_LIST => true); } if (!isset($tagRules[$tag][Jevix::TR_PARAM_ALLOWED])) { $tagRules[$tag][Jevix::TR_PARAM_ALLOWED] = array(); } $tagRules[$tag][Jevix::TR_PARAM_ALLOWED][$param] = true; } else { $commonAttrs[] = trim($attr); } } } $shortTags = array('img', 'br', 'input', 'embed', 'param', 'hr', 'link', 'meta', 'base', 'col'); foreach ($shortTags as $shortTag) { if (!isset($tagRules[$shortTag])) { $tagRules[$shortTag] = array(); } $tagRules[$shortTag][Jevix::TR_TAG_SHORT] = true; } $cutWithContent = array('script', 'embed', 'object', 'style'); foreach ($cutWithContent as $cutTag) { if (!isset($tagRules[$cutTag])) { $tagRules[$cutTag] = array(); } $tagRules[$cutTag][Jevix::TR_TAG_CUT] = true; } self::$jevix->blackListMode = $blackListMode; self::$jevix->commonTagParamRules = $commonAttrs; self::$jevix->tagsRules = $tagRules; self::$jevix->mediaSrcValidate = $mediaSrcValidate; self::$jevix->mediaValidSrc = BOL_TextFormatService::getInstance()->getMediaResourceList(); return self::$jevix; }
public static function processSettingList($settings, $place, $isAdmin) { if ($place != BOL_ComponentService::PLACE_DASHBOARD && !OW::getUser()->isAdmin()) { $settings['content'] = UTIL_HtmlTag::stripJs($settings['content']); //$settings['content'] = UTIL_HtmlTag::stripTags($settings['content'], array('frame'), array(), true, true); } else { $settings['content'] = UTIL_HtmlTag::sanitize($settings['content']); } return parent::processSettingList($settings, $place, $isAdmin); }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { parent::renderInput($params); $this->addAttribute('type', 'hidden'); $this->addAttribute('class', 'userFieldHidden'); $this->addAttribute('placeholder', OW::getLanguage()->text('mailbox', 'to')); $input = new UserFieldRenderable(); $input->assign('input', UTIL_HtmlTag::generateTag('input', $this->attributes)); return $input->render(); }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { parent::renderInput($params); $deleteLabel = OW::getLanguage()->text('base', 'delete'); $markup = '<div class="ow_avatar_field">'; $markup .= UTIL_HtmlTag::generateTag('input', $this->attributes); $markup .= '<div class="ow_avatar_field_preview" style="display: none;"><img src="" alt="" /><span title="' . $deleteLabel . '"></span></div>'; $markup .= '<input type="hidden" name="" value="" class="ow_avatar_field_value" />'; $markup .= '</div>'; return $markup; }
public function addAllGroupFeed() { if (OW::getConfig()->getValue('grouprss', 'disablePosting') == '1') { return; } $commentService = BOL_CommentService::getInstance(); $newsfeedService = NEWSFEED_BOL_Service::getInstance(); $router = OW::getRouter(); $displayText = OW::getLanguage()->text('grouprss', 'feed_display_text'); $location = OW::getConfig()->getValue('grouprss', 'postLocation'); include_once 'autoloader.php'; $allFeeds = $this->feeddao->findAll(); foreach ($allFeeds as $feed) { $simplefeed = new SimplePie(); $simplefeed->set_feed_url($feed->feedUrl); $simplefeed->set_stupidly_fast(true); $simplefeed->enable_cache(false); $simplefeed->init(); $simplefeed->handle_content_type(); $items = $simplefeed->get_items(0, $feed->feedCount); foreach ($items as $item) { $content = UTIL_HtmlTag::autoLink($item->get_content()); if ($location == 'wall' && !$this->isDuplicateComment($feed->groupId, $content)) { $commentService->addComment('groups_wal', $feed->groupId, 'groups', $feed->userId, $content); } if (trim($location) == 'newsfeed' && !$this->isDuplicateFeed($feed->groupId, $content)) { $statusObject = $newsfeedService->saveStatus('groups', (int) $feed->groupId, $content); $content = UTIL_HtmlTag::autoLink($content); $action = new NEWSFEED_BOL_Action(); $action->entityId = $statusObject->id; $action->entityType = "groups-status"; $action->pluginKey = "newsfeed"; $data = array("string" => $content, "content" => "[ph:attachment]", "view" => array("iconClass" => "ow_ic_comment"), "attachment" => array("oembed" => null, "url" => null, "attachId" => null), "data" => array("userId" => $feed->userId), "actionDto" => null, "context" => array("label" => $displayText, "url" => $router->urlForRoute('groups-view', array('groupId' => $feed->groupId)))); $action->data = json_encode($data); $actionObject = $newsfeedService->saveAction($action); $activity = new NEWSFEED_BOL_Activity(); $activity->activityType = NEWSFEED_BOL_Service::SYSTEM_ACTIVITY_CREATE; $activity->activityId = $feed->userId; $activity->actionId = $actionObject->id; $activity->privacy = NEWSFEED_BOL_Service::PRIVACY_EVERYBODY; $activity->userId = $feed->userId; $activity->visibility = NEWSFEED_BOL_Service::VISIBILITY_FULL; $activity->timeStamp = time(); $activity->data = json_encode(array()); $activityObject = $newsfeedService->saveActivity($activity); $newsfeedService->addActivityToFeed($activity, 'groups', $feed->groupId); } } $simplefeed->__destruct(); unset($feed); } }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { parent::renderInput($params); if (isset($params['checked'])) { $this->addAttribute(FormElement::ATTR_CHECKED, 'checked'); } $label = isset($params['label']) ? $params['label'] : ''; $this->addAttribute('value', $params['value']); $this->setId(UTIL_HtmlTag::generateAutoId('input')); $renderedString = '<label>' . UTIL_HtmlTag::generateTag('input', $this->attributes) . $label . '</label>'; $this->removeAttribute(FormElement::ATTR_CHECKED); return $renderedString; }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { $optionsString = ''; foreach ($this->getOptions() as $option) { $attrs = !is_null($this->value) && $option['value'] == $this->value ? array('selected' => 'selected') : array(); $attrs['value'] = $option['value']; if ($option['disabled']) { $attrs['disabled'] = $option['disabled']; $attrs['class'] = 'disabled_option'; } $optionsString .= UTIL_HtmlTag::generateTag('option', $attrs, true, trim($option['label'])); } return UTIL_HtmlTag::generateTag('select', $this->attributes, true, $optionsString); }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { $this->addAttribute('type', 'hidden'); $jsParamsArray = array('cmpId' => $this->getName(), 'itemsCount' => MATCHMAKING_BOL_Service::MAX_COEFFICIENT, 'id' => $this->getId(), 'checkedCoefficient' => $this->getValue()); OW::getDocument()->addOnloadScript("var " . $this->getName() . " = new MatchmakingCoefficient(" . json_encode($jsParamsArray) . "); " . $this->getName() . ".init();"); $renderedString = UTIL_HtmlTag::generateTag('input', $this->attributes); $renderedString .= '<div id="' . $this->getName() . '">'; $renderedString .= '<div class="coefficients_cont clearfix">'; for ($i = 1; $i <= $this->count; $i++) { $renderedString .= '<a href="javascript://" class="coefficient_item" id="' . $this->getName() . '_item_' . $i . '"> </a>'; } $renderedString .= '</div></div>'; return $renderedString; }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { parent::renderInput($params); $staticUrl = OW::getPluginManager()->getPlugin('mcompose')->getStaticUrl(); OW::getDocument()->addStyleSheet($staticUrl . 'select2.css'); OW::getDocument()->addScript($staticUrl . 'select2.js'); OW::getDocument()->addStyleSheet($staticUrl . 'style.css'); OW::getDocument()->addScript($staticUrl . 'script.js'); $this->addAttribute('type', 'hidden'); $this->addAttribute('style', 'width: 100%'); $imagesUrl = OW::getPluginManager()->getPlugin('base')->getStaticCssUrl(); $css = array('.mc-tag-bg { background-image: url(' . $imagesUrl . 'images/tag_bg.png); };'); OW::getDocument()->addStyleDeclaration(implode("\n", $css)); return UTIL_HtmlTag::generateTag('input', $this->attributes) . '<div class="us-field-fake"><input type="text" class="ow_text invitation" value="' . $this->invitation . '" /></div>'; }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { parent::renderInput($params); $elementId = 'file_' . $this->uniqName; $router = OW::getRouter(); $respUrl = $this->slideId ? $router->urlForRoute('slideshow.update-file', array('slideId' => $this->slideId)) : $router->urlForRoute('slideshow.upload-file', array('uniqName' => $this->uniqName)); $params = array('elementId' => $elementId, 'fileResponderUrl' => $respUrl); $script = "window.uploadSlideFields = {};\n \twindow.uploadSlideFields['" . $this->uniqName . "'] = new uploadSlideField(" . json_encode($params) . ");\n\t\t\twindow.uploadSlideFields['" . $this->uniqName . "'].init();"; OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("slideshow")->getStaticJsUrl() . 'upload_slide_field.js'); OW::getDocument()->addOnloadScript($script); $fileAttr = array('type' => 'file', 'id' => $elementId); $fileField = UTIL_HtmlTag::generateTag('input', $fileAttr); $hiddenAttr = array('type' => 'hidden', 'name' => $this->getName(), 'id' => 'hidden_' . $this->uniqName); $hiddenField = UTIL_HtmlTag::generateTag('input', $hiddenAttr); return '<span class="' . $elementId . '_cont">' . $fileField . '</span>' . $hiddenField; }
public function process() { $language = OW::getLanguage(); $conversationService = MAILBOX_BOL_ConversationService::getInstance(); $values = $this->getValues(); $userId = OW::getUser()->getId(); $actionName = 'send_message'; $isAuthorized = OW::getUser()->isAuthorized('mailbox', $actionName); if (!$isAuthorized) { $status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', $actionName); if ($status['status'] != BOL_AuthorizationService::STATUS_AVAILABLE) { return array('result' => false, 'error' => $language->text('mailbox', 'send_message_permission_denied')); } } $checkResult = $conversationService->checkUser($userId, $values['opponentId']); if ($checkResult['isSuspended']) { return array('result' => false, 'error' => $checkResult['suspendReasonMessage']); } $values['message'] = UTIL_HtmlTag::stripTags(UTIL_HtmlTag::stripJs($values['message'])); $event = new OW_Event('mailbox.before_create_conversation', array('senderId' => $userId, 'recipientId' => $values['opponentId'], 'message' => $values['message'], 'subject' => $values['subject']), array('result' => true, 'error' => '', 'message' => $values['message'], 'subject' => $values['subject'])); OW::getEventManager()->trigger($event); $data = $event->getData(); if (empty($data['result'])) { return array('result' => false, 'error' => $data['error']); } if (!trim(strip_tags($values['subject']))) { return array('result' => false, 'error' => $language->text('mailbox', 'subject_is_required')); } $values['subject'] = $data['subject']; $values['message'] = $data['message']; $conversation = $conversationService->createConversation($userId, $values['opponentId'], $values['subject'], $values['message']); $message = $conversationService->getLastMessage($conversation->id); if (!empty($_FILES['attachment']["tmp_name"])) { $attachmentService = BOL_AttachmentService::getInstance(); $uid = $_POST['uid']; $maxUploadSize = OW::getConfig()->getValue('base', 'attch_file_max_size_mb'); $validFileExtensions = json_decode(OW::getConfig()->getValue('base', 'attch_ext_list'), true); $dtoArr = $attachmentService->processUploadedFile('mailbox', $_FILES['attachment'], $uid, $validFileExtensions, $maxUploadSize); $files = $attachmentService->getFilesByBundleName('mailbox', $uid); if (!empty($files)) { $conversationService->addMessageAttachments($message->id, $files); } } BOL_AuthorizationService::getInstance()->trackAction('mailbox', $actionName); return array('result' => true, 'conversationId' => $message->conversationId); }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { parent::renderInput($params); if ($this->getValue() !== null) { $this->addAttribute('value', $this->value); } else { if ($this->getHasInvitation()) { $this->addAttribute('value', $this->invitation); $this->addAttribute('class', 'invitation'); } } $tag = UTIL_HtmlTag::generateTag('input', $this->attributes); if ($this->showCloseButton) { $tag .= '<a href="javascript://" class="ow_btn_close_search" id="' . $this->attributes['name'] . '_close_btn_search"></a>'; } return $tag; }
public function __construct($conversationId, $opponentId) { parent::__construct('newMessageForm'); $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA); $field = new HiddenField('attachment'); $this->addElement($field); $field = new HiddenField('conversationId'); $field->setValue($conversationId); $this->addElement($field); $field = new HiddenField('opponentId'); $field->setValue($opponentId); $this->addElement($field); $field = new HiddenField('uid'); $field->setValue(UTIL_HtmlTag::generateAutoId('mailbox_conversation_' . $conversationId . '_' . $opponentId)); $this->addElement($field); $this->setAction(OW::getRouter()->urlFor('MAILBOX_MCTRL_Messages', 'attachment')); }
public function transferCredits($userId, $receiveUser, $creditValue) { $debitValue = $creditValue * -1; $userCreditsService = USERCREDITS_BOL_CreditsService::getInstance(); $creditsService = CREDITS_BOL_Service::getInstance(); $sendItem = $this->logAction($creditsService->getSentActionId(), $userId, $debitValue); $receiveItem = $this->logAction($creditsService->getReceiveActionId(), $receiveUser, $creditValue); $userCreditsService->increaseBalance($receiveUser, $creditValue); $userCreditsService->decreaseBalance($userId, $creditValue); $sqlInsert = "INSERT INTO " . OW_DB_PREFIX . "credits_sent_log(senderItem, receiverItem, sender, receiver) \n VALUES(:sendItem, :receiveItem, :userId, :receiveUser)"; $qParams = array('sendItem' => $sendItem, 'receiveItem' => $receiveItem, 'userId' => $userId, 'receiveUser' => $receiveUser); OW::getDbo()->query($sqlInsert, $qParams); $service = BOL_UserService::getInstance(); $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId, $receiveUser)); $names = $service->getDisplayNamesForList(array($userId, $receiveUser)); $uUrls = $service->getUserUrlsForList(array($userId, $receiveUser)); if (OW::getConfig()->getValue('credits', 'enableNotification') == '1') { //Send notification to receiver $avatar = $avatars[$userId]; $notificationParams = array('pluginKey' => 'credits', 'action' => 'credits-received', 'entityType' => 'received', 'entityId' => $receiveItem, 'userId' => $receiveUser, 'time' => time()); $sender = '<a href="' . $uUrls[$userId] . '" target="_blank" >' . $names[$userId] . '</a>'; $notificationData = array('string' => array('key' => 'credits+notify_credits_received', 'vars' => array('sender' => $sender, 'credits' => $creditValue)), 'avatar' => $avatar, 'url' => $uUrls[$userId]); $event = new OW_Event('notifications.add', $notificationParams, $notificationData); OW::getEventManager()->trigger($event); } $subject = OW::getLanguage()->text('credits', 'credits_email_subject', array('requester_name' => $names[$userId], 'credits' => $creditValue)); $content = OW::getLanguage()->text('credits', 'credits_email_content', array('requester_name' => $names[$userId], 'requester_url' => $uUrls[$userId], 'credits' => $creditValue, 'user_url' => $uUrls[$receiveUser], 'name' => $names[$receiveUser])); if (OW::getConfig()->getValue('credits', 'enableEmail') == '1') { $tmpUser = $service->findUserById($receiveUser); $sitemail = OW::getConfig()->getValue('base', 'site_email'); $sitename = OW::getConfig()->getValue('base', 'site_name'); $mail = OW::getMailer()->createMail(); $mail->addRecipientEmail($tmpUser->getEmail()); $mail->setSender($sitemail, $sitename); $mail->setSenderSuffix(true); $mail->setSubject($subject); $mail->setHtmlContent($content); $mail->setTextContent(UTIL_HtmlTag::stripTags($content)); OW::getMailer()->addToQueue($mail); } if (OW::getConfig()->getValue('credits', 'enablePM') == '1') { $conversation = MAILBOX_BOL_ConversationService::getInstance()->createConversation($userId, $receiveUser, $subject, $content); } return true; }
/** * Smarty form error function. * * @author Sardar Madumarov <*****@*****.**> * @package ow.ow_smarty.plugin * @since 1.0 */ function smarty_function_error($params) { if (!isset($params['name'])) { throw new InvalidArgumentException('Empty input name!'); } $vr = OW_ViewRenderer::getInstance(); /* @var $form Form */ $form = $vr->getAssignedVar('_owActiveForm_'); if (!$form) { throw new InvalidArgumentException('There is no form for input `' . $params['name'] . '` !'); } $input = $form->getElement(trim($params['name'])); if ($input === null) { throw new WarningException('No input named `' . $params['name'] . '` in form !'); } $errors = $input->renderErrors(); return UTIL_HtmlTag::generateTag('span', array('id' => $input->getId() . '_error', 'style' => $errors ? 'display:block;' : 'display:none;', 'class' => 'error'), true, $errors); }
private function addUserList(EVENTX_BOL_Event $event, $status) { $configs = $this->eventService->getConfigs(); $language = OW::getLanguage(); $listTypes = $this->eventService->getUserListsArray(); $serviceConfigs = $this->eventService->getConfigs(); $userList = $this->eventService->findEventUsers($event->getId(), $status, null, $configs[EVENTX_BOL_EventService::CONF_EVENTX_USERS_COUNT]); $usersCount = $this->eventService->findEventUsersCount($event->getId(), $status); $idList = array(); foreach ($userList as $eventUser) { $idList[] = $eventUser->getUserId(); } $usersCmp = new BASE_CMP_AvatarUserList($idList); $linkId = UTIL_HtmlTag::generateAutoId('link'); $contId = UTIL_HtmlTag::generateAutoId('cont'); $this->userLists[] = array('contId' => $contId, 'cmp' => $usersCmp->render(), 'bottomLinkEnable' => $usersCount > $serviceConfigs[EVENTX_BOL_EventService::CONF_EVENTX_USERS_COUNT], 'toolbarArray' => array(array('label' => $language->text('eventx', 'avatar_user_list_bottom_link_label', array('count' => $usersCount)), 'href' => OW::getRouter()->urlForRoute('eventx.user_list', array('eventId' => $event->getId(), 'list' => $listTypes[(int) $status]))))); $this->userListMenu[] = array('label' => $language->text('eventx', 'avatar_user_list_link_label_' . $status), 'id' => $linkId, 'contId' => $contId, 'active' => sizeof($this->userListMenu) < 1 ? true : false); }
public function renderInput($params = null) { OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'location_search.js', "text/javascript", GOOGLELOCATION_BOL_LocationService::JQUERY_LOAD_PRIORITY + 1); OW::getDocument()->addOnloadScript(' $( document ).ready( function(){ window.googlemap_location_search = new OW_GoogleMapLocationSearch( ' . json_encode($this->getName()) . ',' . ' ' . json_encode($this->getId()) . ', ' . json_encode(GOOGLELOCATION_BOL_LocationService::getInstance()->getCountryRestriction()) . ' ); window.googlemap_location_search.initialize(); }); '); $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[address]', 'value' => !empty($this->value['address']) ? $this->escapeValue($this->value['address']) : ''); $html = UTIL_HtmlTag::generateTag('input', $attribute); $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[latitude]', 'value' => !empty($this->value['latitude']) ? $this->escapeValue($this->value['latitude']) : ''); $html .= UTIL_HtmlTag::generateTag('input', $attribute); $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[longitude]', 'value' => !empty($this->value['longitude']) ? $this->escapeValue($this->value['longitude']) : ''); $html .= UTIL_HtmlTag::generateTag('input', $attribute); $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[northEastLat]', 'value' => !empty($this->value['latitude']) ? $this->escapeValue($this->value['northEastLat']) : ''); $html .= UTIL_HtmlTag::generateTag('input', $attribute); $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[northEastLng]', 'value' => !empty($this->value['longitude']) ? $this->escapeValue($this->value['northEastLng']) : ''); $html .= UTIL_HtmlTag::generateTag('input', $attribute); $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[southWestLat]', 'value' => !empty($this->value['latitude']) ? $this->escapeValue($this->value['southWestLat']) : ''); $html .= UTIL_HtmlTag::generateTag('input', $attribute); $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[southWestLng]', 'value' => !empty($this->value['longitude']) ? $this->escapeValue($this->value['southWestLng']) : ''); $html .= UTIL_HtmlTag::generateTag('input', $attribute); $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[json]', 'value' => !empty($this->value['json']) ? $this->escapeValue($this->value['json']) : ''); $html .= UTIL_HtmlTag::generateTag('input', $attribute); $attribute = array('type' => 'text', 'name' => $this->getName() . '[distance]', 'class' => 'ow_googlelocation_search_distance', 'value' => !empty($this->value['distance']) ? $this->escapeValue($this->value['distance']) : ''); $html .= '<span>' . UTIL_HtmlTag::generateTag('input', $attribute) . '</span>'; if (OW::getConfig()->getValue('googlelocation', 'distance_units') == GOOGLELOCATION_BOL_LocationService::DISTANCE_UNITS_MILES) { $html .= '<span class="ow_googlelocation_search_miles_from" >' . OW::getLanguage()->text('googlelocation', 'miles_from') . '</span>'; } else { $html .= '<span class="ow_googlelocation_search_miles_from" >' . OW::getLanguage()->text('googlelocation', 'kms_from') . '</span>'; } $attribute = $this->attributes; unset($attribute['name']); $attribute['value'] = !empty($this->value['address']) ? $this->value['address'] : ''; $attribute['class'] .= ' ow_left ow_googlelocation_location_search_input'; if (empty($attribute['value']) && $this->hasInvitation) { $attribute['value'] = $this->invitation; $attribute['class'] .= ' invitation'; } $html .= '<div class="googlelocation_address_div">' . UTIL_HtmlTag::generateTag('input', $attribute) . '<div class="googlelocation_address_icon_div"> <span id=' . json_encode($this->getId() . '_icon') . ' style="' . (!empty($this->value['json']) ? 'display:none' : 'display:inline') . '" class="ic_googlemap_pin googlelocation_address_icon"></span> <div id=' . json_encode($this->getId() . '_delete_icon') . ' style="' . (empty($this->value['json']) ? 'display:none' : 'display:inline') . '" class="ow_miniic_delete googlelocation_delete_icon"></div> </div> </div>'; //$html .= '<div id="' . $this->getName() . '_map" style="margin-top:10px;width:90%;height:200px;display:none;"></div>'; return $html; }
/** * @see FormElement::renderInput() * * @param array $params * @return string */ public function renderInput($params = null) { parent::renderInput($params); $deleteLabel = OW::getLanguage()->text('base', 'delete'); if ($this->value) { // hide the input $this->attributes = array_merge($this->attributes, array('style' => 'display:none')); } $markup = '<div class="ow_avatar_field">'; $markup .= UTIL_HtmlTag::generateTag('input', $this->attributes); if (!$this->value) { $markup .= '<div class="ow_avatar_field_preview" style="display: none;"><img src="" alt="" /><span title="' . $deleteLabel . '"></span></div>'; } else { $markup .= '<div class="ow_avatar_field_preview" style="display: block;"><img src="' . $this->value . '" alt="" /><span title="' . $deleteLabel . '"></span></div>'; $markup .= '<input type="hidden" id="' . $this->getId() . '_preload_avatar" name="avatarPreloaded" value="1" />'; } $markup .= '<input type="hidden" name="' . $this->attributes['name'] . '" value="' . $this->value . '" class="ow_avatar_field_value" />'; $markup .= '</div>'; return $markup; }
/** * * @param string $menu * @param int $order * @return BOL_MenuItem */ public function createEmptyItem($menu, $order) { $menuItem = new BOL_MenuItem(); $documentKey = UTIL_HtmlTag::generateAutoId('mobile_page'); $menuItem->setDocumentKey($documentKey); $menuItem->setPrefix(self::MENU_PREFIX); $menuItem->setKey($documentKey); $menuItem->setType($menu); $menuItem->setOrder($order); $this->navigationService->saveMenuItem($menuItem); $document = new BOL_Document(); $document->isStatic = true; $document->isMobile = true; $document->setKey($menuItem->getKey()); $document->setUri($menuItem->getKey()); $this->navigationService->saveDocument($document); $document->setUri("cp-" . $document->getId()); $this->navigationService->saveDocument($document); $this->editItem($menuItem, array(self::SETTING_LABEL => OW::getLanguage()->text("mobile", "admin_nav_default_menu_name"), self::SETTING_TITLE => OW::getLanguage()->text("mobile", "admin_nav_default_page_title"), self::SETTING_CONTENT => OW::getLanguage()->text("mobile", "admin_nav_default_page_content"), self::SETTING_VISIBLE_FOR => 3)); return $menuItem; }
public function __construct($name) { if ($name === null || !$name || strlen(trim($name)) === 0) { throw new InvalidArgumentException('Invalid form element name!'); } $this->setName($name); $this->setId(UTIL_HtmlTag::generateAutoId('input')); $this->addAttribute('type', 'text'); $this->jsObjectName = self::CAPTCHA_PREFIX . preg_replace('/[^\\d^\\w]/', '_', $this->getId()); $this->addAttribute('style', 'width:100px;'); }