tiki-share.php 18.9 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
6
//
7 8
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
9
// $Id$
10 11

// To include a link in your tpl do
12
//<a href="tiki-share.php?url={$smarty.server.REQUEST_URI|escape:'url'}">{tr}Share this page{/tr}</a>
13

14
$section = 'share';
15
require_once ('tiki-setup.php');
16 17 18 19 20 21 22 23 24
if (empty($_REQUEST['report'])) {
	$access->check_feature('feature_share');
	$access->check_permission('tiki_p_share');
} else {
	if ($_REQUEST['report'] == 'y') {
		$access->check_feature('feature_site_report', '', 'look');
		$access->check_permission('tiki_p_site_report');
	}
}
25

26
// email related:
27

28
$smarty->assign('do_email', (isset($_REQUEST['do_email'])?$_REQUEST['do_email']:true));
29 30
if (empty($_REQUEST['report']) || $_REQUEST['report'] != 'y') {
	// twitter/facebook related
31 32
	if (isset($prefs['feature_socialnetworks']) and $prefs['feature_socialnetworks'] == 'y') {

33
		require_once ('lib/socialnetworkslib.php');
34 35 36 37 38 39 40 41 42 43 44
		$smarty->assign('twitterRegistered', $socialnetworkslib->twitterRegistered());
		$smarty->assign('facebookRegistered', $socialnetworkslib->facebookRegistered());

		$twitter_token = $tikilib->get_user_preference($user, 'twitter_token', '');

		$smarty->assign('twitter', ($twitter_token != ''));
		$facebook_token = $tikilib->get_user_preference($user, 'facebook_token', '');
		$smarty->assign('facebook', ($facebook_token != ''));
		$smarty->assign('do_tweet', (isset($_REQUEST['do_tweet']) ? $_REQUEST['do_tweet'] : true));
		$smarty->assign('do_fb', (isset($_REQUEST['do_fb']) ? $_REQUEST['do_fb'] : true));
		$smarty->assign('fblike', (isset($_REQUEST['fblike']) ? $_REQUEST['fblike'] : 1));
45
	} else {
46 47 48 49
		$smarty->assign('twitterRegistered', false);
		$smarty->assign('twitter', false);
		$smarty->assign('facebookRegistered', false);
		$smarty->assign('facebook', false);
50
	}
51

52
	// message related
53
	if (isset($prefs['feature_messages']) and $prefs['feature_messages'] == 'y') {
lphuberdeau's avatar
lphuberdeau committed
54
		$logslib = TikiLib::lib('logs');
55

56 57
		$smarty->assign('priority', (isset($_REQUEST['priority'])?$_REQUEST['priority']:3));
		$smarty->assign('do_message', (isset($_REQUEST['do_message'])?$_REQUEST['do_message']:true));
58 59
		$send_msg = ($tiki_p_messages == 'y');

60 61
		if ($prefs['allowmsg_is_optional'] == 'y') {
			if ($tikilib->get_user_preference($user, 'allowMsgs', 'y') != 'y') {
62
				$send_msg = false;
63
			}
64
		}
65
		$smarty->assign('send_msg', $send_msg);
66
	} else {
67
		$smarty->assign('send_msg', false);
68 69
	}

70
	if (isset($prefs['feature_forums']) and $prefs['feature_forums'] == 'y') {
71
		$commentslib = TikiLib::lib('comments'); // not done in commentslib
72 73
		$sort_mode = $prefs['forums_ordering'];
		$channels = $commentslib->list_forums(0, -1, $sort_mode, '');
74 75 76
		Perms::bulk(array( 'type' => 'forum' ), 'object', $channels['data'], 'forumId');
		$forums = array();
		$temp_max = count($channels['data']);
77
		for ($i = 0; $i < $temp_max; $i++) {
78
			$forumperms = Perms::get(array( 'type' => 'forum', 'object' => $channels['data'][$i]['forumId'] ));
79
			if (($forumperms->forum_post and $forumperms->forum_post_topic) or $forumperms->admin_forum) {
80
				$forums[] = $channels['data'][$i];
81
			}
82
		}
83
		$smarty->assign('forumId', (isset($_REQUEST['forumId']) ? $_REQUEST['forumId'] : 0));
84
	} else {
85
		$forums = array();
86
	}
87
	$smarty->assign('forums', $forums);
88
	$report='n';
89
} else {
90
	$report='y';
91
}
jonnybradley's avatar
jonnybradley committed
92
$smarty->assign('report', isset($_REQUEST['report']) ? $_REQUEST['report'] : '');
93

94
$errors = array();
95
$ok = true;
96 97 98

if (empty($_REQUEST['url']) && !empty($_SERVER['HTTP_REFERER'])) {
	$u = parse_url($_SERVER['HTTP_REFERER']);
99

100 101 102 103 104 105 106
	if ($u['host'] != $_SERVER['SERVER_NAME']) {
		$smarty->assign('msg', tra('Incorrect param'));
		$smarty->display('error.tpl');
		die;
	}
	$_REQUEST['url'] = $_REQUEST['HTTP_REFERER'];
}
107

108 109 110 111 112
if (empty($_REQUEST['url'])) {
	$smarty->assign('msg', tra('missing parameters'));
	$smarty->display('error.tpl');
	die;
}
113

114
$_REQUEST['url'] = urldecode($_REQUEST['url']);
115

116 117 118
if (strstr($_REQUEST['url'], 'tiki-share.php')) {
	$_REQUEST['url'] = preg_replace('/.*tiki-share.php\?url=/', '', $_REQUEST['url']);
	header('location: tiki-share.php?url=' . $_REQUEST['url']);
119
}
120 121

$url_for_friend = $tikilib->httpPrefix(true) . $_REQUEST['url'];
122

123 124
if ($report != 'y') {
	if (isset($_REQUEST['shorturl'])) {
125
		$shorturl = $_REQUEST['shorturl'];
126
	} else {
127 128
		if (isset($prefs['feature_socialnetworks']) and $prefs['feature_socialnetworks'] == 'y') {
			$shorturl = $socialnetworkslib->bitlyShorten($user, $url_for_friend);
129
		} else {
130
			$shorturl = false;
131
		}
132 133
		if ($shorturl == false) {
			$shorturl = $url_for_friend;
134
		}
135
	}
136
	$smarty->assign('shorturl', $shorturl);
137
}
138

139
$smarty->assign('url', $_REQUEST['url']);
140 141
$smarty->assign('prefix', $tikilib->httpPrefix(true));
$smarty->assign_by_ref('url_for_friend', $url_for_friend);
142
$smarty->assign('back_url', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
143 144 145 146 147

if (!empty($_REQUEST['subject'])) {
	$subject = $_REQUEST['subject'];
	$smarty->assign('subject', $subject);
} else {
148
	if ($report == 'y') {
149 150
		$subject = tra('Report to the webmaster', $prefs['site_language']);
	} else {
151
		$smarty->assign('mail_site', $_SERVER['SERVER_NAME']);
152 153 154
		$subject = $smarty->fetch('mail/share_subject.tpl');
	}
}
155

156
$smarty->assign('subject', $subject);
157 158

if (isset($_REQUEST['send'])) {
159

160
	if (!empty($_REQUEST['comment'])) {
161
		$smarty->assign('comment', $_REQUEST['comment']);
162
	}
163 164

	if (!empty($_REQUEST['share_token_notification'])) {
165 166
		$smarty->assign('share_token_notification', $_REQUEST['share_token_notification']);
	}
167 168

	if (!empty($_REQUEST['how_much_time_access'])) {
169 170
		$smarty->assign('how_much_time_access', $_REQUEST['how_much_time_access']);
	}
171

172
	check_ticket('share');
173 174
	if (empty($user) && $prefs['feature_antibot'] == 'y' && !$captchalib->validate()) {
		$errors[] = $captchalib->getErrors();
175
	} else {
176 177 178 179
		if ($report == 'y') {
			$email = !empty($prefs['feature_site_report_email']) ? $prefs['feature_site_report_email'] : (!empty($prefs['sender_email']) ? $prefs['sender_email'] : '');
			if (empty($email)) {
				$errors[] = tra("The mail can't be sent. Contact the administrator");
180
			}
181 182
			$_REQUEST['addresses'] = $email;
			$_REQUEST['do_email'] = 1;
183
		}
184 185 186 187 188 189 190 191

		if (isset ($_REQUEST['do_email']) and $_REQUEST['do_email'] == 1) {
			// send

			// Fix for multi adresses with autocomplete funtionnality
			if (substr($_REQUEST['addresses'], -2) == ', ') {
				$_REQUEST['addresses'] = substr($_REQUEST['addresses'], 0, -2);
			}
192 193
			// Call checkAddresses with error = false to avoid double error reporting
			$adresses = checkAddresses($_REQUEST['addresses'], false);
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216

			require_once 'lib/auth/tokens.php';
			if ($prefs['share_can_choose_how_much_time_access']
						&& isset($_REQUEST['how_much_time_access'])
						&& is_numeric($_REQUEST['how_much_time_access'])
						&& $_REQUEST['how_much_time_access'] >= 1
			) {
				$prefs['auth_token_access_maxhits'] = $_REQUEST['how_much_time_access'];

				/* To upload, you need 2 token: one to see the page and another */
				if (strpos($_REQUEST['url'], 'tiki-upload_file')) {
					$prefs['auth_token_access_maxhits'] = $prefs['auth_token_access_maxhits'] * 2 + 1;
				}

			}

			if ($_REQUEST['share_token_notification'] == 'y') {
				// list all users to give an unique token for notification
				$tokenlib = AuthTokens::build($prefs);

				if (is_array($adresses)) {
					$contactlib = TikiLib::lib('contact');
					foreach ($adresses as $adresse) {
217
						$tokenlist[] = $tokenlib->includeToken($url_for_friend, $globalperms->getGroups(), $adresse);
218 219 220 221 222 223 224
						// if preference share_contact_add_non_existant_contact the add auomaticly to contact
						if ($prefs['share_contact_add_non_existant_contact'] == 'y' && $prefs['feature_contacts'] == 'y') {
							// check if email exist for at least one contact in
							if (!$contactlib->exist_contact($adresse, $user)) {
								$contacts = array(array('email'=>$adresse));
								$contactlib->add_contacts($contacts, $user);
							}
225 226
						}
					}
227
				}
228 229 230 231 232

				$smarty->assign('share_access', true);

				if (is_array($tokenlist)) {
					foreach ($tokenlist as $i=>$data) {
233 234 235
						$query = parse_url($data);
						parse_str($query['query'],$query_vars);
						$detailtoken = $tokenlib->getToken($query_vars['TOKEN']);
236
						// Delete old user watch if it's necessary => avoid bad mails
237 238
						$tikilib->remove_user_watch_object('auth_token_called', $detailtoken['tokenId'], 'security');
						$tikilib->add_user_watch($user, 'auth_token_called', $detailtoken['tokenId'], 'security', tra('Token called'), $data);
239
					}
240
				}
241 242 243 244

			} else {
				if ( $prefs['auth_token_share'] == 'y' && ($prefs['auth_token_access'] == 'y' || isset($_POST['share_access']))) {
					$tokenlib = AuthTokens::build($prefs);
245
					$url_for_friend = $tokenlib->includeToken($url_for_friend, $globalperms->getGroups(), $_REQUEST['addresses']);
246
					$smarty->assign('share_access', true);
247
				}
248
				$tokenlist[0] = $url_for_friend;
249
			}
250 251 252 253 254

			$smarty->assign_by_ref('email', $_REQUEST['email']);

			if (!empty($_REQUEST['addresses'])) {
				$smarty->assign('addresses', $_REQUEST['addresses']);
255
			}
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270

			if (!empty($_REQUEST['name'])) {
				$smarty->assign('name', $_REQUEST['name']);
			}
			$emailSent = sendMail($_REQUEST['email'], $_REQUEST['addresses'], $subject, $tokenlist);
			$smarty->assign('emailSent', $emailSent);
			$ok = $ok && $emailSent;
		} // do_email

		if ($report != 'y') {
			if (isset ($_REQUEST['do_tweet']) and $_REQUEST['do_tweet'] == 1) {
				$tweet = substr($_REQUEST['tweet'], 0, 140);
				if (strlen($tweet) == 0) {
					$ok = false;
					$errors[] = tra("No text given for tweet");
271
				} else {
272 273 274 275 276 277 278 279
					$tweetId = $socialnetworkslib->tweet($tweet, $user);
					if ($tweetId > 0) {
						$smarty->assign('tweetId', $tweetId);
					} else {
						$ok = false;
						$tweetId =- $tweetId;
						$errors[] = tra('Error sending tweet:') . " $tweetId";
					}
280
				}
281 282 283 284 285 286 287 288 289 290 291 292
			} // do_tweet
			if (isset ($_REQUEST['do_fb']) and $_REQUEST['do_fb']==1) {
				$msg = $_REQUEST['comment'];
				$linktitle = $_REQUEST['fblinktitle'];
				$facebookId = $socialnetworkslib->facebookWallPublish($user, $msg, $url_for_friend, $linktitle, $_REQUEST['subject']);
				$smarty->assign('facebookId', $facebookId);
				$ok = $ok && ($facebookId != false);
				if ($_REQUEST['fblike'] == 1) {
					if ($facebookId != false) {
						$like = $socialnetworkslib->facebookLike($user, $facebookId);
						$ok = $ok && ($like != false);
					}
293
				}
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
			} // do_fb

			if (isset($_REQUEST['do_message']) and $_REQUEST['do_message'] == 1) {
				$messageSent = sendMessage($_REQUEST['messageto'], $subject);
				$smarty->assign('messageSent', $messageSent);
				$ok = $ok || $messageSent;
				if ($messageSent) {
					$errors = array();
				}
			} // do_message

			if (isset($_REQUEST['do_forum']) and $_REQUEST['do_forum'] == 1) {
				if (isset($_REQUEST['forumId'])) {
					$threadId = postForum($_REQUEST['forumId'], $subject);
					$smarty->assign('threadId', $threadId);
					$ok = $ok && ($threadId != 0);
				}
			} // do_forum
		} //report != y

		$smarty->assign('errortype', 'no_redirect_login');
		if ($ok && $report == 'y') {
			$access->redirect($_REQUEST['url'], tra('Your link was sent.'));
		}
		$smarty->assign('sent', true);
319
		$smarty->assign('back_url', $_REQUEST['back_url']);
320 321
	}
	$smarty->assign_by_ref('errors', $errors);
322 323 324 325
} else {
	$smarty->assign_by_ref('name', $user);
	$smarty->assign('email', $userlib->get_user_email($user));
}
326

327 328
ask_ticket('share');
$smarty->assign('mid', 'tiki-share.tpl');
329 330 331
$smarty->display('tiki.tpl');

/**
332
 *
333
 * Validates the given recipients and returns false on error or an array containing the recipients on success
334
 * @param array|string	$recipients		list of recipients as an array or a comma/semicolon separated list
335
 * @return array|bool
336
 */
337
function checkAddresses($recipients, $error = true)
338
{
339
	global $errors, $prefs, $user;
340 341 342
	$userlib = TikiLib::lib('user');
	$registrationlib = TikiLib::lib('registration');
	$logslib = TikiLib::lib('logs');
343 344 345

	$e = array();

346
	if (!is_array($recipients)) {
347
		$recipients = preg_split('/(,|;)/', $recipients);
348
	}
349 350 351

	$ok = true;

352
	foreach ($recipients as &$recipient) {
353
		$recipient = trim($recipient);
354 355 356 357 358 359
		if (function_exists('validate_email')) {
			$ok = validate_email($recipient, $prefs['validateEmail']);
		} else {
			$ret = $registrationlib->SnowCheckMail($recipient, '', 'mini');
			$ok = $ret[0];
		}
360
		if ( $error && !$ok) {
361 362
			$e[] = tra('One of the email addresses that was input is invalid:') . '&nbsp;' . $recipient;
			$logslib->add_log('share', tra('One of the email addresses that was input is invalid:') . ' ' . $recipient . ' ' . tra('by') . ' ' . $user);
363 364
		}
	}
365

366
	if (count($e) != 0) {
367
		$errors = array_merge($errors, $e);
368 369 370 371 372 373 374
		return false;
	} else {
		return $recipients;
	}
}

/**
375
 *
376
 * Sends a promotional email to the given recipients
377 378 379 380 381 382
 * @param string        $sender        Sender e-Mail address
 * @param string|array    $recipients    List of recipients either as array or comma/semi colon separated string
 * @param string        $subject    E-Mail subject
 * @param array            $tokenlist
 * @internal param string $url_for_friend URL to share
 * @return bool                        true on success / false if the supplied parameters were incorrect/missing or an error occurred sending the mail
383
 */
384 385
function sendMail($sender, $recipients, $subject, $tokenlist = array())
{
386 387 388 389 390
	global $errors, $prefs, $user;
	$userlib = TikiLib::lib('user');
	$smarty = TikiLib::lib('smarty');
	$registrationlib = TikiLib::lib('registration');
	$logslib = TikiLib::lib('logs');
391

392 393 394 395
	if (empty($sender)) {
		$errors[] = tra('Your email is mandatory');
		return false;
	}
396

397 398 399 400
	if (function_exists('validate_email')) {
		$ok = validate_email($sender, $prefs['validateEmail']);
	} else {
		$ret = $registrationlib->SnowCheckMail($sender, '', 'mini');
401
		$ok = $ret[0];
402
	}
403

404 405 406 407 408 409
	if ($ok) {
		$from = str_replace(array("\r", "\n"), '', $sender);
	} else {
		$errors[] = tra('Invalid email') . ': ' . $_REQUEST['email'];
		return false;
	}
410

411
	$recipients=checkAddresses($recipients);
412 413

	if ($recipients === false) {
414 415
		return false;
	}
416

417 418
	include_once ('lib/webmail/tikimaillib.php');
	$smarty->assign_by_ref('mail_site', $_SERVER['SERVER_NAME']);
419

420
	$applyFrom = (!empty($user) && $from == $userlib->get_user_email($user));
421

422
	$ok = true;
423
	foreach ($recipients as $i=>$recipient) {
424 425 426 427 428 429 430 431 432
		$mail = new TikiMail();

		$mail->setSubject($subject);

		if ($applyFrom) {
			$mail->setFrom($from);
			$mail->setReplyTo("<$from>");
		}

433 434 435 436 437
		if (count($tokenlist) > 1) {
			$url_for_friend = $tokenlist[$i];
		} else {
			$url_for_friend = $tokenlist[0];		// only one token if not "subscribing"
		}
438 439 440 441
		$smarty->assign('url_for_friend', $url_for_friend);
		$txt = $smarty->fetch('mail/share.tpl');
		// Rebuild email message texte
		$mail->setText($txt);
442 443
		$mailsent = $mail->send(array($recipient));
		if (!$mailsent) {
444
			$errors[] = tra('Error sending mail to'). " $recipient";
445
			$logslib->add_log('share', tra('Error sending mail to'). " $recipient "  . tra('by') .' ' . $user);
446 447
		} else {
			$logslib->add_log('share', tra('Share page').': '.$url_for_friend.' '.tra('to').' '.$recipient.' '.tra('by').' '.$user);
448 449 450 451 452
		}
		$ok = $ok && $mailsent;
	}
	return $ok;
}
453 454 455

/**
 * sends a message via the internal messaging to a list of recipients
456
 * @param string|array	$recipients	comma separated list (or array) of recipients
457 458 459
 * @param string		$subject	subject of the message
 * @return bool						true on success/sent to all users successfully
 */
460 461
function sendMessage($recipients, $subject)
{
462
	global $errors, $prefs, $user;
463
	$messulib = TikiLib::lib('message');
464 465 466 467
	$userlib = TikiLib::lib('user');
	$tikilib = TikiLib::lib('tiki');
	$smarty = TikiLib::lib('smarty');
	$logslib = TikiLib::lib('logs');
468 469

	$ok = true;
470
	if (!is_array($recipients)) {
drsassafras's avatar
drsassafras committed
471
		$arr_to = preg_split('/\s*(?<!\\\)[;,]\s*/', $recipients);
472
	} else {
473
		$arr_to = $recipients;
474
	}
drsassafras's avatar
drsassafras committed
475 476 477 478 479
    if ($prefs['user_selector_realnames_messu'] == 'y') {
        $groups = '';
        $arr_to = $userlib->find_best_user($arr_to, $groups, 'login');
    }

480
	$users = array();
481

482
	foreach ($arr_to as $a_user) {
483 484 485 486 487 488 489 490 491
		if (!empty($a_user)) {
			$a_user = str_replace('\\;', ';', $a_user);
			if ($userlib->user_exists($a_user)) {
				// mail only to users with activated message feature
				if ($prefs['allowmsg_is_optional'] != 'y' || $tikilib->get_user_preference($a_user, 'allowMsgs', 'y') == 'y') {
					// only send mail if nox mailbox size is defined or not reached yet
					if (($messulib->count_messages($a_user) < $prefs['messu_mailbox_size']) || ($prefs['messu_mailbox_size'] == 0)) {
						$users[] = $a_user;
					} else {
492 493
						$errors[] = tra('User %s can not receive messages, mailbox is full');
						$ok = false;
494 495
					}
				} else {
496 497
					$errors[] = tra('User %s can not receive messages');
					$ok = false;
498 499
				}
			} else {
500 501
				$errors[] = tra('Invalid user: %s');
				$ok = false;
502
			}
503 504
		}
	}
505

506
	$users = array_unique($users);
507
	$txt = $smarty->fetch('mail/share.tpl');
508

509
	foreach ($users as $a_user) {
510
		$messulib->post_message(
511 512 513 514 515 516 517 518
			$a_user,
			$user,
			$a_user,
			'',
			$subject,
			$txt,
			$_REQUEST['priority'],
			isset($_REQUEST['replyto_hash']) ? $_REQUEST['replyto_hash'] : ''
519 520
		);

521 522 523 524 525 526 527
		TikiLib::events()->trigger('tiki.user.message',
			array(
				'type' => 'user',
				'object' => $a_user,
				'user' => $user,
			)
		);
528
	}
529

530
	// Insert a copy of the message in the sent box of the sender
531
	$messulib->save_sent_message(
532 533 534 535 536 537 538 539
		$user,
		$user,
		$recipients,
		'',
		$subject,
		$txt,
		$_REQUEST['priority'],
		isset($_REQUEST['replyto_hash']) ? $_REQUEST['replyto_hash'] : ''
540 541
	);

drsassafras's avatar
drsassafras committed
542 543 544 545
    // Assign users e-mail was sent to a SMARTY variable to be displayed:
    $users_string = implode(',  ', $users);
    $smarty->assign('messageSentTo', $users_string);

546 547 548
	if ($prefs['feature_actionlog'] == 'y') {
		$logslib->add_action('Posted', '', 'message', 'add=' . strlen($_REQUEST['body']));
	}
549

550 551 552
	return $ok;
}

553 554 555 556 557
/**
 * @param $forumId
 * @param $subject
 * @return bool|int
 */
558 559
function postForum($forumId, $subject)
{
560
	global $errors, $prefs, $user;
561
	global $feedbacks;
562 563 564 565
	$userlib = TikiLib::lib('user');
	$tikilib = TikiLib::lib('tiki');
	$smarty = TikiLib::lib('smarty');
	$commentslib = TikiLib::lib('comments');
566 567

	$forum_info = $commentslib->get_forum($forumId);
568 569
	$forumperms = Perms::get(array( 'type' => 'forum', 'object' => $forumId ));

570
	if (!($forumperms->forum_post and $forumperms->forum_post_topic) or !$forumperms->admin_forum) {
571
		$errors[] = tra("You don't have permission to post in this forum");
572 573
		return 0;
	}
574

575 576
	if ($forum_info['is_locked'] == 'y') {
		// this is a "die" in $commentslib->post_in_forum so we must check here
577
		$errors[] = tra('This forum is locked');
578 579
		return 0;
	}
580

581 582
	$postErrors = array();
	$feedbacks = array();
583
	$txt = $smarty->fetch('mail/share.tpl');
584 585 586 587

	$data = array(
				'comments_title' => $subject,
				'comments_data' => $txt,
588 589 590
				'password' => $_REQUEST['forum_password'],
				'comments_threadId' => 0,
				'forumId' => $forumId,
591 592
	);

593
	$threadId = $commentslib->post_in_forum($forum_info, $data, $feedbacks, $postErrors);
594

595 596 597
	if (count($postErrors)>0) {
		$errors = array_merge($errors, $postErrors);
	}
598

599 600
	$smarty->assign('feedbacks', $feedbacks);
	return $threadId;
601
}