function validate() { $return = array('error' => 0, 'msg' => array()); $input = new JInput(); $ajax = $input->getInt('ajax', 0); $email = $input->getString('email', ''); $name = $input->getString('name', ''); $username = $input->getString('username', ''); if ($email && !$this->validateEmail($email)) { $return['error'] = +1; $return['msg'][] = JText::_('COM_SLOGIN_ERROR_VALIDATE_MAIL'); } if ($email && !$this->checkUniqueEmail($email)) { $return['error'] = +1; $return['msg'][] = JText::_('COM_SLOGIN_ERROR_NOT_UNIQUE_MAIL'); } if ($name && !$this->validateName($name)) { $return['error'] = +1; $return['msg'][] = JText::_('COM_SLOGIN_ERROR_VALIATE_NAME'); } if ($username && !$this->validateUserName($username)) { $return['error'] = +1; $return['msg'][] = JText::_('COM_SLOGIN_ERROR_VALIATE_USERNAME'); } if ($ajax) { echo json_encode($return); die; } return $return; }
protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication(); $input = new JInput(); // Adjust the context to support modal layouts. if ($layout = $input->getString('layout', 'default')) { $this->context .= '.' . $layout; } $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); $provider = $this->getUserStateFromRequest($this->context . '.filter.provider', 'filter_provider', 0, 'string'); $this->setState('filter.provider', $provider); // List state information. parent::populateState('su.id', 'desc'); }
/** * Start a session * * @return void * * @since 4.0 */ public function start() { $session_name = $this->getName(); // Get the cookie object $cookie = $this->input->cookie; if (is_null($cookie->get($session_name))) { $session_clean = $this->input->getString($session_name); if ($session_clean) { $this->setId($session_clean); $cookie->set($session_name, '', time() - 3600); } } parent::start(); // Try loading data from the session if (isset($_SESSION['joomla']) && !empty($_SESSION['joomla'])) { $this->data = unserialize(base64_decode($_SESSION['joomla'])); } }
/** * Saves a classification entity. * * @param JInput $input Holds the data to be saved. * * @return int ID of the inserted / saved object. * * @throws Exception */ public function save($input) { $query = $this->db->getQuery(true); $user = JFactory::getUser(); $values = array("title" => $input->getString('title'), "access" => $input->getString('access'), "project_id" => $input->getInt('project_id')); $values = $this->validate($values); if (!$values) { return false; } $id = $input->getInt('id'); if ($id != 0) { $query->update('#__monitor_issue_classifications')->where('id = ' . $id); } else { $query->insert('#__monitor_issue_classifications'); } $query->set(MonitorHelper::sqlValues($values, $query)); $this->db->setQuery($query); $this->db->execute(); if ($id != 0) { return $id; } return $this->db->insertid(); }
/** * Saves an issue entity. * * @param JInput $input Holds the data to be saved. * * @return int ID of the inserted / saved object. * * @throws Exception */ public function save($input) { $query = $this->db->getQuery(true); $user = JFactory::getUser(); // Validate form data. $values = array("title" => $input->getString('title'), "text" => $input->getString('text'), "version" => $input->getString('version'), "project_id" => $input->getInt('project_id'), "classification" => $input->getInt('classification')); $values = $this->validate($values); if (!$values) { return false; } // Validate attachments. $params = $this->getParams(); $enableAttachments = $params->get('issue_enable_attachments', 1); if ($enableAttachments) { $modelAttachments = new MonitorModelAttachments(); $files = $input->files->get('file', null, 'raw'); if (($files = $this->validateFiles($files, $values, $modelAttachments)) === null) { return false; } } $id = $input->getInt('id'); if ($id != 0) { $query->update('#__monitor_issues')->where('id = ' . $id); } else { $values["author_id"] = $user->id; $query->insert('#__monitor_issues'); } $values["created"] = JDate::getInstance()->toSql(); $query->set(MonitorHelper::sqlValues($values, $query)); $this->db->setQuery($query); $this->db->execute(); if ($id == 0) { $id = $this->db->insertid(); } if ($enableAttachments) { // Upload attachments $modelAttachments->upload($files, $id); } return $id; }
/** * Saves a comment entity. * * @param JInput $input Holds the data to be saved. * * @return int|boolean The ID of the inserted/updated comment on success, boolean false on failure. * * @throws Exception */ public function save($input) { $user = JFactory::getUser(); // Validate form data. $values = array("issue_id" => $input->getInt('issue_id'), "text" => $input->getString('text')); $values = $this->validate($values); if (!$values) { return false; } // Validate attachments. $params = $this->getParams(); $enableAttachments = $params->get('comment_enable_attachments', 1); if ($enableAttachments) { $modelAttachments = new MonitorModelAttachments(); $files = $input->files->get('file', null, 'raw'); if (($files = $this->validateFiles($files, $values, $modelAttachments)) === null) { return false; } } if ($values["issue_id"] == 0) { throw new Exception(JText::_('JGLOBAL_VALIDATION_FORM_FAILED')); } if ($user->authorise('comment.edit.status', 'com_monitor')) { $values["status"] = $input->getInt('issue_status'); if ($values["status"]) { $query = $this->db->getQuery(true); $query->update('#__monitor_issues')->where('id = ' . $values["issue_id"])->set('status = ' . $values["status"]); $this->db->setQuery($query); $this->db->execute(); } else { unset($values["status"]); } } $query = $this->db->getQuery(true); $id = $input->getInt('id'); if (!$this->canEdit($user, $id)) { throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); } if ($id != 0) { $query->update('#__monitor_comments')->where('id = ' . $id); } else { $values["author_id"] = $user->id; $query->insert('#__monitor_comments'); } $values["created"] = JDate::getInstance()->toSql(); $query->set(MonitorHelper::sqlValues($values, $query)); $this->db->setQuery($query); $this->db->execute(); if ($id == 0) { $id = $this->db->insertid(); } // Upload attachments if ($enableAttachments) { $modelAttachments->upload($files, $values["issue_id"], $id); } return $id; }
/** * Saves a project entity. * * @param JInput $input Holds the data to be saved. * * @return mixed A database cursor resource on success, boolean false on failure. * * @throws Exception */ public function save($input) { $query = $this->db->getQuery(true); $values = array("name" => $input->getString('name'), "alias" => $input->getString('alias'), "url" => $input->getString('url'), "logo" => $input->getString('logo'), "logo_alt" => $input->getString('logo_alt'), "description" => $input->get('description', '', 'raw'), "issue_template" => $input->get('issue_template', '', 'raw')); $values = $this->validate($values); if (!$values) { return false; } $id = $input->getInt('id'); if ($id != 0) { $query->update('#__monitor_projects')->where('id = ' . $id); } else { $query->insert('#__monitor_projects'); } if ($values['alias'] == null) { if (JFactory::getConfig()->get('unicodeslugs') == 1) { $values['alias'] = JFilterOutput::stringURLUnicodeSlug($values['name']); } else { $values['alias'] = JFilterOutput::stringURLSafe($values['name']); } } $twin = $this->resolveAlias($values['alias']); if ($twin && $twin != $id) { JFactory::getApplication()->enqueueMessage(JText::_('COM_MONITOR_ERROR_DUPLICATE_PROJECT_ALIAS'), 'error'); return false; } $query->set(MonitorHelper::sqlValues($values, $query)); $this->db->setQuery($query); return $this->db->execute(); }
/** * Saves a status entity. * * @param JInput $input Holds the data to be saved. * * @return int ID of the inserted / saved object. * * @throws Exception */ public function save($input) { $query = $this->db->getQuery(true); $values = array("name" => $input->getString('name'), "helptext" => $input->getString('helptext'), "open" => $input->getBool('open'), "style" => $input->getString('style'), "project_id" => $input->getInt('project_id')); $values = $this->validate($values); if (!$values) { return false; } $id = $input->getInt('id'); if ($id != 0) { $query->update('#__monitor_status')->where('id = ' . $id); } else { $query->insert('#__monitor_status'); $orderQuery = $this->db->getQuery(true); $orderQuery->select('MAX(ordering)')->from('#__monitor_status')->where('project_id = ' . $values["project_id"]); $this->db->setQuery($orderQuery)->execute(); $values["ordering"] = (int) $this->db->loadResult() + 1; } $query->set(MonitorHelper::sqlValues($values, $query)); $this->db->setQuery($query); return $this->db->execute(); }