Skip to content

Commit

Permalink
Add helper methods for getting incident URLS ushahidi#857 ushahidi#853
Browse files Browse the repository at this point in the history
These are used in the json controller and reports listing
  • Loading branch information
rjmackay committed Oct 1, 2012
1 parent 847b667 commit cb39fea
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions application/models/incident.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,4 +635,36 @@ public function delete()
parent::delete();
}

/**
* Get url of this incident
* @return string
**/
public function url()
{
return self::get_url($this);
}

/**
* Get url for the incident object passed
* @param object|int
* @return string
**/
public static function get_url($incident)
{
if (is_object($incident))
{
$id = isset($incident->incident_id) ? $incident->incident_id : $incident->id;
}
elseif (is_int($incident))
{
$id = intval($incident);
}
else
{
return false;
}

return url::site('reports/view/'.$id);
}

}

0 comments on commit cb39fea

Please sign in to comment.