示例#1
0
文件: General.php 项目: robeendey/ce
 public function init()
 {
     // @todo fix form CSS/decorators
     // @todo replace fake values with real values
     $this->setTitle('General Settings')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
     // Init email
     $this->addElement('Text', 'email', array('label' => 'Email Address', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email', array('field' => 'user_id', 'value' => $this->getItem()->getIdentity()))))));
     $this->email->getValidator('NotEmpty')->setMessage('Please enter a valid email address.', 'isEmpty');
     $this->email->getValidator('Db_NoRecordExists')->setMessage('Someone has already registered this email address, please use another one.', 'recordFound');
     // Init username
     $this->addElement('Text', 'username', array('label' => 'Profile Address', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('Alnum', true), array('StringLength', true, array(4, 64)), array('Regex', true, array('/^[a-z0-9]/i')), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'username', array('field' => 'user_id', 'value' => $this->getItem()->getIdentity()))))));
     $this->username->getValidator('NotEmpty')->setMessage('Please enter a valid profile address.', 'isEmpty');
     $this->username->getValidator('Db_NoRecordExists')->setMessage('Someone has already picked this profile address, please use another one.', 'recordFound');
     $this->username->getValidator('Regex')->setMessage('Profile addresses must start with a letter.', 'regexNotMatch');
     $this->username->getValidator('Alnum')->setMessage('Profile addresses must be alphanumeric.', 'notAlnum');
     // Init type
     $this->addElement('Select', 'accountType', array('label' => 'Account Type'));
     // Init Facebook
     $facebook_enable = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_facebook_enable', 'none');
     if ('none' != $facebook_enable) {
         $and_publish = 'publish' == $facebook_enable ? ' and publish content to your Facebook wall.' : '.';
         $this->addElement('Dummy', 'facebook', array('label' => 'Facebook Integration', 'description' => 'Linking your Facebook account will let you login with Facebook' . $and_publish, 'content' => User_Model_DbTable_Facebook::loginButton('Integrate with my Facebook')));
         $this->addElement('Checkbox', 'facebook_id', array('label' => 'Integrate with my Facebook', 'description' => 'Facebook Integration'));
     }
     // Init timezone
     $this->addElement('Select', 'timezone', array('label' => 'Timezone', 'description' => 'Select the city closest to you that shares your same timezone.', 'multiOptions' => array('US/Pacific' => '(UTC-8) Pacific Time (US & Canada)', 'US/Mountain' => '(UTC-7) Mountain Time (US & Canada)', 'US/Central' => '(UTC-6) Central Time (US & Canada)', 'US/Eastern' => '(UTC-5) Eastern Time (US & Canada)', 'America/Halifax' => '(UTC-4)  Atlantic Time (Canada)', 'America/Anchorage' => '(UTC-9)  Alaska (US & Canada)', 'Pacific/Honolulu' => '(UTC-10) Hawaii (US)', 'Pacific/Samoa' => '(UTC-11) Midway Island, Samoa', 'Etc/GMT-12' => '(UTC-12) Eniwetok, Kwajalein', 'Canada/Newfoundland' => '(UTC-3:30) Canada/Newfoundland', 'America/Buenos_Aires' => '(UTC-3) Brasilia, Buenos Aires, Georgetown', 'Atlantic/South_Georgia' => '(UTC-2) Mid-Atlantic', 'Atlantic/Azores' => '(UTC-1) Azores, Cape Verde Is.', 'Europe/London' => 'Greenwich Mean Time (Lisbon, London)', 'Europe/Berlin' => '(UTC+1) Amsterdam, Berlin, Paris, Rome, Madrid', 'Europe/Athens' => '(UTC+2) Athens, Helsinki, Istanbul, Cairo, E. Europe', 'Europe/Moscow' => '(UTC+3) Baghdad, Kuwait, Nairobi, Moscow', 'Iran' => '(UTC+3:30) Tehran', 'Asia/Dubai' => '(UTC+4) Abu Dhabi, Kazan, Muscat', 'Asia/Kabul' => '(UTC+4:30) Kabul', 'Asia/Yekaterinburg' => '(UTC+5) Islamabad, Karachi, Tashkent', 'Asia/Dili' => '(UTC+5:30) Bombay, Calcutta, New Delhi', 'Asia/Katmandu' => '(UTC+5:45) Nepal', 'Asia/Omsk' => '(UTC+6) Almaty, Dhaka', 'India/Cocos' => '(UTC+6:30) Cocos Islands, Yangon', 'Asia/Krasnoyarsk' => '(UTC+7) Bangkok, Jakarta, Hanoi', 'Asia/Hong_Kong' => '(UTC+8) Beijing, Hong Kong, Singapore, Taipei', 'Asia/Tokyo' => '(UTC+9) Tokyo, Osaka, Sapporto, Seoul, Yakutsk', 'Australia/Adelaide' => '(UTC+9:30) Adelaide, Darwin', 'Australia/Sydney' => '(UTC+10) Brisbane, Melbourne, Sydney, Guam', 'Asia/Magadan' => '(UTC+11) Magadan, Soloman Is., New Caledonia', 'Pacific/Auckland' => '(UTC+12) Fiji, Kamchatka, Marshall Is., Wellington')));
     // Init default locale
     $locale = Zend_Registry::get('Locale');
     $localeMultiKeys = array_merge(array_keys(Zend_Locale::getLocaleList()));
     $localeMultiOptions = array();
     $languages = Zend_Locale::getTranslationList('language', $locale);
     $territories = Zend_Locale::getTranslationList('territory', $locale);
     foreach ($localeMultiKeys as $key) {
         if (!empty($languages[$key])) {
             $localeMultiOptions[$key] = $languages[$key];
         } else {
             $locale = new Zend_Locale($key);
             $region = $locale->getRegion();
             $language = $locale->getLanguage();
             if (!empty($languages[$language]) && !empty($territories[$region])) {
                 $localeMultiOptions[$key] = $languages[$language] . ' (' . $territories[$region] . ')';
             }
         }
     }
     $localeMultiOptions = array_merge(array('auto' => '[Automatic]'), $localeMultiOptions);
     $this->addElement('Select', 'locale', array('label' => 'Locale', 'description' => 'Dates, times, and other settings will be displayed using this locale setting.', 'multiOptions' => $localeMultiOptions));
     // Init submit
     $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
     // Create display group for buttons
     #$this->addDisplayGroup($emailAlerts, 'checkboxes');
     // Set default action
     $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'user', 'controller' => 'settings', 'action' => 'general'), 'default'));
 }
示例#2
0
 public function indexAction()
 {
     if (YNRESPONSIVE_ACTIVE != 'ynresponsive-event') {
         return $this->setNoRender(true);
     }
     $this->view->logo = $this->_getParam('logo');
     $this->view->viewer = $viewer = Engine_Api::_()->user()->getViewer();
     $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('core_mini');
     //Search
     $require_check = Engine_Api::_()->getApi('settings', 'core')->core_general_search;
     if (!$require_check) {
         if ($viewer->getIdentity()) {
             $this->view->search_check = true;
         } else {
             $this->view->search_check = false;
         }
     } else {
         $this->view->search_check = true;
     }
     //Facebook Connect
     $settings = Engine_Api::_()->getApi('settings', 'core');
     if ('none' != $settings->getSetting('core_facebook_enable', 'none') && $settings->core_facebook_secret) {
         $this->view->fblogin = new Engine_Form_Element_Dummy('facebook', array('content' => User_Model_DbTable_Facebook::loginButton(), 'decorators' => array('ViewHelper')));
         $this->view->fbLoginEnabled = true;
     } else {
         $this->view->fbLoginEnabled = false;
         $this->view->fblogin = new Engine_Form_Element_Dummy('facebook', array('content' => 'fblogin here', 'decorators' => array('ViewHelper')));
     }
     //Facebook Connect end
     //Twitter Connect
     // Init twitter login link
     $settings = Engine_Api::_()->getApi('settings', 'core');
     if ('none' != $settings->getSetting('core_twitter_enable', 'none') && $settings->core_twitter_secret) {
         $this->view->twlogin = new Engine_Form_Element_Dummy('twitter', array('content' => User_Model_DbTable_Twitter::loginButton(), 'decorators' => array('ViewHelper')));
         $this->view->TwLoginEnabled = true;
     } else {
         $this->view->TwLoginEnabled = false;
         $this->view->twlogin = new Engine_Form_Element_Dummy('twitter', array('content' => 'twlogin here', 'decorators' => array('ViewHelper')));
     }
     //Twitter Connect end
     //Janrain Connect
     // Init janrain login link
     if ('none' != $settings->getSetting('core_janrain_enable', 'none') && $settings->core_janrain_key) {
         $mode = $this->getMode();
         $this->view->jrlogin = new Engine_Form_Element_Dummy('janrain', array('content' => User_Model_DbTable_Janrain::loginButton($mode), 'decorators' => array('ViewHelper')));
         $this->view->JrLoginEnabled = true;
     } else {
         $this->view->JrLoginEnabled = false;
         $this->view->jrlogin = new Engine_Form_Element_Dummy('janrain', array('content' => 'janrain here', 'decorators' => array('ViewHelper')));
     }
     //Janrain Connect end
 }
示例#3
0
 public function init()
 {
     $tabindex = 1;
     $this->_emailAntispamEnabled = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.spam.email.antispam.login', 1) == 1;
     // Used to redirect users to the correct page after login with Facebook
     $_SESSION['redirectURL'] = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
     $description = Zend_Registry::get('Zend_Translate')->_("If you already have an account, please enter your details below. If you don't have one yet, please <a href='%s'>sign up</a> first.");
     $description = sprintf($description, Zend_Controller_Front::getInstance()->getRouter()->assemble(array(), 'user_signup', true));
     // Init form
     $this->setTitle('Member Sign In');
     $this->setDescription($description);
     $this->setAttrib('id', 'user_form_login');
     $this->loadDefaultDecorators();
     $this->getDecorator('Description')->setOption('escape', false);
     $email = Zend_Registry::get('Zend_Translate')->_('Email Address');
     // Init email
     $emailElement = $this->addEmailElement(array('label' => $email, 'required' => true, 'allowEmpty' => false, 'filters' => array('StringTrim'), 'validators' => array('EmailAddress'), 'tabindex' => $tabindex++, 'autofocus' => 'autofocus', 'inputType' => 'email', 'class' => 'text'));
     $emailElement->getValidator('EmailAddress')->getHostnameValidator()->setValidateTld(false);
     $password = Zend_Registry::get('Zend_Translate')->_('Password');
     // Init password
     $this->addElement('Password', 'password', array('label' => $password, 'required' => true, 'allowEmpty' => false, 'tabindex' => $tabindex++, 'filters' => array('StringTrim')));
     $this->addElement('Hidden', 'return_url', array());
     $settings = Engine_Api::_()->getApi('settings', 'core');
     if ($settings->core_spam_login) {
         $this->addElement('captcha', 'captcha', Engine_Api::_()->core()->getCaptchaOptions(array('tabindex' => $tabindex++)));
     }
     // Init submit
     $this->addElement('Button', 'submit', array('label' => 'Sign In', 'type' => 'submit', 'ignore' => true, 'tabindex' => $tabindex++));
     // Init remember me
     $this->addElement('Checkbox', 'remember', array('label' => 'Remember Me', 'tabindex' => $tabindex++));
     $this->addDisplayGroup(array('submit', 'remember'), 'buttons');
     $content = Zend_Registry::get('Zend_Translate')->_("<span><a href='%s'>Forgot Password?</a></span>");
     $content = sprintf($content, Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'user', 'controller' => 'auth', 'action' => 'forgot'), 'default', true));
     // Init forgot password link
     $this->addElement('Dummy', 'forgot', array('content' => $content));
     // Init facebook login link
     if ('none' != $settings->getSetting('core_facebook_enable', 'none') && $settings->core_facebook_secret) {
         $this->addElement('Dummy', 'facebook', array('content' => User_Model_DbTable_Facebook::loginButton()));
     }
     // Init twitter login link
     if ('none' != $settings->getSetting('core_twitter_enable', 'none') && $settings->core_twitter_secret) {
         $this->addElement('Dummy', 'twitter', array('content' => User_Model_DbTable_Twitter::loginButton()));
     }
     // Init janrain login link
     if ('none' != $settings->getSetting('core_janrain_enable', 'none') && $settings->core_janrain_key) {
         $mode = $this->getMode();
         $this->addElement('Dummy', 'janrain', array('content' => User_Model_DbTable_Janrain::loginButton($mode)));
     }
     // Set default action
     $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array(), 'user_login'));
 }
