Merge pull request #8102 from monishdeb/CRM-18349
[civicrm-core.git] / CRM / Core / Page / AJAX / Location.php
index 1199b6c07b97764468cabeec4e9544b914e72e4e..4d128c1228866e60e50a6d6749cebff5d045f3ef 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
+ | Copyright CiviCRM LLC (c) 2004-2016                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2016
  *
  */
 
@@ -58,8 +58,8 @@ class CRM_Core_Page_AJAX_Location {
     }
 
     // Verify user permission on related contact
-    $employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($user);
-    if (!isset($employers[$cid])) {
+    $organizations = CRM_Contact_BAO_Relationship::getPermissionedContacts($user, NULL, NULL, 'Organization');
+    if (!isset($organizations[$cid])) {
       CRM_Utils_System::civiExit();
     }
 
@@ -180,8 +180,8 @@ class CRM_Core_Page_AJAX_Location {
           }
           elseif ($htmlType == 'Select Date') {
             $elements["onbehalf_{$key}"]['type'] = $htmlType;
-            $elements["onbehalf_{$key}"]['value'] = $defaults[$key];
-            $elements["onbehalf_{$key}_display"]['value'] = $defaults[$key];
+            //CRM-18349, date value must be ISO formatted before being set as a default value for crmDatepicker custom field
+            $elements["onbehalf_{$key}"]['value'] = CRM_Utils_Date::processDate($defaults[$key], NULL, FALSE, 'Y-m-d G:i:s');
           }
           else {
             $elements["onbehalf_{$key}"]['type'] = $htmlType;