Our changes
authorLisa Marie Maginnis <lisam@fsf.org>
Thu, 1 May 2014 21:04:18 +0000 (17:04 -0400)
committerAndrew Engelbrecht <andrew@fsf.org>
Thu, 16 May 2019 14:29:58 +0000 (10:29 -0400)
CRM/ACL/BAO/Cache.php
CRM/Contact/Task.php
CRM/Contribute/Task.php
CRM/Core/Resources.php
CRM/Import/Parser.php
CRM/Utils/PDF/Utils.php
CRM/Utils/Token.php
api/v3/Contact.php
api/v3/Contribution.php

index 921adfeaf6c08c03e4c94238af36bde567b793a9..adda9fdf5f2cf0838107b6df73c12fd1dc2c50dc 100644 (file)
@@ -77,9 +77,13 @@ SELECT acl_id
 ";
     $params = [1 => [$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);
 
index 97c62e6b17bcb9a3f0b356742d024073582ba4c5..62d9c9bb3b6e7635ab387307cb2a67d06706a22d 100644 (file)
@@ -50,7 +50,8 @@ class CRM_Contact_Task extends CRM_Core_Task {
     RESTORE = 108,
     COMMUNICATION_PREFS = 109,
     INDIVIDUAL_CONTACTS = 110,
-    ADD_TO_CASE = 111;
+    ADD_TO_CASE = 111,
+    LATEX_LETTER = 112;
 
   /**
    * @var string
@@ -153,6 +154,11 @@ class CRM_Contact_Task extends CRM_Core_Task {
           'class' => 'CRM_Contact_Form_Task_AlterPreferences',
           'url' => 'civicrm/task/alter-contact-preference',
         ),
+        self::LATEX_LETTER => array(
+          'title' => ts('Print Latex PDF Letter for Contacts'),
+          'class' => 'CRM_Contact_Form_Task_LatexPDF',
+          'result' => TRUE,
+        ),
         self::RESTORE => array(
           'title' => ts('Restore contacts from trash'),
           'class' => 'CRM_Contact_Form_Task_Delete',
index c7679aab1b5bca9a1a25137af065858787a8db9c..0d71b255a743f137be4f585df8be3808e7b0001e 100644 (file)
@@ -45,7 +45,8 @@ class CRM_Contribute_Task extends CRM_Core_Task {
     UPDATE_STATUS = 401,
     PDF_RECEIPT = 402,
     PDF_THANKYOU = 403,
-    PDF_INVOICE = 404;
+    PDF_INVOICE = 404,
+    LATEX_TEST = 405;
 
   /**
    * @var string
@@ -116,6 +117,11 @@ class CRM_Contribute_Task extends CRM_Core_Task {
           'class' => 'CRM_Contribute_Form_Task_Invoice',
           'result' => FALSE,
         ],
+        self::LATEX_TEST => [
+          'title' => ts('Latex Letters for Contributions'),
+          'class' => 'CRM_Contribute_Form_Task_PDFLatex',
+          'result' => FALSE,
+        ],
       ];
 
       //CRM-4418, check for delete
index 014750ece774cbbc59b5a51a1127dcd0d1dc310d..959572db4335d84962616aba17d1fbee24f9f13c 100644 (file)
@@ -333,7 +333,7 @@ class CRM_Core_Resources {
    * @return string
    */
   public function renderSetting() {
-    // On a standard page request we construct the CRM object from scratch
+    /*// On a standard page request we construct the CRM object from scratch
     if (!self::isAjaxMode()) {
       $js = 'var CRM = ' . json_encode($this->getSettings()) . ';';
     }
@@ -342,6 +342,10 @@ class CRM_Core_Resources {
       $js = 'CRM.$.extend(true, CRM, ' . json_encode($this->getSettings()) . ');';
     }
     return sprintf("<script type=\"text/javascript\">\n%s\n</script>\n", $js);
+    */
+    $js = 'var CRM = ' . json_encode($this->getSettings()) . ';';
+    //return sprintf("<script type=\"text/javascript\">\n%s\n</script>\n", $js);
+    return sprintf("<script type=\"text/javascript\">\n// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3\n%s\n// @license-end\n</script>\n", $js);
   }
 
   /**
index cf01fdd054821daa1bdca2506520ea979d334f2e..9c9d139846c4909b96b7e63ae688d68dc0232c98 100644 (file)
@@ -34,7 +34,7 @@ abstract class CRM_Import_Parser {
   /**
    * Settings
    */
-  const MAX_WARNINGS = 25, DEFAULT_TIMEOUT = 30;
+  const MAX_ERRORS = 10000, MAX_WARNINGS = 25, DEFAULT_TIMEOUT = 30;
 
   /**
    * Return codes
index 7694dc24c748e06f9fcf7013d5806eedb5366020..55c674dc16d634b9747914f5876019381f4c542a 100644 (file)
@@ -34,8 +34,96 @@ use Dompdf\Options;
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2019
  */
+
 class CRM_Utils_PDF_Utils {
 
+  public 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;
+    }
+       }
+
   /**
    * @param array $text
    *   List of HTML snippets.
index d9014d7760ae41dbade150bf5ea5765e11222ba5..0be89d9189e26bc0517f9f157943fbcaa17e6788 100644 (file)
@@ -683,7 +683,7 @@ class CRM_Utils_Token {
       $str
     );
 
-    $str = preg_replace('/\\\\|\{(\s*)?\}/', ' ', $str);
+    //$str = preg_replace('/\\\\|\{(\s*)?\}/', ' ', $str); //WHY you do this?
     return $str;
   }
 
@@ -873,7 +873,7 @@ class CRM_Utils_Token {
    * @param $str ref to the string that will be scanned and modified
    */
   public static function unescapeTokens(&$str) {
-    $str = preg_replace('/\\\\|\{(\{\w+\.\w+\})\}/', '\\1', $str);
+    //$str = preg_replace('/\\\\|\{(\{\w+\.\w+\})\}/', '\\1', $str);
   }
 
   /**
index c493cad4c89d44fc1b0fc1374be5cc58d8da13b2..a4ca9b4c978c726857106153978de92ce445a2d8 100644 (file)
@@ -170,6 +170,15 @@ function _civicrm_api3_contact_create_spec(&$params) {
   $params['gender_id']['api.aliases'] = ['gender'];
 }
 
+/**
+ * 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.
  *
index 8366a44528cad7e9f00a223d29d137c53050ffa7..ddca6a70c263a71c7bfed61a3b0a83ff17c68001 100644 (file)
@@ -250,6 +250,15 @@ function _civicrm_api3_contribution_delete_spec(&$params) {
   $params['id']['api.aliases'] = ['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.
  *