Advertisement:

Author Topic: Admin Items  (Read 674 times)

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 406
Re: Admin Items
« Reply #15 on: May 02, 2019, 10:00:03 pm »
You need to provide secret in item delete link.

Code: [Select]
<?php
    $id 
osc_item_id();
    
$secret osc_item_secret();
    
$actions[] = '<a class="btn float-left" href="'.osc_admin_base_url(true).'?page=custom_item&action=delete&id='.$id.'&secret='.$secret.'">'.__('Delete') .'</a>';

Regards.

Yes im doing that but still $secret == null

patrickFromCroatia

  • Hero Member
  • *****
  • Posts: 753
Re: Admin Items
« Reply #16 on: May 02, 2019, 11:14:46 pm »
Try

Code: [Select]
$item = osc_item_id();
$aItem = Item::newInstance()->findByPrimaryKey($item);
$secret = $aItem['s_secret'];
$actions[] = '<a class="btn float-left" href="'.osc_admin_base_url(true).'?page=custom_item&action=delete&id='.$id.'&secret='.$secret.'">'.__('Delete') .'</a>';

Regards.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 406
Re: Admin Items
« Reply #17 on: May 03, 2019, 06:07:22 am »
Try

Code: [Select]
$item = osc_item_id();
$aItem = Item::newInstance()->findByPrimaryKey($item);
$secret = $aItem['s_secret'];
$actions[] = '<a class="btn float-left" href="'.osc_admin_base_url(true).'?page=custom_item&action=delete&id='.$id.'&secret='.$secret.'">'.__('Delete') .'</a>';

Regards.

( ! ) Notice: Undefined index: s_secret in oc-admin\items.php

patrickFromCroatia

  • Hero Member
  • *****
  • Posts: 753
Re: Admin Items
« Reply #18 on: May 03, 2019, 11:31:36 am »
Have no idea... Try this

Code: [Select]
<?php
    $item 
osc_item_id();
    
$dao = new DAO();
    
$query $dao->dao->query(sprintf('SELECT s_secret FROM %st_item WHERE pk_i_id = %s'DB_TABLE_PREFIX$item));
    if(
$query) {
        
$result $query->result();
        
$secret $result[0]['s_secret'];
    } else {
        
$secret null;
    }
    
$actions[] = '<a class="btn float-left" href="'.osc_admin_base_url(true).'?page=custom_item&action=delete&id='.$id.'&secret='.$secret.'">'.__('Delete') .'</a>';

Regards.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 406
Re: Admin Items
« Reply #19 on: May 03, 2019, 10:13:39 pm »
Have no idea... Try this

Code: [Select]
<?php
    $item 
osc_item_id();
    
$dao = new DAO();
    
$query $dao->dao->query(sprintf('SELECT s_secret FROM %st_item WHERE pk_i_id = %s'DB_TABLE_PREFIX$item));
    if(
$query) {
        
$result $query->result();
        
$secret $result[0]['s_secret'];
    } else {
        
$secret null;
    }
    
$actions[] = '<a class="btn float-left" href="'.osc_admin_base_url(true).'?page=custom_item&action=delete&id='.$id.'&secret='.$secret.'">'.__('Delete') .'</a>';

Regards.

( ! ) Notice: Undefined offset: 0 in oc-admin\items.php

patrickFromCroatia

  • Hero Member
  • *****
  • Posts: 753
Re: Admin Items
« Reply #20 on: May 03, 2019, 10:31:43 pm »
You must be putting this in a wrong file/location. All codes I've posted work.

calinbehtuk

  • Sr. Member
  • ****
  • Posts: 441
Re: Admin Items
« Reply #21 on: May 03, 2019, 10:34:18 pm »
Code: [Select]
$actions[] = '<a class="btn float-left" href="' . osc_admin_base_url(true) . '?page=items&action=delete&id[]=' . $item['pk_i_id'] . '&'.$csrf_token.'">' . __('Delete') . '</a>';


Sophia_OS

  • Sr. Member
  • ****
  • Posts: 406
Re: Admin Items
« Reply #22 on: May 03, 2019, 11:20:47 pm »
Code: [Select]
$actions[] = '<a class="btn float-left" href="' . osc_admin_base_url(true) . '?page=items&action=delete&id[]=' . $item['pk_i_id'] . '&'.$csrf_token.'">' . __('Delete') . '</a>';


flash error: The listing couldn't be deleted

patrickFromCroatia

  • Hero Member
  • *****
  • Posts: 753
Re: Admin Items
« Reply #23 on: May 03, 2019, 11:25:41 pm »
How is it possible that neither core and custom solutions work?

calinbehtuk

  • Sr. Member
  • ****
  • Posts: 441
Re: Admin Items
« Reply #24 on: May 03, 2019, 11:30:04 pm »
This means one thing, you have a foreign key left in a table generated by some plugin. This is the same link that you have in the item table. Or you have made some changes. try deleting your ad from the item table, the same ad you are trying to delete with this change.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 406
Re: Admin Items
« Reply #25 on: May 03, 2019, 11:52:39 pm »
You must be putting this in a wrong file/location. All codes I've posted work.

i put this function in functions.php:
https://forums.osclass.org/general-help/delete-an-item/msg168349/#msg168349

now i'm using your new code: https://forums.osclass.org/general-help/delete-an-item/msg168452/#msg168452
in this file: oc-admin\items.php
i added this 'delete' button under 'spam' button. under this if condition: if( $item['b_spam'] ) {

when i edit an item in admin-panel->Listings, it gives me debug error: ( ! ) Notice: Undefined offset: 0 in oc-admin\items.php
put this code in config.php to see this error: define('OSC_DEBUG', true);

and when i press on 'Delete' button on item-edit page, it redirects me to admin-panel->Listings and gives me your function flash error: Invalid data provided. because: $secret == null

thanks
« Last Edit: May 03, 2019, 11:54:12 pm by Sophia_OS »

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 406
Re: Admin Items
« Reply #26 on: May 03, 2019, 11:59:26 pm »
This means one thing, you have a foreign key left in a table generated by some plugin. This is the same link that you have in the item table. Or you have made some changes. try deleting your ad from the item table, the same ad you are trying to delete with this change.

i deleted all my plugins but getting same error!
the item could be deleted in admin-Listings.
in admin-Listings instead of "Delete", hit "Edit" (we are trying to delete the item here in edit page!)
thanks
« Last Edit: May 04, 2019, 12:04:20 am by Sophia_OS »

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 406
Re: Admin Items
« Reply #27 on: May 11, 2019, 06:50:44 am »
@Web-Media and @patrickFromCroatia
Thank you for your help, but still your code doesn't work!
Thanks,

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 406
Re: Admin Items
« Reply #28 on: May 17, 2019, 02:10:00 pm »
i tried your code again but it keeps giving me error! please help me to do this thanks!