Exemple #1
0
 public function search()
 {
     $action = SJB_Request::getVar('action');
     $period = SJB_Request::getVar('period', array());
     $sorting_field = SJB_Request::getVar('sorting_field', 'usageCount');
     $sorting_order = SJB_Request::getVar('sorting_order', 'DESC');
     $i18n = SJB_I18N::getInstance();
     $statistics = array();
     if ($action) {
         if (!empty($period['from']) && !empty($period['to'])) {
             $from = $i18n->getInput('date', $period['from']);
             $to = $i18n->getInput('date', $period['to']);
             if (strtotime($from) > strtotime($to)) {
                 throw new Exception('SELECTED_PERIOD_IS_INCORRECT');
             }
         }
         $statistics = SJB_Statistics::getPromotionsStatistics($period, $sorting_field, $sorting_order);
     }
     $periodView = array();
     foreach ($period as $key => $value) {
         $periodView[$key] = $i18n->getInput('date', $period[$key]);
     }
     $this->tp->assign('currency', SJB_CurrencyManager::getDefaultCurrency());
     $this->tp->assign('action', $action);
     $this->tp->assign('period', $period);
     $this->tp->assign('periodView', $periodView);
     $this->tp->assign('statistics', $statistics);
     $this->tp->assign('countResult', count($statistics));
     $this->tp->assign('sorting_field', $sorting_field);
     $this->tp->assign('sorting_order', $sorting_order);
 }
Exemple #2
0
 /**
  * @param SJB_GuestAlert $guestAlert
  * @param SJB_TemplateProcessor $tp
  */
 public function saveNewGuestAlert(SJB_GuestAlert $guestAlert, SJB_TemplateProcessor $tp)
 {
     $guestAlert->addDataProperty(serialize($this->criteriaData));
     $guestAlert->addListingTypeIDProperty($this->listingTypeID);
     $guestAlert->save();
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($this->listingTypeID);
     SJB_GuestAlertStatistics::saveEventSubscribed($listingTypeSID, $guestAlert->getSID());
     SJB_Notifications::sendConfirmationEmailForGuest($guestAlert);
     $tp->assign('email', $guestAlert->getAlertEmail());
     $this->template = 'alert_created.tpl';
 }
Exemple #3
0
 public function showSearchForm()
 {
     $guestAlert = new SJB_GuestAlert(array());
     $guestAlert->addSubscriptionDateProperty();
     $guestAlert->addStatusProperty();
     $searchFormBuilder = new SJB_SearchFormBuilder($guestAlert);
     $this->criteriaSaver = new SJB_GuestAlertCriteriaSaver();
     if (isset($_REQUEST['restore'])) {
         $_REQUEST = array_merge($_REQUEST, $this->criteriaSaver->getCriteria());
     }
     $this->criteria = $searchFormBuilder->extractCriteriaFromRequestData($_REQUEST, $guestAlert);
     $searchFormBuilder->setCriteria($this->criteria);
     $searchFormBuilder->registerTags($this->tp);
     $this->tp->display('search_form.tpl');
 }
Exemple #4
0
 private function assignParametersAndDisplayLog($foundPayments)
 {
     $this->templateProcessor->assign('paginationInfo', $this->paginator->getPaginationInfo());
     $this->templateProcessor->assign("found_payments", $foundPayments);
     $this->templateProcessor->assign("searchFields", $this->getFields());
     $this->templateProcessor->display('payment_log.tpl');
 }
