Update copyright date for 2020
[civicrm-core.git] / CRM / Event / Form / ManageEvent.php
index 9e065f4cc16612d808b96c1912248e58feae6fd9..cdac4d6a23486754f04c99a08b1df1d287000820 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
+ | Copyright CiviCRM LLC (c) 2004-2020                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -27,7 +27,7 @@
 
 /**
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC (c) 2004-2020
  */
 
 /**
@@ -100,6 +100,21 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
     return 'create';
   }
 
+  /**
+   * Set the active tab
+   *
+   * @param string $default
+   *
+   * @throws \CRM_Core_Exception
+   */
+  public function setSelectedChild($default = NULL) {
+    $selectedChild = CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $this, FALSE, $default);
+    if (!empty($selectedChild)) {
+      $this->set('selectedChild', $selectedChild);
+      $this->assign('selectedChild', $selectedChild);
+    }
+  }
+
   /**
    * Set variables up before form is built.
    */
@@ -156,33 +171,21 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
 
     $this->assign('isTemplate', $this->_isTemplate);
 
+    // Set "Manage Event" Title
+    $title = NULL;
     if ($this->_id) {
       if ($this->_isTemplate) {
-        $title = CRM_Utils_Array::value('template_title', $eventInfo);
-        CRM_Utils_System::setTitle(ts('Edit Event Template') . " - $title");
+        $title = ts('Edit Event Template') . ' - ' . CRM_Utils_Array::value('template_title', $eventInfo);
       }
       else {
-        $configureText = ts('Configure Event');
-        $title = CRM_Utils_Array::value('title', $eventInfo);
-        //If it is a repeating event change title
-        if ($this->_isRepeatingEvent) {
-          $configureText = 'Configure Repeating Event';
-        }
-        CRM_Utils_System::setTitle($configureText . " - $title");
+        $configureText = $this->_isRepeatingEvent ? ts('Configure Repeating Event') : ts('Configure Event');
+        $title = $configureText . ' - ' . CRM_Utils_Array::value('title', $eventInfo);
       }
-      $this->assign('title', $title);
     }
     elseif ($this->_action & CRM_Core_Action::ADD) {
-      if ($this->_isTemplate) {
-        $title = ts('New Event Template');
-        CRM_Utils_System::setTitle($title);
-      }
-      else {
-        $title = ts('New Event');
-        CRM_Utils_System::setTitle($title);
-      }
-      $this->assign('title', $title);
+      $title = $this->_isTemplate ? ts('New Event Template') : ts('New Event');
     }
+    $this->setTitle($title);
 
     if (CRM_Core_Permission::check('view event participants') &&
       CRM_Core_Permission::check('view all contacts')
@@ -271,6 +274,8 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
       $defaults['is_template'] = $this->_isTemplate;
       $defaults['template_id'] = $defaults['id'];
       unset($defaults['id']);
+      unset($defaults['start_date']);
+      unset($defaults['end_date']);
     }
     else {
       $defaults['is_active'] = 1;
@@ -378,7 +383,7 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
 
       CRM_Core_Session::setStatus(ts("'%1' information has been saved.",
         [1 => CRM_Utils_Array::value('title', CRM_Utils_Array::value($subPage, $this->get('tabHeader')), $className)]
-      ), ts('Saved'), 'success');
+      ), $this->getTitle(), 'success');
 
       $config = CRM_Core_Config::singleton();
       if (in_array('CiviCampaign', $config->enableComponents)) {