Exemplo n.º 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();
                }
            }
        }
    }
 public function init()
 {
     $this->cleanSessionData(self::$network);
     $error = SJB_Request::getVar('error', false);
     if ($error && $error == 'access_denied') {
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL'));
     }
     if (isset($_GET['code'])) {
         $this->initialize();
         $googlePlusService = new Google_PlusService(self::$object);
         $oauth2 = new Google_Oauth2Service(self::$object);
         self::$object->authenticate($_GET['code']);
         $_SESSION['access_token'] = self::$object->getAccessToken();
         if (!empty($_SESSION['access_token'])) {
             self::$oProfile = self::getProfileInformation($googlePlusService, $oauth2);
             if (self::$oProfile) {
                 $this->flagSocialPluginInSession(self::$network);
                 self::$oSocialPlugin = $this;
                 $this->redirectToRegistrationSocialPage();
             }
         }
     }
     if (is_null(self::$object) && empty($_SESSION['sn']['authorized'])) {
         $this->initialize();
         $authUrl = self::$object->createAuthUrl();
         SJB_HelperFunctions::redirect($authUrl);
     } elseif (self::$oProfile && !parent::ifUserIsRegistered(self::$network)) {
         $this->redirectToRegistrationSocialPage();
     }
 }
Exemplo n.º 3
0
 /**
  *
  * @param string $profileSocialID
  * @return boolean
  */
 public function initializeByProfileSocialID($profileSocialID)
 {
     if (!parent::ifUserIsRegistered(self::NETWORK_ID, $profileSocialID)) {
         return false;
     }
     if ($accessToken = $this->getProfileSavedAccessToken($profileSocialID)) {
         return $this->initialize($accessToken);
     }
     return false;
 }
 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');
         }
     }
 }
 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');
         }
     }
 }
Exemplo n.º 6
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');
         }
     }
 }
Exemplo n.º 7
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_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');
         }
     }
 }
Exemplo n.º 9
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');
     }
 }
Exemplo n.º 10
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');
         }
     }
 }
Exemplo n.º 11
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $activated = SJB_Request::getVar('account_activated', '') == 'yes';
     if (SJB_Request::getVar('returnToShoppingCart', false)) {
         SJB_Session::setValue('fromAnonymousShoppingCart', 1);
     }
     if (!$activated) {
         if (!isset($_REQUEST['username'], $_REQUEST['activation_key'])) {
             $errors['PARAMETERS_MISSED'] = 1;
         } elseif (!($userInfo = SJB_UserManager::getUserInfoByUserName($_REQUEST['username']))) {
             $errors['USER_NOT_FOUND'] = 1;
         } elseif ($userInfo['activation_key'] != $_REQUEST['activation_key']) {
             $errors['INVALID_ACTIVATION_KEY'] = true;
         } elseif ($userInfo['approval'] == 'Rejected') {
             SJB_UserDBManager::deleteActivationKeyByUsername($_REQUEST['username']);
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/system/users/activate_account/?account_activated=no&approval_status=Rejected');
         } else {
             if (SJB_UserManager::activateUserByUserName($_REQUEST['username'])) {
                 SJB_UserDBManager::deleteActivationKeyByUsername($_REQUEST['username']);
                 if (!SJB_Authorization::isUserLoggedIn()) {
                     SJB_Authorization::login($_REQUEST['username'], false, false, $errors, true, true);
                     if (!SJB_SocialPlugin::getProfileSocialID($userInfo['sid'])) {
                         SJB_Notifications::sendUserWelcomeLetter($userInfo['sid']);
                     }
                     $requireApprove = SJB_UserGroupManager::isApproveByAdmin($userInfo['user_group_sid']);
                     if ($requireApprove && !empty($userInfo['approval'])) {
                         $approvalStatus = $userInfo['approval'];
                     } else {
                         $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userInfo['user_group_sid']);
                         $pageId = !empty($userGroupInfo['after_registration_redirect_to']) ? $userGroupInfo['after_registration_redirect_to'] : '';
                         $redirectUrl = SJB_UserGroupManager::getRedirectUrlByPageID($pageId);
                         SJB_HelperFunctions::redirect($redirectUrl . 'account_activated=yes');
                     }
                 }
                 $activated = 1;
             } else {
                 $errors['CANNOT_ACTIVATE'] = TRUE;
             }
         }
     }
     $tp->assign('activated', $activated);
     $tp->assign('errors', $errors);
     $tp->assign('approvalStatus', !empty($approvalStatus) ? $approvalStatus : SJB_Request::getVar('approval_status', ''));
     $tp->assign('isLoggedIn', SJB_Authorization::isUserLoggedIn());
     $tp->display('activate_account.tpl');
 }
Exemplo n.º 12
0
 public function execute()
 {
     if (!SJB_Authorization::isUserLoggedIn() && class_exists('SJB_SocialPlugin') && ($socPlugins = SJB_SocialPlugin::getAvailablePlugins())) {
         SJB_SocialPlugin::preparePluginsThatAreAvailableForRegistration($socPlugins);
         if (empty($socPlugins)) {
             return null;
         }
         $socNetworks = SJB_SocialPlugin::getSocialNetworks($socPlugins);
         $tp = SJB_System::getTemplateProcessor();
         $tp->assign('aSocPlugins', $socNetworks);
         $tp->display('login_buttons.tpl');
     } else {
         if (SJB_Authorization::isUserLoggedIn()) {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-account/');
         }
     }
 }
Exemplo n.º 13
0
 public function execute()
 {
     if (SJB_Authorization::isUserLoggedIn() && class_exists('SJB_SocialPlugin') && !SJB_SocialPlugin::getProfileObject() && ($socPlugins = SJB_SocialPlugin::getAvailablePlugins())) {
         $tp = SJB_System::getTemplateProcessor();
         $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID(SJB_UserManager::getCurrentUser()->user_group_sid);
         /**
          * delete from plugins array plugins that are not allowed
          * for this userGroup registration
          */
         SJB_SocialPlugin::preparePluginsThatAreAvailableForRegistration($socPlugins, $userGroupInfo['id']);
         if (empty($socPlugins)) {
             return null;
         }
         $socialNetworks = SJB_SocialPlugin::getSocialNetworks($socPlugins);
         $tp->assign('label', 'link');
         $tp->assign('social_plugins', $socialNetworks);
         $tp->display('social_plugins.tpl');
     }
 }
Exemplo n.º 14
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');
     }
 }
Exemplo n.º 15
0
<?php

if (!extension_loaded('openssl')) {
    $GLOBALS[SJB_SocialPlugin::SOCIAL_ACCESS_ERROR]['SOCIAL_ACCESS_ERROR'] = 'linkedin';
    SJB_Error::writeToLog('Linkedin Social Plugin needs the "openssl" PHP extension.');
    return null;
}
require_once 'linkedin_social_plugin.php';
SJB_SocialPlugin::loadPlugin('linkedin', new LinkedinSocialPlugin());
if (LinkedinSocialPlugin::getNetwork() === SJB_SocialPlugin::getNetwork()) {
    SJB_Event::handle('Login_Plugin', array('SJB_SocialPlugin', 'login'));
    SJB_Event::handle('Logout', array('SJB_SocialPlugin', 'logout'), 1000);
    /*
     * REGISTRATION
     */
    SJB_Event::handle('FillRegistrationData_Plugin', array('SJB_SocialPlugin', 'fillRegistrationDataWithUser'));
    SJB_Event::handle('PrepareRegistrationFields_SocialPlugin', array('SJB_SocialPlugin', 'prepareRegistrationFields'));
    SJB_Event::handle('MakeRegistrationFieldsNotRequired_SocialPlugin', array('LinkedinSocialPlugin', 'makeRegistrationFieldsNotRequired'));
    SJB_Event::handle('SocialPlugin_AddListingFieldsIntoRegistration', array('SJB_SocialPlugin', 'addListingFieldsIntoRegistration'));
    SJB_Event::handle('AddReferencePluginDetails', array('SJB_SocialPlugin', 'addReferenceDetails'));
    /*
     * LISTING AUTOFILL SYNCHRONIZATION
     */
    SJB_Event::handle('SocialSynchronization', array('SJB_SocialPlugin', 'autofillListing'));
    SJB_Event::handle('SocialSynchronizationForm', array('SJB_SocialPlugin', 'autofillListingForm'));
    SJB_Event::handle('SocialSynchronizationFields', array('SJB_SocialPlugin', 'autofillListingFields'));
    SJB_Event::handle('SocialSynchronizationFieldsOnPostingPages', array('SJB_SocialPlugin', 'autofillListingFieldsOnPostingPages'));
}
Exemplo n.º 16
0
<?php

if (!function_exists('curl_init')) {
    $GLOBALS[SJB_SocialPlugin::SOCIAL_ACCESS_ERROR]['SOCIAL_ACCESS_ERROR'] = 'facebook';
    SJB_Error::writeToLog('Facebook needs the CURL PHP extension.');
    return null;
}
if (!function_exists('json_decode')) {
    $GLOBALS[SJB_SocialPlugin::SOCIAL_ACCESS_ERROR]['SOCIAL_ACCESS_ERROR'] = 'facebook';
    SJB_Error::writeToLog('Facebook needs the JSON PHP extension.');
    return null;
}
require_once 'facebook_social_plugin.php';
SJB_SocialPlugin::loadPlugin('facebook', $socPlugin = new FacebookSocialPlugin());
if ($socPlugin->getNetwork() === SJB_SocialPlugin::getNetwork()) {
    /*
     * login/logout
     */
    SJB_Event::handle('Login_Plugin', array('SJB_SocialPlugin', 'login'));
    SJB_Event::handle('Logout', array('SJB_SocialPlugin', 'logout'), 1000);
    /*
     * registration
     */
    SJB_Event::handle('FillRegistrationDataRequest_Plugin', array('FacebookSocialPlugin', 'fillRegistrationDataWithRequest'));
    SJB_Event::handle('FillRegistrationData_Plugin', array('SJB_SocialPlugin', 'fillRegistrationDataWithUser'));
    SJB_Event::handle('PrepareRegistrationFields_SocialPlugin', array('FacebookSocialPlugin', 'prepareRegistrationFields'));
    SJB_Event::handle('MakeRegistrationFieldsNotRequired_SocialPlugin', array('FacebookSocialPlugin', 'makeRegistrationFieldsNotRequired'));
    SJB_Event::handle('AddReferencePluginDetails', array('SJB_SocialPlugin', 'addReferenceDetails'));
    SJB_Event::handle('SocialPlugin_PostRegistrationActions', array('SJB_SocialPlugin', 'postRegistrationActions'));
    SJB_Event::handle('SocialPlugin_AddListingFieldsIntoRegistration', array('FacebookSocialPlugin', 'addListingFieldsIntoRegistration'));
    /*
Exemplo n.º 17
0
 public static function ifRegistrationIsAllowedByUserGroupSID($userGroupSID)
 {
     return in_array($userGroupSID, SJB_SocialPlugin::getResolvedUserGroupsByNetwork());
 }
Exemplo n.º 18
0
<?php

require_once 'google_plus_integration_plugin.php';
$includePath = explode(PATH_SEPARATOR, get_include_path());
unset($includePath[0]);
set_include_path(implode(PATH_SEPARATOR, $includePath));
SJB_SocialPlugin::loadPlugin('google_plus', new GooglePlusSocialPlugin());
if (GooglePlusSocialPlugin::getNetwork() === SJB_SocialPlugin::getNetwork()) {
    SJB_Event::handle('Login_Plugin', array('SJB_SocialPlugin', 'login'));
    SJB_Event::handle('Logout', array('GooglePlusSocialPlugin', 'logout'), 1000);
    SJB_Event::handle('FillRegistrationData_Plugin', array('SJB_SocialPlugin', 'fillRegistrationDataWithUser'));
    SJB_Event::handle('PrepareRegistrationFields_SocialPlugin', array('SJB_SocialPlugin', 'prepareRegistrationFields'));
    SJB_Event::handle('MakeRegistrationFieldsNotRequired_SocialPlugin', array('SJB_SocialPlugin', 'makeRegistrationFieldsNotRequired'));
    SJB_Event::handle('AddReferencePluginDetails', array('GooglePlusSocialPlugin', 'addReferenceDetails'));
}
Exemplo n.º 19
0
 public static function deleteUserById($id)
 {
     $user = SJB_UserManager::getObjectBySID($id);
     if (empty($user)) {
         SJB_UserDBManager::deleteEmptyUsers();
         return true;
     }
     SJB_Event::dispatch('onBeforeUserDelete', $user);
     $listings = SJB_ListingDBManager::getListingsSIDByUserSID($id);
     SJB_ListingManager::deleteListingBySID($listings);
     $subusers = self::getSubusers($id);
     foreach ($subusers as $subuser) {
         self::deleteUserById($subuser['sid']);
     }
     // delete user logo file
     $pictProp = $user->getProperty('Logo');
     if ($pictProp) {
         SJB_UploadFileManager::deleteUploadedFileByID($pictProp->value);
     }
     $videoProp = $user->getProperty('video');
     if ($videoProp) {
         SJB_UploadFileManager::deleteUploadedFileByID($videoProp->value);
     }
     // delete social info
     $socialReference = SJB_SocialPlugin::getProfileSocialID($user->getSID());
     if ($socialReference) {
         SJB_SocialPlugin::deleteProfileSocialInfoByReference($socialReference);
     }
     $result = SJB_UserDBManager::deleteUserById($id) && SJB_ContractManager::deleteAllContractsByUserSID($id) && SJB_Rating::deleteRatingByUserSID($id);
     SJB_Cache::getInstance()->clean('matchingAnyTag', array(SJB_Cache::TAG_USERS));
     return $result && SJB_SavedSearches::deleteUserSearchesFromDB($id);
 }
Exemplo n.º 20
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('terms_of_use_check', SJB_System::getSettingByName('terms_of_use_check'));
     $user_group_id = SJB_Request::getVar('user_group_id', null);
     $form_submitted = isset($_REQUEST['action']) && $_REQUEST['action'] == 'register';
     if (!is_null($user_group_id)) {
         $user_group_sid = SJB_UserGroupManager::getUserGroupSIDByID($user_group_id);
         /**
          * check if registration is allowed for this UserGroup
          */
         if (!SJB_SocialPlugin::ifRegistrationIsAllowedByUserGroupSID($user_group_sid)) {
             return null;
         }
         $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
         $user = SJB_ObjectMother::createUser($_REQUEST, $user_group_sid);
         $user->deleteProperty('active');
         $user->deleteProperty('featured');
         $errors = array();
         // social plugin
         if ($form_submitted) {
             SJB_Event::dispatch('SocialPlugin_AddListingFieldsIntoRegistration', $user, true);
             SJB_Event::dispatch('MakeRegistrationFieldsNotRequired_SocialPlugin', $user, true);
         } else {
             SJB_Event::dispatch('PrepareRegistrationFields_SocialPlugin', $user, true);
             SJB_Event::dispatch('SocialPlugin_AddListingFieldsIntoRegistration', $user, true);
             SJB_Event::dispatch('FillRegistrationData_Plugin', $user, true);
         }
         $registration_form = SJB_ObjectMother::createForm($user);
         $registration_form->registerTags($tp);
         if ($form_submitted && $registration_form->isDataValid($errors)) {
             SJB_Event::dispatch('FillRegistrationData_Plugin', $user, true);
             SJB_Event::dispatch('AddReferencePluginDetails', $user, true);
             $user->deleteProperty('captcha');
             $user->deleteProperty('active');
             $user->deleteProperty('featured');
             SJB_UserManager::saveUser($user);
             SJB_Statistics::addStatistics('addUser', $user->getUserGroupSID(), $user->getSID(), false, 0, 0, false, 0, SJB_SocialPlugin::getNetwork());
             SJB_Statistics::addStatistics('addUser' . SJB_SocialPlugin::getNetwork(), $user->getUserGroupSID(), $user->getSID(), false, 0, 0, false, 0, SJB_SocialPlugin::getNetwork());
             // subscribe user on default product
             $defaultProduct = SJB_UserGroupManager::getDefaultProduct($user_group_sid);
             $availableProductIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($user_group_sid);
             if ($defaultProduct && in_array($defaultProduct, $availableProductIDs)) {
                 $contract = new SJB_Contract(array('product_sid' => $defaultProduct));
                 $contract->setUserSID($user->getSID());
                 $contract->saveInDB();
             }
             SJB_SocialPlugin::sendUserSocialRegistrationLetter($user);
             // notify administrator
             SJB_AdminNotifications::sendAdminUserRegistrationLetter($user);
             // Activation
             $isSendActivationEmail = SJB_UserGroupManager::isSendActivationEmail($user_group_sid);
             $isApproveByAdmin = SJB_UserGroupManager::isApproveByAdmin($user_group_sid);
             if ($isApproveByAdmin) {
                 SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
             }
             if ($isSendActivationEmail) {
                 $isSent = SJB_Notifications::sendUserActivationLetter($user->getSID());
                 if ($isSent) {
                     $tp->display('../users/registration_confirm.tpl');
                 } else {
                     $tp->display('../users/registration_failed_to_send_activation_email.tpl');
                 }
             } else {
                 if (!$isSendActivationEmail && $isApproveByAdmin) {
                     SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
                     $tp->display('../users/registration_pending.tpl');
                 } else {
                     SJB_UserManager::activateUserByUserName($user->getUserName());
                     $errors = array();
                     SJB_Authorization::login($user->getUserName(), $user->getPropertyValue('password'), false, $errors, false);
                     // save access token, profile info for synchronization
                     SJB_SocialPlugin::postRegistration();
                     $tp->assign('socialNetwork', SJB_SocialPlugin::getNetwork());
                     $pageId = !empty($user_group_info['after_registration_redirect_to']) ? $user_group_info['after_registration_redirect_to'] : '';
                     $redirectUrl = SJB_UserGroupManager::getRedirectUrlByPageID($pageId);
                     SJB_HelperFunctions::redirect($redirectUrl);
                 }
             }
         } else {
             // social plugin
             SJB_Event::dispatch('PrepareRegistrationFields_SocialPlugin', $user, true);
             if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid)) {
                 $user->deleteProperty('username');
             }
             $registration_form = SJB_ObjectMother::createForm($user);
             if ($form_submitted) {
                 $registration_form->isDataValid($errors);
             }
             $registration_form->registerTags($tp);
             $registration_form_template = '../users/registration_form.tpl';
             if (isset($_REQUEST['reg_form_template'])) {
                 $registration_form_template = $_REQUEST['reg_form_template'];
             } elseif (!empty($user_group_info['reg_form_template'])) {
                 $registration_form_template = $user_group_info['reg_form_template'];
             }
             $form_fields = $registration_form->getFormFieldsInfo();
             $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
             $tp->assign('user_group_info', $user_group_info);
             $tp->assign('errors', $errors);
             $tp->assign('user_group_id', $user_group_id);
             $tp->assign('form_fields', $form_fields);
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
             $tp->assign('socialRegistration', true);
             $tp->assign('userTree', true);
             $tp->display($registration_form_template);
         }
     } else {
         $userGroupsSIDs = SJB_SocialPlugin::getResolvedUserGroupsByNetwork();
         $user_groups_info = array();
         foreach ($userGroupsSIDs as $groupSID) {
             array_push($user_groups_info, SJB_UserGroupManager::getUserGroupInfoBySID($groupSID));
         }
         /*
          * if there is only one group available for registration
          * redirect user directly on Registration Fields page
          */
         if (count($user_groups_info) === 1 && !empty($user_groups_info[0]['id'])) {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/registration-social/?user_group_id=' . $user_groups_info[0]['id']);
         }
         $tp->assign('user_groups_info', $user_groups_info);
         $tp->display('registration_choose_user_group_social.tpl');
     }
 }
Exemplo n.º 21
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $registration_form_template = 'registration_form.tpl';
     if (SJB_Authorization::isUserLoggedIn()) {
         $tp->display('already_logged_in.tpl');
         return;
     }
     $tp->assign('terms_of_use_check', SJB_System::getSettingByName('terms_of_use_check'));
     $user_group_id = SJB_Request::getVar('user_group_id', null);
     if (!is_null($user_group_id)) {
         $user_group_sid = SJB_UserGroupManager::getUserGroupSIDByID($user_group_id);
         if (empty($user_group_sid)) {
             $errors['NO_SUCH_USER_GROUP_IN_THE_SYSTEM'] = 1;
         }
     }
     $this->setSessionValueForRedirectAfterRegister();
     if (!is_null($user_group_id) && empty($errors)) {
         $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
         $user = SJB_ObjectMother::createUser($_REQUEST, $user_group_sid);
         if (SJB_Request::isAjax() || 'true' == SJB_Request::getVar('isajaxrequest')) {
             $field = SJB_Request::getVar('type');
             if ('email' == $field) {
                 $user->getProperty($field)->type->disableEmailConfirmation();
             }
             echo $user->getProperty($field)->isValid();
             exit;
         }
         $user->deleteProperty('active');
         $user->deleteProperty('featured');
         $form_submitted = SJB_Request::getVar('action', false) == 'register';
         if (class_exists('MobilePlugin') && MobilePlugin::isMobileThemeOn()) {
             $user->prepareRegistrationFields();
         }
         $registration_form = SJB_ObjectMother::createForm($user);
         $registration_form->registerTags($tp);
         if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid) && $form_submitted) {
             $email = $user->getPropertyValue('email');
             if (is_array($email)) {
                 $email = $email['original'];
             }
             $user->setPropertyValue('username', $email);
         }
         if ($form_submitted && $registration_form->isDataValid($errors)) {
             $user->deleteProperty('captcha');
             $defaultProduct = SJB_UserGroupManager::getDefaultProduct($user_group_sid);
             SJB_UserManager::saveUser($user);
             SJB_Statistics::addStatistics('addUser', $user->getUserGroupSID(), $user->getSID());
             $availableProductIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($user_group_sid);
             if ($defaultProduct && in_array($defaultProduct, $availableProductIDs)) {
                 $contract = new SJB_Contract(array('product_sid' => $defaultProduct));
                 $contract->setUserSID($user->getSID());
                 $contract->saveInDB();
             }
             // >>> SJB-1197
             // needs to check session for ajax-uploaded files, and set it to user profile
             $formToken = SJB_Request::getVar('form_token');
             $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
             if (!empty($formToken)) {
                 $tmpUploadedFields = SJB_Array::getPath($tmpUploadsStorage, $formToken);
                 if (!is_null($tmpUploadsStorage) && is_array($tmpUploadedFields)) {
                     // prepare user profile fields array
                     $userProfileFieldsInfo = SJB_UserProfileFieldManager::getAllFieldsInfo();
                     $userProfileFields = array();
                     foreach ($userProfileFieldsInfo as $field) {
                         $userProfileFields[$field['id']] = $field;
                     }
                     // look for temporary values
                     foreach ($tmpUploadedFields as $fieldId => $fieldInfo) {
                         // check field ID for valid ID in user profile fields
                         if (!array_key_exists($fieldId, $userProfileFields) || empty($fieldInfo)) {
                             continue;
                         }
                         $fieldType = $userProfileFields[$fieldId]['type'];
                         $profilePropertyId = $fieldId . '_' . $user->getSID();
                         switch (strtolower($fieldType)) {
                             case 'video':
                             case 'file':
                                 // change temporary file ID
                                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']);
                                 // set value of user property to new uploaded file
                                 $user->setPropertyValue($fieldId, $profilePropertyId);
                                 break;
                             case 'logo':
                                 // change temporary file ID and thumb ID
                                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']);
                                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId . '_thumb', $fieldInfo['file_id'] . '_thumb');
                                 // set value of user property to new uploaded file
                                 $user->setPropertyValue($fieldId, $profilePropertyId);
                                 break;
                             default:
                                 break;
                         }
                         $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}/{$fieldId}");
                     }
                     // save user with new values
                     SJB_UserManager::saveUser($user);
                     // clean temporary storage
                     $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}");
                     // CLEAR TEMPORARY SESSION STORAGE
                     SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 }
             }
             // <<< SJB-1197
             // notifying administrator
             SJB_AdminNotifications::sendAdminUserRegistrationLetter($user);
             // Activation
             $isSendActivationEmail = SJB_UserGroupManager::isSendActivationEmail($user_group_sid);
             $isApproveByAdmin = SJB_UserGroupManager::isApproveByAdmin($user_group_sid);
             if ($isApproveByAdmin) {
                 SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
             }
             if ($isSendActivationEmail) {
                 $fromAnonymousShoppingCart = SJB_Session::getValue('fromAnonymousShoppingCart');
                 SJB_Session::unsetValue('fromAnonymousShoppingCart');
                 $isSent = SJB_Notifications::sendUserActivationLetter($user->getSID(), $fromAnonymousShoppingCart ? true : false);
                 if ($isSent) {
                     $registration_form_template = 'registration_confirm.tpl';
                 } else {
                     SJB_FlashMessages::getInstance()->addWarning('ERROR_SEND_ACTIVATION_EMAIL');
                     $registration_form_template = 'registration_failed_to_send_activation_email.tpl';
                 }
             } else {
                 if (!$isSendActivationEmail && $isApproveByAdmin) {
                     SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
                     $registration_form_template = 'registration_pending.tpl';
                 } else {
                     SJB_UserManager::activateUserByUserName($user->getUserName());
                     if (!SJB_SocialPlugin::getProfileSocialID($user->getSID())) {
                         SJB_Notifications::sendUserWelcomeLetter($user->getSID());
                     }
                     SJB_Authorization::login($user->getUserName(), $_REQUEST['password']['original'], false, $errors);
                     $proceedToPosting = SJB_Session::getValue('proceed_to_posting');
                     if ($proceedToPosting) {
                         $redirectUrl = SJB_HelperFunctions::getSiteUrl() . '/add-listing/?listing_type_id=' . SJB_Session::getValue('listing_type_id') . '&proceed_to_posting=' . $proceedToPosting . '&productSID=' . SJB_Session::getValue('productSID');
                     } else {
                         $pageId = !empty($user_group_info['after_registration_redirect_to']) ? $user_group_info['after_registration_redirect_to'] : '';
                         $redirectUrl = SJB_UserGroupManager::getRedirectUrlByPageID($pageId);
                     }
                     SJB_HelperFunctions::redirect($redirectUrl);
                 }
             }
         } else {
             if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid)) {
                 $user->deleteProperty('username');
             }
             $registration_form = SJB_ObjectMother::createForm($user);
             $registration_form->registerTags($tp);
             $registration_form_template = 'registration_form.tpl';
             if (isset($_REQUEST['reg_form_template'])) {
                 $registration_form_template = $_REQUEST['reg_form_template'];
             } elseif (!empty($user_group_info['reg_form_template'])) {
                 $registration_form_template = $user_group_info['reg_form_template'];
             }
             $form_fields = $registration_form->getFormFieldsInfo();
             // define default template with ajax checking
             $registration_form->setDefaultTemplateByFieldName('email', 'email_ajaxchecking.tpl');
             $registration_form->setDefaultTemplateByFieldName('username', 'unique_string.tpl');
             // use specific template for user profile video
             $registration_form->setDefaultTemplateByFieldName('video', 'video_profile.tpl');
             $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
             $tp->assign('user_group_info', $user_group_info);
             $tp->assign('errors', $errors);
             $tp->assign('form_fields', $form_fields);
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
         }
     } else {
         $registration_form_template = 'registration_choose_user_group.tpl';
         $user_groups_info = SJB_UserGroupManager::getAllUserGroupsInfo();
         $tp->assign('user_groups_info', $user_groups_info);
     }
     $tp->assign('userTree', true);
     $tp->assign('errors', $errors);
     $tp->display($registration_form_template);
 }
