/** * Method to validate the form data. * Each field error is stored in session and can be retrieved with getFieldError(). * Once getFieldError() is called, the error is deleted from the session. * * @param JForm $form The form to validate against. * @param array $data The data to validate. * @param string $group The name of the field group to validate. * * @return mixed Array of filtered data if valid, false otherwise. */ public function validate($form, $data, $group = null) { if (!isset($data['project_id'])) { $data['project_id'] = TrackslibHelperTools::getCurrentProjectId(); } return parent::validate($form, $data, $group); }
/** * Build an SQL query to load the list data. * * @return object Query object */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select($this->getState('list.select', array('obj.*', 'i.last_name, i.first_name', 't.name AS team'))); $query->from($db->qn('#__tracks_participants', 'obj')); $query->join('INNER', $db->qn('#__tracks_individuals', 'i') . ' ON ' . $db->qn('obj.individual_id') . ' = ' . $db->qn('i.id')); $query->join('LEFT', $db->qn('#__tracks_teams', 't') . ' ON ' . $db->qn('obj.team_id') . ' = ' . $db->qn('t.id')); $query->where($db->qn('obj.project_id') . ' = ' . TrackslibHelperTools::getCurrentProjectId()); // Filter: like / search $search = $this->getState('filter.search', ''); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('obj.id = ' . (int) substr($search, 3)); } else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); $query->where('CONCAT(i.last_name, i.first_name) LIKE ' . $search); } } // Add the list ordering clause. $query->order($db->escape($this->getState('list.ordering', 'i.last_name')) . ' ' . $db->escape($this->getState('list.direction', 'ASC'))); return $query; }
protected function populateState($ordering = 'ordering', $direction = 'asc') { $this->setState('project_id', TrackslibHelperTools::getCurrentProjectId()); parent::populateState($ordering, $direction); }
/** * Get project id * * @return mixed */ protected function getProjectId() { if (!$this->project_id) { $this->project_id = TrackslibHelperTools::getCurrentProjectId(); } return $this->project_id; }