コード例 #1
0
 /**
  * Save the event to the database
  *      
  * @param array $data
  * 
  * @return boolean true if saved successfully, false otherwise
  */
 function save($data)
 {
     global $objDatabase, $_LANGID, $_CONFIG, $objInit;
     parent::getSettings();
     if (empty($data['startDate']) || empty($data['endDate']) || empty($data['category']) || $data['seriesStatus'] == 1 && $data['seriesType'] == 2 && empty($data['seriesWeeklyDays'])) {
         return false;
     }
     foreach ($_POST['showIn'] as $key => $langId) {
         if (empty($_POST['title'][$langId]) && empty($_POST['title'][$_LANGID])) {
             return false;
         }
     }
     list($startDate, $strStartTime) = explode(' ', $data['startDate']);
     list($startHour, $startMin) = explode(':', $strStartTime);
     list($endDate, $strEndTime) = explode(' ', $data['endDate']);
     list($endHour, $endMin) = explode(':', $strEndTime);
     if ($data['all_day']) {
         list($startHour, $startMin) = array(0, 0);
         list($endHour, $endMin) = array(23, 59);
     }
     //event data
     $id = isset($data['copy']) && !empty($data['copy']) ? 0 : (isset($data['id']) ? intval($data['id']) : 0);
     $type = isset($data['type']) ? intval($data['type']) : 0;
     $startDate = date("Y-m-d H:i:s", parent::getDateTimestamp($startDate, intval($startHour), intval($startMin)));
     $endDate = date("Y-m-d H:i:s", parent::getDateTimestamp($endDate, intval($endHour), intval($endMin)));
     $google = isset($data['map'][$_LANGID]) ? intval($data['map'][$_LANGID]) : 0;
     $allDay = isset($data['all_day']) ? 1 : 0;
     $convertBBCode = $objInit->mode == 'frontend' && empty($id);
     $useCustomDateDisplay = isset($data['showDateSettings']) ? 1 : 0;
     $showStartDateList = isset($data['showStartDateList']) ? $data['showStartDateList'] : 0;
     $showEndDateList = isset($data['showEndDateList']) ? $data['showEndDateList'] : 0;
     if ($objInit->mode == 'backend') {
         // reset time values if "no time" is selected
         if ($data['showTimeTypeList'] == 0) {
             $showStartTimeList = 0;
             $showEndTimeList = 0;
         } else {
             $showStartTimeList = isset($data['showStartTimeList']) ? $data['showStartTimeList'] : '';
             $showEndTimeList = isset($data['showEndTimeList']) ? $data['showEndTimeList'] : '';
         }
         $showTimeTypeList = isset($data['showTimeTypeList']) ? $data['showTimeTypeList'] : '';
         $showStartDateDetail = isset($data['showStartDateDetail']) ? $data['showStartDateDetail'] : '';
         $showEndDateDetail = isset($data['showEndDateDetail']) ? $data['showEndDateDetail'] : '';
         // reset time values if "no time" is selected
         if ($data['showTimeTypeDetail'] == 0) {
             $showStartTimeDetail = 0;
             $showEndTimeDetail = 0;
         } else {
             $showStartTimeDetail = isset($data['showStartTimeDetail']) ? $data['showStartTimeDetail'] : '';
             $showEndTimeDetail = isset($data['showEndTimeDetail']) ? $data['showEndTimeDetail'] : '';
         }
         $showTimeTypeDetail = isset($data['showTimeTypeDetail']) ? $data['showTimeTypeDetail'] : '';
     } else {
         $showStartDateList = $this->arrSettings['showStartDateList'] == 1 ? 1 : 0;
         $showEndDateList = $this->arrSettings['showEndDateList'] == 1 ? 1 : 0;
         $showStartTimeList = $this->arrSettings['showStartTimeList'] == 1 ? 1 : 0;
         $showEndTimeList = $this->arrSettings['showEndTimeList'] == 1 ? 1 : 0;
         // reset time values if "no time" is selected
         if ($showStartTimeList == 1 || $showEndTimeList == 1) {
             $showTimeTypeList = 1;
         } else {
             $showStartTimeList = 0;
             $showEndTimeList = 0;
             $showTimeTypeList = 0;
         }
         $showStartDateDetail = $this->arrSettings['showStartDateDetail'] == 1 ? 1 : 0;
         $showEndDateDetail = $this->arrSettings['showEndDateDetail'] == 1 ? 1 : 0;
         $showStartTimeDetail = $this->arrSettings['showStartTimeDetail'] == 1 ? 1 : 0;
         $showEndTimeDetail = $this->arrSettings['showEndTimeDetail'] == 1 ? 1 : 0;
         // reset time values if "no time" is selected
         if ($showStartTimeDetail == 1 || $showEndTimeDetail == 1) {
             $showTimeTypeDetail = 1;
         } else {
             $showStartTimeDetail = 0;
             $showEndTimeDetail = 0;
             $showTimeTypeDetail = 0;
         }
     }
     $access = isset($data['access']) ? intval($data['access']) : 0;
     $priority = isset($data['priority']) ? intval($data['priority']) : 0;
     $placeMediadir = isset($data['placeMediadir']) ? intval($data['placeMediadir']) : 0;
     $hostMediadir = isset($data['hostMediadir']) ? intval($data['hostMediadir']) : 0;
     $price = isset($data['price']) ? contrexx_addslashes(contrexx_strip_tags($data['price'])) : 0;
     $link = isset($data['link']) ? contrexx_addslashes(contrexx_strip_tags($data['link'])) : '';
     $pic = isset($data['picture']) ? contrexx_addslashes(contrexx_strip_tags($data['picture'])) : '';
     $attach = isset($data['attachment']) ? contrexx_addslashes(contrexx_strip_tags($data['attachment'])) : '';
     $catId = isset($data['category']) ? intval($data['category']) : '';
     $showIn = isset($data['showIn']) ? contrexx_addslashes(contrexx_strip_tags(join(",", $data['showIn']))) : '';
     $invited_groups = isset($data['selectedGroups']) ? join(',', $data['selectedGroups']) : '';
     $invited_mails = isset($data['invitedMails']) ? contrexx_addslashes(contrexx_strip_tags($data['invitedMails'])) : '';
     $send_invitation = isset($data['sendInvitation']) ? intval($data['sendInvitation']) : 0;
     $invitationTemplate = isset($data['invitationEmailTemplate']) ? contrexx_input2db($data['invitationEmailTemplate']) : 0;
     $registration = isset($data['registration']) ? intval($data['registration']) : 0;
     $registration_form = isset($data['registrationForm']) ? intval($data['registrationForm']) : 0;
     $registration_num = isset($data['numSubscriber']) ? intval($data['numSubscriber']) : 0;
     $registration_notification = isset($data['notificationTo']) ? contrexx_addslashes(contrexx_strip_tags($data['notificationTo'])) : '';
     $email_template = isset($data['emailTemplate']) ? contrexx_input2db($data['emailTemplate']) : 0;
     $ticket_sales = isset($data['ticketSales']) ? intval($data['ticketSales']) : 0;
     $num_seating = isset($data['numSeating']) ? json_encode(explode(',', $data['numSeating'])) : '';
     $related_hosts = isset($data['selectedHosts']) ? $data['selectedHosts'] : '';
     $locationType = isset($data['eventLocationType']) ? (int) $data['eventLocationType'] : $this->arrSettings['placeData'];
     $hostType = isset($data['eventHostType']) ? (int) $data['eventHostType'] : $this->arrSettings['placeDataHost'];
     $place = isset($data['place']) ? contrexx_input2db(contrexx_strip_tags($data['place'])) : '';
     $street = isset($data['street']) ? contrexx_input2db(contrexx_strip_tags($data['street'])) : '';
     $zip = isset($data['zip']) ? contrexx_input2db(contrexx_strip_tags($data['zip'])) : '';
     $city = isset($data['city']) ? contrexx_input2db(contrexx_strip_tags($data['city'])) : '';
     $country = isset($data['country']) ? contrexx_input2db(contrexx_strip_tags($data['country'])) : '';
     $placeLink = isset($data['placeLink']) ? contrexx_input2db($data['placeLink']) : '';
     $placeMap = isset($data['placeMap']) ? contrexx_input2db($data['placeMap']) : '';
     $update_invitation_sent = $send_invitation == 1;
     if (!empty($placeLink)) {
         if (!preg_match('%^(?:ftp|http|https):\\/\\/%', $placeLink)) {
             $placeLink = "http://" . $placeLink;
         }
     }
     if ($objInit->mode == 'frontend') {
         $unique_id = intval($_REQUEST[self::MAP_FIELD_KEY]);
         if (!empty($unique_id)) {
             $picture = $this->_handleUpload('mapUpload', $unique_id);
             if (!empty($picture)) {
                 $placeMap = $picture;
             }
         }
     }
     $orgName = isset($data['organizerName']) ? contrexx_input2db($data['organizerName']) : '';
     $orgStreet = isset($data['organizerStreet']) ? contrexx_input2db($data['organizerStreet']) : '';
     $orgZip = isset($data['organizerZip']) ? contrexx_input2db($data['organizerZip']) : '';
     $orgCity = isset($data['organizerCity']) ? contrexx_input2db($data['organizerCity']) : '';
     $orgCountry = isset($data['organizerCountry']) ? contrexx_input2db($data['organizerCountry']) : '';
     $orgLink = isset($data['organizerLink']) ? contrexx_input2db($data['organizerLink']) : '';
     $orgEmail = isset($data['organizerEmail']) ? contrexx_input2db($data['organizerEmail']) : '';
     if (!empty($orgLink)) {
         if (!preg_match('%^(?:ftp|http|https):\\/\\/%', $orgLink)) {
             $orgLink = "http://" . $orgLink;
         }
     }
     // create thumb if not exists
     if (!file_exists(\Env::get('cx')->getWebsitePath() . "{$placeMap}.thumb")) {
         $objImage = new \ImageManager();
         $objImage->_createThumb(dirname(\Env::get('cx')->getWebsitePath() . "{$placeMap}") . "/", '', basename($placeMap), 180);
     }
     //frontend picture upload & thumbnail creation
     if ($objInit->mode == 'frontend') {
         $unique_id = intval($_REQUEST[self::PICTURE_FIELD_KEY]);
         $attachmentUniqueId = intval($_REQUEST[self::ATTACHMENT_FIELD_KEY]);
         if (!empty($unique_id)) {
             $picture = $this->_handleUpload('pictureUpload', $unique_id);
             if (!empty($picture)) {
                 //delete thumb
                 if (file_exists("{$this->uploadImgPath}{$pic}.thumb")) {
                     \Cx\Lib\FileSystem\FileSystem::delete_file($this->uploadImgPath . "/.{$pic}.thumb");
                 }
                 //delete image
                 if (file_exists("{$this->uploadImgPath}{$pic}")) {
                     \Cx\Lib\FileSystem\FileSystem::delete_file($this->uploadImgPath . "/.{$pic}");
                 }
                 $pic = $picture;
             }
         }
         if (!empty($attachmentUniqueId)) {
             $attachment = $this->_handleUpload('attachmentUpload', $attachmentUniqueId);
             if ($attachment) {
                 //delete file
                 if (file_exists("{$this->uploadImgPath}{$attach}")) {
                     \Cx\Lib\FileSystem\FileSystem::delete_file($this->uploadImgPath . "/.{$attach}");
                 }
                 $attach = $attachment;
             }
         }
     } else {
         // create thumb if not exists
         if (!file_exists(\Env::get('cx')->getWebsitePath() . "{$pic}.thumb")) {
             $objImage = new \ImageManager();
             $objImage->_createThumb(dirname(\Env::get('cx')->getWebsitePath() . "{$pic}") . "/", '', basename($pic), 180);
         }
     }
     $seriesStatus = isset($data['seriesStatus']) ? intval($data['seriesStatus']) : 0;
     //series pattern
     $seriesStatus = isset($data['seriesStatus']) ? intval($data['seriesStatus']) : 0;
     $seriesType = isset($data['seriesType']) ? intval($data['seriesType']) : 0;
     $seriesPatternCount = 0;
     $seriesPatternWeekday = 0;
     $seriesPatternDay = 0;
     $seriesPatternWeek = 0;
     $seriesPatternMonth = 0;
     $seriesPatternType = 0;
     $seriesPatternDouranceType = 0;
     $seriesPatternEnd = 0;
     $seriesExeptions = '';
     $seriesPatternEndDate = 0;
     if ($seriesStatus == 1) {
         if (!empty($data['seriesExeptions'])) {
             $exeptions = array();
             foreach ($data['seriesExeptions'] as $key => $exeptionDate) {
                 $exeptions[] = date("Y-m-d", parent::getDateTimestamp($exeptionDate, 23, 59));
             }
             sort($exeptions);
             $seriesExeptions = join(",", $exeptions);
         }
         switch ($seriesType) {
             case 1:
                 if ($seriesStatus == 1) {
                     $seriesPatternType = isset($data['seriesDaily']) ? intval($data['seriesDaily']) : 0;
                     if ($seriesPatternType == 1) {
                         $seriesPatternWeekday = 0;
                         $seriesPatternDay = isset($data['seriesDailyDays']) ? intval($data['seriesDailyDays']) : 0;
                     } else {
                         $seriesPatternWeekday = "1111100";
                         $seriesPatternDay = 0;
                     }
                     $seriesPatternWeek = 0;
                     $seriesPatternMonth = 0;
                     $seriesPatternCount = 0;
                 }
                 break;
             case 2:
                 if ($seriesStatus == 1) {
                     $seriesPatternWeek = isset($data['seriesWeeklyWeeks']) ? intval($data['seriesWeeklyWeeks']) : 0;
                     for ($i = 1; $i <= 7; $i++) {
                         if (isset($data['seriesWeeklyDays'][$i])) {
                             $weekdayPattern .= "1";
                         } else {
                             $weekdayPattern .= "0";
                         }
                     }
                     $seriesPatternWeekday = $weekdayPattern;
                     $seriesPatternCount = 0;
                     $seriesPatternDay = 0;
                     $seriesPatternMonth = 0;
                     $seriesPatternType = 0;
                 }
                 break;
             case 3:
                 if ($seriesStatus == 1) {
                     $seriesPatternType = isset($data['seriesMonthly']) ? intval($data['seriesMonthly']) : 0;
                     if ($seriesPatternType == 1) {
                         $seriesPatternMonth = isset($data['seriesMonthlyMonth_1']) ? intval($data['seriesMonthlyMonth_1']) : 0;
                         $seriesPatternDay = isset($data['seriesMonthlyDay']) ? intval($data['seriesMonthlyDay']) : 0;
                         $seriesPatternWeekday = 0;
                     } else {
                         $seriesPatternCount = isset($data['seriesMonthlyDayCount']) ? intval($data['seriesMonthlyDayCount']) : 0;
                         $seriesPatternMonth = isset($data['seriesMonthlyMonth_2']) ? intval($data['seriesMonthlyMonth_2']) : 0;
                         if ($seriesPatternMonth < 1) {
                             // the increment must be at least once a month, otherwise we will end up in a endless loop in the presence
                             $seriesPatternMonth = 1;
                         }
                         $seriesPatternWeekday = isset($data['seriesMonthlyWeekday']) ? $data['seriesMonthlyWeekday'] : '';
                         $seriesPatternDay = 0;
                     }
                     $seriesPatternWeek = 0;
                 }
                 break;
         }
         $seriesPatternDouranceType = isset($data['seriesDouranceType']) ? intval($data['seriesDouranceType']) : 0;
         switch ($seriesPatternDouranceType) {
             case 1:
                 $seriesPatternEnd = 0;
                 break;
             case 2:
                 $seriesPatternEnd = isset($data['seriesDouranceEvents']) ? intval($data['seriesDouranceEvents']) : 0;
                 break;
             case 3:
                 $seriesPatternEndDate = date("Y-m-d H:i:s", parent::getDateTimestamp($data['seriesDouranceDate'], 23, 59));
                 break;
         }
     }
     $formData = array('type' => $type, 'startdate' => $startDate, 'enddate' => $endDate, 'use_custom_date_display' => $useCustomDateDisplay, 'showStartDateList' => $showStartDateList, 'showEndDateList' => $showEndDateList, 'showStartTimeList' => $showStartTimeList, 'showEndTimeList' => $showEndTimeList, 'showTimeTypeList' => $showTimeTypeList, 'showStartDateDetail' => $showStartDateDetail, 'showEndDateDetail' => $showEndDateDetail, 'showStartTimeDetail' => $showStartTimeDetail, 'showEndTimeDetail' => $showEndTimeDetail, 'showTimeTypeDetail' => $showTimeTypeDetail, 'google' => $google, 'access' => $access, 'priority' => $priority, 'price' => $price, 'link' => $link, 'pic' => $pic, 'catid' => $catId, 'attach' => $attach, 'place_mediadir_id' => $placeMediadir, 'host_mediadir_id' => $hostMediadir, 'show_in' => $showIn, 'invited_groups' => $invited_groups, 'invited_mails' => $invited_mails, 'invitation_email_template' => json_encode($invitationTemplate), 'registration' => $registration, 'registration_form' => $registration_form, 'registration_num' => $registration_num, 'registration_notification' => $registration_notification, 'email_template' => json_encode($email_template), 'ticket_sales' => $ticket_sales, 'num_seating' => $num_seating, 'series_status' => $seriesStatus, 'series_type' => $seriesType, 'series_pattern_count' => $seriesPatternCount, 'series_pattern_weekday' => $seriesPatternWeekday, 'series_pattern_day' => $seriesPatternDay, 'series_pattern_week' => $seriesPatternWeek, 'series_pattern_month' => $seriesPatternMonth, 'series_pattern_type' => $seriesPatternType, 'series_pattern_dourance_type' => $seriesPatternDouranceType, 'series_pattern_end' => $seriesPatternEnd, 'series_pattern_end_date' => $seriesPatternEndDate, 'series_pattern_exceptions' => $seriesExeptions, 'all_day' => $allDay, 'location_type' => $locationType, 'host_type' => $hostType, 'place' => $place, 'place_id' => 0, 'place_street' => $street, 'place_zip' => $zip, 'place_city' => $city, 'place_country' => $country, 'place_link' => $placeLink, 'place_map' => $placeMap, 'org_name' => $orgName, 'org_street' => $orgStreet, 'org_zip' => $orgZip, 'org_city' => $orgCity, 'org_country' => $orgCountry, 'org_link' => $orgLink, 'org_email' => $orgEmail, 'invitation_sent' => $update_invitation_sent ? 1 : 0);
     if ($id != 0) {
         $query = \SQL::update("module_{$this->moduleTablePrefix}_event", $formData) . " WHERE id = '{$id}'";
         $objResult = $objDatabase->Execute($query);
         if ($objResult !== false) {
             $this->id = $id;
             $query = "DELETE FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_event_field\n                                WHERE event_id = '" . $id . "'";
             $objResult = $objDatabase->Execute($query);
             $query = "DELETE FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_event_host\n                                WHERE event_id = '" . $id . "'";
             $objResult = $objDatabase->Execute($query);
         } else {
             return false;
         }
     } else {
         $objFWUser = \FWUser::getFWUserObject();
         $objUser = $objFWUser->objUser;
         if ($objInit->mode == 'frontend') {
             $status = 1;
             $confirmed = $this->arrSettings['confirmFrontendEvents'] == 1 ? 0 : 1;
             $author = $objUser->login() ? intval($objUser->getId()) : 0;
         } else {
             $status = 0;
             $confirmed = 1;
             $author = intval($objUser->getId());
         }
         $formData['status'] = $status;
         $formData['confirmed'] = $confirmed;
         $formData['author'] = $author;
         $query = \SQL::insert("module_{$this->moduleTablePrefix}_event", $formData);
         $objResult = $objDatabase->Execute($query);
         if ($objResult !== false) {
             $id = intval($objDatabase->Insert_ID());
             $this->id = $id;
         } else {
             return false;
         }
     }
     if ($id != 0) {
         foreach ($data['showIn'] as $key => $langId) {
             $title = contrexx_addslashes(contrexx_strip_tags($data['title'][$langId]));
             $description = contrexx_addslashes($data['description'][$langId]);
             if ($convertBBCode) {
                 $description = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForDb($data['description'][$langId], true);
             }
             $redirect = contrexx_addslashes($data['calendar-redirect'][$langId]);
             if ($type == 0) {
                 $redirect = '';
             } else {
                 $description = '';
             }
             $query = "INSERT INTO " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_event_field\n                            (`event_id`,`lang_id`,`title`, `description`,`redirect`)\n                          VALUES\n                            ('" . intval($id) . "','" . intval($langId) . "','" . $title . "','" . $description . "','" . $redirect . "')";
             $objResult = $objDatabase->Execute($query);
             if ($objResult === false) {
                 return false;
             }
         }
         if (!empty($related_hosts)) {
             foreach ($related_hosts as $key => $hostId) {
                 $query = "INSERT INTO " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_event_host\n                                      (`host_id`,`event_id`) \n                               VALUES ('" . intval($hostId) . "','" . intval($id) . "')";
                 $objResult = $objDatabase->Execute($query);
             }
         }
     }
     if ($send_invitation == 1) {
         $objMailManager = new \Cx\Modules\Calendar\Controller\CalendarMailManager();
         foreach ($invitationTemplate as $templateId) {
             $objMailManager->sendMail(intval($id), \Cx\Modules\Calendar\Controller\CalendarMailManager::MAIL_INVITATION, null, $templateId);
         }
     }
     return true;
 }
