Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         news
6
 * @author          WebsiteBaker Project
7
 * @copyright       WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.3
11
 * @requirements    PHP 5.3.6 and higher
12
 * @version         $Id: modify.php 2 2017-07-02 15:14:29Z Manuela $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/modules/news/modify.php $
14
 * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
15
 *
16
 */
17
/* -------------------------------------------------------- */
18
// Must include code to stop this file being accessed directly
19
if(defined('WB_PATH') == false) { die('Illegale file access /'.basename(__DIR__).'/'.basename(__FILE__).''); }
20
/* -------------------------------------------------------- */
21
//overwrite php.ini on Apache servers for valid SESSION ID Separator
22
if(function_exists('ini_set')) {
23
    ini_set('arg_separator.output', '&amp;');
24
}
25

    
26
$sql = 'DELETE FROM `'.TABLE_PREFIX.'mod_news_posts`  WHERE `section_id` = 0 OR title=\'\'';
27
$database->query($sql);
28

    
29
$sql = 'DELETE FROM `'.TABLE_PREFIX.'mod_news_groups`  WHERE `section_id` = 0 OR title=\'\'';
30
$database->query($sql);
31

    
32
$sAppUrl = WB_URL;
33
$sModulName = basename(__DIR__);
34
$ModuleRel = '/modules/'.basename(__DIR__).'/';
35
$sAddonUrl = $ModuleUrl = WB_URL.'/modules/'.basename(__DIR__).'/';
36
$ModulePath = WB_PATH.'/modules/'.basename(__DIR__).'/';
37
$sAddonThemeUrl = $sAddonUrl.'templates/default/';
38

    
39
$FTAN = $admin->getFTAN('');
40
$sFtan = $FTAN['name'].'='.$FTAN['value'];
41
// load module language file
42
$sModulName = $sAddonName = basename(__DIR__);
43
require(WB_PATH .'/modules/'.$sAddonName.'/languages/EN.php');
44
if(file_exists(WB_PATH .'/modules/'.$sAddonName.'/languages/'.LANGUAGE .'.php')) {
45
    require(WB_PATH .'/modules/'.$sAddonName.'/languages/'.LANGUAGE .'.php');
46
}
47

    
48
if( !function_exists( 'make_dir' ) )  {  require(WB_PATH.'/framework/functions.php');  }
49

    
50
?>
51
<script type="text/javascript">
52
<!--
53
var News = {
54
    WB_URL : '<?php echo $sAppUrl;?>',
55
    AddonUrl : '<?php echo $sAddonUrl;?>',
56
    THEME_URL : '<?php echo THEME_URL;?>',
57
    ThemeUrl:  '<?php echo $sAddonThemeUrl;?>'
58
};
59
-->
60
</script>
61

    
62
<table style="width: 100%;">
63
<?php  ?>
64
<tbody>
65
<tr style="width: 100%; line-height: 2.825em;">
66
    <td style="width: 25%;">
67
        <form action="<?php echo WB_URL; ?>/modules/news/add_post.php" method="get" >
68
            <input type="hidden" value="<?php echo $page_id; ?>" name="page_id">
69
            <input type="hidden" value="<?php echo $section_id; ?>" name="section_id">
70
            <input type="hidden" value="<?php echo $FTAN['value'];?>" name="<?php echo $FTAN['name'];?>">
71
            <input type="submit" value="<?php echo $TEXT['ADD'].' '.$TEXT['POST']; ?>" class="btn btn-default w3-blue-wb w3-round-small w3-hover-green w3-medium w3-padding-4" style="width: 100%;" />
72
        </form>
73
    </td>
74
    <td style="width: 25%;">
75
        <form action="<?php echo WB_URL; ?>/modules/news/add_group.php" method="get" >
76
            <input type="hidden" value="<?php echo $page_id; ?>" name="page_id">
77
            <input type="hidden" value="<?php echo $section_id; ?>" name="section_id">
