Example #1
0
function profileprogressbar_after_route(OW_Event $event)
{
    $handler = OW::getRequestHandler()->getHandlerAttributes();
    if ($handler[OW_RequestHandler::ATTRS_KEY_CTRL] == 'BASE_CTRL_Edit' && $handler[OW_RequestHandler::ATTRS_KEY_ACTION] == 'index') {
        OW::getRegistry()->addToArray(BASE_CTRL_Edit::EDIT_SYNCHRONIZE_HOOK, array(new PROFILEPROGRESSBAR_CMP_Synchronize(), 'render'));
    }
}
Example #2
0
 /**
  * @see FormElement::renderInput()
  *
  * @param array $params
  * @return string
  */
 public function renderInput($params = null)
 {
     parent::renderInput($params);
     if ($this->textarea !== null) {
         return $this->textarea->renderInput();
     }
     if (OW::getRegistry()->get('baseWsInit') === null) {
         $language = OW::getLanguage();
         $languageDto = BOL_LanguageService::getInstance()->getCurrent();
         $array = array('editorCss' => OW::getPluginManager()->getPlugin('base')->getStaticCssUrl() . 'htmlarea_editor.css', 'themeImagesUrl' => OW::getThemeManager()->getCurrentTheme()->getStaticImagesUrl(), 'imagesUrl' => OW::getRouter()->urlFor('BASE_CTRL_MediaPanel', 'index', array('pluginKey' => 'blog', 'id' => '__id__')), 'labels' => array('buttons' => array('bold' => $language->text('base', 'ws_button_label_bold'), 'italic' => $language->text('base', 'ws_button_label_italic'), 'underline' => $language->text('base', 'ws_button_label_underline'), 'orderedlist' => $language->text('base', 'ws_button_label_orderedlist'), 'unorderedlist' => $language->text('base', 'ws_button_label_unorderedlist'), 'link' => $language->text('base', 'ws_button_label_link'), 'image' => $language->text('base', 'ws_button_label_image'), 'video' => $language->text('base', 'ws_button_label_video'), 'html' => $language->text('base', 'ws_button_label_html'), 'more' => $language->text('base', 'ws_button_label_more'), 'switchHtml' => $language->text('base', 'ws_button_label_switch_html')), 'common' => array('buttonAdd' => $language->text('base', 'ws_add_label'), 'buttonInsert' => $language->text('base', 'ws_insert_label'), 'videoHeadLabel' => $language->text('base', 'ws_video_head_label'), 'htmlHeadLabel' => $language->text('base', 'ws_html_head_label'), 'htmlTextareaLabel' => $language->text('base', 'ws_html_textarea_label'), 'videoTextareaLabel' => $language->text('base', 'ws_video_textarea_label'), 'linkTextLabel' => $language->text('base', 'ws_link_text_label'), 'linkUrlLabel' => $language->text('base', 'ws_link_url_label'), 'linkNewWindowLabel' => $language->text('base', 'ws_link_new_window_label')), 'messages' => array('imagesEmptyFields' => $language->text('base', 'ws_image_empty_fields'), 'linkEmptyFields' => $language->text('base', 'ws_link_empty_fields'), 'videoEmptyField' => $language->text('base', 'ws_video_empty_field'))), 'buttonCode' => OW::getThemeManager()->processDecorator('button', array('label' => '#label#', 'class' => 'ow_ic_add mn_submit')), 'rtl' => $languageDto !== null && (bool) $languageDto->getRtl() ? true : false);
         $script = "window.htmlAreaData = " . json_encode($array);
         OW::getDocument()->addScriptDeclarationBeforeIncludes($script);
         OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'htmlarea.js');
         OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('base')->getStaticCssUrl() . 'htmlarea.css');
         OW::getRegistry()->set('baseWsInit', true);
     }
     $params = array('toolbar' => $this->buttons, 'size' => $this->size);
     if (!empty($this->customBodyClass)) {
         $params["customClass"] = $this->customBodyClass;
     }
     OW::getDocument()->addOnloadScript("\r\n            \$('#{$this->getId()}').get(0).htmlarea = function(){ \$(this).htmlarea( " . json_encode($params) . " );};\r\n            \$('#{$this->getId()}').get(0).htmlareaFocus = function(){this.jhtmlareaObject.iframe[0].contentWindow.focus();};\r\n            \$('#{$this->getId()}').get(0).htmlareaRefresh = function(){if(this.jhtmlareaObject){this.jhtmlareaObject.dispose();\$(this).htmlarea( " . json_encode($params) . " );}};\r\n        ");
     if ($this->value === null && $this->getHasInvitation()) {
         $this->addAttribute('value', $this->getInvitation());
         $this->addAttribute('class', 'invitation');
     }
     if ($this->init) {
         OW::getDocument()->addOnloadScript("\$('#{$this->getId()}').htmlarea( " . json_encode($params) . " );");
     }
     $this->removeAttribute('value');
     if ($this->value === null && $this->getHasInvitation()) {
         $markup = UTIL_HtmlTag::generateTag('textarea', $this->attributes, true, $this->getInvitation());
     } else {
         $markup = UTIL_HtmlTag::generateTag('textarea', $this->attributes, true, htmlspecialchars(BOL_TextFormatService::getInstance()->processWsForInput($this->value, array('buttons' => $this->buttons))));
     }
     return $markup;
 }
