Exemple #1
0
 public function rsp()
 {
     if (!OW::getRequest()->isAjax()) {
         throw new Redirect403Exception();
     }
     if (!OW::getUser()->isAuthenticated()) {
         echo json_encode(array());
         exit;
     }
     $kw = $_GET['term'];
     $context = empty($_GET["context"]) ? MCOMPOSE_BOL_Service::CONTEXT_USER : $_GET["context"];
     $userId = OW::getUser()->getId();
     $entries = $this->service->getSuggestEntries($userId, $kw, null, $context);
     echo json_encode($entries);
     exit;
 }
Exemple #2
0
 /**
  * Returns class instance
  *
  * @return MCOMPOSE_BOL_Service
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Exemple #3
0
 /**
  * Constructor.
  *
  * @param string $name
  */
 public function __construct($name, $invitation = null, $context = MCOMPOSE_BOL_Service::CONTEXT_USER)
 {
     parent::__construct($name);
     if (!empty($invitation)) {
         $this->setInvitation($invitation);
     }
     $this->context = $context;
     $this->addClass('mc-user-select');
     $this->addClass('jhtmlarea');
     $this->service = MCOMPOSE_BOL_Service::getInstance();
 }
Exemple #4
0
 public function __construct($recipients = null, $context = MCOMPOSE_BOL_Service::CONTEXT_USER, $inPopup = true)
 {
     parent::__construct();
     $recipients = empty($recipients) ? array() : $recipients;
     $userId = OW::getUser()->getId();
     $isAuthorized = OW::getUser()->isAuthorized('mailbox', 'send_message');
     $this->assign('isAuthorized', $isAuthorized);
     $this->assign('permissionMessage', OW::getLanguage()->text('mailbox', 'write_permission_denied'));
     if (!$isAuthorized) {
         return;
     }
     $mailboxConfigs = OW::getConfig()->getValues('mailbox');
     $form = new MCOMPOSE_CLASS_Form(uniqid("mcmpose_send_message_form"), $userId, $context, true, $inPopup);
     $event = new OW_Event(MCOMPOSE_BOL_Service::EVENT_ON_INPUT_INIT, array("input" => $form->getElement("recipients"), "userId" => $userId, "context" => $context));
     OW::getEventManager()->trigger($event);
     $preloadedData = MCOMPOSE_BOL_Service::getInstance()->getSuggestEntries($userId, null, $recipients, $context);
     $values = array();
     foreach ($recipients as $r) {
         if (!empty($preloadedData[$r])) {
             $values[] = $preloadedData[$r];
         }
     }
     $form->getElement("recipients")->setData($preloadedData);
     $form->getElement("recipients")->setValue($values);
     $this->addForm($form);
     $attachmentsInput = $form->getElement("attachments");
     if (!empty($attachmentsInput)) {
         $this->assign("attachmentsId", $attachmentsInput->getId());
     }
     $this->assign("formName", $form->getName());
     $displayCaptcha = true;
     $this->assign('enableAttachments', !empty($mailboxConfigs['enable_attachments']));
     $this->assign('displayCaptcha', $displayCaptcha);
     $imagesUrl = OW::getPluginManager()->getPlugin('base')->getStaticCssUrl();
     $css = array('.mc-attachments .ow_mailbox_attachment { background-image: url(' . $imagesUrl . 'images/tag_bg.png); }');
     OW::getDocument()->addStyleDeclaration(implode("\n", $css));
     $jsParams = array("senderId" => $userId, "recipients" => $recipients, "context" => $context, "formId" => $form->getId(), "formName" => $form->getName());
     $js = UTIL_JsGenerator::composeJsString('var sendMessage = new MCOMPOSE.sendMessage({$params}, _scope);', array("params" => $jsParams));
     OW::getDocument()->addOnloadScript($js);
     OW::getLanguage()->addKeyForJs("mcompose", "close_fb_confirmation");
 }
 public function onCollectButtons(BASE_CLASS_EventCollector $event)
 {
     $params = $event->getParams();
     if ($params["entityType"] != HINT_BOL_Service::ENTITY_TYPE_USER) {
         return;
     }
     $userId = $params["entityId"];
     if (!OW::getUser()->isAuthenticated() || $userId == OW::getUser()->getId()) {
         return;
     }
     $uniqId = uniqid("hint-mc-");
     $js = UTIL_JsGenerator::newInstance();
     if (BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $userId)) {
         $js->jQueryEvent("#" . $uniqId, "click", 'OW.error(e.data.msg);', array('e'), array("msg" => OW::getLanguage()->text('base', 'user_block_message')));
     } else {
         $recipients = array(MCOMPOSE_CLASS_BaseBridge::ID_PREFIX . '_' . $userId);
         $recipientsData = MCOMPOSE_BOL_Service::getInstance()->getDataForIds($recipients);
         $js->jQueryEvent("#" . $uniqId, "click", 'HINT.getShown().hide(); OW.trigger("mailbox.open_new_message_form", e.data.data); return false;', array("e"), array("data" => array("opponentId" => $recipients, "mcompose" => array("context" => MCOMPOSE_BOL_Service::CONTEXT_USER, "data" => $recipientsData))));
     }
     OW::getDocument()->addOnloadScript($js);
     $button = array("key" => "mcompose", "label" => OW::getLanguage()->text('hint', 'button_send_message_label'), "attrs" => array("id" => $uniqId));
     $event->add($button);
 }