Example #1
0
 function doView($file)
 {
     osc_run_hook('before_html');
     osc_current_web_theme_path($file);
     Session::newInstance()->_clearVariables();
     osc_run_hook('after_html');
 }
Example #2
0
 public function processEditForm($new_item = array(), $files = array())
 {
     $param_name = 'new_item';
     Session::newInstance()->_setForm($param_name, $new_item);
     // keep values on session
     Session::newInstance()->_keepForm($param_name);
     $default_fields = array('gn_id' => NULL, 'gn_title' => '', 'gn_description' => '', 'gn_tags' => '', 'gn_lang' => osc_current_admin_locale());
     $new_item = array_merge($default_fields, $new_item);
     if (!$new_item['gn_title']) {
         throw new Exception(__('The title must not be empty', 'gz_news'));
     }
     if (!$new_item['gn_description']) {
         throw new Exception(__('The description must not be empty', 'gz_news'));
     }
     $dao = GzNewsDao::newInstance();
     if ($new_item['gn_id']) {
         $item_exists = $dao->findByPrimaryKey($new_item['gn_id']);
         if ($item_exists == FALSE) {
             throw new Exception(__('The new does not exists anymore', 'gz_news'));
         }
     }
     $success = $dao->save($new_item);
     if ($success) {
         if (!empty($files)) {
             $this->uploadFiles($success, $files);
         }
         Session::newInstance()->_dropKeepForm($param_name);
     }
     return $success;
 }
Example #3
0
 function doView($file)
 {
     osc_run_hook("before_admin_html");
     osc_current_admin_theme_path($file);
     Session::newInstance()->_clearVariables();
     osc_run_hook("after_admin_html");
 }
Example #4
0
 function doModel()
 {
     switch ($this->action) {
         case 'logout':
             // unset only the required parameters in Session
             Session::newInstance()->_drop('adminId');
             Session::newInstance()->_drop('adminUserName');
             Session::newInstance()->_drop('adminName');
             Session::newInstance()->_drop('adminEmail');
             Session::newInstance()->_drop('adminLocale');
             Cookie::newInstance()->pop('oc_adminId');
             Cookie::newInstance()->pop('oc_adminSecret');
             Cookie::newInstance()->pop('oc_adminLocale');
             Cookie::newInstance()->set();
             $this->redirectTo(osc_admin_base_url(true));
             break;
         default:
             //default dashboard page (main page at oc-admin)
             $this->_exportVariableToView("numUsers", User::newInstance()->count());
             $this->_exportVariableToView("numAdmins", Admin::newInstance()->count());
             $this->_exportVariableToView("numItems", Item::newInstance()->count());
             $this->_exportVariableToView("numItemsPerCategory", CategoryStats::newInstance()->toNumItemsMap());
             $this->_exportVariableToView("categories", Category::newInstance()->listAll());
             $this->_exportVariableToView("newsList", osc_listNews());
             $this->_exportVariableToView("comments", ItemComment::newInstance()->getLastComments(5));
             //calling the view...
             $this->doView('main/index.php');
     }
 }
Example #5
0
        public function __construct()
        {
            parent::__construct();
            $this->path = osc_themes_path();

            if( Params::getParam('theme') != '' && Session::newInstance()->_get('adminId') != '' ) {
                $this->setCurrentTheme( Params::getParam('theme') );
            } else {
                $this->setCurrentTheme( osc_theme() );
            }

            $functions_path = $this->getCurrentThemePath() . 'functions.php';
            if( file_exists($functions_path) ) {
                require_once $functions_path;
            }

            $info = $this->loadThemeInfo($this->theme);
            if($info['template'] != '' ) {
				//$this->setCurrentTheme($info['template']);
				$parent_functions_path = osc_base_path() . 'oc-content/themes/' . $info['template'] . '/functions.php';
				if( file_exists($parent_functions_path) ) {
					require_once $parent_functions_path;
				}
			}
        }
