예제 #1
0
    public function execute()
    {
        if (!class_exists('SJB_SocialPlugin') || !in_array('facebook', SJB_SocialPlugin::getAvailablePlugins()) || !SJB_Settings::getSettingByName('facebook_resumeAutoFillSync')) {
            echo 'facebook synchronization function is turned off';
            return null;
        }
        /**
         * get all listings where synchronization is set
         */
        $listingsSIDs = SJB_DB::query('SELECT `reference_uid`, `listings`.`sid` as `listingSID`, `listings`.`user_sid` FROM `listings`
				INNER JOIN `users` ON `listings`.`user_sid` = `users`.`sid`
				WHERE `facebook_sync` = 1 AND `users`.`reference_uid` IS NOT NULL ORDER BY `user_sid`');
        if (!empty($listingsSIDs)) {
            $oFacebookSync = new FacebookSync();
            foreach ($listingsSIDs as $rUid) {
                try {
                    if ($oFacebookSync->init($rUid['reference_uid'], $rUid['listingSID'])) {
                        $oFacebookSync->sync();
                    } else {
                        throw new Exception('cant connect to facebook  :: ' . $oFacebookSync->getSocialID());
                    }
                } catch (Exception $e) {
                    echo $e->getMessage();
                }
            }
        }
    }
예제 #2
0
 static function logout()
 {
     SessionStorage::destroy(SJB_Session::getSessionId());
     $forumPath = SJB_Settings::getSettingByName('forum_path');
     if (empty($forumPath)) {
         return;
     }
     $url = SJB_System::getSystemSettings('SITE_URL') . $forumPath . '/';
     $client = new Zend_Http_Client($url, array('useragent' => SJB_Request::getUserAgent()));
     $client->setCookie($_COOKIE);
     $client->setCookieJar();
     try {
         $response = $client->request();
         $matches = array();
         if (preg_match('/\\.\\/ucp.php\\?mode=logout\\&sid=([\\w\\d]+)"/', $response->getBody(), $matches)) {
             $sid = $matches[1];
             $client->setUri($url . 'ucp.php?mode=logout&sid=' . $sid);
             $response = $client->request();
             foreach ($response->getHeaders() as $key => $header) {
                 if ('set-cookie' == strtolower($key)) {
                     if (is_array($header)) {
                         foreach ($header as $val) {
                             header("Set-Cookie: " . $val, false);
                         }
                     } else {
                         header("Set-Cookie: " . $header, false);
                     }
                 }
             }
         }
     } catch (Exception $ex) {
     }
 }
예제 #3
0
 public function execute()
 {
     set_time_limit(0);
     $notifiedEmails = array();
     $emailScheduling = SJB_Settings::getSettingByName('email_scheduling');
     $numberEmails = SJB_Settings::getSettingByName('number_emails');
     $emailsSend = SJB_Settings::getSettingByName('send_emails');
     $limit = $numberEmails - $emailsSend;
     $limit = $limit > 0 ? $limit : 20;
     $letters = SJB_DB::query('SELECT * FROM `email_scheduling` ORDER BY `id` ASC LIMIT 0, ?n', $limit);
     if ($emailScheduling && $numberEmails || count($letters)) {
         foreach ($letters as $letter) {
             $params = $letter;
             unset($params['id']);
             $email = new SJB_Email($params['email']);
             $email->setSubject($params['subject']);
             $email->setText($params['text']);
             $email->setFile($params['file']);
             if ($email->send(true)) {
                 SJB_DB::query('DELETE FROM `email_scheduling` WHERE `id` = ?n', $letter['id']);
                 array_push($notifiedEmails, $params['email']);
             }
         }
     }
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('notified_emails', $notifiedEmails);
     $schedulerLog = $tp->fetch('email_scheduler_log.tpl');
     SJB_HelperFunctions::writeCronLogFile('email_scheduler.log', $schedulerLog);
 }
예제 #4
0
 public static function logout()
 {
     $blogPath = SJB_Settings::getSettingByName('blog_path');
     if (empty($blogPath)) {
         return;
     }
     $url = SJB_System::getSystemSettings('SITE_URL') . $blogPath . '/';
     $client = new Zend_Http_Client($url, array('useragent' => SJB_Request::getUserAgent(), 'maxredirects' => 0));
     if (isset($_SESSION['wp_cookie_jar'])) {
         $client->setCookieJar(@unserialize($_SESSION['wp_cookie_jar']));
     }
     try {
         $response = $client->request();
         $matches = array();
         if (preg_match('/_wpnonce=([\\w\\d]+)"/', $response->getBody(), $matches)) {
             $wpnonce = $matches[1];
             $url = $url . 'wp-login.php?action=logout&_wpnonce=' . $wpnonce . '&noSJB=1';
             $client->setUri($url);
             $response = $client->request();
             foreach ($response->getHeaders() as $key => $header) {
                 if ('set-cookie' == strtolower($key)) {
                     if (is_array($header)) {
                         foreach ($header as $val) {
                             header("Set-Cookie: " . $val, false);
                         }
                     } else {
                         header("Set-Cookie: " . $header, false);
                     }
                 }
             }
         }
     } catch (Exception $ex) {
     }
 }
예제 #5
0
 public static function updateDatabase()
 {
     if (SJB_Settings::getSettingByName('patchDatabaseOnlyUsingSJB') || !($patchList = self::getPatchList())) {
         return;
     }
     $originalMaxExecutionTime = ini_get('max_execution_time');
     ini_set('max_execution_time', 0);
     $patchCode = '';
     foreach ($patchList as $patch) {
         if (!$patchCode) {
             $patchCode = $patch;
         } else {
             if ($patchCode != '*') {
                 $patched = SJB_Settings::getValue('db-patch-' . $patchCode);
             } else {
                 $patched = false;
             }
             if (empty($patched)) {
                 $patch();
                 if (SJB_DB::isErrorExist()) {
                     self::logMysqlErrors($patchCode);
                 } else {
                     if ($patched !== false) {
                         SJB_Settings::addSetting('db-patch-' . $patchCode, 'patched');
                     }
                 }
             }
             $patchCode = '';
         }
     }
     ini_set('max_execution_time', $originalMaxExecutionTime);
 }
예제 #6
0
 /**
  * retrieve display layout property for builder
  * returns from $_GET array if value exists
  * else returns saved value from system
  *
  * @return bool|mixed|null
  */
 public function getDisplayLayout()
 {
     $layoutID = SJB_Request::getVar('builder-layout', null, 'GET');
     if ($layoutID) {
         return $layoutID;
     }
     return SJB_Settings::getSettingByName(SJB_DisplayFormFieldsBuilder::getDisplayLayoutNamePart($this->listingTypeID));
 }
 public function execute()
 {
     if (class_exists('SJB_SocialPlugin') && in_array('linkedin', SJB_SocialPlugin::getAvailablePlugins()) && SJB_Settings::getSettingByName('li_allowPeopleSearch')) {
         $liSearch = SJB_Request::getVar('li_search', false);
         $oLinkedin = SJB_SocialPlugin::getActiveSocialPlugin();
         if ('Resume' == $_REQUEST['listing_type']['equal'] && $liSearch && $oLinkedin instanceof LinkedinSocialPlugin) {
             SJB_Session::setValue('linkedinPeopleSearch', true);
             $request =& $_REQUEST;
             /*
              * keywords=[space delimited keywords]
              * sort=[connections|recommenders|distance|relevance]
              * postal-code=[postal code]
              * start=[number]& count=[1-25]&  facet=[facet code, values]& facets=[facet
              *
              * info:
              * http://developer.linkedin.com/docs/DOC-1191
              */
             $sKeywords = '';
             $sZip = !empty($request['ZipCode']['geo']['location']) ? $request['ZipCode']['geo']['location'] : '';
             $aIndustry = !empty($request['JobCategory']['multi_like']) ? $request['JobCategory']['multi_like'] : array();
             $sIndustry = '';
             $sCount = !empty($request['count']) ? (int) $request['count'] : 10;
             if (!empty($request['keywords']) && is_array($request['keywords'])) {
                 foreach ($request['keywords'] as $keywords) {
                     $sKeywords = $keywords;
                 }
             }
             $aFields = array('keywords' => $sKeywords, 'postal-code' => $sZip, 'count' => $sCount);
             foreach ($aIndustry as $industryName) {
                 if ($industryKey = SJB_LinkedinFields::getIndustryCodeByIndustryName($industryName)) {
                     $sIndustry .= ',' . $industryKey;
                 }
             }
             if (!empty($sIndustry)) {
                 $aFields['facets'] = 'industry';
                 $aFields['facet'] = 'industry' . $sIndustry;
             }
             $liResults = $oLinkedin->peopleSearch($aFields);
             if (isset($liResults->{'num-results'}) && (int) $liResults->{'num-results'} >= 0) {
                 $tp = SJB_System::getTemplateProcessor();
                 if (empty($sKeywords)) {
                     $tp->assign('liKeywordEmpty', true);
                 }
                 $tp->assign('liResults', $oLinkedin->preparePeopleStructure($liResults));
                 $tp->assign('liNumResults', (int) $liResults->{'num-results'});
                 $tp->assign('linkedinSearchIsAllowed', true);
                 $linkedinPeopleSearch = SJB_Session::getValue('linkedinPeopleSearch');
                 $tp->assign('linkedinSearch', !empty($linkedinPeopleSearch) && 'no' === $linkedinPeopleSearch && !empty($_GET['searchId']) ? 'notChecked' : 'no');
                 $tp->display('linkedin_people_search_results.tpl');
             }
         } else {
             SJB_Session::setValue('linkedinPeopleSearch', 'no');
         }
     }
 }
예제 #8
0
 public function execute()
 {
     if (class_exists('SJB_SocialPlugin') && in_array('linkedin', SJB_SocialPlugin::getAvailablePlugins()) && SJB_Settings::getSettingByName('li_companyProfileWidget')) {
         $companyName = SJB_Request::getVar('companyName');
         if ($companyName) {
             $tp = SJB_System::getTemplateProcessor();
             $tp->assign('companyName', $companyName);
             $tp->display('linkedin_profile_widget.tpl');
         }
     }
 }
예제 #9
0
 public function execute()
 {
     if (class_exists('SJB_SocialPlugin') && in_array('linkedin', SJB_SocialPlugin::getAvailablePlugins()) && SJB_Settings::getSettingByName('li_allowPeopleSearch')) {
         if ('Resume' == $_REQUEST['listing_type_id'] && SJB_SocialPlugin::getNetwork() == 'linkedin') {
             $tp = SJB_System::getTemplateProcessor();
             $tp->assign('linkedinSearchIsAllowed', true);
             $tp->assign('linkedinSearch', !empty($_SESSION['linkedinPeopleSearch']) && 'no' === $_SESSION['linkedinPeopleSearch'] && !empty($_GET['searchId']) ? 'notChecked' : 'no');
             $tp->display('linkedin_people_search_form.tpl');
         }
     }
 }
 public function execute()
 {
     if (class_exists('SJB_SocialPlugin') && in_array('linkedin', SJB_SocialPlugin::getAvailablePlugins()) && SJB_Settings::getSettingByName('li_memberProfileWidget')) {
         $userSID = SJB_Request::getInt('profileSID', '');
         if ($userSID && ($profilePublicUrl = SJB_SocialPlugin::getProfilePublicUrlByProfileID($userSID))) {
             $tp = SJB_System::getTemplateProcessor();
             $tp->assign('inPublicUrl', $profilePublicUrl);
             $tp->display('linkedin_member_profile_widget.tpl');
         }
     }
 }
 public function execute()
 {
     if (class_exists('SJB_SocialPlugin') && in_array('linkedin', SJB_SocialPlugin::getAvailablePlugins()) && SJB_Settings::getSettingByName('li_companyInsiderWidget')) {
         $companyName = str_replace(" ", "-", SJB_Request::getVar('companyName', ''));
         if (!empty($companyName)) {
             $tp = SJB_System::getTemplateProcessor();
             $tp->assign('companyName', $companyName);
             $tp->display('company_insider_widget.tpl');
         }
     }
 }
예제 #12
0
 public function execute()
 {
     $formBuilder = SJB_FormBuilderManager::getFormBuilder();
     if ($formBuilder instanceof SJB_FormBuilder) {
         $tp = $formBuilder->getChargedTemplateProcessor();
         $tp->assign('fields_inactive', $formBuilder->getInactiveFields());
         $tp->assign('defaultCountry', SJB_Settings::getSettingByName('default_country'));
         $tp->assign('listingTypeID', $formBuilder->getListingTypeID());
         $tp->assign('mode', $formBuilder->getBuilderType());
         $tp->display('form_builder_in.tpl');
     }
 }
예제 #13
0
 public static function getTaxInfoByCountryAndState($countrySID, $stateSID)
 {
     if (SJB_Settings::getSettingByName('enable_taxes')) {
         $tax_info = SJB_DB::query("SELECT `sid` ,`tax_name` ,`price_includes_tax` , `tax_rate`,\n\t\t\t\tIF(`Country`= ?s and `State`= ?s and `Country` is not null and `State` is not null, 1,\n\t\t\t\t\tIF(`Country`= ?s and `Country` is not null and `State` = '', 2,\n\t\t\t\t\t\tIF(`Country`= '' and `State` = '', 3, 4))) as `param`\n\t\t\t    FROM `taxes` WHERE `active` = 1 and (`Country`= ?s and `State`= ?s and `Country` is not null and `State` is not null\n\t\t\t    or `Country`= ?s and `Country` is not null and `State` = '' or `Country`= '' and `State` = '')\n\t\t\t    ORDER BY `param` LIMIT 1;", $countrySID, $stateSID, $countrySID, $countrySID, $stateSID, $countrySID);
         $tax_info = array_pop($tax_info);
         if (count($tax_info)) {
             return $tax_info;
         } else {
             return array();
         }
     } else {
         return array();
     }
 }
예제 #14
0
 public function execute()
 {
     if (class_exists('SJB_SocialPlugin') && in_array('linkedin', SJB_SocialPlugin::getAvailablePlugins()) && SJB_Settings::getSettingByName('li_allowShareJobs')) {
         if (SJB_SocialPlugin::getProfileObject()) {
             $listing = SJB_Request::getVar('listing');
             $tp = SJB_System::getTemplateProcessor();
             $tp->assign('articleUrl', urlencode(SJB_System::getSystemSettings('SITE_URL') . '/display-job/' . $listing['id'] . '/'));
             $tp->assign('articleTitle', urlencode($listing['Title']));
             $tp->assign('articleSummary', urlencode($listing['JobDescription']));
             $tp->assign('articleSource', urlencode(SJB_System::getSettingByName('site_title')));
             $tp->display('linkedin_share_button.tpl');
         }
     }
 }
예제 #15
0
 public function execute()
 {
     $type = 'subadmin';
     $role = SJB_SubAdmin::getSubAdminSID();
     // get new defined permissions for notification letter
     $acl = SJB_SubAdminAcl::getInstance();
     $permissions = SJB_SubAdminAcl::getAllPermissions($type, $role);
     $resources = $acl->getResources();
     SJB_SubAdminAcl::mergePermissionsWithResources($resources, $permissions);
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('permissions', $resources);
     $tp->assign('admin_email', SJB_Settings::getSettingByName('notification_email'));
     $tp->display('../miscellaneous/subadmin-error.tpl');
 }
예제 #16
0
 /**
  * Constructor explains our requirements to Smarty
  *
  * @param SJB_TemplateSupplier $templatesupplier instatance of SJB_TemplateSupplier class
  * @return SJB_TemplateProcessor
  */
 function __construct($templatesupplier)
 {
     $this->htmlTagConverter = SJB_ObjectMother::createHTMLTagConverterInArray();
     $this->compile_check = true;
     $this->module_name = $templatesupplier->getModuleName();
     parent::__construct();
     $this->error_reporting = E_ALL ^ E_NOTICE;
     $this->setCompileDir(SJB_System::getSystemSettings('COMPILED_TEMPLATES_DIR') . SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') . '/' . $templatesupplier->getTheme());
     if (!@is_dir($this->getCompileDir())) {
         @mkdir($this->getCompileDir(), 0777, true);
     }
     $this->setCacheDir(SJB_System::getSystemSettings('COMPILED_TEMPLATES_DIR') . '/smarty_cache');
     if (!@is_dir($this->getCacheDir())) {
         @mkdir($this->getCacheDir(), 0777, true);
     }
     /**
      * Check for 'cache_control_file.cache' in compile dir. If exists - clear compile dir.
      * Then if 'highlight_templates' mode is ON, and user is 'admin' - create 'cache_control_file'.
      */
     $cacheControlFile = $this->compile_dir . '/cache_control_file.cache';
     if (file_exists($cacheControlFile)) {
         $this->clearAllCache();
         $this->clearCompiledTemplate();
     }
     if (SJB_Settings::getSettingByName('highlight_templates') == 1 && SJB_Request::getVar('admin_mode', false, 'COOKIE')) {
         $fp = fopen($cacheControlFile, 'w');
         fclose($fp);
     }
     /////////////////////////
     $this->registerPlugin('function', 'module', array(&$this, 'module'));
     $this->registerPlugin('function', 'hidden_form_fields', array(&$this, 'hidden_form_fields'));
     $this->registerPlugin('function', 'url', array(&$this, 'get_module_function_url'));
     $this->registerPlugin('function', 'event', array(&$this, 'dispatch_event'));
     $currencyFormatter = new SJB_CurrencyFormatter();
     $this->registerPlugin('function', 'currencyFormat', array($currencyFormatter, 'currencyFormat'));
     $this->registerPlugin('function', 'locationFormat', 'SJB_LocationManager::locationFormat');
     /////////////////////////
     $this->registerPlugin('block', 'title', array(&$this, '_tpl_title'));
     $this->registerPlugin('block', 'keywords', array(&$this, '_tpl_keywords'));
     $this->registerPlugin('block', 'description', array(&$this, '_tpl_description'));
     $this->registerPlugin('block', 'head', array(&$this, '_tpl_head'));
     $this->registerPlugin('block', 'breadcrumbs', array(&$this, '_tpl_breadcrumbs'));
     $this->registerFilter('pre', array(&$this, '_replace_translation_alias'));
     $this->registerPlugin('block', 'tr', array(&$this, 'translate'));
     $templatesupplier->registerResources($this);
     $this->templateSupplier = $templatesupplier;
     $this->registerPlugin('function', 'set_token_field', array(&$this, 'tpl_set_token_field'));
     $this->registerGlobalVariables();
 }
예제 #17
0
 public static function writeToLog($payment, $result = false)
 {
     if (SJB_Settings::getSettingByName('notification_payment') != $payment->recipient_payment) {
         $username = SJB_UserManager::getUserSIDbyPayment($payment->recipient_payment);
     }
     if (!$username) {
         $admin = SJB_SubAdminManager::getUserSIDbyPayment($payment->recipient_payment);
         $admin = $admin ? $admin : 'admin';
     }
     $status = 'Delivered';
     if (!$result) {
         $status = 'Undelivered';
     }
     SJB_DB::query("INSERT INTO `payment_log` (`date`, `gateway`, `message`, `status`) VALUES (NOW(), ?s, ?s, ?s, ?s, ?s, ?s)", $payment->gateway, $payment->text, $status);
 }
예제 #18
0
 /**
  * @param  string $network
  * @param  int    $listingSID
  * @return bool
  */
 private static function isNetworkAllowed($network, $listingSID)
 {
     $allowed = false;
     if (SJB_Settings::getSettingByName("enable_job_sharing_for_users_{$network}")) {
         $permission = SJB_ListingDBManager::getPermissionByListingSid('post_jobs_on_social_networks', $listingSID);
         if ($permission == 'deny') {
             $allowed = false;
         } else {
             if ($permission == 'allow' || SJB_Acl::getInstance()->isAllowed('post_jobs_on_social_networks')) {
                 $allowed = true;
             }
         }
     }
     return $allowed;
 }
예제 #19
0
 /**
  * 
  * @param SJB_PageConfig $page_config
  */
 public static function getPage($page_config)
 {
     SJB_System::setPageTitle($page_config->getPageTitle());
     SJB_System::setGlobalTemplateVariable('user_page_uri', $page_config->getPageUri());
     SJB_System::setPageKeywords($page_config->getPageKeywords());
     SJB_System::setPageDescription($page_config->getPageDescription());
     if ($page_config->getMainContentFunction() == 'add_listing') {
         $passed_parameters_via_uri = SJB_Request::getVar('passed_parameters_via_uri', false);
         if ($passed_parameters_via_uri) {
             $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
             if (isset($passed_parameters_via_uri[2])) {
                 $page_config->setMainContentFunction('add_listing_step');
             }
         }
     }
     $maincontent = SJB_System::executeFunction($page_config->getMainContentModule(), $page_config->getMainContentFunction(), $page_config->getParameters(), $page_config->getPageUri());
     if ($page_config->hasRawOutput()) {
         return $maincontent;
     }
     $page_templates_set_name = SJB_System::getSystemSettings('PAGE_TEMPLATES_MODULE_NAME');
     $template_supplier = new SJB_TemplateSupplier($page_templates_set_name);
     $tp = new SJB_TemplateProcessor($template_supplier);
     // assign 'highlight_templates' variable to main or index template
     if (SJB_Settings::getSettingByName('highlight_templates') == 1 && SJB_Request::getVar('admin_mode', false, 'COOKIE')) {
         $tp->assign('highlight_templates', true);
     }
     if ($errors = SJB_Error::getErrorContent()) {
         SJB_FlashMessages::getInstance()->addWarning($errors);
     }
     $tp->assign('MAIN_CONTENT', $maincontent);
     $tp->registerGlobalVariables();
     $tp->assign('sjb_version', SJB_System::getSystemSettings('SJB_VERSION'));
     $template = $page_config->getPageTemplate();
     $template_supplier->addContainerTemplate($template);
     if (SJB_Request::isAjax()) {
         $template = SJB_System::getSettingByName('default_page_template_by_http');
     } elseif (SJB_FormBuilderManager::getIfBuilderModeIsSet()) {
         $template = 'index_b.tpl';
     } else {
         if (empty($template)) {
             $template = SJB_Settings::getSettingByName('DEFAULT_PAGE_TEMPLATE');
         }
     }
     return $tp->fetch($template);
 }
예제 #20
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);
 }
