-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2769 from ushahidi/release/cycle-3-sms-csv
Release/cycle 3 sms+csv to Master
- Loading branch information
Showing
132 changed files
with
6,380 additions
and
919 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
.*swp | ||
*~ | ||
*.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
|
||
/** | ||
* Ushahidi API CountryCodes Controller | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2013 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
class Controller_Api_CountryCodes extends Ushahidi_Rest { | ||
|
||
protected $_action_map = array | ||
( | ||
Http_Request::GET => 'get', | ||
Http_Request::OPTIONS => 'options' | ||
); | ||
|
||
protected function _scope() | ||
{ | ||
return 'country_codes'; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
application/classes/Controller/Api/Exports/External/Cli.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
|
||
/** | ||
* Ushahidi API Export Execute CLI Controller | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2018 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Output\BufferedOutput; | ||
|
||
class Controller_Api_Exports_External_Cli extends Controller_Api_External { | ||
|
||
protected function _scope() | ||
{ | ||
return 'export_jobs'; | ||
} | ||
|
||
public function action_get_index() | ||
{ | ||
// Get Symfony console app | ||
$app = service('app.console'); | ||
$command = $app->get('exporter'); | ||
|
||
$job_id = $this->request->param('id'); | ||
|
||
//Deal with query string - | ||
// init and assume unset | ||
$limit = 0; | ||
$offset = 0; | ||
$add_header = true; | ||
// then do some validation (remove this if Kohana is better at this) | ||
if (is_numeric($this->request->query('limit'))) | ||
{ | ||
$limit = $this->request->query('limit'); | ||
} | ||
if (is_numeric($this->request->query('offset'))) | ||
{ | ||
$offset = $this->request->query('offset'); | ||
} | ||
// this is a trick to convert 'false' to falsy (which would be true), | ||
// 'true' to true, and an unset param to false | ||
$include_header = json_decode($this->request->query('include_header')) == true ? 1 : 0; | ||
|
||
// Construct console command input | ||
$input = new ArrayInput(array( | ||
'--limit' => $limit, | ||
'--offset' => $offset, | ||
'--job' => $job_id, | ||
'--include_header' => $include_header, | ||
), $command->getDefinition()); | ||
|
||
// Create Output Buffer | ||
$output = new BufferedOutput(); | ||
|
||
|
||
// Run the command | ||
$command->run($input, $output); | ||
|
||
// Retrieve the results of rhe export | ||
// which should be a json formatted string | ||
// containing information aboutt he file generated and | ||
// saved by the exporter | ||
$file_details = json_decode($output->fetch()); | ||
|
||
$this->_response_payload = [ | ||
'results' => $file_details, | ||
]; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
application/classes/Controller/Api/Exports/External/Count.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
|
||
/** | ||
* Ushahidi API External Export Jobs Post Count Controller | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2018 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
class Controller_Api_Exports_External_Count extends Controller_Api_External { | ||
|
||
protected function _scope() | ||
{ | ||
return 'export_jobs'; | ||
} | ||
|
||
public function action_get_index() | ||
{ | ||
$this->_usecase = service('factory.usecase') | ||
->get($this->_resource(), 'post-count') | ||
->setIdentifiers($this->_identifiers()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
application/classes/Controller/Api/Exports/External/Jobs.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
|
||
/** | ||
* Ushahidi API External Webhook Posts Controller | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2013 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
class Controller_Api_Exports_External_Jobs extends Controller_Api_External { | ||
|
||
protected function _scope() | ||
{ | ||
return 'export_jobs'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
|
||
/** | ||
* Ushahidi API Export Jobs Controller | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2013 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
class Controller_Api_Exports_Jobs extends Ushahidi_Rest { | ||
|
||
protected function _scope() | ||
{ | ||
return 'posts'; | ||
} | ||
|
||
protected function _resource() | ||
{ | ||
return 'export_jobs'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
|
||
/** | ||
* Ushahidi API Export Execute CLI Controller | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2018 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Output\BufferedOutput; | ||
|
||
use Ushahidi\Core\Tool\Verifier; | ||
|
||
class Controller_Api_External extends Ushahidi_Rest { | ||
|
||
protected function _scope() | ||
{ | ||
return 'external'; | ||
} | ||
|
||
public function before() | ||
{ | ||
parent::before(); | ||
$data = $this->_request_payload; | ||
$api_key = isset($data['api_key']) ? $data['api_key'] : null; | ||
|
||
if ($this->request->method() === 'GET') { | ||
$data = []; | ||
$api_key = $this->request->query('api_key'); | ||
} | ||
|
||
$signature = $this->request->headers('X-Ushahidi-Signature'); | ||
|
||
$shared_secret = getenv('PLATFORM_SHARED_SECRET'); | ||
$fullURL = URL::site(Request::detect_uri(), TRUE) . URL::query(); | ||
|
||
$verifier = new Verifier($signature, $api_key, $shared_secret, $fullURL, $data); | ||
|
||
if (!$verifier->verified()) { | ||
throw HTTP_Exception::factory(403, 'Forbidden'); | ||
} | ||
} | ||
|
||
protected function _is_auth_required() | ||
{ | ||
return false; | ||
} | ||
|
||
|
||
public function setExternalAuth() { | ||
$this->_usecase->setAuthorizer(service('authorizer.external_auth')); | ||
} | ||
/** | ||
* Create An Entity | ||
* | ||
* POST /api/foo | ||
* | ||
* @return void | ||
*/ | ||
public function action_post_index_collection() | ||
{ | ||
parent::action_post_index_collection(); | ||
$this->setExternalAuth(); | ||
} | ||
|
||
/** | ||
* Retrieve All Entities | ||
* | ||
* GET /api/foo | ||
* | ||
* @return void | ||
*/ | ||
public function action_get_index_collection() | ||
{ | ||
parent::action_get_index_collection(); | ||
$this->setExternalAuth(); | ||
} | ||
|
||
/** | ||
* Retrieve An Entity | ||
* | ||
* GET /api/foo/:id | ||
* | ||
* @return void | ||
*/ | ||
public function action_get_index() | ||
{ | ||
parent::action_get_index(); | ||
$this->setExternalAuth(); | ||
} | ||
|
||
/** | ||
* Update An Entity | ||
* | ||
* PUT /api/foo/:id | ||
* | ||
* @return void | ||
*/ | ||
public function action_put_index() | ||
{ | ||
parent::action_put_index(); | ||
$this->setExternalAuth(); | ||
} | ||
|
||
/** | ||
* Delete An Entity | ||
* | ||
* DELETE /api/foo/:id | ||
* | ||
* @return void | ||
*/ | ||
public function action_delete_index() | ||
{ | ||
parent::action_delete_index(); | ||
$this->setExternalAuth(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
|
||
/** | ||
* Ushahidi API Forms Controller | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2013 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
class Controller_API_Forms_Contacts extends Ushahidi_Rest { | ||
|
||
protected function _scope() | ||
{ | ||
return 'forms'; | ||
} | ||
|
||
protected function _resource() | ||
{ | ||
return 'form_contacts'; | ||
} | ||
|
||
// Get Lock | ||
public function action_post_index_collection() | ||
{ | ||
|
||
$this->_usecase = service('factory.usecase') | ||
->get($this->_resource(), 'create'); | ||
$this->_usecase->setIdentifiers($this->request->param()); | ||
$this->_usecase->setPayload($this->_request_payload); | ||
} | ||
|
||
// Get Lock | ||
public function action_get_index_collection() | ||
{ | ||
$this->_usecase = service('factory.usecase') | ||
->get($this->_resource(), 'search'); | ||
$this->_usecase->setIdentifiers($this->request->param()); | ||
$this->_usecase | ||
->setFormatter(service("formatter.entity.form.contactcollection")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
/** | ||
* Ushahidi API Form Stats Controller | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2018 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
class Controller_Api_Forms_Stats extends Ushahidi_Rest { | ||
|
||
protected $_action_map = array | ||
( | ||
Http_Request::GET => 'get', | ||
Http_Request::OPTIONS => 'options' | ||
); | ||
protected function _scope() | ||
{ | ||
return 'forms'; | ||
} | ||
|
||
protected function _resource() | ||
{ | ||
return 'form_stats'; | ||
} | ||
|
||
// Get Lock | ||
public function action_get_index_collection() | ||
{ | ||
$this->_usecase = service('factory.usecase') | ||
->get($this->_resource(), 'search'); | ||
$this->_usecase->setIdentifiers($this->request->param()); | ||
$this->_usecase | ||
->setFormatter(service("formatter.entity.form.stats")); | ||
} | ||
} |
Oops, something went wrong.