/** * Initiate this module * * @access public * @return void */ public function init() { $this->tab_name = ipsRegistry::getClass('class_localization')->words['tab__core']; /* Facebook? */ if (IPSLib::fbc_enabled() === TRUE and $this->memberData['fb_uid']) { require_once IPS_ROOT_PATH . 'sources/classes/facebook/connect.php'; $facebook = new facebook_connect($this->registry); /* Test connection */ $facebook->testConnectSession(); try { $fbuid = $facebook->FB()->get_loggedin_user(); } catch (Exception $e) { } if ($fbuid) { $this->_isFBUser = true; } } }
/** * Parse a member's profile photo * * @access public * @param mixed Either array of member data, or member ID to self load * @return array Member's photo details */ public static function buildProfilePhoto($member) { //----------------------------------------- // Load the member? //----------------------------------------- if (!is_array($member) and $member == intval($member) and $member > 0) { $member = self::load($member, 'extendedProfile'); } else { if ($member == 0) { $member = array(); } } //----------------------------------------- // Facebook Sync //----------------------------------------- if (IPSLib::fbc_enabled() === TRUE) { if ($member['fb_uid'] and $member['fb_bwoptions']) { $_sync = time() - 86400; $_active = time() - 86400 * 90; /* We have a linked member and options, so check if they haven't sync'd in 24 hours and have been active in the past 90 days... */ if ($member['fb_lastsync'] < $_sync and $member['last_visit'] > $_active) { require_once IPS_ROOT_PATH . 'sources/classes/facebook/connect.php'; $facebook = new facebook_connect(ipsRegistry::instance()); try { $member = $facebook->syncMember($member); } catch (Exception $error) { $msg = $error->getMessage(); switch ($msg) { case 'NOT_LINKED': case 'NO_MEMBER': break; } } } } } //----------------------------------------- // Facebook? //----------------------------------------- if ($member['fb_photo'] and ipsRegistry::member()->getProperty('g_mem_info')) { $member['_has_photo'] = 1; /* Main... */ $member['pp_main_photo'] = $member['fb_photo']; $member['pp_main_width'] = '*'; $member['pp_main_height'] = '*'; /* Thumb */ $member['pp_thumb_photo'] = $member['fb_photo_thumb']; $member['pp_thumb_width'] = 50; $member['pp_thumb_height'] = 50; /* Mini */ $member['pp_mini_photo'] = $member['fb_photo_thumb']; $member['pp_mini_width'] = 25; $member['pp_mini_height'] = 25; } else { //----------------------------------------- // Main photo //----------------------------------------- if (!$member['pp_main_photo'] or !ipsRegistry::member()->getProperty('g_mem_info')) { $member['pp_main_photo'] = ipsRegistry::$settings['img_url'] . '/profile/default_large.png'; $member['pp_main_width'] = 150; $member['pp_main_height'] = 150; $member['_has_photo'] = 0; } else { $member['pp_main_photo'] = ipsRegistry::$settings['upload_url'] . '/' . $member['pp_main_photo']; $member['_has_photo'] = 1; } //----------------------------------------- // Thumbie //----------------------------------------- if (!$member['pp_thumb_photo'] or $member['pp_thumb_photo'] == 'profile/') { if ($member['_has_photo']) { $member['pp_thumb_photo'] = $member['pp_main_photo']; } else { $member['pp_thumb_photo'] = ipsRegistry::$settings['img_url'] . '/profile/default_thumb.png'; } $member['pp_thumb_width'] = 50; $member['pp_thumb_height'] = 50; } else { if ($member['_has_photo']) { $member['pp_thumb_photo'] = ipsRegistry::$settings['upload_url'] . '/' . $member['pp_thumb_photo']; } else { $member['pp_thumb_photo'] = ipsRegistry::$settings['img_url'] . '/profile/default_thumb.png'; } } //----------------------------------------- // Mini //----------------------------------------- $_data = IPSLib::scaleImage(array('max_height' => 25, 'max_width' => 25, 'cur_width' => $member['pp_thumb_width'], 'cur_height' => $member['pp_thumb_height'])); $member['pp_mini_photo'] = $member['pp_thumb_photo']; $member['pp_mini_width'] = $_data['img_width']; $member['pp_mini_height'] = $_data['img_height']; } return $member; }
/** * Main class entry point * * @access public * @param object ipsRegistry reference * @return void [Outputs to screen] */ public function doExecute(ipsRegistry $registry) { //----------------------------------------- // INIT //----------------------------------------- $_thisNav = array(); //----------------------------------------- // Load language //----------------------------------------- $this->registry->getClass('class_localization')->loadLanguageFile(array('public_usercp')); //----------------------------------------- // Logged in? //----------------------------------------- if (!$this->memberData['member_id']) { $this->registry->getClass('output')->silentRedirect($this->settings['base_url'] . '&app=core&module=global§ion=login&do=form'); exit; } //----------------------------------------- // Make sure they're clean //----------------------------------------- $this->request['tab'] = IPSText::alphanumericalClean($this->request['tab']); $this->request['area'] = IPSText::alphanumericalClean($this->request['area']); //----------------------------------------- // Set up some basics... //----------------------------------------- $_TAB = $this->request['tab'] ? $this->request['tab'] : 'core'; $_AREA = $this->request['area'] ? $this->request['area'] : 'settings'; $_DO = $this->request['do'] ? $this->request['do'] : 'show'; $_FUNC = $_DO == 'show' ? 'showForm' : ($_DO == 'save' ? 'saveForm' : $_DO); $tabs = array(); $errors = array(); //----------------------------------------- // Got a plug in? //----------------------------------------- require_once IPS_ROOT_PATH . 'sources/interfaces/interface_usercp.php'; $_FILE = IPSLib::getAppDir($_TAB) . '/extensions/usercpForms.php'; $_CLASS = 'usercpForms_' . $_TAB; if (!file_exists($_FILE)) { $this->registry->getClass('output')->showError('usercp_bad_tab', 10147); exit; } //----------------------------------------- // Grab tabs //----------------------------------------- foreach (ipsRegistry::$applications as $app_dir => $app_data) { if (IPSLib::appIsInstalled($app_dir)) { $__file = IPSLib::getAppDir($app_dir) . '/extensions/usercpForms.php'; $__class = 'usercpForms_' . $app_dir; if (file_exists($__file)) { require_once $__file; $_usercp_module = new $__class(); $_usercp_module->makeRegistryShortcuts($this->registry); if (is_callable(array($_usercp_module, 'init'))) { $_usercp_module->init(); /* Set default area? */ if ($_TAB == $app_dir and !isset($_REQUEST['area'])) { if (isset($_usercp_module->defaultAreaCode)) { $this->request['area'] = $_AREA = $_usercp_module->defaultAreaCode; } } } if (is_callable(array($_usercp_module, 'getLinks'))) { $tabs[$app_dir]['_name'] = $_usercp_module->tab_name ? $_usercp_module->tab_name : IPSLib::getAppTitle($app_dir); $tabs[$app_dir]['_menu'] = $_usercp_module->getLinks(); if (!$tabs[$app_dir]['_menu']) { unset($tabs[$app_dir]); } /* Add in 'last' element */ $tabs[$app_dir]['_menu'][count($tabs[$app_dir]['_menu']) - 1]['last'] = 1; /* This nav? */ if (!count($_thisNav) and $app_dir == $_TAB) { foreach ($tabs[$app_dir]['_menu'] as $_navData) { if ($_navData['url'] == 'area=' . $_AREA) { $_thisNav = array('app=core&module=usercp&tab=' . $_TAB . '&area=' . $_AREA, $_navData['title']); } } } } } } } //----------------------------------------- // Set up basic navigation //----------------------------------------- $this->_nav[] = array($this->lang->words['t_title'], '&app=core&module=usercp'); if (isset($_thisNav[0])) { $this->_nav[] = array($_thisNav[1], $_thisNav[0]); } //----------------------------------------- // Load it... //----------------------------------------- require_once $_FILE; $usercp_module = new $_CLASS(); $usercp_module->makeRegistryShortcuts($this->registry); $usercp_module->init(); if ($_DO == 'saveForm' || $_DO == 'showForm' and !is_callable(array($usercp_module, $_FUNC))) { $this->registry->getClass('output')->showError('usercp_bad_tab', 10148, true); exit; } //----------------------------------------- // Run it... //----------------------------------------- if ($_FUNC == 'showForm') { //----------------------------------------- // Facebook email //----------------------------------------- //@facebook concession if (IPSLib::fbc_enabled() === TRUE) { if (!$this->memberData['fb_emailallow'] and strstr($this->memberData['email'], '@proxymail.facebook.com')) { require_once IPS_ROOT_PATH . 'sources/classes/facebook/connect.php'; $fb = new facebook_connect($this->registry); try { $fb->testConnectSession(); $result = $fb->users_hasAppPermission('email'); IPSMember::save($this->memberData['member_id'], array('core' => array('fb_emailallow' => intval($result)))); } catch (Exception $error) { } } } $html = $usercp_module->showForm($_AREA); } else { if ($_FUNC == 'saveForm') { //----------------------------------------- // Check secure key... //----------------------------------------- if ($this->request['secure_hash'] != $this->member->form_hash) { $html = $usercp_module->showForm($_AREA); $errors[] = $this->lang->words['securehash_not_secure']; } else { $errors = $usercp_module->saveForm($_AREA); $do = $usercp_module->do_url ? $usercp_module->do_url : 'show'; if (is_array($errors) and count($errors)) { $html = $usercp_module->showForm($_AREA, $errors); } else { if ($usercp_module->ok_message) { $this->registry->getClass('output')->redirectScreen($usercp_module->ok_message, $this->settings['base_url'] . 'app=' . IPS_APP_COMPONENT . '&module=usercp&tab=' . $_TAB . '&area=' . $_AREA . '&do=' . $do . '&saved=1', 1); } else { $this->registry->getClass('output')->silentRedirect($this->settings['base_url_with_app'] . 'module=usercp&tab=' . $_TAB . '&area=' . $_AREA . '&do=' . $do . '&saved=1' . '&_r=' . time()); } } } } else { if (!is_callable(array($usercp_module, 'runCustomEvent'))) { $html = $usercp_module->showForm($_AREA); $errors[] = $this->lang->words['called_invalid_function']; } else { $html = $usercp_module->runCustomEvent($_AREA); } } } //----------------------------------------- // If you've run a custom event, may need to // reset the "area" to highlight the menu correctly //----------------------------------------- if (is_callable(array($usercp_module, 'resetArea'))) { $_AREA = $usercp_module->resetArea($_AREA); } //----------------------------------------- // Wrap form and show //----------------------------------------- $template = $this->registry->getClass('output')->getTemplate('ucp')->userCPTemplate($_TAB, $html, $tabs, $_AREA, $errors, $usercp_module->hide_form_and_save_button, $usercp_module->uploadFormMax); //----------------------------------------- // Pass to CP output hander //----------------------------------------- $this->registry->getClass('output')->setTitle($this->_pageTitle ? $this->settings['board_name'] . " {$this->lang->words['pagetitle_bit']} : " . $this->_pageTitle : $this->settings['board_name'] . " {$this->lang->words['pagetitle_bit']}"); $this->registry->getClass('output')->addContent($template); if (is_array($this->_nav) and count($this->_nav)) { foreach ($this->_nav as $_nav) { $this->registry->getClass('output')->addNavigation($_nav[0], $_nav[1]); } } if (is_array($usercp_module->_nav) and count($usercp_module->_nav)) { foreach ($usercp_module->_nav as $_nav) { $this->registry->getClass('output')->addNavigation($_nav[0], $_nav[1]); } } $this->registry->getClass('output')->sendOutput(); }
/** * UserCP Save Form: Ignore Users * * @access public * @return array Errors */ public function saveFacebook() { if (!IPSLib::fbc_enabled()) { $this->registry->getClass('output')->showError('fbc_disabled', 1005); } //----------------------------------------- // Data //----------------------------------------- $toSave = IPSBWOptions::thaw($this->memberData['members_bitoptions'], 'members'); //----------------------------------------- // Loop and save... simple //----------------------------------------- foreach (array('fbc_s_pic', 'fbc_s_avatar', 'fbc_s_status', 'fbc_s_aboutme') as $field) { $toSave[$field] = intval($this->request[$field]); } IPSMember::save($this->memberData['member_id'], array('extendedProfile' => array('fb_bwoptions' => IPSBWOptions::freeze($toSave, 'facebook')))); //----------------------------------------- // Now sync //----------------------------------------- require_once IPS_ROOT_PATH . 'sources/classes/facebook/connect.php'; $facebook = new facebook_connect($this->registry); try { $facebook->syncMember($this->memberData); } catch (Exception $error) { $msg = $error->getMessage(); switch ($msg) { case 'NOT_LINKED': case 'NO_MEMBER': break; } } return TRUE; }