This repository has been archived by the owner on Feb 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
contribution.php
67 lines (59 loc) · 2.47 KB
/
contribution.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
* @package tikiwiki
*/
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
// 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.
// $Id$
// the script uses the var $_REQUEST['contributions'] = the list of selected contributions to preselect the contributions
// $contributionItemId = the commentId if the object exists and you want to preselect the comment contribuions
// $section: to know where you are
// param: $contributionItemId: id of the comment if in coment/forum
if (basename($_SERVER['SCRIPT_NAME']) === basename(__FILE__)) {
die('This script may only be included.');
}
require_once('tiki-setup.php');
global $prefs;
if ($prefs['feature_contribution'] == 'y') {
$contributionlib = TikiLib::lib('contribution');
$contributions = $contributionlib->list_contributions();
if (! empty($_REQUEST['contributions'])) {
for ($i = $contributions['cant'] - 1; $i >= 0; -- $i) {
if (in_array($contributions['data'][$i]['contributionId'], $_REQUEST['contributions'])) {
$contributions['data'][$i]['selected'] = 'y';
$oneSelected = 'y';
}
}
}
if (! empty($contributionItemId)) {
$assignedContributions = $contributionlib->get_assigned_contributions($contributionItemId, 'comment');
if (! empty($assignedContributions)) {
foreach ($assignedContributions as $a) {
for ($i = $contributions['cant'] - 1; $i >= 0; -- $i) {
if ($a['contributionId'] == $contributions['data'][$i]['contributionId']) {
$contributions['data'][$i]['selected'] = 'y';
$oneSelected = 'y';
break;
}
}
}
}
}
if (! empty($oneSelected)) {
if ((isset($section) && $section == 'forum' && $prefs['feature_contribution_mandatory_forum'] != 'y') || ((! isset($section) || $section != 'forum') && $prefs['feature_contribution_mandatory_comment'] != 'y')) {
$contributions['data'][] = ['contributionId' => 0, 'name' => ''];
}
}
$smarty->assign_by_ref('contributions', $contributions['data']);
if ($prefs['feature_contributor_wiki'] == 'y' && ! empty($section) && $section == 'wiki page') {
$users = $userlib->list_all_users();
include_once('lib/smarty_tiki/modifier.username.php');
$users = array_map('smarty_modifier_username', $users);
$smarty->assign_by_ref('users', $users);
if (! empty($_REQUEST['contributors'])) {
$smarty->assign_by_ref('contributors', $_REQUEST['contributors']);
}
}
}