]> git.mxchange.org Git - friendica.git/blob - mod/message.php
Class file relocations
[friendica.git] / mod / message.php
1 <?php
2
3 use Friendica\App;
4 use Friendica\Core\System;
5 use Friendica\Database\DBM;
6
7 require_once('include/acl_selectors.php');
8 require_once('include/message.php');
9 require_once('include/Smilies.php');
10
11 function message_init(App $a) {
12
13         $tabs = '';
14
15         if ($a->argc >1 && is_numeric($a->argv[1])) {
16                 $tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl');
17         }
18
19         $new = array(
20                 'label' => t('New Message'),
21                 'url' => 'message/new',
22                 'sel'=> ($a->argv[1] == 'new'),
23                 'accesskey' => 'm',
24         );
25
26         $tpl = get_markup_template('message_side.tpl');
27         $a->page['aside'] = replace_macros($tpl, array(
28                 '$tabs'=>$tabs,
29                 '$new'=>$new,
30         ));
31         $base = System::baseUrl();
32
33         $head_tpl = get_markup_template('message-head.tpl');
34         $a->page['htmlhead'] .= replace_macros($head_tpl,array(
35                 '$baseurl' => System::baseUrl(true),
36                 '$base' => $base
37         ));
38
39         $end_tpl = get_markup_template('message-end.tpl');
40         $a->page['end'] .= replace_macros($end_tpl,array(
41                 '$baseurl' => System::baseUrl(true),
42                 '$base' => $base
43         ));
44
45 }
46
47 function message_post(App $a) {
48
49         if (! local_user()) {
50                 notice( t('Permission denied.') . EOL);
51                 return;
52         }
53
54         $replyto   = ((x($_REQUEST,'replyto'))   ? notags(trim($_REQUEST['replyto']))   : '');
55         $subject   = ((x($_REQUEST,'subject'))   ? notags(trim($_REQUEST['subject']))   : '');
56         $body      = ((x($_REQUEST,'body'))      ? escape_tags(trim($_REQUEST['body'])) : '');
57         $recipient = ((x($_REQUEST,'messageto')) ? intval($_REQUEST['messageto'])       : 0 );
58
59         $ret = send_message($recipient, $body, $subject, $replyto);
60         $norecip = false;
61
62         switch($ret){
63                 case -1:
64                         notice( t('No recipient selected.') . EOL );
65                         $norecip = true;
66                         break;
67                 case -2:
68                         notice( t('Unable to locate contact information.') . EOL );
69                         break;
70                 case -3:
71                         notice( t('Message could not be sent.') . EOL );
72                         break;
73                 case -4:
74                         notice( t('Message collection failure.') . EOL );
75                         break;
76                 default:
77                         info( t('Message sent.') . EOL );
78         }
79
80         // fake it to go back to the input form if no recipient listed
81
82         if ($norecip) {
83                 $a->argc = 2;
84                 $a->argv[1] = 'new';
85         } else
86                 goaway($_SESSION['return_url']);
87
88 }
89
90 // Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
91 // is identical to the code in include/conversation.php
92 if (! function_exists('item_extract_images')) {
93 function item_extract_images($body) {
94
95         $saved_image = array();
96         $orig_body = $body;
97         $new_body = '';
98
99         $cnt = 0;
100         $img_start = strpos($orig_body, '[img');
101         $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
102         $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
103         while(($img_st_close !== false) && ($img_end !== false)) {
104
105                 $img_st_close++; // make it point to AFTER the closing bracket
106                 $img_end += $img_start;
107
108                 if (! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
109                         // This is an embedded image
110
111                         $saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
112                         $new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
113
114                         $cnt++;
115                 } else
116                         $new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
117
118                 $orig_body = substr($orig_body, $img_end + strlen('[/img]'));
119
120                 if ($orig_body === false) // in case the body ends on a closing image tag
121                         $orig_body = '';
122
123                 $img_start = strpos($orig_body, '[img');
124                 $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
125                 $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
126         }
127
128         $new_body = $new_body . $orig_body;
129
130         return array('body' => $new_body, 'images' => $saved_image);
131 }}
132
133 if (! function_exists('item_redir_and_replace_images')) {
134 function item_redir_and_replace_images($body, $images, $cid) {
135
136         $origbody = $body;
137         $newbody = '';
138
139         for($i = 0; $i < count($images); $i++) {
140                 $search = '/\[url\=(.*?)\]\[!#saved_image' . $i . '#!\]\[\/url\]' . '/is';
141                 $replace = '[url=' . System::baseUrl() . '/redir/' . $cid
142                            . '?f=1&url=' . '$1' . '][!#saved_image' . $i . '#!][/url]' ;
143
144                 $img_end = strpos($origbody, '[!#saved_image' . $i . '#!][/url]') + strlen('[!#saved_image' . $i . '#!][/url]');
145                 $process_part = substr($origbody, 0, $img_end);
146                 $origbody = substr($origbody, $img_end);
147
148                 $process_part = preg_replace($search, $replace, $process_part);
149                 $newbody = $newbody . $process_part;
150         }
151         $newbody = $newbody . $origbody;
152
153         $cnt = 0;
154         foreach ($images as $image) {
155                 // We're depending on the property of 'foreach' (specified on the PHP website) that
156                 // it loops over the array starting from the first element and going sequentially
157                 // to the last element
158                 $newbody = str_replace('[!#saved_image' . $cnt . '#!]', '[img]' . $image . '[/img]', $newbody);
159                 $cnt++;
160         }
161
162         return $newbody;
163 }}
164
165
166
167 function message_content(App $a) {
168
169         $o = '';
170         nav_set_selected('messages');
171
172         if (! local_user()) {
173                 notice( t('Permission denied.') . EOL);
174                 return;
175         }
176
177         $myprofile = System::baseUrl().'/profile/' . $a->user['nickname'];
178
179         $tpl = get_markup_template('mail_head.tpl');
180         $header = replace_macros($tpl, array(
181                 '$messages' => t('Messages'),
182                 '$tab_content' => $tab_content
183         ));
184
185
186         if (($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) {
187                 if (! intval($a->argv[2]))
188                         return;
189
190                 // Check if we should do HTML-based delete confirmation
191                 if ($_REQUEST['confirm']) {
192                         // <form> can't take arguments in its "action" parameter
193                         // so add any arguments as hidden inputs
194                         $query = explode_querystring($a->query_string);
195                         $inputs = array();
196                         foreach($query['args'] as $arg) {
197                                 if (strpos($arg, 'confirm=') === false) {
198                                         $arg_parts = explode('=', $arg);
199                                         $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
200                                 }
201                         }
202
203                         //$a->page['aside'] = '';
204                         return replace_macros(get_markup_template('confirm.tpl'), array(
205                                 '$method' => 'get',
206                                 '$message' => t('Do you really want to delete this message?'),
207                                 '$extra_inputs' => $inputs,
208                                 '$confirm' => t('Yes'),
209                                 '$confirm_url' => $query['base'],
210                                 '$confirm_name' => 'confirmed',
211                                 '$cancel' => t('Cancel'),
212                         ));
213                 }
214                 // Now check how the user responded to the confirmation query
215                 if ($_REQUEST['canceled']) {
216                         goaway($_SESSION['return_url']);
217                 }
218
219                 $cmd = $a->argv[1];
220                 if ($cmd === 'drop') {
221                         $r = q("DELETE FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
222                                 intval($a->argv[2]),
223                                 intval(local_user())
224                         );
225                         if ($r) {
226                                 info( t('Message deleted.') . EOL );
227                         }
228                         //goaway(System::baseUrl(true) . '/message' );
229                         goaway($_SESSION['return_url']);
230                 } else {
231                         $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
232                                 intval($a->argv[2]),
233                                 intval(local_user())
234                         );
235                         if (DBM::is_result($r)) {
236                                 $parent = $r[0]['parent-uri'];
237                                 $convid = $r[0]['convid'];
238
239                                 $r = q("DELETE FROM `mail` WHERE `parent-uri` = '%s' AND `uid` = %d ",
240                                         dbesc($parent),
241                                         intval(local_user())
242                                 );
243
244                                 // remove diaspora conversation pointer
245                                 // Actually if we do this, we can never receive another reply to that conversation,
246                                 // as we will never again have the info we need to re-create it.
247                                 // We'll just have to orphan it.
248
249                                 //if ($convid) {
250                                 //      q("delete from conv where id = %d limit 1",
251                                 //              intval($convid)
252                                 //      );
253                                 //}
254
255                                 if ($r)
256                                         info( t('Conversation removed.') . EOL );
257                         }
258                         //goaway(System::baseUrl(true) . '/message' );
259                         goaway($_SESSION['return_url']);
260                 }
261
262         }
263
264         if (($a->argc > 1) && ($a->argv[1] === 'new')) {
265
266                 $o .= $header;
267
268                 $tpl = get_markup_template('msg-header.tpl');
269                 $a->page['htmlhead'] .= replace_macros($tpl, array(
270                         '$baseurl' => System::baseUrl(true),
271                         '$nickname' => $a->user['nickname'],
272                         '$linkurl' => t('Please enter a link URL:')
273                 ));
274
275                 $tpl = get_markup_template('msg-end.tpl');
276                 $a->page['end'] .= replace_macros($tpl, array(
277                         '$baseurl' => System::baseUrl(true),
278                         '$nickname' => $a->user['nickname'],
279                         '$linkurl' => t('Please enter a link URL:')
280                 ));
281
282                 $preselect = (isset($a->argv[2])?array($a->argv[2]):false);
283
284
285                 $prename = $preurl = $preid = '';
286
287                 if ($preselect) {
288                         $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `id` = %d LIMIT 1",
289                                 intval(local_user()),
290                                 intval($a->argv[2])
291                         );
292                         if (!DBM::is_result($r)) {
293                                 $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
294                                         intval(local_user()),
295                                         dbesc(normalise_link(base64_decode($a->argv[2])))
296                                 );
297                         }
298
299                         if (!DBM::is_result($r)) {
300                                 $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `addr` = '%s' LIMIT 1",
301                                         intval(local_user()),
302                                         dbesc(base64_decode($a->argv[2]))
303                                 );
304                         }
305
306                         if (DBM::is_result($r)) {
307                                 $prename = $r[0]['name'];
308                                 $preurl = $r[0]['url'];
309                                 $preid = $r[0]['id'];
310                                 $preselect = array($preid);
311                         } else
312                                 $preselect = false;
313                 }
314
315                 $prefill = (($preselect) ? $prename  : '');
316
317                 // the ugly select box
318
319                 $select = contact_select('messageto','message-to-select', $preselect, 4, true, false, false, 10);
320
321                 $tpl = get_markup_template('prv_message.tpl');
322                 $o .= replace_macros($tpl,array(
323                         '$header' => t('Send Private Message'),
324                         '$to' => t('To:'),
325                         '$showinputs' => 'true',
326                         '$prefill' => $prefill,
327                         '$autocomp' => $autocomp,
328                         '$preid' => $preid,
329                         '$subject' => t('Subject:'),
330                         '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''),
331                         '$text' => ((x($_REQUEST,'body')) ? escape_tags(htmlspecialchars($_REQUEST['body'])) : ''),
332                         '$readonly' => '',
333                         '$yourmessage' => t('Your message:'),
334                         '$select' => $select,
335                         '$parent' => '',
336                         '$upload' => t('Upload photo'),
337                         '$insert' => t('Insert web link'),
338                         '$wait' => t('Please wait'),
339                         '$submit' => t('Submit')
340                 ));
341                 return $o;
342         }
343
344
345         $_SESSION['return_url'] = $a->query_string;
346
347         if ($a->argc == 1) {
348
349                 // List messages
350
351                 $o .= $header;
352
353                 $r = q("SELECT count(*) AS `total`, ANY_VALUE(`created`) AS `created` FROM `mail`
354                         WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `created` DESC",
355                         intval(local_user())
356                 );
357
358                 if (DBM::is_result($r)) {
359                         $a->set_pager_total($r[0]['total']);
360                 }
361
362                 $r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']);
363
364                 if (! DBM::is_result($r)) {
365                         info( t('No messages.') . EOL);
366                         return $o;
367                 }
368
369                 $o .= render_messages($r, 'mail_list.tpl');
370
371                 $o .= paginate($a);
372
373                 return $o;
374         }
375
376         if (($a->argc > 1) && (intval($a->argv[1]))) {
377
378                 $o .= $header;
379
380                 $r = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`
381                         FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
382                         WHERE `mail`.`uid` = %d AND `mail`.`id` = %d LIMIT 1",
383                         intval(local_user()),
384                         intval($a->argv[1])
385                 );
386                 if (DBM::is_result($r)) {
387                         $contact_id = $r[0]['contact-id'];
388                         $convid = $r[0]['convid'];
389
390                         $sql_extra = sprintf(" and `mail`.`parent-uri` = '%s' ", dbesc($r[0]['parent-uri']));
391                         if ($convid)
392                                 $sql_extra = sprintf(" and ( `mail`.`parent-uri` = '%s' OR `mail`.`convid` = '%d' ) ",
393                                         dbesc($r[0]['parent-uri']),
394                                         intval($convid)
395                                 );
396
397                         $messages = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`
398                                 FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
399                                 WHERE `mail`.`uid` = %d $sql_extra ORDER BY `mail`.`created` ASC",
400                                 intval(local_user())
401                         );
402                 }
403                 if (! count($messages)) {
404                         notice( t('Message not available.') . EOL );
405                         return $o;
406                 }
407
408                 $r = q("UPDATE `mail` SET `seen` = 1 WHERE `parent-uri` = '%s' AND `uid` = %d",
409                         dbesc($r[0]['parent-uri']),
410                         intval(local_user())
411                 );
412
413                 require_once("include/bbcode.php");
414
415                 $tpl = get_markup_template('msg-header.tpl');
416                 $a->page['htmlhead'] .= replace_macros($tpl, array(
417                         '$baseurl' => System::baseUrl(true),
418                         '$nickname' => $a->user['nickname'],
419                         '$linkurl' => t('Please enter a link URL:')
420                 ));
421
422                 $tpl = get_markup_template('msg-end.tpl');
423                 $a->page['end'] .= replace_macros($tpl, array(
424                         '$baseurl' => System::baseUrl(true),
425                         '$nickname' => $a->user['nickname'],
426                         '$linkurl' => t('Please enter a link URL:')
427                 ));
428
429                 $mails = array();
430                 $seen = 0;
431                 $unknown = false;
432
433                 foreach($messages as $message) {
434                         if ($message['unknown'])
435                                 $unknown = true;
436                         if ($message['from-url'] == $myprofile) {
437                                 $from_url = $myprofile;
438                                 $sparkle = '';
439                         } elseif ($message['contact-id'] != 0) {
440                                 $from_url = 'redir/'.$message['contact-id'];
441                                 $sparkle = ' sparkle';
442                         } else {
443                                 $from_url = $message['from-url']."?zrl=".urlencode($myprofile);
444                                 $sparkle = ' sparkle';
445                         }
446
447
448                         $extracted = item_extract_images($message['body']);
449                         if ($extracted['images'])
450                                 $message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']);
451
452                         if ($a->theme['template_engine'] === 'internal') {
453                                 $from_name_e = template_escape($message['from-name']);
454                                 $subject_e = template_escape($message['title']);
455                                 $body_e = template_escape(Smilies::replace(bbcode($message['body'])));
456                                 $to_name_e = template_escape($message['name']);
457                         } else {
458                                 $from_name_e = $message['from-name'];
459                                 $subject_e = $message['title'];
460                                 $body_e = Smilies::replace(bbcode($message['body']));
461                                 $to_name_e = $message['name'];
462                         }
463
464                         $contact = get_contact_details_by_url($message['from-url']);
465                         if (isset($contact["thumb"]))
466                                 $from_photo = $contact["thumb"];
467                         else
468                                 $from_photo = $message['from-photo'];
469
470                         $mails[] = array(
471                                 'id' => $message['id'],
472                                 'from_name' => $from_name_e,
473                                 'from_url' => $from_url,
474                                 'from_addr' => $contact['addr'],
475                                 'sparkle' => $sparkle,
476                                 'from_photo' => proxy_url($from_photo, false, PROXY_SIZE_THUMB),
477                                 'subject' => $subject_e,
478                                 'body' => $body_e,
479                                 'delete' => t('Delete message'),
480                                 'to_name' => $to_name_e,
481                                 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'),
482                                 'ago' => relative_date($message['created']),
483                         );
484
485                         $seen = $message['seen'];
486                 }
487
488
489                 $select = $message['name'] . '<input type="hidden" name="messageto" value="' . $contact_id . '" />';
490                 $parent = '<input type="hidden" name="replyto" value="' . $message['parent-uri'] . '" />';
491
492                 $tpl = get_markup_template('mail_display.tpl');
493
494                 if ($a->theme['template_engine'] === 'internal') {
495                         $subjtxt_e = template_escape($message['title']);
496                 } else {
497                         $subjtxt_e = $message['title'];
498                 }
499
500                 $o = replace_macros($tpl, array(
501                         '$thread_id' => $a->argv[1],
502                         '$thread_subject' => $message['title'],
503                         '$thread_seen' => $seen,
504                         '$delete' =>  t('Delete conversation'),
505                         '$canreply' => (($unknown) ? false : '1'),
506                         '$unknown_text' => t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."),
507                         '$mails' => $mails,
508
509                         // reply
510                         '$header' => t('Send Reply'),
511                         '$to' => t('To:'),
512                         '$showinputs' => '',
513                         '$subject' => t('Subject:'),
514                         '$subjtxt' => $subjtxt_e,
515                         '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ',
516                         '$yourmessage' => t('Your message:'),
517                         '$text' => '',
518                         '$select' => $select,
519                         '$parent' => $parent,
520                         '$upload' => t('Upload photo'),
521                         '$insert' => t('Insert web link'),
522                         '$submit' => t('Submit'),
523                         '$wait' => t('Please wait')
524
525                 ));
526
527                 return $o;
528         }
529 }
530
531 function get_messages($user, $lstart, $lend) {
532         //TODO: rewritte with a sub-query to get the first message of each private thread with certainty
533         return q("SELECT max(`mail`.`created`) AS `mailcreated`, min(`mail`.`seen`) AS `mailseen`,
534                 ANY_VALUE(`mail`.`id`) AS `id`, ANY_VALUE(`mail`.`uid`) AS `uid`, ANY_VALUE(`mail`.`guid`) AS `guid`,
535                 ANY_VALUE(`mail`.`from-name`) AS `from-name`, ANY_VALUE(`mail`.`from-photo`) AS `from-photo`,
536                 ANY_VALUE(`mail`.`from-url`) AS `from-url`, ANY_VALUE(`mail`.`contact-id`) AS `contact-id`,
537                 ANY_VALUE(`mail`.`convid`) AS `convid`, ANY_VALUE(`mail`.`title`) AS `title`, ANY_VALUE(`mail`.`body`) AS `body`,
538                 ANY_VALUE(`mail`.`seen`) AS `seen`, ANY_VALUE(`mail`.`reply`) AS `reply`, ANY_VALUE(`mail`.`replied`) AS `replied`,
539                 ANY_VALUE(`mail`.`unknown`) AS `unknown`, ANY_VALUE(`mail`.`uri`) AS `uri`,
540                 `mail`.`parent-uri`,
541                 ANY_VALUE(`mail`.`created`) AS `created`, ANY_VALUE(`contact`.`name`) AS `name`, ANY_VALUE(`contact`.`url`) AS `url`,
542                 ANY_VALUE(`contact`.`thumb`) AS `thumb`, ANY_VALUE(`contact`.`network`) AS `network`,
543                 count( * ) as `count`
544                 FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
545                 WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ",
546                 intval($user), intval($lstart), intval($lend)
547         );
548 }
549
550 function render_messages(array $msg, $t) {
551
552         $a = get_app();
553
554         $tpl = get_markup_template($t);
555         $rslt = '';
556
557         $myprofile = System::baseUrl().'/profile/' . $a->user['nickname'];
558
559         foreach($msg as $rr) {
560
561                 if ($rr['unknown'])
562                         $participants = sprintf( t("Unknown sender - %s"),$rr['from-name']);
563                 elseif (link_compare($rr['from-url'], $myprofile))
564                         $participants = sprintf( t("You and %s"), $rr['name']);
565                 else
566                         $participants = sprintf(t("%s and You"), $rr['from-name']);
567
568                 if ($a->theme['template_engine'] === 'internal') {
569                         $subject_e = template_escape((($rr['mailseen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'));
570                         $body_e = template_escape($rr['body']);
571                         $to_name_e = template_escape($rr['name']);
572                 } else {
573                         $subject_e = (($rr['mailseen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>');
574                         $body_e = $rr['body'];
575                         $to_name_e = $rr['name'];
576                 }
577
578                 $contact = get_contact_details_by_url($rr['url']);
579                 if (isset($contact["thumb"]))
580                         $from_photo = $contact["thumb"];
581                 else
582                         $from_photo = (($rr['thumb']) ? $rr['thumb'] : $rr['from-photo']);
583
584                 $rslt .= replace_macros($tpl, array(
585                         '$id' => $rr['id'],
586                         '$from_name' => $participants,
587                         '$from_url' => (($rr['network'] === NETWORK_DFRN) ? 'redir/' . $rr['contact-id'] : $rr['url']),
588                         '$from_addr' => $contact['addr'],
589                         '$sparkle' => ' sparkle',
590                         '$from_photo' => proxy_url($from_photo, false, PROXY_SIZE_THUMB),
591                         '$subject' => $subject_e,
592                         '$delete' => t('Delete conversation'),
593                         '$body' => $body_e,
594                         '$to_name' => $to_name_e,
595                         '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['mailcreated'], t('D, d M Y - g:i A')),
596                                                                                                                         '$ago' => relative_date($rr['mailcreated']),
597                         '$seen' => $rr['mailseen'],
598                         '$count' => sprintf( tt('%d message', '%d messages', $rr['count']), $rr['count']),
599                 ));
600         }
601
602         return $rslt;
603 }