Esempio n. 1
0
 /**
  * redirects to correct view...
  *
  * @return bool
  *
  * @throws Exception
  */
 public function onBeforeAdd()
 {
     $user = JFactory::getUser();
     if (!$user) {
         throw new Exception('access not allowed', 403);
     }
     // If the user is logged, check if he already has a profile
     $model = FOFModel::getTmpInstance('IndividualEdits', 'TracksModel');
     $ind = $model->getUserIndividual($user->get('id'));
     if (!$ind) {
         $allow_register = JComponentHelper::getParams('com_tracks')->get('user_registration', 0);
         if (!$allow_register) {
             throw new Exception('Create individuals not allowed', 403);
         }
         // Redirect to individual edit
         $link = JRoute::_(TrackslibHelperRoute::getEditIndividualRoute());
     } else {
         // Redirect to individual edit
         $link = JRoute::_(TrackslibHelperRoute::getEditIndividualRoute($ind));
     }
     $this->setRedirect($link);
     $this->redirect();
     // We shouldn't arrive at that point ;)
     return false;
 }
Esempio n. 2
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  */
 public function display($tpl = null)
 {
     RHelperAsset::load('tracks.css');
     $mainframe = JFactory::getApplication();
     if ($this->getLayout() == 'edit') {
         $this->displayForm($tpl);
         return;
     }
     $user = JFactory::getUser();
     $params = $mainframe->getParams('com_tracks');
     $document = JFactory::getDocument();
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('tracks');
     JPluginHelper::importPlugin('content');
     $data = $this->get('Item');
     $attribs['class'] = "pic";
     if ($data->picture != '') {
         $data->picture = JHTML::image(JURI::root() . $data->picture, $data->first_name . ' ' . $data->last_name, $attribs);
     } else {
         $data->picture = JHTML::image(JURI::root() . 'media/com_tracks/images/misc/tnnophoto.jpg', $data->first_name . ' ' . $data->last_name, $attribs);
     }
     if ($data->picture_small != '') {
         $data->picture_small = JHTML::image(JURI::root() . $data->picture_small, $data->first_name . ' ' . $data->last_name, $attribs);
     } else {
         $data->picture_small = JHTML::image(JURI::root() . 'media/com_tracks/images/misc/tnnophoto.jpg', $data->first_name . ' ' . $data->last_name, $attribs);
     }
     $raceResults = $this->sortResultsByProject($this->get('RaceResults'));
     $show_edit_link = $user->id && $user->id == $data->user_id || $user->authorise('core.manage', 'com_tracks');
     $breadcrumbs = $mainframe->getPathWay();
     $breadcrumbs->addItem($data->first_name . ' ' . $data->last_name, TrackslibHelperRoute::getEditIndividualRoute($data->id));
     $document->setTitle($data->first_name . ' ' . $data->last_name);
     // Allow content plugins
     $data->description = JHTML::_('content.prepare', $data->description);
     $this->assignRef('data', $data);
     $this->assignRef('show_edit_link', $show_edit_link);
     $this->assignRef('results', $raceResults);
     $this->assignRef('params', $params);
     $this->assignRef('dispatcher', $dispatcher);
     parent::display($tpl);
 }
Esempio n. 3
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  */
 public function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     if (!$user->id) {
         print JText::_('COM_TRACKS_You_must_register_to_access_this_page');
         return;
     }
     $model = $this->getModel();
     $data = $model->getData($user->id);
     if (!$data->id) {
         // No tracks individual associated to profile
         $params = $mainframe->getParams('com_tracks');
         if ($params->get('user_registration')) {
             $mainframe->redirect(TrackslibHelperRoute::getEditIndividualRoute());
         } else {
             $msg = JText::_('COM_TRACKS_No_tracks_individual_associated_to_your_account');
             $mainframe->redirect('index.php?option=com_tracks', $msg);
         }
     }
     $mainframe->redirect(TrackslibHelperRoute::getIndividualRoute($data->id));
 }
Esempio n. 4
0
defined('_JEXEC') or die('Restricted access');
?>

<div id="tracks">
	<!-- Title -->
	<h2><?php 
echo $this->data->first_name . ' ' . $this->data->last_name;
?>
</h2>

	<?php 
if ($this->show_edit_link) {
    ?>
		<div id="editprofile"><a
				href="<?php 
    echo JRoute::_(TrackslibHelperRoute::getEditIndividualRoute($this->data->id));
    ?>
"
				title="<?php 
    echo JText::_('COM_TRACKS_Edit_profile');
    ?>
">
				<?php 
    echo JText::_('COM_TRACKS_Edit_profile');
    ?>
			</a></div>
	<?php 
}
?>

	<!-- Content -->