78
            <input type="hidden" value="<?php echo $FTAN['value'];?>" name="<?php echo $FTAN['name'];?>">
79
            <input type="submit" value="<?php echo $TEXT['ADD'].' '.$TEXT['GROUP']; ?>" class="btn btn-default w3-blue-wb w3-round-small w3-hover-green w3-medium w3-padding-4" style="width: 100%;" />
80
        </form>
81
    </td>
82
    <td style="width: 25%;">
83
        <form action="<?php echo WB_URL; ?>/modules/news/modify_settings.php" method="get" >
84
            <input type="hidden" value="<?php echo $page_id; ?>" name="page_id">
85
            <input type="hidden" value="<?php echo $section_id; ?>" name="section_id">
86
            <input type="hidden" value="<?php echo $FTAN['value'];?>" name="<?php echo $FTAN['name'];?>">
87
            <input type="submit" value="<?php echo $TEXT['SETTINGS']; ?>" class="btn btn-default w3-blue-wb w3-round-small w3-hover-green w3-medium w3-padding-4" style="width: 100%;" />
88
        </form>
89
    </td>
90
<?php if(defined('DEBUG')&& DEBUG && $admin->ami_group_member('1') ) {  ?>
91
    <td style="width: 25%;">
92
        <form action="<?php echo WB_URL; ?>/modules/news/reorgPosition.php" method="get" >
93
            <input type="hidden" value="<?php echo $page_id; ?>" name="page_id">
94
            <input type="hidden" value="<?php echo $section_id; ?>" name="section_id">
95
            <input type="hidden" value="<?php echo $FTAN['value'];?>" name="<?php echo $FTAN['name'];?>">
96
            <input type="submit" value="Reorg Position" class="btn btn-default w3-blue-wb w3-round-small w3-hover-green w3-medium w3-padding-4" style="width: 100%;" />
97
        </form>
98
    </td>
99
<?php } ?>
100
</tr>
101
</tbody>
102
</table>
103

    
104
<br />
105

    
106
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['POST']; ?></h2>
107

    
108
<?php
109

    
110
$sSortOrder = 'DESC'; // ASC/DESC
111

    
112
// Loop through existing posts
113
    $sql  = 'SELECT * FROM `'.TABLE_PREFIX.'mod_news_posts` '
114
          . 'WHERE `section_id` = '.$section_id.' '
115
          . 'ORDER BY `position`'.$sSortOrder;
116
    $oPosts = $database->query($sql);
