Skip to content

Commit 2d17576

Browse files
committed
Merge pull request #1369 from tevin-otieno/max-upload
Admin can change max size for reports
2 parents b76450d + 16b3720 commit 2d17576

File tree

6 files changed

+21
-2
lines changed

6 files changed

+21
-2
lines changed

application/controllers/admin/settings.php

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function site()
6363
'allow_alerts' => '',
6464
'allow_reports' => '',
6565
'allow_comments' => '',
66+
'max_upload_size' => '',
6667
'allow_feed' => '',
6768
'allow_feed_category' => '',
6869
'feed_geolocation_user' => '',
@@ -108,6 +109,7 @@ public function site()
108109
$post->add_rules('blocks_per_row','required','numeric');
109110
$post->add_rules('allow_alerts','required','between[0,1]');
110111
$post->add_rules('allow_reports','required','between[0,1]');
112+
$post->add_rules('max_upload_size','length[0,50]', 'alpha_numeric');
111113
$post->add_rules('allow_comments','required','between[0,2]');
112114
$post->add_rules('allow_feed','required','between[0,1]');
113115
$post->add_rules('allow_feed_category','required','between[0,1]');
@@ -264,6 +266,7 @@ public function site()
264266
'allow_alerts' => $settings['allow_alerts'],
265267
'allow_reports' => $settings['allow_reports'],
266268
'allow_comments' => $settings['allow_comments'],
269+
'max_upload_size' => $settings['max_upload_size'],
267270
'allow_feed' => $settings['allow_feed'],
268271
'allow_feed_category' => $settings['allow_feed_category'],
269272
'feed_geolocation_user' => isset($settings['feed_geolocation_user']) ? $settings['feed_geolocation_user'] : null,

application/helpers/reports.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public static function validate(array & $post)
110110
}
111111

112112
// Validate photo uploads
113-
$post->add_rules('incident_photo', 'upload::valid', 'upload::type[gif,jpg,png,jpeg]', 'upload::size[2M]');
113+
$max_upload_size = Kohana::config('settings.max_upload_size');
114+
$post->add_rules('incident_photo', 'upload::valid', 'upload::type[gif,jpg,png,jpeg]', "upload::size[".$max_upload_size."M]");
114115

115116

116117
// Validate Personal Information

application/views/admin/settings/site.php

+7
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@
134134
<span class="sel-holder">
135135
<?php print form::dropdown('allow_reports', $yesno_array, $form['allow_reports']); ?>
136136
</span>
137+
</div>
138+
<!--Adding max file upload setting-->
139+
<div class="row">
140+
<h4><a href="#" class="tooltip" title="<?php echo Kohana::lang("tooltips.settings_max_upload_size"); ?>"><?php echo Kohana::lang('settings.site.max_upload_size');?></a></h4>
141+
<span class="sel-holder">
142+
<?php print form::input('max_upload_size', $form['max_upload_size'], ' class="text long2"', 'id = max_upload_size'); ?>
143+
</span>
137144
</div>
138145
<div class="row">
139146
<h4><a href="#" class="tooltip" title="<?php echo Kohana::lang("tooltips.settings_allow_alerts"); ?>"><?php echo Kohana::lang('settings.site.allow_alerts');?></a></h4>

sql/upgrade117-118.sql

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Add max_upload_size as a setting
2+
INSERT into settings(`key`, `value`) values('max_upload_size', '10');
3+
4+
-- UPDATE db_version
5+
UPDATE `settings` SET `value` = 118 WHERE `key` = 'db_version';

sql/ushahidi.sql

+3-1
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,9 @@ VALUES
14011401
(63,'manually_approve_users','0'),
14021402
(64,'enable_timeline','0'),
14031403
(65,'feed_geolocation_user', ''),
1404-
(66,'allow_feed_category', '0');
1404+
(66,'allow_feed_category', '0'),
1405+
(67, 'max_upload_size', '10');
1406+
14051407
-- --------------------------------------------------------
14061408

14071409
/**

themes/default/views/reports/submit.php

+1
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@
293293
<!-- Photo Fields -->
294294
<div id="divPhoto" class="report_row">
295295
<h4><?php echo Kohana::lang('ui_main.reports_photos'); ?></h4>
296+
<span class="allowed-html"><?php echo Kohana::lang('ui_main.maximum_filesize'),": ", Kohana::config('settings.max_upload_size'), "Mb"; ?></span>
296297
<?php
297298
// Initialize the counter
298299
$i = (empty($form['incident_photo']['name'][0])) ? 1 : 0;

0 commit comments

Comments
 (0)