From 52c1db83fd065be55c58c1a470351e264cb62e11 Mon Sep 17 00:00:00 2001
From: Michael <Chefkeks@users.noreply.github.com>
Date: Mon, 9 May 2016 16:55:45 +0200
Subject: [PATCH] Updated several files to split up phrases like "Your lock has
 expired. Please try again!" into "Your lock has expiredx" and "Please try
 again!"

---
 include/ajax.orgs.php    |  8 ++++----
 include/ajax.tasks.php   |  2 +-
 include/ajax.tickets.php |  2 +-
 include/ajax.users.php   |  6 +++---
 include/class.canned.php |  2 +-
 include/class.page.php   |  2 +-
 login.php                |  4 ++--
 open.php                 |  2 +-
 scp/banlist.php          |  2 +-
 scp/emailtest.php        |  4 ++--
 scp/tickets.php          | 29 +++++++++++++++--------------
 scp/users.php            |  4 ++--
 12 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/include/ajax.orgs.php b/include/ajax.orgs.php
index 273fc0bd4..f6dde6277 100644
--- a/include/ajax.orgs.php
+++ b/include/ajax.orgs.php
@@ -123,7 +123,7 @@ class OrgsAjaxAPI extends AjaxController {
             if ($org->delete())
                  Http::response(204, 'Organization deleted successfully');
             else
-                $info['error'] = __('Unable to delete organization - try again!');
+                $info['error'] = sprintf('%s - %s', __('Unable to delete organization'), __('Try again!'));
         }
 
         include(STAFFINC_DIR . 'templates/org-delete.tmpl.php');
@@ -158,13 +158,13 @@ class OrgsAjaxAPI extends AjaxController {
                 $form = UserForm::getUserForm()->getForm($_POST);
                 $can_create = $thisstaff->hasPerm(User::PERM_CREATE);
                 if (!($user = User::fromForm($form, $can_create)))
-                    $info['error'] = __('Error adding user - try again!');
+                    $info['error'] = sprintf('%s - %s', __('Error adding user'), __('Try again!'));
             }
 
             if (!$info['error'] && $user && $user->setOrganization($org))
                 Http::response(201, $user->to_json());
             elseif (!$info['error'])
-                $info['error'] = __('Unable to add user to the organization - try again');
+                $info['error'] = sprintf('%s - %s', __('Unable to add user to the organization'), __('Try again!'));
 
         } elseif ($remote && $userId) {
             list($bk, $userId) = explode(':', $userId, 2);
@@ -232,7 +232,7 @@ class OrgsAjaxAPI extends AjaxController {
             if (($org = Organization::fromForm($form)))
                 Http::response(201, $org->to_json());
 
-            $info = array('error' =>__('Error adding organization - try again!'));
+            $info = array('error' =>sprintf('%s - %s', __('Error adding organization'), __('Try again!')));
         }
 
         $info['title'] = __('Add New Organization');
diff --git a/include/ajax.tasks.php b/include/ajax.tasks.php
index d9dfbd814..bc5e7e47d 100644
--- a/include/ajax.tasks.php
+++ b/include/ajax.tasks.php
@@ -90,7 +90,7 @@ class TasksAjaxAPI extends AjaxController {
                     Http::response(201, $task->getId());
             }
 
-            $info['error'] = __('Error adding task - try again!');
+            $info['error'] = sprintf('%s - %s', __('Error adding task'), __('Try again!'));
         }
 
         include STAFFINC_DIR . 'templates/task.tmpl.php';
diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php
index 3f3d26e46..eaf42ab8a 100644
--- a/include/ajax.tickets.php
+++ b/include/ajax.tickets.php
@@ -1222,7 +1222,7 @@ class TicketsAjaxAPI extends AjaxController {
                     Http::response(201, $task->getId());
             }
 
-            $info['error'] = __('Error adding task - try again!');
+            $info['error'] = sprintf('%s - %s', __('Error adding task'), __('Try again!'));
         }
 
         $info['action'] = sprintf('#tickets/%d/add-task', $ticket->getId());
