Exemplo n.º 1
0
 public static function init()
 {
     $moduleManager = SJB_System::getModuleManager();
     $miscellaneous = $moduleManager->modules['miscellaneous']['functions'];
     $newMiscellaneous = array('mailchimp' => array('display_name' => 'Subscribe to newsletter', 'script' => 'mailchimp.php', 'type' => 'user', 'access_type' => array('user')));
     $allFunctions = array_merge($miscellaneous, $newMiscellaneous);
     $moduleManager->modules['miscellaneous']['functions'] = $allFunctions;
     if (SJB_Settings::getSettingByName('mc_subscribe_new_users')) {
         SJB_Event::handle('onAfterUserCreated', array('MailChimpPlugin', 'subscribeUser'));
     }
 }
Exemplo n.º 2
0
 /**
  * @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;
 }
Exemplo n.º 3
0
 function SJB_TemplateEditor()
 {
     $module_manager = SJB_System::getModuleManager();
     $this->modules = $module_manager->getModuleInfo();
 }
Exemplo n.º 4
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');
    }
Exemplo n.º 5
0
 public static function getModuleOfCommand($command)
 {
     return SJB_System::getModuleManager()->getModuleOfCommand($command);
 }
Exemplo n.º 6
0
 public function execute()
 {
     // таблица с данными xml-feeds
     $feedsTable = 'listing_feeds';
     $action = SJB_Request::getVar('action', '');
     $feedId = SJB_Request::getVar('feedId', null);
     $feedsArray = SJB_DB::query("SELECT f.*, f.count as count_listings, l.sid as typeId, l.id as type FROM {$feedsTable} as f LEFT JOIN `listing_types` as l ON (l.sid=f.type) ORDER BY f.sid");
     $listingTypes = SJB_DB::query("SELECT * FROM `listing_types`");
     $siteURL = SJB_System::getSystemSettings('SITE_URL');
     $tmp = strrchr(SJB_System::getSystemSettings('SITE_URL'), "/");
     $siteURL = str_replace($tmp, "", $siteURL);
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('listingTypes', $listingTypes);
     // данные для создания файлов-шаблонов для feed
     $module = SJB_System::getModuleManager()->getCurrentModuleAndFunction();
     $templatePath = SJB_TemplatePathManager::getAbsoluteTemplatesPath();
     $filePath = $templatePath . "_system/" . $module[0] . "/";
     switch ($action) {
         case 'add':
             // если была отправка формы
             if (isset($_REQUEST['addFeed']) && $_REQUEST['addFeed'] != '') {
                 $feed_name = $_REQUEST['feed_name'];
                 $feed_template = $_REQUEST['feed_template'];
                 $feed_desc = $_REQUEST['feed_desc'];
                 $typeId = $_REQUEST['typeId'];
                 $count_listings = $_REQUEST['count_listings'];
                 $feed_mimetype = $_REQUEST['mime_type'];
                 // создадим шаблон для нового feed
                 $feed_template = preg_replace("/^feed_|\\.tpl\$/", "", $feed_template);
                 $feed_template = "feed_" . $feed_template . ".tpl";
                 $filePath = $filePath . $feed_template;
                 $fileSystem = new SJB_Filesystem();
                 if (!file_exists($filePath)) {
                     $fileSystem->createFile($filePath);
                 } else {
                     $errors[] = array('code' => 'FILE_ALREADY_EXISTS', 'message' => "Template '{$filePath}' already exists!");
                     $tp->assign('feed', array('name' => $feed_name, 'template' => $feed_template, 'description' => $feed_desc, 'type' => $typeId, 'count_listings' => $count_listings, 'mime_type' => $feed_mimetype));
                     $tp->assign('errors', $errors);
                     $tp->display("add_listing_feed.tpl");
                     break;
                 }
                 SJB_DB::queryExec("INSERT INTO {$feedsTable} SET `name`=?s, `template`=?s, `description`=?s, `type`=?n, `count`=?n, `mime_type`=?s", $feed_name, $feed_template, $feed_desc, $typeId, $count_listings, $feed_mimetype);
                 $site_url = SJB_System::getSystemSettings("SITE_URL");
                 SJB_HelperFunctions::redirect($site_url . "/listing-feeds/");
             }
             $tp->display("add_listing_feed.tpl");
             break;
         case 'edit':
             // если была отправка формы редактирования элемента
             if ($form_submitted = SJB_Request::getVar('submit')) {
                 $feed_name = $_REQUEST['feed_name'];
                 $feed_template = $_REQUEST['feed_template'];
                 $feed_desc = $_REQUEST['feed_desc'];
                 $feedId = $_REQUEST['feedId'];
                 $typeId = $_REQUEST['typeId'];
                 $count_listings = $_REQUEST['count_listings'];
                 $feed_mimetype = $_REQUEST['mime_type'];
                 SJB_DB::queryExec("UPDATE {$feedsTable} SET `name`=?s, `template`=?s, `description`=?s, `type`=?n, `count`=?n, `mime_type`=?s WHERE `sid`=?n LIMIT 1", $feed_name, $feed_template, $feed_desc, $typeId, $count_listings, $feed_mimetype, $feedId);
                 $site_url = SJB_System::getSystemSettings("SITE_URL");
                 if ($form_submitted == 'save_info') {
                     SJB_HelperFunctions::redirect($site_url . "/listing-feeds/");
                 }
             }
             $feed = SJB_DB::query("SELECT f.*, f.count as count_listings  FROM {$feedsTable} as f WHERE `sid`=?n", $feedId);
             $feed = array_pop($feed);
             $tp->assign("feed", $feed);
             $tp->display("edit_listing_feed.tpl");
             break;
         case 'delete':
             $feed = SJB_DB::query("SELECT f.*, f.count as count_listings FROM {$feedsTable} as f WHERE `sid`=?n", $feedId);
             $feed = array_pop($feed);
             $filePath = $filePath . $feed['template'];
             $fileSystem = new SJB_Filesystem();
             if (file_exists($filePath)) {
                 $fileSystem->deleteFile($filePath);
             } else {
                 $errors[] = array('code' => 'FILE_NOT_EXISTS', 'message' => "Template for " . $feed['name'] . ": '{$filePath}' not exists!");
             }
             SJB_DB::queryExec("DELETE FROM {$feedsTable} WHERE `sid`=?n LIMIT 1", $feedId);
             $site_url = SJB_System::getSystemSettings("SITE_URL");
             SJB_HelperFunctions::redirect($site_url . "/listing-feeds/");
             break;
     }
     if ($action == '') {
         $tp->assign('siteURL', $siteURL);
         $tp->assign('feeds', $feedsArray);
         $tp->display('listing_feeds.tpl');
     }
 }
Exemplo n.º 7
0
SJB_Event::handle('listingDeactivated', array('SJB_Notifications', 'notifyOnUserListingDeactivated'));
SJB_Event::handle('beforeListingDelete', array('SJB_Notifications', 'notifyOnUserListingDeleted'));
//bind send notification emails if user deactivated/deleted
SJB_Event::handle('onBeforeUserDelete', array('SJB_Notifications', 'notifyOnUserDeleted'));
SJB_Event::handle('onBeforeUserDeactivate', array('SJB_Notifications', 'notifyOnUserDeactivated'));
// bind session clear to task scheduler event
SJB_Event::handle('task_scheduler_run', array('SJB_Session', 'clearTemporaryData'));
SJB_Request::getInstance()->execute();
SJB_Statistics::addStatistics('siteView', '', 0, true);
$isPseudoCronEnabled = intval(SJB_Settings::getSettingByName('isPseudoCronEnabled')) === 1;
if ($isPseudoCronEnabled) {
    $isEmailSchedulerEnabled = intval(SJB_Settings::getSettingByName('email_scheduling')) === 1;
    $isOncePerHourCondition = SJB_Settings::getSettingByName('emailSchedule_lastTimeExecuted') < strtotime('1 hour ago');
    if ($isEmailSchedulerEnabled && $isOncePerHourCondition) {
        SJB_Settings::updateSetting('emailSchedule_lastTimeExecuted', time());
        SJB_System::getModuleManager()->executeFunction('miscellaneous', 'email_scheduling');
    }
    $numberOfPageViewsSinceLastTime = SJB_Settings::getValue('pseudoCron_numberOfPageViewsSinceLastTime');
    $isPageViewCondition = intval(SJB_Settings::getValue('pseudoCron_numberOfPageViewsSinceLastTime')) > SJB_Settings::getSettingByName('numberOfPageViewsToExecCronIfExceeded');
    if ($isPageViewCondition) {
        SJB_Settings::updateSetting('pseudoCron_numberOfPageViewsSinceLastTime', 0);
        list($month, $day, $year) = explode('.', SJB_Settings::getSettingByName('task_scheduler_last_executed_date'));
        $isOnceADayCondition = strtotime("{$year}-{$month}-{$day}") < strtotime('today');
        if ($isOnceADayCondition) {
            SJB_HelperFunctions::runScriptByCurl(SJB_System::getSystemSettings('SITE_URL') . '/system/miscellaneous/task_scheduler/');
        }
    } else {
        SJB_Settings::updateSetting('pseudoCron_numberOfPageViewsSinceLastTime', $numberOfPageViewsSinceLastTime + 1);
    }
}
SJB_HelperFunctions::debugInfoPrint();