Beispiel #1
0
 public function ajaxGenerateAnalytics()
 {
     $username = JRequest::getVar('user', '');
     $user = JXFactory::getUser($username);
     $view = ProfileFactory::getView('display');
     $html = $view->generateAnalytics($user);
     echo $html;
     exit;
 }
Beispiel #2
0
 function display($tpl = null)
 {
     $user = JXFactory::getUser();
     $this->assignRef('user', $user);
     JForm::addFieldPath(JPATH_COMPONENT . DS . 'models' . DS . 'fields');
     $form = JForm::getInstance('form', JPATH_ROOT . DS . 'components' . DS . 'com_profile' . DS . 'models' . DS . 'forms' . DS . 'details.xml');
     $detailModel = ProfileFactory::getModel('detail');
     $form->bind(array('params' => $detailModel->getDetails($user->id)));
     $this->assignRef('form', $form);
     $document = JFactory::getDocument();
     $document->addScript(JURI::root() . 'media/jquery/jquery-1.7.min.js');
     $document->setTitle(JText::_('COM_PROFILE_LABEL_EDIT_DETAILS'));
     parent::display($tpl);
 }
Beispiel #3
0
 public function details()
 {
     $user = JXFactory::getUser();
     if ($_POST) {
         $mainframe = JFactory::getApplication();
         $detailModel = ProfileFactory::getModel('detail');
         $detailModel->removeDetails($user->id);
         $data = JRequest::getVar('params', array(), 'post', 'array');
         $success = true;
         foreach ($data as $field => $value) {
             $userDetail = JTable::getInstance('detailUser', 'ProfileTable');
             $userDetail->user_id = $user->id;
             $userDetail->field = $field;
             if (is_array($value)) {
                 $value = array_values($value);
                 $userDetail->value = json_encode($value);
             } else {
                 $userDetail->value = $value;
             }
             $success = $userDetail->store() && $success;
         }
         $user->init($user);
         // $percentageFilled below will calculate only the required field
         // $percentageFilled = round($requiredIsFilled/count($requiredFields) * 100);
         $percentageFilled = $user->getCalculateCompletion();
         $user->setGettingStartedCompletion(JXUser::GSTARTED_COMPLETE_PROFILE, $percentageFilled);
         if ($success) {
             /* Redirect to clear the previous user values */
             $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit&task=details', false), JText::_('COM_PROFILE_ACTION_SAVE_DETAIL_SUCCESS'));
         } else {
             $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit&task=details', false), JText::_('COM_PROFILE_ACTION_SAVE_DETAIL_FAILED'), 'error');
         }
     }
     JRequest::setVar('view', 'detail');
     parent::display(null);
 }
Beispiel #4
0
 /**
  *  Clone JUser object into current JXUser obkect
  */
 public function init($user)
 {
     $thisVars = get_object_vars($this);
     foreach ($thisVars as $key => $val) {
         if (isset($user->{$key})) {
             $this->{$key} = $user->{$key};
         }
     }
     // Load user profile information from #_user_details
     if (intval($this->id) > 0) {
         $detailModel = ProfileFactory::getModel('detail');
         $userParams = $detailModel->getDetails($this->id);
         foreach ($userParams as $key => $val) {
             $this->{$key} = $userParams[$key];
         }
         $this->_enableAllNotification();
     }
 }
Beispiel #5
0
 function display($tpl = null)
 {
     include_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'string.php';
     $name = JRequest::getString('user');
     $userId = JUserHelper::getUserId($name);
     $user = JXFactory::getUser($userId);
     $my = JXFactory::getUser();
     $lastStatus = $user->getStatus();
     $task = JRequest::getVar('task', 'activities');
     $this->addPathway(JText::_('NAVIGATOR_LABEL_PEOPLE'), JRoute::_('index.php?option=com_people&view=members'));
     $this->addPathway($user->name);
     $doc = JFactory::getDocument();
     // Add attachment script
     $doc->addScript(JURI::root() . 'media/uploader/fileuploader.js');
     $doc->addStyleSheet(JURI::root() . 'media/uploader/fileuploader.css');
     $groupsView = StreamFactory::getView('groups');
     // $html = $groupsView->getUserGroupsHTML($userId);
     // JXModule::addBuffer('right', $html );
     // this section is to get the group_type to set the twitter button's toggle
     $validGroupType = JAnalytics::getGroupType();
     $analyticsGroupBy = JRequest::getVar('group_type', 'day');
     $analyticIndex = array_search($analyticsGroupBy, $validGroupType);
     $analyticIndex = $analyticIndex === false ? 1 : $analyticIndex;
     $this->assignRef('user', $user);
     $this->assignRef('my', $my);
     $this->assignRef('analyticIndex', $analyticIndex);
     $this->assignRef('analyticType', $validGroupType);
     $this->assign('lastStatus', $lastStatus[0]->message);
     $this->assign('analyticHtml', $this->generateAnalytics($user));
     switch ($task) {
         case 'activities':
             $companyView = StreamFactory::getView('company');
             $filter = array();
             $filter['user_id'] = $user->id;
             // Show only the user's stream
             $options = array();
             $options['filter'] = 'stream.filter.profile';
             $activities = $companyView->getStreamDataHTML($filter, $options);
             $this->assignRef('activities', $activities);
             break;
         case 'bio':
             // Bio
             JForm::addFieldPath(JPATH_COMPONENT . DS . 'models' . DS . 'fields');
             $form = JForm::getInstance('form', JPATH_ROOT . DS . 'components' . DS . 'com_profile' . DS . 'models' . DS . 'forms' . DS . 'details.xml');
             $detailModel = ProfileFactory::getModel('detail');
             $form->bind(array('params' => $detailModel->getDetails($user->id)));
             $this->assignRef('form', $form);
             $this->assignRef('user', $user);
             break;
         case 'content':
             $this->assignRef('user', $user);
             $streamModel = StreamFactory::getModel('stream');
             $blogs = $streamModel->getStream(array('type' => 'page', 'user_id' => $user->id), 10);
             $this->assign('blogs', $blogs);
             $this->assign('blogCount', $streamModel->countStream(array('type' => 'page', 'user_id' => $user->id)));
             $links = $user->getParam('links', '');
             $linkModel = StreamFactory::getModel('links');
             $links = $linkModel->getLinks(array('id' => $links, '!link' => ''), 10);
             $this->assignRef('links', $links);
             $this->assign('linkCount', JXUtility::csvCount($user->getParam('links')));
             $fileModel = StreamFactory::getModel('files');
             $files = $fileModel->getFiles(array('user_id' => $user->id), 10);
             $fileView = StreamFactory::getView('files');
             $this->assignRef('fileView', $fileView);
             $this->assignRef('files', $files);
             $this->assign('fileCount', $fileModel->countFiles(array('user_id' => $user->id)));
             break;
     }
     //$document = JFactory::getDocument();
     // $document->setTitle(JText::_('COM_PROFILE_LABEL_PROFILE_PAGE').': '.$user->name);
     $groupView = StreamFactory::getView('groups');
     JXModule::addBuffer('right', $groupView->getUserActiveGroupsHTML($user->id));
     // development
     $fileView = StreamFactory::getView('files');
     JXModule::addBuffer('right', $fileView->modUserFilesHTML($user));
     parent::display($tpl);
 }