Example #6
0
function osc_show_flash_message($section = 'pubMessages', $class = "FlashMessage", $id = "FlashMessage")
{
    $message = Session::newInstance()->_getMessage($section);
    if ($message != '') {
        echo '<div id="' . $id . '" class="' . $class . '">';
        echo Session::newInstance()->_getMessage($section);
        echo '</div>';
        Session::newInstance()->_dropMessage($section);
    }
}
Example #7
0
 public static function your_message()
 {
     if (Session::newInstance()->_getForm("message_body") != "") {
         $message_body = Session::newInstance()->_getForm("message_body");
         parent::generic_textarea("message", $message_body, null, false);
     } else {
         parent::generic_textarea("message", "");
     }
     return true;
 }
Example #8
0
 public static function body_input_textarea($comment = null)
 {
     $commentBody = '';
     if (isset($comment['s_body'])) {
         $commentBody = $comment['s_body'];
     }
     if (Session::newInstance()->_getForm('commentBody') != '') {
         $commentBody = Session::newInstance()->_getForm('commentBody');
     }
     parent::generic_textarea("body", $commentBody);
 }
Example #9
0
 function logout()
 {
     //destroying session
     Session::newInstance()->session_destroy();
     Session::newInstance()->_drop('userId');
     Session::newInstance()->_drop('userName');
     Session::newInstance()->_drop('userEmail');
     Session::newInstance()->_drop('userPhone');
     Cookie::newInstance()->pop('oc_userId');
     Cookie::newInstance()->pop('oc_userSecret');
     Cookie::newInstance()->set();
 }
Example #10
0
/**
 * Re-send the flash messages of the given section. Usefull for custom theme/plugins files.
 *
 * @param string $$section
 */
function osc_resend_flash_messages($section = "pubMessages")
{
    $message = Session::newInstance()->_getMessage($section);
    if ($message["type"] == "info") {
        osc_add_flash_info_message($message['msg'], $section);
    } else {
        if ($message["type"] == "ok") {
            osc_add_flash_ok_message($message['msg'], $section);
        } else {
            osc_add_flash_error_message($message['msg'], $section);
        }
    }
}
Example #11
0
 public function __construct()
 {
     $this->path = osc_themes_path();
     if (Params::getParam('theme') != '' && Session::newInstance()->_get('adminId') != '') {
         $this->setCurrentTheme(Params::getParam('theme'));
     } else {
         $this->setCurrentTheme(osc_theme());
     }
     $functions_path = $this->getCurrentThemePath() . 'functions.php';
     if (file_exists($functions_path)) {
         require_once $functions_path;
     }
 }
Example #12
0
 public function __construct()
 {
     //#dev.conquer this fix is needed for the preview of appearance in oc-admin
     if (Params::getParam('theme') != '' && Session::newInstance()->_get('adminId') != '') {
         $this->setCurrentTheme(Params::getParam('theme'));
     } else {
         $this->setCurrentTheme(osc_theme());
     }
     //#juanramon: check if exists functions.php
     $functions_path = $this->getCurrentThemePath() . 'functions.php';
     if (file_exists($functions_path)) {
         require_once $functions_path;
     }
 }
Example #13
0
 function logout()
 {
     //destroying session
     Session::newInstance()->session_destroy();
     Session::newInstance()->_drop('adminId');
     Session::newInstance()->_drop('adminUserName');
     Session::newInstance()->_drop('adminName');
     Session::newInstance()->_drop('adminEmail');
     Session::newInstance()->_drop('adminLocale');
     Cookie::newInstance()->pop('oc_adminId');
     Cookie::newInstance()->pop('oc_adminSecret');
     Cookie::newInstance()->pop('oc_adminLocale');
     Cookie::newInstance()->set();
 }
Example #14
0
 function logout()
 {
     //destroying session
     $locale = Session::newInstance()->_get('userLocale');
     Session::newInstance()->session_destroy();
     Session::newInstance()->_drop('userId');
     Session::newInstance()->_drop('userName');
     Session::newInstance()->_drop('userEmail');
     Session::newInstance()->_drop('userPhone');
     Session::newInstance()->session_start();
     Session::newinstance()->_set('userLocale', $locale);
     Cookie::newInstance()->pop('oc_userId');
     Cookie::newInstance()->pop('oc_userSecret');
     Cookie::newInstance()->set();
 }
Example #15
0
 public static function multilanguage_name_description($locales, $page = null)
 {
     $num_locales = count($locales);
     if ($num_locales > 1) {
         echo '<div class="tabber">';
     }
     $aFieldsDescription = Session::newInstance()->_getForm("aFieldsDescription");
     foreach ($locales as $locale) {
         if ($num_locales > 1) {
             echo '<div class="tabbertab">';
             echo '<h2>' . $locale['s_name'] . '</h2>';
         }
         echo '<div class="FormElement">';
         echo '<div class="FormElementName">' . __('Title') . '</div>';
         echo '<div class="FormElementInput">';
         $title = '';
         if (isset($page['locale'][$locale['pk_c_code']])) {
             $title = $page['locale'][$locale['pk_c_code']]['s_title'];
         }
         if (isset($aFieldsDescription[$locale['pk_c_code']]) && isset($aFieldsDescription[$locale['pk_c_code']]['s_title']) && $aFieldsDescription[$locale['pk_c_code']]['s_title'] != '') {
             $title = $aFieldsDescription[$locale['pk_c_code']]['s_title'];
         }
         parent::generic_input_text($locale['pk_c_code'] . '#s_title', $title);
         echo '</div>';
         echo '</div>';
         echo '<div class="FormElement">';
         echo '<div class="FormElementName">' . __('Body') . '</div>';
         echo '<div class="FormElementInput">';
         $description = '';
         if (isset($page['locale'][$locale['pk_c_code']])) {
             $description = $page['locale'][$locale['pk_c_code']]['s_text'];
         }
         if (isset($aFieldsDescription[$locale['pk_c_code']]) && isset($aFieldsDescription[$locale['pk_c_code']]['s_text']) && $aFieldsDescription[$locale['pk_c_code']]['s_text'] != '') {
             $description = $aFieldsDescription[$locale['pk_c_code']]['s_text'];
         }
         parent::generic_textarea($locale['pk_c_code'] . '#s_text', $description);
         echo '</div>';
         echo '</div>';
         if ($num_locales > 1) {
             echo '</div>';
         }
     }
     if ($num_locales > 1) {
         echo '</div>';
     }
 }
Example #16
0
function osc_show_recaptcha($section = '')
{
    if (osc_recaptcha_public_key()) {
        require_once osc_lib_path() . 'recaptchalib.php';
        switch ($section) {
            case 'recover_password':
                $time = Session::newInstance()->_get('recover_time');
                if (time() - $time <= 1200) {
                    echo recaptcha_get_html(osc_recaptcha_public_key()) . "<br />";
                }
                break;
            default:
                echo recaptcha_get_html(osc_recaptcha_public_key());
                break;
        }
    }
}
Example #17
0
 function doModel()
 {
     switch ($this->action) {
         case 'logout':
             // unset only the required parameters in Session
             Session::newInstance()->_drop('userId');
             Session::newInstance()->_drop('userName');
             Session::newInstance()->_drop('userEmail');
             Session::newInstance()->_drop('userPhone');
             Cookie::newInstance()->pop('oc_userId');
             Cookie::newInstance()->pop('oc_userSecret');
             Cookie::newInstance()->set();
             $this->redirectTo(osc_base_url());
             break;
         default:
             $this->doView('main.php');
     }
 }