Exemple #5
0
 /**
  * Display
  */
 public function display()
 {
     if ($this->isCaptcha) {
         $this->tp->assign('displayMode', SJB_Request::getVar('displayMode', 'label'));
         $this->tp->assign('captcha', array_pop($this->captchaForm->form_fields));
         $this->tp->display('captchaHandle.tpl');
     }
 }
 /**
  * @param int $feedSID
  */
 public function run_manually_check($feedSID)
 {
     $feed = SJB_SocialMedia::getFeedInfoByNetworkIdAndSID($this->networkID, $feedSID);
     $feedManager = SJB_SocialMediaPostingsPublisher::getPublisher($feed, $this->networkID);
     $listingSIDs = $feedManager->getListingsSIDsToPostByFeed();
     $postedToday = $feedManager->getPostedTodayByFeed();
     $this->tp->assign('foundListingsToPost', count($listingSIDs));
     $this->tp->assign('postedToday', $postedToday);
     $this->displayResult($feedManager);
 }
 private function prepareTplVarsForUser($onlyUserGroupID = false)
 {
     $userGroups = SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions();
     foreach ($userGroups as $key => &$userGroupInfo) {
         if ($onlyUserGroupID && $userGroupInfo['key'] != $onlyUserGroupID) {
             unset($userGroups[$key]);
             continue;
         }
         $user = SJB_ObjectMother::createUser(array(), $userGroupInfo['id']);
         $fields = SJB_UserManager::createTemplateStructureForUser($user);
         unset($fields['METADATA']);
         unset($fields['password']);
         $userGroupInfo['fields'] = $this->echoVars($fields);
     }
     $this->tp->assign('userGroups', $userGroups);
 }
Exemple #8
0
 private function showErrorsIfExist()
 {
     if (!empty($GLOBALS[SJB_SocialPlugin::SOCIAL_LOGIN_ERROR])) {
         $this->tp->assign('errors', $GLOBALS[SJB_SocialPlugin::SOCIAL_LOGIN_ERROR]);
         $this->tp->display('../users/errors.tpl');
     }
     if (!empty($GLOBALS[SJB_SocialPlugin::SOCIAL_ACCESS_ERROR])) {
         $this->tp->assign('errors', $GLOBALS[SJB_SocialPlugin::SOCIAL_ACCESS_ERROR]);
         $this->tp->assign('socialNetwork', SJB_SocialPlugin::getNetwork());
         $this->tp->display('../users/errors.tpl');
     }
 }
Exemple #9
0
 function tpl_search($params)
 {
     $oldObject = false;
     if (!empty($params['object'])) {
         $oldObject = $this->object;
         $this->SJB_Form($params['object']);
     }
     $this->template_processor->filterThenAssign('templateParams', $params);
     if ($this->form_fields[$params['property']]['disabled']) {
         $result = $this->tpl_property('display', $params);
     } else {
         $result = $this->tpl_property('search', $params);
     }
     if ($oldObject !== false) {
         $this->SJB_Form($oldObject);
     }
     return $result;
 }
Exemple #10
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);
 }
Exemple #11
0
 /**
  * @param SJB_TemplateProcessor $tp
  * @param $networkSocialMedia
  * @param array $errors
  * @param array $feedInfo
  * @param string $network
  * @param int $sid
  */
 private function checkToken(SJB_TemplateProcessor $tp, $networkSocialMedia, array &$errors, array $feedInfo, $network, $sid)
 {
     if ($networkSocialMedia->approveAccount()) {
         if (empty($feedInfo)) {
             $feedInfo = SJB_SocialMedia::getFeedInfoByNetworkIdAndSID($network, $sid);
         }
         if (!empty($feedInfo)) {
             if (SJB_SocialMedia::isFeedExpired($feedInfo)) {
                 $errors[] = 'TOKEN_EXPIRED';
                 $tp->assign('expired', true);
             } else {
                 $errors[] = 'APPROVE_ACCOUNT';
                 $tp->assign('approveAccount', true);
             }
         }
     }
 }
Exemple #12
0
 /**
  * @param SJB_TemplateProcessor $tp
  */
 function registerTags(SJB_TemplateProcessor &$tp)
 {
     $tp->registerPlugin('block', 'fromName', array(&$this, 'parseLetterFromName'));
     $tp->registerPlugin('block', 'subject', array(&$this, 'parseLetterSubject'));
     $tp->registerPlugin('block', 'message', array(&$this, 'parseLetterMessage'));
 }
