phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

[RC] PHP Function add-on for QBar mod


 
Search this topic... | Search MOD Development... | Search Box
Register or Login to Post    Index » MOD Development  Previous TopicPrint TopicNext Topic
Author Message
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 153



PostPosted: Tue Jan 22, 2019 2:41 pm 
Post subject: PHP Function add-on for QBar mod

Hey everyone, this is my first addon here.

I have a lot of addons to integrate mods with others, but this one is a bit different.


Title: PHP function add-on for QBar 1.0.1
Author: Vendethiel
Description: Add-on for QBar that allows you to call a PHP function as part of your QMenu. I use it, for example, for my integration with Advanced Reports Hack, which needs more than a static link.
Version: 1.0.0

Code:

#
#-----[ OPEN ]------------------------------------------
#
admin/admin_qbar.php

#
#-----[ FIND ]------------------------------------------
#
                  'TREE_TITLE'      => qbar_get_tree_title($field['tree_id']),

#
#-----[ AFTER, ADD ]------------------------------------------
#
                  'PHP_FUNCTION'      => $field['php_function'],

#
#-----[ FIND ]------------------------------------------
#
               $line = !empty($field['auth_logged']) || !empty($field['auth_admin']) || !empty($field['auth_pm']);

#
#-----[ REPLACE WITH ]------------------------------------------
#
               $line = !empty($field['php_function']) || !empty($field['auth_logged']) || !empty($field['auth_admin']) || !empty($field['auth_pm']);

#
#-----[ FIND ]------------------------------------------
#
               if (!empty($field['auth_logged']))

#
#-----[ BEFORE, ADD ]------------------------------------------
#
               if (!empty($field['php_function']))
               {
                  $template->assign_block_vars('qbar.field.line.has_php_function', array(
                     'NAME' => $field['php_function']
                  ));
                  $template->assign_block_vars('qbar.field.line', array());
               }

#
#-----[ FIND ]------------------------------------------
#
      $field_tree_id      = $qbar_maps[$qname]['fields'][$fname]['tree_id'];

#
#-----[ AFTER, ADD ]------------------------------------------
#
      $field_php_function   = $qbar_maps[$qname]['fields'][$fname]['php_function'];

#
#-----[ FIND ]------------------------------------------
#
   if (isset($_POST['tree_id']))      $field_tree_id      = trim(stripslashes($_POST['tree_id']));

#
#-----[ AFTER, ADD ]------------------------------------------
#
   if (isset($_POST['php_function']))   $field_php_function      = trim(stripslashes($_POST['php_function']));

#
#-----[ FIND ]------------------------------------------
#
               $field_tree_id      = $qbar_maps[$from_qname]['fields'][$from_fname]['tree_id'];

#
#-----[ AFTER, ADD ]------------------------------------------
#
               $field_php_function   = $qbar_maps[$from_qname]['fields'][$from_fname]['php_function'];

#
#-----[ FIND ]------------------------------------------
# This happens twice, this is the first occurence
                  $wfield['tree_id']      = $field_tree_id;

#
#-----[ AFTER, ADD ]------------------------------------------
#
                  $wfield['php_function']      = $field_php_function;

#
#-----[ FIND ]------------------------------------------
#
         $s_hidden_fields .= '<input type="hidden" name="tree_id" value="' . $field_tree_id . '" />';

#
#-----[ AFTER, ADD ]------------------------------------------
#
         $s_hidden_fields .= '<input type="hidden" name="php_function" value="' . $field_php_function . '" />';

#
#-----[ FIND ]------------------------------------------
# This happens twice, this is the second occurence
                  $wfield['tree_id']      = $field_tree_id;

#
#-----[ AFTER, ADD ]------------------------------------------
#
                  $wfield['php_function']      = $field_php_function;

