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; }
public function onAfterInitialise() { // Make sure this is the back-end $app = JFactory::getApplication(); if (!in_array($app->getName(), array('administrator', 'admin'))) { return; } if (version_compare(JVERSION, '2.5.0', 'lt')) { $this->autoDisable(); return; } // Get the input variables $ji = new JInput(); $component = $ji->getCmd('option', ''); $task = $ji->getCmd('task', ''); $view = $ji->getCmd('view', ''); $backedup = $ji->getInt('is_backed_up', 0); // Perform a redirection on Joomla! Update download or install task, unless we have already backed up the site if ($component == 'com_joomlaupdate' && $task == 'update.install' && !$backedup) { // Get the backup profile ID $profileId = (int) $this->params->get('profileid', 1); if ($profileId <= 0) { $profileId = 1; } // Get the return URL $return_url = JUri::base() . 'index.php?option=com_joomlaupdate&task=update.install&is_backed_up=1'; // Get the redirect URL $token = JFactory::getSession()->getToken(); $redirect_url = JUri::base() . 'index.php?option=com_akeeba&view=backup&autostart=1&returnurl=' . urlencode($return_url) . '&profileid=' . $profileId . "&{$token}=1"; // Perform the redirection $app = JFactory::getApplication(); $app->redirect($redirect_url); } }
public function onAfterInitialise() { // Make sure this is the back-end $app = JFactory::getApplication(); if (!in_array($app->getName(), array('administrator', 'admin'))) { return; } // Get the input variables $ji = new JInput(); $component = $ji->getCmd('option', ''); $task = $ji->getCmd('task', ''); $view = $ji->getCmd('view', ''); $backedup = $ji->getInt('is_backed_up', 0); // Perform a redirection on Joomla! Update download or install task, unless we have already backed up the site if ($component == 'com_joomlaupdate' && $task == 'update.install' && !$backedup) { $return_url = JURI::base() . 'index.php?option=com_joomlaupdate&task=update.install&is_backed_up=1'; $redirect_url = JURI::base() . 'index.php?option=com_akeeba&view=backup&autostart=1&returnurl=' . urlencode($return_url); $app = JFactory::getApplication(); $app->redirect($redirect_url); } }
/** * 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(); }