Commit 4c199286401df26c443b9e346c4e5764fb75bf11
1 parent
c74050e0
KTS-2358
"php5 migration" Updated. Removed & from &new. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7208 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
45 additions
and
45 deletions
plugins/ktstandard/KTEmail.php
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
| 7 | 7 | * compliance with the License. You may obtain a copy of the License at |
| 8 | 8 | * http://www.knowledgetree.com/KPL |
| 9 | - * | |
| 9 | + * | |
| 10 | 10 | * Software distributed under the License is distributed on an "AS IS" |
| 11 | 11 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
| 12 | 12 | * See the License for the specific language governing rights and |
| ... | ... | @@ -17,9 +17,9 @@ |
| 17 | 17 | * (ii) the KnowledgeTree copyright notice |
| 18 | 18 | * in the same form as they appear in the distribution. See the License for |
| 19 | 19 | * requirements. |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * The Original Code is: KnowledgeTree Open Source |
| 22 | - * | |
| 22 | + * | |
| 23 | 23 | * The Initial Developer of the Original Code is The Jam Warehouse Software |
| 24 | 24 | * (Pty) Ltd, trading as KnowledgeTree. |
| 25 | 25 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright |
| ... | ... | @@ -42,7 +42,7 @@ require_once(KT_LIB_DIR . '/documentmanagement/Document.inc'); |
| 42 | 42 | */ |
| 43 | 43 | function sendGroupEmails($aGroupIDs, $oDocument, $sComment = '', $bAttachDocument, &$aEmailErrors) { |
| 44 | 44 | global $default; |
| 45 | - | |
| 45 | + | |
| 46 | 46 | // loop through groups |
| 47 | 47 | for ($i=0; $i<count($aGroupIDs); $i++) { |
| 48 | 48 | // validate the group id |
| ... | ... | @@ -54,7 +54,7 @@ function sendGroupEmails($aGroupIDs, $oDocument, $sComment = '', $bAttachDocumen |
| 54 | 54 | $aDestinationGroups[] = $member; |
| 55 | 55 | } |
| 56 | 56 | $aDestinationGroups[] = $oDestGroup; |
| 57 | - | |
| 57 | + | |
| 58 | 58 | $default->log->info('sendingEmail to group ' . $oDestGroup->getName()); |
| 59 | 59 | // for each group, retrieve all the users |
| 60 | 60 | foreach($aDestinationGroups as $oGroup){ |
| ... | ... | @@ -63,17 +63,17 @@ function sendGroupEmails($aGroupIDs, $oDocument, $sComment = '', $bAttachDocumen |
| 63 | 63 | |
| 64 | 64 | // FIXME: this should send one email with multiple To: users |
| 65 | 65 | for ($j=0; $j<count($aUsers); $j++) { |
| 66 | - $default->log->info('sendingEmail to group-member ' . $aUsers[$j]->getName() . ' with email ' . $aUsers[$j]->getEmail()); | |
| 66 | + $default->log->info('sendingEmail to group-member ' . $aUsers[$j]->getName() . ' with email ' . $aUsers[$j]->getEmail()); | |
| 67 | 67 | // the user has an email address and has email notification enabled |
| 68 | 68 | if (strlen($aUsers[$j]->getEmail())>0 && $aUsers[$j]->getEmailNotification()) { |
| 69 | 69 | //if the to address is valid, send the mail |
| 70 | - if (validateEmailAddress($aUsers[$j]->getEmail())) { | |
| 70 | + if (validateEmailAddress($aUsers[$j]->getEmail())) { | |
| 71 | 71 | sendEmail($aUsers[$j]->getEmail(), $aUsers[$j]->getName(), $oDocument->getID(), $oDocument->getName(), $sComment, $bAttachDocument, $aEmailErrors); |
| 72 | 72 | } else { |
| 73 | 73 | $default->log->error('email validation failed for ' . $aUsers[$j]->getEmail()); |
| 74 | 74 | } |
| 75 | 75 | } else { |
| 76 | - $default->log->info('either ' . $aUsers[$j]->getUserName() . ' has no email address, or notification is not enabled'); | |
| 76 | + $default->log->info('either ' . $aUsers[$j]->getUserName() . ' has no email address, or notification is not enabled'); | |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | } else { |
| ... | ... | @@ -87,16 +87,16 @@ function sendGroupEmails($aGroupIDs, $oDocument, $sComment = '', $bAttachDocumen |
| 87 | 87 | */ |
| 88 | 88 | function sendUserEmails($aUserIDs, $oDocument, $sComment = '', $bAttachDocument, &$aEmailErrors) { |
| 89 | 89 | global $default; |
| 90 | - | |
| 90 | + | |
| 91 | 91 | // loop through users |
| 92 | 92 | for ($i=0; $i<count($aUserIDs); $i++) { |
| 93 | 93 | if ($aUserIDs[$i] > 0) { |
| 94 | 94 | $oDestUser = User::get($aUserIDs[$i]); |
| 95 | - $default->log->info('sendingEmail to user ' . $oDestUser->getName() . ' with email ' . $oDestUser->getEmail()); | |
| 95 | + $default->log->info('sendingEmail to user ' . $oDestUser->getName() . ' with email ' . $oDestUser->getEmail()); | |
| 96 | 96 | // the user has an email address and has email notification enabled |
| 97 | 97 | if (strlen($oDestUser->getEmail())>0 && $oDestUser->getEmailNotification()) { |
| 98 | 98 | //if the to address is valid, send the mail |
| 99 | - if (validateEmailAddress($oDestUser->getEmail())) { | |
| 99 | + if (validateEmailAddress($oDestUser->getEmail())) { | |
| 100 | 100 | sendEmail($oDestUser->getEmail(), $oDestUser->getName(), $oDocument->getID(), $oDocument->getName(), $sComment, $bAttachDocument, $aEmailErrors); |
| 101 | 101 | } |
| 102 | 102 | } else { |
| ... | ... | @@ -104,8 +104,8 @@ function sendUserEmails($aUserIDs, $oDocument, $sComment = '', $bAttachDocument, |
| 104 | 104 | } |
| 105 | 105 | } else { |
| 106 | 106 | $default->log->info('filtered user id=' . $aUserIDs[$i]); |
| 107 | - } | |
| 108 | - } | |
| 107 | + } | |
| 108 | + } | |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
| ... | ... | @@ -113,14 +113,14 @@ function sendUserEmails($aUserIDs, $oDocument, $sComment = '', $bAttachDocument, |
| 113 | 113 | */ |
| 114 | 114 | function sendManualEmails($aEmailAddresses, $oDocument, $sComment = '', $bAttachDocument, &$aEmailErrors) { |
| 115 | 115 | global $default; |
| 116 | - | |
| 116 | + | |
| 117 | 117 | // loop through users |
| 118 | 118 | foreach ($aEmailAddresses as $sEmailAddress) { |
| 119 | 119 | $default->log->info('sendingEmail to address ' . $sEmailAddress); |
| 120 | - if (validateEmailAddress($sEmailAddress)) { | |
| 120 | + if (validateEmailAddress($sEmailAddress)) { | |
| 121 | 121 | sendEmail($sEmailAddress, $sEmailAddress, $oDocument->getID(), $oDocument->getName(), $sComment, $bAttachDocument, $aEmailErrors); |
| 122 | 122 | } |
| 123 | - } | |
| 123 | + } | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
| ... | ... | @@ -179,7 +179,7 @@ function sendEmailDocument($sDestEmailAddress, $sDestUserName, $iDocumentID, $sD |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // emailed link transaction |
| 182 | - $oDocumentTransaction = & new DocumentTransaction($oDocument, sprintf(_kt("Document copy emailed to %s"), $sDestEmailAddress), 'ktcore.transactions.email_attachement'); | |
| 182 | + $oDocumentTransaction = new DocumentTransaction($oDocument, sprintf(_kt("Document copy emailed to %s"), $sDestEmailAddress), 'ktcore.transactions.email_attachement'); | |
| 183 | 183 | if ($oDocumentTransaction->create()) { |
| 184 | 184 | $default->log->debug("emailBL.php created email link document transaction for document ID=$iDocumentID"); |
| 185 | 185 | } else { |
| ... | ... | @@ -190,7 +190,7 @@ function sendEmailDocument($sDestEmailAddress, $sDestUserName, $iDocumentID, $sD |
| 190 | 190 | function sendEmailHyperlink($sDestEmailAddress, $sDestUserName, $iDocumentID, $sDocumentName, $sComment, &$aEmailErrors) { |
| 191 | 191 | global $default; |
| 192 | 192 | $oSendingUser = User::get($_SESSION['userID']); |
| 193 | - | |
| 193 | + | |
| 194 | 194 | $sMessage = '<font face="arial" size="2">'; |
| 195 | 195 | if ($sDestUserName) { |
| 196 | 196 | $sMessage .= $sDestUserName . ',<br><br>'; |
| ... | ... | @@ -223,21 +223,21 @@ function sendEmailHyperlink($sDestEmailAddress, $sDestUserName, $iDocumentID, $s |
| 223 | 223 | $aEmailErrors[] = $res->getMessage(); |
| 224 | 224 | return $res; |
| 225 | 225 | } else if ($res === false) { |
| 226 | - $default->log->error("Error sending email ($sTitle) to $sDestEmailAddress"); | |
| 226 | + $default->log->error("Error sending email ($sTitle) to $sDestEmailAddress"); | |
| 227 | 227 | $aEmailErrors[] = "Error sending email ($sTitle) to $sDestEmailAddress"; |
| 228 | 228 | return PEAR::raiseError(sprintf(_kt("Error sending email (%s) to %s"), $sTitle, $sDestEmailAddress)); |
| 229 | 229 | } else { |
| 230 | 230 | $default->log->info("Send email ($sTitle) to $sDestEmailAddress"); |
| 231 | 231 | } |
| 232 | - | |
| 232 | + | |
| 233 | 233 | // emailed link transaction |
| 234 | 234 | // need a document to do this. |
| 235 | 235 | $oDocument =& Document::get($iDocumentID); |
| 236 | - | |
| 237 | - $oDocumentTransaction = & new DocumentTransaction($oDocument, sprintf(_kt("Document link emailed to %s"), $sDestEmailAddress), 'ktcore.transactions.email_link'); | |
| 236 | + | |
| 237 | + $oDocumentTransaction = new DocumentTransaction($oDocument, sprintf(_kt("Document link emailed to %s"), $sDestEmailAddress), 'ktcore.transactions.email_link'); | |
| 238 | 238 | |
| 239 | 239 | if ($oDocumentTransaction->create()) { |
| 240 | - $default->log->debug("emailBL.php created email link document transaction for document ID=$iDocumentID"); | |
| 240 | + $default->log->debug("emailBL.php created email link document transaction for document ID=$iDocumentID"); | |
| 241 | 241 | } else { |
| 242 | 242 | $default->log->error("emailBL.php couldn't create email link document transaction for document ID=$iDocumentID"); |
| 243 | 243 | } |
| ... | ... | @@ -264,7 +264,7 @@ class KTDocumentEmailAction extends KTDocumentAction { |
| 264 | 264 | function getDisplayName() { |
| 265 | 265 | return _kt('Email'); |
| 266 | 266 | } |
| 267 | - | |
| 267 | + | |
| 268 | 268 | function getInfo() { |
| 269 | 269 | $oConfig =& KTConfig::getSingleton(); |
| 270 | 270 | $sEmailServer = $oConfig->get('email/emailServer'); |
| ... | ... | @@ -273,11 +273,11 @@ class KTDocumentEmailAction extends KTDocumentAction { |
| 273 | 273 | } |
| 274 | 274 | if (empty($sEmailServer)) { |
| 275 | 275 | return null; |
| 276 | - } | |
| 277 | - | |
| 276 | + } | |
| 277 | + | |
| 278 | 278 | return parent::getInfo(); |
| 279 | 279 | } |
| 280 | - | |
| 280 | + | |
| 281 | 281 | function do_main() { |
| 282 | 282 | $oConfig = KTConfig::getSingleton(); |
| 283 | 283 | $bAttachment = $oConfig->get('email/allowAttachment', false); |
| ... | ... | @@ -288,14 +288,14 @@ class KTDocumentEmailAction extends KTDocumentAction { |
| 288 | 288 | $fields = array(); |
| 289 | 289 | |
| 290 | 290 | $fields[] = new KTJSONLookupWidget(_kt('Groups'), '', |
| 291 | - 'groups', '', $this->oPage, false, null, null, | |
| 291 | + 'groups', '', $this->oPage, false, null, null, | |
| 292 | 292 | array('action'=>sprintf('getGroups&fDocumentId=%d', $this->oDocument->getId()), |
| 293 | 293 | 'assigned' => array(), |
| 294 | 294 | 'multi'=>'true', |
| 295 | 295 | 'size'=>'8')); |
| 296 | 296 | |
| 297 | 297 | $fields[] = new KTJSONLookupWidget(_kt('Users'), '', |
| 298 | - 'users', '', $this->oPage, false, null, null, | |
| 298 | + 'users', '', $this->oPage, false, null, null, | |
| 299 | 299 | array('action'=>sprintf('getUsers&fDocumentId=%d', $this->oDocument->getId()), |
| 300 | 300 | 'assigned' => array(), |
| 301 | 301 | 'multi'=>'true', |
| ... | ... | @@ -303,23 +303,23 @@ class KTDocumentEmailAction extends KTDocumentAction { |
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | if ($bAttachment) { |
| 306 | - $fields[] = new KTCheckboxWidget(_kt('Attach document'), | |
| 307 | - _kt('By default, documents are sent as links into the document management system. Select this option if you want the document contents to be sent as an attachment in the email.'), | |
| 306 | + $fields[] = new KTCheckboxWidget(_kt('Attach document'), | |
| 307 | + _kt('By default, documents are sent as links into the document management system. Select this option if you want the document contents to be sent as an attachment in the email.'), | |
| 308 | 308 | 'fAttachDocument', null, $this->oPage); |
| 309 | 309 | } |
| 310 | 310 | if ($bEmailAddresses) { |
| 311 | - $fields[] = new KTTextWidget(_kt('Email addresses'), | |
| 312 | - _kt('Add extra email addresses here'), | |
| 313 | - 'fEmailAddresses', '', $this->oPage, | |
| 311 | + $fields[] = new KTTextWidget(_kt('Email addresses'), | |
| 312 | + _kt('Add extra email addresses here'), | |
| 313 | + 'fEmailAddresses', '', $this->oPage, | |
| 314 | 314 | false, null, null, array('cols' => 60, 'rows' => 5)); |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $fields[] = new KTTextWidget(_kt('Comment'), | |
| 318 | - _kt('A message for those who receive the document'), | |
| 319 | - 'fComment', '', $this->oPage, | |
| 317 | + $fields[] = new KTTextWidget(_kt('Comment'), | |
| 318 | + _kt('A message for those who receive the document'), | |
| 319 | + 'fComment', '', $this->oPage, | |
| 320 | 320 | true, null, null, array('cols' => 60, 'rows' => 5)); |
| 321 | 321 | |
| 322 | - | |
| 322 | + | |
| 323 | 323 | $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/email'); |
| 324 | 324 | $aTemplateData = array( |
| 325 | 325 | 'context' => &$this, |
| ... | ... | @@ -337,14 +337,14 @@ class KTDocumentEmailAction extends KTDocumentAction { |
| 337 | 337 | $sFilter = KTUtil::arrayGet($_REQUEST, 'filter', false); |
| 338 | 338 | $aGroupList = array('off'=> _kt('-- Please filter --')); |
| 339 | 339 | |
| 340 | - if($sFilter && trim($sFilter)) { | |
| 340 | + if($sFilter && trim($sFilter)) { | |
| 341 | 341 | $sWhere = sprintf('name LIKE "%%%s%%"', $sFilter); |
| 342 | 342 | if ($bOnlyOwnGroup != true) { |
| 343 | 343 | $aGroups = Group::getList($sWhere); |
| 344 | 344 | } else { |
| 345 | 345 | $aGroups = GroupUtil::listGroupsForUser($this->oUser, array('where' => $sWhere)); |
| 346 | 346 | } |
| 347 | - | |
| 347 | + | |
| 348 | 348 | $aGroupList = array(); |
| 349 | 349 | foreach($aGroups as $g) { |
| 350 | 350 | $aGroupList[$g->getId()] = $g->getName(); |
| ... | ... | @@ -362,7 +362,7 @@ class KTDocumentEmailAction extends KTDocumentAction { |
| 362 | 362 | $sFilter = KTUtil::arrayGet($_REQUEST, 'filter', false); |
| 363 | 363 | $aUserList = array('off' => _kt('-- Please filter --')); |
| 364 | 364 | |
| 365 | - if($sFilter && trim($sFilter)) { | |
| 365 | + if($sFilter && trim($sFilter)) { | |
| 366 | 366 | $sWhere = sprintf('name LIKE \'%%%s%%\' AND disabled = \'0\'', $sFilter); |
| 367 | 367 | if ($bOnlyOwnGroup != true) { |
| 368 | 368 | $aUsers = User::getEmailUsers($sWhere); |
| ... | ... | @@ -381,7 +381,7 @@ class KTDocumentEmailAction extends KTDocumentAction { |
| 381 | 381 | $aUsers[] = $oUser; |
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | - | |
| 384 | + | |
| 385 | 385 | $aUserList = array(); |
| 386 | 386 | foreach($aUsers as $u) { |
| 387 | 387 | $aUserList[$u->getId()] = $u->getName(); |
| ... | ... | @@ -394,7 +394,7 @@ class KTDocumentEmailAction extends KTDocumentAction { |
| 394 | 394 | |
| 395 | 395 | function do_email() { |
| 396 | 396 | $groupNewRight = trim($_REQUEST['groups_items_added'], chr(160)); |
| 397 | - | |
| 397 | + | |
| 398 | 398 | $userNewRight = trim($_REQUEST['users_items_added'], chr(160)); |
| 399 | 399 | |
| 400 | 400 | $fEmailAddresses = trim($_REQUEST['fEmailAddresses']); |
| ... | ... | @@ -419,7 +419,7 @@ class KTDocumentEmailAction extends KTDocumentAction { |
| 419 | 419 | $oConfig = KTConfig::getSingleton(); |
| 420 | 420 | $bAttachment = $oConfig->get('email/allowAttachment', false); |
| 421 | 421 | $bEmailAddresses = $oConfig->get('email/allowEmailAddresses', false); |
| 422 | - | |
| 422 | + | |
| 423 | 423 | if (empty($bAttachment)) { |
| 424 | 424 | $fAttachDocument = false; |
| 425 | 425 | } |
| ... | ... | @@ -460,7 +460,7 @@ class KTEmailPlugin extends KTPlugin { |
| 460 | 460 | $res = parent::KTPlugin($sFilename); |
| 461 | 461 | $this->sFriendlyName = _kt('Email Plugin'); |
| 462 | 462 | return $res; |
| 463 | - } | |
| 463 | + } | |
| 464 | 464 | |
| 465 | 465 | function setup() { |
| 466 | 466 | $this->registerAction('documentaction', 'KTDocumentEmailAction', 'ktcore.actions.document.email'); | ... | ... |