예제 #1
0
 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);
     }
 }
예제 #2
0
 /**
  * @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');
 }
예제 #5
0
 /**
  * @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');
     }
 }
예제 #6
0
 /**
  * @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;
 }
예제 #7
0
 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');
     }
 }
예제 #8
0
 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();
 }
예제 #9
0
 /**
  * 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;
             }
         }
     }
 }
예제 #10
0
 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;
 }
예제 #11
0
 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;
 }
예제 #12
0
 /**
  * @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;
 }
예제 #13
0
 /**
  * @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();
 }
예제 #14
0
 public function isAccessible()
 {
     $listingTypeID = SJB_Array::get($this->params, 'listing_type_id');
     if ($listingTypeID) {
         $permissionLabel = 'view_' . strtolower($listingTypeID) . '_details';
         $this->setPermissionLabel($permissionLabel);
         $allow = parent::isAccessible() && SJB_System::isUserAccessThisPage();
         $listingID = SJB_Request::getVar('listing_id', false);
         $passedParametersViaUri = SJB_Request::getVar('passed_parameters_via_uri', false);
         if (!$listingID && $passedParametersViaUri) {
             $passedParametersViaUri = SJB_UrlParamProvider::getParams();
             if (isset($passedParametersViaUri[0])) {
                 $listingID = $passedParametersViaUri[0];
             }
         }
         if (SJB_UserManager::isUserLoggedIn()) {
             $currentUser = SJB_UserManager::getCurrentUser();
             if (!$allow && $listingID) {
                 $pageID = SJB_PageManager::getPageParentURI(SJB_Navigator::getURI(), SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE'), false);
                 $pageHasBeenVisited = SJB_ContractManager::isPageViewed($currentUser->getSID(), $pageID, $listingID);
                 if ($pageHasBeenVisited || strpos($pageID, 'print') !== false) {
                     $allow = true;
                 }
             }
             if (!$allow && 'Resume' == $listingTypeID && $listingID) {
                 // if view resume not allowed by ACL, check applications table
                 // for current resume ID, applied for one of current user jobs
                 // if present in applications - allow current user to view resume
                 // check for all jobs of current user
                 $cuJobs = SJB_ListingManager::getListingsByUserSID($currentUser->getSID());
                 $listingSids = array();
                 foreach ($cuJobs as $job) {
                     $listingSids[] = $job->getSID();
                 }
                 if (!empty($listingSids)) {
                     $result = SJB_DB::query('SELECT * FROM `applications` WHERE `resume` = ?n AND `listing_id` IN (?l) LIMIT 1', $listingID, $listingSids);
                     if (!empty($result)) {
                         $allow = true;
                     }
                 }
             }
         }
         return $allow;
     }
     return parent::isAccessible() && SJB_System::isUserAccessThisPage();
 }
예제 #15
0
 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');
     }
 }
예제 #16
0
 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);
 }
예제 #17
0
 /**
  * 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;
 }
예제 #18
0
 /**
  * @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);
 }
예제 #19
0
파일: Captcha.php 프로젝트: Maxlander/shixi
 /**
  * @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;
 }
예제 #20
0
 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);
 }
예제 #21
0
 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;
 }
예제 #22
0
 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;
                 }
             }
         }
     }
 }
예제 #23
0
 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;
 }
예제 #24
0
 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');
 }
예제 #25
0
 public function __construct($info = null)
 {
     $this->db_table_name = 'users_notifications';
     $this->details = new SJB_UserNotificationDetails($info);
     $this->sid = SJB_Array::get($info, 'sid');
 }
예제 #26
0
 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;
 }
예제 #27
0
 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");
     }
 }
예제 #28
0
파일: PayPal.php 프로젝트: Maxlander/shixi
 /**
  * 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);
     }
 }
예제 #29
0
파일: User.php 프로젝트: Maxlander/shixi
 /**
  * @param array $aUserFields
  * @param array $aListingFields
  * @param array $aUserFieldsNotRequiredInRegistration
  */
 public function prepareRegistrationFields($aUserFields = array(), $aListingFields = array(), $aUserFieldsNotRequiredInRegistration = array())
 {
     /** @var $oProperty SJB_ObjectProperty */
     foreach ($this->getProperties() as $oProperty) {
         $propertyID = $oProperty->getID();
         $complexRequired = false;
         if ($oProperty->getType() == 'location') {
             if ($oProperty->is_required) {
                 $complexRequired = true;
             } else {
                 if (!empty($oProperty->type->fields)) {
                     foreach ($oProperty->type->fields as $locationFieldInfo) {
                         if (SJB_Array::get($locationFieldInfo, 'is_required') > 0 || SJB_Array::get($locationFieldInfo, 'hidden') > 0) {
                             $complexRequired = true;
                             break;
                         }
                     }
                 }
             }
             if ($complexRequired) {
                 $location = $oProperty->getObjectType();
                 $location->prepareLocationRegistrationFields();
             }
         }
         if (!$complexRequired && !in_array($propertyID, $aUserFields) && !in_array($propertyID, $aListingFields) && !$oProperty->isRequired() || in_array($propertyID, $aUserFieldsNotRequiredInRegistration)) {
             $this->deleteProperty($propertyID);
         }
     }
 }
예제 #30
0
 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;
 }