Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ushahidi/Ushahidi_Web
Browse files Browse the repository at this point in the history
  • Loading branch information
eyedol committed Aug 19, 2010
2 parents 4471b30 + 9af5e60 commit e734d8e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 26 deletions.
30 changes: 29 additions & 1 deletion application/controllers/admin/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,14 @@ function index($page = 1)
$update->incident_active = '1';

// Tag this as a report that needs to be sent out as an alert
$update->incident_alert_status = '1';
if ($update->incident_alert_status != '2')
{ // 2 = report that has had an alert sent
$update->incident_alert_status = '1';
}

$update->save();


$verify = new Verify_Model();
$verify->incident_id = $item;
$verify->verified_status = '1';
Expand All @@ -115,6 +120,13 @@ function index($page = 1)
$update = new Incident_Model($item);
if ($update->loaded == true) {
$update->incident_active = '0';

// If Alert hasn't been sent yet, disable it
if ($update->incident_alert_status == '1')
{
$update->incident_alert_status = '0';
}

$update->save();

$verify = new Verify_Model();
Expand Down Expand Up @@ -575,6 +587,7 @@ function edit( $id = false, $saved = false )
{
$incident->incident_dateadd = date("Y-m-d H:i:s",time());
}

// Is this an Email, SMS, Twitter submitted report?
//XXX: We may get rid of incident_mode altogether... ???
//$_POST
Expand Down Expand Up @@ -605,6 +618,21 @@ function edit( $id = false, $saved = false )
//Save
$incident->save();

// Tag this as a report that needs to be sent out as an alert
if ($incident->incident_active == '1' AND
$incident->incident_alert_status != '2')
{ // 2 = report that has had an alert sent
$incident->incident_alert_status = '1';
$incident->save();
}
// Remove alert if report is unactivated and alert hasn't yet been sent
if ($incident->incident_active == '0' AND
$incident->incident_alert_status == '1')
{
$incident->incident_alert_status = '0';
$incident->save();
}

// Record Approval/Verification Action
$verify = new Verify_Model();
$verify->incident_id = $incident->id;
Expand Down
38 changes: 21 additions & 17 deletions application/controllers/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Api_Controller extends Controller {
private $messages = array(); // form validation error messages
private $domain; // the domain name of the calling site
protected $table_prefix; // Table Prefix

/**
* constructor
*/
Expand All @@ -36,12 +36,16 @@ function __construct()
$this->domain = $this->_getDomain();
$this->table_prefix = Kohana::config('database.default.table_prefix');
}

// get the FQDN
function _getDomain() {
$domain = ((empty($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] === 'off') ?
'http' : 'https').'://'.$_SERVER['SERVER_NAME'];

$subdomain = '';

if(substr_count($_SERVER["HTTP_HOST"],'.') > 1) $subdomain = substr($_SERVER["HTTP_HOST"],0,strpos($_SERVER["HTTP_HOST"],'.')).'.';

$domain = ((empty($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] === 'off') ?
'http' : 'https').'://'.$subdomain.''.$_SERVER['SERVER_NAME'];

return $domain;
}

Expand Down Expand Up @@ -269,7 +273,7 @@ function switchTask(){
$by = '';
$sort = 'DESC';
$orderfield = 'incidentid';

if(!$this->_verifyArrayIndex($request, 'by')){
$error = array("error" => $this->_getErrorMsg(001, 'by'));
break;
Expand All @@ -290,13 +294,13 @@ function switchTask(){

/*Specify how many incidents to return */
if($this->_verifyArrayIndex($request, 'limit')){

if ( $request['limit'] > 0 ){
$limit = $request['limit'];
} else {
$limit = 20;
}
// Make limit variable optional
// Make limit variable optional
} else {
$limit = 20;
}
Expand All @@ -321,9 +325,9 @@ function switchTask(){
}
switch ($by){
case "all": // incidents

$ret = $this->_incidentsByAll($orderfield, $sort, $limit);

break;

case "latlon": //latitude and longitude
Expand Down Expand Up @@ -488,7 +492,7 @@ function _getIncidents($where = '', $limit = ''){
$retJsonOrXml = ''; //will hold the json/xml string to return

$replar = array(); //assists in proper xml generation

// Doing this manually. It was wasting my time trying to modularize it.
// Will have to visit this again after a good rest. I mean a good rest.

Expand All @@ -515,9 +519,9 @@ function _getIncidents($where = '', $limit = ''){
."FROM ".$this->table_prefix."incident AS i "
."INNER JOIN ".$this->table_prefix."location as l on l.id = i.location_id "
."$where $limit";

$items = $this->db->query($query);

$i = 0;
foreach ($items as $item){

Expand Down Expand Up @@ -586,7 +590,7 @@ function _getIncidents($where = '', $limit = ''){

}
$xml->endElement(); // end incident

//needs different treatment depending on the output
if($this->responseType == 'json'){
$json_incidents[] = array("incident" => $item, "media" => $json_incident_media);
Expand All @@ -599,7 +603,7 @@ function _getIncidents($where = '', $limit = ''){
"payload" => array("domain" => $this->domain,"incidents" => $json_incidents),
"error" => $this->_getErrorMsg(0)
);

if($this->responseType == 'json'){
$retJsonOrXml = $this->_arrayAsJSON($data);
return $retJsonOrXml;
Expand Down Expand Up @@ -1514,11 +1518,11 @@ function _countryByIso($iso){
* Fetch all incidents
*/
function _incidentsByAll($orderfield,$sort,$limit) {

$where = "\nWHERE i.incident_active = 1 ";
$sortby = "\nGROUP BY i.id ORDER BY $orderfield $sort";
$limit = "\nLIMIT 0, $limit";

/* Not elegant but works */
return $this->_getIncidents($where.$sortby, $limit);
}
Expand Down
7 changes: 0 additions & 7 deletions application/controllers/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,6 @@ public function __construct()
}
$this->template->header->l = Kohana::config('locale.language');

//Set up tracking gif
if($_SERVER['SERVER_NAME'] != 'localhost' && $_SERVER['SERVER_NAME'] != '127.0.0.1'){
$track_url = $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
}else{
$track_url = 'null';
}
$this->template->footer->tracker_url = 'http://tracker.ushahidi.com/track.php?url='.urlencode($track_url).'&lang='.$this->template->header->l.'&version='.Kohana::config('version.ushahidi_version');
// Load profiler
// $profiler = new Profiler;

Expand Down
1 change: 0 additions & 1 deletion application/views/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
</div>
<!-- / footer -->

<img src="<?php echo $tracker_url; ?>" />
<?php echo $ushahidi_stats; ?>
<?php echo $google_analytics; ?>

Expand Down

0 comments on commit e734d8e

Please sign in to comment.