-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Work on com_finder (both admin and site) #12254
Conversation
Also Todo'd two things for someone to check
…and it might cause trouble...
$canCreate = $user->authorise('core.create', 'com_finder'); | ||
$canEdit = $user->authorise('core.edit', 'com_finder'); | ||
|
||
foreach ($this->items as $i => $item) : | ||
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || $item->checked_out == 0; | ||
$canChange = $user->authorise('core.edit.state', 'com_finder') && $canCheckin; | ||
?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could also move $user->authorise('core.manage', 'com_checkin')
and $user->authorise('core.edit.state', 'com_finder')
to outside the for since the $user
does not change inside the for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I can't, because the second depends on the first, which may have different results because of the $item
of the loop. Or am I getting this wrong?
But I could move the user->get
outside the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't mean all of it i mean just the
$user->authorise('core.manage', 'com_checkin')
And the
$user->authorise('core.edit.state', 'com_finder')
can be outside the cycle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, missed that. Yes, that is a nice idea. Let's try that.
*/ | ||
protected $state; | ||
|
||
/** | ||
* The total number of items | ||
* | ||
* @var object | ||
* @var int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
integer
*/ | ||
protected $state; | ||
|
||
/** | ||
* The total indexed items | ||
* | ||
* @var int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
integer
*/ | ||
protected $state; | ||
|
||
/** | ||
* The total number of items | ||
* | ||
* @var object | ||
* @var int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
integer
…function calls out of the loop or reduce calls inside the loop.
@frankmayer when you change tabs identation is more hard for testers to make a code review. I normally append So my sugestion is don't chnange code identation in this PRs |
@andrepereiradasilva As far as I can tell changed indentation on purpose was in one file only. |
# Conflicts: # components/com_finder/models/search.php
@@ -20,31 +20,48 @@ class FinderViewFilter extends JViewLegacy | |||
* The filter object | |||
* | |||
* @var FinderTableFilter | |||
* | |||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this (and below) were actually added in 3.6.2 see https://github.com/frankmayer/joomla-cms/commit/20c18465afd26df6d7f2c7b7f46124104edfc70f#diff-9d1414e13ac35d173505ccd27d5fc1f5R20
* | ||
* @since 2.5 | ||
*/ | ||
protected $total; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__DEPLOY_VERSION__
</tr> | ||
$canCheckIn = $userAuthoriseCoreManage || $item->checked_out == $userId || $item->checked_out == 0; | ||
$canChange = $userAuthoriseCoreEditState && $canCheckIn; | ||
$escapedTitle = $this->escape($item->title); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cs: please ident the equal signs
@@ -20,34 +20,44 @@ class FinderViewFilters extends JViewLegacy | |||
* An array of items | |||
* | |||
* @var array | |||
* | |||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this (and below) was actually added in 3.6.1 see 20c1846
@@ -22,41 +22,53 @@ class FinderViewIndex extends JViewLegacy | |||
* An array of items | |||
* | |||
* @var array | |||
* | |||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this (and below) was actually added in 3.6.1 see 20c1846
@@ -22,34 +22,44 @@ class FinderViewMaps extends JViewLegacy | |||
* An array of items | |||
* | |||
* @var array | |||
* | |||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this (and below) was actually added in 3.6.1 see 20c1846
@@ -20,6 +20,8 @@ class FinderViewStatistics extends JViewLegacy | |||
* The index statistics | |||
* | |||
* @var JObject | |||
* | |||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was actually added in 3.6.1 see 20c1846
|
||
protected $total; | ||
|
||
protected $pagination; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add doc blocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed one protected property, as it seemed not be used.
*/ | ||
protected $filter; | ||
|
||
/** | ||
* The JForm object | ||
* | ||
* @var JForm | ||
* | ||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.6.2
* @var object | ||
* @var JObject|boolean | ||
* | ||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.6.2
* @var object | ||
* @var mixed | ||
* | ||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.6.2
*/ | ||
protected $items; | ||
|
||
/** | ||
* The pagination object | ||
* | ||
* @var JPagination | ||
* | ||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.6.1
*/ | ||
protected $pagination; | ||
|
||
/** | ||
* The state of core Smart Search plugins | ||
* | ||
* @var array | ||
* | ||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.6.1
*/ | ||
protected $sidebar; | ||
|
||
/** | ||
* The model state | ||
* | ||
* @var object | ||
* | ||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.6.1
*/ | ||
protected $state; | ||
|
||
/** | ||
* The total number of items | ||
* | ||
* @var object | ||
* | ||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.6.1
* | ||
* @var integer | ||
* | ||
* @since 3.6.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__DEPLOY_VERSION__
* | ||
* @var array | ||
* | ||
* @since 3.6.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__DEPLOY_VERSION__
protected $state; | ||
|
||
protected $user; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this removed? is B/C to remove a protected property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it could be. I was overeagerly cleaning up and noticed, it wasn't used in the context of this file or related tmpl. Will revert.
@@ -345,16 +345,13 @@ public function publish(&$pks, $value = 1) | |||
{ | |||
$table->reset(); | |||
|
|||
if ($table->load($pk)) | |||
if ($table->load($pk) && !$this->canEditState($table)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dedent block below.
@@ -168,12 +168,12 @@ public function publish($pks = null, $state = 1, $userId = 0) | |||
} | |||
|
|||
// If checkin is supported and all rows were adjusted, check them in. | |||
if ($checkin && (count($pks) == $this->_db->getAffectedRows())) | |||
if ($checkin && (count($pks) === $this->_db->getAffectedRows())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove outside parentheses (count($pks) === $this->_db->getAffectedRows())
@@ -118,7 +118,7 @@ | |||
<?php echo JHtml::_('date', $item->indexdate, JText::_('DATE_FORMAT_LC4')); ?> | |||
</td> | |||
<td class="center hidden-phone hidden-tablet"> | |||
<?php if (intval($item->publish_start_date) or intval($item->publish_end_date) or intval($item->start_date) or intval($item->end_date)) : ?> | |||
<?php if ((int) $item->publish_start_date or (int) $item->publish_end_date or (int) $item->start_date or (int) $item->end_date) : ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change or
to ||
@@ -34,7 +34,7 @@ | |||
<?php | |||
$lang_key = 'PLG_FINDER_STATISTICS_' . str_replace(' ', '_', $type->type_title); | |||
$lang_string = JText::_($lang_key); | |||
echo ($lang_string == $lang_key) ? $type->type_title : $lang_string; | |||
echo ($lang_string === $lang_key) ? $type->type_title : $lang_string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove parentheses.
Thanks for reviewing @Quy |
@frankmayer is this PR to be tested by Code review? |
@@ -425,7 +425,7 @@ protected function getResultsTotal() | |||
$temp = $this->_db->loadObjectList(); | |||
|
|||
// Set the more flag to true if any of the sets equal the limit. | |||
$more = (count($temp) === $limit) ? true : false; | |||
$more = (count($temp) === $limit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry found more. Remove parentheses. Do the same 3 more times below.
@franz-wohlkoenig yes code review. |
@Quy thanks for Info. @frankmayer can you please wrote Test Instructions "Code review" in first Comment for willing Tester? |
@Quy, @franz-wohlkoenig : Done and Done. Thanks |
# Conflicts: # administrator/components/com_finder/views/filters/tmpl/default.php
Conflicts resolved. Please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some minor comments
rest seems fine on code review
|
||
return $total; | ||
return $db->loadResult(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small improv: you could use return $db->setQuery($query)->loadResult();
and remove the above line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally missed your comments here. Commit coming up.
@@ -9,22 +9,65 @@ | |||
|
|||
defined('_JEXEC') or die; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this empty line
I have tested this item ✅ successfully on 222ab4c This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12254. |
I have tested this item ✅ successfully on 222ab4c This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12254. |
RTC after two successful tests. |
Summary of Changes
Best practices, some optimization and cleaning up.
Testing Instructions
This should need only code review