示例#4
0
 public function requireuserAction()
 {
     // 403 error -- authorization failed
     $this->getResponse()->setRawHeader($_SERVER['SERVER_PROTOCOL'] . '403 Forbidden');
     $this->view->status = false;
     $this->view->error = Zend_Registry::get('Zend_Translate')->_('You are not authorized to access this resource.');
     // Show the login form for them :P
     $this->view->form = $form = new User_Form_Login();
     $form->addError('Please sign in to continue..');
     $form->return_url->setValue(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
     // Facebook login
     if (User_Model_DbTable_Facebook::authenticate($form)) {
         // Facebook login succeeded, redirect to home
         $this->_helper->redirector->gotoRoute(array(), 'home');
     }
 }
示例#5
0
文件: Account.php 项目: robeendey/ce
 public function onView()
 {
     // Init facebook login link
     if (FALSE && 'none' != Engine_Api::_()->getApi('settings', 'core')->core_facebook_enable) {
         $facebook = User_Model_DbTable_Facebook::getFBInstance();
         if ($facebook->getSession()) {
             try {
                 $me = $facebook->api('/me');
                 $uid = Engine_Api::_()->getDbtable('Facebook', 'User')->fetchRow(array('facebook_uid = ?' => $facebook->getUser()));
                 if ($uid) {
                     $uid = $uid->user_id;
                 }
                 if ($uid) {
                     // prevent Facebook users with established accounts from signing up again
                     Engine_Api::_()->user()->getAuth()->getStorage()->write($uid);
                     $this->getForm()->getElement('facebook')->setContent('<script type="text/javascript">window.location.reload();</script>"');
                     return;
                 } else {
                     // pre-fill facebook data into signup process
                     $this->getForm()->removeElement('facebook');
                     if ($this->getForm()->getElement('email')->getValue() == '') {
                         $this->getForm()->getElement('email')->setValue($me['email']);
                     }
                     if ($this->getForm()->getElement('username')->getValue() == '') {
                         $this->getForm()->getElement('username')->setValue(preg_replace('/[^A-Za-z]/', '', $me['name']));
                     }
                     $maps = Engine_Api::_()->fields()->getFieldsMaps('user');
                     $fb_data = array();
                     foreach (array('gender', 'first_name', 'last_name', 'birthdate') as $field_alias) {
                         if (isset($me[$field_alias])) {
                             $field = Engine_Api::_()->fields()->getFieldsObjectsByAlias('user', $field_alias);
                             $field_id = $field[$field_alias]['field_id'];
                             foreach ($maps as $map) {
                                 if ($field_id == $map->child_id) {
                                     $fb_data[$map->getKey()] = $me[$field_alias];
                                 }
                             }
                         }
                     }
                     $this->getSession()->data = $fb_data;
                 }
             } catch (Exception $e) {
                 $this->getForm()->removeElement('facebook');
             }
         }
     }
 }
示例#6
0
 public function indexAction()
 {
     // Do not show if logged in
     if (Engine_Api::_()->user()->getViewer()->getIdentity()) {
         $this->setNoRender();
         return;
     }
     // Display form
     $form = $this->view->form = new User_Form_Login();
     $form->setTitle(null)->setDescription(null);
     $form->removeElement('forgot');
     // Facebook login
     if ('none' == Engine_Api::_()->getApi('settings', 'core')->core_facebook_enable) {
         $form->removeElement('facebook');
     } else {
         if ($form->getElement('facebook')) {
             $content = $form->getElement('facebook')->getContent();
             $content = str_replace('FB.Event.subscribe', 'FB.Event.subscribe(\'fb.log\', function(response) {
                              window.location.reload();
                             });
                             FB.Event.subscribe', $content);
             $content = str_replace('window.location.reload();', sprintf('window.location.href = "%s";', Zend_Controller_Front::getInstance()->getRouter()->assemble(array(), 'user_login')), $content);
             $form->getElement('facebook')->setContent($content);
         }
         $facebook = User_Model_DbTable_Facebook::getFBInstance();
         if ($facebook->getSession()) {
             try {
                 $me = $facebook->api('/me');
                 $uid = Engine_Api::_()->getDbtable('Facebook', 'User')->fetchRow(array('facebook_uid = ?' => $facebook->getUser()));
                 if ($uid) {
                     $uid = $uid->user_id;
                 }
                 if ($uid) {
                     // already integrated user account; sign in
                     Engine_Api::_()->user()->getAuth()->getStorage()->write($uid);
                 } else {
                     $form->removeElement('facebook');
                     //$form->setAction($this->view->url(array('controller'=>'settings','action'=>'general'), 'user_extended'));
                     $form->addNotice($this->view->translate('USER_FORM_AUTH_FACEBOOK_NOACCOUNT', $this->view->url(array(), 'user_signup'), $this->view->url(array('controller' => 'settings', 'action' => 'general'), 'user_extended')));
                 }
             } catch (Facebook_Exception $e) {
             }
         }
     }
 }
示例#7
0
文件: Core.php 项目: robeendey/ce
 public function onUserCreateAfter($event)
 {
     $payload = $event->getPayload();
     if ($payload instanceof User_Model_User && 'none' != Engine_Api::_()->getApi('settings', 'core')->core_facebook_enable) {
         $facebook = User_Model_DbTable_Facebook::getFBInstance();
         if ($facebook->getSession()) {
             try {
                 $facebook->api('/me');
                 $table = Engine_Api::_()->getDbtable('facebook', 'user');
                 $row = $table->fetchRow(array('user_id = ?' => $payload->getIdentity()));
                 if (!$row) {
                     $row = Engine_Api::_()->getDbtable('facebook', 'user')->createRow();
                     $row->user_id = $payload->getIdentity();
                 }
                 $row->facebook_uid = $facebook->getUser();
                 $row->save();
             } catch (Exception $e) {
             }
         }
     }
 }
示例#8
0
文件: Login.php 项目: robeendey/ce
 public function init()
 {
     $description = Zend_Registry::get('Zend_Translate')->_("If you already have an account, please enter your details below. If you don't have one yet, please <a href='%s'>sign up</a> first.");
     $description = sprintf($description, Zend_Controller_Front::getInstance()->getRouter()->assemble(array(), 'user_signup', true));
     // Init form
     $this->setTitle('Member Sign In');
     $this->setDescription($description);
     $this->setAttrib('id', 'user_form_login');
     $this->loadDefaultDecorators();
     $this->getDecorator('Description')->setOption('escape', false);
     $email = Zend_Registry::get('Zend_Translate')->_('Email Address');
     // Init email
     $this->addElement('Text', 'email', array('label' => $email, 'required' => true, 'allowEmpty' => false, 'filters' => array('StringTrim'), 'validators' => array('EmailAddress'), 'tabindex' => 1));
     $password = Zend_Registry::get('Zend_Translate')->_('Password');
     // Init password
     $this->addElement('Password', 'password', array('label' => $password, 'required' => true, 'allowEmpty' => false, 'tabindex' => 2, 'filters' => array('StringTrim')));
     // Init remember me
     $this->addElement('Checkbox', 'remember', array('label' => 'Remember Me', 'tabindex' => 4));
     $this->addElement('Hidden', 'return_url', array());
     $settings = Engine_Api::_()->getApi('settings', 'core');
     if ($settings->core_spam_login) {
         $this->addElement('captcha', 'captcha', array('label' => 'Human Verification', 'description' => 'Please validate that you are not a robot by typing in the letters and numbers in this image:', 'captcha' => 'image', 'required' => true, 'tabindex' => 3, 'captchaOptions' => array('wordLen' => 6, 'fontSize' => '30', 'timeout' => 300, 'imgDir' => APPLICATION_PATH . '/public/temporary/', 'imgUrl' => $this->getView()->baseUrl() . '/public/temporary', 'font' => APPLICATION_PATH . '/application/modules/Core/externals/fonts/arial.ttf')));
     }
     // Init submit
     $this->addElement('Button', 'submit', array('label' => 'Sign In', 'type' => 'submit', 'ignore' => true, 'tabindex' => 5));
     $this->addDisplayGroup(array('submit', 'remember'), 'buttons');
     $content = Zend_Registry::get('Zend_Translate')->_("<span><a href='%s'>Forgot Password?</a></span>");
     $content = sprintf($content, Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'user', 'controller' => 'auth', 'action' => 'forgot'), 'default', true));
     // Init forgot password link
     $this->addElement('Dummy', 'forgot', array('content' => $content));
     // Init facebook login link
     if ('none' != $settings->getSetting('core_facebook_enable', 'none') && $settings->core_facebook_secret) {
         $this->addElement('Dummy', 'facebook', array('content' => User_Model_DbTable_Facebook::loginButton()));
     }
     // Set default action
     $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array(), 'user_login'));
 }
示例#9
0
文件: Share.php 项目: robeendey/ce
 public function init()
 {
     $this->setTitle('Share')->setDescription('Share this by re-posting it with your own message.')->setMethod('POST')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
     $this->addElement('Textarea', 'body', array('filters' => array(new Engine_Filter_HtmlSpecialChars(), new Engine_Filter_EnableLinks(), new Engine_Filter_Censor())));
     // Buttons
     $buttons = array();
     if ('publish' == Engine_Api::_()->getApi('settings', 'core')->core_facebook_enable && User_Model_DbTable_Facebook::getFBInstance()->getSession()) {
         $this->addElement('Dummy', 'post_to_facebook', array('content' => '
       <span href="javascript:void(0);" class="composer_facebook_toggle" onclick="toggleFacebookShareCheckbox();">
         <span class="composer_facebook_tooltip">
           Publish this on Facebook
         </span>
         <input type="checkbox" name="post_to_facebook" value="1" style="display:none;">
       </span>'));
         $this->getElement('post_to_facebook')->clearDecorators();
         $buttons[] = 'post_to_facebook';
     }
     $this->addElement('Button', 'submit', array('label' => 'Share', 'type' => 'submit', 'ignore' => true, 'decorators' => array('ViewHelper')));
     $buttons[] = 'submit';
     $this->addElement('Cancel', 'cancel', array('label' => 'cancel', 'link' => true, 'prependText' => ' or ', 'href' => '', 'onclick' => 'parent.Smoothbox.close();', 'decorators' => array('ViewHelper')));
     $buttons[] = 'cancel';
     $this->addDisplayGroup($buttons, 'buttons');
     $button_group = $this->getDisplayGroup('buttons');
 }
示例#10
0
 public function generalAction()
 {
     // Config vars
     $user = $this->_helper->api()->core()->getSubject();
     $this->view->form = $form = new User_Form_Settings_General(array('item' => $user));
     // Set up profile type options
     /*
         $aliasedFields = $user->fields()->getFieldsObjectsByAlias();
         if( isset($aliasedFields['profile_type']) )
         {
           $options = $aliasedFields['profile_type']->getElementParams($user);
           unset($options['options']['order']);
           $form->accountType->setOptions($options['options']);
         }
         else
         { */
     $form->removeElement('accountType');
     /* } */
     // Removed disabled features
     if (!Engine_Api::_()->authorization()->isAllowed('user', $user, 'username')) {
         $form->removeElement('username');
     }
     // Facebook
     if ('none' != Engine_Api::_()->getApi('settings', 'core')->getSetting('core.facebook.enable', 'none')) {
         $facebook = User_Model_DbTable_Facebook::getFBInstance();
         if ($facebook->getSession()) {
             $fb_uid = Engine_Api::_()->getDbtable('facebook', 'user')->fetchRow(array('user_id = ?' => Engine_Api::_()->user()->getViewer()->getIdentity()));
             if ($fb_uid && $fb_uid->facebook_uid) {
                 $fb_uid = $fb_uid->facebook_uid;
             } else {
                 $fb_uid = null;
             }
             try {
                 $facebook->api('/me');
                 if ($fb_uid && $facebook->getUser() != $fb_uid) {
                     $form->removeElement('facebook_id');
                     $form->getElement('facebook')->addError('You appear to be logged into a different Facebook account than what was registered with this account.  Please log out of Facebook using the button below to log into your correct Facebook account.');
                     $form->getElement('facebook')->setContent($this->view->translate('<button onclick="window.location.href=this.value;return false;" value="%s">Logout of Facebook</button>', $facebook->getLogoutUrl()));
                 } else {
                     $form->removeElement('facebook');
                     $form->getElement('facebook_id')->setAttrib('checked', (bool) $fb_uid);
                 }
             } catch (Exception $e) {
                 $form->removeElement('facebook');
                 $form->removeElement('facebook_id');
             }
         } else {
             @$form->removeElement('facebook_id');
         }
     } else {
         // these should already be removed inside the form, but lets do it again.
         @$form->removeElement('facebook');
         @$form->removeElement('facebook_id');
     }
     // Check if post and populate
     if (!$this->getRequest()->isPost()) {
         $form->populate($user->toArray());
         $this->view->status = false;
         $this->view->error = Zend_Registry::get('Zend_Translate')->_('Invalid method');
         return;
     }
     // Check if valid
     if (!$form->isValid($this->getRequest()->getPost())) {
         $this->view->status = false;
         $this->view->error = Zend_Registry::get('Zend_Translate')->_('Invalid data');
         return;
     }
     // -- Process --
     // Set values for user object
     $user->setFromArray($form->getValues());
     $user->save();
     // Update account type
     /*
         $accountType = $form->getValue('accountType');
         if( isset($aliasedFields['profile_type']) )
         {
      $valueRow = $aliasedFields['profile_type']->getValue($user);
      if( null === $valueRow ) {
        $valueRow = Engine_Api::_()->fields()->getTable('user', 'values')->createRow();
        $valueRow->field_id = $aliasedFields['profile_type']->field_id;
        $valueRow->item_id = $user->getIdentity();
      }
      $valueRow->value = $accountType;
      $valueRow->save();
         }
     *
     */
     // Update facebook settings
     if (isset($facebook) && $form->getElement('facebook_id')) {
         if ($facebook->getSession()) {
             try {
                 $facebook->api('/me');
                 $uid = Engine_Api::_()->user()->getViewer()->getIdentity();
                 $table = Engine_Api::_()->getDbtable('facebook', 'user');
                 $row = $table->find($uid)->current();
                 if (!$row) {
                     $row = $table->createRow();
                     $row->user_id = $uid;
                 }
                 $row->facebook_uid = $this->getRequest()->getPost('facebook_id') ? $facebook->getUser() : 0;
                 $row->save();
                 $form->removeElement('facebook');
             } catch (Exception $e) {
             }
         }
     }
     // Send success message
     $this->view->status = true;
     $this->view->message = Zend_Registry::get('Zend_Translate')->_('Settings saved.');
     $form->addNotice(Zend_Registry::get('Zend_Translate')->_('Settings were successfully saved.'));
 }
示例#11
0
 public function init()
 {
     setcookie('cookie_test', 1, time() + 600, '/');
     $description = Zend_Registry::get('Zend_Translate')->_("If you already have an account, please enter your details below. If you don't have one yet, please <a href='%s'>sign up</a> first.");
     $description = sprintf($description, Zend_Controller_Front::getInstance()->getRouter()->assemble(array(), 'user_signup', true));
     // Init form
     $this->setTitle('Member Sign In');
     $this->setDescription($description);
     $this->setAttrib('id', 'user_form_login');
     $this->loadDefaultDecorators();
     $this->getDecorator('Description')->setOption('escape', false);
     $email = Zend_Registry::get('Zend_Translate')->_('Email Address');
     // Init email
     $this->addEmailElement(array('label' => $email, 'required' => true, 'allowEmpty' => false, 'filters' => array('StringTrim'), 'validators' => array('EmailAddress'), 'tabindex' => 1, 'autofocus' => 'autofocus', 'inputType' => 'email', 'placeholder' => 'Your Email', 'class' => 'text'));
     $password = Zend_Registry::get('Zend_Translate')->_('Password');
     // Init password
     $this->addElement('Password', 'password', array('label' => $password, 'required' => true, 'allowEmpty' => false, 'tabindex' => 2, 'filters' => array('StringTrim'), 'placeholder' => 'Your Password'));
     // Init remember me
     $this->addElement('Checkbox', 'remember', array('label' => 'Remember Me', 'tabindex' => 4));
     $content = Zend_Registry::get('Zend_Translate')->_("<span><a href='%s'>Forgot Password?</a></span>");
     $content = sprintf($content, Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'user', 'controller' => 'auth', 'action' => 'forgot'), 'default', true));
     // Init forgot password link
     $this->addElement('Dummy', 'forgot', array('content' => $content));
     $this->addElement('Hidden', 'return_url', array());
     $settings = Engine_Api::_()->getApi('settings', 'core');
     if ($settings->core_spam_login) {
         $this->addElement('captcha', 'captcha', array('label' => 'Human Verification', 'description' => 'Please validate that you are not a robot by typing in the letters and numbers in this image:', 'captcha' => 'image', 'required' => true, 'tabindex' => 3, 'captchaOptions' => array('wordLen' => 6, 'fontSize' => '30', 'timeout' => 300, 'imgDir' => APPLICATION_PATH . '/public/temporary/', 'imgUrl' => $this->getView()->baseUrl() . '/public/temporary', 'font' => APPLICATION_PATH . '/application/modules/Core/externals/fonts/arial.ttf')));
     }
     // Init submit
     $this->addElement('Button', 'submit', array('label' => 'Sign In', 'type' => 'submit', 'ignore' => true, 'tabindex' => 5));
     $this->addDisplayGroup(array('submit', 'remember', 'forgot'), 'buttons');
     $table = Engine_Api::_()->getDbTable('Services', 'SocialConnect');
     $rs = $table->getServices(100, 1);
     $separateLimit = Engine_Api::_()->getApi('settings', 'core')->getSetting('socialconnect.seperatelimit', 5);
     $view = Zend_Registry::get('Zend_View');
     $front = Zend_Controller_Front::getInstance();
     $base_path = $view->layout()->staticBaseUrl;
     $htmls = array();
     if ($rs->count()) {
         $htmls[] = '<div style="text-left; margin-top:5px">';
         $counter = 0;
         if ($separateLimit != 0) {
             foreach ($rs as $o) {
                 $htmls[] = sprintf('<a title="%s" href="javascript: void(sopopup(\'%s\'));"><img alt="%s" src="' . $base_path . 'application/modules/SocialConnect/externals/images/%s.png" class="ynsc_sprite"/></a>', $view->translate('Sign in %s', $o->title), $o->getHref(), $o->title, $o->name);
                 if (++$counter >= $separateLimit) {
                     break;
                 }
             }
         }
         $counter = 0;
         if ($rs->count() > $separateLimit) {
             $id2 = 'tid2_' . time();
             $id1 = 'tid1_' . time();
             $htmls[] = '';
             foreach ($rs as $o) {
                 if (++$counter <= $separateLimit) {
                     continue;
                 }
                 $htmls[] = sprintf('<a title="%s" href="javascript: void(0);" onclick="javascript: M2b.SocialConnect.signon(\'%s\')" class="ld44" style="display:none"><img alt="%s" src="' . $base_path . 'application/modules/SocialConnect/externals/images/%s.png" class="ynsc_sprite"/></a>', $view->translate('Sign in %s', $o->title), $o->getHref(), $o->title, $o->name);
             }
             $htmls[] = '';
             $htmls[] = '<a href="javascript:  void(0)" mode="open" onclick="toggleIt( \'' . $id2 . '\',\'' . $id1 . '\')" id="' . $id2 . '" style="line-height:32px;"><img title="' . $view->translate("More") . '" src="' . $base_path . 'application/modules/SocialConnect/externals/images/more.png" width="26px" height="26px" class="ynsc_sprite"/></a>';
         }
         $htmls[] = '</div>';
     }
     $social_connect_html = implode('', $htmls);
     $content = Zend_Registry::get('Zend_Translate')->_("<span><a href='%s'>Forgot Password?</a></span>");
     $content = sprintf($content, Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'user', 'controller' => 'auth', 'action' => 'forgot'), 'default', true));
     // Init forgot password link
     $this->addElement('Dummy', 'forgot', array('content' => $content));
     // start change code
     if ($rs->count()) {
         $this->addElement('Dummy', 'signin_using', array('content' => '<h4 style="margin:5px 0; padding:0;text-align:center;border:0 none;">Or Sign In Using</h4>', 'decorators' => array('ViewHelper')));
     }
     // Init facebook login link
     if ('none' != $settings->getSetting('core_facebook_enable', false) && $settings->core_facebook_secret) {
         $this->addElement('Dummy', 'facebook', array('content' => '<div style="text-align:center">' . User_Model_DbTable_Facebook::loginButton() . '</div>', 'decorators' => array('ViewHelper')));
     }
     $this->addElement('Dummy', 'signing_list', array('content' => $social_connect_html, 'decorators' => array('ViewHelper')));
     // end change code.
     // Set default action
     $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array(), 'user_login'));
 }
示例#12
0
文件: General.php 项目: hoalangoc/ftf
 public function init()
 {
     // @todo fix form CSS/decorators
     // @todo replace fake values with real values
     $this->setTitle('General Settings')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
     // Init email
     $this->addElement('Text', 'email', array('label' => 'Email Address', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email', array('field' => 'user_id', 'value' => $this->getItem()->getIdentity())))), 'filters' => array('StringTrim')));
     $this->email->getValidator('NotEmpty')->setMessage('Please enter a valid email address.', 'isEmpty');
     $this->email->getValidator('Db_NoRecordExists')->setMessage('Someone has already registered this email address, please use another one.', 'recordFound');
     $this->email->getValidator('EmailAddress')->getHostnameValidator()->setValidateTld(false);
     // Init username
     if (Engine_Api::_()->getApi('settings', 'core')->getSetting('user.signup.username', 1) > 0) {
         $description = Zend_Registry::get('Zend_Translate')->_('This will be the end of your profile link, for example: <br /> ' . '<span id="profile_address">http://%s</span>');
         $description = sprintf($description, $_SERVER['HTTP_HOST'] . Zend_Controller_Front::getInstance()->getBaseUrl() . '/yourname');
         $this->addElement('Text', 'username', array('label' => 'Profile URL', 'description' => $description, 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('Alnum', true), array('StringLength', true, array(4, 64)), array('Regex', true, array('/^[a-z][a-z0-9]*$/i')), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'username', array('field' => 'user_id', 'value' => $this->getItem()->getIdentity()))))));
         $this->username->getDecorator('Description')->setOptions(array('placement' => 'APPEND', 'escape' => false));
         $this->username->getValidator('NotEmpty')->setMessage('Please enter a valid profile url.', 'isEmpty');
         $this->username->getValidator('Db_NoRecordExists')->setMessage('Someone has already picked this profile url, please use another one.', 'recordFound');
         $this->username->getValidator('Regex')->setMessage('Profile url must start with a letter.', 'regexNotMatch');
         $this->username->getValidator('Alnum')->setMessage('Profile url must be alphanumeric.', 'notAlnum');
         // Add banned username validator
         $bannedUsernameValidator = new Engine_Validate_Callback(array($this, 'checkBannedUsername'), $this->username);
         $bannedUsernameValidator->setMessage("This profile url is not available, please use another one.");
         $this->username->addValidator($bannedUsernameValidator);
     }
     // Init type
     $this->addElement('Select', 'accountType', array('label' => 'Account Type'));
     // Init Facebook
     $facebook_enable = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_facebook_enable', 'none');
     if ('none' != $facebook_enable) {
         $desc = 'Linking your Facebook account will let you login with Facebook';
         if ('publish' == $facebook_enable) {
             $desc .= ' and publish content to your Facebook wall.';
         } else {
             $desc .= '.';
         }
         $this->addElement('Dummy', 'facebook', array('label' => 'Facebook Integration', 'description' => $desc, 'content' => User_Model_DbTable_Facebook::loginButton('Integrate with my Facebook')));
         $this->addElement('Checkbox', 'facebook_id', array('label' => 'Integrate with my Facebook', 'description' => 'Facebook Integration'));
     }
     // Init Twitter
     $twitter_enable = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_twitter_enable', 'none');
     if ('none' != $twitter_enable) {
         $desc = 'Linking your Twitter account will let you login with Twitter';
         if ('publish' == $twitter_enable) {
             $desc .= ' and publish content to your Twitter feed.';
         } else {
             $desc .= '.';
         }
         $this->addElement('Dummy', 'twitter', array('label' => 'Twitter Integration', 'description' => $desc, 'content' => User_Model_DbTable_Twitter::loginButton('Integrate with my Twitter')));
         $this->addElement('Checkbox', 'twitter_id', array('label' => 'Integrate with my Twitter', 'description' => 'Twitter Integration'));
     }
     $janrain_enable = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_janrain_enable', 'none');
     if ($janrain_enable && $janrain_enable != 'none') {
         // Check if already linked
         $janrainTable = Engine_Api::_()->getDbtable('janrain', 'user');
         $janrainExists = $janrainTable->select()->from($janrainTable, new Zend_Db_Expr('TRUE'))->where('user_id = ?', $this->getItem()->getIdentity())->limit(1)->query()->fetchColumn();
         if (!$janrainExists) {
             $desc = 'Linking another account will let you login using that account.';
             $this->addElement('Dummy', 'janrain', array('label' => 'Social Integration', 'description' => $desc, 'content' => User_Model_DbTable_Janrain::loginButton('page')));
         } else {
             $this->addElement('Radio', 'janrainnoshare', array('label' => 'Share Dialog', 'description' => 'Do you want the option to share a post to ' . 'facebook or twitter to be displayed after posting?', 'multiOptions' => array('0' => 'Yes, display the dialog.', '1' => 'No, do not display the dialog.'), 'value' => 0));
         }
     }
     // Init timezone
     $this->addElement('Select', 'timezone', array('label' => 'Timezone', 'description' => 'Select the city closest to you that shares your same timezone.', 'multiOptions' => array('US/Pacific' => '(UTC-8) Pacific Time (US & Canada)', 'US/Mountain' => '(UTC-7) Mountain Time (US & Canada)', 'US/Central' => '(UTC-6) Central Time (US & Canada)', 'US/Eastern' => '(UTC-5) Eastern Time (US & Canada)', 'America/Halifax' => '(UTC-4)  Atlantic Time (Canada)', 'America/Anchorage' => '(UTC-9)  Alaska (US & Canada)', 'Pacific/Honolulu' => '(UTC-10) Hawaii (US)', 'Pacific/Samoa' => '(UTC-11) Midway Island, Samoa', 'Etc/GMT-12' => '(UTC-12) Eniwetok, Kwajalein', 'Canada/Newfoundland' => '(UTC-3:30) Canada/Newfoundland', 'America/Buenos_Aires' => '(UTC-3) Brasilia, Buenos Aires, Georgetown', 'Atlantic/South_Georgia' => '(UTC-2) Mid-Atlantic', 'Atlantic/Azores' => '(UTC-1) Azores, Cape Verde Is.', 'Europe/London' => 'Greenwich Mean Time (Lisbon, London)', 'Europe/Berlin' => '(UTC+1) Amsterdam, Berlin, Paris, Rome, Madrid', 'Europe/Athens' => '(UTC+2) Athens, Helsinki, Istanbul, Cairo, E. Europe', 'Europe/Moscow' => '(UTC+3) Baghdad, Kuwait, Nairobi, Moscow', 'Iran' => '(UTC+3:30) Tehran', 'Asia/Dubai' => '(UTC+4) Abu Dhabi, Kazan, Muscat', 'Asia/Kabul' => '(UTC+4:30) Kabul', 'Asia/Yekaterinburg' => '(UTC+5) Islamabad, Karachi, Tashkent', 'Asia/Calcutta' => '(UTC+5:30) Bombay, Calcutta, New Delhi', 'Asia/Katmandu' => '(UTC+5:45) Nepal', 'Asia/Omsk' => '(UTC+6) Almaty, Dhaka', 'India/Cocos' => '(UTC+6:30) Cocos Islands, Yangon', 'Asia/Krasnoyarsk' => '(UTC+7) Bangkok, Jakarta, Hanoi', 'Asia/Hong_Kong' => '(UTC+8) Beijing, Hong Kong, Singapore, Taipei', 'Asia/Tokyo' => '(UTC+9) Tokyo, Osaka, Sapporto, Seoul, Yakutsk', 'Australia/Adelaide' => '(UTC+9:30) Adelaide, Darwin', 'Australia/Sydney' => '(UTC+10) Brisbane, Melbourne, Sydney, Guam', 'Asia/Magadan' => '(UTC+11) Magadan, Soloman Is., New Caledonia', 'Pacific/Auckland' => '(UTC+12) Fiji, Kamchatka, Marshall Is., Wellington')));
     // Init default locale
     $locale = Zend_Registry::get('Locale');
     $localeMultiKeys = array_merge(array_keys(Zend_Locale::getLocaleList()));
     $localeMultiOptions = array();
     $languages = Zend_Locale::getTranslationList('language', $locale);
     $territories = Zend_Locale::getTranslationList('territory', $locale);
     foreach ($localeMultiKeys as $key) {
         if (!empty($languages[$key])) {
             $localeMultiOptions[$key] = $languages[$key];
         } else {
             $locale = new Zend_Locale($key);
             $region = $locale->getRegion();
             $language = $locale->getLanguage();
             if (!empty($languages[$language]) && !empty($territories[$region])) {
                 $localeMultiOptions[$key] = $languages[$language] . ' (' . $territories[$region] . ')';
             }
         }
     }
     $localeMultiOptions = array_merge(array('auto' => '[Automatic]'), $localeMultiOptions);
     $this->addElement('Select', 'locale', array('label' => 'Locale', 'description' => 'Dates, times, and other settings will be displayed using this locale setting.', 'multiOptions' => $localeMultiOptions));
     $languages = Engine_Api::_()->getDbTable('languages', 'user')->getLanguagesArray();
     $this->addElement('MultiCheckbox', 'languages', array('label' => 'Language Preference', 'required' => false, 'allowEmpty' => true, 'multiOptions' => $languages, 'filters' => array('StripTags', new Engine_Filter_Censor())));
     // Init submit
     $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
     // Set default action
     $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'user', 'controller' => 'settings', 'action' => 'general'), 'default'));
 }
