Esempio n. 1
0
 public function _updateFirstLastName($user, $profileType = COMMUNITY_DEFAULT_PROFILE)
 {
     $profileModel = CFactory::getModel('profile');
     $filter = array('fieldcode' => 'FIELD_FAMILYNAME');
     $fields = $profileModel->getAllFields($filter, $profileType);
     if (!empty($fields)) {
         $isUseFirstLastName = CUserHelper::isUseFirstLastName();
         if ($isUseFirstLastName) {
             $tmpUserModel = CFactory::getModel('register');
             $mySess = JFactory::getSession();
             $tmpUser = $tmpUserModel->getTempUser($mySess->get('JS_REG_TOKEN', ''));
             $fullname = array();
             $fullname[$profileModel->getFieldId('FIELD_GIVENNAME')] = $tmpUser->firstname;
             $fullname[$profileModel->getFieldId('FIELD_FAMILYNAME')] = $tmpUser->lastname;
             $pModel = $this->getModel('profile');
             $pModel->saveProfile($user->id, $fullname);
         }
     }
 }
Esempio n. 2
0
 /**
  * Edits a user details
  *
  * @access	public
  * @param	array  An associative array to display the editing of the fields
  */
 public function editDetails(&$data)
 {
     $mainframe = JFactory::getApplication();
     // access check
     CFactory::setActiveProfile();
     if (!$this->accessAllowed('registered')) {
         return;
     }
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $userParams = $my->getParams();
     $pathway = $mainframe->getPathway();
     $pathway->addItem(JText::_($my->getDisplayName()), CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
     $pathway->addItem(JText::_('COM_COMMUNITY_EDIT_DETAILS'), '');
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_EDIT_DETAILS'));
     // $js = 'assets/validate-1.5.min.js';
     // CFactory::attach($js, 'js');
     $this->showSubmenu();
     $connectModel = CFactory::getModel('Connect');
     $associated = $connectModel->isAssociated($my->id);
     $fbHtml = '';
     if ($config->get('fbconnectkey') && $config->get('fbconnectsecret') && !$config->get('usejfbc')) {
         //CFactory::load( 'libraries' , 'facebook' );
         $facebook = new CFacebook();
         $fbHtml = $facebook->getLoginHTML();
     }
     if ($config->get('usejfbc')) {
         if (class_exists('JFBCFactory')) {
             $providers = JFBCFactory::getAllProviders();
             foreach ($providers as $p) {
                 $fbHtml .= $p->loginButton();
             }
         }
     }
     // If FIELD_GIVENNAME & FIELD_FAMILYNAME is in use
     $isUseFirstLastName = CUserHelper::isUseFirstLastName();
     $jConfig = JFactory::getConfig();
     //CFactory::load( 'libraries' , 'apps' );
     $app = CAppPlugins::getInstance();
     $appFields = $app->triggerEvent('onFormDisplay', array('jsform-profile-editdetails'));
     $beforeFormDisplay = CFormElement::renderElements($appFields, 'before');
     $afterFormDisplay = CFormElement::renderElements($appFields, 'after');
     $tmpl = new CTemplate();
     echo $tmpl->set('beforeFormDisplay', $beforeFormDisplay)->set('afterFormDisplay', $afterFormDisplay)->set('fbHtml', $fbHtml)->set('fbPostStatus', $userParams->get('postFacebookStatus'))->set('jConfig', $jConfig)->set('params', $data->params)->set('user', $my)->set('config', $config)->set('associated', $associated)->set('isAdmin', COwnerHelper::isCommunityAdmin())->set('offsetList', $data->offsetList)->set('isUseFirstLastName', $isUseFirstLastName)->fetch('profile.edit.details');
 }
Esempio n. 3
0
 /**
  * Edits a user details
  *
  * @access	public
  * @param	array  An associative array to display the editing of the fields
  */
 function editDetails(&$data)
 {
     $mainframe =& JFactory::getApplication();
     // access check
     CFactory::setActiveProfile();
     if (!$this->accessAllowed('registered')) {
         return;
     }
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $pathway =& $mainframe->getPathway();
     $pathway->addItem(JText::_($my->getDisplayName()), CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
     $pathway->addItem(JText::_('CC EDIT DETAILS'), '');
     $document =& JFactory::getDocument();
     $document->setTitle(JText::_('CC EDIT DETAILS'));
     $js = 'assets/validate-1.5';
     $js .= $config->getBool('usepackedjavascript') ? '.pack.js' : '.js';
     CAssets::attach($js, 'js');
     $this->showSubmenu();
     $connectModel = CFactory::getModel('Connect');
     $associated = $connectModel->isAssociated($my->id);
     CFactory::load('helpers', 'owner');
     CFactory::load('libraries', 'facebook');
     $fbHtml = '';
     if ($config->get('fbconnectkey') && $config->get('fbconnectsecret')) {
         CFactory::load('libraries', 'facebook');
         $facebook = new CFacebook();
         $fbHtml = $facebook->getLoginHTML();
     }
     // If FIELD_GIVENNAME & FIELD_FAMILYNAME is in use
     CFactory::load('helpers', 'user');
     $isUseFirstLastName = CUserHelper::isUseFirstLastName();
     $jConfig =& JFactory::getConfig();
     CFactory::load('libraries', 'apps');
     $app =& CAppPlugins::getInstance();
     $appFields = $app->triggerEvent('onFormDisplay', array('jsform-profile-editdetails'));
     $beforeFormDisplay = CFormElement::renderElements($appFields, 'before');
     $afterFormDisplay = CFormElement::renderElements($appFields, 'after');
     $tmpl = new CTemplate();
     $tmpl->set('beforeFormDisplay', $beforeFormDisplay);
     $tmpl->set('afterFormDisplay', $afterFormDisplay);
     $tmpl->set('fbHtml', $fbHtml);
     $tmpl->set('jConfig', $jConfig);
     $tmpl->set('params', $data->params);
     $tmpl->set('user', $my);
     $tmpl->set('config', $config);
     $tmpl->set('associated', $associated);
     $tmpl->set('isAdmin', COwnerHelper::isCommunityAdmin());
     $tmpl->set('offsetList', $data->offsetList);
     $tmpl->set('isUseFirstLastName', $isUseFirstLastName);
     echo $tmpl->fetch('profile.edit.details');
 }
Esempio n. 4
0
 /**
  * Display custom profiles registration form.
  **/
 public function registerProfile($fields)
 {
     CFactory::load('libraries', 'profile');
     jimport('joomla.utilities.arrayhelper');
     jimport('joomla.utilities.date');
     $mainframe =& JFactory::getApplication();
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_COMMUNITY_REGISTER_NEW'));
     $model = CFactory::getModel('profile');
     $profileType = JRequest::getVar('profileType', 0);
     $config = CFactory::getConfig();
     $profileTypes = $model->getProfileTypes();
     // @rule: When multiple profile is enabled, and profile type is not selected, we should trigger an error.
     if ($config->get('profile_multiprofile') && $profileType == COMMUNITY_DEFAULT_PROFILE && !empty($profileTypes)) {
         $mainframe->redirect(CRoute::_('index.php?option=com_community&view=register&task=registerProfileType', false), JText::_('COM_COMMUNITY_NO_PROFILE_TYPE_SELECTED'), 'error');
     }
     $empty_html = array();
     $post = JRequest::get('post');
     CFactory::load('helpers', 'user');
     $isUseFirstLastName = CUserHelper::isUseFirstLastName();
     $firstName = '';
     $lastName = '';
     if ($isUseFirstLastName) {
         $fullname = $this->_getFirstLastName();
         $firstName = $fullname['first'];
         $lastName = $fullname['last'];
     }
     // Bind result from previous post into the field object
     if (!empty($post)) {
         foreach ($fields as $group) {
             $field = $group->fields;
             for ($i = 0; $i < count($field); $i++) {
                 $fieldid = $field[$i]->id;
                 $fieldType = $field[$i]->type;
                 if (!empty($post['field' . $fieldid])) {
                     if (is_array($post['field' . $fieldid])) {
                         if ($fieldType != 'date' && $fieldType != 'birthdate') {
                             $values = $post['field' . $fieldid];
                             //$value  = '';
                             /*foreach($values as $listValue)
                             		{
                             			$value	.= $listValue . ',';
                             		}*/
                             $value = implode(',', $values);
                             $field[$i]->value = $value;
                         } else {
                             $field[$i]->value = $post['field' . $fieldid];
                         }
                     } else {
                         $field[$i]->value = $post['field' . $fieldid];
                     }
                 }
             }
         }
     } else {
         if ($isUseFirstLastName) {
             foreach ($fields as $group) {
                 $field = $group->fields;
                 for ($i = 0; $i < count($field); $i++) {
                     if ($field[$i]->fieldcode == 'FIELD_GIVENNAME') {
                         $field[$i]->value = $firstName;
                     }
                     if ($field[$i]->fieldcode == 'FIELD_FAMILYNAME') {
                         $field[$i]->value = $lastName;
                     }
                 }
             }
         }
     }
     $config = CFactory::getConfig();
     $js = 'assets/validate-1.5' . ($config->getBool('usepackedjavascript') ? '.pack.js' : '.js');
     CAssets::attach($js, 'js');
     $profileType = JRequest::getVar('profileType', 0, 'GET');
     CFactory::load('libraries', 'privacy');
     $tmpl = new CTemplate();
     echo $this->_getProgressBar(2);
     echo $tmpl->set('fields', $fields)->set('profileType', $profileType)->fetch('register.profile');
 }