Example #3
0
 * 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.
 */
$plugin = OW::getPluginManager()->getPlugin('fbconnect');
function FBCONNECT_Autoloader($className)
{
    if (strpos($className, 'FBCONNECT_FC_') === 0) {
        $file = OW::getPluginManager()->getPlugin('fbconnect')->getRootDir() . DS . 'classes' . DS . 'converters.php';
        require_once $file;
        return true;
    }
}
spl_autoload_register('FBCONNECT_Autoloader');
OW::getRouter()->addRoute(new OW_Route('fbconnect_login', 'facebook-connect/login', 'FBCONNECT_CTRL_Connect', 'login'));
OW::getRouter()->addRoute(new OW_Route('fbconnect_synchronize', 'facebook-connect/synchronize', 'FBCONNECT_CTRL_Connect', 'synchronize'));
OW::getRouter()->addRoute(new OW_Route('fbconnect_xd_receiver', 'fbconnect_channel.html', 'FBCONNECT_CTRL_Connect', 'xdReceiver'));
$route = new OW_Route('fbconnect_configuration', 'admin/plugins/fbconnect', 'FBCONNECT_CTRL_Admin', 'index');
OW::getRouter()->addRoute($route);
$route = new OW_Route('fbconnect_configuration_fields', 'admin/plugins/fbconnect/fields', 'FBCONNECT_CTRL_Admin', 'fields');
OW::getRouter()->addRoute($route);
$route = new OW_Route('fbconnect_configuration_settings', 'admin/plugins/fbconnect/settings', 'FBCONNECT_CTRL_Admin', 'settings');
OW::getRouter()->addRoute($route);
$registry = OW::getRegistry();
$registry->addToArray(BASE_CTRL_Join::JOIN_CONNECT_HOOK, array(new FBCONNECT_CMP_ConnectButton(), 'render'));
$registry->addToArray(BASE_CTRL_Edit::EDIT_SYNCHRONIZE_HOOK, array(new FBCONNECT_CMP_SynchronizeButton(), 'render'));
$eventHandler = new FBCONNECT_CLASS_EventHandler();
$eventHandler->init();
Example #4
0
 public function inviteList()
 {
     $userId = OW::getUser()->getId();
     if (empty($userId)) {
         throw new AuthenticateException();
     }
     $language = OW::getLanguage();
     OW::getDocument()->setHeading($language->text('groups', 'group_list_heading'));
     OW::getDocument()->setHeadingIconClass('ow_ic_files');
     OW::getDocument()->setTitle($language->text('groups', 'invite_list_page_title'));
     if (!$this->service->isCurrentUserCanViewList()) {
         $this->assign('permissionMessage', $language->text('groups', 'view_no_permission'));
         $templatePath = OW::getPluginManager()->getPlugin('groups')->getCtrlViewDir() . 'no_permission.html';
         $this->setTemplate($templatePath);
         return;
     }
     OW::getRegistry()->set('groups.hide_console_invite_item', true);
     $this->service->markAllInvitesAsViewed($userId);
     $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? $_GET['page'] : 1;
     $perPage = 20;
     $first = ($page - 1) * $perPage;
     $count = $perPage;
     $dtoList = $this->service->findInvitedGroups($userId, $first, $count);
     $listCount = $this->service->findInvitedGroupsCount($userId);
     $paging = new BASE_CMP_Paging($page, ceil($listCount / $perPage), 5);
     $menu = $this->getGroupListMenu();
     $menu->getElement('invite')->setActive(true);
     $templatePath = OW::getPluginManager()->getPlugin('groups')->getCtrlViewDir() . 'groups_list.html';
     $this->setTemplate($templatePath);
     $acceptUrls = array();
     $declineUrls = array();
     $out = array();
     foreach ($dtoList as $group) {
         $acceptUrls[$group->id] = OW::getRouter()->urlFor('GROUPS_CTRL_Groups', 'join', array('groupId' => $group->id));
         $declineUrls[$group->id] = OW::getRouter()->urlFor('GROUPS_CTRL_Groups', 'declineInvite', array('groupId' => $group->id));
     }
     $acceptLabel = OW::getLanguage()->text('groups', 'invite_accept_label');
     $declineLabel = OW::getLanguage()->text('groups', 'invite_decline_label');
     foreach ($dtoList as $item) {
         /* @var $item GROUPS_BOL_Group */
         $userCount = GROUPS_BOL_Service::getInstance()->findUserListCount($item->id);
         $title = strip_tags($item->title);
         $toolbar = array(array('label' => OW::getLanguage()->text('groups', 'listing_users_label', array('count' => $userCount))), array('href' => $acceptUrls[$item->id], 'label' => $acceptLabel), array('href' => $declineUrls[$item->id], 'label' => $declineLabel));
         $out[] = array('id' => $item->id, 'url' => OW::getRouter()->urlForRoute('groups-view', array('groupId' => $item->id)), 'title' => $title, 'imageTitle' => $title, 'content' => strip_tags($item->description), 'time' => UTIL_DateTime::formatDate($item->timeStamp), 'imageSrc' => GROUPS_BOL_Service::getInstance()->getGroupImageUrl($item), 'users' => $userCount, 'toolbar' => $toolbar);
     }
     $this->addComponent('paging', $paging);
     if (!empty($menu)) {
         $this->addComponent('menu', $menu);
     } else {
         $this->assign('menu', '');
     }
     $this->assign('canCreate', $this->service->isCurrentUserCanCreate());
     $this->assign('list', $out);
 }
 public function index($params)
 {
     $adminMode = false;
     $oneAccountType = false;
     $viewerId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthenticated() || $viewerId === null) {
         throw new AuthenticateException();
     }
     if (!empty($params['userId']) && $params['userId'] != $viewerId) {
         if (OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base')) {
             $adminMode = true;
             $userId = (int) $params['userId'];
             $user = BOL_UserService::getInstance()->findUserById($userId);
             if (empty($user) || BOL_AuthorizationService::getInstance()->isSuperModerator($userId)) {
                 throw new Redirect404Exception();
             }
             $editUserId = $userId;
         } else {
             throw new Redirect403Exception();
         }
     } else {
         $editUserId = $viewerId;
         $changePassword = new BASE_CMP_ChangePassword();
         $this->addComponent("changePassword", $changePassword);
         $contentMenu = new BASE_CMP_DashboardContentMenu();
         $contentMenu->getElement('profile_edit')->setActive(true);
         $this->addComponent('contentMenu', $contentMenu);
         $user = OW::getUser()->getUserObject();
         //BOL_UserService::getInstance()->findUserById($editUserId);
     }
     $accountType = $user->accountType;
     // dispaly account type
     if (OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base')) {
         $accountType = !empty($_GET['accountType']) ? $_GET['accountType'] : $user->accountType;
         // get available account types from DB
         $accountTypes = BOL_QuestionService::getInstance()->findAllAccountTypes();
         $accounts = array();
         if (count($accountTypes) > 1) {
             /* @var $value BOL_QuestionAccount */
             foreach ($accountTypes as $key => $value) {
                 $accounts[$value->name] = OW::getLanguage()->text('base', 'questions_account_type_' . $value->name);
             }
             if (!in_array($accountType, array_keys($accounts))) {
                 if (in_array($user->accountType, array_keys($accounts))) {
                     $accountType = $user->accountType;
                 } else {
                     $accountType = BOL_QuestionService::getInstance()->getDefaultAccountType()->name;
                 }
             }
             $editAccountType = new Selectbox('accountType');
             $editAccountType->setId('accountType');
             $editAccountType->setLabel(OW::getLanguage()->text('base', 'questions_question_account_type_label'));
             $editAccountType->setRequired();
             $editAccountType->setOptions($accounts);
             $editAccountType->setHasInvitation(false);
         } else {
             $accountType = BOL_QuestionService::getInstance()->getDefaultAccountType()->name;
         }
     }
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('base', 'edit_index'));
     $this->setPageHeadingIconClass('ow_ic_user');
     // -- Edit form --
     $editForm = new EditQuestionForm('editForm', $editUserId);
     $editForm->setId('editForm');
     $this->assign('displayAccountType', false);
     // dispaly account type
     if (!empty($editAccountType)) {
         $editAccountType->setValue($accountType);
         $editForm->addElement($editAccountType);
         OW::getDocument()->addOnloadScript(" \$('#accountType').change(function() {\n\n                var form = \$(\"<form method='get'><input type='text' name='accountType' value='\" + \$(this).val() + \"' /></form>\");\n                \$('body').append(form);\n                \$(form).submit();\n\n            }  ); ");
         $this->assign('displayAccountType', true);
     }
     $editSubmit = new Submit('editSubmit');
     $editSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $editSubmit->setValue($language->text('base', 'edit_button'));
     $editForm->addElement($editSubmit);
     $questions = $this->questionService->findEditQuestionsForAccountType($accountType);
     $section = null;
     $questionArray = array();
     $questionNameList = array();
     //        echo '<pre>';
     //        print_r($questions);
     //        echo '</pre>';
     $userData = BOL_QuestionService::getInstance()->getQuestionData(array($editUserId), array(HAMMU_DB_IM_USING_HAMMU_AS_KEY));
     $im_using_hammu_as = $userData[$editUserId][HAMMU_DB_IM_USING_HAMMU_AS_KEY];
     foreach ($questions as $sort => $question) {
         if ($section !== $question['sectionName']) {
             $section = $question['sectionName'];
         }
         $questionArray[$section][$sort] = $questions[$sort];
         $questionNameList[] = $questions[$sort]['name'];
     }
     echo "user->" . $editUserId;
     $this->assign('questionArray', $questionArray);
     $questionData = $this->questionService->getQuestionData(array($editUserId), $questionNameList);
     $questionValues = $this->questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     $editForm->addQuestions($questions, $questionValues, !empty($questionData[$editUserId]) ? $questionData[$editUserId] : array());
     if (OW::getRequest()->isPost() && isset($_POST['editSubmit'])) {
         if ($editForm->isValid($_POST)) {
             $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($user->id)) {
                 if ($this->questionService->saveQuestionsData($data, $user->id)) {
                     if (!$adminMode) {
                         $event = new OW_Event(OW_EventManager::ON_USER_EDIT, array('userId' => $user->id, 'method' => 'native'));
                         OW::getEventManager()->trigger($event);
                         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' => $user->id));
                         OW::getEventManager()->trigger($event);
                         OW::getFeedback()->info($language->text('base', 'edit_successfull_edit'));
                         $this->redirect(OW::getRouter()->urlForRoute('base_user_profile', array('username' => BOL_UserService::getInstance()->getUserName($editUserId))));
                     }
                 } else {
                     OW::getFeedback()->info($language->text('base', 'edit_edit_error'));
                 }
             } else {
                 OW::getFeedback()->info($language->text('base', 'edit_edit_error'));
             }
         }
     }
     $this->addForm($editForm);
     $this->assign('unregisterProfileUrl', OW::getRouter()->urlForRoute('base_delete_user'));
     $language->addKeyForJs('base', 'join_error_username_not_valid');
     $language->addKeyForJs('base', 'join_error_username_already_exist');
     $language->addKeyForJs('base', 'join_error_email_not_valid');
     $language->addKeyForJs('base', 'join_error_email_already_exist');
     $language->addKeyForJs('base', 'join_error_password_not_valid');
     $language->addKeyForJs('base', 'join_error_password_too_short');
     $language->addKeyForJs('base', 'join_error_password_too_long');
     //include js
     $onLoadJs = " window.edit = new OW_BaseFieldValidators( " . json_encode(array('formName' => $editForm->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Edit", "ajaxResponder"))) . ",\n                                                        " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . ", " . $editUserId . " ); ";
     $this->assign('isAdmin', OW::getUser()->isAdmin());
     OW::getDocument()->addOnloadScript($onLoadJs);
     $jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "base_field_validators.js");
     if (!$adminMode) {
         $editSynchronizeHook = OW::getRegistry()->getArray(self::EDIT_SYNCHRONIZE_HOOK);
         if (!empty($editSynchronizeHook)) {
             $content = array();
             foreach ($editSynchronizeHook as $function) {
                 $result = call_user_func($function);
                 if (trim($result)) {
                     $content[] = $result;
                 }
             }
             $content = array_filter($content, 'trim');
             if (!empty($content)) {
                 $this->assign('editSynchronizeHook', $content);
             }
         }
     }
 }