示例#13
0
 public function shareAction()
 {
     if (!$this->_helper->requireUser()->isValid()) {
         return;
     }
     $type = $this->_getParam('type');
     $id = $this->_getParam('id');
     $viewer = Engine_Api::_()->user()->getViewer();
     $this->view->attachment = $attachment = Engine_Api::_()->getItem($type, $id);
     $this->view->form = $form = new Activity_Form_Share();
     if (!$attachment) {
         // tell smoothbox to close
         $this->view->status = true;
         $this->view->message = Zend_Registry::get('Zend_Translate')->_('You cannot share this item because it has been removed.');
         $this->view->smoothboxClose = true;
         return $this->render('deletedItem');
     }
     // hide facebook option if not logged in, or logged into wrong FB account
     if (true) {
         $facebook = User_Model_DbTable_Facebook::getFBInstance();
         if (!$facebook->getSession()) {
             $form->removeElement('post_to_facebook');
         } else {
             try {
                 $facebook->api('/me');
                 $fb_uid = Engine_Api::_()->getDbtable('Facebook', 'User')->fetchRow(array('user_id = ?' => Engine_Api::_()->user()->getViewer()->getIdentity()));
                 if ($fb_uid && $fb_uid->facebook_uid) {
                     $fb_uid = $fb_uid->facebook_uid;
                 } else {
                     $fb_uid = null;
                 }
                 if (!$fb_uid || $fb_uid != $facebook->getUser()) {
                     throw new Exception('User logged into a Facebook account other than the attached account.');
                 }
             } catch (Exception $e) {
                 $form->removeElement('post_to_facebook');
             }
         }
     }
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     // Process
     $db = Engine_Api::_()->getDbtable('actions', 'activity')->getAdapter();
     $db->beginTransaction();
     try {
         // Get body
         $body = $form->getValue('body');
         // Add activity
         $api = $this->_helper->api()->getDbtable('actions', 'activity');
         $action = $api->addActivity($viewer, $viewer, 'post_self', $body);
         $api->attachActivity($action, $attachment);
         $db->commit();
         // Publish to facebook, if checked & enabled
         if ($this->_getParam('post_to_facebook', false) && 'publish' == Engine_Api::_()->getApi('settings', 'core')->core_facebook_enable) {
             $fb_uid = Engine_Api::_()->getDbtable('facebook', 'user')->fetchRow(array('user_id = ?' => Engine_Api::_()->user()->getViewer()->getIdentity()));
             if ($fb_uid && $fb_uid->facebook_uid) {
                 $fb_uid = $fb_uid->facebook_uid;
                 $facebook = User_Model_DbTable_Facebook::getFBInstance();
                 if ($facebook->getSession()) {
                     try {
                         $facebook->api('/me');
                         if ($fb_uid != $facebook->getUser()) {
                             throw new Exception('Unable to post to Facebook account; a different account is assigned to the user.');
                         }
                         $url = 'http://' . $_SERVER['HTTP_HOST'] . $this->getFrontController()->getBaseUrl();
                         $name = 'Activity Feed';
                         $desc = '';
                         $picUrl = null;
                         if ($attachment) {
                             $url = 'http://' . $_SERVER['HTTP_HOST'] . $attachment->getHref();
                             $desc = $attachment->getDescription();
                             $name = $attachment->getTitle();
                             if (empty($name)) {
                                 $name = ucwords($attachment->getShortType());
                             }
                             $picUrl = $attachment->getPhotoUrl();
                             if ($picUrl) {
                                 $picUrl = 'http://' . $_SERVER['HTTP_HOST'] . $picUrl;
                             }
                         }
                         // include the site name with the post:
                         $name = Engine_Api::_()->getApi('settings', 'core')->core_general_site_title . ": {$name}";
                         $fb_data = array('message' => $form->getValue('body'), 'link' => $url, 'name' => $name, 'description' => $desc);
                         if ($picUrl) {
                             $fb_data = array_merge($fb_data, array('picture' => $picUrl));
                         }
                         $res = $facebook->api('/me/feed', 'POST', $fb_data);
                     } catch (Exception $e) {
                         /* do nothing */
                     }
                 }
             }
         }
         // end Facebook
     } catch (Exception $e) {
         $db->rollBack();
         throw $e;
         // This should be caught by error handler
     }
     // If we're here, we're done
     $this->view->status = true;
     $this->view->message = Zend_Registry::get('Zend_Translate')->_('Success!');
     // Redirect if in normal context
     if (null === $this->_helper->contextSwitch->getCurrentContext()) {
         $return_url = $form->getValue('return_url', false);
         if (!$return_url) {
             $return_url = $this->view->url(array(), 'default', true);
         }
         return $this->_helper->redirector->gotoUrl($return_url, array('prependBase' => false));
     } else {
         if ('smoothbox' === $this->_helper->contextSwitch->getCurrentContext()) {
             $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('')));
         }
     }
 }