コード例 #2
0
ファイル: U2u.class.php プロジェクト: Cloudrexx/cloudrexx
 /**
  * Inserts the Messages into the Databases.
  * Performs the Validations..
  *
  * @global   $_ARRAYLANG  $objDatabase $_CORELANG
  */
 function insertMessages()
 {
     global $_ARRAYLANG, $objDatabase, $_CORELANG, $_CONFIG;
     if (!isset($_REQUEST['private_message'])) {
         return false;
     }
     $errArray = array();
     $_REQUEST['private_message'] = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForDb($_REQUEST['private_message']);
     $this->strMessages = $_REQUEST['private_message'];
     /**
      * For display the preview***
      */
     if ($_REQUEST['rcpt_name'] != "") {
         $recpName = $_REQUEST['rcpt_name'];
     } else {
         $recpName = $_REQUEST['recipients'];
     }
     if ($_REQUEST['preview'] != "") {
         $this->_objTpl->setVariable(array('TXT_U2U_PREVIEW_MESSAGE' => $_ARRAYLANG['TXT_U2U_PREVIEW_MESSAGE'], 'TXT_U2U_PREVIEW_HEADER' => $_REQUEST['title'], 'TXT_U2U_PREVIEW_SUBJECT' => \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForOutput($_REQUEST['private_message']), 'TXT_U2U_PREVIEW_WEBSITE' => '', 'TXT_RECEPIENT' => $recpName, 'TXT_PRIVATE_MESSAGE_TITLE' => $_REQUEST['title'], 'TXT_BCC' => $_REQUEST['bcc']));
         $this->showEntries();
     } else {
         $this->_objTpl->hideBlock('u2u_preview_message');
         $objFWUser = \FWUser::getFWUserObject();
         $arrayRecepient = $this->arrayMerge();
         $arrayRecepients = array_unique($arrayRecepient);
         $Private_Message = $_REQUEST['private_message'];
         $settingMaxChars = $this->_getMaxCharDetails();
         $max_chars = $settingMaxChars['max_posting_chars'];
         $db_settings_max_postings = $this->_getMaxPostingDetails();
         $db_settings_max_postings_value = $db_settings_max_postings['max_posting_size'];
         $Posters_id = $objFWUser->objUser->getId();
         $settingMaxPosting = $this->_getMaxpostings($Posters_id);
         $statusU2UActive = $this->_getStatus($objFWUser->objUser->getId());
         if (count($arrayRecepients) > 10) {
             $this->arrStatusMsg['error'][] = $_ARRAYLANG['TXT_U2U_RECEPIENTS_EXCEED_ERROR'];
             $errorMessage = true;
         } elseif ($settingMaxPosting >= $db_settings_max_postings_value) {
             $this->arrStatusMsg['error'][] = $_ARRAYLANG['TXT_MAX_POSTING_SIZE_EXCEEDS'];
             //$_ARRAYLANG['TXT_U2U_ENTRY_ADD_ERROR_TITLE'];
             $this->_objTpl->setVariable(array('TXT_RECEPIENT' => $recpName, 'TXT_BCC' => $_REQUEST['bcc'], 'TXT_PRIVATE_MESSAGE_TITLE' => $_REQUEST['title']));
             $errorMessage = true;
         } elseif (empty($_REQUEST['title'])) {
             $this->arrStatusMsg['error'][] = $_ARRAYLANG['TXT_U2U_ENTRY_ADD_ERROR_TITLE'];
             $this->_objTpl->setVariable(array('TXT_RECEPIENT' => $recpName, 'TXT_BCC' => $_REQUEST['bcc']));
             $errorMessage = true;
         } elseif (empty($Private_Message)) {
             $this->arrStatusMsg['error'][] = $_ARRAYLANG['TXT_U2U_ENTRY_ADD_ERROR_MESSAGE'];
             $this->_objTpl->setVariable(array('TXT_RECEPIENT' => $recpName, 'TXT_BCC' => $_REQUEST['bcc'], 'TXT_PRIVATE_MESSAGE_TITLE' => $_REQUEST['title']));
             $errorMessage = true;
         } elseif (strlen($Private_Message) >= $max_chars) {
             $this->arrStatusMsg['error'][] = $_ARRAYLANG['TXT_PRIVATE_EXCEEDED'] . $max_chars;
             //$_ARRAYLANG['TXT_U2U_ENTRY_ADD_ERROR_MESSAGE'];
             $this->_objTpl->setVariable(array('TXT_RECEPIENT' => $recpName, 'TXT_BCC' => $_REQUEST['bcc'], 'TXT_PRIVATE_MESSAGE_TITLE' => $_REQUEST['title']));
             $errorMessage = true;
         } elseif (count($arrayRecepients) == 0) {
             $this->arrStatusMsg['error'][] = $_ARRAYLANG['TXT_PLS_ENTER_USERNAME'];
             //$_ARRAYLANG['TXT_PRIVATE_EXCEEDED'].$max_chars;//$_ARRAYLANG['TXT_U2U_ENTRY_ADD_ERROR_MESSAGE'];
             $this->_objTpl->setVariable(array('TXT_PRIVATE_MESSAGE_TITLE' => $_REQUEST['title']));
             $errorMessage = true;
         } else {
             foreach ($arrayRecepients as $user) {
                 $ID = $this->getUserID($user);
                 if (empty($ID)) {
                     $errorString = str_replace("[userName]", $user, $_ARRAYLANG['TXT_U2U_ENTRY_ADD_ERROR_EMAIL']);
                     $this->arrStatusMsg['error'][] = $errorString;
                     $errorMessage = true;
                 } elseif ($statusU2UActive == 0) {
                     $errorString = str_replace("[userName]", $user, $_ARRAYLANG['TXT_U2U_STATUS_DISABLED_ERROR']);
                     $this->arrStatusMsg['error'][] = $errorString;
                     $errorMessage = true;
                 } else {
                     $errArray[0]['receipents_userid'] = $ID;
                     $errArray[0]['sending_userid'] = $objFWUser->objUser->getId();
                     $errArray[0]['title'] = contrexx_addslashes(strip_tags(trim(htmlentities($_REQUEST['title'], ENT_QUOTES, CONTREXX_CHARSET))));
                     $errArray[0]['private_message'] = $_REQUEST['private_message'];
                     $this->insertEntryDataMessage($errArray);
                     $this->arrStatusMsg['ok'][] = $_ARRAYLANG['TXT_U2U_ENTRY_ADD_SUCCESS_MESSAGE'];
                     $successVar = 1;
                     $this->strMessages = "";
                     //Send notification to users
                     $this->sendNotificationMail($objFWUser->objUser->getId(), $ID);
                 }
             }
         }
         if ($errorMessage == true) {
             $this->_objTpl->setVariable('U2U_SEND_MESSAGE', implode('<br />', $this->arrStatusMsg['error']));
             $this->_objTpl->parse('u2u_send_confirm_error');
         }
         if ($successVar == 1) {
             $this->_objTpl->setVariable('U2U_SEND_MESSAGE', $_ARRAYLANG['TXT_U2U_ENTRY_ADD_SUCCESS_MESSAGE']);
             $this->_objTpl->parse('u2u_send_confirm_success');
         }
         // $this->_objTpl->hideBlock('u2u_send_confirm_error');
         $this->showEntries();
     }
 }
