Skip to content

Commit

Permalink
Merge pull request #55 from openjournalteam/ojt-support-33
Browse files Browse the repository at this point in the history
Ojt support 33
  • Loading branch information
rahmanramsi authored Oct 25, 2023
2 parents a88b564 + d563dbb commit cebd988
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 2.0.7.0 : 21 Oct 2023
- Integration with OJT Support platform

### 2.0.6.3 : 23 Aug 2023
- Fix false update notification.

Expand Down
22 changes: 21 additions & 1 deletion OjtPageHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,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 @@ -106,7 +124,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 @@ -119,6 +138,7 @@ public function settings($args, $request)
public function saveSettings($args, $request)
{
$this->ojtPlugin->updateSetting(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';
Expand Down
22 changes: 16 additions & 6 deletions OjtPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,19 +249,29 @@ 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(ASSOC_TYPE_USER_ROLES);
if (!$request->getUser() || !count(array_intersect([ROLE_ID_MANAGER, ROLE_ID_SITE_ADMIN], $userRoles))) return;
$templateMgr = TemplateManager::getManager($this->getRequest());
$router = $request->getRouter();
$userRoles = (array) $router->getHandler()->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);
$user = $request->getUser();

if (!$user || !count(array_intersect([ROLE_ID_MANAGER, ROLE_ID_SITE_ADMIN], $userRoles))) return;

$menu = $templateMgr->getState('menu');
$menu['ojtPlugin'] = [
'name' => 'OJT Control Panel',
'url' => $request->getDispatcher()->url($request, ROUTE_PAGE, $request->getContext()->getPath()) . '/ojt?PageSpeed=off',
'url' => $request->getDispatcher()->url($request, 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, ROUTE_PAGE, $request->getContext()->getPath(), 'ojt', 'support'),
"isCurrent" => false
];
}

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

Expand Down
1 change: 0 additions & 1 deletion locale/academic_pro3
Submodule academic_pro3 deleted from 7ac7ee
6 changes: 5 additions & 1 deletion templates/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
</nav>

<div class="ojt-p-4 ojt-mx-auto ojt-w-full ojt-gap-2 ojt-flex ojt-flex-col ojt-border-t">

<button @click="menu = 'Plugin'; $store.plugins.page = 'settings'" role="menuitem" :class="{
'ojt-bg-gradient-to-l ojt-text-white ojt-shadow-lg ojt-shadow-primary-500/50': $store.plugins.page == 'settings',
'ojt-text-gray-500' : $store.plugins.page != 'settings'
Expand Down Expand Up @@ -109,6 +108,11 @@
</svg>
<span>OJS Tutorial</span>
</a>
<a href="{url router=$smarty.const.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
12 changes: 12 additions & 0 deletions templates/settings.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@
</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>

<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">
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>ojtPlugin</application>
<type>plugins.generic</type>
<release>2.0.6.3</release>
<date>2023-08-23</date>
<release>2.0.7.0</release>
<date>2023-10-21</date>
<lazy-load>0</lazy-load>
<class>OjtPlugin</class>
</version>

0 comments on commit cebd988

Please sign in to comment.