Merge pull request #6546 from colemanw/CRM-17059
authorcolemanw <coleman@civicrm.org>
Fri, 21 Aug 2015 00:14:30 +0000 (20:14 -0400)
committercolemanw <coleman@civicrm.org>
Fri, 21 Aug 2015 00:14:30 +0000 (20:14 -0400)
CRM-17059 - Fix faulty relationship count in datatable

CRM/Contact/BAO/Relationship.php
CRM/Contact/Form/Relationship.php
CRM/Contribute/Form/Task/Invoice.php
CRM/Upgrade/Incremental/sql/4.6.8.mysql.tpl [new file with mode: 0644]
sql/civicrm_generated.mysql
tests/phpunit/api/v3/CustomValueTest.php
xml/version.xml

index d7c39429186128414d4dfbfb74682eb46f839b2f..8eed0904cc32e79bcc075906ddff0118c57e943e 100644 (file)
@@ -1295,6 +1295,7 @@ LEFT JOIN  civicrm_country ON (civicrm_address.country_id = civicrm_country.id)
               $mask -= CRM_Core_Action::ENABLE;
               $mask -= CRM_Core_Action::DISABLE;
             }
+            $mask = $mask & $permissionMask;
           }
 
           // Give access to manage case link by copying to MAX_ACTION index temporarily, depending on case permission of user.
index 96c5ca72af6e9ec695c07412d07408af23680259..8dfb5483f122b8cac4ba442de5804caa4abbff0c 100644 (file)
@@ -131,6 +131,13 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form {
 
     $this->assign('display_name_a', $this->_display_name_a);
 
+    // Check for permissions
+    if (in_array($this->_action, array(CRM_Core_Action::ADD, CRM_Core_Action::UPDATE, CRM_Core_Action::DELETE))) {
+      if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
+        CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
+      }
+    }
+
     // Set page title based on action
     switch ($this->_action) {
       case CRM_Core_Action::VIEW:
index 11b0a6cc3b844382e1bf886c834c26bf086db249..ab7a50ebfa3f1ed4df52964c14b93950d7423223 100644 (file)
@@ -457,12 +457,13 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task {
         $tplParams['creditnote_id'] = $creditNoteId;
       }
 
+      $pdfFileName = "{$invoiceId}.pdf";
       $sendTemplateParams = array(
         'groupName' => 'msg_tpl_workflow_contribution',
         'valueName' => 'contribution_invoice_receipt',
         'contactId' => $contribution->contact_id,
         'tplParams' => $tplParams,
-        'PDFFilename' => 'Invoice.pdf',
+        'PDFFilename' => $pdfFileName,
       );
       $session = CRM_Core_Session::singleton();
       $contactID = $session->get('userID');
@@ -520,7 +521,8 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task {
 
         list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
         // functions call for adding activity with attachment
-        $fileName = self::putFile($html);
+        $pdfFileName = "{$invoiceId}.pdf";
+        $fileName = self::putFile($html, $pdfFileName);
         self::addActivities($subject, $contribution->contact_id, $fileName, $params);
       }
       elseif ($contribution->_component == 'event') {
@@ -534,7 +536,8 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task {
 
         list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
         // functions call for adding activity with attachment
-        $fileName = self::putFile($html);
+        $pdfFileName = "{$invoiceId}.pdf";
+        $fileName = self::putFile($html, $pdfFileName);
         self::addActivities($subject, $contribution->contact_id, $fileName, $params);
       }
 
@@ -550,13 +553,14 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task {
         return $html;
       }
       else {
-        CRM_Utils_PDF_Utils::html2pdf($messageInvoice, 'Invoice.pdf', FALSE, array(
+        $pdfFileName = "{$invoiceId}.pdf";
+        CRM_Utils_PDF_Utils::html2pdf($messageInvoice, $pdfFileName, FALSE, array(
           'margin_top' => 10,
           'margin_left' => 65,
           'metric' => 'px',
         ));
         // functions call for adding activity with attachment
-        $fileName = self::putFile($html);
+        $fileName = self::putFile($html, $pdfFileName);
         self::addActivities($subject, $contactIds, $fileName, $params);
 
         CRM_Utils_System::civiExit();
@@ -634,14 +638,14 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task {
    * @return string
    *   Name of file which is in pdf format
    */
-  static public function putFile($html) {
+  static public function putFile($html, $name = 'Invoice.pdf') {
     require_once "vendor/dompdf/dompdf/dompdf_config.inc.php";
     $doc = new DOMPDF();
     $doc->load_html($html);
     $doc->render();
     $html = $doc->output();
     $config = CRM_Core_Config::singleton();
-    $fileName = $config->uploadDir . 'Invoice.pdf';
+    $fileName = $config->uploadDir . $name;
     file_put_contents($fileName, $html);
     return $fileName;
   }
diff --git a/CRM/Upgrade/Incremental/sql/4.6.8.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.6.8.mysql.tpl
new file mode 100644 (file)
index 0000000..23b84cf
--- /dev/null
@@ -0,0 +1 @@
+{* file to handle db changes in 4.6.8 during upgrade *}
index 101cef0269a383b77337421c0c4425d644cbdba8..9ee1d79567a4b4b6bd7ec5a641c948e302976aee 100644 (file)
@@ -400,7 +400,7 @@ UNLOCK TABLES;
 
 LOCK TABLES `civicrm_domain` WRITE;
 /*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
-INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'4.6.7',1,NULL,NULL);
+INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'4.6.8',1,NULL,NULL);
 /*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
 UNLOCK TABLES;
 
index 0471ac8d99dd501848b592df0cf5c3c66c24170f..4920da8abe300571a08df667b423eae104738e6d 100644 (file)
@@ -207,7 +207,7 @@ class api_v3_CustomValueTest extends CiviUnitTestCase {
 
         case '!=':
           $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customId => array($op => $notselectedValue)));
-          $this->assertEquals($contactId, $result['id']);
+          $this->assertEquals(TRUE, array_key_exists($contactId, $result['values']));
           echo $description . $notselectedValue;
           break;
 
index 69ae2ce28c4db45dc91aaa448162595165e96c03..c11e0c6d87a820df3471691d752eebce1b8308ff 100644 (file)
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="iso-8859-1" ?>
 <version>
-  <version_no>4.6.7</version_no>
+  <version_no>4.6.8</version_no>
 </version>