示例#14
0
文件: Core.php 项目: hoalangoc/ftf
 /**
  * create mapped account to revelant process
  * @param int $userId
  * @param string $service
  * @param string $identity
  */
 public function createAccount($userId, $identity, $service, $data = array())
 {
     $table = Engine_Api::_()->getDbtable('Accounts', 'SocialConnect');
     $table->delete("identity='{$identity}' AND service='{$service}'");
     $table->insert(array('user_id' => $userId, 'identity' => $identity, 'service' => $service, 'profile' => json_encode($data)));
     switch ($service) {
         case 'twitter':
             if (class_exists('User_Model_DbTable_Twitter')) {
                 $table = new User_Model_DbTable_Twitter();
                 $account = $table->fetchRow($table->select()->where('user_id=?', $userId));
                 if ($account) {
                     $account->delete();
                 }
                 $table->insert(array('user_id' => $userId, 'twitter_uid' => $identity, 'twitter_token' => '', 'twitter_secret' => ''));
             }
             break;
         case 'facebook':
             if (class_exists('User_Model_DbTable_Facebook')) {
                 $table = new User_Model_DbTable_Facebook();
                 $account = $table->fetchRow($table->select()->where("user_id = {$userId} OR facebook_uid = {$identity}"));
                 if ($account) {
                     $account->delete();
                 }
                 $table->insert(array('user_id' => $userId, 'facebook_uid' => $identity, 'access_token' => '', 'code' => '', 'expires' => ''));
             }
             break;
     }
 }
示例#15
0
 public function facebookSuccessAction()
 {
     $code = $this->_getParam('code');
     if ('none' == Engine_Api::_()->getApi('settings', 'core')->core_facebook_enable) {
         $form->removeElement('facebook');
     } else {
         $facebook = User_Model_DbTable_Facebook::getFBInstance();
         if ($facebook->getSession()) {
             die("hi facebooker");
         }
     }
     if (!$code) {
         $this->_forward('login');
         return;
     }
     $access_token = User_Model_DbTable_Facebook::getAccessToken($code);
 }