Exemplo n.º 22
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $template = SJB_Request::getVar('template', 'users.tpl');
     $searchTemplate = SJB_Request::getVar('search_template', 'user_search_form.tpl');
     $passedParametersViaUri = SJB_UrlParamProvider::getParams();
     $userGroupID = $passedParametersViaUri ? array_shift($passedParametersViaUri) : false;
     $userGroupSID = $userGroupID ? SJB_UserGroupManager::getUserGroupSIDByID($userGroupID) : null;
     $errors = array();
     /********** A C T I O N S   W I T H   U S E R S **********/
     $action = SJB_Request::getVar('action_name');
     if (!empty($action)) {
         $users_sids = SJB_Request::getVar('users', array());
         $_REQUEST['restore'] = 1;
         switch ($action) {
             case 'approve':
                 foreach ($users_sids as $user_sid => $value) {
                     $username = SJB_UserManager::getUserNameByUserSID($user_sid);
                     SJB_UserManager::setApprovalStatusByUserName($username, 'Approved');
                     SJB_UserManager::activateUserByUserName($username);
                     SJB_UserDBManager::deleteActivationKeyByUsername($username);
                     if (!SJB_SocialPlugin::getProfileSocialID($user_sid)) {
                         SJB_Notifications::sendUserWelcomeLetter($user_sid);
                     } else {
                         SJB_Notifications::sendUserApprovedLetter($user_sid);
                     }
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'reject':
                 $rejection_reason = SJB_Request::getVar('rejection_reason', '');
                 foreach ($users_sids as $user_sid => $value) {
                     $username = SJB_UserManager::getUserNameByUserSID($user_sid);
                     SJB_UserManager::setApprovalStatusByUserName($username, 'Rejected', $rejection_reason);
                     SJB_UserManager::deactivateUserByUserName($username);
                     SJB_Notifications::sendUserRejectedLetter($user_sid);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'activate':
                 foreach ($users_sids as $user_sid => $value) {
                     $username = SJB_UserManager::getUserNameByUserSID($user_sid);
                     $userinfo = SJB_UserManager::getUserInfoByUserName($username);
                     SJB_UserManager::activateUserByUserName($username);
                     if ($userinfo['approval'] == 'Approved') {
                         SJB_UserDBManager::deleteActivationKeyByUsername($username);
                         SJB_Notifications::sendUserApprovedLetter($user_sid);
                     }
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'deactivate':
                 foreach ($users_sids as $user_sid => $value) {
                     $username = SJB_UserManager::getUserNameByUserSID($user_sid);
                     SJB_UserManager::deactivateUserByUserName($username);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'delete':
                 foreach (array_keys($users_sids) as $user_sid) {
                     try {
                         SJB_UserManager::deleteUserById($user_sid);
                     } catch (Exception $e) {
                         $errors[] = $e->getMessage();
                     }
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'send_activation_letter':
                 foreach ($users_sids as $user_sid => $value) {
                     SJB_Notifications::sendUserActivationLetter($user_sid);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'change_product':
                 $productToChange = SJB_Request::getVar('product_to_change');
                 if (empty($productToChange)) {
                     $productToChange = 0;
                 }
                 foreach ($users_sids as $user_sid => $value) {
                     $user = SJB_UserManager::getObjectBySID($user_sid);
                     // UNSUBSCRIBE selected
                     if ($productToChange == 0) {
                         SJB_ContractManager::deleteAllContractsByUserSID($user_sid);
                     } else {
                         $productInfo = SJB_ProductsManager::getProductInfoBySID($productToChange);
                         $listingNumber = SJB_Request::getVar('number_of_listings', null);
                         if (is_null($listingNumber) && !empty($productInfo['number_of_listings'])) {
                             $listingNumber = $productInfo['number_of_listings'];
                         }
                         $contract = new SJB_Contract(array('product_sid' => $productToChange, 'numberOfListings' => $listingNumber, 'is_recurring' => 0));
                         $contract->setUserSID($user_sid);
                         $contract->saveInDB();
                         if ($contract->isFeaturedProfile()) {
                             SJB_UserManager::makeFeaturedBySID($user_sid);
                         }
                     }
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'ban_ip':
                 $cantBanUsers = array();
                 foreach ($users_sids as $user_sid => $value) {
                     $user = SJB_UserManager::getUserInfoBySID($user_sid);
                     if ($user['ip'] && !SJB_IPManager::getBannedIPByValue($user['ip'])) {
                         SJB_IPManager::makeIPBanned($user['ip']);
                     } else {
                         $cantBanUsers[] = $user['username'];
                     }
                 }
                 if ($cantBanUsers) {
                     $tp->assign('cantBanUsers', $cantBanUsers);
                 } else {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 }
                 break;
             case 'unban_ip':
                 $cantUnbanIPs = array();
                 foreach ($users_sids as $user_sid => $value) {
                     $user = SJB_UserManager::getUserInfoBySID($user_sid);
                     if ($user['ip'] !== '') {
                         if (SJB_IPManager::getBannedIPByValue($user['ip'])) {
                             SJB_IPManager::makeIPEnabledByValue($user['ip']);
                         } elseif (SJB_UserManager::checkBan($errors, $user['ip'])) {
                             $cantUnbanIPs[] = $user['ip'];
                         }
                     }
                 }
                 if ($cantUnbanIPs) {
                     $tp->assign('rangeIPs', $cantUnbanIPs);
                 } else {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 }
                 break;
             default:
                 unset($_REQUEST['restore']);
                 break;
         }
         if (empty($errors)) {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
         }
     }
     /***************************************************************/
     $_REQUEST['action'] = 'search';
     $user = new SJB_User(array(), $userGroupSID);
     $user->addProperty(array('id' => 'user_group', 'type' => 'list', 'value' => '', 'is_system' => true, 'list_values' => SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions()));
     $user->addProperty(array('id' => 'registration_date', 'type' => 'date', 'value' => '', 'is_system' => true));
     $user->addProperty(array('id' => 'approval', 'caption' => 'Approval', 'type' => 'list', 'list_values' => array(array('id' => 'Pending', 'caption' => 'Pending'), array('id' => 'Approved', 'caption' => 'Approved'), array('id' => 'Rejected', 'caption' => 'Rejected')), 'length' => '10', 'is_required' => false, 'is_system' => true));
     // get array of accessible products
     $productsSIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userGroupSID);
     $products = array();
     foreach ($productsSIDs as $key => $productSID) {
         $product = SJB_ProductsManager::getProductInfoBySID($productSID);
         $products[$key] = $product;
         if (!empty($product['pricing_type']) && $product['pricing_type'] == 'volume_based' && !empty($product['volume_based_pricing'])) {
             $volumeBasedPricing = $product['volume_based_pricing'];
             $minListings = min($volumeBasedPricing['listings_range_from']);
             $maxListings = max($volumeBasedPricing['listings_range_to']);
             $countListings = array();
             for ($i = $minListings; $i <= $maxListings; $i++) {
                 $countListings[] = $i;
             }
             $products[$key]['count_listings'] = $countListings;
         }
     }
     $user->addProperty(array('id' => 'product', 'type' => 'list', 'value' => '', 'list_values' => $products, 'is_system' => true));
     $aliases = new SJB_PropertyAliases();
     $aliases->addAlias(array('id' => 'user_group', 'real_id' => 'user_group_sid', 'transform_function' => 'SJB_UserGroupManager::getUserGroupSIDByID'));
     $aliases->addAlias(array('id' => 'product', 'real_id' => 'product_sid'));
     $_REQUEST['user_group']['equal'] = $userGroupSID;
     $search_form_builder = new SJB_SearchFormBuilder($user);
     $criteria_saver = new SJB_UserCriteriaSaver();
     if (isset($_REQUEST['restore'])) {
         $_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria());
     }
     $criteria = $search_form_builder->extractCriteriaFromRequestData($_REQUEST, $user);
     $search_form_builder->setCriteria($criteria);
     $search_form_builder->registerTags($tp);
     $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userGroupSID);
     if (SJB_Request::getVar('online', '') == '1') {
         $tp->assign("online", true);
     }
     $tp->assign('userGroupInfo', $userGroupInfo);
     $tp->assign('products', $products);
     $tp->assign('selectedProduct', isset($_REQUEST['product']['simple_equal']) ? $_REQUEST['product']['simple_equal'] : '');
     $tp->display($searchTemplate);
     /********************** S O R T I N G *********************/
     $paginator = new SJB_UsersPagination($userGroupInfo, SJB_Request::getVar('online', ''), $template);
     $firstLastName = '';
     if (!empty($_REQUEST['FirstName']['equal'])) {
         $name['FirstName']['any_words'] = $name['LastName']['any_words'] = $_REQUEST['FirstName']['equal'];
         $firstLastName = $_REQUEST['FirstName'];
         unset($_REQUEST['FirstName']);
         $_REQUEST['FirstName']['fields_or'] = $name;
     }
     $criteria = $search_form_builder->extractCriteriaFromRequestData($_REQUEST, $user);
     $inner_join = false;
     // if search by product field
     if (isset($_REQUEST['product']['simple_equal']) && $_REQUEST['product']['simple_equal'] != '') {
         $inner_join = array('contracts' => array('join_field' => 'user_sid', 'join_field2' => 'sid', 'join' => 'INNER JOIN'));
     }
     if (SJB_Request::getVar('online', '') == '1') {
         $maxLifeTime = ini_get("session.gc_maxlifetime");
         $currentTime = time();
         $innerJoinOnline = array('user_session_data_storage' => array('join_field' => 'user_sid', 'join_field2' => 'sid', 'select_field' => 'session_id', 'join' => 'INNER JOIN', 'where' => "AND unix_timestamp(`user_session_data_storage`.`last_activity`) + {$maxLifeTime} > {$currentTime}"));
         if ($inner_join) {
             $inner_join = array_merge($inner_join, $innerJoinOnline);
         } else {
             $inner_join = $innerJoinOnline;
         }
     }
     $searcher = new SJB_UserSearcher(array('limit' => ($paginator->currentPage - 1) * $paginator->itemsPerPage, 'num_rows' => $paginator->itemsPerPage), $paginator->sortingField, $paginator->sortingOrder, $inner_join);
     $found_users = array();
     $found_users_sids = array();
     if (SJB_Request::getVar('action', '') == 'search') {
         $found_users = $searcher->getObjectsSIDsByCriteria($criteria, $aliases);
         $criteria_saver->setSession($_REQUEST, $searcher->getFoundObjectSIDs());
     } elseif (isset($_REQUEST['restore'])) {
         $found_users = $criteria_saver->getObjectsFromSession();
     }
     foreach ($found_users as $id => $userID) {
         $user_info = SJB_UserManager::getUserInfoBySID($userID);
         $contractInfo = SJB_ContractManager::getAllContractsInfoByUserSID($user_info['sid']);
         $user_info['products'] = count($contractInfo);
         $found_users[$id] = $user_info;
     }
     $paginator->setItemsCount($searcher->getAffectedRows());
     $sorted_found_users_sids = $found_users_sids;
     /****************************************************************/
     $tp->assign("userGroupInfo", $userGroupInfo);
     $tp->assign("found_users", $found_users);
     $searchFields = '';
     foreach ($_REQUEST as $key => $val) {
         if (is_array($val)) {
             foreach ($val as $fieldName => $fieldValue) {
                 if (is_array($fieldValue)) {
                     foreach ($fieldValue as $fieldSubName => $fieldSubValue) {
                         $searchFields .= "&{$key}[{$fieldSubName}]=" . array_pop($fieldSubValue);
                     }
                 } else {
                     $searchFields .= "&{$key}[{$fieldName}]={$fieldValue}";
                 }
             }
         }
     }
     $tp->assign('paginationInfo', $paginator->getPaginationInfo());
     $tp->assign("searchFields", $searchFields);
     $tp->assign("found_users_sids", $sorted_found_users_sids);
     $tp->assign('errors', $errors);
     $tp->display($template);
 }
Exemplo n.º 23
0
 public static function generateGeneralGraph($dateStatistics, $filter = array())
 {
     $listingTypes = SJB_ListingTypeManager::getListingAllTypesForListType();
     $userGroups = SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions();
     $nameEvents = array();
     $filterValues = is_array($filter) ? array_keys($filter) : array();
     foreach ($filter as $blockName => $val) {
         switch ($blockName) {
             case 'popularity':
                 $popularityEvents = array('siteView' => 'Number of Website Views', 'viewListing' => 'Number of #listingTypeName# Views');
                 $nameEvents = array_merge($nameEvents, $popularityEvents);
                 break;
             case 'users':
                 $usersEvents = array('addUser' => 'Number of #userGroupName# Registered', 'addSubAccount' => 'Number of Sub-Employers Registered', 'deleteUser' => 'Number of Profiles Deleted');
                 $nameEvents = array_merge($nameEvents, $usersEvents);
                 break;
             case 'listings':
                 $listingsEvents = array('addListing' => 'Number of #listingTypeName# Posted', 'deleteListing' => 'Number of #listingTypeName# Deleted');
                 $nameEvents = array_merge($nameEvents, $listingsEvents);
                 break;
             case 'applications':
                 $applyEvents = array('apply' => 'Number of Applications Made');
                 $nameEvents = array_merge($nameEvents, $applyEvents);
                 break;
             case 'alerts':
                 $alertsEvents = array('addAlert' => 'Number of Job Alerts #listingTypeName# for', 'sentAlert' => 'Number of #listingTypeName# Alerts Sent', SJB_GuestAlertStatistics::EVENT_SUBSCRIBED => 'Number of Guest #listingTypeName# Alerts subscribed for', SJB_GuestAlertStatistics::EVENT_SENT => 'Number of Guest #listingTypeName# Alerts Sent');
                 $nameEvents = array_merge($nameEvents, $alertsEvents);
                 break;
             case 'sales':
                 $salesEvents = array('payment' => 'Earnings from #userGroupName#', SJB_PromotionsManager::STATISTIC_EVENT => 'Promotion Discount');
                 $nameEvents = array_merge($nameEvents, $salesEvents);
                 break;
             case 'plugins':
                 $popularityEvents = array('viewMobileVersion' => 'Number of Mobile Version Views', 'partneringSites' => 'Number of Redirects to Partnering Sites');
                 $socialPlugins = SJB_SocialPlugin::getAvailablePlugins();
                 foreach ($socialPlugins as $socialPluginName) {
                     $socialRegistrationEventName = 'addUser' . $socialPluginName;
                     $popularityEvents[$socialRegistrationEventName] = 'Number of #userGroupName# Registered through ' . $socialPluginName;
                 }
                 $nameEvents = array_merge($nameEvents, $popularityEvents);
                 break;
         }
     }
     $nameEvents = array_unique($nameEvents);
     $graph = array();
     foreach ($nameEvents as $nameEvent => $title) {
         switch ($nameEvent) {
             case 'addAlert':
             case 'sentAlert':
             case SJB_GuestAlertStatistics::EVENT_SUBSCRIBED:
             case SJB_GuestAlertStatistics::EVENT_SENT:
             case 'deleteListing':
             case 'addListing':
             case 'viewListing':
                 foreach ($listingTypes as $listingTypeInfo) {
                     $listingType = $listingTypeInfo['caption'];
                     $listingTypeID = $listingTypeInfo['id'];
                     if ($nameEvent == 'addListing' || $nameEvent == 'deleteListing') {
                         if ($listingTypeInfo['key'] == 'Job' || $listingTypeInfo['key'] == 'Resume') {
                             $listingType = $listingTypeInfo['key'] . 's';
                         } else {
                             $listingType = '"' . $listingType . '" listings ';
                         }
                     }
                     $graph[$nameEvent . $listingTypeID]['title'] = str_replace('#listingTypeName#', $listingType, $title);
                     if (!empty($dateStatistics[$nameEvent . $listingTypeID]['type']) && $dateStatistics[$nameEvent . $listingTypeID]['type'] == $listingTypeID) {
                         $graph[$nameEvent . $listingTypeID]['statistic'] = $dateStatistics[$nameEvent . $listingTypeID]['count'];
                     } else {
                         $graph[$nameEvent . $listingTypeID]['statistic'] = 0;
                     }
                     if ($nameEvent == 'addListing') {
                         $graph[$nameEvent . 'Featured' . $listingTypeID]['title'] = "Number of Featured {$listingType} Posted";
                         $graph[$nameEvent . 'Priority' . $listingTypeID]['title'] = "Number of Priority {$listingType} Posted";
                         $graph[$nameEvent . 'Featured' . $listingTypeID]['statistic'] = 0;
                         $graph[$nameEvent . 'Priority' . $listingTypeID]['statistic'] = 0;
                         if (!empty($dateStatistics[$nameEvent . $listingTypeID]['featured']) && $dateStatistics[$nameEvent . $listingTypeID]['featured'] == 1) {
                             $graph[$nameEvent . 'Featured' . $listingTypeID]['statistic'] = $dateStatistics[$nameEvent . $listingTypeID]['count'];
                         }
                         if (!empty($dateStatistics[$nameEvent . $listingTypeID]['priority']) && $dateStatistics[$nameEvent . $listingTypeID]['priority'] == 1) {
                             $graph[$nameEvent . 'Priority' . $listingTypeID]['statistic'] = $dateStatistics[$nameEvent . $listingTypeID]['count'];
                         }
                     }
                 }
                 break;
             case 'addUser':
             case 'addUserlinkedin':
             case 'addUserfacebook':
             case 'addUsergoogle':
                 foreach ($userGroups as $userGroupInfo) {
                     $userGroupID = $userGroupInfo['id'];
                     $userGroup = $userGroupInfo['caption'];
                     if ($userGroupInfo['key'] == 'JobSeeker' || $userGroupInfo['key'] == 'Employer') {
                         $userGroup = $userGroupInfo['key'] . 's';
                     } else {
                         $userGroup = '"' . $userGroup . '" Users';
                     }
                     $graph[$nameEvent . $userGroupID]['title'] = str_replace('#userGroupName#', $userGroup, $title);
                     if (!empty($dateStatistics[$nameEvent . $userGroupID]['type']) && $dateStatistics[$nameEvent . $userGroupID]['type'] == $userGroupID) {
                         $graph[$nameEvent . $userGroupID]['statistic'] = $dateStatistics[$nameEvent . $userGroupID]['count'];
                     } else {
                         $graph[$nameEvent . $userGroupID]['statistic'] = 0;
                     }
                 }
                 break;
             case 'deleteUser':
                 $countUsers = 0;
                 foreach ($userGroups as $userGroupInfo) {
                     $userGroupID = $userGroupInfo['id'];
                     if (!empty($dateStatistics[$nameEvent . $userGroupID]['type']) && $dateStatistics[$nameEvent . $userGroupID]['type'] == $userGroupID) {
                         $countUsers += $dateStatistics[$nameEvent . $userGroupID]['count'];
                     }
                 }
                 $graph['deleteUser']['title'] = $title;
                 $graph['deleteUser']['statistic'] = $countUsers;
                 break;
             case 'payment':
                 $graph['totalAmount']['title'] = 'Total Sales';
                 $graph['totalAmount']['statistic'] = !empty($dateStatistics['totalAmount']['count']) ? $dateStatistics['totalAmount']['count'] : 0;
                 foreach ($userGroups as $userGroupInfo) {
                     $userGroupID = $userGroupInfo['id'];
                     $userGroup = $userGroupInfo['caption'];
                     if ($userGroupInfo['key'] == 'JobSeeker' || $userGroupInfo['key'] == 'Employer') {
                         $userGroup = $userGroupInfo['key'] . 's';
                     } else {
                         $userGroup = '"' . $userGroup . '" Users';
                     }
                     $graph['amount_' . $userGroupID]['title'] = str_replace('#userGroupName#', $userGroup, $title);
                     $graph['amount_' . $userGroupID]['statistic'] = !empty($dateStatistics['amount_' . $userGroupID]['count']) ? $dateStatistics['amount_' . $userGroupID]['count'] : 0;
                 }
                 break;
             case 'apply':
                 $graph[$nameEvent]['title'] = $title;
                 $graph[$nameEvent]['statistic'] = !empty($dateStatistics[$nameEvent]['count']) ? $dateStatistics[$nameEvent]['count'] : 0;
                 $graph[$nameEvent . 'Approved']['title'] = "Number of Applications Approved";
                 $graph[$nameEvent . 'Rejected']['title'] = "Number of Applications Rejected";
                 $graph[$nameEvent . 'Approved']['statistic'] = 0;
                 $graph[$nameEvent . 'Rejected']['statistic'] = 0;
                 if (!empty($dateStatistics[$nameEvent]['approve']) && $dateStatistics[$nameEvent]['approve'] == 1) {
                     $graph[$nameEvent . 'Approved']['statistic'] = $dateStatistics[$nameEvent]['count'];
                 }
                 if (!empty($dateStatistics[$nameEvent]['reject']) && $dateStatistics[$nameEvent]['reject'] == 1) {
                     $graph[$nameEvent . 'Rejected']['statistic'] = $dateStatistics[$nameEvent]['count'];
                 }
                 break;
             default:
                 $graph[$nameEvent]['title'] = $title;
                 $graph[$nameEvent]['statistic'] = !empty($dateStatistics[$nameEvent]['count']) ? $dateStatistics[$nameEvent]['count'] : 0;
                 break;
         }
     }
     return $graph;
 }
Exemplo n.º 24
0
 /**
  * fill user object with values from social account
  * also adds some reference data
  * @param SJB_User $user
  * @return SJB_User
  */
 public static function addReferenceDetails(SJB_User $user)
 {
     if (self::$oProfile) {
         parent::fillRegistrationDataWithUser($user);
         parent::addReferenceDetails($user, self::NETWORK_ID);
     }
     return $user;
 }