From: Nik Okuntseff Date: Wed, 30 Mar 2016 18:59:22 +0000 (+0000) Subject: Refactoring - more usage of ttUser::isPluginEnabled(). X-Git-Tag: timetracker_1.19-1~1759 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0dfc4dda20c54e173938eaf196f8e071ce790830;p=timetracker.git Refactoring - more usage of ttUser::isPluginEnabled(). --- diff --git a/WEB-INF/templates/expense_edit.tpl b/WEB-INF/templates/expense_edit.tpl index 4c921299..41e3c2e2 100644 --- a/WEB-INF/templates/expense_edit.tpl +++ b/WEB-INF/templates/expense_edit.tpl @@ -78,7 +78,7 @@ function get_date() { {if $user->isPluginEnabled('cl')} - + {/if} diff --git a/WEB-INF/templates/expenses.tpl b/WEB-INF/templates/expenses.tpl index a64fbc26..12d9534d 100644 --- a/WEB-INF/templates/expenses.tpl +++ b/WEB-INF/templates/expenses.tpl @@ -81,7 +81,7 @@ function get_date() { {/if} {if $user->isPluginEnabled('cl')} - + {/if} diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 6e45a438..b55bc06a 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
{$i18n.label.client} {if in_array('cm', explode(',', $user->plugins))}(*){/if}:{$i18n.label.client} {if $user->isPluginEnabled('cm')}(*){/if}: {$forms.expenseItemForm.client.control}
{$i18n.label.client}{if in_array('cm', explode(',', $user->plugins))} (*){/if}:{$i18n.label.client}{if $user->isPluginEnabled('cm')} (*){/if}: {$forms.expensesForm.client.control}
- {/if} -{if in_array('iv', explode(',', $user->plugins))} +{if $user->isPluginEnabled('iv')} {/if} {if ($custom_fields && $custom_fields->fields[0])} diff --git a/WEB-INF/templates/mobile/time_edit.tpl b/WEB-INF/templates/mobile/time_edit.tpl index 2dbd7460..7d1e66fe 100644 --- a/WEB-INF/templates/mobile/time_edit.tpl +++ b/WEB-INF/templates/mobile/time_edit.tpl @@ -214,7 +214,7 @@ function get_date() { {/if} -{if in_array('iv', explode(',', $user->plugins))} +{if $user->isPluginEnabled('iv')} {/if} {if ($custom_fields && $custom_fields->fields[0])} diff --git a/WEB-INF/templates/mobile/timer.tpl b/WEB-INF/templates/mobile/timer.tpl index b32da743..5df54cb8 100644 --- a/WEB-INF/templates/mobile/timer.tpl +++ b/WEB-INF/templates/mobile/timer.tpl @@ -221,7 +221,7 @@ startTimer(); {/if} -{if in_array('iv', explode(',', $user->plugins))} +{if $user->isPluginEnabled('iv')} {/if} {if ($custom_fields && $custom_fields->fields[0])} diff --git a/WEB-INF/templates/reports.tpl b/WEB-INF/templates/reports.tpl index b5db6d3b..bd5ab3f4 100644 --- a/WEB-INF/templates/reports.tpl +++ b/WEB-INF/templates/reports.tpl @@ -197,7 +197,7 @@ function handleCheckboxes() { {/if} {/if} -{if in_array('iv', explode(',', $user->plugins))} +{if $user->isPluginEnabled('iv')} @@ -236,12 +236,12 @@ function handleCheckboxes() {
 Anuko Time Tracker 1.9.20.3460 | Copyright © Anuko | +  Anuko Time Tracker 1.9.20.3461 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/header.tpl b/WEB-INF/templates/header.tpl index 4d08cfc1..ce8e229c 100644 --- a/WEB-INF/templates/header.tpl +++ b/WEB-INF/templates/header.tpl @@ -105,12 +105,11 @@ With 101% height we essentially force the scrollbar to always appear. --> · {$i18n.menu.expenses} {/if} {if !$user->isClient()}· {/if}{$i18n.menu.reports} - {if ($user->canManageTeam() || $user->isClient()) && in_array('iv', explode(',', $user->plugins))} + {if ($user->canManageTeam() || $user->isClient()) && $user->isPluginEnabled('iv')} · {$i18n.title.invoices} {/if} - {if (in_array('ch', explode(',', $user->plugins)) && !$user->isClient()) && ($smarty.const.MODE_PROJECTS == $user->tracking_mode - || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode - || in_array('cl', explode(',', $user->plugins)))} + {if ($user->isPluginEnabled('ch') && !$user->isClient()) && ($smarty.const.MODE_PROJECTS == $user->tracking_mode + || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode || $user->isPluginEnabled('cl'))} · {$i18n.menu.charts} {/if} {if !$user->isClient() && ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)} @@ -122,7 +121,7 @@ With 101% height we essentially force the scrollbar to always appear. --> {if !$user->isClient()} · {$i18n.menu.users} {/if} - {if $user->canManageTeam() && in_array('cl', explode(',', $user->plugins))} + {if $user->canManageTeam() && $user->isPluginEnabled('cl')} · {$i18n.menu.clients} {/if} {if $user->isManager()} diff --git a/WEB-INF/templates/mobile/time.tpl b/WEB-INF/templates/mobile/time.tpl index 4371be29..46d8a5e6 100644 --- a/WEB-INF/templates/mobile/time.tpl +++ b/WEB-INF/templates/mobile/time.tpl @@ -254,7 +254,7 @@ function get_date() {
{$i18n.label.client}:
{$forms.timeRecordForm.client.control}
{$i18n.label.client}:
{$forms.timeRecordForm.client.control}
{$i18n.label.client}:
{$forms.timerRecordForm.client.control}
{$i18n.form.time.billable}  
-{if $user->isPluginEnabled('cl') || in_array('iv', explode(',', $user->plugins))} +{if $user->isPluginEnabled('cl') || $user->isPluginEnabled('iv')} {if $user->isPluginEnabled('cl')} {/if} - {if ($user->canManageTeam() || $user->isClient()) && in_array('iv', explode(',', $user->plugins))} + {if ($user->canManageTeam() || $user->isClient()) && $user->isPluginEnabled('iv')} {/if} diff --git a/WEB-INF/templates/time.tpl b/WEB-INF/templates/time.tpl index d1610112..089e57cc 100644 --- a/WEB-INF/templates/time.tpl +++ b/WEB-INF/templates/time.tpl @@ -223,13 +223,13 @@ function get_time() { {/if} -{if in_array('cl', explode(',', $user->plugins))} +{if $user->isPluginEnabled('cl')} - + {/if} -{if in_array('iv', explode(',', $user->plugins))} +{if $user->isPluginEnabled('iv')} @@ -294,7 +294,7 @@ function get_time() { {if $time_records}
{$forms.timeRecordForm.onBehalfUser.control}
{$i18n.label.client}{if in_array('cm', explode(',', $user->plugins))} (*){/if}:{$i18n.label.client}{if $user->isPluginEnabled('cm')} (*){/if}: {$forms.timeRecordForm.client.control}
 
- {if in_array('cl', explode(',', $user->plugins))} + {if $user->isPluginEnabled('cl')} {/if} {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)} @@ -313,7 +313,7 @@ function get_time() { {foreach $time_records as $record} - {if in_array('cl', explode(',', $user->plugins))} + {if $user->isPluginEnabled('cl')} {/if} {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)} diff --git a/WEB-INF/templates/time_edit.tpl b/WEB-INF/templates/time_edit.tpl index 4a97fc96..03e00087 100644 --- a/WEB-INF/templates/time_edit.tpl +++ b/WEB-INF/templates/time_edit.tpl @@ -205,13 +205,13 @@ function setNow(formField) {
{$i18n.label.client}
{$record.client|escape:'html'}
-{if in_array('cl', explode(',', $user->plugins))} +{if $user->isPluginEnabled('cl')} - + {/if} -{if in_array('iv', explode(',', $user->plugins))} +{if $user->isPluginEnabled('iv')} diff --git a/charts.php b/charts.php index 08834508..9dec840a 100644 --- a/charts.php +++ b/charts.php @@ -67,11 +67,11 @@ if (!$cl_type) { $cl_type = $sc->getValue(SYSC_CHART_TYPE); } if (MODE_TIME == $user->tracking_mode) { - if (in_array('cl', explode(',', $user->plugins))) + if ($user->isPluginEnabled('cl')) $cl_type = CHART_CLIENTS; } else { if ($cl_type == CHART_CLIENTS) { - if (!in_array('cl', explode(',', $user->plugins))) + if (!$user->isPluginEnabled('cl')) $cl_type = CHART_PROJECTS; } elseif ($cl_type == CHART_TASKS) { if (MODE_PROJECTS_AND_TASKS != $user->tracking_mode) @@ -154,15 +154,14 @@ $chart_form->addInput(array('type' => 'combobox', )); // Chart type options. -$chart_selector = (MODE_PROJECTS_AND_TASKS == $user->tracking_mode - || in_array('cl', explode(',', $user->plugins))); +$chart_selector = (MODE_PROJECTS_AND_TASKS == $user->tracking_mode || $user->isPluginEnabled('cl')); if ($chart_selector) { $types = array(); if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) $types[CHART_PROJECTS] = $i18n->getKey('dropdown.projects'); if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) $types[CHART_TASKS] = $i18n->getKey('dropdown.tasks'); - if (in_array('cl', explode(',', $user->plugins))) + if ($user->isPluginEnabled('cl')) $types[CHART_CLIENTS] = $i18n->getKey('dropdown.clients'); // Add chart type dropdown. diff --git a/expense_edit.php b/expense_edit.php index abd5c39c..16b9abba 100644 --- a/expense_edit.php +++ b/expense_edit.php @@ -68,7 +68,7 @@ if ($request->isPost()) { $form = new Form('expenseItemForm'); // Dropdown for clients in MODE_TIME. Use all active clients. -if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plugins))) { +if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', @@ -93,7 +93,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Dropdown for clients if the clients plugin is enabled. - if (in_array('cl', explode(',', $user->plugins))) { + if ($user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) @@ -131,7 +131,7 @@ $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getK if ($request->isPost()) { // Validate user input. - if (in_array('cl', explode(',', $user->plugins)) && in_array('cm', explode(',', $user->plugins)) && !$cl_client) + if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client) $err->add($i18n->getKey('error.client')); if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { if (!$cl_project) $err->add($i18n->getKey('error.project')); diff --git a/expenses.php b/expenses.php index 307c9c01..f1319e0f 100644 --- a/expenses.php +++ b/expenses.php @@ -75,7 +75,7 @@ if ($user->canManageTeam()) { } // Dropdown for clients in MODE_TIME. Use all active clients. -if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plugins))) { +if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', @@ -101,7 +101,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Dropdown for clients if the clients plugin is enabled. - if (in_array('cl', explode(',', $user->plugins))) { + if ($user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) @@ -145,7 +145,7 @@ if ($lock_interval > 0) { if ($request->isPost()) { if ($request->getParameter('btn_submit')) { // Validate user input. - if (in_array('cl', explode(',', $user->plugins)) && in_array('cm', explode(',', $user->plugins)) && !$cl_client) + if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client) $err->add($i18n->getKey('error.client')); if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { if (!$cl_project) $err->add($i18n->getKey('error.project')); diff --git a/invoice_add.php b/invoice_add.php index 0efc99ee..f68753fc 100644 --- a/invoice_add.php +++ b/invoice_add.php @@ -50,7 +50,7 @@ $form = new Form('invoiceForm'); $form->addInput(array('type'=>'datefield','name'=>'date','size'=>'20','value'=>$cl_date)); // Dropdown for clients if the clients plugin is enabled. -if (in_array('cl', explode(',', $user->plugins))) { +if ($user->isPluginEnabled('cl')) { $clients = ttTeamHelper::getActiveClients($user->team_id); $form->addInput(array('type'=>'combobox','name'=>'client','style'=>'width: 250px;','data'=>$clients,'datakeys'=>array('id','name'),'value'=>$cl_client,'empty'=>array(''=>$i18n->getKey('dropdown.select')))); } diff --git a/mobile/time.php b/mobile/time.php index 268bf9ba..b7a26b64 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -69,7 +69,7 @@ $cl_note = trim($request->getParameter('note')); $cl_cf_1 = trim($request->getParameter('cf_1', ($request->getMethod()=='POST'? null : @$_SESSION['cf_1']))); $_SESSION['cf_1'] = $cl_cf_1; $cl_billable = 1; -if (in_array('iv', explode(',', $user->plugins))) { +if ($user->isPluginEnabled('iv')) { if ($request->isPost()) { $cl_billable = $request->getParameter('billable'); $_SESSION['billable'] = (int) $cl_billable; @@ -88,7 +88,7 @@ $_SESSION['task'] = $cl_task; $form = new Form('timeRecordForm'); // Dropdown for clients in MODE_TIME. Use all active clients. -if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plugins))) { +if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', @@ -114,7 +114,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Dropdown for clients if the clients plugin is enabled. - if (in_array('cl', explode(',', $user->plugins))) { + if ($user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) @@ -164,7 +164,7 @@ if (!$user->canManageTeam() && defined('READONLY_START_FINISH') && isTrue(READON if ((TYPE_DURATION == $user->record_type) || (TYPE_ALL == $user->record_type)) $form->addInput(array('type'=>'text','name'=>'duration','value'=>$cl_duration,'onchange'=>"formDisable('duration');")); $form->addInput(array('type'=>'textarea','name'=>'note','style'=>'width: 250px; height: 60px;','value'=>$cl_note)); -if (in_array('iv', explode(',', $user->plugins))) +if ($user->isPluginEnabled('iv')) $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable)); $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on btn_submit click. $form->addInput(array('type'=>'submit','name'=>'btn_submit','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.submit'))); @@ -196,7 +196,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_submit')) { // Validate user input. - if (in_array('cl', explode(',', $user->plugins)) && in_array('cm', explode(',', $user->plugins)) && !$cl_client) + if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client) $err->add($i18n->getKey('error.client')); if ($custom_fields) { if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $err->add($i18n->getKey('error.field'), $custom_fields->fields[0]['label']); diff --git a/mobile/time_edit.php b/mobile/time_edit.php index dbba54af..f2083ee4 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -70,7 +70,7 @@ if ($request->isPost()) { $cl_project = $request->getParameter('project'); $cl_task = $request->getParameter('task'); $cl_billable = 1; - if (in_array('iv', explode(',', $user->plugins))) + if ($user->isPluginEnabled('iv')) $cl_billable = $request->getParameter('billable'); } else { $cl_client = $time_rec['client_id']; @@ -106,7 +106,7 @@ if ($request->isPost()) { $form = new Form('timeRecordForm'); // Dropdown for clients in MODE_TIME. Use all active clients. -if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plugins))) { +if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', @@ -132,7 +132,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Dropdown for clients if the clients plugin is enabled. - if (in_array('cl', explode(',', $user->plugins))) { + if ($user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) @@ -201,7 +201,7 @@ if ($custom_fields && $custom_fields->fields[0]) { } // Hidden control for record id. $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id)); -if (in_array('iv', explode(',', $user->plugins))) +if ($user->isPluginEnabled('iv')) $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable)); $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on btn_save click. $form->addInput(array('type'=>'submit','name'=>'btn_save','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.save'))); @@ -210,7 +210,7 @@ $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getK if ($request->isPost()) { // Validate user input. - if (in_array('cl', explode(',', $user->plugins)) && in_array('cm', explode(',', $user->plugins)) && !$cl_client) + if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client) $err->add($i18n->getKey('error.client')); if ($custom_fields) { if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $err->add($i18n->getKey('error.field'), $custom_fields->fields[0]['label']); diff --git a/mobile/timer.php b/mobile/timer.php index 7dfdc99f..949d585c 100644 --- a/mobile/timer.php +++ b/mobile/timer.php @@ -64,7 +64,7 @@ $cl_finish = trim($request->getParameter('browser_time')); $cl_cf_1 = trim($request->getParameter('cf_1', ($request->getMethod()=='POST'? null : @$_SESSION['cf_1']))); $_SESSION['cf_1'] = $cl_cf_1; $cl_billable = 1; -if (in_array('iv', explode(',', $user->plugins))) { +if ($user->isPluginEnabled('iv')) { if ($request->isPost()) { $cl_billable = $request->getParameter('billable'); $_SESSION['billable'] = (int) $cl_billable; @@ -87,7 +87,7 @@ $enable_controls = ($uncompleted == null); $form = new Form('timerRecordForm'); // Dropdown for clients in MODE_TIME. Use all active clients. -if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plugins))) { +if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', @@ -115,7 +115,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Dropdown for clients if the clients plugin is enabled. - if (in_array('cl', explode(',', $user->plugins))) { + if ($user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) @@ -154,7 +154,7 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { 'datakeys'=>array('id','name'), 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); } -if (in_array('iv', explode(',', $user->plugins))) +if ($user->isPluginEnabled('iv')) $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable,'enable'=>$enable_controls)); $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on button click. $form->addInput(array('type'=>'hidden','name'=>'browser_time','value'=>'')); // User current time, which gets filled in on button click. @@ -194,7 +194,7 @@ if ($request->isPost()) { $cl_finish = null; // Validate user input. - if (in_array('cl', explode(',', $user->plugins)) && in_array('cm', explode(',', $user->plugins)) && !$cl_client) + if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client) $err->add($i18n->getKey('error.client')); if ($custom_fields) { if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $err->add($i18n->getKey('error.field'), $custom_fields->fields[0]['label']); diff --git a/reports.php b/reports.php index c8b34cc3..4947e4d9 100644 --- a/reports.php +++ b/reports.php @@ -66,7 +66,7 @@ $form->addInput(array('type'=>'submit','name'=>'btn_generate','value'=>$i18n->ge $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete'),'onclick'=>"return confirm('".$i18n->getKey('form.reports.confirm_delete')."')")); // Dropdown for clients if the clients plugin is enabled. -if (in_array('cl', explode(',', $user->plugins)) && !($user->isClient() && $user->client_id)) { +if ($user->isPluginEnabled('cl') && !($user->isClient() && $user->client_id)) { if ($user->canManageTeam() || ($user->isClient() && !$user->client_id)) $client_list = ttClientHelper::getClients($user->team_id); else @@ -171,9 +171,9 @@ $form->addInput(array('type'=>'datefield','maxlength'=>'20','name'=>'start_date' $form->addInput(array('type'=>'datefield','maxlength'=>'20','name'=>'end_date')); // Add checkboxes for fields. -if (in_array('cl', explode(',', $user->plugins))) +if ($user->isPluginEnabled('cl')) $form->addInput(array('type'=>'checkbox','name'=>'chclient','data'=>1)); -if (($user->canManageTeam() || $user->isClient()) && in_array('iv', explode(',', $user->plugins))) +if (($user->canManageTeam() || $user->isClient()) && $user->isPluginEnabled('iv')) $form->addInput(array('type'=>'checkbox','name'=>'chinvoice','data'=>1)); if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) $form->addInput(array('type'=>'checkbox','name'=>'chproject','data'=>1)); @@ -196,7 +196,7 @@ $group_by_options['no_grouping'] = $i18n->getKey('form.reports.group_by_no'); $group_by_options['date'] = $i18n->getKey('form.reports.group_by_date'); if ($user->canManageTeam() || $user->isClient()) $group_by_options['user'] = $i18n->getKey('form.reports.group_by_user'); -if (in_array('cl', explode(',', $user->plugins)) && !($user->isClient() && $user->client_id)) +if ($user->isPluginEnabled('cl') && !($user->isClient() && $user->client_id)) $group_by_options['client'] = $i18n->getKey('form.reports.group_by_client'); if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) $group_by_options['project'] = $i18n->getKey('form.reports.group_by_project'); diff --git a/time.php b/time.php index 193f7a2b..047556b4 100644 --- a/time.php +++ b/time.php @@ -72,7 +72,7 @@ $cl_note = trim($request->getParameter('note')); $cl_cf_1 = trim($request->getParameter('cf_1', ($request->getMethod()=='POST'? null : @$_SESSION['cf_1']))); $_SESSION['cf_1'] = $cl_cf_1; $cl_billable = 1; -if (in_array('iv', explode(',', $user->plugins))) { +if ($user->isPluginEnabled('iv')) { if ($request->isPost()) { $cl_billable = $request->getParameter('billable'); $_SESSION['billable'] = (int) $cl_billable; @@ -106,7 +106,7 @@ if ($user->canManageTeam()) { } // Dropdown for clients in MODE_TIME. Use all active clients. -if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plugins))) { +if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', @@ -132,7 +132,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Dropdown for clients if the clients plugin is enabled. - if (in_array('cl', explode(',', $user->plugins))) { + if ($user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) @@ -185,7 +185,7 @@ if ((TYPE_DURATION == $user->record_type) || (TYPE_ALL == $user->record_type)) $form->addInput(array('type'=>'text','name'=>'duration','value'=>$cl_duration,'onchange'=>"formDisable('duration');")); $form->addInput(array('type'=>'textarea','name'=>'note','style'=>'width: 600px; height: 40px;','value'=>$cl_note)); $form->addInput(array('type'=>'calendar','name'=>'date','value'=>$cl_date)); // calendar -if (in_array('iv', explode(',', $user->plugins))) +if ($user->isPluginEnabled('iv')) $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable)); $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on btn_submit click. $form->addInput(array('type'=>'submit','name'=>'btn_submit','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.submit'))); @@ -217,7 +217,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_submit')) { // Validate user input. - if (in_array('cl', explode(',', $user->plugins)) && in_array('cm', explode(',', $user->plugins)) && !$cl_client) + if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client) $err->add($i18n->getKey('error.client')); if ($custom_fields) { if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $err->add($i18n->getKey('error.field'), $custom_fields->fields[0]['label']); diff --git a/time_edit.php b/time_edit.php index 5dad555c..18638b07 100644 --- a/time_edit.php +++ b/time_edit.php @@ -70,7 +70,7 @@ if ($request->isPost()) { $cl_project = $request->getParameter('project'); $cl_task = $request->getParameter('task'); $cl_billable = 1; - if (in_array('iv', explode(',', $user->plugins))) + if ($user->isPluginEnabled('iv')) $cl_billable = $request->getParameter('billable'); } else { $cl_client = $time_rec['client_id']; @@ -106,7 +106,7 @@ if ($request->isPost()) { $form = new Form('timeRecordForm'); // Dropdown for clients in MODE_TIME. Use all active clients. -if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plugins))) { +if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', @@ -132,7 +132,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Dropdown for clients if the clients plugin is enabled. - if (in_array('cl', explode(',', $user->plugins))) { + if ($user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) @@ -201,7 +201,7 @@ if ($custom_fields && $custom_fields->fields[0]) { } // Hidden control for record id. $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id)); -if (in_array('iv', explode(',', $user->plugins))) +if ($user->isPluginEnabled('iv')) $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable)); $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on btn_save or btn_copy click. $form->addInput(array('type'=>'submit','name'=>'btn_save','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.save'))); @@ -211,7 +211,7 @@ $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getK if ($request->isPost()) { // Validate user input. - if (in_array('cl', explode(',', $user->plugins)) && in_array('cm', explode(',', $user->plugins)) && !$cl_client) + if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client) $err->add($i18n->getKey('error.client')); if ($custom_fields) { if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $err->add($i18n->getKey('error.field'), $custom_fields->fields[0]['label']); diff --git a/user_add.php b/user_add.php index 59300859..403c6ca6 100644 --- a/user_add.php +++ b/user_add.php @@ -43,7 +43,7 @@ if (!ttAccessCheck(right_manage_team)) { // The "limit" plugin is not required for normal operation of the Time Tracker. @include('plugins/limit/user_add.php'); -if (in_array('cl', explode(',', $user->plugins))) +if ($user->isPluginEnabled('cl')) $clients = ttTeamHelper::getActiveClients($user->team_id); $assigned_projects = array(); @@ -84,10 +84,10 @@ $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'email','value'= $roles[ROLE_USER] = $i18n->getKey('label.user'); $roles[ROLE_COMANAGER] = $i18n->getKey('form.users.comanager'); -if (in_array('cl', explode(',', $user->plugins))) +if ($user->isPluginEnabled('cl')) $roles[ROLE_CLIENT] = $i18n->getKey('label.client'); $form->addInput(array('type'=>'combobox','onchange'=>'handleClientControl()','name'=>'role','value'=>$cl_role,'data'=>$roles)); -if (in_array('cl', explode(',', $user->plugins))) +if ($user->isPluginEnabled('cl')) $form->addInput(array('type'=>'combobox','name'=>'client','value'=>$cl_client_id,'data'=>$clients,'datakeys'=>array('id', 'name'),'empty'=>array(''=>$i18n->getKey('dropdown.select')))); $form->addInput(array('type'=>'floatfield','maxlength'=>'10','name'=>'rate','format'=>'.2','value'=>$cl_rate));
{$i18n.label.client}{if in_array('cm', explode(',', $user->plugins))} (*){/if}:{$i18n.label.client}{if $user->isPluginEnabled('cm')} (*){/if}: {$forms.timeRecordForm.client.control}