#
#-----[ FIND ]------------------------------------------
#
         // value
         $template->assign_vars(array(

#
#-----[ AFTER, ADD ]------------------------------------------
#
            'PHP_FUNCTION'         => $field_php_function,


#
#-----[ OPEN ]------------------------------------------
#
includes/functions_admin_qbar.php

#
#-----[ FIND ]------------------------------------------
# in function qbar_write()
      'tree_id'      => 'alpha',

#
#-----[ AFTER, ADD ]------------------------------------------
#
      'php_function'  => 'alpha',

#
#-----[ OPEN ]------------------------------------------
#
includes/functions_qbar.php

#
#-----[ FIND ]------------------------------------------
#
            // check private messaging
            if (($fdata['auth_pm'] == 1) && ($new_pms <= 0))
            {
#
#-----[ BEFORE, ADD ]------------------------------------------
#
            if (!empty($fdata['php_function']) && $ok)
            {
               $ok = function_exists($fdata['php_function']);
            }

#
#-----[ FIND ]------------------------------------------
#
               $options['window'][]      = $fdata['window'];

#
#-----[ AFTER, ADD ]------------------------------------------
#
               $options['php_function'][]   = $fdata['php_function'];

#
#-----[ FIND ]------------------------------------------
#
            // add to options
            $options[] = $wres;

#
#-----[ REPLACE WITH ]------------------------------------------
#
            if (!empty($fields['php_function'][$j]))
            {
               $wres = call_user_func($fields['php_function'][$j], array(
                  'url' => $fields['url'][$j],
                  'icon' => $fields['icon'][$j],
                  'shortcut' => $fields['shortcut'][$j],
                  'mouseover' => $fields['mouseover'][$j],
                  'window' => $fields['window'][$j],
                  'wres' => $wres,
               ));
            }
            if (!empty(trim($wres)))
            {
               $options[] = $wres;
            }

#
#-----[ OPEN ]------------------------------------------
#
admin/qbar_admin_body.tpl

#
#-----[ FIND ]------------------------------------------
#
         <!-- BEGIN switch_auth_logged -->
         <td width="50%" nowrap="nowrap"><span class="gensmall"><b>{L_AUTH_LOGGED}:</b>&nbsp;{qbar.field.AUTH_LOGGED}</span></td>
         <!-- END switch_auth_logged -->

#
#-----[ BEFORE, ADD ]------------------------------------------
#
         <!-- BEGIN has_php_function -->
         <td width="50%" nowrap="nowrap"><span class="gensmall"><b>{L_QBAR_PHP_FUNCTION}:</b>&nbsp;{qbar.field.has_php_function.NAME}</span></td>
         <!-- END has_php_function -->

#
#-----[ OPEN ]------------------------------------------
#
admin/qbar_field_body.tpl

#
#-----[ FIND ]------------------------------------------
#
<tr>
   <td class="cat" align="center" colspan="2"><span class="cattitle">{L_SHORTCUT}</span></td>
</tr>

#
#-----[ BEFORE, ADD ]------------------------------------------
#
<tr>
   <td class="row2" width="50%"><span class="gen">{L_QBAR_PHP_FUNCTION}</span><span class="gensmall"><br />{L_QBAR_PHP_FUNCTION_EXPLAIN}</span></td>
   <td class="row1"><span class="gen"><input type="text" name="php_function" value="{PHP_FUNCTION}" /></span></td>
   </td>
</tr>

#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_extend_qbar.php

#
#-----[ FIND ]------------------------------------------
#
   $lang['Qbar_all']                     = '---------- All -----------';

#
#-----[ AFTER, ADD ]------------------------------------------
#
   // V: PHP function for QBar
   $lang['QBAR_PHP_FUNCTION'] = 'PHP function';
   $lang['QBAR_PHP_FUNCTION_EXPLAIN'] = 'Call a PHP function to render this field';


_________________
Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs).
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Development  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0257 seconds using 15 queries. (SQL 0.0021 Parse 0.0008 Other 0.0228)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo