Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task #165259 Chore: Adding user filter under search tools in Issued C… #65

Open
wants to merge 19 commits into
base: release-1.0.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1027e30
Bug #164674 fix: search box for cert-xxxx is showing error (#48)
tushar33 Sep 16, 2020
2ed2b03
Bug #164625 fix: title is showing blank data, it should display cours…
tushar33 Sep 16, 2020
6c6bd48
Bug #164705 fix: click on the social media post the back button on th…
tushar33 Sep 22, 2020
b4b495e
Bug #164707 fix: user able to download others certificate as well (#53)
tushar33 Sep 22, 2020
1909543
Task #164910 chore: Button to copy shareble certificate link (#51)
tushar33 Sep 22, 2020
240967b
Task #163318 fix: Fixed image cut issue while image generation (#54)
praneettekdi Sep 23, 2020
a057d47
Issue #164867 style: desing changes update (#50)
mangeshmane Sep 25, 2020
d04d061
Task #163318 fix: Added fixed width height for certificate container …
praneettekdi Sep 28, 2020
89b3ca0
Bug165031 : Backend > Attendees > Error '0 Call to a member function …
snehal0904 Sep 29, 2020
0ef5447
Task #165230 Chore: Back end>>Issued Certificate >> Search should als…
divyachaudhari Sep 29, 2020
9e4399c
Task #165122 Chore: Backend certificate view changes- Adding Course c…
divyachaudhari Sep 29, 2020
b4d5aa6
Task #165122 Chore: Backend Issued certificate view changes- Adding a…
divyachaudhari Sep 29, 2020
05e96c7
Task #165166 Chore: Add Certificate Url column under Issued Certifica…
divyachaudhari Sep 29, 2020
f61ca96
Task #165166 Feat: Adding (#63)
divyachaudhari Sep 29, 2020
9b15699
Bug165031 : Backend > Attendees > Error '0 Call to a member function …
snehal0904 Sep 29, 2020
99029ca
Task #165259 Chore: Adding user filter under search tools in Issued C…
divyachaudhari Sep 29, 2020
45e039e
Task #165259 Chore: Adding proper names to the client filter and colu…
divyachaudhari Sep 30, 2020
f4e38aa
Task #165259 Chore: Renaming Unique Certificate Id column name to Cer…
divyachaudhari Sep 30, 2020
47b2540
Resolving conflicts
divyachaudhari Sep 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/com_tjcertificate/administrator/access.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
<action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC" />
<action name="template.edit" title="COM_TJCERTIFICATE_PERMISSION_TEMPLATE_EDIT_ALL_TITLE" description="COM_TJCERTIFICATE_PERMISSION_TEMPLATE_EDIT_ALL_DESC" />
<action name="template.edit.own" title="COM_TJCERTIFICATE_PERMISSION_TEMPLATE_EDIT_OWN_TITLE" description="COM_TJCERTIFICATE_PERMISSION_TEMPLATE_EDIT_OWN_DESC" />
<action name="certificate.download.own" title="COM_TJCERTIFICATE_PERMISSION_CERTIFICATE_DOWNLOAD_OWN" description="COM_TJCERTIFICATE_PERMISSION_CERTIFICATE_DOWNLOAD_OWN_DESC" />
<action name="certificate.download.all" title="COM_TJCERTIFICATE_PERMISSION_CERTIFICATE_DOWNLOAD_ALL" description="COM_TJCERTIFICATE_PERMISSION_CERTIFICATE_DOWNLOAD_ALL_DESC" />
</section>
</access>
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ public function download()
}

$certificate = TJCERT::Certificate();

// Check user having permission to download
if (!$certificate::canDownload($uniqueCertificateId))
{
$app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'));
$app->redirect('index.php');
}

$certificateObj = $certificate::validateCertificate($uniqueCertificateId);

if (!$certificateObj->id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_COMMENT="Comment"

;Certificate - Filters
COM_TJCERTIFICATE_CERTIFICATE_FILTER_SEARCH_LABEL="Search"
COM_TJCERTIFICATE_CERTIFICATE_FILTER_SEARCH_LABEL_DESC="Search in template title. Prefix with ID:to search for a Certificate ID"
COM_TJCERTIFICATE_CERTIFICATE_FILTER_SEARCH_LABEL_DESC="Search in template title. Prefix with ID:to search for a Certificate ID. Search for User Name"
COM_TJCERTIFICATE_CERTIFICATE_FILTER_CERTIFICATE_TEMPLATE_SELECT="- Select Template -"
COM_TJCERTIFICATE_CERTIFICATE_FILTER_CERTIFICATE_TEMPLATE="Template"
COM_TJCERTIFICATE_CERTIFICATE_FILTER_DESC_CERTIFICATE_TEMPLATE="Select Template"
Expand Down Expand Up @@ -250,3 +250,22 @@ COM_TJCERTIFICATE_SOCIAL_SHARING_OPTIONS="Select social sharing options"
;Certificate Menu option
COM_TJCERTIFICATE_CERTIFICATE_TEXT_FILTER="Show Free Text Filter"
COM_TJCERTIFICATE_CERTIFICATE_TYPE_FILTER="Show Certificate Type Filter"

;Certificate PDF download permissions
COM_TJCERTIFICATE_PERMISSION_CERTIFICATE_DOWNLOAD_OWN="Download own certificate"
COM_TJCERTIFICATE_PERMISSION_CERTIFICATE_DOWNLOAD_OWN_DESC="Allow users to download own certificate"
COM_TJCERTIFICATE_PERMISSION_CERTIFICATE_DOWNLOAD_ALL="Download all certificate"
COM_TJCERTIFICATE_PERMISSION_CERTIFICATE_DOWNLOAD_ALL_DESC="Allow users to download all certificate"

;Issued Certificate View
COM_TJCERTIFICATE_CERTIFICATE_EXPIRED="Certificate expired"
COM_TJCERTIFICATE_CERTIFICATE_URL_COPY="Copy Url"
COM_TJCERTIFICATE_CERTIFICATE_URL="Certificate Url"
COM_TJCERTIFICATE_CERTIFICATE_TYPE_NAME="Title"
COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_USER_NAME="User Name"
COM_TJCERTIFICATE_CERTIFICATE_FILTER_USER_SELECT="- Select User -"
COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_CERTIFICATE_ID="Certificate Id"
COM_TJCERTIFICATE_CERTIFICATE_FILTER_CERTIFICATE_TYPE_SELECT="- Select Type -"
COM_TJCERTIFICATE_CLIENT_COM_TJLMS_COURSE="Course"
COM_TJCERTIFICATE_CLIENT_COM_JTICKETING_EVENT="Event"
COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_TYPE="Type"
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,11 @@ public function getUrl($options, $showSearchBox = true)
{
$url = 'index.php?option=com_tjcertificate&view=certificate&certificate=' . $this->unique_certificate_id;

$url .= '&show_search=' . $showSearchBox;
// If search box is true then only show search box param in URL
if ($showSearchBox)
{
$url .= '&show_search=' . $showSearchBox;
}

if (isset($options['popup']))
{
Expand Down Expand Up @@ -751,8 +755,8 @@ public function issueCertificate($replacements, $options)
{
try
{
// Check user_id or certificate_template_id (this is needed to generate certificate body) is empty
if (empty($this->user_id) || empty($this->certificate_template_id))
// Check user_id or issued Id or certificate_template_id (this is needed to generate certificate body) is empty
if ((empty($this->user_id) && empty($this->client_issued_to)) || empty($this->certificate_template_id))
{
throw new Exception(Text::_('COM_TJCERTIFICATE_CERTIFICATE_EMPTY_DATA'));
}
Expand Down Expand Up @@ -937,4 +941,36 @@ protected function generateUniqueCertId($options)

return $certificateString;
}

/**
* This function checks the certificate download permission
*
* @param STRING $uniqueCertificateId certificate Id
*
* @return boolean
*
* @since __DEPLOY_VERSION__
*/
public static function canDownload($uniqueCertificateId)
{
$user = Factory::getUser();

if ($user->authorise('certificate.download.all', 'com_tjcertificate'))
{
return true;
}

if ($user->authorise('certificate.download.own', 'com_tjcertificate'))
{
$table = TJCERT::table("certificates");
$table->load(array('unique_certificate_id' => $uniqueCertificateId));

if ($user->get('id') == $table->user_id)
{
return true;
}
}

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ protected function getListQuery()
else
{
$search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%'));
$query->where(' (ct.title LIKE ' . $search . ' OR ci.unique_certificate_id LIKE ' . $search . ' )');
$query->where(' (ct.title LIKE ' . $search . ' OR ci.unique_certificate_id LIKE '
. $search . ' OR ci.client_issued_to_name LIKE ' . $search .
' OR users.name LIKE ' . $search . ' )');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,24 @@
</field>

<field name="client"
type="sql"
query="SELECT DISTINCT (`client`) FROM `#__tj_certificate_issue` ORDER BY client ASC" key_field="client" value_field="client"
type="getclientlist"
filter="safehtml"
label="COM_TJCERTIFICATE_CERTIFICATE_FILTER_CERTIFICATE_CLIENT"
description="COM_TJCERTIFICATE_CERTIFICATE_FILTER_DESC_CERTIFICATE_CLIENT"
onchange="this.form.submit();">
<option value="">COM_TJCERTIFICATE_CERTIFICATE_FILTER_CERTIFICATE_CLIENT_SELECT</option>
</field>
addfieldpath="/components/com_tjcertificate/models/fields"
clientByUser="0"
onchange="this.form.submit();" />

<!-- <field
<field
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you will need a custom field here because this will only give you users who have Joomla account but not the client_issue_to column'd data

name="user_id"
type="sql"
query="SELECT DISTINCT (`ci`.`user_id`), u.name FROM `#__tj_certificate_issue` AS ci LEFT JOIN `#__users` AS u ON (ci.user_id = u.id)" key_field="user_id" value_field="name"
filter="safehtml"
label="COM_TJCERTIFICATE_CERTIFICATE_FILTER_ISSUED_USER"
description="COM_TJCERTIFICATE_CERTIFICATE_FILTER_ISSUED_USER"
onchange="this.form.submit();">
<option value="">COM_TJCERTIFICATE_CERTIFICATE_FILTER_ISSUED_USER_SELECT</option>
</field> -->
<option value="">COM_TJCERTIFICATE_CERTIFICATE_FILTER_USER_SELECT</option>
</field>

<field
name="state"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,24 @@
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;

$options = array();
$options['relative'] = true;

HTMLHelper::addIncludePath(JPATH_COMPONENT . '/helpers/html');
HTMLHelper::_('bootstrap.tooltip');
HTMLHelper::_('behavior.multiselect');
HTMLHelper::_('formbehavior.chosen', 'select');
HTMLHelper::_('behavior.modal', 'a.modal');
HTMLHelper::script('com_tjcertificate/certificateImage.min.js', $options);

$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$saveOrder = $listOrder == 'ci.id';
$dispatcher = JDispatcher::getInstance();
PluginHelper::importPlugin('content');

if ( $saveOrder )
{
Expand Down Expand Up @@ -81,23 +89,29 @@
</th>

<th>
<?php echo Text::_('COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_UNIQUE_ID'); ?>
<?php echo Text::_('COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_CERTIFICATE_ID'); ?>
</th>
<th>
<?php echo HTMLHelper::_('searchtools.sort', 'COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_TEMPLATE', 'ci.certificate_template_id', $listDirn, $listOrder); ?>
</th>
<th>
<?php echo HTMLHelper::_('searchtools.sort', 'COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_CLIENT', 'ci.client', $listDirn, $listOrder); ?>
<?php echo HTMLHelper::_('searchtools.sort', 'COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_TYPE', 'ci.client', $listDirn, $listOrder); ?>
</th>
<th>
<?php echo HTMLHelper::_('searchtools.sort', 'COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_USER', 'ci.user_id', $listDirn, $listOrder); ?>
<?php echo HTMLHelper::_('searchtools.sort', 'COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_USER_NAME', 'ci.user_id', $listDirn, $listOrder); ?>
</th>
<th>
<?php echo HTMLHelper::_('searchtools.sort', 'COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_ISSUED_DATE', 'ci.issued_on', $listDirn, $listOrder); ?>
</th>
<th>
<?php echo HTMLHelper::_('searchtools.sort', 'COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_EXPIRY_DATE', 'ci.expired_on', $listDirn, $listOrder); ?>
</th>
<th>
<?php echo Text::_('COM_TJCERTIFICATE_CERTIFICATE_TYPE_NAME'); ?>
</th>
<th>
<?php echo Text::_('COM_TJCERTIFICATE_CERTIFICATE_URL'); ?>
</th>
<th>
<?php echo Text::_('COM_TJCERTIFICATE_CERTIFICATE_LIST_VIEW_COMMENT'); ?>
</th>
Expand All @@ -117,6 +131,7 @@
<?php
foreach ($this->items as $i => $item)
{
$data = $dispatcher->trigger('getCertificateClientData', array($item->client_id, $item->client));
$item->max_ordering = 0;

$canEdit = $this->canDo->get('core.edit');
Expand Down Expand Up @@ -156,8 +171,29 @@
</div>
</td>
<td><?php echo $this->escape($item->title); ?></td>
<td><?php echo $this->escape($item->client); ?></td>
<td><?php echo $this->escape($item->uname); ?></td>
<td>
<?php
$client = str_replace(".", "_", $item->client);
$client = strtoupper("COM_TJCERTIFICATE_CLIENT_" . $client);
echo TEXT::_($client);
?>
</td>
<td>
<?php
$userName = '-';

if (!empty($item->client_issued_to_name))
{
$userName = $this->escape($item->client_issued_to_name);
}
elseif (!empty($item->uname))
{
$userName = $this->escape($item->uname);
}

echo $userName;
?>
</td>
<td><?php echo HTMLHelper::date($item->issued_on, Text::_('DATE_FORMAT_LC')); ?></td>
<td><?php
if (!empty($item->expired_on) && $item->expired_on != '0000-00-00 00:00:00')
Expand All @@ -169,6 +205,37 @@
echo '-';
}
?></td>
<td>
<?php
echo (!empty($data[0]->title)) ? $data[0]->title : '-';
?>
</td>
<td>
<?php
$utcNow = Factory::getDate()->toSql();

if ($item->expired_on > $utcNow || $item->expired_on == '0000-00-00 00:00:00')
{
// Get TJcertificate url for display certificate
$urlOpts = array ('absolute' => '');
$link = TJCERT::Certificate($item->id)->getUrl($urlOpts, false);
?>
<div class="btn-group">
<a id="copyurl<?php echo $item->id;?>" data-toggle="popover"
data-placement="bottom" data-content="Copied!"
data-alt-url="<?php echo $link;?>" class="btn" type="button"
onclick="certificateImage.copyUrl('copyurl<?php echo $item->id;?>');">
<?php echo Text::_('COM_TJCERTIFICATE_CERTIFICATE_URL_COPY');?>
</a>
</div>
<?php
}
else
{
echo Text::_('COM_TJCERTIFICATE_CERTIFICATE_EXPIRED');
}
?>
</td>
<td><?php echo $this->escape($item->comment); ?></td>
<td><?php echo (int) $item->id; ?></td>
</tr>
Expand Down
35 changes: 29 additions & 6 deletions src/components/com_tjcertificate/media/css/tjCertificate.css
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,20 @@
.bs-v1 {
box-shadow: 0 4px 10px 0 rgba(0,0,0,0.1);
}
.line-h-noraml{
line-height: normal;
}
.w-100{
width:100%;
}
.tj-certificate-image {
background-color: #fff;
width: 100%;
float: left;
}
.tj-certificate-image img{
width: 100%;
}
#certificateContent{
margin: 0 auto;
}
Expand All @@ -148,32 +157,47 @@
border-radius: 5px;
margin-left: 4px;
border: 1px solid #ddd;
display: inline-block;
display: inline-block !important;
}
.tjlmspin__caption_desc{
line-height: 18px;
font-size: 14px;
margin-bottom: 10px;
}
.tjlmspin__position {
.tjlmspin__position,
.eventlist__price
{
position: absolute;
top: 9px;
background: #FAF8F8;
padding: 1px 10px;
color: #333;
font-weight: 600;
}
.tjlmslist .tjlmslist__image .tjlmspin__price {
.tjlmslist .tjlmslist__image .tjlmspin__price,
.eventlist .eventlist__price
{
left: 25px;
}
.tjlmspin.mobile-view{
.tjlmspin.mobile-view,
.eventpin.mobile-view
{
width: 255px;
margin: 0 auto;
float: none;
}
.view-certificate .popover-title{
display: none;
}
.tj-certificate .thumbnail{
min-height: auto !important;
width: 100% !important;
}
.eventlist__desc{
height: 20px;
overflow: hidden;
display: inline-block;
}
@media screen and (max-width: 600px) {
.tj-certificate-share-download{
text-align: center;
Expand All @@ -183,9 +207,8 @@
.tjlmslist .thumbnail{
border:0;
}

#certificateContent{
min-height: 800px;
width: 1150px;
}
}
}
Loading