<commit_before><?php defined('SYSPATH') OR die('No direct script access.');
/**
 * FrontlineCloud Settings Controller
 *
 * PHP version 5
 * LICENSE: This source file is subject to LGPL license
 * that is available through the world-wide-web at the following URI:
 * http://www.gnu.org/copyleft/lesser.html
 * @author	   <NAME> <<EMAIL>>
 * @package    Ushahidi - http://source.ushahididev.com
 * @module	   FrontlineCloud Settings Controller
 * @copyright  Ushahidi - http://www.ushahidi.com
 * @license    http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
*
*/

class Frontlinecloud_Settings_Controller extends Admin_Controller {

	public function index()
	{
		$this->template->this_page = 'addons';

		// Standard Settings View
		$this->template->content = new View("admin/addons/plugin_settings");
		$this->template->content->title = "FrontlineCloud Settings";

		// Settings Form View
		$this->template->content->settings_form = new View("frontlinecloud/admin/frontlinecloud_settings");

		// Do we have a frontlinecloud Key? If not create and save one on the fly
		$frontlinecloud = ORM::factory('frontlinecloud', 1);

		if ($frontlinecloud->loaded AND $frontlinecloud->frontlinecloud_key)
		{
			$frontlinecloud_key = $frontlinecloud->frontlinecloud_key;
		}
		else
		{
			$frontlinecloud_key = strtoupper(text::random('alnum',8));
			$frontlinecloud->frontlinecloud_key = $frontlinecloud_key;
			$frontlinecloud->save();
		}

		$this->template->content->settings_form->frontlinecloud_key = $frontlinecloud_key;
		$this->template->content->settings_form->frontlinecloud_link = url::site()."frontlinecloud";
		$this->template->content->settings_form->frontlinecloud_sender = "\${sender_number}";
		$this->template->content->settings_form->frontlinecloud_message = "\${message_content}";
		// setup and initialize form field names
		$form = array
		(
			'frontlinecloud_api_url' => ''
		);
		//  Copy the form as errors, so the errors will be stored with keys
		//  corresponding to the form field names
		$errors = $form;
		$form_error = FALSE;
		$form_saved = FALSE;

		// check, has the form been submitted, if so, setup validation
		if ($_POST)
		{
			// Instantiate Validation, use $post, so we don't overwrite $_POST
			// fields with our own things
			$post = new Validation($_POST);

			// Add some filters
			$post->pre_filter('trim', TRUE);

			// Add some rules, the input field, followed by a list of checks, carried out in order
			$post->add_rules('frontlinecloud_api_url', 'required', 'url');

			// Test to see if things passed the rule checks
			if ($post->validate())
			{<commit_msg>Fix frontline SMS parameter names<commit_after><?php defined('SYSPATH') OR die('No direct script access.');
/**
 * FrontlineCloud Settings Controller
 *
 * PHP version 5
 * LICENSE: This source file is subject to LGPL license
 * that is available through the world-wide-web at the following URI:
 * http://www.gnu.org/copyleft/lesser.html
 * @author	   <NAME> <<EMAIL>>
 * @package    Ushahidi - http://source.ushahididev.com
 * @module	   FrontlineCloud Settings Controller
 * @copyright  Ushahidi - http://www.ushahidi.com
 * @license    http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
*
*/

class Frontlinecloud_Settings_Controller extends Admin_Controller {

	public function index()
	{
		$this->template->this_page = 'addons';

		// Standard Settings View
		$this->template->content = new View("admin/addons/plugin_settings");
		$this->template->content->title = "FrontlineCloud Settings";

		// Settings Form View
		$this->template->content->settings_form = new View("frontlinecloud/admin/frontlinecloud_settings");

		// Do we have a frontlinecloud Key? If not create and save one on the fly
		$frontlinecloud = ORM::factory('frontlinecloud', 1);

		if ($frontlinecloud->loaded AND $frontlinecloud->frontlinecloud_key)
		{
			$frontlinecloud_key = $frontlinecloud->frontlinecloud_key;
		}
		else
		{
			$frontlinecloud_key = strtoupper(text::random('alnum',8));
			$frontlinecloud->frontlinecloud_key = $frontlinecloud_key;
			$frontlinecloud->save();
		}

		$this->template->content->settings_form->frontlinecloud_key = $frontlinecloud_key;
		$this->template->content->settings_form->frontlinecloud_link = url::site()."frontlinecloud";
		$this->template->content->settings_form->frontlinecloud_sender = "\${message_src_number}";
		$this->template->content->settings_form->frontlinecloud_message = "\${message_body}";
		// setup and initialize form field names
		$form = array
		(
			'frontlinecloud_api_url' => ''
		);
		//  Copy the form as errors, so the errors will be stored with keys
		//  corresponding to the form field names
		$errors = $form;
		$form_error = FALSE;
		$form_saved = FALSE;

		// check, has the form been submitted, if so, setup validation
		if ($_POST)
		{
			// Instantiate Validation, use $post, so we don't overwrite $_POST
			// fields with our own things
			$post = new Validation($_POST);

			// Add some filters
			$post->pre_filter('trim', TRUE);

			// Add some rules, the input field, followed by a list of checks, carried out in order
			$post->add_rules('frontlinecloud_api_url', 'required', 'url');

			// Test to see if things passed the rule checks
			if ($post->validate())
			{
{'fraction_non_alphanumeric': 0.12986032465081163, 'fraction_numerical': 0.0011325028312570782, 'mean_word_length': 4.190009794319295, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3511404', 'n_tokens_mistral': 1747, 'n_tokens_neox': 1591, 'n_words': 432}