diff --git a/include/ajax.users.php b/include/ajax.users.php
index bf85d0c57..8b57e27d1 100644
--- a/include/ajax.users.php
+++ b/include/ajax.users.php
@@ -193,7 +193,7 @@ class UsersAjaxAPI extends AjaxController {
             if ($errors['err'])
                 $info['error'] = $errors['err'];
             else
-                $info['error'] = __('Unable to register user - try again!');
+                $info['error'] = sprintf('%s - %s', __('Unable to register user'), __('Try again!'));
         }
 
         include(STAFFINC_DIR . 'templates/user-register.tmpl.php');
@@ -258,7 +258,7 @@ class UsersAjaxAPI extends AjaxController {
             if (!$info['error'] && $user->delete())
                  Http::response(204, 'User deleted successfully');
             elseif (!$info['error'])
-                $info['error'] = __('Unable to delete user - try again!');
+                $info['error'] = sprintf('%s - %s', __('Unable to delete user'), __('Try again!'));
         }
 
         include(STAFFINC_DIR . 'templates/user-delete.tmpl.php');
@@ -295,7 +295,7 @@ class UsersAjaxAPI extends AjaxController {
             if (($user = User::fromForm($form)))
                 Http::response(201, $user->to_json());
 
-            $info['error'] = __('Error adding user - try again!');
+            $info['error'] = sprintf('%s - %s', __('Error adding user'), __('Try again!'));
         }
 
         return self::_lookupform($form, $info);
diff --git a/include/class.canned.php b/include/class.canned.php
index bb126d740..8e8cafdd5 100644
--- a/include/class.canned.php
+++ b/include/class.canned.php
@@ -260,7 +260,7 @@ extends VerySimpleModel {
 
         $id = isset($this->canned_id) ? $this->canned_id : null;
         if ($id && $id != $vars['id'])
-            $errors['err']=__('Internal error. Try again');
+            $errors['err']=sprintf('%s - %s', __('Internal error'), __('Try again!'));
 
         if (!$vars['title'])
             $errors['title'] = __('Title required');
diff --git a/include/class.page.php b/include/class.page.php
index 920c2ee88..88648cd62 100644
--- a/include/class.page.php
+++ b/include/class.page.php
@@ -254,7 +254,7 @@ class Page extends VerySimpleModel {
         }
 
         if (isset($this->id) && $this->getId() != $vars['id'])
-            $errors['err'] = __('Internal error. Try again');
+            $errors['err'] = sprintf('%s - %s', __('Internal error'), __('Try again!'));
 
         if(!$vars['type'])
             $errors['type'] = __('Type is required');
diff --git a/login.php b/login.php
index 4c7f3b6c1..d1ef1abd6 100644
--- a/login.php
+++ b/login.php
@@ -70,7 +70,7 @@ if ($_POST && isset($_POST['luser'])) {
                 ?: 'tickets.php');
         }
     } elseif(!$errors['err']) {
-        $errors['err'] = __('Invalid username or password - try again!');
+        $errors['err'] = sprintf('%s - %s', __('Invalid username or password'), __('Try again!'));
     }
     $suggest_pwreset = true;
 }
