UsersDataTable.php
if( $aRow['b_enabled'] == 1 ) {
$options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=disable&id[]=' . $aRow['pk_i_id'] . '&' . $csrf_token_url . '">' . __('Block') . '</a>';
$options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=disable_items&id[]=' . $aRow['pk_i_id'] . '&' . $csrf_token_url . '">' . __('Block all items') . '</a>';
} else {
$options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=enable&id[]=' . $aRow['pk_i_id'] . '&' . $csrf_token_url . '">' . __('Unblock') . '</a>';
$options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=enable_items&id[]=' . $aRow['pk_i_id'] . '&' . $csrf_token_url . '">' . __('Unblock all items') . '</a>';
}
oc-admin\users.php
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;