예제 #21
0
 public static function writeToLog($email, $result = false, $error_msg = false)
 {
     $username = '';
     $admin = '';
     if (SJB_Settings::getSettingByName('notification_email') != $email->recipient_email) {
         $username = SJB_UserManager::getUserSIDbyEmail($email->recipient_email);
     }
     if (!$username) {
         $admin = SJB_SubAdminManager::getUserSIDbyEmail($email->recipient_email);
         $admin = $admin ? $admin : 'admin';
     }
     $status = 'Delivered';
     if (!$result) {
         $status = 'Undelivered';
     } elseif ('Not Sent' === $result) {
         $status = $result;
     }
     SJB_DB::query("INSERT INTO `email_log` (`date`, `subject`, `email`, `message`, `username`, `admin`, `status`, `error_msg`) VALUES (NOW(), ?s, ?s, ?s, ?s, ?s, ?s, ?s)", $email->subject, $email->recipient_email, $email->text, $username, $admin, $status, $error_msg);
 }
예제 #22
0
 public static function subscribeUser($user = '', $email = '', $name = '', &$error = '')
 {
     if (!empty($user)) {
         $email = $user->getUserEmail();
         $name = $user->getUserName();
     }
     $apikey = SJB_Settings::getSettingByName('mc_apikey');
     $listId = SJB_Settings::getSettingByName('mc_listId');
     $api = new MCAPI($apikey);
     $merge_vars = array('FNAME' => $name);
     // By default this sends a confirmation email - you will not see new members
     // until the link contained in it is clicked!
     $api->listSubscribe($listId, $email, $merge_vars);
     if ($api->errorCode) {
         $error = $api->errorMessage;
         return false;
     } else {
         return true;
     }
 }
