bulk comment fix
[civicrm-core.git] / CRM / Core / Page / Basic.php
index c55c368829f9d4dd9657150f2f8b7f79e9376ec6..d0632397c490d9bd69fc6d93c9924c3ce2328c4a 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -127,9 +127,9 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
    * class constructor
    *
    * @param string $title title of the page
-   * @param int    $mode  mode of the page
+   * @param int $mode mode of the page
    *
-   * @return CRM_Core_Page
+   * @return \CRM_Core_Page_Basic
    */
   function __construct($title = NULL, $mode = NULL) {
     parent::__construct($title, $mode);
@@ -224,13 +224,13 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
 
     $fields = &$object->fields();
     $key = '';
-    if (CRM_Utils_Array::value('title', $fields)) {
+    if (!empty($fields['title'])) {
       $key = 'title';
     }
-    elseif (CRM_Utils_Array::value('label', $fields)) {
+    elseif (!empty($fields['label'])) {
       $key = 'label';
     }
-    elseif (CRM_Utils_Array::value('name', $fields)) {
+    elseif (!empty($fields['name'])) {
       $key = 'name';
     }
 
@@ -241,7 +241,10 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
       $object->orderBy($key . ' asc');
     }
 
-
+    //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
+    // this is loaded onto then replace with something like '__' & test
+    $separator = CRM_Core_DAO::VALUE_SEPARATOR;
+    $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
     // find all objects
     $object->find();
     while ($object->fetch()) {
@@ -257,7 +260,10 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
           $values[$object->id] = array();
           CRM_Core_DAO::storeValues($object, $values[$object->id]);
 
-          CRM_Contact_DAO_RelationshipType::addDisplayEnums($values[$object->id]);
+          if (is_a($object, 'CRM_Contact_DAO_RelationshipType')) {
+            $values[$object->id]['contact_type_a_display'] = $contactTypes[$values[$object->id]['contact_type_a']];
+            $values[$object->id]['contact_type_b_display'] = $contactTypes[$values[$object->id]['contact_type_b']];
+          }
 
           // populate action links
           $this->action($object, $action, $values[$object->id], $links, $permission);
@@ -291,7 +297,7 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
     $newAction       = $action;
     $hasDelete       = $hasDisable = TRUE;
 
-    if (CRM_Utils_Array::value('name', $values) && in_array($values['name'], array(
+    if (!empty($values['name']) && in_array($values['name'], array(
       'encounter_medium', 'case_type', 'case_status'))) {
       static $caseCount = NULL;
       if (!isset($caseCount)) {
@@ -307,7 +313,14 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
         $values['class'] = 'reserved';
         // check if object is relationship type
         $object_type = get_class($object);
-        if ($object_type == 'CRM_Contact_BAO_RelationshipType' || $object_type == 'CRM_Core_BAO_LocationType') {
+
+        $exceptions = array(
+          'CRM_Contact_BAO_RelationshipType',
+          'CRM_Core_BAO_LocationType',
+          'CRM_Badge_BAO_Layout',
+        );
+
+        if (in_array($object_type, $exceptions)) {
           $newAction = CRM_Core_Action::VIEW + CRM_Core_Action::UPDATE;
         }
         else {
@@ -350,6 +363,9 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
    * @param int $mode - what mode for the form ?
    * @param int $id - id of the entity (for update, view operations)
    *
+   * @param bool $imageUpload
+   * @param bool $pushUserContext
+   *
    * @return void
    */
   function edit($mode, $id = NULL, $imageUpload = FALSE, $pushUserContext = TRUE) {