Exemple #1
0
 /**
  *
  * @param $email
  * @param $name
  * @return BASE_CLASS_Mail
  */
 public function setSender($email, $name = '')
 {
     if (!UTIL_Validator::isEmailValid($email)) {
         throw new InvalidArgumentException('Invalid argument `$email`');
     }
     $this->state['sender'] = array($email, $name);
     return $this;
 }
Exemple #2
0
 protected function checkCaptcha()
 {
     $lastSendStamp = BOL_PreferenceService::getInstance()->getPreferenceValue('mailbox_create_conversation_stamp', $this->userId);
     $displayCaptcha = BOL_PreferenceService::getInstance()->getPreferenceValue('mailbox_create_conversation_display_capcha', $this->userId);
     if (!$displayCaptcha && $lastSendStamp + CreateConversationForm::DISPLAY_CAPTCHA_TIMEOUT > time()) {
         BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_display_capcha', true, $this->userId);
         $displayCaptcha = true;
     }
     $captcha = $this->getElement('captcha');
     $captcha->setRequired();
     return !$displayCaptcha || $captcha->isValid() && UTIL_Validator::isCaptchaValid($captcha->getValue());
 }
 /**
  * @see Validator::isValid()
  *
  * @param mixed $value
  */
 public function isValid($value)
 {
     $language = OW::getLanguage();
     if (!UTIL_Validator::isEmailValid($value)) {
         $this->setErrorMessage($language->text('base', 'join_error_email_not_valid'));
         return false;
     } else {
         if (BOL_UserService::getInstance()->isExistEmail($value)) {
             $this->setErrorMessage($language->text('base', 'join_error_email_already_exist'));
             return false;
         }
     }
     return true;
 }
Exemple #4
0
 public function ajaxResponder()
 {
     if (empty($_POST["command"]) || !OW::getRequest()->isAjax()) {
         throw new Redirect404Exception();
     }
     $command = (string) $_POST["command"];
     switch ($command) {
         case 'checkCaptcha':
             $value = $_POST["value"];
             $result = UTIL_Validator::isCaptchaValid($value);
             if ($result) {
                 OW::getSession()->set('securimage_code_value', $value);
             }
             echo json_encode(array('result' => $result));
             break;
     }
     exit;
 }
Exemple #5
0
 public function ajaxResponder()
 {
     if (empty($_POST["command"]) || !OW::getRequest()->isAjax()) {
         throw new Redirect404Exception();
     }
     $command = (string) $_POST["command"];
     switch ($command) {
         case 'checkCaptcha':
             $value = $_POST["value"];
             $result = UTIL_Validator::isCaptchaValid($value);
             if ($result) {
                 OW::getSession()->set('securimage_code_value', $value);
             }
             $result === FALSE ? OW::getEventManager()->trigger(new OW_Event(ANTIBRUTEFORCE_BOL_Service::EVENT_AUTHENTICATE_FAIL)) : NULL;
             echo json_encode(array('result' => $result));
             break;
     }
     exit;
 }
 /**
  * @see Validator::isValid()
  *
  * @param mixed $value
  */
 public function isValid($value)
 {
     $language = OW::getLanguage();
     if (!UTIL_Validator::isUserNameValid($value)) {
         $this->setErrorMessage($language->text('base', 'join_error_username_not_valid'));
         return false;
     } else {
         if (BOL_UserService::getInstance()->isExistUserName($value)) {
             $this->setErrorMessage($language->text('base', 'join_error_username_already_exist'));
             return false;
         } else {
             if (BOL_UserService::getInstance()->isRestrictedUsername($value)) {
                 $this->setErrorMessage($language->text('base', 'join_error_username_restricted'));
                 return false;
             }
         }
     }
     return true;
 }
Exemple #7
0
 private function getQuestionWhereString(BOL_Question $question, $value, $prefix = '')
 {
     $result = '';
     $prefix = $this->dbo->escapeString($prefix);
     /* $event = new OW_Event('base.questions_get_search_sql', array(
               'presentation' => $question->presentation,
               'fieldName' => $question->name,
               'value' => $value,
               'tablePrefix' => $prefix,
               'questionDto' => $question
               ));
     
               OW::getEventManager()->trigger($event);
     
               $result = $event->getData();
     
               if ( !empty($result) )
               {
               return $result;
               } */
     switch ($question->presentation) {
         case BOL_QuestionService::QUESTION_PRESENTATION_URL:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
             $result = " LCASE(`" . $prefix . "`.`textValue`) LIKE '" . $this->dbo->escapeString(strtolower($value)) . "%'";
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
             $result = " `" . $prefix . "`.`intValue` = " . (bool) $value;
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
         case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
             if (!empty($value)) {
                 if (is_array($value)) {
                     $result = ' `' . $this->dbo->escapeString($prefix) . '`.`intValue` IN ( ' . $this->dbo->mergeInClause($value) . ') ';
                 } else {
                     if ((int) $value > 0) {
                         $result = ' `' . $this->dbo->escapeString($prefix) . '`.`intValue` & \'' . (int) $value . '\' ';
                     }
                 }
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
             if (!empty($value)) {
                 if (is_array($value)) {
                     $result = " `" . $prefix . "`.`intValue` & '" . $this->dbo->escapeString(array_sum($value)) . "'";
                 } else {
                     if ((int) $value > 0) {
                         $result = " `" . $prefix . "`.`intValue` & '" . (int) $value . "'";
                     }
                 }
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
         case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
             if (isset($value['from']) && isset($value['to'])) {
                 $maxDate = date('Y') - (int) $value['from'] . '-12-31';
                 $minDate = date('Y') - (int) $value['to'] . '-01-01';
                 $result = " `" . $prefix . "`.`dateValue` BETWEEN  '" . $this->dbo->escapeString($minDate) . "' AND '" . $this->dbo->escapeString($maxDate) . "'";
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
             $dateFrom = UTIL_DateTime::parseDate($value['from']);
             $dateTo = UTIL_DateTime::parseDate($value['to']);
             if (isset($dateFrom)) {
                 if (UTIL_Validator::isDateValid($dateFrom[UTIL_DateTime::PARSE_DATE_MONTH], $dateFrom[UTIL_DateTime::PARSE_DATE_DAY], $dateFrom[UTIL_DateTime::PARSE_DATE_YEAR])) {
                     $valueFrom = $dateFrom[UTIL_DateTime::PARSE_DATE_YEAR] . '-' . $dateFrom[UTIL_DateTime::PARSE_DATE_MONTH] . '-' . $dateFrom[UTIL_DateTime::PARSE_DATE_DAY];
                 }
             }
             if (isset($dateTo)) {
                 if (UTIL_Validator::isDateValid($dateTo[UTIL_DateTime::PARSE_DATE_MONTH], $dateTo[UTIL_DateTime::PARSE_DATE_DAY], $dateTo[UTIL_DateTime::PARSE_DATE_YEAR])) {
                     $valueTo = $dateTo[UTIL_DateTime::PARSE_DATE_YEAR] . '-' . $dateTo[UTIL_DateTime::PARSE_DATE_MONTH] . '-' . $dateTo[UTIL_DateTime::PARSE_DATE_DAY];
                 }
             }
             if (isset($valueFrom) && isset($valueTo)) {
                 $result = " `" . $prefix . "`.`dateValue` BETWEEN  '" . $valueFrom . "' AND '" . $valueTo . "'";
             }
             break;
     }
     return $result;
 }
Exemple #8
0
 private function setDefaultDate($year, $month, $day)
 {
     if (UTIL_Validator::isDateValid((int) $month, (int) $day, (int) $year)) {
         $this->defaultDate['year'] = (int) $year;
         $this->defaultDate['month'] = (int) $month;
         $this->defaultDate['day'] = (int) $day;
     } else {
         throw new InvalidArgumentException('Invalid date!');
     }
 }
Exemple #9
0
 public function login($params)
 {
     $backUri = empty($_GET['backUri']) ? '' : urldecode($_GET['backUri']);
     $backUrl = OW_URL_HOME . $backUri;
     $language = OW::getLanguage();
     $fbUser = $this->service->fbRequireUser();
     $authAdapter = new FBCONNECT_CLASS_AuthAdapter($fbUser);
     // Login and redirect if already registered
     if ($authAdapter->isRegistered()) {
         $authResult = OW::getUser()->authenticate($authAdapter);
         if ($authResult->isValid()) {
             OW::getFeedback()->info($language->text('fbconnect', 'login_success_msg'));
         } else {
             OW::getFeedback()->error($language->text('fbconnect', 'login_failure_msg'));
         }
         $this->redirect($backUrl);
     }
     //Register if not registered
     $questions = $this->service->requestQuestionValueList($fbUser);
     if (empty($questions["email"]) || empty($questions["username"])) {
         OW::getFeedback()->error($language->text('fbconnect', 'join_incomplete'));
         $this->redirect($backUrl);
     }
     $username = $questions['username'];
     $password = uniqid();
     $userByEmail = BOL_UserService::getInstance()->findByEmail($questions['email']);
     if ($userByEmail !== null) {
         OW::getUser()->login($userByEmail->id);
         OW::getFeedback()->info($language->text('fbconnect', 'login_success_msg'));
         $this->redirect($backUrl);
     }
     $validUsername = UTIL_Validator::isUserNameValid($username);
     $username = $validUsername ? $username : uniqid("user_");
     try {
         $user = BOL_UserService::getInstance()->createUser($username, $password, $questions['email'], null, true);
         if (!$validUsername) {
             $user->username = "******" . $user->id;
             BOL_UserService::getInstance()->saveOrUpdate($user);
         }
         unset($questions['username']);
         unset($questions['email']);
     } catch (Exception $e) {
         switch ($e->getCode()) {
             case BOL_UserService::CREATE_USER_DUPLICATE_EMAIL:
                 OW::getFeedback()->error($language->text('fbconnect', 'join_dublicate_email_msg'));
                 $this->redirect($backUrl);
                 break;
             case BOL_UserService::CREATE_USER_INVALID_USERNAME:
                 OW::getFeedback()->error($language->text('fbconnect', 'join_incorrect_username'));
                 $this->redirect($backUrl);
                 break;
             default:
                 OW::getFeedback()->error($language->text('fbconnect', 'join_incomplete'));
                 $this->redirect($backUrl);
         }
     }
     if (!empty($questions['picture_big'])) {
         BOL_AvatarService::getInstance()->setUserAvatar($user->id, $questions['picture_big']);
         unset($questions['picture_small']);
         unset($questions['picture_medium']);
         unset($questions['picture_big']);
     }
     BOL_QuestionService::getInstance()->saveQuestionsData(array_filter($questions), $user->id);
     $authAdapter->register($user->id);
     $authResult = OW_Auth::getInstance()->authenticate($authAdapter);
     if ($authResult->isValid()) {
         $event = new OW_Event(OW_EventManager::ON_USER_REGISTER, array('method' => 'facebook', 'userId' => $user->id, 'params' => $_GET));
         OW::getEventManager()->trigger($event);
         OW::getFeedback()->info($language->text('fbconnect', 'join_success_msg'));
     } else {
         OW::getFeedback()->error($language->text('fbconnect', 'join_failure_msg'));
     }
     $this->redirect($backUrl);
 }
Exemple #10
0
 /**
  * User list page controller
  *
  * @param array $params
  */
 public function index(array $params)
 {
     $language = OW::getLanguage();
     $userService = BOL_UserService::getInstance();
     OW::getDocument()->getMasterPage()->getMenu(OW_Navigation::ADMIN_USERS)->getElement('sidebar_menu_item_users')->setActive(true);
     // invite members
     $form = new Form('invite-members');
     $hidden = new HiddenField('invite_members');
     $hidden->setValue('1');
     $form->addElement($hidden);
     $emails = new Textarea('emails');
     $form->addElement($emails);
     $emails->setRequired();
     $emails->setHasInvitation(true);
     $emails->setInvitation($language->text('admin', 'invite_members_textarea_invitation_text', array('limit' => (int) OW::getConfig()->getValue('base', 'user_invites_limit'))));
     $submit = new Submit('submit');
     $submit->setValue($language->text('admin', 'invite_members_submit_label'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost() && isset($_POST['invite_members'])) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $emails = array_unique(preg_split('/\\n/', $data['emails']));
             $emailList = array();
             foreach ($emails as $email) {
                 if (UTIL_Validator::isEmailValid(trim($email))) {
                     $emailList[] = trim($email);
                 }
             }
             if (sizeof($emailList) > (int) OW::getConfig()->getValue('base', 'user_invites_limit')) {
                 OW::getFeedback()->error($language->text('admin', 'invite_members_max_limit_message', array('limit' => (int) OW::getConfig()->getValue('base', 'user_invites_limit'))));
                 $form->getElement('emails')->setValue($data['emails']);
                 $this->redirect();
             }
             if (empty($emailList)) {
                 OW::getFeedback()->error($language->text('admin', 'invite_members_min_limit_message'));
                 $form->getElement('emails')->setValue($data['emails']);
                 $this->redirect();
             }
             foreach ($emailList as $email) {
                 BOL_UserService::getInstance()->sendAdminInvitation($email);
             }
             OW::getFeedback()->info($language->text('admin', 'invite_members_success_message'));
             $this->redirect();
         }
     }
     $language->addKeyForJs('admin', 'invite_members_cap_label');
     $language->addKeyForJs('admin', 'admin_suspend_floatbox_title');
     $menu = $this->getMenu();
     $this->addComponent('menu', $menu);
     if (!empty($_GET['search']) && !empty($_GET['search_by'])) {
         $extra = array('question' => $_GET['search_by'], 'value' => $_GET['search']);
         $type = 'search';
     } else {
         $extra = null;
         $type = isset($params['list']) ? $params['list'] : 'recent';
     }
     $buttons['suspend'] = array('name' => 'suspend', 'id' => 'suspend_user_btn', 'label' => $language->text('base', 'suspend_user_btn'), 'class' => 'ow_mild_red');
     $buttons['suspend']['js'] = ' $("#suspend_user_btn").click(function(e){ 
         e.preventDefault();
         OW.ajaxFloatBox("ADMIN_CMP_SetSuspendMessage", [],{width: 520, title: OW.getLanguageText(\'admin\', \'admin_suspend_floatbox_title\')}); 
         return false;
     }); ';
     $buttons['unverify'] = array('name' => 'email_unverify', 'id' => 'email_unverify_user_btn', 'label' => $language->text('base', 'mark_email_unverified_btn'), 'class' => 'ow_mild_red');
     $buttons['unsuspend'] = array('name' => 'reactivate', 'id' => 'unsuspend_user_btn', 'label' => $language->text('base', 'unsuspend_user_btn'), 'class' => 'ow_mild_green');
     $buttons['verify'] = array('name' => 'email_verify', 'id' => 'email_verify_user_btn', 'label' => $language->text('base', 'mark_email_verified_btn'), 'class' => 'ow_mild_green');
     $buttons['approve'] = array('name' => 'approve', 'id' => 'approve_user_btn', 'label' => $language->text('base', 'approve_user_btn'), 'class' => 'ow_mild_green');
     //$buttons['disapprove'] = array('name' => 'disapprove', 'id' => 'disapprove_user_btn', 'label' => $language->text('base', 'disapprove_user_btn'), 'class' => 'ow_mild_red');
     $par = new ADMIN_UserListParams();
     $par->setType($type);
     $par->setExtra($extra);
     switch ($type) {
         case 'recent':
         case 'search':
             $par->addButton($buttons['suspend']);
             $par->addButton($buttons['unsuspend']);
             $par->addButton($buttons['unverify']);
             $par->addButton($buttons['verify']);
             $par->addButton($buttons['approve']);
             //$par->addButton($buttons['disapprove']);
             break;
         case 'suspended':
             $par->addButton($buttons['unsuspend']);
             break;
         case 'unverified':
             $par->addButton($buttons['verify']);
             break;
         case 'unapproved':
             $par->addButton($buttons['approve']);
             break;
     }
     $usersCmp = new ADMIN_CMP_UserList($par);
     $this->addComponent('userList', $usersCmp);
     if (!OW::getRequest()->isAjax()) {
         OW::getDocument()->setHeading(OW::getLanguage()->text('admin', 'heading_browse_users'));
         OW::getDocument()->setHeadingIconClass('ow_ic_user');
         $menuElement = $menu->getElement($type);
         if ($menuElement) {
             $menuElement->setActive(true);
         }
     }
     $this->assign('totalUsers', BOL_UserService::getInstance()->count(true));
     $question = OW::getConfig()->getValue('base', 'display_name_question');
     $searchQ = array($question => $language->text('base', 'questions_question_' . $question . '_label'), 'email' => $language->text('base', 'questions_question_email_label'));
     $this->assign('searchQ', $searchQ);
     $this->assign('currentSearch', array('question' => !empty($_GET['search_by']) ? $_GET['search_by'] : '', 'value' => !empty($_GET['search']) ? htmlspecialchars($_GET['search']) : ''));
     $this->assign('userSearchUrl', OW::getRouter()->urlForRoute('admin_users_browse'));
 }
Exemple #11
0
 public static function validateSettingList($settingList)
 {
     parent::validateSettingList($settingList);
     if (!UTIL_Validator::isUrlValid($settingList['rss_url'])) {
         throw new WidgetSettingValidateException(OW::getLanguage()->text('base', 'rss_widget_url_invalid_msg'), 'rss_url');
     }
     $urlInfo = parse_url($settingList['rss_url']);
     $urlHomeInfo = parse_url(OW_URL_HOME);
     if ($urlInfo['host'] == $urlHomeInfo['host']) {
         throw new WidgetSettingValidateException(OW::getLanguage()->text('base', 'rss_widget_url_invalid_msg'), 'rss_url');
     }
 }
 /**
  * @see Validator::isValid()
  *
  * @param mixed $value
  */
 public function isValid($value)
 {
     $language = OW::getLanguage();
     if (!UTIL_Validator::isEmailValid($value)) {
         $this->setErrorMessage($language->text('base', 'join_error_email_not_valid'));
         return false;
     }
     if (BOL_UserService::getInstance()->isExistEmail($value)) {
         $userId = $this->userId;
         if (empty($this->userId)) {
             $userId = OW::getUser()->getId();
         }
         $user = BOL_UserService::getInstance()->findUserById($userId);
         if ($value !== $user->email) {
             $this->setErrorMessage($language->text('base', 'join_error_email_already_exist'));
             return false;
         }
     }
     return true;
 }
 /**
  * Save questions data.
  *
  * @param array $data
  * @param int $userId
  */
 public function saveQuestionsData(array $data, $userId)
 {
     if ($data === null || !is_array($data)) {
         return false;
     }
     $user = null;
     if ((int) $userId > 0) {
         $user = $this->userService->findUserById($userId);
         if ($user === null) {
             return false;
         }
     } else {
         return false;
     }
     $oldUserEmail = $user->email;
     $event = new OW_Event('base.questions_save_data', array('userId' => $userId), $data);
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     $dataFields = array_keys($data);
     $questions = $this->questionDao->findQuestionsByQuestionNameList($dataFields);
     $questionsData = $this->dataDao->findByQuestionsNameList($dataFields, $userId);
     $questionsUserData = array();
     foreach ($questionsData as $questionData) {
         $questionsUserData[$questionData->questionName] = $questionData;
     }
     $questionDataArray = array();
     foreach ($questions as $key => $question) {
         $value = null;
         if (isset($data[$question->name])) {
             switch ($question->type) {
                 case self::QUESTION_VALUE_TYPE_TEXT:
                     $value = $question->presentation !== self::QUESTION_PRESENTATION_PASSWORD ? $this->questionTextFormatter(trim($data[$question->name])) : BOL_UserService::getInstance()->hashPassword($data[$question->name]);
                     if ((int) $question->base === 1 && in_array($question->name, $dataFields)) {
                         $property = new ReflectionProperty('BOL_User', $question->name);
                         $property->setValue($user, $value);
                     } else {
                         if (isset($questionsUserData[$question->name])) {
                             $questionData = $questionsUserData[$question->name];
                         } else {
                             $questionData = new BOL_QuestionData();
                             $questionData->userId = $userId;
                             $questionData->questionName = $question->name;
                         }
                         $questionData->textValue = $value;
                         if ($question->presentation === self::QUESTION_PRESENTATION_URL && !empty($value)) {
                             $questionData->textValue = $this->urlFilter($value);
                         }
                         $questionDataArray[] = $questionData;
                         //$this->dataDao->save($questionData);
                     }
                     break;
                 case self::QUESTION_VALUE_TYPE_DATETIME:
                     $date = UTIL_DateTime::parseDate($data[$question->name], UTIL_DateTime::DEFAULT_DATE_FORMAT);
                     if (!isset($date)) {
                         $date = UTIL_DateTime::parseDate($data[$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                     }
                     if (isset($date)) {
                         if (UTIL_Validator::isDateValid($date[UTIL_DateTime::PARSE_DATE_MONTH], $date[UTIL_DateTime::PARSE_DATE_DAY], $date[UTIL_DateTime::PARSE_DATE_YEAR])) {
                             $value = $date[UTIL_DateTime::PARSE_DATE_YEAR] . '-' . $date[UTIL_DateTime::PARSE_DATE_MONTH] . '-' . $date[UTIL_DateTime::PARSE_DATE_DAY];
                             if ((int) $question->base === 1 && in_array($question->name, $dataFields)) {
                                 $property = new ReflectionProperty('BOL_User', $question->name);
                                 $property->setValue($user, $value);
                             } else {
                                 if (isset($questionsUserData[$question->name])) {
                                     $questionData = $questionsUserData[$question->name];
                                 } else {
                                     $questionData = new BOL_QuestionData();
                                     $questionData->userId = $userId;
                                     $questionData->questionName = $question->name;
                                 }
                                 $questionData->dateValue = $value;
                                 $questionDataArray[] = $questionData;
                             }
                         }
                     }
                     break;
                 case self::QUESTION_VALUE_TYPE_MULTISELECT:
                     if (!empty($data[$question->name]) && is_array($data[$question->name])) {
                         $value = array_sum($data[$question->name]);
                     }
                 case self::QUESTION_VALUE_TYPE_SELECT:
                     if (!isset($value)) {
                         $value = (int) $data[$question->name];
                     }
                     if ((int) $question->base === 1 && in_array($question->name, $dataFields)) {
                         $property = new ReflectionProperty('BOL_User', $question->name);
                         $property->setValue($user, $value);
                     } else {
                         if (isset($questionsUserData[$question->name])) {
                             $questionData = $questionsUserData[$question->name];
                         } else {
                             $questionData = new BOL_QuestionData();
                             $questionData->userId = $userId;
                             $questionData->questionName = $question->name;
                         }
                         $questionData->intValue = $value;
                         $questionDataArray[] = $questionData;
                         //$this->dataDao->save($questionData);
                     }
                     break;
                 case self::QUESTION_VALUE_TYPE_BOOLEAN:
                     $value = false;
                     $issetValues = array('1', 'true', 'on');
                     if (in_array(mb_strtolower((string) $data[$question->name]), $issetValues)) {
                         $value = true;
                     }
                     if ((int) $question->base === 1 && in_array($question->name, $dataFields)) {
                         $property = new ReflectionProperty('BOL_User', $question->name);
                         $property->setValue($user, $value);
                     } else {
                         if (isset($questionsUserData[$question->name])) {
                             $questionData = $questionsUserData[$question->name];
                         } else {
                             $questionData = new BOL_QuestionData();
                             $questionData->userId = $userId;
                             $questionData->questionName = $question->name;
                         }
                         $questionData->intValue = $value;
                         $questionDataArray[] = $questionData;
                         //$this->dataDao->save($questionData);
                     }
                     break;
             }
         }
     }
     $sendVerifyMail = false;
     if ($user->id !== null) {
         if (strtolower($user->email) !== strtolower($oldUserEmail)) {
             $user->emailVerify = false;
             $sendVerifyMail = true;
         }
         if (!empty($data['accountType'])) {
             $accountType = $this->findAccountTypeByName($data['accountType']);
             $accountTypeOld = $this->findAccountTypeByName($user->accountType);
             if (!empty($accountType)) {
                 $user->accountType = $accountType->name;
                 $this->updateQuestionsEditStamp();
             }
         }
     }
     //printVar($user);
     $this->userService->saveOrUpdate($user);
     if (count($questionDataArray) > 0) {
         $this->dataDao->batchReplace($questionDataArray);
     }
     if ($sendVerifyMail && OW::getConfig()->getValue('base', 'confirm_email')) {
         BOL_EmailVerifyService::getInstance()->sendUserVerificationMail($user);
     }
     return true;
 }
Exemple #14
0
 public static function validateSettingList($settingList)
 {
     parent::validateSettingList($settingList);
     if (!UTIL_Validator::isUrlValid($settingList['rss_url'])) {
         throw new WidgetSettingValidateException(OW::getLanguage()->text('base', 'rss_widget_url_invalid_msg'), 'rss_url');
     }
 }
Exemple #15
0
 public function createUser($username, $password, $email, $accountType = null, $emailVerify = false)
 {
     if (!UTIL_Validator::isEmailValid($email)) {
         throw new InvalidArgumentException('Invalid email!', self::CREATE_USER_INVALID_EMAIL);
     }
     if (!UTIL_Validator::isUserNameValid($username)) {
         throw new InvalidArgumentException('Invalid username!', self::CREATE_USER_INVALID_USERNAME);
     }
     if (!isset($password) || strlen($password) === 0) {
         throw new InvalidArgumentException('Invalid password!', self::CREATE_USER_INVALID_PASSWORD);
     }
     if ($this->isExistUserName($username)) {
         throw new LogicException('Duplicate username!', self::CREATE_USER_DUPLICATE_USERNAME);
     }
     if ($this->isExistEmail($email)) {
         throw new LogicException('Duplicate email!', self::CREATE_USER_DUPLICATE_EMAIL);
     }
     $userAccountType = $accountType;
     if ($userAccountType === null) {
         $userAccountType = '';
         $accountTypes = BOL_QuestionService::getInstance()->findAllAccountTypes();
         if (count($accountTypes) === 1) {
             $userAccountType = $accountTypes[0]->name;
         }
     }
     $user = new BOL_User();
     $user->username = trim($username);
     $user->password = BOL_UserService::getInstance()->hashPassword($password);
     $user->email = trim($email);
     $user->joinStamp = time();
     $user->activityStamp = time();
     $user->accountType = $userAccountType;
     $user->joinIp = ip2long(OW::getRequest()->getRemoteAddress());
     if ($emailVerify === true) {
         $user->emailVerify = true;
     }
     $this->saveOrUpdate($user);
     BOL_AuthorizationService::getInstance()->assignDefaultRoleToUser($user->id);
     return $user;
 }
Exemple #16
0
 public function site()
 {
     $this->setPageTitle('Site');
     INSTALL::getStepIndicator()->activate('site');
     $fieldData = array();
     $fieldData['site_url'] = OW_URL_HOME;
     $fieldData['site_path'] = OW_DIR_ROOT;
     $sessionData = INSTALL::getStorage()->getAll();
     $fieldData = array_merge($fieldData, $sessionData);
     $this->assign('data', $fieldData);
     $errors = array();
     if (OW::getRequest()->isPost()) {
         $data = $_POST;
         $data = array_filter($data, 'trim');
         $success = true;
         if (empty($data['site_title'])) {
             $errors[] = 'site_title';
         }
         if (empty($data['site_url']) || !trim($data['site_url'])) {
             $errors[] = 'site_url';
         }
         if (empty($data['site_path']) || !is_dir($data['site_path'])) {
             $errors[] = 'site_path';
         }
         if (empty($data['admin_username']) || !UTIL_Validator::isUserNameValid($data['admin_username'])) {
             $errors[] = 'admin_username';
         }
         if (empty($data['admin_password']) || strlen($data['admin_password']) < 3) {
             $errors[] = 'admin_password';
         }
         if (empty($data['admin_email']) || !UTIL_Validator::isEmailValid($data['admin_email'])) {
             $errors[] = 'admin_email';
         }
         $this->processData($data);
         if (empty($errors)) {
             $this->redirect(OW::getRouter()->urlForRoute('db'));
         }
         foreach ($errors as $flag) {
             INSTALL::getFeedback()->errorFlag($flag);
         }
         $this->redirect();
     }
 }
Exemple #17
0
 public function checkValue($value)
 {
     return UTIL_Validator::isCaptchaValid($value);
 }
 /**
  * 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;
     }
 }
Exemple #19
0
 public function ajaxResponder()
 {
     if (empty($_POST["command"]) || !OW::getRequest()->isAjax()) {
         throw new Redirect404Exception();
     }
     $command = (string) $_POST["command"];
     switch ($command) {
         case 'sendVerifyEmail':
             $result = false;
             $email = trim($_POST["email"]);
             if (UTIL_Validator::isEmailValid($email)) {
                 OW::getConfig()->saveConfig('base', 'unverify_site_email', $email);
                 $siteEmail = OW::getConfig()->getValue('base', 'site_email');
                 if ($siteEmail !== $email) {
                     $type = 'info';
                     BOL_EmailVerifyService::getInstance()->sendSiteVerificationMail(false);
                     $message = OW::getLanguage()->text('base', 'email_verify_verify_mail_was_sent');
                     $result = true;
                 } else {
                     $type = 'warning';
                     $message = OW::getLanguage()->text('admin', 'email_already_verify');
                 }
             }
             $responce = json_encode(array('result' => $result, 'type' => $type, 'message' => $message));
             break;
     }
     exit($responce);
 }