mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-22 04:53:46 +09:00
Checking if key of array is set using checkRequiredParamsForArray() method
This commit is contained in:
1 parent
b4e5f8c3e2
commit
487e9cd733
5 files changed
+69
-60
No files matched your search
@@ -142,13 +142,11 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function create($data)
|
||||
{
|
||||
if(!isset($data['email']) || empty($data['email'])) {
|
||||
throw new \Box_Exception('Email required');
|
||||
}
|
||||
|
||||
if(!isset($data['first_name'])) {
|
||||
throw new \Box_Exception('First name is required');
|
||||
}
|
||||
$required = array(
|
||||
'email' => 'Email required',
|
||||
'first_name' => 'First name is required',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
$validator = $this->di['validator'];
|
||||
$validator->isEmailValid($data['email']);
|
||||
@@ -539,9 +537,10 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function group_create($data)
|
||||
{
|
||||
if(!isset($data['title']) || empty($data['title'])) {
|
||||
throw new \Box_Exception('Group title is missing');
|
||||
}
|
||||
$required = array(
|
||||
'title' => 'Group title is missing',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
return $this->getService()->createGroup($data);
|
||||
}
|
||||
|
||||
@@ -55,9 +55,10 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function get($data)
|
||||
{
|
||||
if(!isset($data['code']) || empty($data['code'])) {
|
||||
throw new \Box_Exception('Currency code is missing');
|
||||
}
|
||||
$required = array(
|
||||
'code' => 'Currency code is missing',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
$service = $this->getService();
|
||||
$model = $service->getByCode($data['code']);
|
||||
@@ -131,9 +132,10 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function update($data)
|
||||
{
|
||||
if (!isset($data['code']) || empty($data['code'])) {
|
||||
throw new \Box_Exception('Currency code is missing');
|
||||
}
|
||||
$required = array(
|
||||
'code' => 'Currency code is missing',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
$format = isset($data['format']) ? $data['format'] : null;
|
||||
$title = isset($data['title']) ? $data['title'] : null;
|
||||
@@ -163,9 +165,10 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function delete($data)
|
||||
{
|
||||
if (!isset($data['code']) || empty($data['code'])) {
|
||||
throw new \Box_Exception('Currency code is missing');
|
||||
}
|
||||
$required = array(
|
||||
'code' => 'Currency code is missing',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
return $this->getService()->deleteCurrencyByCode($data['code']);
|
||||
}
|
||||
@@ -181,9 +184,10 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function set_default($data)
|
||||
{
|
||||
if (!isset($data['code']) || empty($data['code'])) {
|
||||
throw new \Box_Exception('Currency code is missing');
|
||||
}
|
||||
$required = array(
|
||||
'code' => 'Currency code is missing',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
$service = $this->getService();
|
||||
$model = $service->getByCode($data['code']);
|
||||
|
||||
@@ -55,9 +55,10 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function email_get($data)
|
||||
{
|
||||
if (!isset($data['id']) || empty($data['id'])) {
|
||||
throw new \Box_Exception('Email ID is required');
|
||||
}
|
||||
$required = array(
|
||||
'id' => 'Email ID is required',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
$service = $this->getService();
|
||||
$model = $service->getEmailById($data['id']);
|
||||
@@ -114,9 +115,10 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function email_resend($data)
|
||||
{
|
||||
if (!isset($data['id']) || empty($data['id'])) {
|
||||
throw new \Box_Exception('Email ID is required');
|
||||
}
|
||||
$required = array(
|
||||
'id' => 'Email ID is required',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
$model = $this->di['db']->findOne('ActivityClientEmail', 'id = ?', array($data['id']));
|
||||
|
||||
@@ -137,9 +139,10 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function email_delete($data)
|
||||
{
|
||||
if (!isset($data['id']) || empty($data['id'])) {
|
||||
throw new \Box_Exception('Email ID is required');
|
||||
}
|
||||
$required = array(
|
||||
'id' => 'Email ID is required',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
$model = $this->di['db']->findOne('ActivityClientEmail', 'id = ?', array($data['id']));
|
||||
|
||||
@@ -191,9 +194,10 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function template_get($data)
|
||||
{
|
||||
if (!isset($data['id']) || empty($data['id'])) {
|
||||
throw new \Box_Exception('Email template ID is required');
|
||||
}
|
||||
$required = array(
|
||||
'id' => 'Email ID is required',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
$model = $this->di['db']->getExistingModelById('EmailTemplate', $data['id'], 'Email template not found');
|
||||
|
||||
@@ -210,9 +214,10 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function template_delete($data)
|
||||
{
|
||||
if (!isset($data['id']) || empty($data['id'])) {
|
||||
throw new \Box_Exception('Email ID is required');
|
||||
}
|
||||
$required = array(
|
||||
'id' => 'Email ID is required',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
$model = $this->di['db']->findOne('EmailTemplate', 'id = ?', array($data['id']));
|
||||
|
||||
@@ -241,22 +246,18 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function template_create($data)
|
||||
{
|
||||
if (!isset($data['action_code'])) {
|
||||
throw new \Box_Exception('Email template code is required');
|
||||
}
|
||||
|
||||
if (!isset($data['subject'])) {
|
||||
throw new \Box_Exception('Email template subject is required');
|
||||
}
|
||||
|
||||
if (!isset($data['content'])) {
|
||||
throw new \Box_Exception('Email template content is required');
|
||||
}
|
||||
$required = array(
|
||||
'action_code' => 'Email template code is required',
|
||||
'subject' => 'Email template subject is required',
|
||||
'content' => 'Email template content is required',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
$enabled = isset($data['enabled']) ? $data['enabled'] : 0;
|
||||
$category = isset($data['category']) ? $data['category'] : NULL;
|
||||
|
||||
$templateModel = $this->getService()->templateCreate($data['action_code'], $data['subject'], $data['content'], $enabled, $category);
|
||||
|
||||
return $templateModel->id;
|
||||
}
|
||||
|
||||
@@ -270,9 +271,10 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function template_update($data)
|
||||
{
|
||||
if (!isset($data['id']) || empty($data['id'])) {
|
||||
throw new \Box_Exception('Email template ID is required');
|
||||
}
|
||||
$required = array(
|
||||
'id' => 'Email ID is required',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
$enabled = isset($data['enabled']) ? $data['enabled'] : null;
|
||||
$category = isset($data['category']) ? $data['category'] : null;
|
||||
@@ -293,9 +295,11 @@ class Admin extends \Api_Abstract
|
||||
*/
|
||||
public function template_reset($data)
|
||||
{
|
||||
if (!isset($data['code']) || empty($data['code'])) {
|
||||
throw new \Box_Exception('Email template code was not passed');
|
||||
}
|
||||
$required = array(
|
||||
'code' => 'Email template code was not passed',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
return $this->getService()->resetTemplateByCode($data['code']);
|
||||
}
|
||||
|
||||
|
||||
@@ -175,9 +175,10 @@ class Guest extends \Api_Abstract
|
||||
*/
|
||||
public function search($data)
|
||||
{
|
||||
if (!isset($data['q']) || empty($data['q'])) {
|
||||
throw new \Box_Exception('Enter some keywords for search');
|
||||
}
|
||||
$required = array(
|
||||
'q' => 'Enter some keywords for search',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
if (strlen($data['q']) < 3) {
|
||||
throw new \Box_Exception('Search keyword must be longer than 3 characters');
|
||||
|
||||
@@ -296,9 +296,10 @@ Order our services at {{ "order"|link }}
|
||||
$mod = $this->di['mod']('massmailer');
|
||||
$c = $mod->getConfig();
|
||||
|
||||
if(!isset($c['test_client_id']) || empty($c['test_client_id'])) {
|
||||
throw new \Box_Exception('Client ID needs to be configured in mass mailer settings.');
|
||||
}
|
||||
$required = array(
|
||||
'test_client_id' => 'Client ID needs to be configured in mass mailer settings.',
|
||||
);
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $c);
|
||||
|
||||
return (int)$c['test_client_id'];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user