Index: print.module
===================================================================
--- print.module (revision 870)
+++ print.module (working copy)
@@ -253,13 +253,18 @@
break;
case 1:
$block['subject'] = t('Most printed');
- $result = db_query_range("SELECT path FROM {print_page_counter} ORDER BY totalcount DESC", 0, 3);
- if (db_affected_rows()) {
- $block['content'] = '
';
+ if ($result = db_query_range("SELECT path FROM {print_page_counter} ORDER BY totalcount DESC", 0, 3)) {
+ $block['content'] = '';
while ($obj = db_fetch_object($result)) {
$block['content'] .= '- '. l(_print_get_title($obj->path), $obj->path) .'
';
}
- $block['content'] .= '
';
+
+ if (!empty($block['content'])) {
+ $block['content'] = '' . $block['content'] . '
';
+ }
+ else {
+ unset($block['content']);
+ }
}
break;
}
@@ -548,10 +553,10 @@
* value of the url_list field (0 or 1)
*/
function _print_node_conf_modify($nid, $link, $comments, $url_list) {
+ @db_query("INSERT INTO {print_node_conf} (nid, link, comments, url_list) VALUES (%d, %d, %d, %d)", $nid, $link, $comments, $url_list);
+ if (!db_affected_rows()) {
db_query("UPDATE {print_node_conf} SET link = %d, comments = %d, url_list = %d WHERE nid = %d", $link, $comments, $url_list, $nid);
- if (!db_affected_rows()) {
- db_query("INSERT INTO {print_node_conf} (nid, link, comments, url_list) VALUES (%d, %d, %d, %d)", $nid, $link, $comments, $url_list);
- }
+ }
}
/**
Index: print.pages.inc
===================================================================
--- print.pages.inc (revision 870)
+++ print.pages.inc (working copy)
@@ -33,11 +33,9 @@
print $html;
$nodepath = (isset($node->path)) ? drupal_get_normal_path($node->path) : 'node/'. $path;
- db_query("UPDATE {print_page_counter} SET totalcount = totalcount + 1, timestamp = %d WHERE path = '%s'", time(), $nodepath);
- // If we affected 0 rows, this is the first time viewing the node.
+ @db_query("INSERT INTO {print_page_counter} (path, totalcount, timestamp) VALUES ('%s', 1, %d)", $nodepath, time());
if (!db_affected_rows()) {
- // We must create a new row to store counters for the new node.
- db_query("INSERT INTO {print_page_counter} (path, totalcount, timestamp) VALUES ('%s', 1, %d)", $nodepath, time());
+ db_query("UPDATE {print_page_counter} SET totalcount = totalcount + 1, timestamp = %d WHERE path = '%s'", time(), $nodepath);
}
}
}
Index: print_mail/print_mail.inc
===================================================================
--- print_mail/print_mail.inc (revision 870)
+++ print_mail/print_mail.inc (working copy)
@@ -50,11 +50,10 @@
if (count($form_state['post']) == 0) {
$nodepath = drupal_get_normal_path($path);
- db_query("UPDATE {print_mail_page_counter} SET totalcount = totalcount + 1, timestamp = %d WHERE path = '%s'", time(), $nodepath);
- // If we affected 0 rows, this is the first time viewing the node.
+ @db_query("INSERT INTO {print_mail_page_counter} (path, totalcount, timestamp) VALUES ('%s', 1, %d)", $nodepath, time());
if (!db_affected_rows()) {
- // We must create a new row to store counters for the new node.
- db_query("INSERT INTO {print_mail_page_counter} (path, totalcount, timestamp) VALUES ('%s', 1, %d)", $nodepath, time());
+ db_query("UPDATE {print_mail_page_counter} SET totalcount = totalcount + 1, timestamp = %d WHERE path = '%s'", time(), $nodepath);
+
}
}
Index: print_mail/print_mail.module
===================================================================
--- print_mail/print_mail.module (revision 870)
+++ print_mail/print_mail.module (working copy)
@@ -113,13 +113,18 @@
switch ($delta) {
case 0:
$block['subject'] = t('Most emailed');
- $result = db_query_range("SELECT path FROM {print_mail_page_counter} ORDER BY sentcount DESC", 0, 3);
- if (db_affected_rows()) {
- $block['content'] = '';
+ if ($result = db_query_range("SELECT path FROM {print_mail_page_counter} ORDER BY sentcount DESC", 0, 3)) {
+ $block['content'] = '';
while ($obj = db_fetch_object($result)) {
$block['content'] .= '- '. l(_print_get_title($obj->path), $obj->path) .'
';
}
- $block['content'] .= '
';
+
+ if (!empty($block['content'])) {
+ $block['content'] = '' . $block['content'] . '
';
+ }
+ else {
+ unset($block['content']);
+ }
}
break;
}
@@ -342,10 +347,10 @@
* value of the url_list field (0 or 1)
*/
function _print_mail_node_conf_modify($nid, $link, $comments, $url_list) {
+ @db_query("INSERT INTO {print_mail_node_conf} (nid, link, comments, url_list) VALUES (%d, %d, %d, %d)", $nid, $link, $comments, $url_list);
+ if (!db_affected_rows()) {
db_query("UPDATE {print_mail_node_conf} SET link = %d, comments = %d, url_list = %d WHERE nid = %d", $link, $comments, $url_list, $nid);
- if (!db_affected_rows()) {
- db_query("INSERT INTO {print_mail_node_conf} (nid, link, comments, url_list) VALUES (%d, %d, %d, %d)", $nid, $link, $comments, $url_list);
- }
+ }
}
/**
Index: print_pdf/print_pdf.module
===================================================================
--- print_pdf/print_pdf.module (revision 870)
+++ print_pdf/print_pdf.module (working copy)
@@ -138,13 +138,18 @@
switch ($delta) {
case 0:
$block['subject'] = t('Most PDFd');
- $result = db_query_range("SELECT path FROM {print_pdf_page_counter} ORDER BY totalcount DESC", 0, 3);
- if (db_affected_rows()) {
- $block['content'] = '';
+ if ($result = db_query_range("SELECT path FROM {print_pdf_page_counter} ORDER BY totalcount DESC", 0, 3)) {
+ $block['content'] = '';
while ($obj = db_fetch_object($result)) {
$block['content'] .= '- '. l(_print_get_title($obj->path), $obj->path) .'
';
}
- $block['content'] .= '
';
+
+ if (!empty($block['content'])) {
+ $block['content'] = '' . $block['content'] . '
';
+ }
+ else {
+ unset($block['content']);
+ }
}
break;
}
@@ -375,10 +380,10 @@
* value of the url_list field (0 or 1)
*/
function _print_pdf_node_conf_modify($nid, $link, $comments, $url_list) {
+ @db_query("INSERT INTO {print_pdf_node_conf} (nid, link, comments, url_list) VALUES (%d, %d, %d, %d)", $nid, $link, $comments, $url_list);
+ if (!db_affected_rows()) {
db_query("UPDATE {print_pdf_node_conf} SET link = %d, comments = %d, url_list = %d WHERE nid = %d", $link, $comments, $url_list, $nid);
- if (!db_affected_rows()) {
- db_query("INSERT INTO {print_pdf_node_conf} (nid, link, comments, url_list) VALUES (%d, %d, %d, %d)", $nid, $link, $comments, $url_list);
- }
+ }
}
/**
@@ -553,7 +558,7 @@
function _print_pdf_wkhtmltopdf_version() {
$print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
$descriptor = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
-
+
$cmd = realpath($print_pdf_pdf_tool) ." --version";
$process = proc_open($cmd, $descriptor, $pipes, NULL, NULL);
if (is_resource($process)) {
Index: print_pdf/print_pdf.pages.inc
===================================================================
--- print_pdf/print_pdf.pages.inc (revision 870)
+++ print_pdf/print_pdf.pages.inc (working copy)
@@ -81,11 +81,9 @@
}
$nodepath = (isset($node->path)) ? drupal_get_normal_path($node->path) : 'node/'. $path;
- db_query("UPDATE {print_pdf_page_counter} SET totalcount = totalcount + 1, timestamp = %d WHERE path = '%s'", time(), $nodepath);
- // If we affected 0 rows, this is the first time viewing the node.
+ @db_query("INSERT INTO {print_pdf_page_counter} (path, totalcount, timestamp) VALUES ('%s', 1, %d)", $nodepath, time());
if (!db_affected_rows()) {
- // We must create a new row to store counters for the new node.
- db_query("INSERT INTO {print_pdf_page_counter} (path, totalcount, timestamp) VALUES ('%s', 1, %d)", $nodepath, time());
+ db_query("UPDATE {print_pdf_page_counter} SET totalcount = totalcount + 1, timestamp = %d WHERE path = '%s'", time(), $nodepath);
}
}