コード例 #3
0
ファイル: News.class.php プロジェクト: nahakiole/cloudrexx
 /**
  * Insert new locales after submit news from frontend
  * @global ADONewConnection
  * @param Integer   $newsId
  * @param String    $title
  * @param String    $text
  * @param String    $teaser_text
  * @return Boolean
  */
 private function storeLocalesOfSubmittedNewsMessage($newsId, $title, $text, $teaser_text)
 {
     global $objDatabase;
     if (empty($newsId)) {
         return false;
     }
     $status = true;
     $arrActiveFrontendLanguages = array_keys(\FWLanguage::getActiveFrontendLanguages());
     foreach ($arrActiveFrontendLanguages as $langId) {
         $query = "INSERT INTO " . DBPREFIX . "module_news_locale (`lang_id`, `news_id`, `title`, `text`, `teaser_text`)\n                VALUES (" . intval($langId) . ", " . intval($newsId) . ", '" . contrexx_raw2db($title) . "', '" . \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForDb($text, true) . "', '" . contrexx_raw2db($teaser_text) . "')";
         if (!$objDatabase->Execute($query)) {
             $status = false;
         }
     }
     return $status;
 }
コード例 #4
0
ファイル: Blog.class.php プロジェクト: Cloudrexx/cloudrexx
 /**
  * Insert a new comment for a message into database, if the function is activated. Furthermore, all input values are validated.
  * Sends also the notification mail to the administrator, if it is enabled in options.
  *
  * @global  ADONewConnection
  * @global  array
  * @global  array
  */
 function addComment()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     \Cx\Core\Csrf\Controller\Csrf::check_code();
     $this->initUserId();
     //Check for activated function
     if (!$this->_arrSettings['blog_comments_activated']) {
         $this->_strErrorMessage = $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_ERROR_ACTIVATED'];
         return;
     }
     if ($this->hasUserJustCommented()) {
         $this->_strErrorMessage = str_replace('[SECONDS]', intval($this->_arrSettings['blog_comments_timeout']), $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_ERROR_TIMEOUT']);
         return;
     }
     //Create validator-object
     $objValidator = new \FWValidator();
     //Get general-input
     $intMessageId = intval($_POST['frmAddComment_MessageId']);
     $strSubject = contrexx_addslashes(strip_tags($_POST['frmAddComment_Subject']));
     $strComment = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForDb($_POST['frmAddComment_Comment']);
     //Get specified-input
     if ($this->_intCurrentUserId == 0) {
         $intUserId = 0;
         $strName = contrexx_addslashes(strip_tags($_POST['frmAddComment_Name']));
         $strEMail = contrexx_addslashes(strip_tags($_POST['frmAddComment_EMail']));
         $strWWW = contrexx_addslashes(strip_tags($objValidator->getUrl($_POST['frmAddComment_WWW'])));
     } else {
         $intUserId = $this->_intCurrentUserId;
         $strName = '';
         $strEMail = '';
         $strWWW = '';
     }
     //Get options
     $intIsActive = intval($this->_arrSettings['blog_comments_autoactivate']);
     $intIsNotification = intval($this->_arrSettings['blog_comments_notification']);
     //Validate general-input
     if ($intMessageId <= 0) {
         $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_MID']);
     }
     if (empty($strSubject)) {
         $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_SUBJECT']);
     }
     if (empty($strComment)) {
         $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_COMMENT']);
     }
     //Validate specified-input
     if ($this->_intCurrentUserId == 0) {
         if (empty($strName)) {
             $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_NAME']);
         }
         if (!$objValidator->isEmail($strEMail)) {
             $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_EMAIL']);
         }
     }
     $captchaCheck = true;
     if (!\FWUser::getFWUserObject()->objUser->login() && !\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
         $captchaCheck = false;
     }
     //Now check error-string
     if (empty($this->_strErrorMessage) && $captchaCheck) {
         //No errors, insert entry
         $objDatabase->Execute(' INSERT INTO ' . DBPREFIX . 'module_blog_comments
                                 SET     message_id = ' . $intMessageId . ',
                                         lang_id = ' . $this->_intLanguageId . ',
                                         is_active = "' . $intIsActive . '",
                                         time_created = ' . time() . ',
                                         ip_address = "' . $_SERVER['REMOTE_ADDR'] . '",
                                         user_id = ' . $intUserId . ',
                                         user_name = "' . $strName . '",
                                         user_mail = "' . $strEMail . '",
                                         user_www = "' . $strWWW . '",
                                         subject = "' . $strSubject . '",
                                         comment = "' . $strComment . '"
                             ');
         //Set a cookie with the current timestamp. Avoids flooding.
         setcookie('BlogCommentLast', time(), 0, ASCMS_PATH_OFFSET . '/');
         $this->_strStatusMessage = $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_SUCCESS'];
         $this->writeCommentRSS();
         if ($intIsNotification) {
             //Send notification to administrator
             if (\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
                 $objMail = new \phpmailer();
                 if ($_CONFIG['coreSmtpServer'] > 0) {
                     if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                         $objMail->IsSMTP();
                         $objMail->Host = $arrSmtp['hostname'];
                         $objMail->Port = $arrSmtp['port'];
                         $objMail->SMTPAuth = true;
                         $objMail->Username = $arrSmtp['username'];
                         $objMail->Password = $arrSmtp['password'];
                     }
                 }
                 if ($this->_intCurrentUserId > 0) {
                     $objFWUser = \FWUser::getFWUserObject();
                     $strName = htmlentities($objFWUser->objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET);
                 }
                 $strMailSubject = str_replace('[SUBJECT]', $strSubject, $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_MAIL_SUBJECT']);
                 $strMailBody = str_replace('[USERNAME]', $strName, $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_MAIL_BODY']);
                 $strMailBody = str_replace('[DOMAIN]', ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET, $strMailBody);
                 $strMailBody = str_replace('[SUBJECT]', $strSubject, $strMailBody);
                 $strMailBody = str_replace('[COMMENT]', $strComment, $strMailBody);
                 $objMail->CharSet = CONTREXX_CHARSET;
                 $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']);
                 $objMail->AddAddress($_CONFIG['coreAdminEmail']);
                 $objMail->Subject = $strMailSubject;
                 $objMail->IsHTML(false);
                 $objMail->Body = $strMailBody;
                 $objMail->Send();
             }
         }
     }
 }