@@ -95,7 +95,7 @@ elseif ($_POST && isset($_POST['lticket'])) {
             Format::htmlchars($user->getName()->getFirst()));
         $_POST = null;
     } elseif(!$errors['err']) {
-        $errors['err'] = __('Invalid email or ticket number - try again!');
+        $errors['err'] = sprintf('%s - %s', __('Invalid email or ticket number'), __('Try again!'));
     }
 }
 elseif (isset($_GET['do'])) {
diff --git a/open.php b/open.php
index 7cf09ec11..d6a862a6b 100644
--- a/open.php
+++ b/open.php
@@ -26,7 +26,7 @@ if ($_POST) {
         if(!$_POST['captcha'])
             $errors['captcha']=__('Enter text shown on the image');
         elseif(strcmp($_SESSION['captcha'], md5(strtoupper($_POST['captcha']))))
-            $errors['captcha']=__('Invalid - try again!');
+            $errors['captcha']=sprintf('%s - %s', __('Invalid'), __('Try again!'));
     }
 
     $tform = TicketForm::objects()->one()->getForm($vars);
diff --git a/scp/banlist.php b/scp/banlist.php
index 8667b2e74..9356bbd18 100644
--- a/scp/banlist.php
+++ b/scp/banlist.php
@@ -63,7 +63,7 @@ if($_POST && !$errors && $filter){
                 $_REQUEST['a']=null;
                 //Add filter rule here.
             }elseif(!$errors['err']){
-                $errors['err']=sprintf(__('Error creating %s. Try again!'), __('ban rule'));
+                $errors['err']=sprintf('%s %s', __('Error creating %s.'), __('ban rule'), __('Try again!'));
             }
             break;
         case 'mass_process':
diff --git a/scp/emailtest.php b/scp/emailtest.php
index 5bd65e319..189d22312 100644
--- a/scp/emailtest.php
+++ b/scp/emailtest.php
@@ -43,9 +43,9 @@ if($_POST){
             Draft::deleteForNamespace('email.diag');
         }
         else
-            $errors['err']=__('Error sending email - try again.');
+            $errors['err']=sprintf('%s - %s', __('Error sending email'), __('Try again!'));
     }elseif($errors['err']){
-        $errors['err']=__('Error sending email - try again.');
+        $errors['err']=sprintf('%s - %s', __('Error sending email'), __('Try again!'));
     }
 }
 $nav->setTabActive('emails');
diff --git a/scp/tickets.php b/scp/tickets.php
index 7e8f027dc..0ad162b29 100644
--- a/scp/tickets.php
+++ b/scp/tickets.php
@@ -92,7 +92,7 @@ if($_POST && !$errors):
 
                 if ($cfg->getLockTime()) {
                     if (!$lock) {
-                        $errors['err'] = __('This action requires a lock. Please try again');
+                        $errors['err'] = sprintf('%s %s', __('This action requires a lock.'), __('Please try again!'));
                     }
                     // Use locks to avoid double replies
                     elseif ($lock->getStaffId()!=$thisstaff->getId()) {
@@ -102,7 +102,7 @@ if($_POST && !$errors):
                     elseif (($lock->isExpired() && !$lock->renew())
                         ||($lock->getCode() != $_POST['lockCode'])
                     ) {
-                        $errors['err'] = __('Your lock has expired. Please try again');
+                        $errors['err'] = sprintf('%s %s', __('Your lock has expired.'), __('Please try again!'));
                     }
                 }
 
@@ -149,14 +149,14 @@ if($_POST && !$errors):
 
             if ($cfg->getLockTime()) {
                 if (!$lock) {
-                    $errors['err'] = __('This action requires a lock. Please try again');
+                    $errors['err'] = sprintf('%s %s', __('This action requires a lock.'), __('Please try again!'));
                 }
                 // Use locks to avoid double replies
                 elseif ($lock->getStaffId()!=$thisstaff->getId()) {
                     $errors['err'] = __('Action Denied. Ticket is locked by someone else!');
                 }
                 elseif ($lock->getCode() != $_POST['lockCode']) {
-                    $errors['err'] = __('Your lock has expired. Please try again');
+                    $errors['err'] = sprintf('%s %s', __('Your lock has expired.'), __('Please try again!'));
                 }
             }
 
@@ -201,9 +201,10 @@ if($_POST && !$errors):
                 if(!$ticket->checkStaffPerm($thisstaff))
                     $ticket=null;
             } elseif(!$errors['err']) {
-                $errors['err']=sprintf(
-                    __('Unable to update %s. Correct any errors below and try again.'),
-                    __('ticket'));
+                $errors['err']=sprintf('%s %s',
+                    __('Unable to update %s.'),
+                    __('ticket'),
+                    __('Correct any errors below and try again.'));
             }
             break;
         case 'process':
@@ -218,7 +219,7 @@ if($_POST && !$errors):
                             $assigned, $thisstaff->getName());
                         $ticket->logActivity(__('Ticket unassigned'),$msg);
                     } else {
-                        $errors['err'] = __('Problems releasing the ticket. Try again');
+                        $errors['err'] = sprintf('%s %s', __('Problems releasing the ticket.'), __('Try again!'));
                     }
                     break;
                 case 'claim':
