Advertisement
Guest User

Untitled

a guest
Oct 18th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.99 KB | None | 0 0
  1. <?php
  2. class phpbb_ext_example_ext extends phpbb_extension_base
  3. {
  4.     protected $umil_instructions = array(
  5.         '0.7.0'     => array(
  6.             'table_add' => array(
  7.                 array('phpbb_ads', array(
  8.                     'COLUMNS'       => array(
  9.                         'ad_id'         => array('UINT', NULL, 'auto_increment'),
  10.                         'ad_name'       => array('VCHAR', ''),
  11.                         'ad_code'       => array('TEXT_UNI', ''),
  12.                         'ad_views'      => array('UINT', 0),
  13.                         'ad_priority'   => array('TINT:1', 5),
  14.                         'ad_enabled'    => array('BOOL', 1),
  15.                         'all_forums'    => array('BOOL', 0),
  16.                     ),
  17.                     'PRIMARY_KEY'   => 'ad_id',
  18.                 )),
  19.  
  20.                 array('phpbb_ads_forums', array(
  21.                     'COLUMNS'       => array(
  22.                         'ad_id'         => array('UINT', 0),
  23.                         'forum_id'      => array('UINT', 0),
  24.                     ),
  25.                     'KEYS'          => array(
  26.                         'ad_forum'      => array('INDEX', array('ad_id', 'forum_id')),
  27.                     ),
  28.                 )),
  29.  
  30.                 array('phpbb_ads_groups', array(
  31.                     'COLUMNS'       => array(
  32.                         'ad_id'         => array('UINT', 0),
  33.                         'group_id'      => array('UINT', 0),
  34.                     ),
  35.                     'KEYS'          => array(
  36.                         'ad_group'      => array('INDEX', array('ad_id', 'group_id')),
  37.                     ),
  38.                 )),
  39.  
  40.                 array('phpbb_ads_in_positions', array(
  41.                     'COLUMNS'       => array(
  42.                         'ad_id'         => array('UINT', 0),
  43.                         'position_id'   => array('UINT', 0),
  44.                         'ad_priority'   => array('TINT:1', 5),
  45.                         'ad_enabled'    => array('BOOL', 1),
  46.                         'all_forums'    => array('BOOL', 0),
  47.                     ),
  48.                     'KEYS'          => array(
  49.                         'ad_position'   => array('INDEX', array('ad_id', 'position_id')),
  50.                         'ad_priority'   => array('INDEX', 'ad_priority'),
  51.                         'ad_enabled'    => array('INDEX', 'ad_enabled'),
  52.                         'all_forums'    => array('INDEX', 'all_forums'),
  53.                     ),
  54.                 )),
  55.  
  56.                 array('phpbb_ads_positions', array(
  57.                     'COLUMNS'       => array(
  58.                         'position_id'   => array('UINT', NULL, 'auto_increment'),
  59.                         'lang_key'      => array('TEXT_UNI', ''),
  60.                     ),
  61.                     'PRIMARY_KEY'   => 'position_id',
  62.                 )),
  63.             ),
  64.  
  65.             'permission_add'    => array('a_ads'),
  66.  
  67.             'module_add'        => array(
  68.                 array('acp', 'ACP_BOARD_CONFIGURATION', array('module_basename' => 'ads')),
  69.             ),
  70.  
  71.             'config_add'        => array(
  72.                 array('ads_enable', 1),
  73.                 array('ads_rules_forums', 1),
  74.                 array('ads_rules_groups', 1),
  75.             ),
  76.  
  77.             'custom'            => 'ads_install',
  78.         ),
  79.         '1.0.0'     => array(),
  80.         '1.0.1'     => array(
  81.             'table_column_add'  => array(
  82.                 array('phpbb_ads', 'ad_clicks', array('UINT', 0)),
  83.             ),
  84.  
  85.             'config_add'        => array(
  86.                 array('ads_count_clicks', 1),
  87.                 array('ads_count_views', 1),
  88.                 array('ads_accurate_views', 0),
  89.             ),
  90.         ),
  91.         '1.0.2'     => array(),
  92.         '1.0.3'     => array(),
  93.         '1.0.4'     => array(
  94.             'table_column_add'  => array(
  95.                 array('phpbb_ads', 'ad_note', array('MTEXT_UNI', '')),
  96.                 array('phpbb_ads', 'ad_time', array('TIMESTAMP', 0)),
  97.                 array('phpbb_ads', 'ad_time_end', array('TIMESTAMP', 0)),
  98.             ),
  99.  
  100.             'config_add'        => array(
  101.                 array('ads_last_cron', 0, true),
  102.             ),
  103.         ),
  104.         '1.0.5'     => array(),
  105.         '1.0.6'     => array(),
  106.         '1.0.7'     => array(),
  107.         '1.0.8'     => array(
  108.             'table_column_add'  => array(
  109.                 array('phpbb_ads', 'ad_view_limit', array('UINT', 0)),
  110.                 array('phpbb_ads', 'ad_click_limit', array('UINT', 0)),
  111.             ),
  112.         ),
  113.         '1.0.9'     => array(
  114.             'config_add'    => array(
  115.                 array('ads_group', 0),
  116.             ),
  117.             'table_column_add'  => array(
  118.                 array('phpbb_ads', 'ad_owner', array('UINT', 0)),
  119.                 array('phpbb_users', 'ad_owner', array('BOOL', 0)),
  120.             ),
  121.         ),
  122.         '1.0.10'    => array(
  123.             'table_column_update'   => array(
  124.                 array('phpbb_ads', 'ad_views', array('BINT', 0)),
  125.                 array('phpbb_ads', 'ad_view_limit', array('BINT', 0)),
  126.                 array('phpbb_ads', 'ad_clicks', array('BINT', 0)),
  127.                 array('phpbb_ads', 'ad_click_limit', array('BINT', 0)),
  128.             ),
  129.  
  130.             'table_index_add'       => array(
  131.                 array('phpbb_ads', 'ad_priority'),
  132.                 array('phpbb_ads', 'ad_enabled'),
  133.                 array('phpbb_ads', 'ad_owner'),
  134.             ),
  135.  
  136.             'cache_purge'   => array(
  137.                 'template',
  138.             ),
  139.         ),
  140.       '1.0.11'    => array(),
  141.       '1.0.12'    => array(),
  142.     );
  143.  
  144.     /**
  145.     * Single enable step that does nothing
  146.     *
  147.     * @param mixed $old_state State returned by previous call of this method
  148.     * @return false Indicates no further steps are required
  149.     */
  150.     public function enable_step($old_state)
  151.     {
  152.         parent::enable_step($old_state);
  153.  
  154.         set_config('ads_enable', 1);
  155.  
  156.         return false;
  157.     }
  158.  
  159.  
  160.     /**
  161.     * Single disable step that does nothing
  162.     *
  163.     * @param mixed $old_state State returned by previous call of this method
  164.     * @return false Indicates no further steps are required
  165.     */
  166.     public function disable_step($old_state)
  167.     {
  168.         set_config('ads_enable', 0);
  169.  
  170.         return false;
  171.     }
  172. }
  173.  
  174. function ads_install($action, $version)
  175. {
  176.     global $db, $table_prefix;
  177.  
  178.     if ($action != 'install')
  179.     {
  180.         return;
  181.     }
  182.  
  183.     // Insert the default positions
  184.     $positions = array('ABOVE_HEADER', 'BELOW_HEADER', 'ABOVE_POSTS', 'BELOW_POSTS', 'AFTER_FIRST_POST', 'AFTER_EVERY_POST', 'ABOVE_FOOTER', 'BELOW_FOOTER');
  185.     foreach ($positions as $position)
  186.     {
  187.         $db->sql_query('INSERT INTO ' . $table_prefix . 'ads_positions ' . $db->sql_build_array('INSERT', array('lang_key' => $position)));
  188.     }
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement