This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

Tango

  • ****
  • 214 posts
Bug in Osclass v4.4.0
« on: September 05, 2021, 12:47:38 PM »
Please note that there's a bug in Osclass v4.4.0, related to Users > Block/Unblock all items.

After you Block all items, you can't unblock them.
The unblock option doesn't appear and it still shows Block all items.

Thanks!

PS: please move the topic in the Report bug section.
« Last Edit: September 05, 2021, 02:50:49 PM by Tango »

*

MB Themes

Re: Bug in Osclass v4.4.0
« Reply #1 on: September 05, 2021, 03:53:13 PM »
Let me check, I would say there is no such button.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Tango

  • ****
  • 214 posts
Re: Bug in Osclass v4.4.0
« Reply #2 on: September 05, 2021, 04:05:25 PM »
UsersDataTable.php

Code: [Select]
if( $aRow['b_enabled'] == 1 ) {
          $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=disable&amp;id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '">' . __('Block') . '</a>';
          $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=disable_items&amp;id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '">' . __('Block all items') . '</a>';
        } else {
          $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=enable&amp;id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '">' . __('Unblock') . '</a>';
          $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=enable_items&amp;id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '">' . __('Unblock all items') . '</a>';
        }

oc-admin\users.php

Code: [Select]
case('enable_items'):
        osc_csrf_check();
        require_once LIB_PATH . 'osclass/UserActions.php';
        require_once LIB_PATH . 'osclass/ItemActions.php';
       
        $iUpdated = 0;
        $userId   = Params::getParam('id');
       
        if(!is_array($userId)) {
          osc_add_flash_error_message(_m("User id isn't in the correct format"), 'admin');
          $this->redirectTo(osc_admin_base_url(true) . '?page=users');
        }

        $itemActions = new ItemActions(true);
        foreach($userId as $id) {
          $items = Item::newInstance()->findByUserID($id);
         
          if(is_array($items) && count($items) > 0) {
            foreach($items as $item) {
              if($item['b_enabled'] == 0) {
                $iUpdated += $itemActions->enable($item['pk_i_id']);
              }
            }
          }
        }

        if( $iUpdated == 0 ) {
          $msg = _m('No users listings have been unblocked');
        } else {
          $msg = sprintf( _mn('One user listing has been unblocked', '%s user listings have been unblocked', $iUpdated), $iUpdated );
        }

        osc_add_flash_ok_message($msg, 'admin');
        $this->redirectTo(Params::getServerParam('HTTP_REFERER', false, false));
        break;
       
      case('disable_items'):
        osc_csrf_check();
        require_once LIB_PATH . 'osclass/UserActions.php';
        require_once LIB_PATH . 'osclass/ItemActions.php';
       
        $iUpdated = 0;
        $userId   = Params::getParam('id');
       
        if(!is_array($userId)) {
          osc_add_flash_error_message(_m("User id isn't in the correct format"), 'admin');
          $this->redirectTo(osc_admin_base_url(true) . '?page=users');
        }

        $itemActions = new ItemActions(true);
        foreach($userId as $id) {
          $items = Item::newInstance()->findByUserID($id);
         
          if(is_array($items) && count($items) > 0) {
            foreach($items as $item) {
              if($item['b_enabled'] == 1) {
                $iUpdated += $itemActions->disable($item['pk_i_id']);
              }
            }
          }
        }

        if( $iUpdated == 0 ) {
          $msg = _m('No users listings have been blocked');
        } else {
          $msg = sprintf( _mn('One user listing has been blocked', '%s user listings have been blocked', $iUpdated), $iUpdated );
        }

        osc_add_flash_ok_message($msg, 'admin');
        $this->redirectTo(Params::getServerParam('HTTP_REFERER', false, false));
        break;

Marked as best answer by frosticek on September 05, 2021, 08:13:10 PM
*

MB Themes

Re: Bug in Osclass v4.4.0
« Reply #3 on: September 05, 2021, 08:13:05 PM »
@Tango
Good one.
Disable user and you will have that button switched.

Reason is, that following flow is expected.

For enabled user:
- first, you disable user items
- next, you disable user itself

Then, when user is disabled, and for some reason you want to enable this user:
- first, you enable all user items
- next, you enable user itself

Hope it is clear now ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots