1 |
2
|
Manuela
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category module
|
5 |
|
|
* @package droplet
|
6 |
|
|
* @author Ruud Eisinga (Ruud) John (PCWacht)
|
7 |
|
|
* @author WebsiteBaker Project
|
8 |
|
|
* @copyright Ryan Djurovich
|
9 |
|
|
* @copyright WebsiteBaker Org. e.V.
|
10 |
|
|
* @link http://websitebaker.org/
|
11 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
12 |
|
|
* @platform WebsiteBaker 2.8.3
|
13 |
|
|
* @requirements PHP 5.3.6 and higher
|
14 |
|
|
* @version $Id$
|
15 |
|
|
* @filesource $HeadURL$
|
16 |
|
|
* @lastmodified $Date$
|
17 |
|
|
*
|
18 |
|
|
*/
|
19 |
|
|
/* -------------------------------------------------------- */
|
20 |
|
|
// Must include code to stop this file being accessed directly
|
21 |
|
|
if(defined('WB_PATH') == false) { die('Illegale file access /'.basename(__DIR__).'/'.basename(__FILE__).''); }
|
22 |
|
|
/* -------------------------------------------------------- */
|
23 |
|
|
$msg = array();
|
24 |
|
|
if (!$oApp->get_permission($sAddonName,'module' ) ) {
|
25 |
|
|
$oApp->print_error($oTrans->MESSAGE_ADMIN_INSUFFICIENT_PRIVELLIGES, $js_back);
|
26 |
|
|
exit();
|
27 |
|
|
}
|
28 |
|
|
// Get userid for showing admin only droplets or not
|
29 |
|
|
$loggedin_user = ($oApp->ami_group_member('1') ? 1 : $oApp->get_user_id() );
|
30 |
|
|
$loggedin_group = $oApp->get_groups_id();
|
31 |
|
|
$oApp_user = (($oApp->get_home_folder() == '') && ($oApp->ami_group_member('1') ) || ($loggedin_user == '1'));
|
32 |
|
|
//removes empty entries from the table so they will not be displayed
|
33 |
|
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'mod_droplets` '
|
34 |
|
|
. 'WHERE name = \'\' ';
|
35 |
|
|
if( !$oDb->query($sql) ) {
|
36 |
|
|
$msg[] = $oDb->get_error();
|
37 |
|
|
}
|
38 |
|
|
// if import failed after installation, should be only 1 time
|
39 |
|
|
$sql = 'SELECT COUNT(`id`) FROM `'.TABLE_PREFIX.'mod_droplets` ';
|
40 |
|
|
if( !$oDb->get_one($sql) ) {
|
41 |
|
|
include($sAddonPath.'/install.php');
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
function check_syntax($code) {
|
45 |
|
|
if (class_exists('ParseError')) {
|
46 |
|
|
$bRetval = true;
|
47 |
|
|
try{
|
48 |
|
|
$bRetval = (@eval('return true;' . $code));
|
49 |
|
|
} catch(ParseError $e) {
|
50 |
|
|
$bRetval = false;
|
51 |
|
|
}
|
52 |
|
|
} else {
|
53 |
|
|
$bRetval = false;
|
54 |
|
|
$bRetval = (@eval('return true;' . $code));
|
55 |
|
|
}
|
56 |
|
|
return $bRetval;
|
57 |
|
|
}
|
58 |
|
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_droplets` ';
|
59 |
|
|
if (!$oApp_user) {
|
60 |
|
|
$sql .= 'WHERE `admin_view` <> 1 ';
|
61 |
|
|
}
|
62 |
|
|
$sql .= 'ORDER BY `modified_when` DESC';
|
63 |
|
|
$oDroplets = $oDb->query($sql);
|
64 |
|
|
$num_droplets = $oDroplets->numRows();
|
65 |
|
|
$aFtan = $admin->getFTAN('');
|
66 |
|
|
// prepare default data for phplib and twig
|
67 |
|
|
$aTplData = array (
|
68 |
|
|
'action' => $action,
|
69 |
|
|
'FTAN_NAME' => $aFtan['name'],
|
70 |
|
|
'FTAN_VALUE' => $aFtan['value'],
|
71 |
|
|
'IDKEY0' => $oApp->getIDKEY(0),
|
72 |
|
|
);
|
73 |
|
|
// Create new template object with phplib IDKEY0
|
74 |
|
|
$oTpl = new Template($sAddonThemePath, 'keep' );
|
75 |
|
|
$oTpl->set_file('page', 'overview.htt');
|
76 |
|
|
$oTpl->set_block('page', 'main_block', 'main');
|
77 |
|
|
$oTpl->set_var($aLang);
|
78 |
|
|
$oTpl->set_var($aTplDefaults);
|
79 |
|
|
$oTpl->set_var($aTplData);
|
80 |
|
|
$oTpl->set_block('main_block', 'list_droplet_block', 'list_droplet');
|
81 |
|
|
/*----------------------------------------------------------------------------------------------------------------------*/
|
82 |
|
|
while($aDroplets = $oDroplets->fetchRow(MYSQLI_ASSOC))
|
83 |
|
|
{
|
84 |
|
|
$aComment = array();
|
85 |
|
|
$modified_user = $TEXT['UNKNOWN'];
|
86 |
|
|
$modified_userid = 0;
|
87 |
|
|
$sql = 'SELECT `display_name`,`username`, `user_id` FROM `'.TABLE_PREFIX.'users` '
|
88 |
|
|
.'WHERE `user_id` = '.$aDroplets['modified_by'];
|
89 |
|
|
$get_modified_user = $oDb->query($sql);
|
90 |
|
|
if($get_modified_user->numRows() > 0) {
|
91 |
|
|
$fetch_modified_user = $get_modified_user->fetchRow(MYSQLI_ASSOC);
|
92 |
|
|
$modified_user = $fetch_modified_user['username'];
|
93 |
|
|
$modified_userid = $fetch_modified_user['user_id'];
|
94 |
|
|
}
|
95 |
|
|
$sDropletName = mb_strlen($aDroplets['name']) > 20 ? mb_substr($aDroplets['name'], 0, 19).'…' : $aDroplets['name'];
|
96 |
|
|
# $sDropletDescription = mb_strlen($aDroplets['description']) > 60 ? mb_substr($aDroplets['description'], 0, 59).'…' : $aDroplets['description'];
|
97 |
|
|
$sDropletDescription = $aDroplets['description'];
|
98 |
|
|
// $iDropletIdKey = $aDroplets['id'];
|
99 |
|
|
$iDropletIdKey = $oApp->getIDKEY($aDroplets['id']);
|
100 |
|
|
$comments = '';
|
101 |
|
|
// $comments = str_replace(array("\r\n", "\n", "\r"), '<br >', $aDroplets['comments']);
|
102 |
|
|
if (!strpos($comments,"[[")) $comments = "Use: [[".$aDroplets['name']."]]<br />".$comments;
|
103 |
|
|
$comments = str_replace(array("[[", "]]"), array('<b>[[',']]</b>'), $comments);
|
104 |
|
|
$valid_code = true;
|
105 |
|
|
$valid_code = check_syntax($aDroplets['code']);
|
106 |
|
|
if (!$valid_code === true) $comments = '<span color=\'red\'><strong>'.$oTrans->DR_TEXT_INVALIDCODE.'</strong></span><br />'.$comments;
|
107 |
|
|
$unique_droplet = true;
|
108 |
|
|
if ($unique_droplet === false ) {$comments = '<span color=\'red\'><strong>'.$oTrans->DR_TEXT_NOTUNIQUE.'</strong></span><br />'.$comments;}
|
109 |
|
|
|
110 |
|
|
$aTplData = array(
|
111 |
|
|
'iDropletIdKey' => $iDropletIdKey,
|
112 |
|
|
'sDropletName' => $sDropletName,
|
113 |
|
|
'sDropletTitle' => $aDroplets['name'],
|
114 |
|
|
'comments' => '',
|
115 |
|
|
'icon' => ($valid_code && $unique_droplet ? 'droplet' : 'invalid'),
|
116 |
|
|
'sDropletDescription' => $sDropletDescription,
|
117 |
|
|
'DropletId' => $aDroplets['id'],
|
118 |
|
|
'iDropletId' => $aDroplets['id'],
|
119 |
|
|
'modified_when' => date('d.m.Y'.' '.'H:i', $aDroplets['modified_when']+TIMEZONE),
|
120 |
|
|
'active' => $aDroplets['id'],
|
121 |
|
|
'ActiveIcon' => ($aDroplets['active']?'1':'0'),
|
122 |
|
|
);
|
123 |
|
|
/*----------------------------------------------------------------------------------------------------------------------*/
|
124 |
|
|
$oTpl->set_var($aTplData);
|
125 |
|
|
$oTpl->parse('list_droplet', 'list_droplet_block', true);
|
126 |
|
|
}
|
127 |
|
|
/*-- finalize the page -----------------------------------------------------------------*/
|
128 |
|
|
$oTpl->parse('main', 'main_block', false);
|
129 |
|
|
$oTpl->pparse('output', 'page');
|