Exemple #13
0
 /**
  * @param SJB_TemplateProcessor $tp
  */
 function registerTags($tp)
 {
     $this->template_processor = $tp;
     $tp->registerPlugin('function', "search", array($this, "tpl_search"));
 }
 /**
  * @param SJB_TemplateProcessor $tp
  */
 public function setChargedTemplateProcessor($tp)
 {
     $tp->assign('display_layout', $this->getDisplayLayout($this->listingTypeID));
     parent::setChargedTemplateProcessor($tp);
 }
Exemple #15
0
 /**
  * @param array $aPositions
  * @return bool|mixed|string
  */
 protected function getWorkDisplayPart($aPositions)
 {
     $this->tp->assign('positions', $aPositions);
     $value = $this->tp->fetch('../social/experience.tpl');
     return $value;
 }
Exemple #16
0
    private function runTaskScheduler()
    {
        // Deactivate Expired Listings & Send Notifications
        $listingsExpiredID = SJB_ListingManager::getExpiredListingsSID();
        foreach ($listingsExpiredID as $listingExpiredID) {
            SJB_ListingManager::deactivateListingBySID($listingExpiredID, true);
            $listing = SJB_ListingManager::getObjectBySID($listingExpiredID);
            $listingInfo = SJB_ListingManager::createTemplateStructureForListing($listing);
            if (SJB_UserNotificationsManager::isUserNotifiedOnListingExpiration($listing->getUserSID())) {
                SJB_Notifications::sendUserListingExpiredLetter($listingInfo);
            }
            // notify admin
            SJB_AdminNotifications::sendAdminListingExpiredLetter($listingInfo);
        }
        $listingsDeactivatedID = array();
        if (SJB_Settings::getSettingByName('automatically_delete_expired_listings')) {
            $listingsDeactivatedID = SJB_ListingManager::getDeactivatedListingsSID();
            foreach ($listingsDeactivatedID as $listingID) {
                SJB_ListingManager::deleteListingBySID($listingID);
            }
        }
        SJB_ListingManager::unFeaturedListings();
        SJB_ListingManager::unPriorityListings();
        SJB_Cache::getInstance()->clean('matchingAnyTag', array(SJB_Cache::TAG_LISTINGS));
        /////////////////////////// Send remind notifications about expiration of LISTINGS
        // 1. get user sids and days count of 'remind listing notification' setting = 1 from user_notifications table
        // 2. foreach user:
        //   - get listings with that expiration remind date
        //   - check every listing sid in DB table of sended. If sended - remove from send list
        //   - send notification with listings to user
        //   - write listings sid in DB table of sended notifications
        $notificationData = SJB_UserNotificationsManager::getUsersAndDaysOnListingExpirationRemind();
        foreach ($notificationData as $elem) {
            $userSID = $elem['user_sid'];
            $days = $elem['days'];
            $listingSIDs = SJB_ListingManager::getListingsIDByDaysLeftToExpired($userSID, $days);
            if (empty($listingSIDs)) {
                continue;
            }
            $listingsInfo = array();
            // check listings remind sended
            foreach ($listingSIDs as $key => $sid) {
                if (SJB_ListingManager::isListingNotificationSended($sid)) {
                    unset($listingSIDs[$key]);
                    continue;
                }
                $info = SJB_ListingManager::getListingInfoBySID($sid);
                $listingsInfo[$sid] = $info;
            }
            if (!empty($listingsInfo)) {
                // now only unsended listings we have in array
                // send listing notification
                foreach ($listingSIDs as $sid) {
                    SJB_Notifications::sendRemindListingExpirationLetter($userSID, $sid, $days);
                }
                // write listing id in DB table of sended notifications
                SJB_ListingManager::saveListingIDAsSendedNotificationsTable($listingSIDs);
            }
        }
        // Send Notifications for Expired Contracts
        $contractsExpiredID = SJB_ContractManager::getExpiredContractsID();
        foreach ($contractsExpiredID as $contractExpiredID) {
            $contractInfo = SJB_ContractManager::getInfo($contractExpiredID);
            $productInfo = SJB_ProductsManager::getProductInfoBySID($contractInfo['product_sid']);
            $userInfo = SJB_UserManager::getUserInfoBySID($contractInfo['user_sid']);
            $serializedExtraInfo = unserialize($contractInfo['serialized_extra_info']);
            if (!empty($serializedExtraInfo['featured_profile']) && !empty($userInfo['featured'])) {
                $contracts = SJB_ContractManager::getAllContractsInfoByUserSID($userInfo['sid']);
                $isFeatured = 0;
                foreach ($contracts as $contract) {
                    if ($contract['id'] != $contractExpiredID) {
                        $serializedExtraInfo = unserialize($contract['serialized_extra_info']);
                        if (!empty($serializedExtraInfo['featured'])) {
                            $isFeatured = 1;
                        }
                    }
                }
                if (!$isFeatured) {
                    SJB_UserManager::removeFromFeaturedBySID($userInfo['sid']);
                }
            }
            if (SJB_UserNotificationsManager::isUserNotifiedOnContractExpiration($contractInfo['user_sid'])) {
                SJB_Notifications::sendUserContractExpiredLetter($userInfo, $contractInfo, $productInfo);
            }
            // notify admin
            SJB_AdminNotifications::sendAdminUserContractExpiredLetter($userInfo['sid'], $contractInfo, $productInfo);
            SJB_ContractManager::deleteContract($contractExpiredID, $contractInfo['user_sid']);
        }
        //////////////////////// Send remind notifications about expiration of contracts
        // 1. get user sids and days count of 'remind subscription notification' setting = 1 from user_notifications table
        // 2. foreach user:
        //   - get contracts with that expiration remind date
        //   - check every contract sid in DB table of sended. If sended - remove from send list
        //   - send notification with contracts to user
        //   - write contract sid in DB table of sended contract notifications
        $notificationData = SJB_UserNotificationsManager::getUsersAndDaysOnSubscriptionExpirationRemind();
        foreach ($notificationData as $elem) {
            $userSID = $elem['user_sid'];
            $days = $elem['days'];
            $contractSIDs = SJB_ContractManager::getContractsIDByDaysLeftToExpired($userSID, $days);
            if (empty($contractSIDs)) {
                continue;
            }
            $contractsInfo = array();
            // check contracts sended
            foreach ($contractSIDs as $key => $sid) {
                if (SJB_ContractManager::isContractNotificationSended($sid)) {
                    unset($contractSIDs[$key]);
                    continue;
                }
                $info = SJB_ContractManager::getInfo($sid);
                $info['extra_info'] = !empty($info['serialized_extra_info']) ? unserialize($info['serialized_extra_info']) : '';
                $contractsInfo[$sid] = $info;
            }
            if (!empty($contractsInfo)) {
                // now only unsended contracts we have in array
                // send contract notification
                foreach ($contractSIDs as $sid) {
                    SJB_Notifications::sendRemindSubscriptionExpirationLetter($userSID, $contractsInfo[$sid], $days);
                }
                // write contract id in DB table of sended contract notifications
                SJB_ContractManager::saveContractIDAsSendedNotificationsTable($contractSIDs);
            }
        }
        // delete applications with no employer and job seeker
        $emptyApplications = SJB_DB::query('SELECT `id` FROM `applications` WHERE `show_js` = 0 AND `show_emp` = 0');
        foreach ($emptyApplications as $application) {
            SJB_Applications::remove($application['id']);
        }
        // NEWS
        $expiredNews = SJB_NewsManager::getExpiredNews();
        foreach ($expiredNews as $article) {
            SJB_NewsManager::deactivateItemBySID($article['sid']);
        }
        // LISTING XML IMPORT
        SJB_XmlImport::runImport();
        // UPDATE PAGES WITH FUNCTION EQUAL BROWSE(e.g. /browse-by-city/)
        SJB_BrowseDBManager::rebuildBrowses();
        //-------------------sitemap generator--------------------//
        SJB_System::executeFunction('miscellaneous', 'sitemap_generator');
        // CLEAR `error_log` TABLE
        $errorLogLifetime = SJB_System::getSettingByName('error_log_lifetime');
        $lifeTime = strtotime("-{$errorLogLifetime} days");
        if ($lifeTime > 0) {
            SJB_DB::query('DELETE FROM `error_log` WHERE `date` < ?t', $lifeTime);
        }
        SJB_Settings::updateSetting('task_scheduler_last_executed_date', $this->currentDate);
        $this->tp->assign('expired_listings_id', $listingsExpiredID);
        $this->tp->assign('deactivated_listings_id', $listingsDeactivatedID);
        $this->tp->assign('expired_contracts_id', $contractsExpiredID);
        $this->tp->assign('notified_saved_searches_id', $this->notifiedSavedSearchesSID);
        $schedulerLog = $this->tp->fetch('task_scheduler_log.tpl');
        SJB_HelperFunctions::writeCronLogFile('task_scheduler.log', $schedulerLog);
        SJB_DB::query('INSERT INTO `task_scheduler_log`
			(`last_executed_date`, `notifieds_sent`, `expired_listings`, `expired_contracts`, `log_text`)
			VALUES ( NOW(), ?n, ?n, ?n, ?s)', count($this->notifiedSavedSearchesSID), count($listingsExpiredID), count($contractsExpiredID), $schedulerLog);
        SJB_System::getModuleManager()->executeFunction('social', 'linkedin');
        SJB_System::getModuleManager()->executeFunction('social', 'facebook');
        SJB_System::getModuleManager()->executeFunction('classifieds', 'linkedin');
        SJB_System::getModuleManager()->executeFunction('classifieds', 'facebook');
        SJB_System::getModuleManager()->executeFunction('classifieds', 'twitter');
        SJB_Event::dispatch('task_scheduler_run');
    }
Exemple #17
0
 public function search()
 {
     $search = SJB_Request::getVar('search', false);
     $period = SJB_Request::getVar('period', array());
     $filter = SJB_Request::getVar('filter', false);
     $listingTypeID = SJB_Request::getVar('listingTypeID', false);
     $sorting_field = SJB_Request::getVar('sorting_field', 'total');
     $sorting_order = SJB_Request::getVar('sorting_order', 'DESC');
     $i18n = SJB_I18N::getInstance();
     $statistics = array();
     if ($search) {
         $from = $i18n->getInput('date', $period['from']);
         $to = $i18n->getInput('date', $period['to']);
         if (!empty($period['from']) && !empty($period['to']) && strtotime($from) > strtotime($to)) {
             throw new Exception('SELECTED_PERIOD_IS_INCORRECT');
         }
         if (empty($filter)) {
             throw new Exception('EMPTY_PARAMETER');
         }
         $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
         $statistics = SJB_Statistics::getGuestAlertsStatistics($period, $listingTypeSID, $filter, $sorting_field, $sorting_order);
     }
     $columnTitle = $i18n->gettext('Backend', 'Guest Email');
     $periodView = array();
     foreach ($period as $key => $value) {
         $periodView[$key] = $i18n->getInput('date', $period[$key]);
     }
     $this->tp->assign('filter', $filter);
     $this->tp->assign('search', $search);
     $this->tp->assign('columnTitle', $columnTitle);
     $this->tp->assign('listingTypeID', $listingTypeID);
     $this->tp->assign('period', $period);
     $this->tp->assign('periodView', $periodView);
     $this->tp->assign('statistics', $statistics);
     $this->tp->assign('countResult', count($statistics));
     $this->tp->assign('sorting_field', $sorting_field);
     $this->tp->assign('sorting_order', $sorting_order);
 }