117
    if ($oPosts->numRows() > 0) {
118
        $num_posts = $oPosts->numRows();
119
?><div class="jsadmin hide"></div>
120
    <div class="outer">
121
        <table class="news-post w3-table w3-border w3-hoverable w3-stripped table-scroll sortierbar" id="tableData"  >
122
            <thead>
123
                <tr class="w3-header-blue-wb">
124
                    <th class="action"><span>&nbsp;</span></th>
125
                    <th class="title sortierbar" style="padding-left: 5px; text-align: left;"><span><?php print $TEXT['POST']; ?></span></th>
126
                    <th class="group sortierbar" style=" text-align: left; "><span><?php print $TEXT['GROUP']; ?></span></th>
127
                    <th class="status" style="padding-right: 5px; text-align: left; "><span><?php print $TEXT['COMMENTS']; ?></span></th>
128
                    <th class="active" style=" text-align: left; " ><span><?php print $TEXT['ACTIVE']; ?></span></th>
129
                    <th class="action"><span>&nbsp;</span></th>
130
                    <th class="action"><span>&nbsp;</span></th>
131
                    <th class="action"><span>&nbsp;</span></th>
132
                    <th class="action"><span>&nbsp;</span></th>
133
                    <th class="sortierbar vorsortiert-" style="padding-right: 8px; "><span>Pos</span></th>
134
                </tr>
135
            </thead>
136
            <tbody>
137
        <?php
138
        while($post = $oPosts->fetchRow( MYSQLI_ASSOC )) {
139
            $pid = $admin->getIDKEY($post['post_id']);
140
            $sid = $admin->getIDKEY($section_id);
141
            $iPostId = intval($post['post_id']);
142
            if ($post['active'] == 1) {
143
                $activ_string = $TEXT['ENABLED'];
144
            } else {
145
                $activ_string = $TEXT['DISABLED'];
146
            }
147

    
148
            ?>
149
            <tr class=" sectionrow">
150
                <td class="action" style="text-align: center;">
151
                    <a href="<?php echo WB_URL; ?>/modules/news/modify_post.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
152
                        <img src="<?php echo THEME_URL; ?>/images/modify_16.png"  alt="Modify - " />
153
                    </a>
154
                </td>
155
                <td class="title" style="padding-left: 5px; ">
156
                    <a href="<?php echo WB_URL; ?>/modules/news/modify_post.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>">
157
                        <?php echo ($post['title']); ?>
158
                    </a>
159
                </td>
160
                <td class="group">
161
                    <?php
162
                    // Get group title
163
                    $sqlGroups  = 'SELECT `title`   FROM `'.TABLE_PREFIX.'mod_news_groups`  WHERE `group_id` = \''.$post['group_id'].'\'';
164
                    $oGroups = $database->query($sqlGroups);
165
                    if($oGroups->numRows() > 0) {
166
                        $fetch_title = $oGroups->fetchRow( MYSQLI_ASSOC );
167
                        echo ($fetch_title['title']);
168
                    } else {
169
                        echo $TEXT['NONE'];
170
                    }
171
                    ?>
172
                </td>
173
                <td class="status">
174
                    <?php
175
                    // Get number of comments
176
                    $sqlComment = 'SELECT COUNT(*) `iComment` FROM `'.TABLE_PREFIX.'mod_news_comments` WHERE `post_id` = \''.$post['post_id'].'\'';
177
                    $iComment = $database->get_one($sqlComment);
178
                    echo $iComment;
179
                    ?>
180
                </td>
181
                <td id="id_<?php echo $iPostId; ?>" class="toggle_active_status">
182
                    <img id="active_<?php echo $iPostId; ?>" src="<?php echo $sAddonThemeUrl; ?>img/24/status_<?php echo (int)$post['active'];?>.png" alt=""  />
183
                </td>
184
                <td >
185
                <?php
186
                $start = $post['published_when'];
187
                $end = $post['published_until'];
188
                $t = time();
189
                $icon = '';
190
                if($start<=$t && $end==0)
191
                    $icon=THEME_URL.'/images/noclock_16.png';
192
                elseif(($start<=$t || $start==0) && $end>=$t)
193
                    $icon=THEME_URL.'/images/clock_16.png';
194
                else
195
                    $icon=THEME_URL.'/images/clock_red_16.png';
196
                ?>
197
                <a href="<?php echo WB_URL; ?>/modules/news/modify_post.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
198
                    <img src="<?php echo $icon; ?>" alt="" />
199
                </a>
200
                </td>
201
                <td style="text-align: center;">
202

    
203
                <?php if ((($sSortOrder=='DESC'))&&($post['position'] > 1)&&($post['position'] < $num_posts)) { ?>
204
                    <a href="<?php echo WB_URL; ?>/modules/news/move_down.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;move_id=<?php echo $iPostId; ?>&amp;position=<?php echo $post['position']; ?>&amp;module=<?php echo $sModulName; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
205
                        <img src="<?php echo THEME_URL; ?>/images/up_16.png" alt="^" />
206
                    </a>
207
                <?php } else if (($post['position'] > 1)&&($post['position'] < $num_posts)) { ?>
208
                    <a href="<?php echo WB_URL; ?>/modules/news/move_up.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;move_id=<?php echo $iPostId; ?>&amp;position=<?php echo $post['position']; ?>&amp;module=<?php echo $sModulName; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
209
                        <img src="<?php echo THEME_URL; ?>/images/up_16.png" alt="^" />
210
                    </a>
211
                <?php } else if ((empty($sSortOrder)||($sSortOrder=='ASC'))&&($post['position'] == $num_posts)){ ?>
212
                    <a href="<?php echo WB_URL; ?>/modules/news/move_up.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;move_id=<?php echo $iPostId; ?>&amp;position=<?php echo $post['position']; ?>&amp;module=<?php echo $sModulName; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
213
                        <img src="<?php echo THEME_URL; ?>/images/up_16.png" alt="^" />
214
                    </a>
215
                <?php } else if ((($sSortOrder=='DESC'))&&($post['position'] == 1)){ ?>
216
                    <a href="<?php echo WB_URL; ?>/modules/news/move_down.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;move_id=<?php echo $iPostId; ?>&amp;position=<?php echo $post['position']; ?>&amp;module=<?php echo $sModulName; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
217
                        <img src="<?php echo THEME_URL; ?>/images/up_16.png" alt="^" />
218
                    </a>
219
                <?php } ?>
220
                </td>
221

    
222
                <td style="text-align: center;">
223
                <?php if (($post['position'] > 1)&&($post['position'] < $num_posts)) { ?>
224
                    <a href="<?php echo WB_URL; ?>/modules/news/move_down.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;move_id=<?php echo $iPostId; ?>&amp;position=<?php echo $post['position']; ?>&amp;module=<?php echo $sModulName; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
225
                        <img src="<?php echo THEME_URL; ?>/images/down_16.png" alt="v" />
226
                    </a>
227
                <?php } else if ((empty($sSortOrder)||($sSortOrder=='ASC'))&&($post['position'] == 1)){ ?>
228
                    <a href="<?php echo WB_URL; ?>/modules/news/move_down.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;move_id=<?php echo $iPostId; ?>&amp;position=<?php echo $post['position']; ?>&amp;module=<?php echo $sModulName; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
229
                        <img src="<?php echo THEME_URL; ?>/images/down_16.png" alt="^" />
230
                    </a>
231
                <?php } else if ((($sSortOrder=='DESC'))&&($post['position'] == $num_posts)){ ?>
232
                    <a href="<?php echo WB_URL; ?>/modules/news/move_up.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;move_id=<?php echo $iPostId; ?>&amp;position=<?php echo $post['position']; ?>&amp;module=<?php echo $sModulName; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
233
                        <img src="<?php echo THEME_URL; ?>/images/down_16.png" alt="^" />
234
                    </a>
235
                <?php } ?>
236

    
237
                </td>
238
                <td style="text-align: center;">
239
                    <a href="javascript:confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>','<?php echo WB_URL; ?>/modules/news/delete_post.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
240
                        <img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="X" />
241
                    </a>
242
                </td>
243
                <td style="text-align: right;"><?php echo $post['position']; ?></td>
244
            </tr>
245
            <?php
246
        }
247
        ?>
248
            </tbody>
249
        </table>
250
    </div>
251
    <?php
252
} else {
253
    echo $TEXT['NONE_FOUND'];
254
}
255

    
256
?>
257

    
258
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['GROUP']; ?></h2>
259

    
260
<?php
261

    
262
// Loop through existing groups
263
$query_groups = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_news_groups` WHERE section_id = '$section_id' ORDER BY position");
264
if($query_groups->numRows() > 0) {
265
    $num_groups = $query_groups->numRows();
266
    ?>
267
    <table class="news-group w3-table" id="NewsGroupDataTable" >
268
        <colgroup class="action">
269
          <col />
270
        </colgroup>
271
        <colgroup class="title">
272
          <col />
273
        </colgroup>
274
        <colgroup class="group">
275
          <col />
276
        </colgroup>
277
        <colgroup class="status">
278
          <col />
279
        </colgroup>
280
        <colgroup class="active">
281
          <col />
282
        </colgroup>
283
        <colgroup class="action">
284
          <col />
285
          <col />
286
          <col />
287
          <col />
288
          <col />
289
        </colgroup>
290
        <thead>
291
            <tr class=" w3-header-blue-wb">
292
                <th style="padding-left: 5px;">&nbsp;</th>
293
                <th style="padding-left: 5px; text-align: left;"><?php print $TEXT['GROUP']; ?></th>
294
                <th > </th>
295
                <th > </th>
296
                <th ><?php print $TEXT['ACTIVE']; ?></th>
297
                <th > </th>
298
                <th > </th>
299
                <th > </th>
300
                <th > </th>
301
                <th style="padding-right: 4px;">Pos</th>
302
            </tr>
303
        </thead>
304
        <tbody>
305
    <?php
306
    while($group = $query_groups->fetchRow( MYSQLI_ASSOC )) {
307
        $gid = $admin->getIDKEY($group['group_id']);
308
        ?>
309
        <tr>
310
            <td style="padding-left: 5px; text-align: center;">
311
                <a href="<?php echo WB_URL; ?>/modules/news/modify_group.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;group_id=<?php echo $gid; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
312
                    <img src="<?php echo THEME_URL; ?>/images/modify_16.png" alt="Modify - " />
313
                </a>
314
            </td>
315
            <td style="padding-left: 5px;">
316
                <a href="<?php echo WB_URL; ?>/modules/news/modify_group.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;group_id=<?php echo $gid; ?>">
317
                    <?php echo $group['title']; ?>
318
                </a>
319
            </td>
320
            <td  style="text-align: right;"> </td>
321
            <td  style="text-align: right;"> </td>
322
            <td  style="text-align: center;">
323
                <?php if($group['active'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; } ?>
324
            </td>
325
            <td  style="text-align: right;"> </td>
326
            <td  style="text-align: center;">
327
            <?php if($group['position'] != 1 ) { ?>
328
                <a href="<?php echo WB_URL; ?>/modules/news/move_up.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;group_id=<?php echo $gid; ?>&amp;move_id=<?php echo $group['group_id']; ?>&amp;position=<?php echo $group['position']; ?>&amp;module=<?php echo $sModulName; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
329
                    <img src="<?php echo THEME_URL; ?>/images/up_16.png" alt="^" />
330
                </a>
331
            <?php } ?>
332
            </td>
333
            <td  style="text-align: center;">
334
            <?php if($group['position'] != $num_groups ) { ?>
335
                <a href="<?php echo WB_URL; ?>/modules/news/move_down.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;group_id=<?php echo $gid; ?>&amp;move_id=<?php echo $group['group_id']; ?>&amp;position=<?php echo $group['position']; ?>&amp;module=<?php echo $sModulName; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
336
                    <img src="<?php echo THEME_URL; ?>/images/down_16.png" alt="v" />
337
                </a>
338
            <?php } ?>
339
            </td>
340
            <td  style="text-align: center;">
341
                <a href="javascript:confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/news/delete_group.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;group_id=<?php echo $gid; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
342
                    <img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="X" />
343
                </a>
344
            </td>
345
            <td  style="text-align: right;"><?php echo $group['position']; ?></td>
346
        </tr>
347
        <?php
348
    }
349
    ?>
350
        </tbody>
351
    </table>
352
    <script src="<?php echo $ModuleUrl;?>templates/default/js/TableSort.js" type="text/javascript"></script>
353

    
354
<?php
355
} else {
356
    echo $TEXT['NONE_FOUND'];
357
}
358
    // include the required file for Javascript admin
359
    if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
360
    {
361
//        $js_buttonCell = 6;
362
        include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
363
    }
(18-18/36)