* @throws Exception
*/
public function run($args = NULL, $pageArgs = NULL, $sort = NULL) {
+ $id = $this->getIdAndAction();
// handle the revert action and offload the rest to parent
- if (CRM_Utils_Request::retrieve('action', 'String', $this) & CRM_Core_Action::REVERT) {
-
- $id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
- if (!$this->checkPermission($id, NULL)) {
- CRM_Core_Error::fatal(ts('You do not have permission to revert this template.'));
- }
-
+ if ($this->_action & CRM_Core_Action::REVERT) {
$this->_revertedId = $id;
-
CRM_Core_BAO_MessageTemplate::revert($id);
}
- $selectedChild = CRM_Utils_Request::retrieve('selectedChild', 'String', $this);
- if (in_array($selectedChild, array('user', 'workflow'))) {
- $this->assign('selectedChild', $selectedChild);
- }
+
return parent::run($args, $pageArgs, $sort);
}
->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header')
->addSetting(array(
'summaryPrint' => array('mode' => $this->_print),
- 'tabSettings' => array('active' => CRM_Utils_Request::retrieve('selectedChild', 'String', $this, FALSE, 'summary')),
+ 'tabSettings' => array('active' => CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $this, FALSE, 'summary')),
));
$this->assign('summaryPrint', $this->_print);
$session = CRM_Core_Session::singleton();
*
* @return int
* The ID if present, or 0.
+ * @throws \CRM_Core_Exception
*/
public function getIdAndAction() {
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->assign('action', $this->_action);
+ $this->assign('selectedChild', CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $this));
+
// get 'id' if present
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
unset($params['id']);
$url = 'civicrm/event/manage/repeat';
- $urlParams = "action=update&reset=1&id={$this->_id}";
+ $urlParams = "action=update&reset=1&id={$this->_id}&selectedChild=repeat";
$linkedEntities = array(
array(
* @param CRM_Event_Form_ManageEvent $form
*
* @return array
+ * @throws \CRM_Core_Exception
*/
public static function build(&$form) {
+ $form->assign('selectedChild', CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $form));
+
$tabs = $form->get('tabHeader');
if (!$tabs || empty($_GET['reset'])) {
$tabs = self::process($form);
if (is_array($tabs)) {
foreach ($tabs as $subPage => $pageVal) {
- if ($pageVal['current'] === TRUE) {
+ if (CRM_Utils_Array::value('current', $pageVal) === TRUE) {
$current = $subPage;
break;
}
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
- *
- * @param
- *
- * @return void
*/
public function run() {
// get the requested action
// assign vars to templates
$this->assign('action', $action);
- $this->assign('selectedChild', CRM_Utils_Request::retrieve('selectedChild', 'String', $this));
+ $this->assign('selectedChild', CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $this));
$id = CRM_Utils_Request::retrieve('id', 'Positive',
$this, FALSE, 0
);
</script>
{/literal}
- {* Tab management *}
- <script type="text/javascript">
- var selectedTab = 'summary';
- {if $selectedChild}selectedTab = "{$selectedChild}";{/if}
-
- {literal}
-
- CRM.$(function($) {
- var tabIndex = $('#tab_' + selectedTab).prevAll().length;
- $("#mainTabContainer").tabs({active: tabIndex});
- $(".crm-tab-button").addClass("ui-corner-bottom");
- });
- {/literal}
- </script>
+ {include file="CRM/common/TabSelected.tpl" defaultTab="summary"}
{* Refresh buttons *}
{literal}
{/foreach}
</div>
</div>
- <script type='text/javascript'>
- var selectedTab = 'user';
- {if $selectedChild}selectedTab = '{$selectedChild}';{/if}
- {literal}
- CRM.$(function($) {
- var tabIndex = $('#tab_' + selectedTab).prevAll().length
- $("#mainTabContainer").tabs( {active: tabIndex} );
- });
- {/literal}
- </script>
+{include file="CRM/common/TabSelected.tpl" defaultTab="user"}
{elseif $action ne 1 and $action ne 2 and $action ne 4 and $action ne 8}
<div class="messages status no-popup">
<div class="contact-summary-contribute-tab view-content">
<div id="secondaryTabContainer" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
- {* Tab management *}
- <script type="text/javascript">
- var selectedTab = 'contributions';
+ {include file="CRM/common/TabSelected.tpl" defaultTab="contributions" tabContainer="#secondaryTabContainer"}
- {literal}
- CRM.$(function($) {
- var tabIndex = $('#tab_' + selectedTab).prevAll().length;
- $("#secondaryTabContainer").tabs({active: tabIndex});
- $(".crm-tab-button").addClass("ui-corner-bottom");
- });
- {/literal}
- </script>
<ul class="ui-tabs-nav ui-corner-all ui-helper-reset ui-helper-clearfix ui-widget-header">
<li id="tab_contributions" class="crm-tab-button ui-corner-all ui-tabs-tab ui-corner-top ui-state-default ui-tab ui-tabs-active ui-state-active">
<a href="#contributions-subtab" title="{ts}Contributions{/ts}">
</script>
{/literal}
{include file="CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl" entityID=$id entityTable="civicrm_event"}
+{include file="CRM/common/TabSelected.tpl" defaultTab="settings"}
</div>
</div>{* reserved profile*}
- </div> {* maincontainer*}
- <script type='text/javascript'>
- var selectedTab = 'user-profiles';
- {if $selectedChild}selectedTab = '{$selectedChild}';{/if}
- {literal}
- CRM.$(function($) {
- var tabIndex = $('#tab_' + selectedTab).prevAll().length
- $("#mainTabContainer").tabs( {active: tabIndex} );
- });
- {/literal}
- </script>
+ </div>
+{include file="CRM/common/TabSelected.tpl" defaultTab="user-profiles"}
{else}
{if $action ne 1} {* When we are adding an item, we should not display this message *}
--- /dev/null
+<script type='text/javascript'>
+ var selectedTab = '{$defaultTab}';
+ var tabContainer = '#mainTabContainer';
+ {if $tabContainer}tabContainer = '{$tabContainer}';{/if}
+ {if $selectedChild}selectedTab = '{$selectedChild}';{/if}
+ {literal}
+ CRM.$(function($) {
+ var tabIndex = $('#tab_' + selectedTab).prevAll().length;
+ $(tabContainer).tabs( {active: tabIndex} );
+ });
+ {/literal}
+</script>