Example #18
0
 function doModel()
 {
     switch ($this->action) {
         case 'change_email_confirm':
             //change email confirm
             if (Params::getParam('userId') && Params::getParam('code')) {
                 $userManager = new User();
                 $user = $userManager->findByPrimaryKey(Params::getParam('userId'));
                 if ($user['s_pass_code'] == Params::getParam('code')) {
                     $userEmailTmp = UserEmailTmp::newInstance()->findByPk(Params::getParam('userId'));
                     $code = osc_genRandomPassword(50);
                     $userManager->update(array('s_email' => $userEmailTmp['s_new_email']), array('pk_i_id' => $userEmailTmp['fk_i_user_id']));
                     Item::newInstance()->update(array('s_contact_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
                     ItemComment::newInstance()->update(array('s_author_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
                     Alerts::newInstance()->update(array('s_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
                     Session::newInstance()->_set('userEmail', $userEmailTmp['s_new_email']);
                     UserEmailTmp::newInstance()->delete(array('s_new_email' => $userEmailTmp['s_new_email']));
                     osc_add_flash_message(_m('Your email has been changed successfully'));
                     $this->redirectTo(osc_user_profile_url());
                 } else {
                     osc_add_flash_message(_m('Sorry, the link is not valid'));
                     $this->redirectTo(osc_base_url());
                 }
             } else {
                 osc_add_flash_message(_m('Sorry, the link is not valid'));
                 $this->redirectTo(osc_base_url());
             }
             break;
         case 'unsub_alert':
             $email = Params::getParam('email');
             $alert = Params::getParam('alert');
             if ($email != '' && $alert != '') {
                 Alerts::newInstance()->delete(array('s_email' => $email, 's_search' => $alert));
                 osc_add_flash_message(__('Unsubscribed correctly.'));
             } else {
                 osc_add_flash_message(__('Ops! There was a problem trying to unsubscribe you. Please contact the administrator.'));
             }
             $this->redirectTo(osc_base_url());
             break;
         default:
             $this->redirectTo(osc_user_login_url());
             break;
     }
 }
Example #19
0
    /**
     * Re-send the flash messages of the given section. Usefull for custom theme/plugins files.
     *
     * @param string $$section
     */
    function osc_resend_flash_messages($section = "pubMessages") {
        $messages = Session::newInstance()->_getMessage($section);
        if (is_array($messages)) {

            foreach ($messages as $message) {
      
                $message = Session::newInstance()->_getMessage($section);
                if(isset($message['msg'])) {
                    if(isset($message["type"]) && $message["type"]=="info") {
                        osc_add_flash_info_message($message['msg'], $section);
                    } else if(isset($message["type"]) && $message["type"]=="ok") {
                        osc_add_flash_ok_message($message['msg'], $section);
                    } else {
                        osc_add_flash_error_message($message['msg'], $section);
                    }
                }
            }
        }
    }
Example #20
0
 function handleUpload($uploadFilename, $replace = false)
 {
     if (!is_writable(dirname($uploadFilename))) {
         return array('error' => __("Server error. Upload directory isn't writable."));
     }
     if (!$this->_file) {
         return array('error' => __('No files were uploaded.'));
     }
     $size = $this->_file->getSize();
     if ($size == 0) {
         return array('error' => __('File is empty'));
     }
     if ($size > $this->_sizeLimit) {
         return array('error' => __('File is too large'));
     }
     $pathinfo = pathinfo($this->_file->getOriginalName());
     $ext = @$pathinfo['extension'];
     $uuid = pathinfo($uploadFilename);
     if ($this->_allowedExtensions && stripos($this->_allowedExtensions, strtolower($ext)) === false) {
         @unlink($uploadFilename);
         // Wrong extension, remove it for security reasons
         return array('error' => sprintf(__('File has an invalid extension, it should be one of %s.'), $this->_allowedExtensions));
     }
     if (!$replace) {
         if (file_exists($uploadFilename)) {
             return array('error' => 'Could not save uploaded file. File already exists');
         }
     }
     if ($this->_file->save($uploadFilename)) {
         $result = $this->checkAllowedExt($uploadFilename);
         if (!$result) {
             @unlink($uploadFilename);
             // Wrong extension, remove it for security reasons
             return array('error' => sprintf(__('File has an invalid extension, it should be one of %s.'), $this->_allowedExtensions));
         }
         $files = Session::newInstance()->_get('ajax_files');
         $files[Params::getParam('qquuid')] = $uuid['basename'];
         Session::newInstance()->_set('ajax_files', $files);
         return array('success' => true);
     } else {
         return array('error' => 'Could not save uploaded file. The upload was cancelled, or server error encountered');
     }
 }
Example #21
0
 public static function meta($field = null)
 {
     if ($field != null) {
         if (Session::newInstance()->_getForm('meta_' . $field['pk_i_id']) != "") {
             $field['s_value'] = Session::newInstance()->_getForm('meta_' . $field['pk_i_id']);
         }
         echo '<label for="meta_' . $field['s_slug'] . '">' . $field['s_name'] . ': </label>';
         if ($field['e_type'] == "TEXTAREA") {
             echo '<textarea id="meta_' . $field['s_slug'] . '" name="meta[' . $field['pk_i_id'] . ']" rows="10">' . (isset($field) && isset($field["s_value"]) ? $field["s_value"] : "") . '</textarea>';
         } else {
             if ($field['e_type'] == "DROPDOWN") {
                 if (isset($field) && isset($field['s_options'])) {
                     $options = explode(",", $field['s_options']);
                     if (count($options) > 0) {
                         echo '<select name="meta[' . $field['pk_i_id'] . ']" id="meta_' . $field['s_slug'] . '">';
                         foreach ($options as $option) {
                             echo '<option value="' . $option . '" ' . ($field['s_value'] == $option ? 'selected="selected"' : '') . '>' . $option . '</option>';
                         }
                         echo '</select>';
                     }
                 }
             } else {
                 if ($field['e_type'] == "RADIO") {
                     if (isset($field) && isset($field['s_options'])) {
                         $options = explode(",", $field['s_options']);
                         if (count($options) > 0) {
                             echo '<ul style="float:left;" >';
                             foreach ($options as $key => $option) {
                                 echo '<li><input type="radio" name="meta[' . $field['pk_i_id'] . ']" id="meta_' . $field['s_slug'] . '_' . $key . '" value="' . $option . '" ' . ($field['s_value'] == $option ? 'checked' : '') . '/><label style="float:none;" for="meta_' . $field['s_slug'] . '_' . $key . '">' . $option . '</label></li>';
                             }
                             echo '</ul>';
                         }
                     }
                 } else {
                     echo '<input id="meta_' . $field['s_slug'] . '" type="text" name="meta[' . $field['pk_i_id'] . ']" value="' . htmlentities(isset($field) && isset($field["s_value"]) ? $field["s_value"] : "", ENT_COMPAT, "UTF-8") . '" ';
                     echo '/>';
                 }
             }
         }
     }
 }
Example #22
0
 function doModel()
 {
     $id = Params::getParam('id');
     $page = $this->pageManager->findByPrimaryKey($id);
     if (empty($page) || $page['b_indelible'] == 1) {
         $this->do404();
     } else {
         if (file_exists(osc_themes_path() . osc_theme() . '/' . $page['s_internal_name'] . ".php")) {
             $this->doView($page['s_internal_name'] . ".php");
         } else {
             if (file_exists(osc_themes_path() . osc_theme() . '/pages/' . $page['s_internal_name'] . ".php")) {
                 $this->doView("pages/" . $page['s_internal_name'] . ".php");
             } else {
                 //calling the view...
                 if (Params::getParam('lang') != '') {
                     Session::newInstance()->_set('userLocale', Params::getParam('lang'));
                 }
                 $this->_exportVariableToView('page', $page);
                 $this->doView('page.php');
             }
         }
     }
 }
Example #23
0
/**
 * Gets logged admin email
 *
 * @return string
 */
function osc_logged_admin_email()
{
    return (string) Session::newInstance()->_get('adminEmail');
}
Example #24
0
 function showAuthFailPage()
 {
     if (Params::getParam('page') == 'ajax') {
         echo json_encode(array('error' => 1, 'msg' => __('Session timed out')));
     } else {
         //Session::newInstance()->session_start();
         Session::newInstance()->_setReferer(osc_base_url() . preg_replace('|^' . REL_WEB_URL . '|', '', $_SERVER['REQUEST_URI']));
         header("Location: " . osc_admin_base_url(true) . "?page=login");
         exit;
     }
 }
Example #25
0
function printLocaleDescriptionPage($locales = null, $page = null)
{
    if ($locales == null) {
        $locales = osc_get_locales();
    }
    $aFieldsDescription = Session::newInstance()->_getForm("aFieldsDescription");
    $num_locales = count($locales);
    foreach ($locales as $locale) {
        $description = '';
        if (isset($page['locale'][$locale['pk_c_code']])) {
            $description = $page['locale'][$locale['pk_c_code']]['s_text'];
        }
        if (isset($aFieldsDescription[$locale['pk_c_code']]) && isset($aFieldsDescription[$locale['pk_c_code']]['s_text']) && $aFieldsDescription[$locale['pk_c_code']]['s_text'] != '') {
            $description = $aFieldsDescription[$locale['pk_c_code']]['s_text'];
        }
        $name = $locale['pk_c_code'] . '#s_text';
        echo '<div><label for="description">' . __('Description') . ' *</label>';
        echo '<textarea id="' . $name . '" name="' . $name . '" rows="10">' . $description . '</textarea></div>';
    }
}
Example #26
0
        public function sendEmails($aItem){

            $item   = $aItem['item'];
            View::newInstance()->_exportVariableToView('item', $item);

            /**
             * Send email to non-reg user requesting item activation
             */
            if( Session::newInstance()->_get('userId') == '' && $aItem['active']=='INACTIVE' ) {
                osc_run_hook('hook_email_item_validation_non_register_user', $item);
            } else if ( $aItem['active']=='INACTIVE' ) { //  USER IS REGISTERED
                osc_run_hook('hook_email_item_validation', $item);
            } else if( Session::newInstance()->_get('userId') == '' ){ // USER IS NOT REGISTERED
                osc_run_hook('hook_email_new_item_non_register_user', $item);
            }

            /**
             * Send email to admin about the new item
             */
            if (osc_notify_new_item()) {
                osc_run_hook('hook_email_admin_new_item', $item);
            }
        }
Example #27
0
 public static function show_email_checkbox($item = null)
 {
     if ($item == null) {
         $item = osc_item();
     }
     if (Session::newInstance()->_getForm('showEmail') != 0) {
         $item['b_show_email'] = Session::newInstance()->_getForm('showEmail');
     }
     parent::generic_input_checkbox('showEmail', '1', isset($item['b_show_email']) ? $item['b_show_email'] : false);
     return true;
 }
Example #28
0
/**
 *
 *
 * @param string $section
 * @return string Message
 */
function osc_get_flash_message($section = 'pubMessages', $dropMessages = true)
{
    $message = Session::newInstance()->_getMessage($section);
    if ($dropMessages) {
        Session::newInstance()->_dropMessage($section);
    }
    return $message;
}
Example #29
0
function make_userlogin()
{
    if (isset($_GET['page'])) {
        return;
    }
    $facebookData = FacebookClassified::newInstance()->selectFacebookData();
    $api_id = osc_get_preference('facebook_api_id', 'classified');
    $api_secret = osc_get_preference('facebook_api_secret', 'classified');
    if (isset($_GET['code']) and !empty($_GET['code'])) {
        $code = $_GET['code'];
        if (!empty($code)) {
            $get_access_data = facebookall_get_fb_contents("https://graph.facebook.com/v2.3/oauth/access_token?" . 'client_id=' . $api_id . '&redirect_uri=' . urlencode(osc_base_url()) . '&client_secret=' . $api_secret . '&code=' . urlencode($code));
            $access_data = json_decode($get_access_data, true);
        }
        if (empty($access_data['access_token'])) {
            $get_access_data = facebookall_get_fb_contents("https://graph.facebook.com/v2.3/oauth/access_token?" . 'client_id=' . $api_id . '&redirect_uri=' . urlencode(osc_base_url()) . '&client_secret=' . $api_secret . '&code=' . urlencode($code));
            $access_data = json_decode($get_access_data, true);
        }
        if (!empty($access_data['access_token'])) {
            $access_token = $access_data['access_token'];
        } else {
            echo 'Error : Could not get access token please check your app settings for more about this error<br> Or Follow our doc setion <a href="http://sourceaddons.com/documentation">Documentation Section</a>.';
            exit;
        }
        ?>
    <script>
      window.opener.FbAll.parentRedirect({'action' : 'fball', 'fball_access_token' : '<?php 
        echo $access_token;
        ?>
'});
      window.close();
    </script>
    <?php 
    }
    if (!empty($_REQUEST['fball_access_token']) and isset($_REQUEST['fball_redirect'])) {
        $user_info = json_decode(facebookall_get_fb_contents("https://graph.facebook.com/v2.3/me?access_token=" . $_REQUEST['fball_access_token']));
        Session::newInstance()->_set('fb-token', $_REQUEST['fball_access_token']);
        $user_data = get_userprofile_data($user_info);
        if (!empty($user_data['email']) and !empty($user_data['id'])) {
            // Filter username form data.
            if (!empty($user_data['name'])) {
                $username = $user_data['name'];
            } else {
                if (!empty($user_data['first_name']) && !empty($user_data['last_name'])) {
                    $username = $user_data['first_name'] . $user_data['last_name'];
                } else {
                    $user_emailname = explode('@', $user_data['email']);
                    $username = $user_emailname[0];
                }
            }
            $user_login = $username;
            $new_user = false;
            $user_id = get_userid($user_data['id']);
            if (empty($user_id)) {
                //Not Registered As Facebook User
                $u_data = User::newInstance()->findByEmail($user_data['email']);
                if (!empty($u_data)) {
                    //Registered As OSClass but not as Facebook User
                    $user = User::newInstance()->findByEmail($user_data['email']);
                    insert_facebook_user_data($user['pk_i_id'], $user_data['id']);
                } else {
                    //New User Not Registered as Facebook User And OSClass User
                    $new_user = true;
                    register_user($user_data);
                }
            }
            $manager = User::newInstance();
            $oscUser = $manager->findByEmail($user_data['email']);
            $email = $oscUser['pk_i_id'];
            require_once osc_lib_path() . 'osclass/UserActions.php';
            $uActions = new UserActions(false);
            $logged = $uActions->bootstrap_login($oscUser['pk_i_id']);
            // Redirect user.
            osc_redirect_to(osc_user_dashboard_url());
            /*
              if (!empty ($_GET['redirect_to'])) {
                $redirect_to = $_GET['redirect_to'];
                wp_safe_redirect ($redirect_to);
              }
              else {
                $redirect_to = facebookall_redirect_loggedin_user();
                wp_redirect ($redirect_to);
              }
              exit();
            }
            */
        }
    }
}
Example #30
0
/**
 * Get the actual locale of the admin.
 *
 * You get the right locale code. If an admin is using the website in another language different of the default one, or
 * the admin uses the default one, you'll get it.
 *
 * @return string OSCLocale Code
 */
function osc_current_admin_locale()
{
    if (Session::newInstance()->_get('adminLocale') != '') {
        return Session::newInstance()->_get('adminLocale');
    }
    return osc_admin_language();
}