@@ -231,7 +232,7 @@ if($_POST && !$errors):
                     } elseif ($ticket->claim()) {
                         $msg = __('Ticket is now assigned to you!');
                     } else {
-                        $errors['err'] = __('Problems assigning the ticket. Try again');
+                        $errors['err'] = sprintf('%s %s', __('Problems assigning the ticket.'), __('Try again!'));
                     }
                     break;
                 case 'overdue':
@@ -242,7 +243,7 @@ if($_POST && !$errors):
                         $msg=sprintf(__('Ticket flagged as overdue by %s'),$thisstaff->getName());
                         $ticket->logActivity(__('Ticket Marked Overdue'),$msg);
                     } else {
-                        $errors['err']=__('Problems marking the the ticket overdue. Try again');
+                        $errors['err']=sprintf('%s %s', __('Problems marking the the ticket overdue.'), __('Try again!'));
                     }
                     break;
                 case 'answered':
@@ -253,7 +254,7 @@ if($_POST && !$errors):
                         $msg=sprintf(__('Ticket flagged as answered by %s'),$thisstaff->getName());
                         $ticket->logActivity(__('Ticket Marked Answered'),$msg);
                     } else {
-                        $errors['err']=__('Problems marking the the ticket answered. Try again');
+                        $errors['err']=sprintf('%s %s', __('Problems marking the ticket answered.'), __('Try again!'));
                     }
                     break;
                 case 'unanswered':
@@ -264,7 +265,7 @@ if($_POST && !$errors):
                         $msg=sprintf(__('Ticket flagged as unanswered by %s'),$thisstaff->getName());
                         $ticket->logActivity(__('Ticket Marked Unanswered'),$msg);
                     } else {
-                        $errors['err']=__('Problems marking the ticket unanswered. Try again');
+                        $errors['err']=sprintf('%s %s', __('Problems marking the ticket unanswered.'), __('Try again!'));
                     }
                     break;
                 case 'banemail':
@@ -286,7 +287,7 @@ if($_POST && !$errors):
                     } elseif(!BanList::includes($ticket->getEmail())) {
                         $warn = __('Email is not in the banlist');
                     } else {
-                        $errors['err']=__('Unable to remove the email from banlist. Try again.');
+                        $errors['err']=sprintf('%s %s', __('Unable to remove the email from banlist.'), __('Try again!'));
                     }
                     break;
                 case 'changeuser':
@@ -298,7 +299,7 @@ if($_POST && !$errors):
                         $msg = sprintf(__('Ticket ownership changed to %s'),
                             Format::htmlchars($user->getName()));
                     } else {
-                        $errors['err'] = __('Unable to change ticket ownership. Try again');
+                        $errors['err'] = sprintf('%s %s', __('Unable to change ticket ownership.'), __('Try again!'));
                     }
                     break;
                 default:
diff --git a/scp/users.php b/scp/users.php
index a99f06709..c3525c4d1 100644
--- a/scp/users.php
+++ b/scp/users.php
@@ -62,7 +62,7 @@ if ($_POST) {
             elseif ($user->getAccount()->sendConfirmEmail())
                 $msg = sprintf(__('Account activation email sent to %s'),$user->getEmail());
             else
-                $errors['err'] = __('Unable to send account activation email - try again!');
+                $errors['err'] = sprintf('%s - %s', __('Unable to send account activation email'), __('Try again!'));
             break;
         case 'pwreset':
             if (!$user || !$user->getAccount())
@@ -70,7 +70,7 @@ if ($_POST) {
             elseif ($user->getAccount()->sendResetEmail())
                 $msg = sprintf(__('Account password reset email sent to %s'),$user->getEmail());
             else
-                $errors['err'] = __('Unable to send account password reset email - try again!');
+                $errors['err'] = sprintf('%s - %s', __('Unable to send account password reset email'), __('Try again!'));
             break;
         case 'mass_process':
             if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) {
-- 
GitLab