Skip to content

Commit 42185e3

Browse files
committedNov 27, 2022
initial commit from postslistOptions 2013.07.10
0 parents  commit 42185e3

File tree

7 files changed

+599
-0
lines changed

7 files changed

+599
-0
lines changed
 

‎LICENSE

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

‎_admin.php

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
<?php
2+
# -- BEGIN LICENSE BLOCK ----------------------------------
3+
#
4+
# This file is part of postslistOptions, a plugin for Dotclear 2.
5+
#
6+
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
7+
# contact@jcdenis.fr http://jcd.lv
8+
#
9+
# Licensed under the GPL version 2.0 license.
10+
# A copy of this license is available in LICENSE file or at
11+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12+
#
13+
# -- END LICENSE BLOCK ------------------------------------
14+
15+
if (!defined('DC_CONTEXT_ADMIN')){return;}
16+
17+
if (!$core->auth->check('admin',$core->blog->id)) { return; }
18+
19+
$core->addBehavior('adminPostsActionsCombo',array('behaviorsPostlistOptions','adminPostsActionsCombo'));
20+
$core->addBehavior('adminPostsActionsContent',array('behaviorsPostlistOptions','adminPostsActionsContent'));
21+
$core->addBehavior('adminPostsActions',array('behaviorsPostlistOptions','adminPostsActions'));
22+
23+
class behaviorsPostlistOptions
24+
{
25+
public static function adminPostsActionsCombo($args)
26+
{
27+
if (!$GLOBALS['core']->auth->check('admin',$GLOBALS['core']->blog->id)) return;
28+
29+
$args[0][__('Comments')][__('Mark as opened')] = 'commentsopen';
30+
$args[0][__('Comments')][__('Mark as closed')] = 'commentsclose';
31+
$args[0][__('Comments')][__('Delete all comments')] = 'commentsdelete';
32+
$args[0][__('Trackbacks')][__('Mark as opened')] = 'trackbacksopen';
33+
$args[0][__('Trackbacks')][__('Mark as closed')] = 'trackbacksclose';
34+
$args[0][__('Trackbacks')][__('Delete all trackbacks')] = 'trackbacksdelete';
35+
}
36+
37+
public static function adminPostsActionsContent($core,$action,$hidden_fields)
38+
{
39+
$allow = array(
40+
'commentsdelete' => __('Are you sure you want to delete all comments?'),
41+
'trackbacksdelete' => __('Are you sure you want to delete all trackbacks?')
42+
);
43+
44+
if (!isset($allow[$action])
45+
|| !$core->auth->check('admin',$core->blog->id)){ return; }
46+
47+
echo
48+
'<h3>'.__('Confirm action').'</h3>'.
49+
'<form action="posts_actions.php" method="post">'.
50+
'<p>'.$allow[$action].'</p>'.
51+
'<p>'.$hidden_fields.$core->formNonce().
52+
form::hidden(array('action'),'confirmed'.$action).
53+
'<input type="submit" value="'.__('yes').'" /></p>'.
54+
'</form>';
55+
}
56+
57+
public static function adminPostsActions($core,$posts,$action,$redir)
58+
{
59+
$allow = array(
60+
'commentsopen','commentsclose','confirmedcommentsdelete',
61+
'trackbacksopen','trackbacksclose','confirmedtrackbacksdelete'
62+
);
63+
if (!in_array($action,$allow)
64+
|| !$core->auth->check('admin',$core->blog->id)){ return; }
65+
66+
try {
67+
while ($posts->fetch())
68+
{
69+
$id = $posts->post_id;
70+
71+
switch ($action) {
72+
case 'commentsopen' :
73+
self::updPostOption($id,'post_open_comment',1);
74+
break;
75+
76+
case 'commentsclose' :
77+
self::updPostOption($id,'post_open_comment',0);
78+
break;
79+
80+
case 'trackbacksopen' :
81+
self::updPostOption($id,'post_open_tb',1);
82+
break;
83+
84+
case 'trackbacksclose' :
85+
self::updPostOption($id,'post_open_tb',0);
86+
break;
87+
88+
case 'confirmedcommentsdelete' :
89+
self::delPostComments($id,false);
90+
self::updPostOption($id,'nb_comment',0);
91+
break;
92+
93+
case 'confirmedtrackbacksdelete' :
94+
self::delPostComments($id,true);
95+
self::updPostOption($id,'nb_trackback',0);
96+
break;
97+
}
98+
}
99+
if (!$core->error->flag()) {
100+
http::redirect($redir);
101+
}
102+
}
103+
catch (Exception $e)
104+
{
105+
$core->error->add($e->getMessage());
106+
}
107+
}
108+
109+
private static function updPostOption($id,$option,$value)
110+
{
111+
global $core;
112+
113+
if (!$core->auth->check('admin',$core->blog->id)) {
114+
throw new Exception(__('You are not allowed to change this entry option'));
115+
}
116+
117+
$id = abs((integer) $id);
118+
$cur = $core->con->openCursor($core->prefix.'post');
119+
120+
$cur->{$option} = $value;
121+
$cur->post_upddt = date('Y-m-d H:i:s');
122+
123+
$cur->update(
124+
'WHERE post_id = '.$id.' '.
125+
"AND blog_id = '".$core->con->escape($core->blog->id)."' "
126+
);
127+
$core->blog->triggerBlog();
128+
}
129+
130+
private static function delPostComments($id,$tb=false)
131+
{
132+
global $core;
133+
134+
$params = array(
135+
'no_content' => true,
136+
'post_id' => abs((integer) $id),
137+
'comment_trackback' => $tb ? 1: 0
138+
);
139+
$comments = $core->blog->getComments($params);
140+
141+
while($comments->fetch())
142+
{
143+
// slower but preserve core behaviors
144+
$core->blog->delComment($comments->comment_id);
145+
}
146+
}
147+
}
148+
?>

‎_define.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
# -- BEGIN LICENSE BLOCK ----------------------------------
3+
#
4+
# This file is part of postslistOptions, a plugin for Dotclear 2.
5+
#
6+
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
7+
# contact@jcdenis.fr http://jcd.lv
8+
#
9+
# Licensed under the GPL version 2.0 license.
10+
# A copy of this license is available in LICENSE file or at
11+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12+
#
13+
# -- END LICENSE BLOCK ------------------------------------
14+
15+
if (!defined('DC_RC_PATH')){return;}
16+
17+
$this->registerModule(
18+
/* Name */ "Posts list options",
19+
/* Description*/ "Add some options on admin posts list",
20+
/* Author */ "JC Denis",
21+
/* Version */ '2013.07.10',
22+
/* Permissions */ 'admin'
23+
);
24+
?>

‎icon.png

454 Bytes
Loading

‎locales/fr/main.lang.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
// Language: Français
3+
// Module: postslistOptions - 0.1
4+
// Date: 2010-09-09 23:05:58
5+
// Translated with dcTranslater - 1.5
6+
7+
#_admin.php:27
8+
#_admin.php:30
9+
$GLOBALS['__l10n']['Mark as opened'] = 'Ouvrir';
10+
11+
#_admin.php:28
12+
#_admin.php:31
13+
$GLOBALS['__l10n']['Mark as closed'] = 'Fermer';
14+
15+
#_admin.php:29
16+
$GLOBALS['__l10n']['Delete all comments'] = 'Supprimer tous les commentaires';
17+
18+
#_admin.php:32
19+
$GLOBALS['__l10n']['Delete all trackbacks'] = 'Supprimer tous les rétroliens';
20+
21+
#_admin.php:38
22+
$GLOBALS['__l10n']['Are you sure you want to delete all comments?'] = 'Êtes-vous sûr de vouloir supprimer tous les commentaires ?';
23+
24+
#_admin.php:39
25+
$GLOBALS['__l10n']['Are you sure you want to delete all trackbacks?'] = 'Êtes-vous sûr de vouloir supprimer tous les rétroliens ?';
26+
27+
#_admin.php:46
28+
$GLOBALS['__l10n']['Confirm action'] = 'Confirmation';
29+
30+
#_admin.php:112
31+
$GLOBALS['__l10n']['You are not allowed to change this entry option'] = 'Vous n\'êtes pas autorisé à changer cette option';
32+
33+
?>

‎locales/fr/main.po

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Language: Français
2+
# Module: postslistOptions - 0.1
3+
# Date: 2010-09-09 23:05:58
4+
# Translated with translater 1.5
5+
6+
msgid ""
7+
msgstr ""
8+
"Content-Type: text/plain; charset=UTF-8\n"
9+
"Project-Id-Version: postslistOptions 0.1\n"
10+
"POT-Creation-Date: \n"
11+
"PO-Revision-Date: 2010-09-09T23:05:58+00:00\n"
12+
"Last-Translator: JC Denis\n"
13+
"Language-Team: \n"
14+
"MIME-Version: 1.0\n"
15+
"Content-Transfer-Encoding: 8bit\n"
16+
17+
#: _admin.php:27
18+
#: _admin.php:30
19+
msgid "Mark as opened"
20+
msgstr "Ouvrir"
21+
22+
#: _admin.php:28
23+
#: _admin.php:31
24+
msgid "Mark as closed"
25+
msgstr "Fermer"
26+
27+
#: _admin.php:29
28+
msgid "Delete all comments"
29+
msgstr "Supprimer tous les commentaires"
30+
31+
#: _admin.php:32
32+
msgid "Delete all trackbacks"
33+
msgstr "Supprimer tous les rétroliens"
34+
35+
#: _admin.php:38
36+
msgid "Are you sure you want to delete all comments?"
37+
msgstr "Êtes-vous sûr de vouloir supprimer tous les commentaires ?"
38+
39+
#: _admin.php:39
40+
msgid "Are you sure you want to delete all trackbacks?"
41+
msgstr "Êtes-vous sûr de vouloir supprimer tous les rétroliens ?"
42+
43+
#: _admin.php:46
44+
msgid "Confirm action"
45+
msgstr "Confirmation"
46+
47+
#: _admin.php:112
48+
msgid "You are not allowed to change this entry option"
49+
msgstr "Vous n'êtes pas autorisé à changer cette option"
50+

‎release.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2013.07.10
2+
* Fixed action on multiple posts
3+
4+
0.1 20100910
5+
* First lab release (closes #557)

0 commit comments

Comments
 (0)
Please sign in to comment.