Beispiel #1
0
 /**
  * Display the view
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     if ($this->getLayout() !== 'modal') {
         SibdietHelper::addSubmenu('profiles');
     }
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->filterForm = $this->get('FilterForm');
     $this->activeFilters = $this->get('ActiveFilters');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->permissions = SibdietHelper::getUserPermissions();
     if ($this->getLayout() !== 'modal') {
         // Calculate profile refer No.
         foreach ($this->items as $item) {
             $item->referNo = SibdietHelper::getReferNo($item->id);
         }
         $this->addToolbar();
         $this->sidebar = JHtmlSidebar::render();
     }
     if (in_array('profiles', $this->permissions) || $this->getLayout() == 'modal') {
         parent::display($tpl);
     }
 }
Beispiel #2
0
 /**
  * Method to toggle the featured setting of a list of articles.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $user = JFactory::getUser();
     $ids = $this->input->get('cid', array(), 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     // Access checks.
     foreach ($ids as $i => $id) {
         $permissions = SibdietHelper::getUserPermissions();
         if (!in_array('nutrients', $permissions) || !$user->authorise('core.edit.state', 'com_sibdiet.nutrient.' . (int) $id)) {
             // Prune items that you can't change.
             unset($ids[$i]);
             JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Publish the items.
         if (!$model->featured($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         }
         if ($value == 1) {
             $message = JText::plural('COM_SIBDIET_N_ITEMS_FEATURED', count($ids));
         } else {
             $message = JText::plural('COM_SIBDIET_N_ITEMS_UNFEATURED', count($ids));
         }
     }
     $this->setRedirect('index.php?option=com_sibdiet&view=nutrients', false, $message);
 }
Beispiel #3
0
 /**
  * Method override to check if you can edit an existing record.
  *
  * @param   array   $data  An array of input data.
  * @param   string  $key   The name of the key for the primary key.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 protected function allowEdit($data = array(), $key = 'id')
 {
     $permissions = SibdietHelper::getUserPermissions();
     $recordId = (int) isset($data[$key]) ? $data[$key] : 0;
     $user = JFactory::getUser();
     $userId = $user->get('id');
     // Check requests manage permission first.
     if ($this->input->get('return') == 'requestschecks') {
         if (in_array('requestschecks', $permissions)) {
             return parent::allowEdit($data, $key);
         }
     } elseif (in_array('requests', $permissions)) {
         // Check that diet not started
         if ($recordId) {
             // Need to do a lookup from the model.
             $record = $this->getModel()->getItem($recordId);
             if ($record->room1 || $record->room2 || $record->room3 || $record->room4 || $record->room5 || $record->room6) {
                 return false;
             }
             // Now test the owner is the user.
             $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
             if (empty($ownerId)) {
                 if (empty($record)) {
                     return false;
                 }
                 $ownerId = $record->created_by;
             }
             // If the owner matches 'me' then do the test.
             if ($ownerId == $userId) {
                 return true;
             }
         }
     }
     return false;
 }
Beispiel #4
0
 /**
  * Display the view
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     SibdietHelper::addSubmenu('requestschecks');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->filterForm = $this->get('FilterForm');
     $this->activeFilters = $this->get('ActiveFilters');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->permissions = SibdietHelper::getUserPermissions();
     // Calculate profile refer No.
     foreach ($this->items as $item) {
         $item->referNo = SibdietHelper::getReferNo($item->profiles_id);
         // Convert the payment field to an array.
         $registry = new JRegistry();
         $registry->loadString($item->payment);
         $item->payment = $registry->toArray();
     }
     $this->addToolbar();
     $this->sidebar = JHtmlSidebar::render();
     if (in_array('requestschecks', $this->permissions)) {
         parent::display($tpl);
     }
 }
Beispiel #5
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.
  *
  * @since   1.6
  */
 public function display($tpl = null)
 {
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->canDo = JHelperContent::getActions('com_sibdiet');
     $this->return = JFactory::getApplication()->input->getCmd('return');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Check second time
     $this->second_time = false;
     if ($this->item->profiles_id) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('COUNT(id)')->from('#__sibdiet_setdiets')->where('profiles_id = ' . $this->item->profiles_id)->where('id <> ' . (int) $this->item->id);
         $db->setQuery($query);
         $this->second_time = $db->loadResult();
     }
     $this->permissions = SibdietHelper::getUserPermissions();
     $this->addToolbar();
     if (in_array('requests', $this->permissions) || in_array('requestschecks', $this->permissions)) {
         parent::display($tpl);
     }
 }
Beispiel #6
0
 /**
  * Method to test whether a record can have its state edited.
  *
  * @param   object  $record  A record object.
  *
  * @return  boolean  True if allowed to change the state of the record. Defaults to the permission set in the component.
  *
  * @since   1.6
  */
 protected function canEditState($record)
 {
     $permissions = SibdietHelper::getUserPermissions();
     if (in_array('contags', $permissions)) {
         return parent::canEditState($record);
     }
     return false;
 }
Beispiel #7
0
 /**
  * Method override to check if you can edit an existing record.
  *
  * @param   array   $data  An array of input data.
  * @param   string  $key   The name of the key for the primary key.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 protected function allowEdit($data = array(), $key = 'id')
 {
     $permissions = SibdietHelper::getUserPermissions();
     if (in_array('sweeteners', $permissions)) {
         return parent::allowEdit($data, $key);
     } else {
         return false;
     }
 }
Beispiel #8
0
 /**
  * Method to test whether a record can have its state edited.
  *
  * @param   object  $record  A record object.
  *
  * @return  boolean  True if allowed to change the state of the record. Defaults to the permission set in the component.
  *
  * @since   1.6
  */
 protected function canEditState($record)
 {
     $permissions = SibdietHelper::getUserPermissions();
     // Check requests manage permission first.
     if (in_array('setdiets', $permissions)) {
         return parent::canEditState($record);
     }
     return false;
 }
Beispiel #9
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.
  *
  * @since   1.6
  */
 public function display($tpl = null)
 {
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->canDo = SibdietHelper::getActions('com_sibdiet');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->permissions = SibdietHelper::getUserPermissions();
     $this->addToolbar();
     if (in_array('units', $this->permissions)) {
         parent::display($tpl);
     }
 }
Beispiel #10
0
 /**
  * Display the view
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     SibdietHelper::addSubmenu('contags');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->filterForm = $this->get('FilterForm');
     $this->activeFilters = $this->get('ActiveFilters');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->permissions = SibdietHelper::getUserPermissions();
     $this->addToolbar();
     $this->sidebar = JHtmlSidebar::render();
     if (in_array('contags', $this->permissions)) {
         parent::display($tpl);
     }
 }
Beispiel #11
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.
  *
  * @since   1.6
  */
 public function display($tpl = null)
 {
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->canDo = JHelperContent::getActions('com_sibdiet');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Get Bread & Rice & diseases & prescriptions history
     $profiles_id = $this->item->profiles_id ? $this->item->profiles_id : JFactory::getApplication()->getUserState('com_sibdiet.setdiets.filter.profiles_id');
     $this->item->history = $this->getHistories($profiles_id, $this->item->id);
     $this->permissions = SibdietHelper::getUserPermissions();
     $this->addToolbar();
     if (in_array('setdiets', $this->permissions)) {
         parent::display($tpl);
     }
 }