function display($tpl = null) { // @rule: Test for user access if on 1.6 and above if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { if (!JFactory::getUser()->authorise('easyblog.manage.user', 'com_easyblog')) { JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error'); JFactory::getApplication()->close(); } } //initialise variables $document = JFactory::getDocument(); $mainframe = JFactory::getApplication(); $config = EasyBlogHelper::getConfig(); $id = JRequest::getInt('id'); $blogger = EasyBlogHelper::getTable('Profile', 'Table'); $blogger->load($id); $post = EasyBlogHelper::getSession('EASYBLOG_REGISTRATION_POST'); $avatarIntegration = $config->get('layout_avatarIntegration', 'default'); $user = JFactory::getUser($id); $isNew = $user->id == 0 ? true : false; if ($isNew && !empty($post)) { unset($post['id']); $pwd = $post['password']; unset($post['password']); unset($post['password2']); $user->bind($post); $post['password'] = $pwd; $blogger->bind($post); } jimport('joomla.html.pane'); $feedburner = EasyBlogHelper::getTable('Feedburner', 'Table'); $feedburner->load($id); JTable::addIncludePath(EBLOG_TABLES); //twitter $twitter = EasyBlogHelper::getTable('Oauth', 'Table'); $twitter->loadByUser($user->id, EBLOG_OAUTH_TWITTER); //linkedin $linkedin = EasyBlogHelper::getTable('Oauth', 'Table'); $linkedin->loadByUser($user->id, EBLOG_OAUTH_LINKEDIN); //facebook $facebook = EasyBlogHelper::getTable('Oauth', 'Table'); $facebook->loadByUser($user->id, EBLOG_OAUTH_FACEBOOK); $adsense = EasyBlogHelper::getTable('Adsense', 'Table'); $adsense->load($id); if ($isNew && !empty($post)) { $feedburner->url = $post['feedburner_url']; $twitter->message = $post['integrations_twitter_message']; $twitter->auto = $post['integrations_twitter_auto']; $linkedin->auto = $post['integrations_linkedin_auto']; $linkedin->private = isset($post['integrations_linkedin_private']) ? $post['integrations_linkedin_private'] : false; $facebook->auto = $post['integrations_facebook_auto']; $adsense->published = $post['adsense_published']; $adsense->code = $post['adsense_code']; $adsense->display = $post['adsense_display']; } if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_users' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'user.php'; $jUserModel = new UsersModelUser(); $form = $jUserModel->getForm(); $form->setValue('password', null); $form->setValue('password2', null); $this->assignRef('form', $form); } $joomla_date = EasyBlogHelper::getJoomlaVersion() <= '1.5' ? '%Y-%m-%d %H:%M:%S' : 'Y-m-d H:i:s'; $editor = JFactory::getEditor($config->get('layout_editor', 'tinymce')); $userParams = $user->getParameters(true); $bloggerRawParams = $blogger->getParams(); if (is_array($bloggerRawParams)) { $bloggerRawParams = ''; } $bloggerParams = EasyBlogHelper::getRegistry($bloggerRawParams); $this->assignRef('bloggerParams', $bloggerParams); $this->assignRef('editor', $editor); $this->assignRef('dateFormat', $joomla_date); $this->assignRef('config', $config); $this->assignRef('pane', $pane); $this->assignRef('feedburner', $feedburner); $this->assignRef('adsense', $adsense); $this->assignRef('twitter', $twitter); $this->assignRef('facebook', $facebook); $this->assignRef('linkedin', $linkedin); $this->assignRef('blogger', $blogger); $this->assignRef('user', $user); $this->assignRef('isNew', $isNew); $this->assignRef('params', $userParams); $this->assignRef('avatarIntegration', $avatarIntegration); $this->assignRef('post', $post); parent::display($tpl); }
/** * Displays the author's form * * @since 4.0 * @access public * @param string * @return */ public function form() { // Check for access $this->checkAccess('easyblog.manage.user'); // Get the author's id $id = $this->input->get('id', 0, 'int'); $author = EB::user($id); // Get the session data $post = EB::getSession('EASYBLOG_REGISTRATION_POST'); // Set heading $title = 'COM_EASYBLOG_TITLE_EDIT_AUTHOR'; if (!$id) { $title = 'COM_EASYBLOG_TITLE_CREATE_AUTHOR'; } JToolBarHelper::title(JText::_($title), 'users'); $this->setHeading($title, '', 'fa-user'); $user = JFactory::getUser($id); // Determines if this is a new user or not $isNew = $user->id == 0 ? true : false; if ($isNew && !empty($post)) { unset($post['id']); $pwd = $post['password']; unset($post['password']); unset($post['password2']); $user->bind($post); $post['password'] = $pwd; $author->bind($post); } // Load up feedburner data $feedburner = EB::table('Feedburner'); $feedburner->load($author->id); // Load up twitter oauth client $twitter = EB::table('OAuth'); $twitter->load(array('user_id' => $user->id, 'type' => EBLOG_OAUTH_TWITTER, 'system' => false)); // Load up linkedin oauth table $linkedin = EB::table('OAuth'); $linkedin->load(array('user_id' => $user->id, 'type' => EBLOG_OAUTH_LINKEDIN, 'system' => false)); // Load up facebook oauth table $facebook = EB::table('OAuth'); $facebook->load(array('user_id' => $user->id, 'type' => EBLOG_OAUTH_FACEBOOK, 'system' => false)); $facebookClient = EB::oauth()->getClient(EBLOG_OAUTH_FACEBOOK); $twitterClient = EB::oauth()->getClient(EBLOG_OAUTH_TWITTER); $linkedinClient = EB::oauth()->getClient(EBLOG_OAUTH_LINKEDIN); // Load up adsense data $adsense = EB::table('Adsense'); $adsense->load($author->id); // If this is a new author and the post was submitted before if ($isNew && $post) { $feedburner->url = $post['feedburner_url']; $twitter->message = $post['integrations_twitter_message']; $twitter->auto = $post['integrations_twitter_auto']; $linkedin->auto = $post['integrations_linkedin_auto']; $linkedin->private = isset($post['integrations_linkedin_private']) ? $post['integrations_linkedin_private'] : false; $facebook->auto = $post['integrations_facebook_auto']; $adsense->published = $post['adsense_published']; $adsense->code = $post['adsense_code']; $adsense->display = $post['adsense_display']; } // Get the WYSIWYG editor $editor = JFactory::getEditor(); // Get the user params $params = $user->getParameters(true); // Get the params $bloggerParams = $author->getParams(); // Load up joomla's user forms require_once JPATH_ADMINISTRATOR . '/components/com_users/models/user.php'; $language = JFactory::getLanguage(); $language->load('com_users', JPATH_ADMINISTRATOR); JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_users/models/forms'); JForm::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_users/models/fields'); JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_users/model/form'); JForm::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_users/model/field'); $jUserModel = new UsersModelUser(); $form = $jUserModel->getForm(); $form->setValue('password', null); $form->setValue('password2', null); $this->set('linkedinClient', $linkedinClient); $this->set('twitterClient', $twitterClient); $this->set('facebookClient', $facebookClient); $this->set('form', $form); $this->set('editor', $editor); $this->set('bloggerParams', $bloggerParams); $this->set('user', $user); $this->set('author', $author); $this->set('params', $params); $this->set('feedburner', $feedburner); $this->set('adsense', $adsense); $this->set('twitter', $twitter); $this->set('facebook', $facebook); $this->set('linkedin', $linkedin); $this->set('isNew', $isNew); $this->set('post', $post); parent::display('bloggers/form'); }