예제 #23
0
파일: news.php 프로젝트: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $i18n = SJB_I18N::getInstance();
     $lang = $i18n->getLanguageData($i18n->getCurrentLanguage());
     $langId = $lang['id'];
     // params
     $count = SJB_Settings::getSettingByName('number_news_on_main_page');
     $result = SJB_NewsManager::getLatestNews($count, $langId, SJB_Settings::getSettingByName('main_page_news_display_mode'));
     $articles = array();
     foreach ($result as $article) {
         $articles[] = SJB_NewsManager::createTemplateStructureForNewsArticle($article);
     }
     // clear unnecessary data
     unset($result);
     $tp->assign('count', $count);
     $tp->assign('articles_count', count($articles));
     $tp->assign('articles', $articles);
     $tp->display('news.tpl');
 }
예제 #24
0
 /**
  * @param array  $criteria
  * @param string $settingName
  * @return string
  */
 protected static function getLocation(array $criteria, $settingName = '')
 {
     $location = isset($criteria['Location']['location']['value']) ? $criteria['Location']['location']['value'] : '';
     $locationInfo['zipCode'] = isset($criteria['Location_ZipCode']['geo']['location']) ? $criteria['Location_ZipCode']['geo']['location'] : '';
     if (isset($criteria['Location_City']['like'])) {
         $locationInfo['city'] = $criteria['Location_City']['like'];
     } else {
         if (isset($criteria['Location_City']['multi_like_and'][0])) {
             $locationInfo['city'] = $criteria['Location_City']['multi_like_and'][0];
         }
     }
     if (isset($criteria['Location_State']['multi_like'])) {
         foreach ($criteria['Location_State']['multi_like'] as $stateSID) {
             if (!empty($stateSID)) {
                 $stateInfo = SJB_StatesManager::getStateInfoBySID($stateSID);
                 $locationInfo['state'] = !empty($stateInfo['state_code']) ? $stateInfo['state_code'] : '';
             }
         }
     }
     $result = '';
     if (!empty($location)) {
         $result = $location;
     }
     foreach ($locationInfo as $value) {
         if (!empty($value) && $value != $location) {
             if (!empty($result)) {
                 $result .= ",{$value}";
             } else {
                 $result = $value;
             }
         }
     }
     if (!empty($settingName) && empty($result)) {
         $result = SJB_Settings::getSettingByName($settingName);
     }
     if (!empty($result)) {
         $result = trim($result);
         $result = urlencode($result);
     }
     return empty($result) ? '' : $result;
 }
예제 #25
0
 public function execute()
 {
     $listingTypeID = SJB_Request::getVar('type');
     if (class_exists('SJB_SocialPlugin') && in_array('facebook', SJB_SocialPlugin::getAvailablePlugins()) && SJB_Settings::getSettingByName('fb_like' . $listingTypeID)) {
         $listing = SJB_Request::getVar('listing', array());
         $listingID = isset($listing['id']) ? $listing['id'] : 0;
         $tp = SJB_System::getTemplateProcessor();
         switch ($listingTypeID) {
             case 'Job':
                 $tp->assign('url', SJB_System::getSystemSettings('SITE_URL') . '/display-job/' . $listingID . '/');
                 break;
             case 'Resume':
                 $tp->assign('url', SJB_System::getSystemSettings('SITE_URL') . '/display-resume/' . $listingID . '/');
                 break;
             default:
                 $tp->assign('url', SJB_System::getSystemSettings('SITE_URL') . '/display-listing/' . $listingID . '/');
                 break;
         }
         $tp->display('facebook_like_button.tpl');
     }
 }
예제 #26
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action');
     $template = 'task_scheduler_settings.tpl';
     $isPseudoCronEnabled = intval(SJB_Settings::getSettingByName('isPseudoCronEnabled')) == 1;
     if (SJB_Request::getVar('command', null, 'post') == 'manage-pseudo-cron') {
         SJB_Settings::updateSetting('isPseudoCronEnabled', SJB_Request::getVar('isEnabled', 'off', 'post') == 'on' ? '1' : '0');
         SJB_Settings::updateSetting('numberOfPageViewsToExecCronIfExceeded', SJB_Request::getVar('numberOfPageViewsToExecCronIfExceeded', null, 'post'));
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/task-scheduler-settings');
     }
     $tp->assign('isPseudoCronEnabled', $isPseudoCronEnabled);
     $numberOfPageViewsToExecCronIfExceeded = intval(SJB_Settings::getSettingByName('numberOfPageViewsToExecCronIfExceeded'));
     $tp->assign('cronPath', SJB_BASE_DIR . 'cron/index.php');
     $tp->assign('numberOfPageViewsToExecCronIfExceeded', $numberOfPageViewsToExecCronIfExceeded);
     if ($action != 'log_view') {
         $last_executed_date = SJB_System::getSettingByName('task_scheduler_last_executed_date');
         $expired_listings_id = SJB_ListingManager::getExpiredListingsSID();
         $count_expired_listings = count($expired_listings_id);
         $expired_contracts_id = SJB_ContractManager::getExpiredContractsID();
         $count_expired_contracts = count($expired_contracts_id);
         $res = SJB_DB::query("SELECT * FROM `task_scheduler_log` ORDER BY `sid` DESC LIMIT 1");
         $tp->assign('last_executed_date', $last_executed_date);
         $tp->assign('task_scheduler_log', array_pop($res));
     } else {
         $log_file = array();
         $res = SJB_DB::query("SELECT `log_text` FROM `task_scheduler_log` ORDER BY `sid` DESC LIMIT 30");
         foreach ($res as $record) {
             $text = $record['log_text'];
             if ($text) {
                 $log_file[] = $text;
             }
         }
         $tp->assign('log_content', $log_file);
         $template = 'task_scheduler_log_view.tpl';
     }
     $tp->display($template);
 }
예제 #27
0
파일: filters.php 프로젝트: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', '');
     $htmltags = SJB_Settings::getSettingByName('htmltags');
     $htmltags = array_keys(unserialize($htmltags));
     if ($action == 'Save') {
         $tags = SJB_Request::getVar('tags', false);
         $filter = '';
         if ($tags) {
             foreach ($tags as $key => $val) {
                 if ($key == 'br') {
                     $filter .= "<{$key}>,<{$key}/>,<{$key} />,";
                 } else {
                     $filter .= "<" . $key . '>,';
                 }
             }
             if ($filter != '') {
                 $filter = substr($filter, 0, -1);
             }
         }
         SJB_Settings::updateSetting("htmlFilter", $filter);
     }
     $savedFilters = SJB_Settings::getSettingByName('htmlFilter');
     $savedFilters = $savedFilters ? explode(',', $savedFilters) : $savedFilters;
     $savedFilters = !empty($savedFilters) ? str_replace('<', '', str_replace('>', '', $savedFilters)) : array();
     $savedFiltersArray = array();
     $checkStyle = !empty($savedFilters) ? "checked = checked" : "";
     foreach ($savedFilters as $val) {
         $savedFiltersArray[$val] = 'checked';
     }
     $tp->assign('htmltags', $htmltags);
     $tp->assign('checkStyle', $checkStyle);
     $tp->assign('rowsInColumn', round(count($htmltags) / 2) + 1);
     $tp->assign('savedFilters', $savedFiltersArray);
     $tp->display('filters.tpl');
 }
예제 #28
0
 public function execute()
 {
     $listing_id = isset($_REQUEST['listing_id']) ? $_REQUEST['listing_id'] : null;
     $template_processor = SJB_System::getTemplateProcessor();
     if (isset($_REQUEST['action'])) {
         $action = strtolower($_REQUEST['action']);
         $rating_id = isset($_REQUEST['rating_id']) ? $_REQUEST['rating_id'] : null;
         $comment_ids = array();
         if (isset($_REQUEST['rating']) && is_array($_REQUEST['rating'])) {
             $rating_ids = array_keys($_REQUEST['rating']);
         } else {
             $rating_ids = array($rating_id);
         }
         $listing_id = SJB_Rating::getListingSIDByRatingSID($rating_ids[0]);
         $listing_id = $listing_id[0]['listing_id'];
         switch ($action) {
             case 'delete':
                 foreach ($rating_ids as $rating_id) {
                     SJB_Rating::deleteRating($rating_id);
                 }
                 break;
         }
         header('Location: ' . SJB_System::getSystemSettings('SITE_URL') . '/listing-rating/?listing_id=' . $listing_id);
         exit;
     }
     if (!is_null($listing_id) && SJB_Settings::getSettingByName('show_rates') == 1) {
         $rating = SJB_Rating::getRatingListing($listing_id);
         $listingInfo = SJB_ListingManager::getListingInfoBySID($listing_id);
         $listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listingInfo['listing_type_sid']);
         $template_processor->assign('rating', $rating);
         $template_processor->assign('listing_id', $listing_id);
         $template_processor->assign('rating_num', count($rating));
         $template_processor->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo));
         $template_processor->display('listing_rating.tpl');
     }
 }
예제 #29
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default');
     $tp->assign('theme', $theme);
     $errors = array();
     $message = '';
     $alternativeText = SJB_Request::getVar('logoAlternativeText', '');
     switch (SJB_Request::getVar('action', '')) {
         case 'save':
             if (isset($_FILES['logo']['error'])) {
                 if ($_FILES['logo']['error'] == UPLOAD_ERR_OK) {
                     if (SJB_System::getSystemSettings('isDemo')) {
                         $errors[] = 'NOT_ALLOWED_IN_DEMO';
                     } else {
                         $themePath = SJB_TemplatePathManager::getAbsoluteThemePath($theme);
                         if (move_uploaded_file($_FILES['logo']['tmp_name'], "{$themePath}main/images/logo.png")) {
                             $message = 'Logo has been uploaded successfully';
                         }
                     }
                 } else {
                     switch ($_FILES['logo']['error']) {
                         case UPLOAD_ERR_INI_SIZE:
                             $errors[] = 'File size exceeds system limit. Please check the file size limits on your hosting or upload another file.';
                             break;
                         case UPLOAD_ERR_FORM_SIZE:
                             $errors[] = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
                             break;
                         case UPLOAD_ERR_PARTIAL:
                             $errors[] = 'The uploaded file was only partially uploaded';
                             break;
                         case UPLOAD_ERR_NO_FILE:
                             // Разрешим изменять текст без аплоада лого
                             break;
                         case UPLOAD_ERR_NO_TMP_DIR:
                             $errors[] = 'Missing a temporary folder';
                             break;
                         case UPLOAD_ERR_CANT_WRITE:
                             $errors[] = 'Failed to write file to disk';
                             break;
                         default:
                             $errors[] = 'File upload error';
                     }
                     if ($alternativeText == SJB_Settings::getSettingByName('logoAlternativeText')) {
                         $errors[] = 'Upload a logo or enter alternative text';
                     }
                 }
             }
             if (SJB_Settings::getSettingByName('logoAlternativeText') === false) {
                 SJB_Settings::addSetting('logoAlternativeText', $alternativeText);
             } else {
                 if ($alternativeText != SJB_Settings::getSettingByName('logoAlternativeText')) {
                     SJB_Settings::updateSetting('logoAlternativeText', $alternativeText);
                     if (!$message) {
                         $message = 'Alternative text has been updated successfully';
                     } else {
                         $message = 'Logo and Alternative text has been uploaded successfully';
                     }
                 }
             }
             break;
     }
     $tp->assign('errors', $errors);
     $tp->assign('message', $message);
     $tp->assign('uploadMaxFilesize', SJB_UploadFileManager::getIniUploadMaxFilesize());
     $tp->assign('logoAlternativeText', SJB_Request::getVar('logoAlternativeText', SJB_Settings::getSettingByName('logoAlternativeText')));
     $tp->display('upload_logo.tpl');
 }
예제 #30
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $currentUser = SJB_UserManager::getCurrentUser();
     $action = SJB_Request::getVar('action', false);
     $error = SJB_Request::getVar('error', false);
     $applyPromoCode = SJB_Request::getVar('applyPromoCode', false);
     $action = $applyPromoCode ? 'applyPromoCode' : $action;
     $numberOfListings = SJB_Request::getVar('number_of_listings');
     $productInfo = null;
     $errors = array();
     switch ($action) {
         case 'delete':
             $itemSID = SJB_Request::getVar('item_sid', 0, false, 'int');
             if (SJB_UserManager::isUserLoggedIn()) {
                 if (SJB_Settings::getSettingByName('allow_to_post_before_checkout') == true) {
                     $this->findCheckoutedListingsByProduct($itemSID, $currentUser->getSID());
                 }
                 SJB_ShoppingCart::deleteItemFromCartBySID($itemSID, $currentUser->getSID());
             } else {
                 $products = SJB_Session::getValue('products');
                 if (!empty($products[$itemSID])) {
                     unset($products[$itemSID]);
                     SJB_Session::setValue('products', $products);
                 }
             }
             break;
         case 'checkout':
             if (SJB_UserManager::isUserLoggedIn()) {
                 $products = SJB_Session::getValue('products');
                 $products = $products ? $products : array();
                 $trialProduct = false;
                 foreach ($products as $product) {
                     if (!empty($product['product_info'])) {
                         $productInfo = unserialize($product['product_info']);
                         if ($currentUser->getUserGroupSID() != $productInfo['user_group_sid']) {
                             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/shopping-cart/?error=user_group");
                         } elseif (in_array($productInfo['sid'], $currentUser->getTrialProductSIDByUserSID())) {
                             $trialProduct = true;
                         } else {
                             $product = new SJB_Product($productInfo, $productInfo['product_type']);
                             $number_of_listings = !empty($productInfo['number_of_listings']) ? $productInfo['number_of_listings'] : 1;
                             $product->setNumberOfListings($number_of_listings);
                             $productInfo['price'] = $product->getPrice();
                             SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUser->getSID());
                         }
                     }
                 }
                 SJB_Session::unsetValue('products');
                 if ($trialProduct) {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/shopping-cart/?error=trial_product");
                 } elseif ($products) {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/shopping-cart/");
                 }
                 $products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID());
                 if (empty($products)) {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/my-account/");
                 }
                 $isRecurring = false;
                 $subTotal = 0;
                 foreach ($products as $key => $product) {
                     $productInfo = unserialize($product['product_info']);
                     if (!empty($productInfo['recurring'])) {
                         $isRecurring = true;
                     }
                     if (!empty($productInfo['pricing_type']) == 'volume_based' && isset($numberOfListings[$productInfo['sid']][$product['sid']])) {
                         $productInfo['number_of_listings'] = $numberOfListings[$productInfo['sid']][$product['sid']];
                         $productObj = new SJB_Product($productInfo, $productInfo['product_type']);
                         $number_of_listings = !empty($productInfo['number_of_listings']) ? $productInfo['number_of_listings'] : 1;
                         $productObj->setNumberOfListings($number_of_listings);
                         $productInfo['price'] = $productObj->getPrice();
                         if (!empty($productInfo['code_info'])) {
                             SJB_PromotionsManager::applyPromoCodeToProduct($productInfo, $productInfo['code_info']);
                         }
                         SJB_ShoppingCart::updateItemBySID($product['sid'], $productInfo);
                     }
                     $subTotal += $productInfo['price'];
                     $products[$key] = $productInfo;
                     $products[$key]['item_sid'] = $product['sid'];
                     $products[$key]['product_info'] = serialize($productInfo);
                 }
                 $index = 1;
                 $items = array();
                 $codeInfo = array();
                 if ($isRecurring) {
                     $tp->assign('confirmation', 1);
                     $tp->assign('sub_total_price', $subTotal);
                 } else {
                     foreach ($products as $product) {
                         $product_info = unserialize($product['product_info']);
                         SJB_PromotionsManager::preparePromoCodeInfoByProductPromoCodeInfo($product, $product['code_info']);
                         $qty = !empty($product_info['number_of_listings']) ? $product_info['number_of_listings'] : null;
                         $items['products'][$index] = $product_info['sid'];
                         if ($qty > 0) {
                             $items['price'][$index] = round($product['price'] / $qty, 2);
                         } else {
                             $items['price'][$index] = round($product['price'], 2);
                         }
                         $items['amount'][$index] = $product['price'];
                         $items['qty'][$index] = $qty;
                         if (isset($product['custom_item'])) {
                             $items['custom_item'][$index] = $product['custom_item'];
                         } else {
                             $items['custom_item'][$index] = "";
                         }
                         if (isset($product['custom_info'])) {
                             $items['custom_info'][$index] = $product['custom_info'];
                         } else {
                             $items['custom_info'][$index]['shoppingCartRecord'] = $product['item_sid'];
                         }
                         if ($product_info['product_type'] == 'banners' && !empty($product_info['banner_info'])) {
                             $items['custom_info'][$index]['banner_info'] = $product_info['banner_info'];
                         }
                         $index++;
                         SJB_PromotionsManager::preparePromoCodeInfoByProductPromoCodeInfo($product_info, $codeInfo);
                     }
                     $subUserInfo = $currentUser->getSubuserInfo();
                     $userSID = isset($subUserInfo['sid']) ? $subUserInfo['sid'] : $currentUser->getSID();
                     $invoiceSID = SJB_InvoiceManager::generateInvoice($items, $userSID, $subTotal, SJB_System::getSystemSettings('SITE_URL') . "/create-contract/");
                     SJB_PromotionsManager::addCodeToHistory($codeInfo, $invoiceSID, $userSID);
                     if ($subTotal <= 0) {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/create-contract/?invoice_sid=' . $invoiceSID);
                     } else {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/payment-page/?invoice_sid=" . $invoiceSID);
                     }
                 }
             }
             break;
         case 'applyPromoCode':
             $promotionCode = SJB_Request::getVar('promotion_code', false);
             if ($promotionCode) {
                 if (SJB_UserManager::isUserLoggedIn()) {
                     $products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID());
                 } else {
                     $products = SJB_Session::getValue('products');
                     $products = $products ? $products : array();
                     krsort($products);
                 }
                 $allowShoppingItems = array();
                 $productSIDs = array();
                 foreach ($products as $product) {
                     $productInfo = unserialize($product['product_info']);
                     if (!isset($productInfo['code_info'])) {
                         if (isset($productInfo['custom_info'])) {
                             $allowShoppingItems[] = $product['sid'];
                             $productSIDs[] = $productInfo['custom_info']['productSid'];
                         } else {
                             $allowShoppingItems[] = $product['sid'];
                             $productSIDs[] = $productInfo['sid'];
                         }
                     } else {
                         $appliedPromoCode = $productInfo['code_info'];
                     }
                 }
                 if ($codeInfo = SJB_PromotionsManager::checkCode($promotionCode, $productSIDs)) {
                     $productSIDs = $codeInfo['product_sid'] ? explode(',', $codeInfo['product_sid']) : false;
                     $appliedProducts = array();
                     $codeValid = false;
                     foreach ($products as $key => $product) {
                         $productInfo = unserialize($product['product_info']);
                         if ($productInfo['sid'] != '-1') {
                             $productSid = $productInfo['sid'];
                         } else {
                             $productSid = $productInfo['custom_info']['productSid'];
                         }
                         if ($productSIDs && in_array($productSid, $productSIDs) && $allowShoppingItems && in_array($product['sid'], $allowShoppingItems)) {
                             $currentUsesCount = SJB_PromotionsManager::getUsesCodeBySID($codeInfo['sid']);
                             if ($codeInfo['maximum_uses'] != 0 && $codeInfo['maximum_uses'] > $currentUsesCount || $codeInfo['maximum_uses'] == 0) {
                                 $codeValid = true;
                                 SJB_PromotionsManager::applyPromoCodeToProduct($productInfo, $codeInfo);
                                 $appliedProducts[] = $productInfo;
                                 if (SJB_UserManager::isUserLoggedIn()) {
                                     SJB_ShoppingCart::updateItemBySID($product['sid'], $productInfo);
                                 } else {
                                     $products[$key]['product_info'] = serialize($productInfo);
                                     SJB_Session::setValue('products', $products);
                                 }
                             }
                         }
                     }
                     if (!$codeValid) {
                         $errors['NOT_VALID'] = 'Invalid promotion code';
                         unset($promotionCode);
                     }
                     $tp->assign('applied_products', $appliedProducts);
                     $tp->assign('code_info', $codeInfo);
                 } else {
                     $errors['NOT_VALID'] = 'Invalid promotion code';
                 }
                 if (isset($promotionCode) && isset($appliedPromoCode)) {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/shopping-cart/');
                 }
             } else {
                 $errors['EMPTY_VALUE'] = 'Promotion code';
             }
             break;
         case 'deletePromoCode':
             if (SJB_UserManager::isUserLoggedIn()) {
                 $products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID());
             } else {
                 $products = SJB_Session::getValue('products');
                 $products = $products ? $products : array();
                 krsort($products);
             }
             foreach ($products as $key => $product) {
                 $productInfo = unserialize($product['product_info']);
                 SJB_PromotionsManager::removePromoCodeFromProduct($productInfo);
                 if (SJB_UserManager::isUserLoggedIn()) {
                     $numberOfListings = is_array($numberOfListings) ? array_pop($numberOfListings) : false;
                     if (is_array($numberOfListings)) {
                         foreach ($numberOfListings as $listingSid => $listingsCount) {
                             if ($listingSid == $product['sid']) {
                                 $productInfo['number_of_listings'] = $listingsCount;
                             }
                         }
                     }
                     SJB_ShoppingCart::updateItemBySID($product['sid'], $productInfo);
                 } else {
                     $products[$key]['product_info'] = serialize($productInfo);
                     SJB_Session::setValue('products', $products);
                 }
             }
             break;
     }
     if (SJB_UserManager::isUserLoggedIn()) {
         $products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID());
         // To display products in shopping cart after user has been registered from shopping cart page
         if (empty($products)) {
             $products = SJB_Session::getValue('products');
             $products = $products ? $products : array();
         }
     } else {
         $products = SJB_Session::getValue('products');
         $products = $products ? $products : array();
         krsort($products);
     }
     $allowShoppingItems = array();
     foreach ($products as $product) {
         $productInfo = unserialize($product['product_info']);
         if (!empty($productInfo['code_info'])) {
             $promotionCode = $productInfo['code_info']['code'];
             $promotionCodeInfo = $productInfo['code_info'];
         } else {
             $allowShoppingItems[] = $product['sid'];
         }
     }
     $promotionCode = isset($promotionCode) ? $promotionCode : '';
     $totalPrice = 0;
     $discountTotalAmount = 0;
     $numberOfListings = SJB_Request::getVar('number_of_listings', false);
     foreach ($products as $key => $product) {
         $productInfo = unserialize($product['product_info']);
         if ($allowShoppingItems && in_array($product['sid'], $allowShoppingItems)) {
             $this->applyPromoCodesToProduct($promotionCode, $productInfo);
             if (SJB_UserManager::isUserLoggedIn()) {
                 SJB_ShoppingCart::updateItemBySID($product['sid'], $productInfo);
             } else {
                 $products[$key]['product_info'] = serialize($productInfo);
             }
         }
         if ($numberOfListings && array_key_exists('number_of_listings', $productInfo) && array_key_exists($productInfo['sid'], $numberOfListings)) {
             $productInfo['number_of_listings'] = $numberOfListings[$productInfo['sid']][$product['sid']];
         }
         $productObj = new SJB_Product($productInfo, $productInfo['product_type']);
         $productExtraInfo = unserialize($productInfo['serialized_extra_info']);
         if (!empty($productInfo['expiration_period']) && !is_numeric($productInfo['expiration_period'])) {
             $productInfo['primaryPrice'] = $productExtraInfo['price'];
             $productInfo['period'] = ucwords($productInfo['expiration_period']);
         } elseif (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based') {
             $volumeBasedPricing = $productInfo['volume_based_pricing'];
             $number_of_listings = !empty($productInfo['number_of_listings']) ? $productInfo['number_of_listings'] : 1;
             $productObj->setNumberOfListings($number_of_listings);
             $productInfo['price'] = $productObj->getPrice();
             $productInfo['primaryPrice'] = $productObj->getPrice();
             $this->applyPromoCodesToProduct($promotionCode, $productInfo);
             $minListings = min($volumeBasedPricing['listings_range_from']);
             $maxListings = max($volumeBasedPricing['listings_range_to']);
             $countListings = array();
             for ($i = $minListings; $i <= $maxListings; $i++) {
                 $countListings[$i]['number_of_listings'] = $i;
                 for ($j = 1; $j <= count($volumeBasedPricing['listings_range_from']); $j++) {
                     if ($i >= $volumeBasedPricing['listings_range_from'][$j] && $i <= $volumeBasedPricing['listings_range_to'][$j]) {
                         $countListings[$i]['price'] = $volumeBasedPricing['price_per_unit'][$j] * $i;
                         $countListings[$i]['primaryPrice'] = $volumeBasedPricing['price_per_unit'][$j] * $i;
                         if (!empty($productInfo['code_info']['type'])) {
                             switch ($productInfo['code_info']['type']) {
                                 case 'percentage':
                                     $countListings[$i]['price'] = round($countListings[$i]['price'] - $countListings[$i]['primaryPrice'] / 100 * $productInfo['code_info']['discount'], 2);
                                     $countListings[$i]['percentPromoAmount'] = round($countListings[$i]['primaryPrice'] - $countListings[$i]['price'], 2);
                                     $countListings[$i]['percentPromoCode'] = $productInfo['code_info']['code'];
                                     break;
                                 case 'fixed':
                                     $countListings[$i]['price'] = round($countListings[$i]['price'] - $productInfo['code_info']['discount'], 2);
                                     break;
                             }
                         }
                     }
                 }
             }
             $productInfo['count_listings'] = $countListings;
         } elseif (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'fixed') {
             $productInfo['primaryPrice'] = $productObj->getPrice();
             $this->applyPromoCodesToProduct($promotionCode, $productInfo);
             unset($productInfo['volume_based_pricing']);
         }
         if (isset($productInfo['code_info'])) {
             if ($productInfo['code_info']['type'] != 'fixed' && isset($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based') {
                 $discountTotalAmount += (double) $productInfo['count_listings'][$productInfo['number_of_listings']]['percentPromoAmount'];
             } else {
                 $discountTotalAmount += (double) $productInfo['code_info']['promoAmount'];
             }
         }
         if (empty($productInfo['volume_based_pricing'])) {
             $productInfo['primaryPrice'] = $productExtraInfo['price'];
             $this->applyPromoCodesToProduct($promotionCode, $productInfo);
             $totalPrice += (double) $productInfo['price'];
         }
         $products[$key] = $productInfo;
         $products[$key]['item_sid'] = $product['sid'];
     }
     if ($currentUser) {
         $taxInfo = SJB_TaxesManager::getTaxInfoByUserSidAndPrice($currentUser->getSID(), $totalPrice);
         $tp->assign('tax', $taxInfo);
     }
     $userGroupID = $productInfo ? SJB_UserGroupDBManager::getUserGroupIDBySID($productInfo['user_group_sid']) : false;
     $tp->assign('promotionCodeAlreadyUsed', $promotionCode && empty($errors));
     if (isset($promotionCodeInfo)) {
         $tp->assign('promotionCodeInfo', $promotionCodeInfo);
     }
     $tp->assign('error', $error);
     $tp->assign('errors', $errors);
     $tp->assign('total_price', $totalPrice);
     $tp->assign('discountTotalAmount', $discountTotalAmount);
     $tp->assign('products', $products);
     $tp->assign('userGroupID', $userGroupID);
     $tp->assign('account_activated', SJB_Request::getVar('account_activated', ''));
     $tp->display('shopping_cart.tpl');
 }