mirror of https://github.com/MISP/MISP
new: [dashboard:orgWidget] Added support of `first_half_year` and `second_half_year` time frames
parent
123b1d07c2
commit
8d2b5933b4
|
@ -16,6 +16,8 @@ class NewOrgsWidget
|
|||
'days' => 'How many days back should the list go - for example, setting 7 will only show the organisations that were added in the past 7 days. (integer)',
|
||||
'month' => 'Which organisations have been added this month? (boolean)',
|
||||
'previous_month' => 'Who contributed most the previous, finished month? (boolean)',
|
||||
'first_half_year' => 'Who contributed most the first half-year (between Jan and June)? (boolean)',
|
||||
'second_half_year' => 'Who contributed most the second half-year (between July and Dec)? (boolean)',
|
||||
'year' => 'Which organisations have been added this year? (boolean)',
|
||||
'local' => 'Should the list only show local organisations? (boolean or list of booleans, defaults to 1. To get both sets, use [0,1])',
|
||||
'fields' => 'Which fields should be displayed, by default all are selected. Pass a list with the following options: [id, uuid, name, sector, type, nationality, creation_date]'
|
||||
|
@ -59,6 +61,14 @@ class NewOrgsWidget
|
|||
} else if (!empty($options['year'])) {
|
||||
$condition = strtotime('first day of this year 00:00:00', time());
|
||||
$this->tableDescription = __('The %d newest organisations created during the current year', $limit);
|
||||
} else if (!empty($options['first_half_year'])) {
|
||||
$condition = strtotime('first day of january this year 00:00:00', time());
|
||||
$end_condition = strtotime('last day of june this year 23:59:59', time());
|
||||
$this->tableDescription = __('The %d newest organisations created during the last half year', $limit);
|
||||
} else if (!empty($options['second_half_year'])) {
|
||||
$condition = strtotime('first day of july this year 00:00:00', time());
|
||||
$end_condition = strtotime('last day of december this year 23:59:59', time());
|
||||
$this->tableDescription = __('The %d newest organisations created during the current half year', $limit);
|
||||
} else {
|
||||
$this->tableDescription = __('The %d newest organisations created', $limit);
|
||||
return null;
|
||||
|
@ -142,7 +152,7 @@ class NewOrgsWidget
|
|||
}
|
||||
$timeConditions = $this->timeConditions($options);
|
||||
if ($timeConditions) {
|
||||
$params['conditions']['AND'][] = ['Organisation.date_created >=' => $timeConditions];
|
||||
$params['conditions']['AND'][]['AND'] = $timeConditions;
|
||||
}
|
||||
if (isset($options['fields'])) {
|
||||
$fields = [];
|
||||
|
|
|
@ -11,6 +11,8 @@ class OrgContributionToplistWidget
|
|||
'month' => 'Who contributed most this month? (boolean)',
|
||||
'previous_month' => 'Who contributed most the previous, finished month? (boolean)',
|
||||
'year' => 'Which contributed most this year? (boolean)',
|
||||
'first_half_year' => 'Which contributed most the first half-year (between Jan and June)? (boolean)',
|
||||
'second_half_year' => 'Which contributed most the second half-year (between July and Dec)? (boolean)',
|
||||
'filter' => 'A list of filters by organisation meta information (nationality, sector, type, name, uuid, local (- expects a boolean or a list of boolean values)) to include. (dictionary, prepending values with ! uses them as a negation)',
|
||||
'limit' => 'Limits the number of displayed tags. Default: 10'
|
||||
];
|
||||
|
@ -37,7 +39,6 @@ class OrgContributionToplistWidget
|
|||
|
||||
private function timeConditions($options)
|
||||
{
|
||||
$limit = empty($options['limit']) ? 10 : $options['limit'];
|
||||
if (!empty($options['days'])) {
|
||||
$condition = strtotime(sprintf("-%s days", $options['days']));
|
||||
} else if (!empty($options['month'])) {
|
||||
|
@ -47,6 +48,12 @@ class OrgContributionToplistWidget
|
|||
$end_condition = strtotime('last day of last month 23:59:59', time());
|
||||
} else if (!empty($options['year'])) {
|
||||
$condition = strtotime('first day of this year 00:00:00', time());
|
||||
} else if (!empty($options['last_half_year'])) {
|
||||
$condition = strtotime('first day of january this year 00:00:00', time());
|
||||
$end_condition = strtotime('last day of june this year 23:59:59', time());
|
||||
} else if (!empty($options['current_half'])) {
|
||||
$condition = strtotime('first day of july this year 00:00:00', time());
|
||||
$end_condition = strtotime('last day of december this year 23:59:59', time());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue