cvs: pearweb /include pear-database.php /public_html package-info.php /public_html/trackback trackback.php /sql packages.sql

From: Date: Thu, 23 Feb 2006 22:33:32 +0000
Subject: cvs: pearweb /include pear-database.php /public_html package-info.php /public_html/trackback trackback.php /sql packages.sql
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-cvs+get-38535@lists.php.net to get a copy of this message
pajoye Thu Feb 23 22:33:32 2006 UTC Modified files: /pearweb/include pear-database.php /pearweb/public_html/trackback trackback.php /pearweb/public_html package-info.php /pearweb/sql packages.sql Log: - allow to disable trackbacks on a package basis trackbacks are allowed by default, as it is the case now

http://cvs.php.net/viewcvs.cgi/pearweb/include/pear-database.php?r1=1.300&r2=1.301&diff_format=u Index: pearweb/include/pear-database.php diff -u pearweb/include/pear-database.php:1.300 pearweb/include/pear-database.php:1.301 --- pearweb/include/pear-database.php:1.300 Tue Nov 29 08:18:12 2005 +++ pearweb/include/pear-database.php Thu Feb 23 22:33:31 2006 @@ -17,7 +17,7 @@ | Tomas V.V.Cox <cox@php.net> | | Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: pear-database.php,v 1.300 2005/11/29 08:18:12 cellog Exp $ + $Id: pear-database.php,v 1.301 2006/02/23 22:33:31 pajoye Exp $ */ require_once 'DB/storage.php'; @@ -700,7 +700,8 @@ "p.description AS description, p.cvs_link AS cvs_link, ". "p.doc_link as doc_link, ". "p.unmaintained AS unmaintained,". - "p.newpk_id AS newpk_id". + "p.newpk_id AS newpk_id,". + "p.blocktrackbacks" . " FROM packages p, categories c ". "WHERE " . $package_type . " c.id = p.category AND p.{$what} = ?"; $rel_sql = "SELECT version, id, doneby, license, summary, ". @@ -856,7 +857,7 @@ "SELECT p.name, r.id AS rid, r.version AS stable, r.state AS state ". "FROM packages p, releases r ". "WHERE " . $package_type . - ' p.id = r.package ' . + ' p.id = r.package ' . "ORDER BY r.releasedate ASC ", false, null, DB_FETCHMODE_ASSOC); $stablereleases = $dbh->getAssoc( "SELECT p.name, r.id AS rid, r.version AS stable, r.state AS state ". @@ -1196,6 +1197,24 @@ } // }}} + // {{{ allowTrackbacks() + /** + * Enable or disable trackbacks for a package + * + * @access public + * @param int ID of the package + * @return void + */ + function allowTrackbacks($name, $allow) + { + global $dbh; + + $query = 'UPDATE packages + SET blocktrackbacks=' . ((int) !$allow) . ' + WHERE name=' . $dbh->quoteSmart($name); + $res = $dbh->query($query); + } + // }}} } /** http://cvs.php.net/viewcvs.cgi/pearweb/public_html/trackback/trackback.php?r1=1.17&r2=1.18&diff_format=u Index: pearweb/public_html/trackback/trackback.php diff -u pearweb/public_html/trackback/trackback.php:1.17 pearweb/public_html/trackback/trackback.php:1.18 --- pearweb/public_html/trackback/trackback.php:1.17 Tue Feb 14 22:35:33 2006 +++ pearweb/public_html/trackback/trackback.php Thu Feb 23 22:33:32 2006 @@ -17,7 +17,7 @@ | Authors: Tobias Schlitt <toby@php.net> | | | +----------------------------------------------------------------------+ - $Id: trackback.php,v 1.17 2006/02/14 22:35:33 toby Exp $ + $Id: trackback.php,v 1.18 2006/02/23 22:33:32 pajoye Exp $ */ @@ -51,11 +51,14 @@ echo Services_Trackback::getResponseError('No package with ID '.$id.' found. Trackback not possible.', 1); exit; } - +if ($pkgInfo['blocktrackbacks']) { + echo Services_Trackback::getResponseError('Package ' . $id . ' does not allow trackbacks.', 1); + exit; +} // Creating new trackback $trackback = new Damblan_Trackback(array( - 'id' => $id, + 'id' => $id, 'timestamp' => time(), )); @@ -141,7 +144,7 @@ } $res = $trackback->save($dbh); -if (PEAR::isError($res)) { +if (PEAR::isError($res)) { echo Services_Trackback::getResponseError('Your trackback could not be saved, please try again or inform the administrator.', 1); exit; } http://cvs.php.net/viewcvs.cgi/pearweb/public_html/package-info.php?r1=1.114&r2=1.115&diff_format=u Index: pearweb/public_html/package-info.php diff -u pearweb/public_html/package-info.php:1.114 pearweb/public_html/package-info.php:1.115 --- pearweb/public_html/package-info.php:1.114 Tue Feb 7 07:38:16 2006 +++ pearweb/public_html/package-info.php Thu Feb 23 22:33:32 2006 @@ -16,7 +16,7 @@ | Authors: Martin Jansen <mj@php.net> | | Tomas V.V.Cox <cox@idecnet.com> | +----------------------------------------------------------------------+ - $Id: package-info.php,v 1.114 2006/02/07 07:38:16 toby Exp $ + $Id: package-info.php,v 1.115 2006/02/23 22:33:32 pajoye Exp $ */ @@ -27,8 +27,7 @@ // {{{ setup, queries - -$params = array('package|pacid' => '', 'action' => '', 'version' => ''); +$params = array('package|pacid' => '', 'action' => '', 'version' => '', 'allowtrackbacks' => ''); $site->getElements($params); $pacid = $params['package|pacid']; @@ -66,8 +65,21 @@ if (isset($auth_user)) { $karma =& new Damblan_Karma($dbh); $trackbackIsAdmin = (isset($auth_user) && $karma->has($auth_user->handle, 'pear.dev')); + if ($trackbackIsAdmin) { + if ($pkg['blocktrackbacks'] && $params['allowtrackbacks'] == 1) { + package::allowTrackbacks($pkg['name'], true); + localRedirect('/package/' . $pkg['name'] . '/trackbacks'); + } elseif ($params['allowtrackbacks'] == 2) { + package::allowTrackbacks($pkg['name'], false); + localRedirect('/package/' . $pkg['name'] . '/trackbacks'); + } + } } else { - $trackbackIsAdmin = false; + if ($pkg['blocktrackbacks']) { + localRedirect('/package/' . $pkg['name']); + } else { + $trackbackIsAdmin = false; + } } $action = $params['action']; @@ -136,9 +148,12 @@ $accounts .= '</ul>'; $channel_name = PEAR_CHANNELNAME; -$trackback_uri = "http://$channel_name/trackback/trackback.php?id=$name"; -$trackback_header = <<<EOD +if ($pkg['blocktrackbacks']) { + $trackback_header = ''; +} else { + $trackback_uri = "http://$channel_name/trackback/trackback.php?id=$name"; + $trackback_header = <<<EOD <!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" @@ -151,7 +166,7 @@ </rdf:RDF> --> EOD; - +} // }}} // {{{ page header @@ -469,6 +484,13 @@ // }}} } elseif ($action == 'trackbacks') { + if ($pkg['blocktrackbacks']) { + echo '<p>Trackbacks are disabled for this package. If you like to enable them, click below:</p>'; + echo '<p><a href="/package/' . $pkg['name'] . '/trackbacks/?allowtrackbacks=1">Allow trackbacks</a></p>'; + response_footer(); + exit(); + } + include_once 'Damblan/Trackback.php'; // Generate trackback list @@ -476,7 +498,9 @@ print '<p>This page provides a list of trackbacks, which have been received to this package. A trackback is usually generated, when a weblog entry is created, which is related to the package. If you want to learn more about trackbacks, please take a look at -&quot; <a href="http://www.movabletype.org/trackback/beginners/">A Beginner\'s Guide to TrackBack</a>&quot; (by movabletype.org).</p>'; +&quot; <a href="http://www.movabletype.org/trackback/beginners/">A Beginner\'s Guide to TrackBack</a>&quot; (by movabletype.org).</p> +<p>If you like to disable the trackbacks for this package, click here: +<p><a href="/package/' . $pkg['name'] . '/trackbacks/?allowtrackbacks=2">Disable trackbacks</a></p>'; print '<p>The trackback URL for this package is: <a href="'.$trackback_uri.'">'.$trackback_uri.'</a>'; @@ -566,4 +590,3 @@ // }}} response_footer(); -?> http://cvs.php.net/viewcvs.cgi/pearweb/sql/packages.sql?r1=1.20&r2=1.21&diff_format=u Index: pearweb/sql/packages.sql diff -u pearweb/sql/packages.sql:1.20 pearweb/sql/packages.sql:1.21 --- pearweb/sql/packages.sql:1.20 Sat Jan 7 19:17:08 2006 +++ pearweb/sql/packages.sql Thu Feb 23 22:33:32 2006 @@ -17,6 +17,7 @@ cvs_link varchar(255) default NULL, approved tinyint(4) NOT NULL default '0', wiki_area tinyint(1) NOT NULL default '0', + blocktrackbacks tinyint(1) NOT NULL default '0', unmaintained tinyint(1) NOT NULL default '0', newpk_id int(11) default NULL, PRIMARY KEY (id),
« previous php.pear.cvs (#38535) next »