public function execute() { if (!SJB_Settings::getValue('cookieLaw')) { return; } $template = SJB_Request::getVar('template', 'cookie_preferences.tpl'); $tp = SJB_System::getTemplateProcessor(); $mobileTheme = false; if (class_exists('MobilePlugin') && MobilePlugin::isMobileThemeOn()) { $this->processingMobileVersion($tp); $mobileTheme = true; } $showCookiePreferences = false; $cookiePreferences = SJB_Request::getVar('cookiePreferences', false, 'COOKIE'); if (!$cookiePreferences) { $showCookiePreferences = true; $_COOKIE['cookiePreferences'] = 'Advertising'; setcookie('cookiePreferences', 'Advertising', time() + 30 * 24 * 3600, '/'); } else { if (($cookiePreferences != 'Advertising' || $mobileTheme) && !SJB_Session::getValue('cookiePreferencesAlreadyShown')) { $showCookiePreferences = true; } } $tp->assign('action', SJB_Array::get($this->params, 'action', 'view')); $tp->assign('showCookiePreferences', $showCookiePreferences); $tp->display($template); if (!SJB_Session::getValue('cookiePreferencesAlreadyShown')) { SJB_Session::setValue('cookiePreferencesAlreadyShown', true); } }
/** * @param array $data * @throws Exception */ private function setType($data) { $this->type = (string) SJB_Array::get($data, 'type'); if (!$this->type) { throw new Exception('Builder type is required'); } }
/** * @param int $listingSID * @return bool */ public function postListing($listingSID) { $linkedIn = new SJB_LinkedIn(); $linkedIn->_getAccessToken(unserialize($this->feedInfo['access_token'])); $listing = SJB_ListingManager::getObjectBySID($listingSID); if (!$listing instanceof SJB_Listing) { $params = array($listingSID); $message = 'Listing #$param_0 does not exist in system'; throw new SJB_FeedException($message, $params); } $listingStructure = SJB_ListingManager::createTemplateStructureForListing($listing); $link = SJB_ListingManager::getListingUrlBySID($listingSID); $userInfo = SJB_Array::get($listingStructure, 'user'); $this->tp->assign('post_template', $this->feedInfo['post_template']); $this->tp->assign('listing', $listingStructure); $this->tp->assign('user', $userInfo); $title = $this->tp->fetch($this->template); if ($this->feedInfo['post_to_updates']) { $post['content'] = self::getContentToPostToUpdates($title, $listingStructure['Title'], $link, $userInfo['Logo']['file_url']); $linkedIn->postToUpdates($post); } if (!empty($this->feedInfo['post_to_groups']) && !empty($this->feedInfo['groups'])) { $post['content'] = self::getContentToPostToGroup($title, $listingStructure['Title'], $link, $userInfo['Logo']['file_url']); $post['groups'] = explode(',', $this->feedInfo['groups']); $linkedIn->postToGroups($post); } return true; }
public function execute() { if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $etSID = SJB_Array::get($passed_parameters_via_uri, 0); } $field_id = SJB_Request::getVar('field_id', null); $etInfo = SJB_EmailTemplateEditor::getEmailTemplateInfoBySID($etSID); if (is_null($etSID) || is_null($field_id)) { $errors['PARAMETERS_MISSED'] = 1; } elseif (is_null($etInfo) || !isset($etInfo[$field_id])) { $errors['WRONG_PARAMETERS_SPECIFIED'] = 1; } else { $uploaded_file_id = $etInfo[$field_id]; SJB_UploadFileManager::deleteUploadedFileByID($uploaded_file_id); $etInfo[$field_id] = ''; $emailTemplate = new SJB_EmailTemplate($etInfo); $emailTemplate->setSID($etSID); SJB_EmailTemplateEditor::saveEmailTemplate($emailTemplate); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-email-templates/' . $emailTemplate->getPropertyValue('group') . '/' . $etSID); } $tp = SJB_System::getTemplateProcessor(); $tp->assign('errors', isset($errors) ? $errors : null); $tp->display('delete_uploaded_file.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $listing_field_sid = SJB_Request::getVar('listing_sid', null); $errors = array(); $listingTypes = array(); if (!is_null($listing_field_sid)) { $listing_field = SJB_ListingFieldManager::getFieldInfoBySID($listing_field_sid); $listing_type_id = 'Job/Resume'; if ($listing_field['listing_type_sid'] != 0) { $listing_type_id = SJB_ListingTypeManager::getListingTypeIDBySID($listing_field['listing_type_sid']); array_push($listingTypes, SJB_ListingTypeManager::getListingTypeInfoBySID(SJB_Array::get($listing_field, 'listing_type_sid'))); } else { $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo(); } $tp->assign('listingTypesInfo', $listingTypes); $tp->assign('listing_type_id', $listing_type_id); $tp->assign('listing_sid', $listing_field_sid); $tp->assign('listing_field_info', $listing_field); $tp->assign('listing_type_sid', $listing_field['listing_type_sid']); } else { $errors[] = 'The system cannot proceed as Listing SID is not set'; } $tp->assign('errors', $errors); $tp->display('attention_listing_type_field.tpl'); }
/** * @param string $key * @return array * @throws Exception */ public static function getGuestAlertInfoFromKey($key) { $dataFromKey = SJB_GuestAlert::getDataFromKey($key); if (!SJB_Array::get($dataFromKey, 'sid') || !SJB_Array::get($dataFromKey, 'key')) { throw new Exception('PARAMETERS_MISSED'); } return $dataFromKey; }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $subAdminSID = SJB_Request::getVar('subadmin', 0); if (!empty($subAdminSID) && ($adminInfo = SJB_SubAdminManager::getSubAdminInfoBySID($subAdminSID))) { $editedSubAdminInfo = $_REQUEST; $subAdminInfo = array_merge($adminInfo, $editedSubAdminInfo); // create subAdmin object $oSubAdmin = SJB_ObjectMother::createSubAdmin($subAdminInfo); $oSubAdmin->setSID($adminInfo['sid']); $oSubAdmin->makePropertyNotRequired("password"); // permissions $acl = SJB_SubAdminAcl::getInstance(); $type = 'subadmin'; $resources = $acl->getResources(); $perms = SJB_SubAdminAcl::getAllPermissions($type, $oSubAdmin->getSID()); // /permissions SJB_SubAdminAcl::mergePermissionsWithResources($resources, $perms); $registration_form = SJB_ObjectMother::createForm($oSubAdmin); $action = SJB_Request::getVar('action', ''); $registration_form->registerTags($tp); $errors = array(); if ('save' == $action || $action == 'apply') { if ($adminInfo['username'] == $subAdminInfo['username']) { $oSubAdmin->deleteProperty('username'); } if ($adminInfo['email'] == $subAdminInfo['email']) { $oSubAdmin->deleteProperty('email'); } if ($registration_form->isDataValid($errors)) { $password_value = $oSubAdmin->getPropertyValue('password'); if (empty($password_value['original'])) { $oSubAdmin->deleteProperty('password'); } // save subAdmin SJB_SubAdminManager::saveSubAdmin($oSubAdmin); $role = $oSubAdmin->getSID(); SJB_Acl::clearPermissions($type, $role); foreach ($resources as $name => $resource) { SJB_SubAdminAcl::allow($name, $type, $role, SJB_SubAdminAcl::definePermission($name), SJB_Array::get($resource, 'params', '')); } SJB_FlashMessages::getInstance()->addMessage('CHANGES_SAVED'); if ($action == 'save') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-subadmins/"); } } SJB_SubAdminAcl::mergePermissionsWithRequest($resources); } SJB_SubAdminAcl::prepareSubPermissions($resources); $tp->assign("errors", $errors); $tp->assign("form_fields", $registration_form->getFormFieldsInfo()); $tp->assign('groups', SJB_SubAdminAcl::getPermissionGroups()); $tp->assign('resources', $resources); $tp->assign('type', $type); $tp->assign('sid', $subAdminInfo['sid']); $tp->display('add_subadmin.tpl'); } }
public function isAccessible() { $listingTypeID = SJB_Array::get($this->params, 'listing_type_id'); if ($listingTypeID) { $permissionLabel = 'view_' . strtolower($listingTypeID) . '_search_results'; $this->setPermissionLabel($permissionLabel); } return parent::isAccessible() && SJB_System::isUserAccessThisPage(); }
/** * prepare notifications for frontend */ private function retrieveUserSideNotifications() { $this->userSideNotifications = array(); foreach ($this->getNotifications() as $groupID => $notifications) { foreach ($notifications as $notificationID => $notificationData) { if (SJB_Array::get($notificationData, self::LABEL_CONFIGURABLE_FOR_USER) > 0) { $this->userSideNotifications[$groupID][$notificationID] = $notificationData; } } } }
public function __call($name, $arguments) { $value = ''; $aParams = explode('_', $name); $method = array_shift($aParams); if ('get' == $method) { $returnType = SJB_Array::get($arguments, 0); $fieldType = SJB_Array::get($arguments, 1); $listingFieldID = SJB_Array::get($arguments, 2); $value = null; switch ($returnType) { case 'array': case 'string': case 'int': $type = '(' . $returnType . ')'; break; default: $type = '(string)'; break; } $val = '$this->oProfile->' . implode('->', array_map('strtolower', $aParams)); $exec = 'return (!empty(' . $val . ')) ? ' . $type . $val . ': \'\';'; switch ($fieldType) { case 'tree': $exec = 'return (!empty(' . $val . ')) ? ' . $type . $val . ': \'\';'; $value = eval($exec); if (is_array($value)) { if (isset($value[0])) { $value = $value[0]; } } $value = $this->getTreeValues($value, $listingFieldID); break; case 'array': $listingFieldSID = SJB_ListingFieldManager::getListingFieldSIDByID($listingFieldID); if (!empty($listingFieldSID)) { $exec = 'return (!empty(' . $val . ')) ? ' . $val . ': \'\';'; $value = eval($exec); $value = SJB_ListingFieldManager::getListItemSIDByValue($value, $listingFieldSID); $value = eval('return ' . $type . ' $value;'); } break; default: $value = eval($exec); break; } } return $value; }
public function getDetails() { $notificationGroupsSet = $this->notificationGroups->getNotifications(); $notifications = array(); foreach ($notificationGroupsSet as $groupID => $groupNotifications) { foreach ($groupNotifications as $notificationID => &$notificationInfo) { if (SJB_Array::get($notificationInfo, SJB_NotificationGroups::LABEL_CONFIGURABLE_FOR_USER) < 1) { unset($groupNotifications[$notificationID]); } $this->prepareNotification($notificationInfo, $groupID); } $notifications = array_merge($notifications, $groupNotifications); } return $notifications; }
/** * @return array */ public function getEnabledForGroupUserNotifications() { $userGroupNotificationsInfo = $this->getUserGroupNotificationsInfo(); $availableUserNotifications = $this->getNotificationGroups()->getUserSideNotifications(); $enabledUserNotifications = array(); foreach ($availableUserNotifications as $notificationGroupID => $notificationGroups) { foreach ($notificationGroups as $notificationID => $notificationInfo) { $userGroupNotificationValue = SJB_Array::get($userGroupNotificationsInfo, $notificationID); if (!empty($userGroupNotificationValue)) { $notificationInfo['group_value'] = $userGroupNotificationValue; $enabledUserNotifications[$notificationGroupID][$notificationID] = $notificationInfo; } } } return $enabledUserNotifications; }
/** * @return bool */ public function isAccessible() { $listingTypeID = SJB_Array::get($this->params, 'listing_type_id'); if ($listingTypeID) { $permissionLabel = 'open_' . strtolower($listingTypeID) . '_search_form'; $this->setPermissionLabel($permissionLabel); $form_template = SJB_Array::get($this->params, 'form_template'); if ($listingTypeID === 'Job') { if (!parent::isAccessible() && !isset($form_template) && !SJB_System::isUserAccessThisPage()) { return false; } elseif ($form_template == 'quick_search.tpl') { return true; } } } return parent::isAccessible() && SJB_System::isUserAccessThisPage(); }
/** * @param $listingSID * @return mixed * @throws Exception */ public function postListing($listingSID) { $listing = SJB_ListingManager::getObjectBySID($listingSID); if (!$listing instanceof SJB_Listing) { $params = array($listingSID); $message = 'Listing #$param_0 does not exist in system'; throw new SJB_FeedException($message, $params); } $listingInfo = SJB_ListingManager::createTemplateStructureForListing($listing); $listingUrl = SJB_ListingManager::getListingUrlBySID($listingSID); $link = " {$listingUrl} {$this->feedInfo['hash_tags']}"; $userInfo = SJB_Array::get($listingInfo, 'user'); $this->tp->assign('post_template', $this->feedInfo['post_template']); $this->tp->assign('listing', $listingInfo); $this->tp->assign('user', $userInfo); $text = $this->tp->fetch($this->template); $picture = $userInfo['Logo']['file_url'] == null ? SJB_System::getSystemSettings('SITE_URL') . '/' . SJB_TemplatePathManager::getAbsoluteImagePath(SJB_TemplateSupplier::getUserCurrentTheme(), 'main', 'logo.png') : $userInfo['Logo']['file_url']; return $this->postToWall($listingSID, $text . $link, $listingUrl, $picture); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $action = null; if (SJB_UserManager::isUserLoggedIn()) { $userSID = SJB_UserManager::getCurrentUserSID(); $contactSID = 0; $errors = array(); if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $contactSID = SJB_Array::get($passed_parameters_via_uri, 0); } if (!$contactSID) { $errors['UNDEFINED_CONTACT_ID'] = 1; } else { $contactInfo = SJB_PrivateMessage::getContactInfo($userSID, $contactSID); if (!$contactInfo) { $errors['WRONG_CONTACT_ID_SPECIFIED'] = 1; } else { $action = SJB_Request::getVar('action'); switch ($action) { case 'save': $note = SJB_Request::getVar('note'); $result = SJB_PrivateMessage::saveContactNote($userSID, $contactSID, $note); if ($result) { $tp->assign('noteSaved', true); } break; default: break; } } $tp->assign('contactInfo', $contactInfo); } $tp->assign('errors', $errors); } if ($action) { $tp->assign('action', $action); $tp->display('notes.tpl'); } else { $tp->display('contact.tpl'); } }
function getPropertyVariablesToAssign() { $propertyVariables = parent::getPropertyVariablesToAssign(); $profileFieldAsDv = SJB_Array::get($propertyVariables, 'profile_field_as_dv'); if ($profileFieldAsDv && !isset($this->property_info['parentID'])) { $fieldValue = SJB_UserProfileFieldManager::getListItemValueBySID($profileFieldAsDv); if ($fieldValue) { $listingListItemSID = SJB_ListingFieldManager::getListItemSIDByValue($fieldValue, SJB_Array::get($this->property_info, 'sid')); $propertyVariables['profile_field_as_dv'] = $listingListItemSID; } } $defaultValue = SJB_Array::get($propertyVariables, 'default_value'); if ($defaultValue == 'default_country') { $propertyVariables['default_value'] = SJB_Settings::getSettingByName('default_country'); } $propertyVariables['hidden'] = $this->property_info['hidden']; $newPropertyVariables = array('list_values' => $this->list_values, 'caption' => $this->property_info['caption'], 'sort_by_alphabet' => $this->property_info['sort_by_alphabet']); return array_merge($newPropertyVariables, $propertyVariables); }
/** * Check 'sort_by_alphabet' flag for field, and sort values if needed * * @param $values */ private function getSortedValues($values) { $fieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($this->field['sid']); if (SJB_Array::get($fieldInfo, 'sort_by_alphabet') > 0) { $i18n = SJB_I18N::getInstance(); // translate captions to current language $translates = array(); foreach ($values as $value) { $translates[] = $i18n->gettext('', $value); } // we need to recover keys for $values after array_multisort $keys = array_keys($values); // sort $keys and $values order by $translates sort array_multisort($translates, SORT_STRING, $keys, $values); // restore keys for $values $values = array_combine($keys, $values); } return $values; }
/** * @return bool */ private function isCaptchaEnable() { $isCaptcha = false; if (SJB_PluginManager::isPluginActive('CaptchaPlugin') && SJB_Session::getValue('CURRENT_THEME') != 'mobile') { $userType = SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') != SJB_System::getSystemSettings('ADMIN_ACCESS_TYPE') ? 'user' : 'admin'; $captchaSettingName = ''; if (!($currentFunction = SJB_Request::getVar('currentFunction'))) { $currentFunction = SJB_Array::get(SJB_System::getModuleManager()->getCurrentFunction(), 1); } switch ($currentFunction) { case 'apply_now': $captchaSettingName = 'contactUserCaptcha'; break; case 'flag_listing': $captchaSettingName = 'flagListingCaptcha'; break; case 'tell_friend': $captchaSettingName = 'tellFriendCaptcha'; break; case 'contact_form': $captchaSettingName = 'contactUsCaptcha'; break; default: if (SJB_System::getSettingByName('captcha_max_allowed_auth_attempts') != 0) { if (SJB_Session::getValue($userType . 'LoginCounter') >= SJB_System::getSettingByName('captcha_max_allowed_auth_attempts')) { $isCaptcha = true; if (SJB_Session::getValue($userType . 'LoginCounter') == SJB_System::getSettingByName('captcha_max_allowed_auth_attempts')) { SJB_Session::setValue($userType . 'LoginCounter', SJB_Session::getValue($userType . 'LoginCounter') + 1); $this->isNotValidate = true; } } } } if (!$isCaptcha) { $isCaptcha = SJB_System::getSettingByName($captchaSettingName) == 1; } } return $isCaptcha; }
function getPropertyVariablesToAssign() { $propertyVariables = parent::getPropertyVariablesToAssign(); $propertyVariables['choiceLimit'] = SJB_Array::get($this->property_info, 'choiceLimit'); $displayListValues = array(); $listValues = array(); foreach ($this->list_values as $key => $list_values) { $displayListValues[$list_values['id']] = $list_values['caption']; $listValues[$key]['id'] = $list_values['id']; $listValues[$key]['caption'] = $list_values['caption']; } $arrValues = array('value' => $this->property_info['value'], 'default_value' => $this->property_info['default_value'], 'profile_field_as_dv' => $this->property_info['profile_field_as_dv']); $value = array(); foreach ($arrValues as $valueID => $arrValue) { if (is_array($arrValue)) { $value[$valueID] = $this->cleanRemovedItems($arrValue, $displayListValues); } else { $itemSIDs = explode(',', $arrValue); $value[$valueID] = $this->cleanRemovedItems($itemSIDs, $displayListValues); } } $newPropertyVariables = array('value' => $value['value'], 'display_list_values' => $displayListValues, 'default_value' => $value['default_value'], 'profile_field_as_dv' => $value['profile_field_as_dv'], 'list_values' => $listValues, 'caption' => $this->property_info['caption'], 'no_first_option' => $this->property_info['no_first_option'], 'comment' => $this->property_info['comment'], 'sort_by_alphabet' => $this->property_info['sort_by_alphabet']); return array_merge($propertyVariables, $newPropertyVariables); }
public function getMessageByListingSIDToPost($listingSID) { $listing = SJB_ListingManager::getObjectBySID($listingSID); if (!$listing instanceof SJB_Listing) { $params = array($listingSID); $message = 'Listing #$param_0 does not exist in system'; throw new SJB_FeedException($message, $params); } $listingInfo = SJB_ListingManager::createTemplateStructureForListing($listing); $link = SJB_BitlyManager::getBitlyShortenUrlByListingSid($listingSID); $link = " {$link} {$this->feedInfo['hash_tags']}"; $userInfo = SJB_Array::get($listingInfo, 'user'); $this->tp->assign('post_template', $this->feedInfo['post_template']); $this->tp->assign('listing', $listingInfo); $this->tp->assign('user', $userInfo); $text = $this->tp->fetch($this->template); $post = $text . $link; if (mb_strlen($post) > 138) { $countStrCut = 138 - mb_strlen($post) - 3; $text = mb_substr($text, 0, $countStrCut) . '...'; $post = $text . $link; } return $post; }
public static function getListItemValueBySID($sid) { $result = SJB_DB::query('SELECT `value` FROM `user_profile_field_list` WHERE `sid` = ?n', $sid); if (!empty($result)) { $result = array_pop($result); $result = SJB_Array::get($result, 'value'); } return $result; }
public static function sendInvoiceToCustomer($invoice_sid, $user_sid) { $invoice_info = SJB_InvoiceManager::getInvoiceInfoBySID($invoice_sid); $invoice_structure = SJB_InvoiceManager::createInvoiceTemplate($invoice_info); $user = SJB_UserManager::getObjectBySID($user_sid); $userInfo = SJB_UserManager::createTemplateStructureForUser($user); $parentSID = SJB_Array::get($userInfo, 'parent_sid'); if ($parentSID > 0) { $user = SJB_UserManager::getObjectBySID($parentSID); $userInfo = SJB_UserManager::createTemplateStructureForUser($user); } $data = array('user' => $userInfo, 'invoice' => $invoice_structure); $email = SJB_EmailTemplateEditor::getEmail($userInfo['email'], self::SEND_INVOICE_SID, $data); return $email->send('Send Invoice to Customer'); }
public function __construct($info = null) { $this->db_table_name = 'users_notifications'; $this->details = new SJB_UserNotificationDetails($info); $this->sid = SJB_Array::get($info, 'sid'); }
public static function newValueFromSearchCriteria($listing_structure, $search_criteria_structure) { foreach ($search_criteria_structure as $key => $criteria) { if (isset($criteria['monetary']) && array_key_exists($key, $listing_structure)) { $currency = isset($criteria['monetary']['currency']) ? SJB_CurrencyManager::getCurrencyByCurrCode($criteria['monetary']['currency']) : false; $course = SJB_Array::get($listing_structure[$key], 'course'); if (is_array($listing_structure[$key]) && $course && isset($listing_structure[$key]['add_parameter']) && !empty($currency) && $currency['sid'] != $listing_structure[$key]['add_parameter'] && is_numeric($listing_structure[$key]['value'])) { $listing_structure[$key]['value'] = round($listing_structure[$key]['value'] / $course * $currency['course']); $listing_structure[$key]['currency_sign'] = $currency['currency_sign']; } } } return $listing_structure; }
public function execute() { ini_set('max_execution_time', 0); $encodingFromCharset = SJB_Request::getVar('encodingFromCharset', 'UTF-8'); $preview = SJB_Request::getVar('preview', false); $importedDataForPreview = array(); $template_processor = SJB_System::getTemplateProcessor(); $errors = null; $start_line = SJB_Request::getVar('start_line', null); $name_column = SJB_Request::getVar('name_column', null); $longitude_column = SJB_Request::getVar('longitude_column', null); $latitude_column = SJB_Request::getVar('latitude_column', null); $city_column = SJB_Request::getVar('city_column', null); $state_column = SJB_Request::getVar('state_column', null); $state_code_column = SJB_Request::getVar('state_code_column', null); $country_sid = SJB_Request::getVar('country_sid', null); $file_format = SJB_Request::getVar('file_format', null); $fields_delimiter = SJB_Request::getVar('fields_delimiter', null); $imported_file_config['start_line'] = $start_line; $imported_file_config['name_column'] = $name_column; $imported_file_config['longitude_column'] = $longitude_column; $imported_file_config['latitude_column'] = $latitude_column; $imported_file_config['city_column'] = $city_column; $imported_file_config['state_column'] = $state_column; $imported_file_config['state_code_column'] = $state_code_column; $imported_file_config['file_format'] = $file_format; $imported_file_config['fields_delimiter'] = $fields_delimiter; $imported_location_count = null; if (isset($_FILES['imported_geo_file']) && !$_FILES['imported_geo_file']['error']) { $fileInfo = $_FILES['imported_geo_file']; $fileFormats = array('csv', 'xls', 'xlsx'); $pathInfo = pathinfo($fileInfo['name']); $fileExtension = isset($pathInfo['extension']) ? strtolower($pathInfo['extension']) : ''; if (!in_array(strtolower($fileExtension), $fileFormats)) { $errors['File'] = 'WRONG_FORMAT'; } if (empty($_FILES['imported_geo_file']['name'])) { $errors['File'] = 'EMPTY_VALUE'; } if (empty($start_line)) { $errors['Start Line'] = 'EMPTY_VALUE'; } elseif (!is_numeric($start_line) || !is_int($start_line + 0)) { $errors['Start Line'] = 'NOT_INT_VALUE'; } if (empty($name_column)) { $errors['Name Column'] = 'EMPTY_VALUE'; } elseif (!is_numeric($name_column) || !is_int($name_column + 0)) { $errors['Name Column'] = 'NOT_INT_VALUE'; } if (empty($longitude_column)) { $errors['Longitude Column'] = 'EMPTY_VALUE'; } elseif (!is_numeric($longitude_column) || !is_int($longitude_column + 0)) { $errors['Longitude Column'] = 'NOT_INT_VALUE'; } if (empty($latitude_column)) { $errors['Latitude Column'] = 'EMPTY_VALUE'; } elseif (!is_numeric($latitude_column) || !is_int($latitude_column + 0)) { $errors['Latitude Column'] = 'NOT_INT_VALUE'; } if (empty($country_sid)) { $errors['Country'] = 'EMPTY_VALUE'; } if (!SJB_ImportFile::isValidFileExtensionByFormat($file_format, $_FILES['imported_geo_file'])) { $errors['File'] = 'DO_NOT_MATCH_SELECTED_FILE_FORMAT'; } if (!SJB_ImportFile::isValidFileCharset($_FILES['imported_geo_file'], $encodingFromCharset)) { $errors['Charset'] = 'CHARSET_INCORRECT'; } if (is_null($errors)) { set_time_limit(0); $file_info = SJB_Array::get($_FILES, 'imported_geo_file'); if (!strcasecmp($file_format, 'excel')) { $import_file = new SJB_ImportFileXLS($file_info); } else { if ($fields_delimiter == 'semicolon') { $fields_delimiter = ';'; } elseif ($fields_delimiter == 'tab') { $fields_delimiter = "\t"; } else { $fields_delimiter = ','; } $import_file = new SJB_ImportFileCSV($file_info, $fields_delimiter); } $import_file->parse($encodingFromCharset); $imported_data = $import_file->getData(); $imported_location_count = 0; $countryInfo = SJB_CountriesManager::getCountryInfoBySID($country_sid); foreach ($imported_data as $key => $importedColumn) { if (empty($importedColumn[$name_column - 1]) || empty($importedColumn[$longitude_column - 1]) || empty($importedColumn[$latitude_column - 1]) || $start_line > $key) { continue; } $name = $importedColumn[$name_column - 1]; $longitude = $importedColumn[$longitude_column - 1]; $latitude = $importedColumn[$latitude_column - 1]; $city = isset($importedColumn[$city_column - 1]) ? $importedColumn[$city_column - 1] : null; $state = isset($importedColumn[$state_column - 1]) ? $importedColumn[$state_column - 1] : null; $state_code = isset($importedColumn[$state_code_column - 1]) ? $importedColumn[$state_code_column - 1] : null; if ($preview) { if (count($importedDataForPreview) >= 10) { break; } $importedDataForPreview[] = array('name' => $name, 'longitude' => $longitude, 'latitude' => $latitude, 'city' => $city, 'state' => $state, 'stateCode' => $state_code, 'country' => $countryInfo['country_name']); } else { $imported_location_count += SJB_LocationManager::addLocation($name, $longitude, $latitude, $city, $state, $state_code, $country_sid, $countryInfo); } } } } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { $errorSid = isset($_FILES['imported_geo_file']['error']) ? $_FILES['imported_geo_file']['error'] : 0; $errors['File'] = SJB_UploadFileManager::getErrorId($errorSid); } $countries = SJB_CountriesManager::getAllCountriesCodesAndNames(); $template_processor->assign("charSets", SJB_HelperFunctions::getCharSets()); $template_processor->assign("importedGeographicData", $importedDataForPreview); $template_processor->assign("countries", $countries); $template_processor->assign("country_sid", $country_sid); $template_processor->assign("errors", $errors); $template_processor->assign("imported_location_count", $imported_location_count); $template_processor->assign("imported_file_config", $imported_file_config); $template_processor->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); if ($preview) { $template_processor->display("import_geographic_data_preview.tpl"); } else { $template_processor->display("import_geographic_data_form.tpl"); } }
public function execute() { $formToken = SJB_Request::getVar('form_token'); $tp = SJB_System::getTemplateProcessor(); $tp->assign('form_token', $formToken); $post_max_size_orig = ini_get('post_max_size'); $server_content_length = isset($_SERVER['CONTENT_LENGTH']) ? $_SERVER['CONTENT_LENGTH'] : null; // get post_max_size in bytes $val = trim($post_max_size_orig); $tmp = substr($val, strlen($val) - 1); $tmp = strtolower($tmp); switch ($tmp) { case 'g': $val *= 1024; break; case 'm': $val *= 1024; break; case 'k': $val *= 1024; break; } $post_max_size = $val; $errors = array(); if (SJB_Request::getVar('from-preview', false, 'POST') && !SJB_Request::getVar('action_add', false, 'POST')) { $listingId = SJB_Request::getVar('listing_id', null, 'GET', 'int'); $previewListingId = SJB_Session::getValue('preview_listing_sid'); if ($previewListingId && SJB_ListingManager::isListingExists($previewListingId)) { $listingId = $previewListingId; } } else { $listingId = SJB_Request::getVar('listing_id', null, 'default', 'int'); } $template = SJB_Request::getVar('edit_template', 'edit_listing.tpl'); $filename = SJB_Request::getVar('filename', false); if ($filename) { SJB_UploadFileManager::openFile($filename, $listingId); // if file not found - set error here $errors['NO_SUCH_FILE'] = true; } if (empty($_POST) && $server_content_length > $post_max_size) { $errors['MAX_FILE_SIZE_EXCEEDED'] = 1; $listingId = SJB_Request::getVar('listing_id', null, 'GET', 'int'); $tp->assign('post_max_size', $post_max_size_orig); } $current_user = SJB_UserManager::getCurrentUser(); $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId); // for listing preview $formSubmittedFromPreview = false; if (empty($listingInfo)) { $listingId = SJB_Session::getValue('preview_listing_sid'); $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId); if (!empty($listingInfo)) { // if on preview page 'POST' button was pressed $formSubmittedFromPreview = SJB_Request::getVar('action_add', false, 'POST') && SJB_Request::getVar('from-preview', false, 'POST'); if ($formSubmittedFromPreview) { $listing = new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']); $properties = $listing->getProperties(); foreach ($properties as $fieldID => $property) { switch ($property->getType()) { case 'date': if (!empty($listingInfo[$fieldID])) { $listingInfo[$fieldID] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID]); } break; case 'complex': $complex = $property->type->complex; $complexProperties = $complex->getProperties(); foreach ($complexProperties as $complexfieldID => $complexProperty) { if ($complexProperty->getType() == 'date') { $values = $complexProperty->getValue(); foreach ($values as $index => $value) { if (!empty($listingInfo[$fieldID][$complexfieldID][$index])) { $listingInfo[$fieldID][$complexfieldID][$index] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID][$complexfieldID][$index]); } } } } break; } } } } else { $listingId = null; SJB_Session::unsetValue('preview_listing_sid'); } } // if preview button was pressed $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST'); if (SJB_UserManager::isUserLoggedIn()) { if ($listingInfo['user_sid'] != $current_user->getID()) { $errors['NOT_OWNER_OF_LISTING'] = $listingId; } elseif (!is_null($listingInfo)) { $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingInfo['listing_type_sid']); $form_is_submitted = SJB_Request::getVar('action', '') == 'save_info' || SJB_Request::getVar('action', '') == 'add' || $isPreviewListingRequested || $formSubmittedFromPreview; if (!$form_is_submitted && !SJB_Request::getVar('from-preview', false, 'POST')) { SJB_Session::unsetValue('previewListingId'); SJB_Session::unsetValue('preview_listing_sid_or'); } // fill listing from an array of social data if allowed $listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($listingInfo['listing_type_sid']); $listingTypeID = $listing_type_info['id']; $aAutoFillData = array('formSubmitted' => $form_is_submitted, 'listingTypeID' => $listingTypeID); SJB_Event::dispatch('SocialSynchronization', $aAutoFillData); $listingInfo = array_merge($listingInfo, $_REQUEST); $listing = new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']); $listing->deleteProperty('ListingLogo'); $listing->deleteProperty('featured'); $listing->deleteProperty('priority'); $listing->deleteProperty('reject_reason'); $listing->deleteProperty('status'); $list_emp_ids = SJB_Request::getVar('list_emp_ids'); $listing->setSID($listingId); $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($current_user->getSID()); if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) { $value = SJB_Request::getVar('screening_questionnaire'); $value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : ''; $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($current_user->getSID()), 'is_system' => true)); } else { $listing->deleteProperty('screening_questionnaire'); } //--->CLT-2637 $properties = $listing->getProperties(); $listing_fields_by_page = array(); foreach ($pages as $page) { $listing_fields_by_page = array_merge(SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']), $listing_fields_by_page); } foreach ($properties as $property) { if (!in_array($property->getID(), array_keys($listing_fields_by_page))) { $listing->deleteProperty($property->getID()); } } //--->CLT-2637 // if user is not registered using linkedin , delete linkedin sync property, also if sync is turned off in admin part $aAutoFillData = array('oListing' => &$listing, 'userSID' => $current_user->getSID(), 'listingTypeID' => $listingTypeID, 'listing_info' => $listingInfo); SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData); $listing_edit_form = new SJB_Form($listing); $listing_edit_form->registerTags($tp); $extraInfo = $listingInfo['product_info']; if ($extraInfo) { $extraInfo = unserialize($extraInfo); $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $listingSidForPictures = SJB_Session::getValue('preview_listing_sid_or') ? SJB_Session::getValue('preview_listing_sid_or') : $listingId; $tp->assign('pic_limit', $numberOfPictures); $tp->assign('listingSidForPictures', $listingSidForPictures); } if ($form_is_submitted) { $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar('list_emp_ids'), 'is_system' => true)); } $field_errors = array(); if ($form_is_submitted && ($formSubmittedFromPreview || $listing_edit_form->isDataValid($field_errors))) { $or_listing_id = SJB_Session::getValue('preview_listing_sid_or'); /* preview listing */ if ($isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') != $listing->getSID()) { SJB_Session::setValue('preview_listing_sid_or', $listing->getSID()); $listing->setSID(null); } elseif (!$isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') == $listing->getSID() && $or_listing_id && $or_listing_id != $listingId) { $listing->setSID($or_listing_id); } if ($isPreviewListingRequested) { $listing->addProperty(array('id' => 'preview', 'type' => 'integer', 'value' => 1, 'is_system' => true)); } else { $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true)); } if ($isPreviewListingRequested) { $listing->product_info = $extraInfo; if (SJB_Session::getValue('previewListingId')) { $listing->setSID(SJB_Session::getValue('previewListingId')); } } else { SJB_BrowseDBManager::deleteListings($listing->getID()); } $listingSidsForCopy = array('filesFrom' => $listingId, 'picturesFrom' => $isPreviewListingRequested && (!$or_listing_id || $or_listing_id === $listingId) ? $listingId : null); SJB_ListingManager::saveListing($listing, $listingSidsForCopy); if (!$isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') == $listingId && $or_listing_id && $or_listing_id != $listingId) { SJB_Session::unsetValue('preview_listing_sid'); SJB_ListingManager::deleteListingBySID($listingId); } $listingInfo = SJB_ListingManager::getListingInfoBySID($listing->getSID()); if ($listingInfo['active']) { SJB_ListingManager::activateListingKeywordsBySID($listing->getSID()); SJB_BrowseDBManager::addListings($listing->getID()); } // >>> SJB-1197 // SET VALUES FROM TEMPORARY SESSION STORAGE $formToken = SJB_Request::getVar('form_token'); $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage'); $tempFieldsData = SJB_Array::getPath($sessionFileStorage, $formToken); if (is_array($tempFieldsData)) { foreach ($tempFieldsData as $fieldId => $fieldData) { $isComplex = false; if (strpos($fieldId, ':') !== false) { $isComplex = true; } $tmpUploadedFileId = $fieldData['file_id']; // rename it to real listing field value $newFileId = $fieldId . "_" . $listing->getSID(); SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId); if ($isComplex) { list($parentField, $subField, $complexStep) = explode(':', $fieldId); $parentProp = $listing->getProperty($parentField); $parentValue = $parentProp->getValue(); // look for complex property with current $fieldID and set it to new value of property if (!empty($parentValue)) { foreach ($parentValue as $id => $value) { if ($id == $subField) { $parentValue[$id][$complexStep] = $newFileId; } } $listing->setPropertyValue($parentField, $parentValue); } } else { $listing->setPropertyValue($fieldId, $newFileId); } } SJB_ListingManager::saveListing($listing); // recreate form object for saved listing // it fix display of complex file fields $listing = SJB_ListingManager::getObjectBySID($listing->getSID()); $listing->deleteProperty('featured'); $listing->deleteProperty('priority'); $listing->deleteProperty('reject_reason'); $listing->deleteProperty('status'); $listing_edit_form = new SJB_Form($listing); $listing_edit_form->registerTags($tp); } // <<< SJB-1197 if ($isPreviewListingRequested) { SJB_Session::setValue('previewListingId', $listing->getSID()); } /* preview listing */ if ($isPreviewListingRequested) { $listing->setUserSID($current_user->getSID()); SJB_Session::setValue('preview_listing_sid', $listing->getSID()); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($listingTypeID) . '-preview/' . $listing->getSID() . '/'); } else { /* normal */ $listingSid = $listing->getSID(); SJB_Event::dispatch('listingEdited', $listingSid); $tp->assign('display_preview', 1); SJB_Session::unsetValue('preview_listing_sid'); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-' . strtolower($listingTypeID) . '-details/' . $listing->getSID() . '/'); } } $listing->deleteProperty('access_list'); $tp->assign('form_is_submitted', $form_is_submitted); $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing); $form_fields = $listing_edit_form->getFormFieldsInfo(); $listing_fields_by_page = array(); foreach ($pages as $page) { $listing_fields_by_page[$page['page_name']] = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']); foreach (array_keys($listing_fields_by_page[$page['page_name']]) as $field) { if (!$listing->propertyIsSet($field)) { unset($listing_fields_by_page[$page['page_name']][$field]); } } } // delete sync fields from posting pages that are not in array $form_fields $aAutoFillData = array('listing_fields_by_page' => &$listing_fields_by_page, 'pages' => &$pages, 'form_fields' => $form_fields); SJB_Event::dispatch('SocialSynchronizationFieldsOnPostingPages', $aAutoFillData); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign('METADATA', array('listing' => $metaDataProvider->getMetaData($listing_structure['METADATA']), 'form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields))); if (!isset($listing_structure['access_type'])) { $listing_structure['access_type'] = 'everyone'; } $listing_access_list = SJB_ListingManager::getListingAccessList($listingId, $listing->getPropertyValue('access_type')); $tp->assign('contract_id', $listingInfo['contract_id']); $tp->assign('extraInfo', $extraInfo); $tp->assign('listing', $listing_structure); $tp->assign('pages', $listing_fields_by_page); $tp->assign('countPages', count($listing_fields_by_page)); $tp->assign('field_errors', $field_errors); $tp->assign('listing_access_list', $listing_access_list); $tp->assign('listingTypeID', $listingTypeID); $tp->assign('expired', SJB_ListingManager::getIfListingHasExpiredBySID($listing->getSID())); // only for Resume listing types $aAutoFillData = array('tp' => &$tp, 'listingTypeID' => $listingTypeID, 'userSID' => $current_user->getSID()); SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData); } } else { $errors['NOT_LOGGED_IN'] = 1; } $tp->assign('errors', $errors); $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $listingTypeID = SJB_Request::getVar('listing_type_id', null); $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID); $listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listingTypeSID); $productSID = SJB_Request::getVar('product_sid', false); $editUser = SJB_Request::getVar('edit_user', false); $action = SJB_Request::getVar('action', false); $username = SJB_Request::getVar('username', false); $errors = array(); if ($username && ($userSID = SJB_UserManager::getUserSIDbyUsername($username))) { $userInfo = SJB_UserManager::getUserInfoBySID($userSID); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userInfo['user_group_sid']); if (!$productSID) { $products = SJB_ProductsManager::getProductsInfoByUserGroupSID($userGroupInfo['sid']); foreach ($products as $key => $product) { if (empty($product['listing_type_sid']) || $product['listing_type_sid'] != $listingTypeSID) { unset($products[$key]); } } if ($action == 'productVerify') { $errors['PRODUCT_NOT_SELECTED'] = 1; } $tp->assign('errors', $errors); $tp->assign('username', $username); $tp->assign('products', $products); $tp->assign('edit_user', $editUser); $tp->assign('userSID', $userSID); $tp->assign('userGroupInfo', $userGroupInfo); $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo)); $tp->display('select_product.tpl'); } else { $form_submitted = SJB_Request::getVar('action', '') == 'add'; $tmp_listing_id_from_request = SJB_Request::getVar('listing_id', false, 'default', 'int'); if (!empty($tmp_listing_id_from_request)) { $tmp_listing_sid = $tmp_listing_id_from_request; } elseif (!$tmp_listing_id_from_request) { $tmp_listing_sid = time(); } $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID); $extraInfo = is_null($productInfo['serialized_extra_info']) ? null : unserialize($productInfo['serialized_extra_info']); if (!empty($extraInfo)) { $extraInfo['product_sid'] = $productSID; } $_REQUEST['featured'] = !empty($_REQUEST['featured']) ? $_REQUEST['featured'] : $productInfo['featured']; $_REQUEST['priority'] = !empty($_REQUEST['priority']) ? $_REQUEST['priority'] : $productInfo['priority']; $listing = new SJB_Listing($_REQUEST, $listingTypeSID); $properties = $listing->getPropertyList(); foreach ($properties as $property) { $propertyInfo = $listing->getPropertyInfo($property); $propertyInfo['user_sid'] = $userSID; if ($propertyInfo['type'] == 'location') { $child = $listing->getChild($property); $childProperties = $child->getPropertyList(); foreach ($childProperties as $childProperty) { $childPropertyInfo = $child->getPropertyInfo($childProperty); $childPropertyInfo['user_sid'] = $userSID; $child->setPropertyInfo($childProperty, $childPropertyInfo); } } $listing->setPropertyInfo($property, $propertyInfo); } $listing->deleteProperty('status'); $listing->deleteProperty('reject_reason'); $access_type = $listing->getProperty('access_type'); if ($form_submitted) { if (!empty($access_type)) { $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar("list_emp_ids"), 'is_system' => true)); } } $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($userSID); if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) { $issetQuestionnairyField = $listing->getProperty('screening_questionnaire'); if ($issetQuestionnairyField) { $value = SJB_Request::getVar("screening_questionnaire"); $listing_info = $_REQUEST; $value = $value ? $value : isset($listing_info['screening_questionnaire']) ? $listing_info['screening_questionnaire'] : ''; $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($userSID), 'is_system' => true)); } } else { $listing->deleteProperty('screening_questionnaire'); } if ($listing->getProperty('captcha')) { $listing->deleteProperty('captcha'); } $add_listing_form = new SJB_Form($listing); $add_listing_form->registerTags($tp); $field_errors = array(); if ($form_submitted && $add_listing_form->isDataValid($field_errors)) { $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true)); $listing->setUserSID($userSID); $listing->setProductInfo($extraInfo); if (empty($access_type->value)) { $listing->setPropertyValue('access_type', 'everyone'); } SJB_ListingManager::saveListing($listing); SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listing->getSID(), false, $_REQUEST['featured'], $_REQUEST['priority'], $userSID); if (isset($_SESSION['tmp_file_storage'])) { foreach ($_SESSION['tmp_file_storage'] as $v) { SJB_DB::query("UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `picture_saved_name` = ?s", $listing->getSID(), $v['picture_saved_name']); SJB_DB::query("UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `thumb_saved_name` = ?s", $listing->getSID(), $v['thumb_saved_name']); } SJB_Session::unsetValue('tmp_file_storage'); } $formToken = SJB_Request::getVar('form_token'); $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage'); $uploadedFields = SJB_Array::getPath($sessionFilesStorage, $formToken); if (!empty($uploadedFields)) { foreach ($uploadedFields as $fieldId => $fieldValue) { // get field of listing $isComplex = false; if (strpos($fieldId, ':') !== false) { $isComplex = true; } $tmpUploadedFileId = $fieldValue['file_id']; // rename it to real listing field value $newFileId = $fieldId . "_" . $listing->getSID(); SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId); if ($isComplex) { list($parentField, $subField, $complexStep) = explode(':', $fieldId); $parentProp = $listing->getProperty($parentField); $parentValue = $parentProp->getValue(); // look for complex property with current $fieldID and set it to new value of property if (!empty($parentValue)) { foreach ($parentValue as $id => $value) { if ($id == $subField) { $parentValue[$id][$complexStep] = $newFileId; } } $listing->setPropertyValue($parentField, $parentValue); } } else { $listing->setPropertyValue($fieldId, $newFileId); } // unset value from session temporary storage $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}/{$fieldId}"); } //and remove token key from temporary storage $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}"); SJB_Session::setValue('tmp_uploads_storage', $sessionFilesStorage); SJB_ListingManager::saveListing($listing); } SJB_ListingManager::activateListingBySID($listing->getSID()); SJB_ProductsManager::incrementPostingsNumber($productSID); $listingSid = $listing->getSID(); SJB_Event::dispatch('listingSaved', $listingSid); if ($editUser) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/edit-user/?user_sid=" . $userSID); } else { if ($listingTypeID == 'resume' || $listingTypeID == 'job') { $link = "manage-" . strtolower($listingTypeID) . "s"; } else { $link = "manage-" . strtolower($listingTypeID) . "-listings"; } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/{$link}/?action=search&listing_type_sid=" . $listingTypeSID); } } else { $listing->deleteProperty('access_list'); $listing->deleteProperty('contract_id'); $add_listing_form = new SJB_Form($listing); if ($form_submitted) { $add_listing_form->isDataValid($field_errors); } $add_listing_form->registerTags($tp); $form_fields = $add_listing_form->getFormFieldsInfo(); $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingTypeSID); $formFieldsSorted = array(); $formFieldsSorted['featured'] = $form_fields['featured']; $formFieldsSorted['priority'] = $form_fields['priority']; foreach ($pages as $page) { $listing_fields = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']); foreach (array_keys($listing_fields) as $field) { if ($listing->propertyIsSet($field)) { $formFieldsSorted[$field] = $form_fields[$field]; } } } $form_fields = $formFieldsSorted; //SJB_HelperFunctions::d($form_fields); $employers_list = SJB_Request::getVar('list_emp_ids', false); $employers = array(); if (is_array($employers_list)) { foreach ($employers_list as $emp) { $currEmp = SJB_UserManager::getUserInfoBySID($emp); $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']); } sort($employers); } $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $tp->assign("pic_limit", $numberOfPictures); $tp->assign("listing_id", $tmp_listing_sid); $tp->assign("listing_access_list", $employers); $tp->assign("errors", $field_errors); $tp->assign("form_fields", $form_fields); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields))); } $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->assign('edit_user', $editUser); $tp->assign('productInfo', $productInfo); $tp->assign('username', $username); $tp->assign('product_sid', $productSID); $tp->assign('userSID', $userSID); $tp->assign('userGroupInfo', $userGroupInfo); $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo)); $tp->display('input_form.tpl'); } } else { if ($username && !$userSID) { $errors['USER_NOT_FOUND'] = 1; } elseif ($action == 'userVerify') { $errors['USER_NOT_SELECTED'] = 1; } $tp->assign('errors', $errors); $tp->assign('username', $username); $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo)); $tp->display('select_user.tpl'); } }
/** * Recurring notification handlign function * @param array|null $callback_data Notification data */ function handleRecurringNotification($callback_data) { if (SJB_Array::get($callback_data, 'txn_type') == 'subscr_cancel' || SJB_Array::get($callback_data, 'txn_type') == 'subscr_eot') { SJB_ContractManager::removeSubscriptionId(SJB_Array::get($callback_data, 'subscr_id')); return; } if (SJB_Array::get($callback_data, 'txn_type') != 'subscr_payment') { return; } $invoice_sid = isset($callback_data['item_number']) ? $callback_data['item_number'] : null; if (is_null($invoice_sid)) { return; } $invoice = SJB_InvoiceManager::getObjectBySID($invoice_sid); if (is_null($invoice)) { return null; } $reactivation = false; $status = $invoice->getStatus(); if ($invoice->getStatus() == SJB_Invoice::INVOICE_STATUS_PAID) { // Пришёл рекьюринг платёж $invoice->setSID(null); $invoice->setDate(null); $invoice->setStatus(SJB_Invoice::INVOICE_STATUS_UNPAID); $reactivation = true; } $invoice->setCallbackData($callback_data); if ($this->isPaymentVerified($invoice) && in_array($callback_data['payment_status'], array('Completed', 'Processed'))) { $items = $invoice->getPropertyValue('items'); $user_sid = $invoice->getUserSID(); $subscriptionSID = $callback_data['custom']; if (!empty($items['products'])) { $recurringProductsInfo = array(); foreach ($items['products'] as $key => $product) { if ($product != -1) { $productInfo = $invoice->getItemValue($key); if ($status == SJB_Invoice::INVOICE_STATUS_PAID && $subscriptionSID == $product) { $listingNumber = $productInfo['qty']; $contract = new SJB_Contract(array('product_sid' => $product, 'recurring_id' => $callback_data['subscr_id'], 'gateway_id' => 'paypal_standard', 'numberOfListings' => $listingNumber)); $contract->setUserSID($user_sid); $contractSID = SJB_ContractManager::getContractSIDByRecurringId($callback_data['subscr_id']); SJB_ContractManager::deleteAllContractsByRecurringId($callback_data['subscr_id']); $contract->setPrice($productInfo['amount']); if ($contract->saveInDB()) { SJB_ShoppingCart::deleteItemFromCartBySID($productInfo['shoppingCartRecord'], $user_sid); $bannerInfo = $productInfo['banner_info']; if ($productInfo['product_type'] == 'banners' && !empty($bannerInfo)) { $bannersObj = new SJB_Banners(); if (isset($contractSID)) { $bannerID = $bannersObj->getBannerIDByContract($contractSID); if ($bannerID) { $bannersObj->updateBannerContract($contract->getID(), $bannerID); } } else { $bannersObj->addBanner($bannerInfo['title'], $bannerInfo['link'], $bannerInfo['bannerFilePath'], $bannerInfo['sx'], $bannerInfo['sy'], $bannerInfo['type'], 0, $bannerInfo['banner_group_sid'], $bannerInfo, $user_sid, $contract->getID()); $bannerGroup = $bannersObj->getBannerGroupBySID($bannerInfo['banner_group_sid']); SJB_AdminNotifications::sendAdminBannerAddedLetter($user_sid, $bannerGroup); } } if ($contract->isFeaturedProfile()) { SJB_UserManager::makeFeaturedBySID($user_sid); } SJB_Statistics::addStatistics('payment', 'product', $product, false, 0, 0, $user_sid, $productInfo['amount']); if (SJB_UserNotificationsManager::isUserNotifiedOnSubscriptionActivation($user_sid)) { SJB_Notifications::sendSubscriptionActivationLetter($user_sid, $productInfo, $reactivation); } } $recurringProductsInfo[$key] = $productInfo; } elseif ($status != SJB_Invoice::INVOICE_STATUS_PAID) { $listingNumber = $productInfo['qty']; if ($subscriptionSID == $product) { $contract = new SJB_Contract(array('product_sid' => $product, 'recurring_id' => $callback_data['subscr_id'], 'gateway_id' => 'paypal_standard', 'numberOfListings' => $listingNumber)); } else { $contract = new SJB_Contract(array('product_sid' => $product, 'gateway_id' => 'paypal_standard', 'numberOfListings' => $listingNumber)); } $contract->setUserSID($user_sid); $contract->setPrice($productInfo['amount']); if ($contract->saveInDB()) { SJB_ShoppingCart::deleteItemFromCartBySID($productInfo['shoppingCartRecord'], $user_sid); $bannerInfo = $productInfo['banner_info']; if ($productInfo['product_type'] == 'banners' && !empty($bannerInfo) && $contractSID) { $bannersObj = new SJB_Banners(); $bannersObj->addBanner($bannerInfo['title'], $bannerInfo['link'], $bannerInfo['bannerFilePath'], $bannerInfo['sx'], $bannerInfo['sy'], $bannerInfo['type'], 0, $bannerInfo['banner_group_sid'], $bannerInfo, $user_sid, $contract->getID()); $bannerGroup = $bannersObj->getBannerGroupBySID($bannerInfo['banner_group_sid']); SJB_AdminNotifications::sendAdminBannerAddedLetter($user_sid, $bannerGroup); } if ($contract->isFeaturedProfile()) { SJB_UserManager::makeFeaturedBySID($user_sid); } SJB_Statistics::addStatistics('payment', 'product', $product, false, 0, 0, $user_sid, $productInfo['amount']); if (SJB_UserNotificationsManager::isUserNotifiedOnSubscriptionActivation($user_sid)) { SJB_Notifications::sendSubscriptionActivationLetter($user_sid, $productInfo); } } } } } if ($reactivation) { $invoice->setNewPropertiesToInvoice($recurringProductsInfo); } $price = isset($callback_data['payment_gross']) ? $callback_data['payment_gross'] : $invoice->getPropertyValue('total'); $invoice->setStatus(SJB_Invoice::INVOICE_STATUS_PAID); $id = $this->details->getProperty('id'); $invoice->setPropertyValue('payment_method', $id->getValue()); SJB_InvoiceManager::saveInvoice($invoice); SJB_PromotionsManager::markPromotionAsPaidByInvoiceSID($invoice->getSID()); $transactionID = $callback_data['txn_id']; $transactionInfo = array('transaction_id' => $transactionID, 'invoice_sid' => $invoice->getSID(), 'amount' => $price, 'payment_method' => $invoice->getPropertyValue('payment_method'), 'user_sid' => $invoice->getPropertyValue('user_sid')); $transaction = new SJB_Transaction($transactionInfo); SJB_TransactionManager::saveTransaction($transaction); } } else { $invoice->setStatus(SJB_Invoice::INVOICE_STATUS_UNPAID); SJB_InvoiceManager::saveInvoice($invoice); } }
private static function changeListProperties(&$export_data) { $listFieldsInfo = SJB_UserProfileFieldManager::getFieldsInfoByType('list'); $multilistFieldsInfo = SJB_UserProfileFieldManager::getFieldsInfoByType('multilist'); $fieldsInfo = array_merge($listFieldsInfo, $multilistFieldsInfo); foreach ($export_data as $user_sid => $property) { $userGroupSID = (int) SJB_UserGroupManager::getUserGroupSIDByName(SJB_Array::get($property[self::USER_OPTIONS_INDEX], 'user_group_id')); foreach ($fieldsInfo as $field_info) { $fieldID = SJB_Array::get($field_info, 'id'); $fieldUserGroupSID = (int) SJB_Array::get($field_info, 'user_group_sid'); if ($fieldUserGroupSID === $userGroupSID && !empty($property[$fieldID])) { $fieldInfo = SJB_UserProfileFieldManager::getFieldInfoBySID($field_info['sid']); switch ($fieldInfo['type']) { case 'list': foreach ($fieldInfo['list_values'] as $listValues) { if ($listValues['id'] == $property[$field_info['id']]) { $export_data[$user_sid][$field_info['id']] = $listValues['caption']; break; } } break; case 'multilist': $multilistValues = explode(',', $property[$field_info['id']]); $multilistDisplayValues = array(); foreach ($fieldInfo['list_values'] as $listValues) { if (in_array($listValues['id'], $multilistValues)) { $multilistDisplayValues[] = $listValues['caption']; } } $export_data[$user_sid][$field_info['id']] = implode(',', $multilistDisplayValues); break; } } } } }
private function getSortedResults($values) { if (!empty($values)) { $fieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($this->field['sid']); if (SJB_Array::get($fieldInfo, 'sort_by_alphabet') > 0) { $i18n = SJB_I18N::getInstance(); $parents = array(); // in this place we have 'caption' with ids of children items, like '300,301,302,305' etc. // need to get real caption value (for children and parent) and sort by it foreach ($values as $parent => $items) { if (!is_array($items)) { $items = array(); } $sids = array_keys($items); $parentSid = SJB_ListingFieldTreeManager::getParentSID($parent); $parentInfo = SJB_ListingFieldTreeManager::getTreeItemInfoBySID($parentSid); $parents[] = $i18n->gettext('', $parentInfo['caption']); // sort children by alphabet $children = array(); foreach ($sids as $sid) { $info = SJB_ListingFieldTreeManager::getTreeItemInfoBySID($sid); $children[] = $i18n->gettext('', $info['caption']); } array_multisort($children, SORT_STRING, $sids); $sids = array_fill_keys($sids, 1); // set to sorted sids $values[$parent] = $sids; } // sort parent by alphabet $keys = array_keys($values); array_multisort($parents, SORT_ASC, SORT_STRING, $keys, $values); $values = array_combine($keys, $values); } } return $values; }