Commit 553bf781 authored by sylvieg's avatar sylvieg

[MOD]fgal: admin can watch fgal quota excceeded

parent 22377b47
......@@ -3475,6 +3475,7 @@ templates/mail/confirm_user_email.tpl -text
templates/mail/confirm_user_email_after_approval.tpl -text
templates/mail/confirm_user_email_after_approval_subject.tpl -text
templates/mail/confirm_user_email_subject.tpl -text
templates/mail/fgal_quota_exceeded.tpl -text
templates/mail/forum_outbound.tpl -text
templates/mail/forum_post_notification.tpl -text
templates/mail/index.php -text
......
......@@ -1038,24 +1038,47 @@ class FileGalLib extends TikiLib {
}
// check a size in K can be added to a gallery
function checkQuota($size, $galleryId, &$error) {
global $prefs;
global $prefs, $smarty;
if (!empty($prefs['fgal_quota'])) {
$use = $this->getUsedSize();
if ($use + $size > $prefs['fgal_quota']*1024*1024) {
$error = tra('The global quota has been reached');
return false;
$diff = $use + $size - $prefs['fgal_quota']*1024*1024;
}
}
if ($prefs['fgal_quota_per_fgal'] == 'y') {
if (empty($error) && $prefs['fgal_quota_per_fgal'] == 'y') {
$list = $this->getGalleryParentsColumns($galleryId, array('galleryId', 'quota', 'size', 'name'));
//echo '<pre>';print_r($list);echo '</pre>';
foreach ($list as $fgal) {
if (!empty($fgal['quota']) && $fgal['size'] + $size > $fgal['quota']*1024*1024) {
$error = tra('The quota has been reached in:').' '.$fgal['name'];
return false;
$smarty->assign('mail_fgal', $fgal);
$diff = $fgal['size'] + $size - $fgal['quota']*1024*1024;
break;
}
}
}
if (!empty($error)) {
global $tikilib;
$nots = $tikilib->get_event_watches('fgal_quota_exceeded', '*');
if (!empty($nots)) {
include_once ('lib/webmail/tikimaillib.php');
$mail = new TikiMail();
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $tikilib->httpPrefix() . dirname( $foo["path"] );
$machine = preg_replace("!/$!", "", $machine); // just incase
$smarty->assign('mail_machine', $machine);
$smarty->assign('mail_diff', $diff);
foreach ($nots as $not) {
$lg = $tikilib->get_user_preference($not['user'], 'language', $prefs['site_language']);
$mail->setSubject(tra('File gallery quota exceeded', $lg));
$mail->setText($smarty->fetchLang($lg, 'mail/fgal_quota_exceeded.tpl'));
$mail->buildMessage();
$mail->send(array($not['email']));
}
}
return false;
}
return true;
}
}
......
......@@ -400,7 +400,6 @@ class TikiLib extends TikiDb_Bridge {
left join `tiki_user_preferences` tup2 on (tup2.`user`=uu.`login` and tup2.`prefName`='mailCharset')
where $mid
";
$result = $this->query($query,array_merge( $bindvars, $bindvars ));
if ($result->numRows()) {
......@@ -454,9 +453,13 @@ class TikiLib extends TikiDb_Bridge {
$res['perm'] = $this->user_has_perm_on_object($res['user'],$object,'image gallery','tiki_p_view_image_gallery');
break;
case 'category_changed':
global $categlib;
global $categlib; include_once ('lib/categories/categlib.php');
$res['perm']= $categlib->has_view_permission($res['user'],$object);
break;
break;
case 'fgal_quota_exceeded':
global $tiki_p_admin_file_galleries;
$res['perm'] = ($tiki_p_admin_file_galleries == 'y');
break;
default:
// for security we deny all others.
$res['perm']=FALSE;
......
{tr}File gallery quota exceeded{/tr}
{if !empty($mail_fgal)}{tr}File gallery:{/tr} <a href="{$mail_machine_raw}/tiki-list_file_gallery.php?galleryId={$mail_fgal.galleryId}">{$mail_fgal.name|escape}</a>
{tr}Quota:{/tr} ($mail_fgal.quota} {tr}Mb{/tr}{/if}
{tr}User:{/tr} {$user|escape}
{tr}Size:{/tr} {$mail_diff|kbsize|replace:'&nbsp;':' '}
......@@ -22,14 +22,9 @@
<td class="formcolor"><label for="event">{tr}Event{/tr}:</label></td>
<td class="formcolor">
<select id="event" name="event">
<option value="user_registers">{tr}A user registers{/tr}</option>
<option value="article_submitted">{tr}A user submits an article{/tr}</option>
<option value="article_edited">{tr}A user edits an article{/tr}</option>
<option value="article_deleted">{tr}A user deletes an article{/tr}</option>
<option value="wiki_page_changes">{tr}Any wiki page is changed{/tr}</option>
<option value="wiki_page_changes_incl_minor">{tr}Any wiki page is changed, even minor changes{/tr}</option>
<option value="wiki_comment_changes">{tr}A comment in a wiki page is posted or edited{/tr}</option>
<option value="php_error">{tr}PHP error{/tr}</option>
{foreach from=$watches key=key item=watch}
<option value="{$key}">{$watch.label|escape}</option>
{/foreach}
</select>
</td>
</tr>
......
......@@ -89,6 +89,12 @@ $watches['php_error'] = array(
'url' => '',
'object' => '*'
);
$watches['fgal_quota_exceeded'] = array(
'label' => tra('File gallery quota exceeded') ,
'type' => 'file gallery',
'url' => '',
'object' => '*'
);
$save = true;
$login = $email = '';
if (isset($_REQUEST["add"])) {
......@@ -167,6 +173,7 @@ $smarty->assign_by_ref('find', $find);
if (!empty($_REQUEST['maxRecords'])) {
$maxRecords = $_REQUEST['maxRecords'];
}
$smarty->assign_by_ref('watches', $watches);
$smarty->assign_by_ref('maxRecords', $maxRecords);
$smarty->assign_by_ref('sort_mode', $sort_mode);
$channels = $tikilib->list_watches($offset, $maxRecords, $sort_mode, $find);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment