Commit 97f7c46b authored by lindonb's avatar lindonb

[REF] Revamp feedback method to centralize and standardize coding...

[REF] Revamp feedback method to centralize and standardize coding (continuation of r58746). This commit replaces some usages of the $errors Smarty variable with Feedback functions.
parent 96ce8a03
......@@ -59,10 +59,10 @@ if (!empty($_REQUEST['move'])) {
$errors = $filegallib->moveFiles($_REQUEST['move'], $feedbacks);
}
if (!empty($errors)) {
$smarty->assign_by_ref('errors', $errors);
Feedback::error(['mes' => $errors]);
}
if (!empty($feedbacks)) {
$smarty->assign_by_ref('feedbacks', $feedbacks);
Feedback::note(['mes' => $feedbacks]);
}
}
......
......@@ -62,7 +62,7 @@ if (!empty($_REQUEST['testMail']) && key_check(null, false)) {
$mailerrors = print_r($mail->errors, true);
$msg .= '<br>' . $mailerrors;
}
$smarty->assign('error_msg', $msg);
Feedback::warning($msg);
} else {
add_feedback('testMail', tra('Test mail sent to') . ' ' . $_REQUEST['testMail'], 3);
}
......
......@@ -31,10 +31,15 @@ if (!empty($_REQUEST['moveWikiUp'])) {
$errorsWikiUp[] = tra('You must set a home file gallery');
} else {
$filegallib->moveAllWikiUpToFgal($prefs['home_file_gallery'], $errorsWikiUp, $feedbacksWikiUp);
$smarty->assign_by_ref('feedbacksWikiUp', $feedbacksWikiUp);
$smarty->assign_by_ref('moveWikiUp', $_REQUEST['moveWikiUp']);
}
$smarty->assign_by_ref('errorsWikiUp', $errorsWikiUp);
if (!empty($errorsWikiUp)) {
Feedback::error(['mes' => $errorsWikiUp]);
}
if (!empty($feedbacksWikiUp)) {
Feedback::success(['mes' => $feedbacksWikiUp, 'title' => tr('The following pages were modified')]);
} else {
Feedback::note(tr('Nothing was changed (no images in wiki_up were found in Wiki pages).'));
}
}
// Included for the forum dropdown
......
......@@ -467,7 +467,6 @@ class TikiWebdav_Backends_Wiki extends ezcWebdavSimpleBackend
print_debug('getCollectionMembers ' . $path . "\n");
$contents = array();
$errors = array();
if ($path !== '/') {
return $contents;
......
......@@ -3588,8 +3588,7 @@ class FileGalLib extends TikiLib
die;
}
}
$smarty->assign('errors', $errors);
Feedback::error(['mes' => $errors]);
$smarty->assign('uploads', $uploads);
if (!empty($params['returnUrl'])) {
......
......@@ -13,23 +13,23 @@ if ( isset($_REQUEST['pollVote']) && !empty($_REQUEST['polls_pollId']) ) {
$voted = false;
if (empty($_REQUEST['polls_optionId'])) {
$ok = false;
$smarty->assign('msg_poll', tra('You must choose an option'));
$error = tra('You must choose an option');
} elseif ( $tiki_p_vote_poll == 'y' && ($prefs['feature_poll_anonymous'] == 'y' || $user || $prefs['feature_antibot'] == 'y')) {
$captchalib = TikiLib::lib('captcha');
if (empty($user) && empty($_COOKIE)) {
$ok = false;
$smarty->assign('msg_poll', tra('For you to vote, cookies must be allowed'));
$error = tra('For you to vote, cookies must be allowed');
$smarty->assign_by_ref('polls_optionId', $_REQUEST['polls_optionId']);
} elseif (($prefs['feature_antibot'] == 'y' && empty($user)) && (!$captchalib->validate())) {
$ok = false;
$smarty->assign('msg_poll', $captchalib->getErrors());
$errors = $captchalib->getErrors();
$smarty->assign_by_ref('polls_optionId', $_REQUEST['polls_optionId']);
} else {
$polllib = TikiLib::lib('poll');
$poll = $polllib->get_poll($_REQUEST['polls_pollId']);
if ( empty($poll) || $poll['active'] == 'x' ) {
$ok = false;
$smarty->assign('msg_poll', tra('This poll is closed.'));
$error = tra('This poll is closed.');
$smarty->assign_by_ref('polls_optionId', $_REQUEST['polls_optionId']);
} else {
$previous_vote = $polllib->get_user_vote('poll' . $_REQUEST['polls_pollId'], $user);
......@@ -39,6 +39,9 @@ if ( isset($_REQUEST['pollVote']) && !empty($_REQUEST['polls_pollId']) ) {
}
}
}
if (!empty($error)) {
Feedback::error($error);
}
if ( $ok && ! isset($_REQUEST['wikipoll']) && $tiki_p_view_poll_results == 'y' && empty($_REQUEST['showresult'])) {
header('location: tiki-poll_results.php?pollId='.$_REQUEST['polls_pollId']);
die;
......
......@@ -549,7 +549,7 @@ class SurveyLib extends TikiLib
if (count($errors) > 0) {
if ($error_msg !== null) {
$error_msg = implode('<br />', $errors);
$error_msg = $errors;
}
return false;
} else {
......
......@@ -119,7 +119,7 @@ function wikiplugin_invite( $data, $params)
return $data;
} else {
$smarty->assign_by_ref('errors', $errors);
Feedback::error(['mes' => $errors]);
$smarty->assign_by_ref('email', $_REQUEST['email']);
if (!empty($_REQUEST['groups'])) $smarty->assign_by_ref('groups', $_REQUEST['groups']);
if (!empty($_REQUEST['message'])) $smarty->assign_by_ref('message', $_REQUEST['message']);
......
......@@ -232,7 +232,9 @@ function wikiplugin_mail($data, $params)
}
unset($_SESSION['wikiplugin_mail_to']);
}
$smarty->assign_by_ref('mail_error', $mail_error);
if ($mail_error) {
Feedback::error(tr('Mail send was unsuccessful.'));
}
if ($preview || $mail_error) {
$smarty->assign('mail_user', isset($_REQUEST['mail_user'])? $_REQUEST['mail_user']:'');
$smarty->assign('mail_user_dd', isset($_REQUEST['mail_user_dd'])? $_REQUEST['mail_user_dd']:array());
......
......@@ -202,6 +202,6 @@ function module_domain_password($mod_reference, $module_params)
}
}
if (!empty($errors[$cntModule])) {
$smarty->assign('errors', $errors);
Feedback::error(['mes' => $errors[$cntModule]]);
}
}
{* $Id$ *}
{if !empty($errors)}
{remarksbox type="errors" title="{tr}Errors{/tr}"}
{foreach from=$errors item=error}
{$error|escape}
<br>
{/foreach}
{/remarksbox}
{/if}
{if !empty($feedbacks)}
{remarksbox type="note" title="{tr}Feedback{/tr}"}
{foreach from=$feedbacks item=feedback}
{$feedback|escape}
<br>
{/foreach}
{/remarksbox}
{/if}
{remarksbox type="tip" title="{tr}Tip{/tr}"}
{tr}To create or remove file galleries, select{/tr} <a class="rbox-link" href="tiki-list_file_gallery.php">{tr}File Galleries{/tr}</a> {tr}from the application menu{/tr}.
<hr>
......
......@@ -11,11 +11,6 @@
<input type="submit" class="btn btn-primary btn-sm tips" title=":{tr}Apply Changes{/tr}" value="{tr}Apply{/tr}" />
</div>
</div>
{if !empty($error_msg)}
{remarksbox type='warning' title="{tr}Warning{/tr}" icon='error'}
{$error_msg}
{/remarksbox}
{/if}
{tabset name="admin_general"}
{tab name="{tr}General Preferences{/tr}"}
<h2>{tr}General Preferences{/tr}</h2>
......
{* $Id$ *}
{if !empty($feedbacksWikiUp) || !empty($moveWikiUp)}
{remarksbox type="feedback" title="{tr}Feedback{/tr}"}
{if !empty($feedbacksWikiUp)}
{tr}The following pages were modified:{/tr}
<ul>
{foreach from=$feedbacksWikiUp item=f}
<li>{$f|escape}</li>
{/foreach}
</ul>
{else}
{tr}Nothing was changed (no images in wiki_up were found in Wiki pages).{/tr}
{/if}
{/remarksbox}
{elseif !empty($moveWikiUp)}
{/if}
{if !empty($errorsWikiUp)}
{remarksbox type="errors" title="{tr}Errors{/tr}"}
<ul>
{foreach from=$errorsWikiUp item=f}
<li>{$f|escape}</li>
{/foreach}
</ul>
{/remarksbox}
{/if}
{remarksbox type="tip" title="{tr}Tip{/tr}"}
{tr}Use the 'Quick Edit' module to easily create or edit wiki pages.{/tr} <a class="btn btn-default" href="tiki-admin_modules.php">{icon name="module"} {tr}Modules{/tr}</a>
{/remarksbox}
......
......@@ -22,17 +22,6 @@
<td class="pwddom_domain_name">{$domain}</td>
{/if}
</tr>
{if !empty($errors[{$dompwdCount}])}
<tr>
<td colspan="2">
<span id="error" class="alert-warning">
{foreach from=$errors[{$dompwdCount}] item=error}
{$error|escape}<br>
{/foreach}
</span>
</td>
</tr>
{/if}
{if !empty($user)}
<tr>
<td>{tr}User{/tr}</td>
......
......@@ -33,37 +33,6 @@
{if $prefs.feature_intertiki_import_preferences eq 'y'}{tr}Since this Tiki site is in slave mode and imports preferences, the master user preferences will be automatically reimported at each login{/tr}{/if}
{/remarksbox}
{/if}
{if !empty($added) or !empty($discarded) or !empty($discardlist)}
{remarksbox type="information" title="{tr}Batch Upload Results{/tr}"}
{tr}Updated users{/tr} {$added}
{if $discarded != ""}- {tr}Rejected users{/tr} {$discarded}{/if}
<br>
<br>
{if $discardlist != ''}
<div class="table-responsive">
<table class="table">
<tr>
<th>{tr}Username{/tr}</th>
<th>{tr}Reason{/tr}</th>
</tr>
{section name=reject loop=$discardlist}
<tr class="odd">
<td class="username">{$discardlist[reject].login}</td>
<td class="text">{$discardlist[reject].reason}</td>
</tr>
{/section}
</table>
</div>
{/if}
{if $batcherrors}
<br>
{section name=ix loop=$batcherrors}
{$batcherrors[ix]}<br>
{/section}
{/if}
{/remarksbox}
{/if}
{/if}
{tabset name='tabs_adminusers'}
......
......@@ -7,17 +7,6 @@
{icon name="structure"} {tr}Structures{/tr}
</a>
</div>
{if $error}
{remarksbox type='errors' title="{tr}Errors{/tr}"}
{$error}
{/remarksbox}
{/if}
{if $msg}
{remarksbox type='feedback' title="{tr}Feedback{/tr}"}
{$msg}
{/remarksbox}
{/if}
<form class="form-horizontal" enctype='multipart/form-data' method="post">
<div class="form-group">
<div class="col-sm-12">
......
{if !empty($msg_poll)}
{remarksbox type="errors"}
{$msg_poll}
{/remarksbox}
{/if}
{if $showtitle ne 'n'}{$menu_info.title|escape}<br>{/if}
<form method="post" action="{$ownurl}">
<input type="hidden" name="polls_pollId" value="{$menu_info.pollId|escape}">
......
......@@ -2,15 +2,6 @@
{title help="Communication Center"}{tr}Received Pages{/tr}{/title}
{if !empty($errors)}
<div class="alert alert-warning">
{foreach item=error from=$errors}
{tr}{$error.error}{/tr} {$error.param}
<br>
{/foreach}
</div>
{/if}
{if $receivedPageId > 0 or $view eq 'y'}
<h2>{tr}Preview{/tr}</h2>
<div class="wikitext">{$parsed}</div>
......
......@@ -19,12 +19,6 @@
</div>
{/if}
{if $upload_err_msg neq ''}
{remarksbox type='warning' title="{tr}Warning{/tr}" icon='error'}
{$upload_err_msg}
{/remarksbox}
{/if}
{if $mailto_link}
{remarksbox type=info title="External Client"}
{tr}You can also send newsletters using an external client:{/tr}
......@@ -40,7 +34,7 @@
{if $errors}
{remarksbox type='warning' title="{tr}Errors{/tr}" icon='error'}
<div class="table-responsive">
<table class="table">
<table class="table table-striped table-hover">
<tr>
<th>{tr}User{/tr}</th>
<th>{tr}Email{/tr}</th>
......
......@@ -4,9 +4,6 @@
{if !isset($show_name) or $show_name eq 'y'}
{title url="tiki-take_survey.php?surveyId=$surveyId"}{$survey_info.name}{/title}
{/if}
{if $error_msg neq ''}
{remarksbox type="warning" title="{tr}Warning{/tr}"}{$error_msg}{/remarksbox}
{/if}
<div class="surveyquestions">
<div class="description help-block questionblock page0">{wiki}{$survey_info.description}{/wiki}</div>
{$pageCount=0}
......
......@@ -31,10 +31,6 @@
</tr>
</table>
{if !empty($conmsg)}
{remarksbox type='warning' title="{tr}Error{/tr}"}{$conmsg}{/remarksbox}
{/if}
<hr/>
{if $locSection eq 'settings'}
......
{* $Id$ *}
{if $errors}
{remarksbox type="feedback"}
{foreach from=$errors item=error}
{$error|escape}<br>
{/foreach}
{/remarksbox}
{/if}
<form method="post">
<div class="table-responsive">
<table class="table invite">
......
......@@ -9,11 +9,6 @@
</ul>
{/remarksbox}
{/if}
{if !empty($mail_error)}
{remarksbox type='errors' title="{tr}Errors{/tr}"}
{tr}Error{/tr}
{/remarksbox}
{/if}
{if $preview}
<form method="post" class="margin-bottom-md">
<h3>{tr}Message preview:{/tr}</h3>
......
......@@ -221,16 +221,18 @@ function batchImportUsers()
}
$added++;
}
$smarty->assign('added', $added);
Feedback::success(tr('Users added:') . ' ' . $added);
if (count($discarded)) {
$smarty->assign('discarded', count($discarded));
$smarty->assign_by_ref('discardlist', $discarded);
foreach ($discarded as $key => $value) {
$df[] = $discarded[$key]['login'] . ' (' . $discarded[$key]['reason'] . ')';
}
Feedback::warning(['mes' => $df, 'title' => tr('%0 users not added', count($discarded))]);
}
if (count($errors)) {
array_unique($errors);
$smarty->assign_by_ref('batcherrors', $errors);
Feedback::error(['mes' => $errors]);
}
}
......
......@@ -22,7 +22,7 @@ if (isset($_REQUEST['import'])) {
} elseif (is_uploaded_file($_FILES['zip']['tmp_name'])) {
$zipFile = $_FILES['zip']['tmp_name'];
} else {
$smarty->assign('error', tra('Error'));
$error = tra('Unable to locate import file.');
$zipFile = '';
}
if ($zipFile) {
......@@ -30,11 +30,18 @@ if (isset($_REQUEST['import'])) {
$xmllib = new XmlLib;
$config = array();
if ($xmllib->import_pages($zipFile, $config)) {
$smarty->assign('msg', tra('Operations executed successfully'));
$success = tra('Operations executed successfully');
} else {
$smarty->assign('error', $xmllib->get_error());
$error = $xmllib->get_error();
}
}
if (isset($success)) {
Feedback::success(['mes' => $success]);
}
if (isset($error)) {
Feedback::error(['mes' => $error]);
}
}
ask_ticket('import_xml_zip');
$smarty->assign('mid', 'tiki-import_xml_zip.tpl');
......
......@@ -170,7 +170,7 @@ if (!empty($_REQUEST['submit_mult']) && isset($_REQUEST['checked'])) {
die;
}
} else {
$smarty->assign('error', $xmllib->get_error());
Feedback::error(['mes' => $xmllib->get_error()]);
}
}
break;
......
......@@ -21,7 +21,7 @@ if (isset($_REQUEST["accept"])) {
// CODE TO ACCEPT A PAGE HERE
if (!$commlib->accept_page($_REQUEST["accept"])) {
$info = $commlib->get_received_page($_REQUEST['accept']);
$errors[] = array('error' => 'Page already exists');
$errors[] = tr('Page already exists');
}
}
if ($_REQUEST["receivedPageId"]) {
......@@ -65,7 +65,7 @@ if (!empty($_REQUEST['checked']) && (!empty($_REQUEST['prefix']) || !empty($_REQ
foreach ($_REQUEST['checked'] as $page) {
$newpage = empty($_REQUEST['postfix']) ? $_REQUEST['prefix'] . $page : $page . $_REQUEST['postfix'];
if ($tikilib->page_exists($newpage)) {
$errors[] = array('error' => 'Page already exists', 'param' => $page);
$errors[] = tr('Page already exists') . ' ' . $page;
}
}
if (empty($errors)) {
......
......@@ -217,7 +217,11 @@ if (!empty($_FILES) && !empty($_FILES['newsletterfile'])) {
'savestate' => 'phptmp',
);
} else {
$smarty->assign('upload_err_msg', tra('A problem occurred during file uploading') . '<br />' . tra('File which was causing trouble was at rank') . '&nbsp;' . ($i + 1) . '<br />' . tra('The error was:') . '&nbsp;<strong>' . $tikilib->uploaded_file_error($_FILES['newsletterfile']['error'][$i]) . '</strong>');
$error['title'] = tra('A problem occurred during file uploading');
$error['mes'] = tra('File causing trouble was at rank') . ' ' . ($i + 1);
$error['mes'] = tr('The error was %0',
$tikilib->uploaded_file_error($_FILES['newsletterfile']['error'][$i]));
Feedback::error($error);
}
}
}
......
......@@ -141,6 +141,6 @@ $smarty->assign('showToolBars', $showToolBars);
include_once ('tiki-section_options.php');
ask_ticket('take-survey');
// Display the template
$smarty->assign('error_msg', $error_msg);
Feedback::error(['mes' => $error_msg]);
$smarty->assign('mid', 'tiki-take_survey.tpl');
$smarty->display("tiki.tpl");
......@@ -169,8 +169,12 @@ if (isset($_REQUEST['comments_postComment'])) {
$cat_objid = $threadId;
include_once ('freetag_apply.php');
}
$smarty->assign_by_ref('errors', $errors);
$smarty->assign_by_ref('feedbacks', $feedbacks);
if (!empty($errors)) {
Feedback::error(['mes' => $errors]);
}
if (!empty($feedbacks)) {
Feedback::success(['mes' => $feedbacks]);
}
}
// Here we send the user to the right thread/topic if it already exists; this
......
......@@ -113,7 +113,7 @@ if ($_REQUEST['locSection'] == 'read') {
$mail = $webmaillib->get_mail_storage($current);
} catch (Exception $e) {
// do something better with the error
$smarty->assign('conmsg', tra('There was a problem connecting to that account.').'<br />'.$e->getMessage());
Feedback::error(tra('There was a problem connecting to that account:') . ' ' . $e->getMessage());
}
if (isset($_REQUEST['delete_one'])) {
......@@ -124,7 +124,7 @@ if ($_REQUEST['locSection'] == 'read') {
$webmaillib->remove_webmail_message($current['accountId'], $user, $aux['realmsgid']);
unset($_REQUEST['msgid']);
} catch (Exception $e) {
$smarty->assign('conmsg', tra('There was a problem deleting that email message.').'<br />'.$e->getMessage());
Feedback::error(tra('There was a problem deleting that email message:') . ' ' . $e->getMessage());
}
}
......@@ -326,8 +326,8 @@ END;
$webmail_list = $webmaillib->refresh_mailbox($user, $current['accountId'], $webmail_reload);
} catch (Exception $e) {
$err = $e->getMessage();
$urlq = http_build_query(array('locSection'=>'settings', 'conmsg'=>$err), '', '&');
Feedback::error(['mes' => $e->getMessage()], 'session');
$urlq = http_build_query(array('locSection'=>'settings'), '', '&');
handleWebmailRedirect($urlq);
}
......@@ -336,7 +336,7 @@ END;
$mail = $webmaillib->get_mail_storage($current);
} catch (Exception $e) {
// do something better with the error
$smarty->assign('conmsg', tra('There was a problem connecting to that account.').'<br />'.$e->getMessage());
Feedback::error(tra('There was a problem connecting to that account:') . ' ' . $e->getMessage());
}
// The user just clicked on one of the flags, so set up for flag change
......@@ -369,7 +369,7 @@ END;
}
}
if (!empty($err)) {
$smarty->assign('conmsg', tra('There was a problem while trying to delete these email messages.').'<br />'.$err);
Feedback::error(tra('There was a problem while trying to delete these email messages:') . ' ' . $err);
}
}
}
......@@ -381,7 +381,8 @@ END;
try {
$mail->removeMessage($_REQUEST['msgdel']);
} catch (Exception $e) {
$smarty->assign('conmsg', tra('TThere was a problem while trying to delete this email message.').'<br />'.$e->getMessage());
Feedback::error(tra('There was a problem while trying to delete this email message:') . ' '
. $e->getMessage());
}
}
......@@ -391,9 +392,8 @@ END;
try {
$webmail_list = $webmaillib->refresh_mailbox($user, $current['accountId'], true); // really need a smarter way of caching the whole mailbox...
} catch (Exception $e) {
$err = $e->getMessage();
$urlq = http_build_query(array('locSection'=>'settings', 'conmsg'=>$err), '', '&');
Feedback::error(['mes' => $e->getMessage()], 'session');
$urlq = http_build_query(array('locSection'=>'settings'), '', '&');
handleWebmailRedirect($urlq);
}
......@@ -590,12 +590,7 @@ END;
$headerlib->add_jq_onready($js);
}
$headerlib->add_js('if (webmailTimeoutId) {window.clearTimeout(webmailTimeoutId);}', 0);
if (isset($_REQUEST['conmsg'])) {
check_ticket('webmail');
$smarty->assign('conmsg', $_REQUEST['conmsg']);
}
if (isset($_REQUEST['cancel_acc'])) {
check_ticket('webmail');
unset($_REQUEST['cancel_acc']);
......
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