Example #6
0
 public function index($params)
 {
     $session = OW::getSession();
     if (OW::getUser()->isAuthenticated()) {
         $this->redirect(OW::getRouter()->urlForRoute('base_member_dashboard'));
     }
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('base', 'join_index'));
     //TODO DELETE config who_can_join from join
     if ((int) OW::getConfig()->getValue('base', 'who_can_join') === BOL_UserService::PERMISSIONS_JOIN_BY_INVITATIONS) {
         $code = null;
         if (isset($_GET['code'])) {
             $code = $_GET['code'];
         } else {
             if (isset($params['code'])) {
                 $code = $params['code'];
             }
         }
         //close join form
         try {
             $event = new OW_Event(OW_EventManager::ON_JOIN_FORM_RENDER, array('code' => $code));
             OW::getEventManager()->trigger($event);
             $this->assign('notValidInviteCode', true);
             return;
         } catch (JoinRenderException $ex) {
             //ignore;
         }
     }
     $urlParams = $_GET;
     if (is_array($params) && !empty($params)) {
         $urlParams = array_merge($_GET, $params);
     }
     $this->joinForm = OW::getClassInstance('JoinForm', $this);
     $this->joinForm->setAction(OW::getRouter()->urlFor('BASE_CTRL_Join', 'joinFormSubmit', $urlParams));
     $step = $this->joinForm->getStep();
     $this->addForm($this->joinForm);
     $language->addKeyForJs('base', 'join_error_username_not_valid');
     $language->addKeyForJs('base', 'join_error_username_already_exist');
     $language->addKeyForJs('base', 'join_error_email_not_valid');
     $language->addKeyForJs('base', 'join_error_email_already_exist');
     $language->addKeyForJs('base', 'join_error_password_not_valid');
     $language->addKeyForJs('base', 'join_error_password_too_short');
     $language->addKeyForJs('base', 'join_error_password_too_long');
     //include js
     $onLoadJs = " window.join = new OW_BaseFieldValidators( " . json_encode(array('formName' => $this->joinForm->getName(), 'responderUrl' => $this->responderUrl, 'passwordMaxLength' => UTIL_Validator::PASSWORD_MAX_LENGTH, 'passwordMinLength' => UTIL_Validator::PASSWORD_MIN_LENGTH)) . ",\n                " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . " ); ";
     OW::getDocument()->addOnloadScript($onLoadJs);
     $jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "base_field_validators.js");
     $joinConnectHook = OW::getRegistry()->getArray(self::JOIN_CONNECT_HOOK);
     if (!empty($joinConnectHook)) {
         $content = array();
         foreach ($joinConnectHook as $function) {
             $result = call_user_func($function);
             if (trim($result)) {
                 $content[] = $result;
             }
         }
         $this->assign('joinConnectHook', $content);
     }
     $this->setDocumentKey('base_user_join');
 }
Example #7
0
OW::getRouter()->addRoute(new OW_Route('groups-admin-additional-features', 'admin/plugins/groups/additional', 'GROUPS_CTRL_Admin', 'additional'));
OW::getRouter()->addRoute(new OW_Route('groups-admin-uninstall', 'admin/plugins/groups/uninstall', 'GROUPS_CTRL_Admin', 'uninstall'));
//Frontend Routs
OW::getRouter()->addRoute(new OW_Route('groups-create', 'groups/create', 'GROUPS_CTRL_Groups', 'create'));
OW::getRouter()->addRoute(new OW_Route('groups-edit', 'groups/:groupId/edit', 'GROUPS_CTRL_Groups', 'edit'));
OW::getRouter()->addRoute(new OW_Route('groups-view', 'groups/:groupId', 'GROUPS_CTRL_Groups', 'view'));
OW::getRouter()->addRoute(new OW_Route('groups-join', 'groups/:groupId/join', 'GROUPS_CTRL_Groups', 'join'));
OW::getRouter()->addRoute(new OW_Route('groups-customize', 'groups/:groupId/customize', 'GROUPS_CTRL_Groups', 'customize'));
OW::getRouter()->addRoute(new OW_Route('groups-most-popular', 'groups/most-popular', 'GROUPS_CTRL_Groups', 'mostPopularList'));
OW::getRouter()->addRoute(new OW_Route('groups-latest', 'groups/latest', 'GROUPS_CTRL_Groups', 'latestList'));
OW::getRouter()->addRoute(new OW_Route('groups-invite-list', 'groups/invitations', 'GROUPS_CTRL_Groups', 'inviteList'));
OW::getRouter()->addRoute(new OW_Route('groups-my-list', 'groups/my', 'GROUPS_CTRL_Groups', 'myGroupList'));
OW::getRouter()->addRoute(new OW_Route('groups-index', 'groups', 'GROUPS_CTRL_Groups', 'index'));
OW::getRouter()->addRoute(new OW_Route('groups-user-groups', 'users/:user/groups', 'GROUPS_CTRL_Groups', 'userGroupList'));
OW::getRouter()->addRoute(new OW_Route('groups-leave', 'groups/:groupId/leave', 'GROUPS_CTRL_Groups', 'leave'));
OW::getRouter()->addRoute(new OW_Route('groups-user-list', 'groups/:groupId/users', 'GROUPS_CTRL_Groups', 'userList'));
OW::getRouter()->addRoute(new OW_Route('groups-private-group', 'groups/:groupId/private', 'GROUPS_CTRL_Groups', 'privateGroup'));
OW::getRegistry()->addToArray(BASE_CMP_AddNewContent::REGISTRY_DATA_KEY, array(BASE_CMP_AddNewContent::DATA_KEY_ICON_CLASS => 'ow_ic_comment', BASE_CMP_AddNewContent::DATA_KEY_URL => OW::getRouter()->urlForRoute('groups-create'), BASE_CMP_AddNewContent::DATA_KEY_LABEL => OW::getLanguage()->text('groups', 'add_new_label')));
$eventHandler = GROUPS_CLASS_EventHandler::getInstance();
$eventHandler->genericInit();
OW::getEventManager()->bind('forum.activate_plugin', array($eventHandler, "onForumActivate"));
OW::getEventManager()->bind('forum.find_forum_caption', array($eventHandler, "onForumFindCaption"));
OW::getEventManager()->bind('forum.uninstall_plugin', array($eventHandler, "onForumUninstall"));
OW::getEventManager()->bind('forum.collect_widget_places', array($eventHandler, "onForumCollectWidgetPlaces"));
OW::getEventManager()->bind('feed.collect_widgets', array($eventHandler, "onFeedCollectWidgets"));
OW::getEventManager()->bind('feed.on_widget_construct', array($eventHandler, "onFeedWidgetConstruct"));
OW::getEventManager()->bind('feed.on_item_render', array($eventHandler, "onFeedItemRender"));
OW::getEventManager()->bind('admin.add_admin_notification', array($eventHandler, "onCollectAdminNotifications"));
OW::getEventManager()->bind(BASE_CMP_QuickLinksWidget::EVENT_NAME, array($eventHandler, 'onCollectQuickLinks'));
GROUPS_CLASS_ConsoleBridge::getInstance()->init();
GROUPS_CLASS_ContentProvider::getInstance()->init();
Example #8
0
 public function index($params)
 {
     $adminMode = false;
     $viewerId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthenticated() || $viewerId === null) {
         throw new AuthenticateException();
     }
     if (!empty($params['userId']) && $params['userId'] != $viewerId) {
         if (OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base')) {
             $adminMode = true;
             $userId = (int) $params['userId'];
             $user = BOL_UserService::getInstance()->findUserById($userId);
             if (empty($user) || BOL_AuthorizationService::getInstance()->isSuperModerator($userId)) {
                 throw new Redirect404Exception();
             }
             $editUserId = $userId;
         } else {
             throw new Redirect403Exception();
         }
     } else {
         $editUserId = $viewerId;
         $changePassword = new BASE_CMP_ChangePassword();
         $this->addComponent("changePassword", $changePassword);
         $contentMenu = new BASE_CMP_DashboardContentMenu();
         $contentMenu->getElement('profile_edit')->setActive(true);
         $this->addComponent('contentMenu', $contentMenu);
         $user = OW::getUser()->getUserObject();
         //BOL_UserService::getInstance()->findUserById($editUserId);
     }
     $changeList = BOL_PreferenceService::getInstance()->getPreferenceValue(self::PREFERENCE_LIST_OF_CHANGES, $editUserId);
     if (empty($changeList)) {
         $changeList = '[]';
     }
     $this->assign('changeList', json_decode($changeList, true));
     $isEditedUserModerator = BOL_AuthorizationService::getInstance()->isModerator($editUserId) || BOL_AuthorizationService::getInstance()->isSuperModerator($editUserId);
     $accountType = $user->accountType;
     // dispaly account type
     if (OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base')) {
         $accountType = !empty($_GET['accountType']) ? $_GET['accountType'] : $user->accountType;
         // get available account types from DB
         $accountTypes = BOL_QuestionService::getInstance()->findAllAccountTypes();
         $accounts = array();
         if (count($accountTypes) > 1) {
             /* @var $value BOL_QuestionAccount */
             foreach ($accountTypes as $key => $value) {
                 $accounts[$value->name] = OW::getLanguage()->text('base', 'questions_account_type_' . $value->name);
             }
             if (!in_array($accountType, array_keys($accounts))) {
                 if (in_array($user->accountType, array_keys($accounts))) {
                     $accountType = $user->accountType;
                 } else {
                     $accountType = BOL_QuestionService::getInstance()->getDefaultAccountType()->name;
                 }
             }
             $editAccountType = new Selectbox('accountType');
             $editAccountType->setId('accountType');
             $editAccountType->setLabel(OW::getLanguage()->text('base', 'questions_question_account_type_label'));
             $editAccountType->setRequired();
             $editAccountType->setOptions($accounts);
             $editAccountType->setHasInvitation(false);
         } else {
             $accountType = BOL_QuestionService::getInstance()->getDefaultAccountType()->name;
         }
     }
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('base', 'edit_index'));
     $this->setPageHeadingIconClass('ow_ic_user');
     // -- Edit form --
     $editForm = new EditQuestionForm('editForm', $editUserId);
     $editForm->setId('editForm');
     $this->assign('displayAccountType', false);
     // dispaly account type
     if (!empty($editAccountType)) {
         $editAccountType->setValue($accountType);
         $editForm->addElement($editAccountType);
         OW::getDocument()->addOnloadScript(" \$('#accountType').change(function() {\n                \n                var form = \$(\"<form method='get'><input type='text' name='accountType' value='\" + \$(this).val() + \"' /></form>\");\n                \$('body').append(form);\n                \$(form).submit();\n\n            }  ); ");
         $this->assign('displayAccountType', true);
     }
     $userId = !empty($params['userId']) ? $params['userId'] : $viewerId;
     // add avatar field
     $editAvatar = OW::getClassInstance("BASE_CLASS_AvatarField", 'avatar', false);
     $editAvatar->setLabel(OW::getLanguage()->text('base', 'questions_question_user_photo_label'));
     $editAvatar->setValue(BOL_AvatarService::getInstance()->getAvatarUrl($userId, 1, null, true, false));
     $displayPhotoUpload = OW::getConfig()->getValue('base', 'join_display_photo_upload');
     // add the required avatar validator
     if ($displayPhotoUpload == BOL_UserService::CONFIG_JOIN_DISPLAY_AND_SET_REQUIRED_PHOTO_UPLOAD) {
         $avatarValidator = OW::getClassInstance("BASE_CLASS_AvatarFieldValidator", true, $userId);
         $editAvatar->addValidator($avatarValidator);
     }
     $editForm->addElement($editAvatar);
     $isUserApproved = BOL_UserService::getInstance()->isApproved($editUserId);
     $this->assign('isUserApproved', $isUserApproved);
     // add submit button
     $editSubmit = new Submit('editSubmit');
     $editSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $editSubmit->setValue($language->text('base', 'edit_button'));
     if ($adminMode && !$isUserApproved) {
         $editSubmit->setName('saveAndApprove');
         $editSubmit->setValue($language->text('base', 'save_and_approve'));
         // TODO: remove
         if (!$isEditedUserModerator) {
             // add delete button
             $script = UTIL_JsGenerator::newInstance()->jQueryEvent('input.delete_user_by_moderator', 'click', 'OW.Users.deleteUser(e.data.userId, e.data.callbackUrl, false);', array('e'), array('userId' => $userId, 'callbackUrl' => OW::getRouter()->urlForRoute('base_member_dashboard')));
             OW::getDocument()->addOnloadScript($script);
         }
     }
     $editForm->addElement($editSubmit);
     // prepare question list
     $questions = $this->questionService->findEditQuestionsForAccountType($accountType);
     $section = null;
     $questionArray = array();
     $questionNameList = array();
     foreach ($questions as $sort => $question) {
         if ($section !== $question['sectionName']) {
             $section = $question['sectionName'];
         }
         $questionArray[$section][$sort] = $questions[$sort];
         $questionNameList[] = $questions[$sort]['name'];
     }
     $this->assign('questionArray', $questionArray);
     $questionData = $this->questionService->getQuestionData(array($editUserId), $questionNameList);
     $questionValues = $this->questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     // add question to form
     $editForm->addQuestions($questions, $questionValues, !empty($questionData[$editUserId]) ? $questionData[$editUserId] : array());
     // process form
     if (OW::getRequest()->isPost()) {
         if (isset($_POST['editSubmit']) || isset($_POST['saveAndApprove'])) {
             $this->process($editForm, $user->id, $questionArray, $adminMode);
         }
     }
     $this->addForm($editForm);
     $deleteUrl = OW::getRouter()->urlForRoute('base_delete_user');
     $this->assign('unregisterProfileUrl', $deleteUrl);
     // add langs to js
     $language->addKeyForJs('base', 'join_error_username_not_valid');
     $language->addKeyForJs('base', 'join_error_username_already_exist');
     $language->addKeyForJs('base', 'join_error_email_not_valid');
     $language->addKeyForJs('base', 'join_error_email_already_exist');
     $language->addKeyForJs('base', 'join_error_password_not_valid');
     $language->addKeyForJs('base', 'join_error_password_too_short');
     $language->addKeyForJs('base', 'join_error_password_too_long');
     //include js
     $onLoadJs = " window.edit = new OW_BaseFieldValidators( " . json_encode(array('formName' => $editForm->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Edit", "ajaxResponder"))) . ",\n                                                        " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . ", " . $editUserId . " ); ";
     $this->assign('isAdmin', OW::getUser()->isAdmin());
     $this->assign('isEditedUserModerator', $isEditedUserModerator);
     $this->assign('adminMode', $adminMode);
     $approveEnabled = OW::getConfig()->getValue('base', 'mandatory_user_approve');
     $this->assign('approveEnabled', $approveEnabled);
     OW::getDocument()->addOnloadScript('
         $("input.write_message_button").click( function() {
                 OW.ajaxFloatBox("BASE_CMP_SendMessageToEmail", [' . (int) $editUserId . '],
                 {
                     title: ' . json_encode($language->text('base', 'send_message_to_email')) . ',
                     width:600
                 });
             }
         );
     ');
     OW::getDocument()->addOnloadScript($onLoadJs);
     $jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "base_field_validators.js");
     if (!$adminMode) {
         $editSynchronizeHook = OW::getRegistry()->getArray(self::EDIT_SYNCHRONIZE_HOOK);
         if (!empty($editSynchronizeHook)) {
             $content = array();
             foreach ($editSynchronizeHook as $function) {
                 $result = call_user_func($function);
                 if (trim($result)) {
                     $content[] = $result;
                 }
             }
             $content = array_filter($content, 'trim');
             if (!empty($content)) {
                 $this->assign('editSynchronizeHook', $content);
             }
         }
     }
 }
Example #9
0
 public function index($params)
 {
     $adminMode = false;
     $viewerId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthenticated() || $viewerId === null) {
         throw new AuthenticateException();
     }
     if (!empty($params['userId']) && $params['userId'] != $viewerId) {
         if (OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base')) {
             $adminMode = true;
             $userId = (int) $params['userId'];
             $user = BOL_UserService::getInstance()->findUserById($userId);
             if (empty($user) || BOL_AuthorizationService::getInstance()->isSuperModerator($userId)) {
                 throw new Redirect404Exception();
             }
             $editUserId = $userId;
         } else {
             throw new Redirect403Exception();
         }
     } else {
         $editUserId = $viewerId;
         $changePassword = new BASE_CMP_ChangePassword();
         $this->addComponent("changePassword", $changePassword);
         $contentMenu = new BASE_CMP_DashboardContentMenu();
         $contentMenu->getElement('profile_edit')->setActive(true);
         $this->addComponent('contentMenu', $contentMenu);
         $user = BOL_UserService::getInstance()->findUserById($editUserId);
     }
     $accountType = $user->accountType;
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('base', 'edit_index'));
     $this->setPageHeadingIconClass('ow_ic_user');
     // -- Edit form --
     $editForm = new EditQuestionForm('editForm', $editUserId);
     $editForm->setId('editForm');
     $editSubmit = new Submit('editSubmit');
     $editSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $editSubmit->setValue($language->text('base', 'edit_button'));
     $editForm->addElement($editSubmit);
     $questions = $this->questionService->findEditQuestionsForAccountType($accountType);
     $section = null;
     $questionArray = array();
     $questionNameList = array();
     foreach ($questions as $sort => $question) {
         if ($section !== $question['sectionName']) {
             $section = $question['sectionName'];
         }
         $questionArray[$section][$sort] = $questions[$sort];
         $questionNameList[] = $questions[$sort]['name'];
     }
     $this->assign('questionArray', $questionArray);
     $questionData = $this->questionService->getQuestionData(array($editUserId), $questionNameList);
     $questionValues = $this->questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     $editForm->addQuestions($questions, $questionValues, $questionData[$editUserId]);
     if (OW::getRequest()->isPost()) {
         if ($editForm->isValid($_POST)) {
             $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($user->id)) {
                 if ($this->questionService->saveQuestionsData($data, $user->id)) {
                     if (!$adminMode) {
                         $event = new OW_Event(OW_EventManager::ON_USER_EDIT, array('userId' => $user->id, 'method' => 'native'));
                         OW::getEventManager()->trigger($event);
                         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' => $user->id));
                         OW::getEventManager()->trigger($event);
                         OW::getFeedback()->info($language->text('base', 'edit_successfull_edit'));
                         $this->redirect(OW::getRouter()->urlForRoute('base_user_profile', array('username' => BOL_UserService::getInstance()->getUserName($editUserId))));
                     }
                 } else {
                     OW::getFeedback()->info($language->text('base', 'edit_edit_error'));
                 }
             } else {
                 OW::getFeedback()->info($language->text('base', 'edit_edit_error'));
             }
         }
     }
     $this->addForm($editForm);
     $this->assign('unregisterProfileUrl', OW::getRouter()->urlForRoute('base_delete_user'));
     $language->addKeyForJs('base', 'join_error_username_not_valid');
     $language->addKeyForJs('base', 'join_error_username_already_exist');
     $language->addKeyForJs('base', 'join_error_email_not_valid');
     $language->addKeyForJs('base', 'join_error_email_already_exist');
     $language->addKeyForJs('base', 'join_error_password_not_valid');
     $language->addKeyForJs('base', 'join_error_password_too_short');
     $language->addKeyForJs('base', 'join_error_password_too_long');
     //include js
     $onLoadJs = " window.edit = new OW_BaseFieldValidators( " . json_encode(array('formName' => $editForm->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Edit", "ajaxResponder"))) . ",\n                                                        " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . ", " . $editUserId . " ); ";
     $this->assign('isAdmin', OW::getUser()->isAdmin());
     OW::getDocument()->addOnloadScript($onLoadJs);
     $jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "base_field_validators.js");
     if (!$adminMode) {
         $editSynchronizeHook = OW::getRegistry()->getArray(self::EDIT_SYNCHRONIZE_HOOK);
         if (!empty($editSynchronizeHook)) {
             $content = array();
             foreach ($editSynchronizeHook as $function) {
                 $result = call_user_func($function);
                 if (trim($result)) {
                     $content[] = $result;
                 }
             }
             $content = array_filter($content, 'trim');
             if (!empty($content)) {
                 $this->assign('editSynchronizeHook', $content);
             }
         }
     }
 }
Example #10
0
 public function init()
 {
     if (!OW::getRegistry()->get("baseInited")) {
         $handler = new BASE_CLASS_EventHandler();
         $handler->genericInit();
         OW::getRegistry()->set("baseInited", true);
     }
     $em = OW::getEventManager();
     $em->bind(self::EVENT_COLLECT_AUTHORIZATION_ACTIONS, array($this, 'onCollectBaseAuthLabels'));
     $em->bind(self::EVENT_COLLECT_AUTHORIZATION_ACTIONS, array($this, 'onCollectMailboxAuthLabels'));
     $em->bind(self::EVENT_COLLECT_AUTHORIZATION_ACTIONS, array($this, 'onCollectPhotoAuthLabels'));
     $em->bind(self::EVENT_COLLECT_AUTHORIZATION_ACTIONS, array($this, 'onCollectVirtualGiftsAuthLabels'));
     $em->bind(SKADATEIOS_ACTRL_Ping::PING_EVENT . '.notifications', array($this, 'onPingNotifications'));
     $em->bind(OW_EventManager::ON_AFTER_ROUTE, array($this, "onAfterRoute"));
     $em->bind('mailbox.renderOembed', array($this, 'onRenderOembedInMailbox'));
     $em->bind('wink.renderWink', array($this, 'onRenderWinkInMailbox'));
     $em->bind('wink.renderWinkBack', array($this, 'onRenderWinkBackInMailbox'));
 }
Example #11
0
 public function init()
 {
     if (!OW::getRegistry()->get("baseInited")) {
         $handler = new BASE_CLASS_EventHandler();
         $handler->genericInit();
         OW::getRegistry()->set("baseInited", true);
     }
     $em = OW::getEventManager();
     $em->bind(self::EVENT_COLLECT_AUTHORIZATION_ACTIONS, array($this, 'onCollectBaseAuthLabels'));
     $em->bind(self::EVENT_COLLECT_AUTHORIZATION_ACTIONS, array($this, 'onCollectMailboxAuthLabels'));
     $em->bind(self::EVENT_COLLECT_AUTHORIZATION_ACTIONS, array($this, 'onCollectPhotoAuthLabels'));
     $em->bind(self::EVENT_COLLECT_AUTHORIZATION_ACTIONS, array($this, 'onCollectVirtualGiftsAuthLabels'));
     $em->bind(self::EVENT_COLLECT_AUTHORIZATION_ACTIONS, array($this, 'onCollectHotListAuthLabels'));
     $em->bind('skandroid.base.ping', array($this, 'onPing'));
     $em->bind(self::PING_EVENT . '.mailbox_dialog', array($this, 'onMailboxGetChatNewMessages'));
     $em->bind(self::PING_EVENT . '.mailbox_new_messages', array($this, 'onMailboxGetNewMessages'));
     $em->bind(OW_EventManager::ON_AFTER_ROUTE, array($this, "onAfterRoute"));
     //        $em->bind('mailbox.renderOembed', array($this, 'onRenderOembedInMailbox'));
     //        $em->bind('wink.renderWink', array($this, 'onRenderWinkInMailbox'));
     //        $em->bind('wink.renderWinkBack', array($this, 'onRenderWinkBackInMailbox'));
 }