Advertisement:

Author Topic: Conejo? Admin items filter by email not showing pagination modern theme 3.7.1  (Read 1219 times)

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
I noticed that in admin area, @ items, when filtering by email the pagination does not show in the results. If a user has more than 100 items, the admin can't see them in that filter.
After model it showes the pagination, after email no and after id no.
Maybe the behaviour from ID filtering is not ok for email filtering.

Has anybody else noticed this?
« Last Edit: November 15, 2017, 09:28:31 pm by marius-ciclistu »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Admin items filter by email not showing pagination modern theme 3.7.1
« Reply #1 on: August 23, 2017, 07:44:25 pm »
Thanks to Teseo, the solution is to manually change in url:
Code: [Select]
page=items&iDisplayLength=10
to

Code: [Select]
page=items&iDisplayLength=100for viewing 100 ads for example.
« Last Edit: August 23, 2017, 07:46:35 pm by marius-ciclistu »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Admin items filter by email not showing pagination modern theme 3.7.1
« Reply #2 on: November 15, 2017, 12:04:28 am »
This issue is related to the search results in public search page when searging by user id.

https://forums.osclass.org/general-help/search-in-public-profile/msg157890/#msg157890

Does anyone know a solution for this pagination issue?

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Admin items filter by email not showing pagination modern theme 3.7.1
« Reply #3 on: November 15, 2017, 01:40:44 am »
I found this

        /**
         * Returns the number of rows in the table represented by this object.
         *
         * @access public
         * @since unknown
         * @return int
         */
        public function count()
        {
            $this->dao->select('COUNT(*) AS count');
            $this->dao->from($this->getTableName());
            $result = $this->dao->get();

            if( $result == false ) {
                return 0;
            }

            if( $result->numRows() == 0 ) {
                return 0;
            }

            $row = $result->row();
            return $row['count'];
        }
    }

    /* file end: ./oc-includes/osclass/classes/database/DAO.php */

As I read here, it is not recomended to use reserved words for names in SQL "count" highlighted above
 https://stackoverflow.com/questions/28561154/select-count-as-count-how-to-use-this-count

Could this be an issue related to the counts from admin and from search by user id as a parameter?
« Last Edit: November 15, 2017, 01:43:36 am by marius-ciclistu »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Admin items filter by email not showing pagination modern theme 3.7.1
« Reply #4 on: November 15, 2017, 03:49:53 pm »
Hi,

I don't think that's the problem (although not recommended, the query would work).

Quote
This issue is related to the search results in public search page when searging by user id.

https://forums.osclass.org/general-help/search-in-public-profile/msg157890/#msg157890

Indeed, seems to be the same problem, and I'cve found the issue is a modification made in oc-includes/osclass/model/Search.php in Osclass 3.7 (everything works fine on 3.6.1):

Code: [Select]
        private function _loadUserTable()
        {
            if(!$this->userTableLoaded){
                $this->dao->from(sprintf('%st_user',DB_TABLE_PREFIX));
                $this->userTableLoaded = true;
            }
        }

t_user table is being correctly added on the first query (to get items) but not on the second one (to get total number of items, needed for pagination).

If you comment this line:

Code: [Select]
// $this->userTableLoaded = true;
Pagination works correctly.

Now, I don't know why this change was made (probaby to try and fix some other problem elsewhere ???), so take that into account if you use this core patch.

Regards


marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Admin items filter by email not showing pagination modern theme 3.7.1
« Reply #5 on: November 15, 2017, 04:28:09 pm »
I'll give it a try later. Thank you.

Maybe Conejo could confirm if this mod would brake other things.
« Last Edit: November 15, 2017, 04:30:04 pm by marius-ciclistu »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Admin items filter by email not showing pagination modern theme 3.7.1
« Reply #6 on: November 15, 2017, 06:29:36 pm »
I tried it and it works perfectly, the pagination and the count of the results.
Thank you.

PS. I searched the files for this

grep -ir "_loadUserTable()"

and the result were:

oc-includes/osclass/model/Search.php:            $this->_loadUserTable();   //        private function _fromUser()
oc-includes/osclass/model/Search.php:            $this->_loadUserTable();  //        public function notFromUser($id)
oc-includes/osclass/model/Search.php:        private function _loadUserTable()

So the only places it gets called are:

Code: [Select]
        private function _fromUser()
        {
            $this->_loadUserTable();
            $this->dao->where(sprintf('%st_user.pk_i_id = %st_item.fk_i_user_id',DB_TABLE_PREFIX,DB_TABLE_PREFIX));

            if(is_array($this->user_ids)) {
                $this->dao->where(" ( ".implode(" || ", $this->user_ids)." ) ");
            } else {
                $this->dao->where(sprintf("%st_item.fk_i_user_id = %d ", DB_TABLE_PREFIX, $this->user_ids));
            }
        }

        public function notFromUser($id)
        {
            $this->_loadUserTable();

            $this->dao->where(sprintf("((%st_user.pk_i_id = %st_item.fk_i_user_id AND %st_item.fk_i_user_id != %d) || %st_item.fk_i_user_id IS NULL) ",
                DB_TABLE_PREFIX,
                DB_TABLE_PREFIX,
                DB_TABLE_PREFIX,
                $id,
                DB_TABLE_PREFIX));
        }

So is there a problem if that table gets loaded each time?

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Admin items filter by email not showing pagination modern theme 3.7.1
« Reply #7 on: November 15, 2017, 08:15:22 pm »
I can't be a hundred percent sure that that won't break something. ??? If they made this change, I imagine it was for a reason... ???


marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Admin items filter by email not showing pagination modern theme 3.7.1
« Reply #8 on: November 15, 2017, 09:04:04 pm »
I don't use plugins, so for me what is there to break? :)

I posted here: https://forums.osclass.org/general-help/search-in-public-profile/msg157890/#msg157890
 a solution for searching in user public profile and user-items.php,  that together with your fix works great.

Thank you.
« Last Edit: November 15, 2017, 09:39:25 pm by marius-ciclistu »