Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! I cleaned up your code for you! #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Logs and databases #
######################
*.log

# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
44 changes: 22 additions & 22 deletions controllers/admin/generatedata_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
* Generate Data Settings Controller
*
* PHP version 5
* LICENSE: This source file is subject to LGPL license
* 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 Ushahidi Team <team@ushahidi.com>
* @author Ushahidi Team <team@ushahidi.com>
* @package Ushahidi - http://source.ushahididev.com
* @module Generate Date Settings Controller
* @module Generate Date Settings Controller
* @copyright Ushahidi - http://www.ushahidi.com
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
*
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
*
*/

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

// Standard Settings View
$this->template->content = new View("admin/plugins_settings");
$this->template->content->title = "Generate Data Settings";

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

// setup and initialize form field names
$form = array
(
Expand Down Expand Up @@ -57,18 +57,18 @@ public function index()
{
// Yes! everything is valid
// CREATE REPORTS HERE

// Just double check it's a positive integer value
$num_make = abs((int)$post->thismanyreports);

$categories = Category_Model::categories();

$cat_arr = array();
foreach($categories as $cat)
{
$cat_arr[] = $cat['category_id'];
}

$i = 0;
while($i < $num_make)
{
Expand All @@ -78,17 +78,17 @@ public function index()
$latlon = $lat.','.$lon;
$rand_title = Generatedata_Settings_Controller::rand_string(mt_rand(5,40));
$rand_description = Generatedata_Settings_Controller::rand_string(mt_rand(15,1000));



// Create Location
$location = new Location_Model();
$location->location_name = $latlon;
$location->latitude = $lat;
$location->longitude = $lon;
$location->location_date = date("Y-m-d H:i:s",time());
$location->save();

// Create Report
$incident = new Incident_Model();
$incident->location_id = $location->id;
Expand All @@ -104,7 +104,7 @@ public function index()
$incident->incident_verified = mt_rand(0,1);
//Save
$incident->save();

// Set Category (only setting one category per report)
$incident_category = new Incident_Category_Model();
$incident_category->incident_id = $incident->id;
Expand All @@ -113,7 +113,7 @@ public function index()

$i++;
}

// Everything is A-Okay!
$form_saved = TRUE;

Expand Down Expand Up @@ -143,16 +143,16 @@ public function index()
'thismanyreports' => '1'
);
}

// Pass the $form on to the settings_form variable in the view
$this->template->content->settings_form->form = $form;

// Other variables
$this->template->content->errors = $errors;
$this->template->content->form_error = $form_error;
$this->template->content->form_saved = $form_saved;
}

public function rand_string($lenth) {
// makes a random alpha numeric string of a given lenth
$aZ09 = array_merge(range('A', 'Z'), range('a', 'z'),range(0, 9));
Expand All @@ -164,5 +164,5 @@ public function rand_string($lenth) {
$out .= $aZ09[mt_rand(0,count($aZ09)-1)];
}
return $out;
}
}
}