From 4f9fa8d86f9466b14d4b77580bc8859f2c9bb8dc Mon Sep 17 00:00:00 2001 From: Lisa Marie Maginnis Date: Thu, 1 May 2014 17:04:18 -0400 Subject: [PATCH] Our changes --- CRM/ACL/BAO/Cache.php | 10 +++-- CRM/Contact/Task.php | 6 ++- CRM/Contribute/Task.php | 6 ++- CRM/Core/Resources.php | 4 +- CRM/Import/Parser.php | 2 +- CRM/Utils/PDF/Utils.php | 88 +++++++++++++++++++++++++++++++++++++++++ CRM/Utils/Token.php | 4 +- api/v3/Contact.php | 9 +++++ api/v3/Contribution.php | 9 +++++ 9 files changed, 129 insertions(+), 9 deletions(-) diff --git a/CRM/ACL/BAO/Cache.php b/CRM/ACL/BAO/Cache.php index 86b4fda4f0..d5dc6e3c63 100644 --- a/CRM/ACL/BAO/Cache.php +++ b/CRM/ACL/BAO/Cache.php @@ -69,9 +69,13 @@ SELECT acl_id "; $params = array(1 => array($id, 'Integer')); - if ($id == 0) { - $query .= " OR contact_id IS NULL"; - } +## this is related to RT#765026 +# Something is occasionally inserting records in civicrm_acl_cache with id null. That causes i +# for our anonymous visitors who want to sign petitions. +# Removed. Ward, 2012-07-20 +# if ($id == 0) { +# $query .= " OR contact_id IS NULL"; +# } $dao = CRM_Core_DAO::executeQuery($query, $params); diff --git a/CRM/Contact/Task.php b/CRM/Contact/Task.php index 2b2119462d..72ca4cd88d 100644 --- a/CRM/Contact/Task.php +++ b/CRM/Contact/Task.php @@ -43,7 +43,7 @@ class CRM_Contact_Task { EMAIL_CONTACTS = 6, SMS_CONTACTS = 7, DELETE_CONTACTS = 8, HOUSEHOLD_CONTACTS = 9, ORGANIZATION_CONTACTS = 10, RECORD_CONTACTS = 11, MAP_CONTACTS = 12, SAVE_SEARCH = 13, SAVE_SEARCH_UPDATE = 14, PRINT_CONTACTS = 15, LABEL_CONTACTS = 16, BATCH_UPDATE = 17, ADD_EVENT = 18, PRINT_FOR_CONTACTS = 19, EMAIL_UNHOLD = 22, RESTORE = 23, - DELETE_PERMANENTLY = 24; + DELETE_PERMANENTLY = 24, LATEX_LETTER = 26; /** * the task array @@ -148,6 +148,10 @@ class CRM_Contact_Task { 'title' => ts('Alter Contact Communication Preferences'), 'class' => 'CRM_Contact_Form_Task_AlterPreferences', ), + 26 => array('title' => ts('Print Latex PDF Letter for Contacts'), + 'class' => 'CRM_Contact_Form_Task_LatexPDF', + 'result' => TRUE, + ), self::RESTORE => array( 'title' => ts('Restore Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', diff --git a/CRM/Contribute/Task.php b/CRM/Contribute/Task.php index 06feed0f20..7362425ede 100644 --- a/CRM/Contribute/Task.php +++ b/CRM/Contribute/Task.php @@ -39,7 +39,7 @@ * */ class CRM_Contribute_Task { - CONST DELETE_CONTRIBUTIONS = 1, PRINT_CONTRIBUTIONS = 2, EXPORT_CONTRIBUTIONS = 3, BATCH_CONTRIBUTIONS = 4, EMAIL_CONTACTS = 5, UPDATE_STATUS = 6, PDF_RECEIPT = 7; + CONST DELETE_CONTRIBUTIONS = 1, PRINT_CONTRIBUTIONS = 2, EXPORT_CONTRIBUTIONS = 3, BATCH_CONTRIBUTIONS = 4, EMAIL_CONTACTS = 5, UPDATE_STATUS = 6, PDF_RECEIPT = 7, LATEX_TEST = 9; /** * the task array @@ -106,6 +106,10 @@ class CRM_Contribute_Task { 'class' => 'CRM_Contribute_Form_Task_PDFLetter', 'result' => FALSE, ), + 9 => array('title' => ts('Latex Letters for Contributions'), + 'class' => 'CRM_Contribute_Form_Task_PDFLatex', + 'result' => FALSE, + ), ); //CRM-4418, check for delete diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index fd7d57f4be..00af3d18a2 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -268,7 +268,9 @@ class CRM_Core_Resources { */ public function renderSetting() { $js = 'var CRM = ' . json_encode($this->getSettings()) . ';'; - return sprintf("\n", $js); + //return sprintf("\n", $js); + return sprintf("\n", $js); + } /** diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index b6b6603096..91e0c00e5e 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -38,7 +38,7 @@ abstract class CRM_Import_Parser { /** * Settings */ - CONST MAX_ERRORS = 250, MAX_WARNINGS = 25, DEFAULT_TIMEOUT = 30; + CONST MAX_ERRORS = 10000, MAX_WARNINGS = 25, DEFAULT_TIMEOUT = 30; /** * Return codes diff --git a/CRM/Utils/PDF/Utils.php b/CRM/Utils/PDF/Utils.php index 72d4880563..492dae75f4 100644 --- a/CRM/Utils/PDF/Utils.php +++ b/CRM/Utils/PDF/Utils.php @@ -32,8 +32,96 @@ * $Id$ * */ + class CRM_Utils_PDF_Utils { + static function latex2pdf(&$text, $fileName = 'civicrm.pdf', $output = FALSE, $pdfFormat = NULL) { + /* FIXME: get $paper_size, $orientation, $margins */ + + if (is_array($text)) { + $pages = &$text; + } + else { + $pages = array($text); + } + + + $head='\documentclass[11pt]{letter} +\usepackage{url} +\usepackage{ucs} +\usepackage{graphicx} +\usepackage[T1]{fontenc} +\usepackage{fullpage} + +\newcommand{\fsfclosing}[1]{\par\nobreak\vspace{\parskip} + \stopbreaks + \noindent + \ifx\@empty\fromaddress\else + \hspace*{\longindentation}\fi + \parbox{\indentedwidth}{\raggedright + \ignorespaces #1\\\\[1\medskipamount] + \hspace*{-0.25in}\includegraphics[scale=1.0]{sigjohns.pdf} + \\\\ + + \ifx\@empty\fromsig + \fromname + \else \fromsig \fi\strut} + \par} +\medskipamount=\parskip + +%% This line might be necessary, but it was not able to find utf8.def on my +%% machine. +\usepackage[utf8x]{inputenc} +\pagestyle{empty} +\tolerance=8000 +\address{\vspace{0.05in}} +\signature{John Sullivan \\\\ Executive Director} +\usepackage[ +top = 0.4in, +bottom = 0.9in, +left = 0.8in, +right = 0.8in]{geometry} +\begin{document} +'; + $footer=' +\end{document}'; + + $latex = $head; + foreach ($pages as $page) { + $latex.=$page; + } + $latex.=$footer; + + $descriptorspec = array( + 0 => array("pipe", "r"), + 1 => array("pipe", "w") + ); + + + + $process = proc_open("/usr/local/bin/pdflatex_wrapper.sh", $descriptorspec, $pipes); + + + if (is_resource($process)) { + fwrite($pipes[0], $latex); + fclose($pipes[0]); + + $pdf = stream_get_contents($pipes[1]); + fclose($pipes[1]); + } else { + CRM_Core_Error::debug_log_message("ERROR creating PDF. Check /tmp/pdflatex_*"); + } + + if ($output) { + return $pdf; + } + else { + header('Content-Type: application/pdf'); + header('Content-Disposition: attachment; filename="' . $fileName . '"'); + echo $pdf; + } + } + static function html2pdf(&$text, $fileName = 'civicrm.pdf', $output = FALSE, $pdfFormat = NULL) { if (is_array($text)) { $pages = &$text; diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 0f3c069a4e..bc7c4d0d89 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -619,7 +619,7 @@ class CRM_Utils_Token { $str ); - $str = preg_replace('/\\\\|\{(\s*)?\}/', ' ', $str); + //$str = preg_replace('/\\\\|\{(\s*)?\}/', ' ', $str); //WHY you do this? return $str; } @@ -775,7 +775,7 @@ class CRM_Utils_Token { * @static */ public static function unescapeTokens(&$str) { - $str = preg_replace('/\\\\|\{(\{\w+\.\w+\})\}/', '\\1', $str); + //$str = preg_replace('/\\\\|\{(\{\w+\.\w+\})\}/', '\\1', $str); } /** diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 79ad85ff28..a4886810e7 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -133,6 +133,15 @@ function _civicrm_api3_contact_create_spec(&$params) { $params['suffix_id']['api.aliases'] = array('individual_suffix', 'individual_suffix_id'); } +/** + * Added by Ward; basic filter-able contribution list + * use filter.receive_date_high etc + * 2013-07-02 + */ +function civicrm_api3_contact_list($params) { + return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); +} + /** * Retrieve one or more contacts, given a set of search params * diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index cd9f8f79d3..94f3abd9d7 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -159,6 +159,15 @@ function _civicrm_api3_contribution_delete_spec(&$params) { $params['id']['api.aliases'] = array('contribution_id'); } +/** + * Added by Ward; basic filter-able contribution list + * use filter.receive_date_high etc + * 2013-07-02 + */ +function civicrm_api3_contribution_list($params) { + return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); +} + /** * Retrieve a set of contributions, given a set of input params * -- 2.25.1