Skip to content

Commit

Permalink
Merge pull request #56 from openjournalteam/ojt-support-34
Browse files Browse the repository at this point in the history
add support 34
  • Loading branch information
rahmanramsi authored Oct 26, 2023
2 parents d6c3f93 + 1dcae22 commit 4dbe867
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 25 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 3.0.1.0 : 21 Oct 2023
- Integration with OJT Support platform

### 3.0.0.4 : 05 Sep 2023
- Fix showing log by PluginRegistry on Modules Plugin

Expand Down
15 changes: 12 additions & 3 deletions OjtControlPanelPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,27 @@ public function setupBackendPage($hookName, $args)
if (!$request->getContext()) return;

$templateMgr = TemplateManager::getManager($this->getRequest());
$dispatcher = $request->getDispatcher();
$router = $request->getRouter();
$userRoles = (array) $router->getHandler()->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);
if (!$request->getUser() || !count(array_intersect([Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN], $userRoles))) return;
$user = $request->getUser();
if (!$user || !count(array_intersect([Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN], $userRoles))) return;

$menu = $templateMgr->getState('menu');
$menu['ojtPlugin'] = [
'name' => 'OJT Control Panel',
'url' => $request->getDispatcher()->url($request, Application::ROUTE_PAGE, $request->getContext()->getPath()) . '/ojt?PageSpeed=off',
'url' => $request->getDispatcher()->url($request, Application::ROUTE_PAGE, $request->getContext()->getPath(), 'ojt') . '?PageSpeed=off',
"isCurrent" => false,
];


if($this->getSetting($this->getCurrentContextId(), 'show_support_link_ojs') ?? true){
$menu['ojtSupportTicketing'] = [
'name' => 'Get OJT support',
'url' => $request->getDispatcher()->url($request, Application::ROUTE_PAGE, $request->getContext()->getPath(), 'ojt', 'support'),
"isCurrent" => false
];
}

$templateMgr->setState(['menu' => $menu]);
}

Expand Down
24 changes: 22 additions & 2 deletions OjtPageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ public function index($args, $request)
return $templateMgr->display($this->ojtPlugin->getTemplateResource('index.tpl'));
}

public function support($args, $request)
{
$user = $request->getUser();
$journalName = $request->getContext()->getLocalizedName();
$params = [
$user->getEmail(),
time(),
$user->getLocalizedGivenName(),
$user->getLocalizedFamilyName(),
$journalName
];
$url = 'https://ticketing.openjournaltheme.com/login/' . base64_encode(implode('+', $params));

header('Location: ' . $url, true, 302);

return;
}

protected function getPluginFullUrl($path = '', $withVersion = true)
{
return $this->ojtPlugin->getPluginFullUrl($path, $withVersion);
Expand All @@ -113,7 +131,8 @@ public function settings($args, $request)
{
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign('settings', [
'enable_diagnostic' => $this->ojtPlugin->isDiagnosticEnabled()
'enable_diagnostic' => $this->ojtPlugin->isDiagnosticEnabled(),
'show_support_link_ojs' => $this->ojtPlugin->getSetting($this->contextId, 'show_support_link_ojs') ?? true,
]);


Expand All @@ -127,7 +146,8 @@ public function settings($args, $request)
public function saveSettings($args, $request)
{
$this->ojtPlugin->updateSetting(Application::CONTEXT_SITE, 'enable_diagnostic', filter_var($request->getUserVar('enable_diagnostic'), FILTER_VALIDATE_BOOLEAN));

$this->ojtPlugin->updateSetting($this->contextId, 'show_support_link_ojs', filter_var($request->getUserVar('show_support_link_ojs'), FILTER_VALIDATE_BOOLEAN));

$json['error'] = 0;
$json['msg'] = 'Save Success';
return showJson($json);
Expand Down
5 changes: 5 additions & 0 deletions templates/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@
</svg>
<span class="ojt-font-medium">OJS Tutorial</span>
</a>
<a href="{url router=\PKP\core\PKPApplication::ROUTE_PAGE page="ojt" op="support"}" target="_blank"
class="ojt-w-full ojt-text-sm ojt-flex ojt-text-gray-500 ojt-items-center ojt-px-4 ojt-py-2 ojt-rounded-xl ojt-from-primary-500 ojt-via-primary-600 ojt-to-primary-700 hover:ojt-bg-gradient-to-br hover:ojt-text-white ojt-gap-4 ojt-text-left">
<svg class="ojt-icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" viewBox="0 0 24 24" fill="currentColor"><g><rect fill="none" height="24" width="24"></rect></g><g><g><circle cx="9" cy="13" r="1"></circle><circle cx="15" cy="13" r="1"></circle><path d="M18,11.03C17.52,8.18,15.04,6,12.05,6c-3.03,0-6.29,2.51-6.03,6.45c2.47-1.01,4.33-3.21,4.86-5.89 C12.19,9.19,14.88,11,18,11.03z"></path><path d="M20.99,12C20.88,6.63,16.68,3,12,3c-4.61,0-8.85,3.53-8.99,9H2v6h3v-5.81c0-3.83,2.95-7.18,6.78-7.29 c3.96-0.12,7.22,3.06,7.22,7V19h-8v2h10v-3h1v-6H20.99z"></path></g></g></svg>
<span>Get Support</span>
</a>
<a href="https://openjournaltheme.com/about-open-journal-theme" target="_blank"
class="focus:ojt-outline-none ojt-text-white ojt-text-sm ojt-justify-center ojt-py-2.5 ojt-px-5 ojt-rounded-xl ojt-flex ojt-items-center ojt-bg-gradient-to-l ojt-text-white ojt-shadow-lg ojt-shadow-primary-500/50 ojt-from-primary-500 ojt-via-primary-600 ojt-to-primary-700 hover:ojt-bg-gradient-to-br ojt-gap-4">
<img src="{$ojtPlugin->logo}" class="ojt-h-5">
Expand Down
48 changes: 30 additions & 18 deletions templates/settings.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,38 @@
<main>
<!-- === Remove and replace with your own content... === -->
<form x-data='settingForm({$settings|@json_encode})' method="POST">
<div class="ojt-mb-6">
<div class="ojt-flex ojt-items-center">
<input id="default-checkbox" type="checkbox" x-model="data.enable_diagnostic"
class="ojt-w-4 ojt-h-4 ojt-text-primary-600 ojt-bg-gray-100 ojt-border-gray-300 ojt-rounded focus:ojt-ring-primary-500 dark:focus:ojt-ring-primary-600 dark:ojt-ring-offset-gray-800 focus:ojt-ring-2 dark:ojt-bg-gray-700 dark:ojt-border-gray-600">
<div class="ojt-ml-2">
<label class="ojt-text-sm ojt-font-medium ojt-text-gray-900 dark:ojt-text-gray-300">Enable
Diagnostics</label>
<p class="ojt-text-xs">
Help us fix things and improve OJT Products and services. Send diagnostics data (error
log) to Open
Journal Theme.
</p>
</div>
<div class="ojt-mb-6">
<div class="ojt-flex ojt-items-center">
<input id="default-checkbox" type="checkbox" x-model="data.enable_diagnostic"
class="ojt-w-4 ojt-h-4 ojt-text-primary-600 ojt-bg-gray-100 ojt-border-gray-300 ojt-rounded focus:ojt-ring-primary-500 dark:focus:ojt-ring-primary-600 dark:ojt-ring-offset-gray-800 focus:ojt-ring-2 dark:ojt-bg-gray-700 dark:ojt-border-gray-600">
<div class="ojt-ml-2">
<label class="ojt-text-sm ojt-font-medium ojt-text-gray-900 dark:ojt-text-gray-300">Enable
Diagnostics</label>
<p class="ojt-text-xs">
Help us fix things and improve OJT Products and services. Send diagnostics data (error
log) to Open
Journal Theme.
</p>
</div>
</div>
</div>
<div class="ojt-mb-6">
<div class="ojt-flex ojt-items-center">
<input id="default-checkbox" type="checkbox" x-model="data.show_support_link_ojs"
class="ojt-w-4 ojt-h-4 ojt-text-primary-600 ojt-bg-gray-100 ojt-border-gray-300 ojt-rounded focus:ojt-ring-primary-500 dark:focus:ojt-ring-primary-600 dark:ojt-ring-offset-gray-800 focus:ojt-ring-2 dark:ojt-bg-gray-700 dark:ojt-border-gray-600">
<div class="ojt-ml-2">
<label class="ojt-text-sm ojt-font-medium ojt-text-gray-900 dark:ojt-text-gray-300">Show Get Support Link on OJS Dashboard</label>
<p class="ojt-text-xs">
Allow plugin to show Get Support Link on OJS Dashboard.
</p>
</div>
</div>
</div>
</div>

<button type="submit" @click.prevent="submit" :disabled="loading"
class="ojt-text-white ojt-bg-primary-700 hover:ojt-bg-primary-800 focus:ojt-ring-4 focus:ojt-outline-none focus:ojt-ring-primary-300 ojt-font-medium ojt-rounded-lg ojt-text-sm ojt-w-full sm:ojt-w-auto ojt-px-4 ojt-py-2 ojt-text-center disabled:ojt-opacity-75">
Submit
</button>
<button type="submit" @click.prevent="submit" :disabled="loading"
class="ojt-text-white ojt-bg-primary-700 hover:ojt-bg-primary-800 focus:ojt-ring-4 focus:ojt-outline-none focus:ojt-ring-primary-300 ojt-font-medium ojt-rounded-lg ojt-text-sm ojt-w-full sm:ojt-w-auto ojt-px-4 ojt-py-2 ojt-text-center disabled:ojt-opacity-75">
Submit
</button>
</form>
<!-- === End === -->
</main>
Expand Down
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<version>
<application>ojtControlPanel</application>
<type>plugins.generic</type>
<release>3.0.0.4</release>
<date>2023-09-05</date>
<release>3.0.1.0</release>
<date>2023-10-21</date>
<lazy-load>0</lazy-load>
<class>OjtControlPanelPlugin</class>
</version>

0 comments on commit 4dbe867

Please sign in to comment.