public function __construct($userId) { parent::__construct(); $data = OW::getEventManager()->call("photo.entity_albums_find", array("entityType" => "user", "entityId" => $userId)); $albums = empty($data["albums"]) ? array() : $data["albums"]; $source = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_source", $userId); $this->assign("source", $source == "album" ? "album" : "all"); $selectedAlbum = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_album", $userId); $form = new Form("pcGallerySettings"); $form->setEmptyElementsErrorMessage(null); $form->setAction(OW::getRouter()->urlFor("PCGALLERY_CTRL_Gallery", "saveSettings")); $element = new HiddenField("userId"); $element->setValue($userId); $form->addElement($element); $element = new Selectbox("album"); $element->setHasInvitation(true); $element->setInvitation(OW::getLanguage()->text("pcgallery", "settings_album_invitation")); $validator = new PCGALLERY_AlbumValidator(); $element->addValidator($validator); $albumsPhotoCount = array(); foreach ($albums as $album) { $element->addOption($album["id"], $album["name"] . " ({$album["photoCount"]})"); $albumsPhotoCount[$album["id"]] = $album["photoCount"]; if ($album["id"] == $selectedAlbum) { $element->setValue($album["id"]); } } OW::getDocument()->addOnloadScript(UTIL_JsGenerator::composeJsString('window.pcgallery_settingsAlbumCounts = {$albumsCount};', array("albumsCount" => $albumsPhotoCount))); $element->setLabel(OW::getLanguage()->text("pcgallery", "source_album_label")); $form->addElement($element); $submit = new Submit("save"); $submit->setValue(OW::getLanguage()->text("pcgallery", "save_settings_btn_label")); $form->addElement($submit); $this->addForm($form); }
/** * Application init actions. */ public function init() { require_once OW_DIR_SYSTEM_PLUGIN . 'base' . DS . 'classes' . DS . 'json_err_output.php'; OW_ErrorManager::getInstance()->setErrorOutput(new BASE_CLASS_JsonErrOutput()); $authToken = empty($_SERVER["HTTP_API_AUTH_TOKEN"]) ? null : $_SERVER["HTTP_API_AUTH_TOKEN"]; OW_Auth::getInstance()->setAuthenticator(new OW_TokenAuthenticator($authToken)); if (!empty($_SERVER["HTTP_API_LANGUAGE"])) { $tag = $_SERVER["HTTP_API_LANGUAGE"]; $languageDto = BOL_LanguageService::getInstance()->findByTag($tag); if (empty($languageDto)) { $tag = mb_substr($tag, 0, 2); $languageDto = BOL_LanguageService::getInstance()->findByTag($tag); } if (!empty($languageDto) && $languageDto->status == "active") { BOL_LanguageService::getInstance()->setCurrentLanguage($languageDto); } } $this->detectLanguage(); // setting default time zone date_default_timezone_set(OW::getConfig()->getValue('base', 'site_timezone')); if (OW::getUser()->isAuthenticated()) { $userId = OW::getUser()->getId(); $timeZone = BOL_PreferenceService::getInstance()->getPreferenceValue('timeZoneSelect', $userId); if (!empty($timeZone)) { date_default_timezone_set($timeZone); } } // synchronize the db's time zone OW::getDbo()->setTimezone(); // OW::getRequestHandler()->setIndexPageAttributes('BASE_CTRL_ComponentPanel'); // OW::getRequestHandler()->setStaticPageAttributes('BASE_CTRL_StaticDocument'); // // // router init - need to set current page uri and base url $router = OW::getRouter(); $router->setBaseUrl(OW_URL_HOME . 'api/'); $uri = OW::getRequest()->getRequestUri(); // before setting in router need to remove get params if (strstr($uri, '?')) { $uri = substr($uri, 0, strpos($uri, '?')); } $router->setUri($uri); $router->setDefaultRoute(new OW_ApiDefaultRoute()); OW::getPluginManager()->initPlugins(); $event = new OW_Event(OW_EventManager::ON_PLUGINS_INIT); OW::getEventManager()->trigger($event); $beckend = OW::getEventManager()->call('base.cache_backend_init'); if ($beckend !== null) { OW::getCacheManager()->setCacheBackend($beckend); OW::getCacheManager()->setLifetime(3600); OW::getDbo()->setUseCashe(true); } OW::getResponse()->setDocument($this->newDocument()); if (OW::getUser()->isAuthenticated()) { BOL_UserService::getInstance()->updateActivityStamp(OW::getUser()->getId(), $this->getContext()); } }
public function apiUnsubscribe($params) { if (empty($params['emails']) || !is_array($params['emails'])) { throw new InvalidArgumentException('Invalid email list'); } foreach ($params['emails'] as $email) { $user = BOL_UserService::getInstance()->findByEmail($email); if ($user === null) { throw new LogicException('User with email ' . $email . ' not found'); } BOL_PreferenceService::getInstance()->savePreferenceValue('mass_mailing_subscribe', false, $user->id); } }
public function saveSettings() { $source = $_POST["source"] == "all" ? "all" : "album"; $album = $_POST["album"]; $userId = $_POST["userId"]; if ($userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized("pcgallery")) { throw new Redirect403Exception(); } BOL_PreferenceService::getInstance()->savePreferenceValue("pcgallery_album", $album, $userId); BOL_PreferenceService::getInstance()->savePreferenceValue("pcgallery_source", $source, $userId); OW::getFeedback()->info(OW::getLanguage()->text("pcgallery", "settings_saved_message")); $this->redirect(BOL_UserService::getInstance()->getUserUrl($userId)); }
/** * Application init actions. */ public function init() { // router init - need to set current page uri and base url $router = OW::getRouter(); $router->setBaseUrl(OW_URL_HOME); $this->urlHostRedirect(); OW_Auth::getInstance()->setAuthenticator(new OW_SessionAuthenticator()); $this->userAutoLogin(); // setting default time zone date_default_timezone_set(OW::getConfig()->getValue('base', 'site_timezone')); if (OW::getUser()->isAuthenticated()) { $userId = OW::getUser()->getId(); $timeZone = BOL_PreferenceService::getInstance()->getPreferenceValue('timeZoneSelect', $userId); if (!empty($timeZone)) { date_default_timezone_set($timeZone); } } // synchronize the db's time zone OW::getDbo()->setTimezone(); // OW::getRequestHandler()->setIndexPageAttributes('BASE_CTRL_ComponentPanel'); OW::getRequestHandler()->setStaticPageAttributes('BASE_MCTRL_BaseDocument', 'staticDocument'); $uri = OW::getRequest()->getRequestUri(); // before setting in router need to remove get params if (strstr($uri, '?')) { $uri = substr($uri, 0, strpos($uri, '?')); } $router->setUri($uri); $defaultRoute = new OW_DefaultRoute(); //$defaultRoute->setControllerNamePrefix('MCTRL'); $router->setDefaultRoute($defaultRoute); $navService = BOL_NavigationService::getInstance(); // // // try to find static document with current uri // $document = $navService->findStaticDocument($uri); // // if ( $document !== null ) // { // $this->documentKey = $document->getKey(); // } OW::getPluginManager()->initPlugins(); $event = new OW_Event(OW_EventManager::ON_PLUGINS_INIT); OW::getEventManager()->trigger($event); $beckend = OW::getEventManager()->call('base.cache_backend_init'); if ($beckend !== null) { OW::getCacheManager()->setCacheBackend($beckend); OW::getCacheManager()->setLifetime(3600); OW::getDbo()->setUseCashe(true); } $this->devActions(); OW::getThemeManager()->initDefaultTheme(true); // setting current theme $activeThemeName = OW::getEventManager()->call('base.get_active_theme_name'); $activeThemeName = $activeThemeName ? $activeThemeName : OW::getConfig()->getValue('base', 'selectedTheme'); if ($activeThemeName !== BOL_ThemeService::DEFAULT_THEME && OW::getThemeManager()->getThemeService()->themeExists($activeThemeName)) { OW_ThemeManager::getInstance()->setCurrentTheme(BOL_ThemeService::getInstance()->getThemeObjectByName(trim($activeThemeName), true)); } // adding static document routes $staticDocs = $navService->findAllMobileStaticDocuments(); $staticPageDispatchAttrs = OW::getRequestHandler()->getStaticPageAttributes(); /* @var $value BOL_Document */ foreach ($staticDocs as $value) { OW::getRouter()->addRoute(new OW_Route($value->getKey(), $value->getUri(), $staticPageDispatchAttrs['controller'], $staticPageDispatchAttrs['action'], array('documentKey' => array(OW_Route::PARAM_OPTION_HIDDEN_VAR => $value->getKey())))); // TODO refactor - hotfix for TOS page if (UTIL_String::removeFirstAndLastSlashes($value->getUri()) == 'terms-of-use') { OW::getRequestHandler()->addCatchAllRequestsExclude('base.members_only', $staticPageDispatchAttrs['controller'], $staticPageDispatchAttrs['action'], array('documentKey' => $value->getKey())); } } //adding index page route $item = BOL_NavigationService::getInstance()->findFirstLocal(OW::getUser()->isAuthenticated() ? BOL_NavigationService::VISIBLE_FOR_MEMBER : BOL_NavigationService::VISIBLE_FOR_GUEST, OW_Navigation::MOBILE_TOP); if ($item !== null) { if ($item->getRoutePath()) { $route = OW::getRouter()->getRoute($item->getRoutePath()); $ddispatchAttrs = $route->getDispatchAttrs(); } else { $ddispatchAttrs = OW::getRequestHandler()->getStaticPageAttributes(); } $router->addRoute(new OW_Route('base_default_index', '/', $ddispatchAttrs['controller'], $ddispatchAttrs['action'], array('documentKey' => array(OW_Route::PARAM_OPTION_HIDDEN_VAR => $item->getDocumentKey())))); $this->indexMenuItem = $item; OW::getEventManager()->bind(OW_EventManager::ON_AFTER_REQUEST_HANDLE, array($this, 'activateMenuItem')); } else { $router->addRoute(new OW_Route('base_default_index', '/', 'BASE_MCTRL_WidgetPanel', 'index')); } if (!OW::getRequest()->isAjax()) { OW::getResponse()->setDocument($this->newDocument()); OW::getDocument()->setMasterPage(new OW_MobileMasterPage()); OW::getResponse()->setHeader(OW_Response::HD_CNT_TYPE, OW::getDocument()->getMime() . '; charset=' . OW::getDocument()->getCharset()); } else { OW::getResponse()->setDocument(new OW_AjaxDocument()); } /* additional actions */ if (OW::getUser()->isAuthenticated()) { BOL_UserService::getInstance()->updateActivityStamp(OW::getUser()->getId(), $this->getContext()); } // adding global template vars $currentThemeImagesDir = OW::getThemeManager()->getCurrentTheme()->getStaticImagesUrl(); $viewRenderer = OW_ViewRenderer::getInstance(); $viewRenderer->assignVar('themeImagesUrl', $currentThemeImagesDir); $viewRenderer->assignVar('siteName', OW::getConfig()->getValue('base', 'site_name')); $viewRenderer->assignVar('siteTagline', OW::getConfig()->getValue('base', 'site_tagline')); $viewRenderer->assignVar('siteUrl', OW_URL_HOME); $viewRenderer->assignVar('isAuthenticated', OW::getUser()->isAuthenticated()); $viewRenderer->assignVar('bottomPoweredByLink', '<a href="http://www.oxwall.org/" target="_blank" title="Powered by Oxwall Community Software"><img src="' . $currentThemeImagesDir . 'powered-by-oxwall.png" alt="Oxwall Community Software" /></a>'); $viewRenderer->assignVar('adminDashboardIframeUrl', "http://static.oxwall.org/spotlight/?platform=oxwall&platform-version=" . OW::getConfig()->getValue('base', 'soft_version') . "&platform-build=" . OW::getConfig()->getValue('base', 'soft_build')); if (function_exists('ow_service_actions')) { call_user_func('ow_service_actions'); } $this->handleHttps(); }
/** * * @param string $name * @return Form */ public function getUserSettingsForm() { $form = new Form('im_user_settings_form'); $form->setAjax(true); $form->setAction(OW::getRouter()->urlFor('AJAXIM_CTRL_Action', 'processUserSettingsForm')); $form->setAjaxResetOnSuccess(false); $form->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n OW_InstantChat_App.setSoundEnabled(data.im_soundEnabled);\n }"); $findContact = new ImSearchField('im_find_contact'); $findContact->setHasInvitation(true); $findContact->setInvitation(OW::getLanguage()->text('ajaxim', 'find_contact')); $form->addElement($findContact); $enableSound = new CheckboxField('im_enable_sound'); $user_preference_enable_sound = BOL_PreferenceService::getInstance()->getPreferenceValue('ajaxim_user_settings_enable_sound', OW::getUser()->getId()); $enableSound->setValue($user_preference_enable_sound); $enableSound->setLabel(OW::getLanguage()->text('ajaxim', 'enable_sound_label')); $form->addElement($enableSound); $userIdHidden = new HiddenField('user_id'); $form->addElement($userIdHidden); return $form; }
public function render() { OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("base")->getStaticJsUrl() . "jquery-ui.min.js"); OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('ajaxim')->getStaticJsUrl() . 'audio-player.js'); OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('ajaxim')->getStaticJsUrl() . 'ajaxim.js'); $node = OW::getUser()->getId(); $password = ''; $domain = 'localhost'; $port = 0; $username = BOL_UserService::getInstance()->getDisplayName($node); $avatar = BOL_AvatarService::getInstance()->getAvatarUrl(OW::getUser()->getId()); if (empty($avatar)) { $avatar = BOL_AvatarService::getInstance()->getDefaultAvatarUrl(); } $jsGenerator = UTIL_JsGenerator::newInstance(); $jsGenerator->setVariable('im_oldTitle', OW::getDocument()->getTitle()); $jsGenerator->setVariable('im_soundEnabled', (bool) BOL_PreferenceService::getInstance()->getPreferenceValue('ajaxim_user_settings_enable_sound', OW::getUser()->getId())); $jsGenerator->setVariable('im_awayTimeout', 5000); //TODO change to 30000 $jsGenerator->setVariable('im_soundSwf', OW::getPluginManager()->getPlugin('ajaxim')->getStaticUrl() . 'js/player.swf'); $jsGenerator->setVariable('im_soundUrl', OW::getPluginManager()->getPlugin('ajaxim')->getStaticUrl() . 'sound/receive.mp3'); $jsGenerator->setVariable('window.ajaximLogMsgUrl', OW::getRouter()->urlFor('AJAXIM_CTRL_Action', 'logMsg')); $jsGenerator->setVariable('window.ajaximGetLogUrl', OW::getRouter()->urlFor('AJAXIM_CTRL_Action', 'getLog')); $jsGenerator->setVariable('window.im_updateUserInfoUrl', OW::getRouter()->urlFor('AJAXIM_CTRL_Action', 'updateUserInfo')); $jsGenerator->setVariable('window.im_userBlockedMessage', OW::getLanguage()->text('base', 'user_block_message')); $site_timezone = OW::getConfig()->getValue('base', 'site_timezone'); $site_datetimezone = new DateTimeZone($site_timezone); $site_datetime = new DateTime("now", $site_datetimezone); $jsGenerator->setVariable('ajaximSiteTimezoneOffset', $site_datetimezone->getOffset($site_datetime) * 1000); $isFriendsOnlyMode = (bool) OW::getEventManager()->call('plugin.friends'); $jsGenerator->setVariable('im_isFriendsOnlyMode', (bool) $isFriendsOnlyMode); $privacyPluginActive = OW::getEventManager()->call('plugin.privacy'); $this->assign('privacyPluginActive', $privacyPluginActive); $privacyActionValue = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => OW::getUser()->getId(), 'action' => 'ajaxim_invite_to_chat')); $jsGenerator->setVariable('im_privacyActionValue', $privacyActionValue); if ($privacyPluginActive) { $this->assign('privacy_settings_url', OW::getRouter()->urlForRoute('privacy_index')); $visibleForFriends = $privacyActionValue == 'friends_only'; $visibleForEverybody = $privacyActionValue == 'everybody'; } else { $visibleForFriends = false; $visibleForEverybody = true; } $jsGenerator->setVariable('im_visibleForFriends', $visibleForFriends); $jsGenerator->setVariable('im_visibleForEverybody', $visibleForEverybody); $this->assign('im_sound_url', OW::getPluginManager()->getPlugin('ajaxim')->getStaticUrl() . 'sound/receive.mp3'); /* Instant Chat DEBUG MODE */ $debugMode = false; $jsGenerator->setVariable('im_debug_mode', $debugMode); $this->assign('debug_mode', $debugMode); $variables = $jsGenerator->generateJs(); $details = array('userId' => OW::getUser()->getId(), 'node' => $node, 'password' => $password, 'username' => $username, 'domain' => $domain, 'avatar' => $avatar); OW::getDocument()->addScriptDeclaration("window.OW_InstantChat.Details = " . json_encode($details) . ";\n " . $variables); $userSettingsForm = AJAXIM_BOL_Service::getInstance()->getUserSettingsForm(); $this->addForm($userSettingsForm); $userSettingsForm->getElement('user_id')->setValue(OW::getUser()->getId()); $avatar_proto_data = array('url' => 1, 'src' => BOL_AvatarService::getInstance()->getDefaultAvatarUrl(), 'class' => 'talk_box_avatar'); $this->assign('avatar_proto_data', $avatar_proto_data); $this->assign('no_avatar_url', BOL_AvatarService::getInstance()->getDefaultAvatarUrl()); $this->assign('online_list_url', OW::getRouter()->urlForRoute('base_user_lists', array('list' => 'online'))); return parent::render(); }
public function index($params) { $userId = OW::getUser()->getId(); if (OW::getRequest()->isAjax()) { exit; } if (!OW::getUser()->isAuthenticated() || $userId === null) { throw new AuthenticateException(); } $language = OW::getLanguage(); $this->setPageHeading($language->text('base', 'preference_index')); $this->setPageHeadingIconClass('ow_ic_gear_wheel'); // -- Preference form -- $preferenceForm = new Form('preferenceForm'); $preferenceForm->setId('preferenceForm'); $preferenceSubmit = new Submit('preferenceSubmit'); $preferenceSubmit->addAttribute('class', 'ow_button ow_ic_save'); $preferenceSubmit->setValue($language->text('base', 'preference_submit_button')); $preferenceForm->addElement($preferenceSubmit); // -- $sectionList = BOL_PreferenceService::getInstance()->findAllSections(); $preferenceList = BOL_PreferenceService::getInstance()->findAllPreference(); $preferenceNameList = array(); foreach ($preferenceList as $preference) { $preferenceNameList[$preference->key] = $preference->key; } $preferenceValuesList = BOL_PreferenceService::getInstance()->getPreferenceValueListByUserIdList($preferenceNameList, array($userId)); $formElementEvent = new BASE_CLASS_EventCollector(BOL_PreferenceService::PREFERENCE_ADD_FORM_ELEMENT_EVENT, array('values' => $preferenceValuesList[$userId])); OW::getEventManager()->trigger($formElementEvent); $data = $formElementEvent->getData(); $formElements = empty($data) ? array() : call_user_func_array('array_merge', $data); $formElementList = array(); foreach ($formElements as $formElement) { /* @var $formElement FormElement */ $formElementList[$formElement->getName()] = $formElement; } $resultList = array(); foreach ($sectionList as $section) { foreach ($preferenceList as $preference) { if ($preference->sectionName === $section->name && !empty($formElementList[$preference->key])) { $resultList[$section->name][$preference->key] = $preference->key; $element = $formElementList[$preference->key]; $preferenceForm->addElement($element); } } } if (OW::getRequest()->isPost()) { if ($preferenceForm->isValid($_POST)) { $values = $preferenceForm->getValues(); $restul = BOL_PreferenceService::getInstance()->savePreferenceValues($values, $userId); if ($restul) { OW::getFeedback()->info($language->text('base', 'preference_preference_data_was_saved')); } else { OW::getFeedback()->warning($language->text('base', 'preference_preference_data_not_changed')); } $this->redirect(); } } $this->addForm($preferenceForm); $data = array(); $sectionLabelEvent = new BASE_CLASS_EventCollector(BOL_PreferenceService::PREFERENCE_SECTION_LABEL_EVENT); OW::getEventManager()->trigger($sectionLabelEvent); $data = $sectionLabelEvent->getData(); $sectionLabels = empty($data) ? array() : call_user_func_array('array_merge', $data); $this->assign('preferenceList', $resultList); $this->assign('sectionLabels', $sectionLabels); }
public function onBeforeRender() { parent::onBeforeRender(); $permissions = $this->getPemissions(); PCGALLERY_CLASS_PhotoBridge::getInstance()->initFloatbox(); $staticUrl = OW::getPluginManager()->getPlugin('pcgallery')->getStaticUrl(); OW::getDocument()->addStyleSheet($staticUrl . 'style.css'); OW::getDocument()->addScript($staticUrl . 'script.js'); $this->assign("avatarApproval", $this->avatarDto && $this->avatarDto->status != "active"); $this->initJs($permissions); $toolbar = new BASE_CMP_ProfileActionToolbar($this->userId); $this->addComponent('actionToolbar', $toolbar); $this->assign('uniqId', $this->uniqId); $this->assign('user', $this->getUserInfo()); $this->assign('permissions', $permissions); $photos = $permissions["view"] ? $this->getPhotos() : array(); $this->assign('empty', empty($photos)); if (empty($photos)) { $this->initEmptyGallery(); } else { $this->initFullGallery(); } $this->assign('photos', $photos); $source = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_source", $this->userId); $settings = array("changeInterval" => self::PHOTO_CHANGE_INTERVAL, "userId" => $this->userId, "listType" => $source == "all" ? "userPhotos" : "albumPhotos"); $js = UTIL_JsGenerator::newInstance(); $js->callFunction(array('PCGALLERY', 'init'), array($this->uniqId, $settings, $photos)); OW::getDocument()->addOnloadScript($js); OW::getLanguage()->addKeyForJs("pcgallery", "setting_fb_title"); }
public function onPluginsInitCheckUserStatus() { if (OW::getUser()->isAuthenticated()) { $user = BOL_UserService::getInstance()->findUserById(OW::getUser()->getId()); $signOutDispatchAttrs = OW::getRouter()->getRoute('base_sign_out')->getDispatchAttrs(); if (empty($signOutDispatchAttrs['controller']) || empty($signOutDispatchAttrs['action'])) { $signOutDispatchAttrs['controller'] = 'BASE_CTRL_User'; $signOutDispatchAttrs['action'] = 'signOut'; } if (OW::getConfig()->getValue('base', 'mandatory_user_approve') && !BOL_UserService::getInstance()->isApproved()) { OW::getRequestHandler()->setCatchAllRequestsAttributes('base.wait_for_approval', array('controller' => 'BASE_MCTRL_WaitForApproval', 'action' => 'index')); OW::getRequestHandler()->addCatchAllRequestsExclude('base.wait_for_approval', $signOutDispatchAttrs['controller'], $signOutDispatchAttrs['action']); OW::getRequestHandler()->addCatchAllRequestsExclude('base.wait_for_approval', 'BASE_MCTRL_AjaxLoader', 'component'); OW::getRequestHandler()->addCatchAllRequestsExclude('base.wait_for_approval', 'BASE_MCTRL_Invitations', 'command'); OW::getRequestHandler()->addCatchAllRequestsExclude('base.wait_for_approval', 'BASE_MCTRL_Ping', 'index'); } if ($user !== null) { if (BOL_UserService::getInstance()->isSuspended($user->getId()) && !OW::getUser()->isAdmin()) { OW::getRequestHandler()->setCatchAllRequestsAttributes('base.suspended_user', array('controller' => 'BASE_MCTRL_SuspendedUser', 'action' => 'index')); OW::getRequestHandler()->addCatchAllRequestsExclude('base.suspended_user', $signOutDispatchAttrs['controller'], $signOutDispatchAttrs['action']); OW::getRequestHandler()->addCatchAllRequestsExclude('base.suspended_user', 'BASE_MCTRL_AjaxLoader'); OW::getRequestHandler()->addCatchAllRequestsExclude('base.suspended_user', 'BASE_MCTRL_Invitations', 'command'); OW::getRequestHandler()->addCatchAllRequestsExclude('base.suspended_user', 'BASE_MCTRL_Ping', 'index'); } if ((int) $user->emailVerify === 0 && OW::getConfig()->getValue('base', 'confirm_email')) { OW::getRequestHandler()->setCatchAllRequestsAttributes('base.email_verify', array(OW_RequestHandler::CATCH_ALL_REQUEST_KEY_CTRL => 'BASE_MCTRL_EmailVerify', OW_RequestHandler::CATCH_ALL_REQUEST_KEY_ACTION => 'index')); OW::getRequestHandler()->addCatchAllRequestsExclude('base.email_verify', $signOutDispatchAttrs['controller'], $signOutDispatchAttrs['action']); OW::getRequestHandler()->addCatchAllRequestsExclude('base.email_verify', 'BASE_MCTRL_EmailVerify'); } $accountType = BOL_QuestionService::getInstance()->findAccountTypeByName($user->accountType); if (empty($accountType)) { OW::getRequestHandler()->setCatchAllRequestsAttributes('base.complete_profile.account_type', array('controller' => 'BASE_MCTRL_CompleteProfile', 'action' => 'fillAccountType')); OW::getRequestHandler()->addCatchAllRequestsExclude('base.complete_profile.account_type', $signOutDispatchAttrs['controller'], $signOutDispatchAttrs['action']); OW::getRequestHandler()->addCatchAllRequestsExclude('base.complete_profile.account_type', 'BASE_MCTRL_AjaxLoader'); OW::getRequestHandler()->addCatchAllRequestsExclude('base.complete_profile.account_type', 'BASE_MCTRL_Invitations'); OW::getRequestHandler()->addCatchAllRequestsExclude('base.complete_profile.account_type', 'BASE_MCTRL_Ping'); } else { $questionsEditStamp = OW::getConfig()->getValue('base', 'profile_question_edit_stamp'); $updateDetailsStamp = BOL_PreferenceService::getInstance()->getPreferenceValue('profile_details_update_stamp', OW::getUser()->getId()); if ($questionsEditStamp >= (int) $updateDetailsStamp) { require_once OW_DIR_CORE . 'validator.php'; $questionList = BOL_QuestionService::getInstance()->getEmptyRequiredQuestionsList($user->id); if (!empty($questionList)) { OW::getRequestHandler()->setCatchAllRequestsAttributes('base.complete_profile', array('controller' => 'BASE_MCTRL_CompleteProfile', 'action' => 'fillRequiredQuestions')); OW::getRequestHandler()->addCatchAllRequestsExclude('base.complete_profile', $signOutDispatchAttrs['controller'], $signOutDispatchAttrs['action']); OW::getRequestHandler()->addCatchAllRequestsExclude('base.complete_profile', 'BASE_MCTRL_AjaxLoader'); OW::getRequestHandler()->addCatchAllRequestsExclude('base.complete_profile', 'BASE_CTRL_AjaxLoader'); OW::getRequestHandler()->addCatchAllRequestsExclude('base.complete_profile', 'BASE_MCTRL_Invitations'); OW::getRequestHandler()->addCatchAllRequestsExclude('base.complete_profile', 'BASE_MCTRL_Ping'); } else { BOL_PreferenceService::getInstance()->savePreferenceValue('profile_details_update_stamp', time(), OW::getUser()->getId()); } } } } else { OW::getUser()->logout(); } } }
`from` INTEGER(11) NOT NULL, `to` INTEGER(11) NOT NULL, `message` TEXT COLLATE utf8_general_ci DEFAULT NULL, `timestamp` INTEGER(11) NOT NULL, `read` INTEGER(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) )ENGINE=MyISAM CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'; EOT; OW::getDbo()->query($sql); $authorization = OW::getAuthorization(); $groupName = 'ajaxim'; $authorization->addGroup($groupName, false); $authorization->addAction($groupName, 'chat'); /* Update to 3555 */ $ajaxim_user_preference_section = BOL_PreferenceService::getInstance()->findSection('ajaxim'); if (empty($ajaxim_user_preference_section)) { $ajaxim_user_preference_section = new BOL_PreferenceSection(); $ajaxim_user_preference_section->name = 'ajaxim'; $ajaxim_user_preference_section->sortOrder = 0; BOL_PreferenceService::getInstance()->savePreferenceSection($ajaxim_user_preference_section); } $ajaxim_user_preference = BOL_PreferenceService::getInstance()->findPreference('ajaxim_user_settings_enable_sound'); if (empty($ajaxim_user_preference)) { $ajaxim_user_preference = new BOL_Preference(); $ajaxim_user_preference->key = 'ajaxim_user_settings_enable_sound'; $ajaxim_user_preference->defaultValue = true; $ajaxim_user_preference->sectionName = 'ajaxim'; $ajaxim_user_preference->sortOrder = 0; BOL_PreferenceService::getInstance()->savePreference($ajaxim_user_preference); }
/** * @param $userId * @param string $sortOrder * @return array */ private function getQueryParams($userId, $sortOrder = 'newest') { $questionService = BOL_QuestionService::getInstance(); $userService = BOL_UserService::getInstance(); $matchFields = $this->findAll(); $prefix = 'qd'; $counter = 0; $innerJoin = ''; $leftJoin = ''; $where = ''; $compatibility = ''; foreach ($matchFields as $field) { $question = $questionService->findQuestionByName($field->questionName); if (!$question) { continue; } $matchQuestion = $questionService->findQuestionByName($field->matchQuestionName); if (!$matchQuestion) { continue; } $checkData = $questionService->getQuestionData(array($userId), array($field->matchQuestionName)); if (empty($checkData[$userId][$field->matchQuestionName])) { if ($field->required) { return array(); } } $value1 = null; if (isset($checkData[$userId][$field->matchQuestionName])) { $value1 = $checkData[$userId][$field->matchQuestionName]; } if (!empty($value1)) { if ($field->required) { $questionString = $this->prepareQuestionWhere($question, $value1, $prefix . $counter); if (!empty($questionString)) { if ($question->base == 1) { $where .= ' OR ' . $questionString; } else { $innerJoin .= "\n INNER JOIN `" . BOL_QuestionDataDao::getInstance()->getTableName() . "` `" . $prefix . $counter . "`\n ON ( `user`.`id` = `" . $prefix . $counter . "`.`userId` AND `" . $prefix . $counter . "`.`questionName` = '" . $this->dbo->escapeString($question->name) . "' AND " . $questionString . " ) "; //$compatibility .= ' IF( `' . $prefix . $counter . '`.`questionName` IS NOT NULL, ' . MATCHMAKING_BOL_Service::MAX_COEFFICIENT . ', 0 ) +'; $counter++; } } $checkData2 = $questionService->getQuestionData(array($userId), array($field->questionName)); if (empty($checkData2[$userId][$field->questionName])) { continue; } $value2 = $checkData2[$userId][$field->questionName]; $questionString = $this->prepareQuestionWhere($matchQuestion, $value2, $prefix . $counter); if (!empty($questionString)) { if ($matchQuestion->base == 1) { $where .= ' OR ' . $questionString; } else { $innerJoin .= "\n INNER JOIN `" . BOL_QuestionDataDao::getInstance()->getTableName() . "` `" . $prefix . $counter . "`\n ON ( `user`.`id` = `" . $prefix . $counter . "`.`userId` AND `" . $prefix . $counter . "`.`questionName` = '" . $this->dbo->escapeString($matchQuestion->name) . "' AND " . $questionString . " ) "; $counter++; } } } else { $questionString = $this->prepareQuestionWhere($question, $value1, $prefix . $counter); if (!empty($questionString)) { if ($question->base == 1) { $where .= ' OR ' . $questionString; } else { $leftJoin .= "\n LEFT JOIN `" . BOL_QuestionDataDao::getInstance()->getTableName() . "` `" . $prefix . $counter . "` ON ( `user`.`id` = `" . $prefix . $counter . "`.`userId` AND `" . $prefix . $counter . "`.`questionName` = '" . $this->dbo->escapeString($question->name) . "' AND " . $questionString . " ) "; $compatibility .= ' IF( `' . $prefix . $counter . '`.`questionName` IS NOT NULL, ' . $field->coefficient . ', 0 ) +'; $counter++; } } } } else { $compatibility .= ' ' . $field->coefficient . ' +'; } } /**/ if ($sortOrder == 'newest') { $order = ' `user`.`joinStamp` DESC, '; } else { if ($sortOrder == 'mail') { $order = ' `user`.`joinStamp` DESC, '; $matchmaking_lastmatch_userid = BOL_PreferenceService::getInstance()->getPreferenceValue('matchmaking_lastmatch_userid', $userId); $where = ' AND `user`.`id` > ' . $matchmaking_lastmatch_userid; } else { if ($sortOrder == 'compatible') { //$order = '(' . substr($compatibility, 0, -1) . ') DESC , '; $order = '`matches`.`compatibility` DESC , '; } } } if (empty($compatibility)) { return array(); } $result = array('userId' => $userId, 'join' => $innerJoin . $leftJoin, 'where' => $where, 'order' => $order, 'compatibility' => '(' . substr($compatibility, 0, -1) . ')'); // pve($result); return $result; }
private function getQueryParamsForUserIdList($userId, $userIdList, $sortOrder = 'newest') { $questionService = BOL_QuestionService::getInstance(); $userService = BOL_UserService::getInstance(); $matchFields = $this->findAll(); $prefix = 'qd'; $counter = 0; $innerJoin = ''; $leftJoin = ''; $where = ''; $compatibility = ' 0 +'; $requiredCompatibility = ' 1 *'; foreach ($matchFields as $field) { $question = $questionService->findQuestionByName($field->questionName); if (!$question) { continue; } $matchQuestion = $questionService->findQuestionByName($field->matchQuestionName); if (!$matchQuestion) { continue; } $checkData = $questionService->getQuestionData(array($userId), array($field->matchQuestionName)); if (empty($checkData[$userId][$field->matchQuestionName])) { if ($field->required) { return array(); } } $value1 = null; if (isset($checkData[$userId][$field->matchQuestionName])) { $value1 = $checkData[$userId][$field->matchQuestionName]; } if (!empty($value1)) { if ($field->required) { // calculate compatibility for required fields $questionString = $this->prepareQuestionWhere($question, $value1, $prefix . $counter); if (!empty($questionString)) { // there is no base match questions // if ( $question->base == 1 ) // { // $where .= ' OR ' . $questionString; // // if users don't match by required field than compatibility = 0 // $requiredCompatibility .= ' IF( ' . $questionString . ', 1, 0 ) *'; // } // else // { $innerJoin .= "\n LEFT JOIN `" . BOL_QuestionDataDao::getInstance()->getTableName() . "` `" . $prefix . $counter . "`\n ON ( `user`.`id` = `" . $prefix . $counter . "`.`userId` AND `" . $prefix . $counter . "`.`questionName` = '" . $this->dbo->escapeString($question->name) . "' AND " . $questionString . " ) "; $compatibility .= ' IF( `' . $prefix . $counter . '`.`questionName` IS NOT NULL, ' . $field->coefficient . ', 0 ) +'; // if users don't match by required field than compatibility = 0 $requiredCompatibility .= ' IF( `' . $prefix . $counter . '`.`id` IS NOT NULL, 1, 0 ) *'; // } $counter++; } $checkData2 = $questionService->getQuestionData(array($userId), array($field->questionName)); if (empty($checkData2[$userId][$field->questionName])) { continue; } $value2 = $checkData2[$userId][$field->questionName]; $questionString = $this->prepareQuestionWhere($matchQuestion, $value2, $prefix . $counter); if (!empty($questionString)) { // there is no base match questions // if ( $matchQuestion->base == 1 ) // { // $where .= ' OR ' . $questionString; // // if users don't match by required field than compatibility = 0 // $requiredCompatibility .= ' IF( ' . $questionString . ', 1, 0 ) *'; // } // else // { $innerJoin .= "\n LEFT JOIN `" . BOL_QuestionDataDao::getInstance()->getTableName() . "` `" . $prefix . $counter . "`\n ON ( `user`.`id` = `" . $prefix . $counter . "`.`userId` AND `" . $prefix . $counter . "`.`questionName` = '" . $this->dbo->escapeString($matchQuestion->name) . "' AND " . $questionString . " ) "; // if users don't match by required field than compatibility = 0 $requiredCompatibility .= ' IF( `' . $prefix . $counter . '`.`questionName` IS NOT NULL, 1, 0 ) *'; // } $counter++; } } else { // calculate compatibility for not required fields $questionString = $this->prepareQuestionWhere($question, $value1, $prefix . $counter); if (!empty($questionString)) { // there is no base match questions // if ( $question->base == 1 ) // { // $where .= ' OR ' . $questionString; // } // else // { $leftJoin .= "\n LEFT JOIN `" . BOL_QuestionDataDao::getInstance()->getTableName() . "` `" . $prefix . $counter . "` ON ( `user`.`id` = `" . $prefix . $counter . "`.`userId` AND `" . $prefix . $counter . "`.`questionName` = '" . $this->dbo->escapeString($question->name) . "' AND " . $questionString . " ) "; $compatibility .= ' IF( `' . $prefix . $counter . '`.`questionName` IS NOT NULL, ' . $field->coefficient . ', 0 ) +'; $counter++; // } } } } else { $compatibility .= ' ' . $field->coefficient . ' +'; } } /**/ if ($sortOrder == 'newest') { $order = ' `user`.`joinStamp` DESC, '; } else { if ($sortOrder == 'mail') { $order = ' `user`.`joinStamp` DESC, '; $matchmaking_lastmatch_userid = BOL_PreferenceService::getInstance()->getPreferenceValue('matchmaking_lastmatch_userid', $userId); $where = ' AND `user`.`id` > ' . $matchmaking_lastmatch_userid; } else { if ($sortOrder == 'compatible') { //$order = '(' . substr($compatibility, 0, -1) . ') DESC , '; $order = '`matches`.`compatibility` DESC , '; } } } if (!empty($userIdList)) { $listOfUserIds = $this->dbo->mergeInClause($userIdList); $where .= ' AND `user`.`id` IN ( ' . $listOfUserIds . ' ) '; } $result = array('userId' => $userId, 'join' => $innerJoin . $leftJoin, 'where' => $where, 'order' => $order, 'compatibility' => ' (' . substr($compatibility, 0, -1) . ') * (' . substr($requiredCompatibility, 0, -1) . ') '); if (!empty($userIdList)) { $result['userIdList'] = $userIdList; } return $result; }
public function upload($params) { $userId = OW::getUser()->getId(); if (!$userId) { throw new ApiResponseErrorException("Undefined userId"); } if (empty($_FILES['file'])) { throw new ApiResponseErrorException("Files were not uploaded"); } $files = array("tmp_name" => array($_FILES['file']["tmp_name"])); $selectedAlbumId = null; $source = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_source", $userId); $source = $source == "album" ? "album" : "all"; if ($source == "album") { $selectedAlbumId = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_album", $userId); if (!$selectedAlbumId) { $source = "all"; } } if ($source == "all") { $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId)); OW::getEventManager()->trigger($event); $album = $event->getData(); $selectedAlbumId = !empty($album['album']) ? $album['album']['id'] : null; } if (!$selectedAlbumId && isset($_POST["albumId"])) { $selectedAlbumId = (int) $_POST["albumId"]; } if (!$selectedAlbumId) { throw new ApiResponseErrorException("Undefined album"); } $uploadedIdList = array(); foreach ($files['tmp_name'] as $path) { $photo = OW::getEventManager()->call('photo.add', array('albumId' => $selectedAlbumId, 'path' => $path)); if (!empty($photo['photoId'])) { $uploadedIdList[] = $photo['photoId']; BOL_AuthorizationService::getInstance()->trackActionForUser($userId, 'photo', 'upload'); } } $result = array(); if ($uploadedIdList) { $uploadedList = PHOTO_BOL_PhotoDao::getInstance()->findByIdList($uploadedIdList); if ($uploadedList) { /* @var $photo PHOTO_BOL_Photo */ foreach ($uploadedList as $photo) { $result[] = self::preparePhotoData($photo->id, $photo->hash, $photo->dimension, $photo->status); } } } $this->assign("uploaded", array($photo, $result)); }
<?php /** * Copyright (c) 2014, Skalfa LLC * All rights reserved. * * ATTENTION: This commercial software is intended for exclusive use with SkaDate Dating Software (http://www.skadate.com) and is licensed under SkaDate Exclusive License by Skalfa LLC. * * Full text of this license can be found at http://www.skadate.com/sel.pdf */ BOL_PreferenceService::getInstance()->deletePreference('pcgallery_source'); BOL_PreferenceService::getInstance()->deletePreference('pcgallery_album');
* - Redistributions of source code must retain the above copyright notice, this list of conditions and * the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and * the following disclaimer in the documentation and/or other materials provided with the distribution. * * - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * @author Podyachev Evgeny <*****@*****.**> * @package ow_plugins.mailbox * @since 1.0 */ OW::getConfig()->deleteConfig('mailbox', 'results_per_page'); $sql = "DROP TABLE IF EXISTS `" . OW_DB_PREFIX . "mailbox_conversation`"; OW::getDbo()->query($sql); $sql = "DROP TABLE IF EXISTS `" . OW_DB_PREFIX . "mailbox_last_message`"; OW::getDbo()->query($sql); $sql = "DROP TABLE IF EXISTS `" . OW_DB_PREFIX . "mailbox_message`"; OW::getDbo()->query($sql); BOL_PreferenceService::getInstance()->deletePreference('mailbox_create_conversation_display_capcha'); BOL_PreferenceService::getInstance()->deletePreference('mailbox_create_conversation_stamp');
public function render() { OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("base")->getStaticJsUrl() . "jquery-ui.min.js"); OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'underscore-min.js', 'text/javascript', 3000); OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'backbone-min.js', 'text/javascript', 3000); OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('mailbox')->getStaticJsUrl() . 'audio-player.js'); OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('mailbox')->getStaticJsUrl() . 'mailbox.js', 'text/javascript', 3000); OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('mailbox')->getStaticJsUrl() . 'contactmanager.js', 'text/javascript', 3001); OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('mailbox')->getStaticCssUrl() . 'mailbox.css'); $conversationService = MAILBOX_BOL_ConversationService::getInstance(); $userId = OW::getUser()->getId(); $displayName = BOL_UserService::getInstance()->getDisplayName($userId); $avatarUrl = BOL_AvatarService::getInstance()->getAvatarUrl($userId); if (empty($avatarUrl)) { $avatarUrl = BOL_AvatarService::getInstance()->getDefaultAvatarUrl(); } $profileUrl = BOL_UserService::getInstance()->getUserUrl($userId); $jsGenerator = UTIL_JsGenerator::newInstance(); $jsGenerator->setVariable('OWMailbox.documentTitle', OW::getDocument()->getTitle()); $jsGenerator->setVariable('OWMailbox.soundEnabled', (bool) BOL_PreferenceService::getInstance()->getPreferenceValue('mailbox_user_settings_enable_sound', $userId)); $jsGenerator->setVariable('OWMailbox.showOnlineOnly', (bool) BOL_PreferenceService::getInstance()->getPreferenceValue('mailbox_user_settings_show_online_only', $userId)); $jsGenerator->setVariable('OWMailbox.showAllMembersMode', (bool) OW::getConfig()->getValue('mailbox', 'show_all_members')); $jsGenerator->setVariable('OWMailbox.soundSwfUrl', OW::getPluginManager()->getPlugin('mailbox')->getStaticUrl() . 'js/player.swf'); $jsGenerator->setVariable('OWMailbox.soundUrl', OW::getPluginManager()->getPlugin('mailbox')->getStaticUrl() . 'sound/receive.mp3'); $jsGenerator->setVariable('OWMailbox.defaultAvatarUrl', BOL_AvatarService::getInstance()->getDefaultAvatarUrl()); $jsGenerator->setVariable('OWMailbox.serverTimezoneOffset', date('Z') / 3600); $jsGenerator->setVariable('OWMailbox.useMilitaryTime', (bool) OW::getConfig()->getValue('base', 'military_time')); $jsGenerator->setVariable('OWMailbox.getHistoryResponderUrl', OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'getHistory')); $jsGenerator->setVariable('OWMailbox.openDialogResponderUrl', OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'updateUserInfo')); $jsGenerator->setVariable('OWMailbox.attachmentsSubmitUrl', OW::getRouter()->urlFor('BASE_CTRL_Attachment', 'addFile')); $jsGenerator->setVariable('OWMailbox.attachmentsDeleteUrl', OW::getRouter()->urlFor('BASE_CTRL_Attachment', 'deleteFile')); $jsGenerator->setVariable('OWMailbox.authorizationResponderUrl', OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'authorization')); $jsGenerator->setVariable('OWMailbox.responderUrl', OW::getRouter()->urlFor("MAILBOX_CTRL_Mailbox", "responder")); $jsGenerator->setVariable('OWMailbox.userListUrl', OW::getRouter()->urlForRoute('mailbox_user_list')); $jsGenerator->setVariable('OWMailbox.convListUrl', OW::getRouter()->urlForRoute('mailbox_conv_list')); $jsGenerator->setVariable('OWMailbox.pingResponderUrl', OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'ping')); $jsGenerator->setVariable('OWMailbox.settingsResponderUrl', OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'settings')); $jsGenerator->setVariable('OWMailbox.userSearchResponderUrl', OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'rsp')); $jsGenerator->setVariable('OWMailbox.bulkOptionsResponderUrl', OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'bulkOptions')); $plugin_update_timestamp = 0; if (OW::getConfig()->configExists('mailbox', 'plugin_update_timestamp')) { $plugin_update_timestamp = OW::getConfig()->getValue('mailbox', 'plugin_update_timestamp'); } $jsGenerator->setVariable('OWMailbox.pluginUpdateTimestamp', $plugin_update_timestamp); $todayDate = date('Y-m-d', time()); $jsGenerator->setVariable('OWMailbox.todayDate', $todayDate); $todayDateLabel = UTIL_DateTime::formatDate(time(), true); $jsGenerator->setVariable('OWMailbox.todayDateLabel', $todayDateLabel); $activeModeList = $conversationService->getActiveModeList(); $chatModeEnabled = in_array('chat', $activeModeList) ? true : false; $this->assign('chatModeEnabled', $chatModeEnabled); $jsGenerator->setVariable('OWMailbox.chatModeEnabled', $chatModeEnabled); $jsGenerator->setVariable('OWMailbox.useChat', $this->useChat); $mailModeEnabled = in_array('mail', $activeModeList) ? true : false; $this->assign('mailModeEnabled', $mailModeEnabled); $jsGenerator->setVariable('OWMailbox.mailModeEnabled', $mailModeEnabled); $isAuthorizedSendMessage = OW::getUser()->isAuthorized('mailbox', 'send_message'); $this->assign('isAuthorizedSendMessage', $isAuthorizedSendMessage); $configs = OW::getConfig()->getValues('mailbox'); // if ( !empty($configs['enable_attachments'])) // { OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'attachments.js'); // } $this->assign('im_sound_url', OW::getPluginManager()->getPlugin('mailbox')->getStaticUrl() . 'sound/receive.mp3'); /* DEBUG MODE */ $debugMode = false; $jsGenerator->setVariable('im_debug_mode', $debugMode); $this->assign('debug_mode', $debugMode); $variables = $jsGenerator->generateJs(); $details = array('userId' => $userId, 'displayName' => $displayName, 'profileUrl' => $profileUrl, 'avatarUrl' => $avatarUrl); OW::getDocument()->addScriptDeclaration("OWMailbox.userDetails = " . json_encode($details) . ";\n " . $variables); OW::getLanguage()->addKeyForJs('mailbox', 'find_contact'); OW::getLanguage()->addKeyForJs('base', 'user_block_message'); OW::getLanguage()->addKeyForJs('mailbox', 'send_message_failed'); OW::getLanguage()->addKeyForJs('mailbox', 'confirm_conversation_delete'); OW::getLanguage()->addKeyForJs('mailbox', 'silent_mode_off'); OW::getLanguage()->addKeyForJs('mailbox', 'silent_mode_on'); OW::getLanguage()->addKeyForJs('mailbox', 'show_all_users'); OW::getLanguage()->addKeyForJs('mailbox', 'show_all_users'); OW::getLanguage()->addKeyForJs('mailbox', 'show_online_only'); OW::getLanguage()->addKeyForJs('mailbox', 'new_message'); OW::getLanguage()->addKeyForJs('mailbox', 'mail_subject_prefix'); OW::getLanguage()->addKeyForJs('mailbox', 'chat_subject_prefix'); OW::getLanguage()->addKeyForJs('mailbox', 'new_message_count'); OW::getLanguage()->addKeyForJs('mailbox', 'chat_message_empty'); OW::getLanguage()->addKeyForJs('mailbox', 'text_message_invitation'); $avatar_proto_data = array('url' => 1, 'src' => BOL_AvatarService::getInstance()->getDefaultAvatarUrl(), 'class' => 'talk_box_avatar'); $this->assign('avatar_proto_data', $avatar_proto_data); $this->assign('defaultAvatarUrl', BOL_AvatarService::getInstance()->getDefaultAvatarUrl()); $this->assign('online_list_url', OW::getRouter()->urlForRoute('base_user_lists', array('list' => 'online'))); /**/ $actionPromotedText = ''; $isAuthorizedReplyToMessage = OW::getUser()->isAuthorized('mailbox', 'reply_to_chat_message'); $isAuthorizedSendMessage = OW::getUser()->isAuthorized('mailbox', 'send_chat_message'); $isAuthorized = $isAuthorizedReplyToMessage || $isAuthorizedSendMessage; if (!$isAuthorized) { $actionName = 'send_chat_message'; $status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', $actionName); if ($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED) { $actionPromotedText = $status['msg']; } } $this->assign('replyToMessageActionPromotedText', $actionPromotedText); $this->assign('isAuthorizedReplyToMessage', $isAuthorized); /**/ $lastSentMessage = $conversationService->getLastSentMessage($userId); $lastMessageTimestamp = (int) ($lastSentMessage ? $lastSentMessage->timeStamp : 0); if ($chatModeEnabled) { $countOnline = BOL_UserService::getInstance()->countOnline(); if ($countOnline < 5) { $pingInterval = 5000; } else { if ($countOnline > 15) { $pingInterval = 15000; } else { $pingInterval = 5000; //TODO think about ping interval here } } } else { $pingInterval = 30000; } $applicationParams = array('pingInterval' => $pingInterval, 'lastMessageTimestamp' => $lastMessageTimestamp); $js = UTIL_JsGenerator::composeJsString('OW.Mailbox = new OWMailbox.Application({$params});', array('params' => $applicationParams)); OW::getDocument()->addOnloadScript($js, 3003); $js = "\n OW.Mailbox.contactManager = new MAILBOX_ContactManager;\n OW.Mailbox.contactManagerView = new MAILBOX_ContactManagerView({model: OW.Mailbox.contactManager});"; OW::getDocument()->addOnloadScript($js, 3009); return parent::render(); }
<?php /** * This software is intended for use with Oxwall Free Community Software http://www.oxwall.org/ and is * licensed under The BSD license. * --- * Copyright (c) 2011, Oxwall Foundation * All rights reserved. * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the * following conditions are met: * * - Redistributions of source code must retain the above copyright notice, this list of conditions and * the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and * the following disclaimer in the documentation and/or other materials provided with the distribution. * * - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ BOL_PreferenceService::getInstance()->deletePreference('ajaxim_user_settings_enable_sound'); //BOL_PreferenceService::getInstance()->deletePreference('im_user_settings_status_invisible'); BOL_PreferenceService::getInstance()->deleteSection('ajaxim');
public function deleteActionSetByUserId($userId) { $this->actionSetDao->deleteActionSetUserId($userId); BOL_PreferenceService::getInstance()->savePreferenceValue(NEWSFEED_BOL_ActionDao::CACHE_TIMESTAMP_PREFERENCE, 0, $userId); }
public function onUserRegisterWelcomeLetter(OW_Event $event) { $params = $event->getParams(); $userId = (int) $params['userId']; if ($userId === 0) { return; } BOL_PreferenceService::getInstance()->savePreferenceValue('send_wellcome_letter', 1, $userId); }
<?php $preference = BOL_PreferenceService::getInstance()->findPreference('timeZoneSelect'); if (empty($preference)) { $preference = new BOL_Preference(); } $preference->key = 'timeZoneSelect'; $preference->sectionName = 'general'; $preference->defaultValue = json_encode(null); $preference->sortOrder = 1; BOL_PreferenceService::getInstance()->savePreference($preference);
public function sendWellcomeLetter(BOL_User $user) { if ($user === null) { return; } if (OW::getConfig()->getValue('base', 'confirm_email') && $user->emailVerify != true) { return; } $vars = array('username' => $this->getDisplayName($user->id)); $language = OW::getLanguage(); $subject = !$language->text('base', 'welcome_letter_subject', $vars) ? 'base+welcome_letter_subject' : $language->text('base', 'welcome_letter_subject', $vars); $template_html = !$language->text('base', 'welcome_letter_template_html', $vars) ? 'base+welcome_letter_template_html' : $language->text('base', 'welcome_letter_template_html', $vars); $template_text = !$language->text('base', 'welcome_letter_template_text', $vars) ? 'base+welcome_letter_template_text' : $language->text('base', 'welcome_letter_template_text', $vars); $mail = OW::getMailer()->createMail(); $mail->addRecipientEmail($user->email); $mail->setSubject($subject); $mail->setHtmlContent($template_html); $mail->setTextContent($template_text); try { OW::getMailer()->send($mail); } catch (phpmailerException $e) { $user->emailVerify = false; $this->saveOrUpdate($user); } BOL_PreferenceService::getInstance()->savePreferenceValue('send_wellcome_letter', 0, $user->id); }
<?php /** * Copyright (c) 2014, Skalfa LLC * All rights reserved. * * ATTENTION: This commercial software is intended for exclusive use with SkaDate Dating Software (http://www.skadate.com) and is licensed under SkaDate Exclusive License by Skalfa LLC. * * Full text of this license can be found at http://www.skadate.com/sel.pdf */ BOL_PreferenceService::getInstance()->deleteSection('matchmaking');
OW::getDbo()->query("INSERT INTO `" . OW_DB_PREFIX . "matchmaking_question_match` (`questionName`, `matchQuestionName`, `coefficient`, `match_type`, `required`) VALUES\n('sex', 'match_sex', 5, 'exact', 1),\n('birthdate', 'match_age', 5, 'exact', 1);"); OW::getDbo()->query("CREATE TABLE IF NOT EXISTS `" . OW_DB_PREFIX . "matchmaking_sent_matches` (\n `id` int(11) NOT NULL auto_increment,\n `userId` int(11) NOT NULL,\n `match_userId` int(11) NOT NULL,\n PRIMARY KEY (`id`),\n KEY `match_userId` (`match_userId`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); OW::getPluginManager()->addPluginSettingsRouteName('matchmaking', 'matchmaking_admin_rules'); OW::getPluginManager()->addUninstallRouteName('matchmaking', 'matchmaking_uninstall'); OW::getConfig()->addConfig('matchmaking', 'send_new_matches_interval', 7, 'Send new matches to users by email'); OW::getConfig()->addConfig('matchmaking', 'last_matches_sent_timestamp', 0, 'Timestamp of the last matchmaking mass mailing'); $matchmaking_user_preference_section = BOL_PreferenceService::getInstance()->findSection('matchmaking'); if (empty($matchmaking_user_preference_section)) { $matchmaking_user_preference_section = new BOL_PreferenceSection(); $matchmaking_user_preference_section->name = 'matchmaking'; $matchmaking_user_preference_section->sortOrder = 0; BOL_PreferenceService::getInstance()->savePreferenceSection($matchmaking_user_preference_section); } $matchmaking_lastmatch_userid = BOL_PreferenceService::getInstance()->findPreference('matchmaking_lastmatch_userid'); if (empty($matchmaking_lastmatch_userid)) { $matchmaking_lastmatch_userid = new BOL_Preference(); $matchmaking_lastmatch_userid->key = 'matchmaking_lastmatch_userid'; $matchmaking_lastmatch_userid->defaultValue = 0; $matchmaking_lastmatch_userid->sectionName = 'matchmaking'; $matchmaking_lastmatch_userid->sortOrder = 0; BOL_PreferenceService::getInstance()->savePreference($matchmaking_lastmatch_userid); } $matchSection = BOL_QuestionService::getInstance()->findSectionBySectionName('about_my_match'); if (empty($matchSection)) { $matchSection = new BOL_QuestionSection(); $matchSection->name = 'about_my_match'; $matchSection->sortOrder = 1; $matchSection->isHidden = 0; $matchSection->isDeletable = 0; BOL_QuestionService::getInstance()->saveOrUpdateSection($matchSection); }
public function settings() { if (isset($_POST['soundEnabled'])) { $_POST['soundEnabled'] = $_POST['soundEnabled'] === 'false' ? false : true; BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_user_settings_enable_sound', $_POST['soundEnabled'], OW::getUser()->getId()); } if (isset($_POST['showOnlineOnly'])) { $_POST['showOnlineOnly'] = $_POST['showOnlineOnly'] === 'false' ? false : true; BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_user_settings_show_online_only', $_POST['showOnlineOnly'], OW::getUser()->getId()); } exit('true'); }
private function process($editForm, $userId, $questionArray, $adminMode) { if ($editForm->isValid($_POST)) { $language = OW::getLanguage(); $data = $editForm->getValues(); foreach ($questionArray as $section) { foreach ($section as $key => $question) { switch ($question['presentation']) { case 'multicheckbox': if (is_array($data[$question['name']])) { $data[$question['name']] = array_sum($data[$question['name']]); } else { $data[$question['name']] = 0; } break; } } } // save user data if (!empty($userId)) { $changesList = $this->questionService->getChangedQuestionList($data, $userId); if ($this->questionService->saveQuestionsData($data, $userId)) { // delete avatar if (empty($data['avatar'])) { if (empty($_POST['avatarPreloaded'])) { BOL_AvatarService::getInstance()->deleteUserAvatar($userId); } } else { // update user avatar BOL_AvatarService::getInstance()->createAvatar($userId); } if (!$adminMode) { $isNeedToModerate = $this->questionService->isNeedToModerate($changesList); $event = new OW_Event(OW_EventManager::ON_USER_EDIT, array('userId' => $userId, 'method' => 'native', 'moderate' => $isNeedToModerate)); OW::getEventManager()->trigger($event); // saving changed fields if (BOL_UserService::getInstance()->isApproved($userId)) { $changesList = array(); } BOL_PreferenceService::getInstance()->savePreferenceValue(self::PREFERENCE_LIST_OF_CHANGES, json_encode($changesList), $userId); // ---- OW::getFeedback()->info($language->text('base', 'edit_successfull_edit')); $this->redirect(); } else { $event = new OW_Event(OW_EventManager::ON_USER_EDIT_BY_ADMIN, array('userId' => $userId)); OW::getEventManager()->trigger($event); BOL_PreferenceService::getInstance()->savePreferenceValue(self::PREFERENCE_LIST_OF_CHANGES, json_encode(array()), $userId); if (!BOL_UserService::getInstance()->isApproved($userId)) { BOL_UserService::getInstance()->approve($userId); } OW::getFeedback()->info($language->text('base', 'edit_successfull_edit')); $this->redirect(OW::getRouter()->urlForRoute('base_user_profile', array('username' => BOL_UserService::getInstance()->getUserName($userId)))); } } else { OW::getFeedback()->info($language->text('base', 'edit_edit_error')); } } else { OW::getFeedback()->info($language->text('base', 'edit_edit_error')); } } }
public function process() { $language = OW::getLanguage(); $uploadFiles = MAILBOX_BOL_FileUploadService::getInstance(); $isAuthorized = OW::getUser()->isAuthorized('mailbox', 'send_message'); if (!$isAuthorized) { return array('result' => 'permission_denied'); } if (!$this->checkCaptcha()) { return array('result' => 'display_captcha'); } $values = $this->getValues(); $recipients = $values['recipients']; $fileDtoList = array(); if (!empty($values['attachments'])) { $fileDtoList = $uploadFiles->findUploadFileList($values['attachments']); } $event = new BASE_CLASS_EventCollector(MCOMPOSE_BOL_Service::EVENT_ON_SEND, array("recipients" => $recipients, "userId" => $this->userId, "context" => $this->context)); OW::getEventManager()->trigger($event); $userIds = array_unique($event->getData()); $error = null; $sentCount = 0; foreach ($userIds as $uid) { try { $this->sendMessage($uid, $values['subject'], $values['message'], $fileDtoList); $sentCount++; } catch (LogicException $e) { $error = $e->getMessage(); break; } } foreach ($fileDtoList as $fileDto) { $uploadFiles->deleteUploadFile($fileDto->hash, $fileDto->userId); } BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_display_capcha', false, $this->userId); BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_stamp', time(), $this->userId); $result = array('result' => true); if ($sentCount > 0 && $error !== null) { $result['warning'] = $language->text('mcompose', 'some_messages_not_sent', array('sentCount' => $sentCount)); } else { if ($sentCount > 0) { $result['message'] = $language->text('mailbox', 'create_conversation_message'); } } if ($error !== null) { $result['error'] = $error; } return $result; }
public function sendNotification() { $subject = $this->getSubject(); $txt = $this->getTxt(); $html = $this->getHtml(); $mail = OW::getMailer()->createMail()->addRecipientEmail($this->user->email)->setTextContent($txt)->setHtmlContent($html)->setSubject($subject); OW::getMailer()->send($mail); // BOL_PreferenceService::getInstance()->savePreferenceValue('matchmaking_lastmatch_userid', (int)$this->items[0]['id'], $this->user->getId()); BOL_PreferenceService::getInstance()->savePreferenceValue('matchmaking_lastmatch_userid', (int) $this->lastUserId, $this->user->getId()); }
/** * Creates new conversation * * @param int $initiatorId * @param int $interlocutorId */ public function process($initiatorId, $interlocutorId) { if (OW::getRequest()->isAjax()) { if (empty($initiatorId) || empty($interlocutorId)) { echo json_encode(array('result' => false)); exit; } $isAuthorized = OW::getUser()->isAuthorized('mailbox', 'send_message'); if (!$isAuthorized) { echo json_encode(array('result' => 'permission_denied')); exit; } // credits check $eventParams = array('pluginKey' => 'mailbox', 'action' => 'send_message', 'extra' => array('senderId' => $initiatorId, 'recipientId' => $interlocutorId)); $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams); if ($credits === false) { $error = OW::getEventManager()->call('usercredits.error_message', $eventParams); echo json_encode(array('result' => 'permission_denied', 'message' => $error)); exit; } $captcha = $this->getElement('captcha'); $captcha->setRequired(); if ($this->displayCapcha && (!$captcha->isValid() || !UTIL_Validator::isCaptchaValid($captcha->getValue()))) { echo json_encode(array('result' => 'display_captcha')); exit; } $values = $this->getValues(); $conversationService = MAILBOX_BOL_ConversationService::getInstance(); $uploadFiles = MAILBOX_BOL_FileUploadService::getInstance(); $conversation = $conversationService->createConversation($initiatorId, $interlocutorId, htmlspecialchars($values['subject']), $values['message']); $message = $conversationService->getLastMessages($conversation->id); $fileDtoList = $uploadFiles->findUploadFileList($values['attachments']); foreach ($fileDtoList as $fileDto) { $attachmentDto = new MAILBOX_BOL_Attachment(); $attachmentDto->messageId = $message->initiatorMessageId; $attachmentDto->fileName = htmlspecialchars($fileDto->fileName); $attachmentDto->fileSize = $fileDto->fileSize; $attachmentDto->hash = $fileDto->hash; if ($conversationService->fileExtensionIsAllowed(UTIL_File::getExtension($fileDto->fileName))) { $conversationService->addAttachment($attachmentDto, $fileDto->filePath); } $uploadFiles->deleteUploadFile($fileDto->hash, $fileDto->userId); } // credits track if ($credits === true) { OW::getEventManager()->call('usercredits.track_action', $eventParams); } BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_display_capcha', false, OW::getUser()->getId()); $timestamp = 0; if ($this->displayCapcha == false) { $timestamp = time(); } BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_stamp', $timestamp, OW::getUser()->getId()); echo json_encode(array('result' => true)); exit; } }
public function processUserSettingsForm() { if (!OW::getRequest()->isAjax()) { throw new Redirect404Exception(); } $form = AJAXIM_BOL_Service::getInstance()->getUserSettingsForm(); if ($form->isValid($_POST)) { $data = $form->getValues(); BOL_PreferenceService::getInstance()->savePreferenceValue('ajaxim_user_settings_enable_sound', (bool) $data['im_enable_sound'], $data['user_id']); echo json_encode(array('im_soundEnabled' => (bool) $data['im_enable_sound'])); exit; } }