Topic: extensions questions (db_prefix and extra file)

when an extension uses the query builder engine, how do i use the automatic adding of the db prefix?

i have to manually add the forum_ prefix otherwise the code below doe not work ...

$query = array(
                'INSERT'        => 'txt, author',
                'INTO'          => 'forum_qq',
                'VALUES'        => '\''.$_POST['txt'].'\', \''.$_POST['author'].'\''
        );

then second question, i hqve a new admin php file, should my extension move this (on install) to the admin dir or should it stay in the extensions dir?

~Cereal
I've finally learned what "upward compatible" means. It means we get to keep all our old mistakes.
The limits of language are the limits of one's world.

Re: extensions questions (db_prefix and extra file)

the forum prefix is held in $forum_db->prefix so you would use:

 'INTO'          => $forum_db->prefix.'qq',

Why create a whole new admin page? couldn't you have used the hooks in place?

my mind is on a permanent tangent
byUsers forum

3 (edited by Cereal 2009-01-15 13:05)

Re: extensions questions (db_prefix and extra file)

Rich Pedley wrote:

Why create a whole new admin page? couldn't you have used the hooks in place?

hmm, well its easyer smile

i ahve been trying todo this but could not find the right hooks for this ...

what i did

1- modifyed url scheme (co_modify_url_scheme)
2- added main admin link (ca_fn_generate_admin_menu_new_link)
3- generated sub admin links (ca_fn_generate_admin_menu_new_sublink)

but then i got stuck smile

~Cereal
I've finally learned what "upward compatible" means. It means we get to keep all our old mistakes.
The limits of language are the limits of one's world.

4 (edited by YonasH 2009-01-15 13:10)

Re: extensions questions (db_prefix and extra file)

but prefix should be added automatically until disabled by

'PARAMS' => array('NO_PREFIX' => true),

or in any other way to make

isset($query['PARAMS']['NO_PREFIX']) == true
YonasH's repository + Extensions Directory = PunBB Extensions Online Library (in progress....)

Away. I will be back soon.

Re: extensions questions (db_prefix and extra file)

yonash wrote:

but prefix should be added automatically until disabled by

thought as much, but wasn't 100% sure. Thanks for correcting smile

my mind is on a permanent tangent
byUsers forum

Re: extensions questions (db_prefix and extra file)

yonash wrote:

but prefix should be added automatically until disabled by

well yeah i thought so ... but this doesn't work

~Cereal
I've finally learned what "upward compatible" means. It means we get to keep all our old mistakes.
The limits of language are the limits of one's world.

Re: extensions questions (db_prefix and extra file)

Cereal wrote:
yonash wrote:

but prefix should be added automatically until disabled by

well yeah i thought so ... but this doesn't work

you must do something wrong. can you paste all manifest.xml file?

YonasH's repository + Extensions Directory = PunBB Extensions Online Library (in progress....)

Away. I will be back soon.

Re: extensions questions (db_prefix and extra file)

nvm its solved, but i'm still creating seperated admin page for my admin commands,

what hook can i use to create new admin pages?

~Cereal
I've finally learned what "upward compatible" means. It means we get to keep all our old mistakes.
The limits of language are the limits of one's world.

9 (edited by User33 2009-01-15 14:43)

Re: extensions questions (db_prefix and extra file)

For a new section in 'admin/settings.php', use hook='aop_new_section' and:

if($section == 'your_section_name')
{
//Code
}

Then, to show your section's link under a certain admin menu tab, use hook='ca_fn_generate_admin_menu_new_sublink' and:

if (FORUM_PAGE_SECTION == 'management') //Example
$forum_page['admin_submenu']['your_section_name'] = '<li class="'.((FORUM_PAGE == 'your_section_name') ? 'active' : 'normal').((empty($forum_page['admin_submenu'])) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['your_section_name']).'">Section Name</a></li>';

For 'forum_link($forum_url['your_section_name'])' to work, you'll need this hook='co_modify_url_scheme' and:

$forum_url['your_section_name'] = 'admin/settings.php?section=your_section_name';

And you have to define the following before including 'header.php' for your link to display as active:

define('FORUM_PAGE_SECTION', 'management'); //or whatever "parent section" you want to use
define('FORUM_PAGE', 'your_section_name');

I think that's it smile

(For more info on the links, check out this file: 'include/common_admin.php')

10

Re: extensions questions (db_prefix and extra file)

yeah well i first of all want this to be an admin page that mods can access to (settings.php is limited to admins only

secondly, i want to create a main header (next to extensions) and not a subheader ...

a simple subheader is pretty easy, but a main header is a bit harder i think

~Cereal
I've finally learned what "upward compatible" means. It means we get to keep all our old mistakes.
The limits of language are the limits of one's world.

11

Re: extensions questions (db_prefix and extra file)

Then, you could make the page load from a file inside your extension.

Add your link through 'ca_fn_generate_admin_menu_new_link':

$forum_page['admin_menu']['your_admin_page'] = '<li class="'.((FORUM_PAGE_SECTION == 'your_admin_page') ? 'active' : 'normal').((empty($forum_page['admin_menu'])) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['your_admin_page']).'"><span>Your Page</span></a></li>';

Add one default sublink through 'ca_fn_generate_admin_menu_new_sublink':

if (FORUM_PAGE_SECTION == 'your_admin_page')
$forum_page['admin_submenu']['default'] = '<li class="'.((FORUM_PAGE == 'default-page') ? 'active' : 'normal').((empty($forum_page['admin_submenu'])) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['your_admin_page']).'">Default Page</span></a></li>';

Add the URL scheme for your page through 'co_modify_url_scheme':

$forum_url['your_admin_page'] = $ext_info['url'].'/your_admin_page.php';

Then, on 'your_admin_page.php' inside your extension folder:

if (!defined('FORUM_ROOT'))
    define('FORUM_ROOT', '../');
require FORUM_ROOT.'include/common.php';
require FORUM_ROOT.'include/common_admin.php';

if (!$forum_user['is_admmod'])
    message($lang_common['No permission']);

require FORUM_ROOT.'lang/'.$forum_user['language'].'/admin_common.php';
//add your language files

$forum_page['crumbs'] = array(
    array($forum_config['o_board_title'], forum_link($forum_url['index'])),
    array($lang_admin_common['Forum administration'], forum_link($forum_url['admin_index'])),
    array('Your Page', forum_link($forum_url['your_admin_page']))
);

define('FORUM_PAGE_SECTION', 'your_admin_page');
define('FORUM_PAGE', 'default-page');
require FORUM_ROOT.'header.php';

ob_start();
?>
//Your content. To get an idea of the markup, check other admin pages
<?php
$tpl_temp = forum_trim(ob_get_contents());
$tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
ob_end_clean();

require FORUM_ROOT.'footer.php';

There are probably some errors there because I made it right in this text area, but I guess you get the idea.

12

Re: extensions questions (db_prefix and extra file)

thats exactly what i'm doing now smile

~Cereal
I've finally learned what "upward compatible" means. It means we get to keep all our old mistakes.
The limits of language are the limits of one's world.

13

Re: extensions questions (db_prefix and extra file)

Garciat wrote:

Add the URL scheme for your page through 'co_modify_url_scheme'

$forum_url['your_admin_page'] = $ext_info['url'].'/your_admin_page.php';

$ext_info['url'] gives the full forum url, so its not usable with forum_link

~Cereal
I've finally learned what "upward compatible" means. It means we get to keep all our old mistakes.
The limits of language are the limits of one's world.

14

Re: extensions questions (db_prefix and extra file)

True.

'extensions/'.$ext_info['id'].'/your_admin_page.php';

15

Re: extensions questions (db_prefix and extra file)

Cereal wrote:
$query = array(
                'INSERT'        => 'txt, author',
                'INTO'          => 'forum_qq',
                'VALUES'        => '\''.$_POST['txt'].'\', \''.$_POST['author'].'\''
        );

Not specifically related to you alone, but more of a general comment for which you are included. smile

Will you people please start sanitising your code. There isn't a $forum_db->escape in sight there, and I'm assuming from that omission that little else input sanitisation and verification is done either. Code correctly from the start.

16

Re: extensions questions (db_prefix and extra file)

MattF wrote:

Will you people please start sanitising your code. There isn't a $forum_db->escape in sight there, and I'm assuming from that omission that little else input sanitisation and verification is done either. Code correctly from the start.

QFT

17

Re: extensions questions (db_prefix and extra file)

I just had to Google to find out what that means. big_smile

18

Re: extensions questions (db_prefix and extra file)

Lol... well, it certainly doesn't mean "Queen's Film Theatre" nor "Quantum Field Theory".

19

Re: extensions questions (db_prefix and extra file)

MattF wrote:

Will you people please start sanitising your code. There isn't a $forum_db->escape in sight there, and I'm assuming from that omission that little else input sanitisation and verification is done either. Code correctly from the start.

well i'm planning it smile


together with the install and unstill part of the manifest.xml, it still has to be done smile (probebly today)
its still not released smile

~Cereal
I've finally learned what "upward compatible" means. It means we get to keep all our old mistakes.
The limits of language are the limits of one's world.