diff --git a/root/adm/style/acp_portal_config.html b/root/adm/style/acp_portal_config.html index 8f54e59f..b732e490 100644 --- a/root/adm/style/acp_portal_config.html +++ b/root/adm/style/acp_portal_config.html @@ -40,6 +40,18 @@
+
+ {L_MODULE_OPTIONS} +
+
+
+
+
+
+
+
{L_MODULE_IMAGE}
+
+
diff --git a/root/includes/acp/acp_portal.php b/root/includes/acp/acp_portal.php new file mode 100644 index 00000000..f87b9f0f --- /dev/null +++ b/root/includes/acp/acp_portal.php @@ -0,0 +1,451 @@ +add_lang('mods/portal'); + $submit = (isset($_POST['submit'])) ? true : false; + + $form_key = 'acp_portal'; + add_form_key($form_key); + + /** + * Validation types are: + * string, int, bool, + * script_path (absolute path in url - beginning with / and no trailing slash), + * rpath (relative), rwpath (realtive, writeable), path (relative path, but able to escape the root), wpath (writeable) + */ + switch ($mode) + { + case 'config': + $display_vars = array( +/* 'title' => 'ACP_PORTAL_GENERAL_TITLE', + 'vars' => array( + 'legend1' => 'ACP_PORTAL_GENERAL_INFO', + 'portal_enable' => array('lang' => 'PORTAL_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'portal_left_column_width' => array('lang' => 'PORTAL_LEFT_COLUMN_WIDTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), + 'portal_right_column_width' => array('lang' => 'PORTAL_RIGHT_COLUMN_WIDTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), + )*/ + ); + + $module_id = request_var('module_id', 0); + if ($module_id) + { + $sql = 'SELECT * + FROM ' . PORTAL_MODULES_TABLE . ' + WHERE module_id = ' . $module_id; + $result = $db->sql_query_limit($sql, 1); + $module_data = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($module_data !== false) + { + $class = 'portal_' . $module_data['module_classname'] . '_module'; + if (!class_exists($class)) + { + include($phpbb_root_path . 'portal/modules/portal_' . $module_data['module_classname'] . '.' . $phpEx); + } + if (!class_exists($class)) + { + trigger_error('CLASS_NOT_FOUND', E_USER_ERROR); + } + + $c_class = new $class(); + if ($c_class->language) + { + $user->add_lang('mods/portal/' . $c_class->language); + } + $display_vars = $c_class->get_template_acp($module_id); + $template->assign_vars(array( + 'MODULE_NAME' => $module_data['module_name'], + 'MODULE_IMAGE' => $module_data['module_image_src'], + 'MODULE_IMAGE_SRC' => ($module_data['module_image_src']) ? $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/' . $module_data['module_image_src'] : '', + )); + } + } + + $this->new_config = $config; + $cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config; + $error = array(); + + // We validate the complete config if whished + validate_config_vars($display_vars['vars'], $cfg_array, $error); + if ($submit && !check_form_key($form_key)) + { + $error[] = $user->lang['FORM_INVALID']; + } + + // Do not write values if there is an error + if (sizeof($error)) + { + $submit = false; + } + + // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... + foreach ($display_vars['vars'] as $config_name => $null) + { + if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) + { + continue; + } + + $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; + + if ($submit) + { + set_config($config_name, $config_value); + } + } + + if ($submit) + { + $sql_ary = array( + 'module_image_src' => request_var('module_image', ''), + 'module_name' => request_var('module_name', '', true), + ); + + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE module_id = ' . $module_id; + $db->sql_query($sql); + + $cache->destroy('sql', CONFIG_TABLE); + add_log('admin', 'LOG_PORTAL_CONFIG', $user->lang['ACP_PORTAL_' . strtoupper($mode) . '_INFO']); + trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); + } + + $this->tpl_name = 'acp_portal_config'; + $this->page_title = $display_vars['title']; + + $template->assign_vars(array( + 'L_TITLE' => $user->lang[$display_vars['title']], + 'L_TITLE_EXPLAIN' => (isset($user->lang[$display_vars['title'] . '_EXPLAIN'])) ? $user->lang[$display_vars['title'] . '_EXPLAIN'] : '', + + 'S_ERROR' => (sizeof($error)) ? true : false, + 'ERROR_MSG' => implode('
', $error), + + 'U_ACTION' => $this->u_action . (($module_id) ? '&module_id=' . $module_id : ''), + )); + + // Output relevant page + foreach ($display_vars['vars'] as $config_key => $vars) + { + if (!is_array($vars) && strpos($config_key, 'legend') === false) + { + continue; + } + + if (strpos($config_key, 'legend') !== false) + { + $template->assign_block_vars('options', array( + 'S_LEGEND' => true, + 'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars) + ); + + continue; + } + $this->new_config[$config_key] = $config[$config_key]; + $type = explode(':', $vars['type']); + + $l_explain = ''; + if ($vars['explain']) + { + $l_explain = (isset($user->lang[$vars['lang'] . '_EXP'])) ? $user->lang[$vars['lang'] . '_EXP'] : ''; + } + + $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars); + + if (empty($content)) + { + continue; + } + + $template->assign_block_vars('options', array( + 'KEY' => $config_key, + 'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'], + 'S_EXPLAIN' => $vars['explain'], + 'TITLE_EXPLAIN' => $l_explain, + 'CONTENT' => $content, + )); + + unset($display_vars['vars'][$config_key]); + } + break; + case 'modules': + $action = request_var('action', ''); + $module_id = request_var('module_id', ''); + if ($action == 'move_up') + { + $sql = 'SELECT module_order, module_column + FROM ' . PORTAL_MODULES_TABLE . ' + WHERE module_id = ' . $module_id; + $result = $db->sql_query_limit($sql, 1); + $module_data = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (($module_data !== false) && ($module_data['module_order'] > 1)) + { + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET module_order = module_order + 1 + WHERE module_order = ' . ($module_data['module_order'] - 1) . ' + AND module_column = ' . $module_data['module_column']; + $db->sql_query($sql); + $updated = $db->sql_affectedrows(); + if ($updated) + { + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET module_order = module_order - 1 + WHERE module_id = ' . $module_id; + $db->sql_query($sql); + } + } + } + elseif ($action == 'move_down') + { + $sql = 'SELECT module_order, module_column + FROM ' . PORTAL_MODULES_TABLE . ' + WHERE module_id = ' . $module_id; + $result = $db->sql_query_limit($sql, 1); + $module_data = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($module_data !== false) + { + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET module_order = module_order - 1 + WHERE module_order = ' . ($module_data['module_order'] + 1) . ' + AND module_column = ' . $module_data['module_column']; + $db->sql_query($sql); + $updated = $db->sql_affectedrows(); + if ($updated) + { + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET module_order = module_order + 1 + WHERE module_id = ' . $module_id; + $db->sql_query($sql); + } + } + } + elseif ($action == 'delete') + { + $sql = 'SELECT * + FROM ' . PORTAL_MODULES_TABLE . ' + WHERE module_id = ' . $module_id; + $result = $db->sql_query_limit($sql, 1); + $module_data = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($module_data !== false) + { + $module_classname = request_var('module_classname', ''); + $class = 'portal_' . $module_classname . '_module'; + if (!class_exists($class)) + { + include($directory . 'portal_' . $module_classname . '.' . $phpEx); + } + if (!class_exists($class)) + { + trigger_error('CLASS_NOT_FOUND', E_USER_ERROR); + } + + $c_class = new $class(); + $c_class->uninstall($module_data['module_id']); + + $sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE . ' + WHERE module_id = ' . $module_id; + $db->sql_query($sql); + + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET module_order = module_order - 1 + WHERE module_column = ' . $module_data['module_column'] . ' + AND module_order > ' . $module_data['module_order']; + $db->sql_query($sql); + + trigger_error('SUCCESS'); + } + } + + $add_module = key(request_var('add', array('' => ''))); + $add_column = request_var('add_column', column_string_num($add_module)); + if ($add_column) + { + $submit = (isset($_POST['submit'])) ? true : false; + $directory = $phpbb_root_path . 'portal/modules/'; + + if ($submit) + { + $module_classname = request_var('module_classname', ''); + $class = 'portal_' . $module_classname . '_module'; + if (!class_exists($class)) + { + include($directory . 'portal_' . $module_classname . '.' . $phpEx); + } + if (!class_exists($class)) + { + trigger_error('CLASS_NOT_FOUND', E_USER_ERROR); + } + + $sql = 'SELECT module_order + FROM ' . PORTAL_MODULES_TABLE . ' + WHERE module_column = ' . $add_column . ' + ORDER BY module_order DESC'; + $result = $db->sql_query_limit($sql, 1); + $module_order = 1 + (int) $db->sql_fetchfield('module_order'); + $db->sql_freeresult($result); + + $c_class = new $class(); + + $sql_ary = array( + 'module_classname' => $module_classname, + 'module_column' => $add_column, + 'module_order' => $module_order, + 'module_name' => $c_class->name, + 'module_image_src' => $c_class->image_src, + 'module_group_ids' => '', + ); + $sql = 'INSERT INTO ' . PORTAL_MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); + $db->sql_query($sql); + + $c_class->install($db->sql_nextid()); + + trigger_error('SUCCESS'); + } + + $template->assign_var('S_EDIT', true); + $fileinfo = array(); + + $dh = @opendir($directory); + if (!$dh) + { + return $fileinfo; + } + + while (($file = readdir($dh)) !== false) + { + // Is module? + if (preg_match('/^portal_.+\.' . $phpEx . '$/', $file)) + { + $class = str_replace(".$phpEx", '', $file) . '_module'; + if (!class_exists($class)) + { + include($directory . $file); + } + + // Get module title tag + if (class_exists($class)) + { + $c_class = new $class(); + if ($c_class->columns & column_string_const($add_module)) + { + $fileinfo[] = substr($class, 7, -7); + } + } + } + } + closedir($dh); + + ksort($fileinfo); + $options = ''; + + foreach ($fileinfo as $module) + { + $options .= ''; + } + + $s_hidden_fields = build_hidden_fields(array( + 'add_column' => column_string_num($add_module), + )); + $template->assign_vars(array( + 'S_MODULE_NAMES' => $options, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + )); + } + else + { + $directory = $phpbb_root_path . 'portal/modules/'; + + $sql = 'SELECT * + FROM ' . PORTAL_MODULES_TABLE . ' + ORDER BY module_column, module_order ASC'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $class = 'portal_' . $row['module_classname'] . '_module'; + if (!class_exists($class)) + { + include($directory . 'portal_' . $row['module_classname'] . '.' . $phpEx); + } + if (!class_exists($class)) + { + trigger_error('CLASS_NOT_FOUND', E_USER_ERROR); + } + + $c_class = new $class(); + if ($c_class->language) + { + $user->add_lang('mods/portal/' . $c_class->language); + } + $template_column = column_num_string($row['module_column']); + + $template->assign_block_vars('modules_' . $template_column, array( + 'MODULE_NAME' => (isset($user->lang[$row['module_name']])) ? $user->lang[$row['module_name']] : $row['module_name'], + 'MODULE_IMAGE' => ($row['module_image_src']) ? '' . $row['module_name'] . '' : '', + + 'U_DELETE' => $this->u_action . '&module_id=' . $row['module_id'] . '&action=delete', + 'U_EDIT' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=portal&mode=config&module_id=' . $row['module_id']), + 'U_MOVE_UP' => $this->u_action . '&module_id=' . $row['module_id'] . '&action=move_up', + 'U_MOVE_DOWN' => $this->u_action . '&module_id=' . $row['module_id'] . '&action=move_down', + )); + } + $db->sql_freeresult($result); + } + + $this->tpl_name = 'acp_portal_modules'; + $this->page_title = 'ACP_PORTAL_MODULES'; + break; + default: + trigger_error('NO_MODE', E_USER_ERROR); + break; + } + } +} +?> \ No newline at end of file diff --git a/root/includes/acp/acp_portal_blocks.php b/root/includes/acp/acp_portal_blocks.php index 9fb8f069..6c8a3207 100644 --- a/root/includes/acp/acp_portal_blocks.php +++ b/root/includes/acp/acp_portal_blocks.php @@ -8,6 +8,8 @@ * */ +// COULD BE DELETED + /** * @ignore */ diff --git a/root/includes/acp/acp_portal_config.php b/root/includes/acp/acp_portal_config.php index f10dcd52..20dc84b0 100644 --- a/root/includes/acp/acp_portal_config.php +++ b/root/includes/acp/acp_portal_config.php @@ -8,6 +8,8 @@ * */ +// COULD BE DELETED + /** * @ignore */ diff --git a/root/includes/acp/acp_portal_links.php b/root/includes/acp/acp_portal_links.php index 219c9a43..4b991820 100644 --- a/root/includes/acp/acp_portal_links.php +++ b/root/includes/acp/acp_portal_links.php @@ -8,6 +8,8 @@ * */ +// COULD BE DELETED + /** * @ignore */ diff --git a/root/includes/acp/info/acp_portal.php b/root/includes/acp/info/acp_portal.php new file mode 100644 index 00000000..f403b293 --- /dev/null +++ b/root/includes/acp/info/acp_portal.php @@ -0,0 +1,33 @@ + 'acp_portal', + 'title' => 'ACP_PORTAL', + 'version' => '1.2.0', + 'modes' => array( + 'config' => array('title' => 'ACP_PORTAL_GENERAL_INFO', 'auth' => 'acl_a_portal', 'cat' => array('ACP_PORTAL')), + 'modules' => array('title' => 'ACP_PORTAL_MODULES', 'auth' => 'acl_a_portal', 'cat' => array('ACP_PORTAL')), + ), + ); + } +} + +?> \ No newline at end of file diff --git a/root/install/umil.php b/root/install/umil.php new file mode 100644 index 00000000..ceec15fe --- /dev/null +++ b/root/install/umil.php @@ -0,0 +1,61 @@ +session_begin(); +$auth->acl($user->data); +$user->setup(); + +if (!file_exists($phpbb_root_path . 'umil/umil_auto.' . $phpEx)) +{ + trigger_error('Please download the latest UMIL (Unified MOD Install Library) from: phpBB.com/mods/umil', E_USER_ERROR); +} + +$mod_name = 'PORTAL_MOD'; + +$version_config_name = 'portal_board3_version'; +$language_file = 'mods/info_acp_portal'; + +$versions = array( + // Version 1.1.0 => 1.2.x-dev + '1.1.1' => array( + 'permission_add' => array( + array('a_portal'), + ), + ), + '1.1.4' => array( + 'table_add' => array( + array(PORTAL_MODULES_TABLE, array( + 'COLUMNS' => array( + 'module_id' => array('UINT', NULL, 'auto_increment'), + 'module_classname' => array('VCHAR:64', ''), + 'module_column' => array('TINT:3', 0), + 'module_order' => array('TINT:3', 0), + 'module_name' => array('VCHAR', ''), + 'module_image_src' => array('VCHAR', ''), + 'module_group_ids' => array('VCHAR', ''), + ), + 'PRIMARY_KEY' => 'module_id', + )), + ), + ), +); + +// Include the UMIL Auto file and everything else will be handled automatically. +include($phpbb_root_path . 'umil/umil_auto.' . $phpEx); +?> \ No newline at end of file diff --git a/root/language/de/mods/portal/portal_topposters_module.php b/root/language/de/mods/portal/portal_topposters_module.php new file mode 100644 index 00000000..a1a24619 --- /dev/null +++ b/root/language/de/mods/portal/portal_topposters_module.php @@ -0,0 +1,39 @@ + 'Top Poster', + 'TOPPOSTERS_CONFIG' => 'Einstellungen zu Top Poster', + 'NUM_TOPPOSTERS' => 'Anzahl der Top Poster', +)); + +?> \ No newline at end of file diff --git a/root/portal.php b/root/portal.php index c7c2aab7..a356a00e 100644 --- a/root/portal.php +++ b/root/portal.php @@ -1,13 +1,13 @@ session_begin(); $auth->acl($user->data); $user->setup('mods/portal'); -$portal_root_path = PORTAL_ROOT_PATH; -$portal_icons_path = PORTAL_ICONS_PATH; -if (!function_exists('group_memberships')) -{ - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); -} -if (!function_exists('obtain_portal_config')) -{ - include($phpbb_root_path . $portal_root_path . 'includes/functions.' . $phpEx); -} -$portal_config = obtain_portal_config(); - - -if (!$portal_config['portal_enable']) -{ - redirect($phpbb_root_path . 'index.' . $phpEx); -} - -if (file_exists($phpbb_root_path . 'install/index.' . $phpEx) && ($user->data['user_type'] == USER_FOUNDER)) -{ - $template->assign_var('S_DISPLAY_GENERAL', true); -} - -// Grab blocks -if ($portal_config['num_blocks'] > 0) -{ - $blocks = $cache->obtain_blocks(); - - if (sizeof($blocks)) - { - foreach ($blocks as $id => $data) - { - $group_id = $data['group']; - $user_id = $user->data['user_id']; - $is_in_group = ($data['group'] <> 0) ? group_memberships($group_id, $user_id , true) : true; - - /*if ($data['title'] == 'BLOCK_ANNOUNCEMENTS' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/announcements.' . $phpEx); - } - if ($data['title'] == 'BLOCK_ATTACHMENTS' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/attachments.' . $phpEx); - }*/ - if ($data['title'] == 'BLOCK_BIRTHDAY' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/birthday_list.' . $phpEx); - } - /*if ($data['title'] == 'BLOCK_CHANGE_STYLE' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/change_style.' . $phpEx); - }*/ - if ($data['title'] == 'BLOCK_DONATE' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/donate.' . $phpEx); - } - if ($data['title'] == 'BLOCK_ONLINE_FRIENDS' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/friends.' . $phpEx); - } - if ($data['title'] == 'BLOCK_LATEST_MEMBERS' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/latest_members.' . $phpEx); - } - if ($data['title'] == 'BLOCK_BOTS' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/latest_bots.' . $phpEx); - } - /*if ($data['title'] == 'BLOCK_LEADERS' && $data['position'] > 0 && $is_in_group) - { - if ($portal_config['portal_leaders_ext']) - { - include($phpbb_root_path . 'portal/block/leaders_ext.'.$phpEx); - } - else - { - include($phpbb_root_path . 'portal/block/leaders.'.$phpEx); - } - } - if ($data['title'] == 'BLOCK_LINK_US' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/link_us.' . $phpEx); - } - if ($data['title'] == 'BLOCK_MINI_CAL' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/mini_cal.' . $phpEx); - } - if ($data['title'] == 'BLOCK_POLL' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/poll.' . $phpEx); - } - if ($data['title'] == 'BLOCK_RANDOM_MEMBER' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/random_member.' . $phpEx); - } - if ($data['title'] == 'BLOCK_RECENT' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/recent.' . $phpEx); - }*/ - if ($data['title'] == 'BLOCK_STATISTICS' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/statistics.' . $phpEx); - } - if ($data['title'] == 'BLOCK_TOP_POSTERS' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/top_posters.' . $phpEx); - } - if ($data['title'] == 'BLOCK_USER_MENU' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/user_menu.' . $phpEx); - } - /*if ($data['title'] == 'BLOCK_WORDGRAPH' && $data['position'] > 0 && $is_in_group) - { - include($phpbb_root_path . $portal_root_path . 'block/wordgraph.' . $phpEx); - }*/ - - $template->assign_block_vars('blocks', array( - 'TYPE' => $data['type'], - 'ICON' => $phpbb_root_path . $portal_icons_path .'/' . $data['icon'], - 'TITLE' => (!empty($user->lang[strtoupper($data['title'])])) ? $user->lang[strtoupper($data['title'])] : $data['title'], - 'TEXT' => ($data['type'] == 'custom') ? generate_text_for_display($data['text'], $data['text_uid'], $data['text_bitfield'], $data['text_options']) : '', - - 'S_GROUP' => ($is_in_group) ? true : false, - 'S_ICON' => ($data['icon']) ? true : false, - 'S_BLOCK_LEFT' => ($data['position'] == BLOCK_LEFT) ? true : false, - 'S_BLOCK_RIGHT' => ($data['position'] == BLOCK_RIGHT) ? true : false, - 'S_BLOCK_TOP' => ($data['position'] == BLOCK_TOP) ? true : false, - 'S_BLOCK_BOTTOM' => ($data['position'] == BLOCK_BOTTOM) ? true : false, - 'S_BLOCK_MIDDLE_TOP' => ($data['position'] == BLOCK_MIDDLE_TOP) ? true : false, - 'S_BLOCK_MIDDLE_BOTTOM' => ($data['position'] == BLOCK_MIDDLE_BOTTOM) ? true : false, - )); - } - } -} - -$sql = 'SELECT block_position - FROM ' . PORTAL_BLOCKS_TABLE; +$sql = 'SELECT * + FROM ' . PORTAL_MODULES_TABLE; $result = $db->sql_query($sql); -$db->sql_freeresult($result); - -// Grab navigation links -if ($portal_config['num_links'] > 0) +while ($row = $db->sql_fetchrow($result)) { - $links = $cache->obtain_links(); - - if (sizeof($links)) + $class_name = 'portal_' . $row['module_classname'] . '_module'; + if (!class_exists($class_name)) { - foreach ($links as $id => $data) - { - $template->assign_block_vars('links', array( - 'TITLE' => $data['title'], - 'URL' => $data['url'], - - 'S_IS_CAT' => $data['is_cat'], - )); - } + include("{$phpbb_root_path}{$portal_root_path}modules/portal_{$row['module_classname']}.$phpEx"); } + if (!class_exists($class_name)) + { + trigger_error(sprintf($user->lang['CLASS_NOT_FOUND'], $class_name, 'portal_' . $row['module_classname']), E_USER_ERROR); + } + + + $module = new $class_name(); + if ($module->language) + { + $user->add_lang('mods/portal/' . $module->language); + } + if ($row['module_column'] == 1) + { + $template_module = $module->get_template_side($row['module_id']); + $template_column = 'left'; + } + if ($row['module_column'] == 2) + { + $template_module = $module->get_template_center($row['module_id']); + $template_column = 'center'; + } + if ($row['module_column'] == 3) + { + $template_module = $module->get_template_side($row['module_id']); + $template_column = 'right'; + } + if (!$template_module) + { + continue; + } + + $template->assign_block_vars('modules_' . column_num_string($row['module_column']), array( + 'TEMPLATE_FILE' => 'portal/modules/' . $template_module, + 'IMAGE_SRC' => $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/' . $row['module_image_src'], + )); } +$db->sql_freeresult($result); // Assign specific vars $template->assign_vars(array( - 'WELCOME_USERNAME' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), - - 'U_M_BBCODE' => append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode'), - 'U_M_TERMS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), - 'U_M_PRV' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), - - 'PAY_ACC' => $portal_config['portal_pay_acc'], - - 'S_SMALL_BLOCK' => ($row['block_position'] == BLOCK_LEFT || $row['block_position'] == BLOCK_RIGHT) ? true : false, - 'S_PORTAL_LEFT_COLUMN' => $portal_config['portal_left_column_width'], - 'S_PORTAL_RIGHT_COLUMN' => $portal_config['portal_right_column_width'], + 'S_SMALL_BLOCK' => true, + 'S_PORTAL_LEFT_COLUMN' => 250, + 'S_PORTAL_RIGHT_COLUMN' => 250, )); // Output page diff --git a/root/portal/includes/functions_modules.php b/root/portal/includes/functions_modules.php new file mode 100644 index 00000000..8a231451 --- /dev/null +++ b/root/portal/includes/functions_modules.php @@ -0,0 +1,69 @@ + \ No newline at end of file diff --git a/root/portal/modules/portal_default.php b/root/portal/modules/portal_default.php new file mode 100644 index 00000000..e34da23a --- /dev/null +++ b/root/portal/modules/portal_default.php @@ -0,0 +1,107 @@ +lang}/mods/portal/" + */ + var $language = ''; + + function get_template_center($module_id) + { + global $config, $template; + + $template->assign_vars(array( + 'EXAMPLE' => $config['portal_' . $module_id . '_configname'], + )); + + return 'modulename_center.html'; + } + + function get_template_side($module_id) + { + global $config, $template; + + $template->assign_vars(array( + 'EXAMPLE' => $config['portal_' . $module_id . '_configname2'], + )); + + return 'modulename_side.html'; + } + + function get_template_acp($module_id) + { + return array( + 'title' => 'ACP_CONFIG_MODULENAME', + 'vars' => array( + 'legend1' => 'ACP_MODULENAME_CONFIGLEGEND', + 'portal_' . $module_id . '_configname' => array('lang' => 'MODULENAME_CONFIGNAME', 'validate' => 'string', 'type' => 'text:10:200', 'explain' => false), + 'portal_' . $module_id . '_configname2' => array('lang' => 'MODULENAME_CONFIGNAME2', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), + ), + ); + } + + /** + * API functions + */ + function install($module_id) + { + set_config('portal_' . $module_id . '_configname', 'Hello World!'); + set_config('portal_' . $module_id . '_configname2', 1337); + return true; + } + + function uninstall($module_id) + { + global $db; + + $del_config = array( + 'portal_' . $module_id . '_configname', + 'portal_' . $module_id . '_configname2', + ); + $sql = 'DELETE FROM ' . CONFIG_TABLE . ' + WHERE ' . $db->sql_in_set('config_name', $del_config); + return $db->sql_query($sql); + } +} + +?> \ No newline at end of file diff --git a/root/portal/modules/portal_topposters.php b/root/portal/modules/portal_topposters.php new file mode 100644 index 00000000..dbb46b22 --- /dev/null +++ b/root/portal/modules/portal_topposters.php @@ -0,0 +1,113 @@ +lang}/mods/portal/" + */ + var $language = 'portal_topposters_module'; + + function get_template_center($module_id) + { + return false; + } + + function get_template_side($module_id) + { + global $config, $db, $template; + global $phpbb_root_path, $phpEx; + + $sql = 'SELECT user_id, username, user_posts, user_colour + FROM ' . USERS_TABLE . ' + WHERE user_type <> ' . USER_IGNORE . " + AND user_posts <> 0 + AND username <> '' + ORDER BY user_posts DESC"; + $result = $db->sql_query_limit($sql, $config['portal_topposters']); + + while (($row = $db->sql_fetchrow($result))) + { + $template->assign_block_vars('topposters', array( + 'S_SEARCH_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $row['user_id'] . '&sr=posts'), + 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), + 'POSTER_POSTS' => $row['user_posts'], + )); + } + $db->sql_freeresult($result); + + return 'topposters_side.html'; + } + + function get_template_acp($module_id) + { + return array( + 'title' => 'TOPPOSTERS_CONFIG', + 'vars' => array( + 'legend1' => 'TOPPOSTERS', + 'portal_topposters' => array('lang' => 'NUM_TOPPOSTERS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), + ), + ); + } + + /** + * API functions + */ + function install($module_id) + { + set_config('portal_topposters', 5); + return true; + } + + function uninstall($module_id) + { + global $db; + + $del_config = array( + 'portal_topposters', + ); + $sql = 'DELETE FROM ' . CONFIG_TABLE . ' + WHERE ' . $db->sql_in_set('config_name', $del_config); + return $db->sql_query($sql); + } +} + +?> \ No newline at end of file diff --git a/root/styles/prosilver/template/portal/modules/birthdays_side.html b/root/styles/prosilver/template/portal/modules/birthdays_side.html new file mode 100644 index 00000000..c1673c22 --- /dev/null +++ b/root/styles/prosilver/template/portal/modules/birthdays_side.html @@ -0,0 +1,15 @@ + +{$LR_BLOCK_H_L} {L_BIRTHDAYS}{$LR_BLOCK_H_R} + + {L_CONGRATULATIONS}:
{BIRTHDAY_LIST} + + {L_NO_BIRTHDAYS} + +{$LR_BLOCK_F_L}{$LR_BLOCK_F_R} +{$LR_BLOCK_H_L}{L_BIRTHDAYS_AHEAD}{$LR_BLOCK_H_R} + + {BIRTHDAYS_AHEAD_LIST} + + {L_NO_BIRTHDAYS_AHEAD} + +{$LR_BLOCK_F_L}{$LR_BLOCK_F_R} \ No newline at end of file diff --git a/root/styles/prosilver/template/portal/modules/donate_center.html b/root/styles/prosilver/template/portal/modules/donate_center.html new file mode 100644 index 00000000..5120168b --- /dev/null +++ b/root/styles/prosilver/template/portal/modules/donate_center.html @@ -0,0 +1,39 @@ + +{SITENAME} {L_DONATION_TEXT} +
+
+ +
+ + + + + + + + + + +
+
+
+{L_PAY_MSG} \ No newline at end of file diff --git a/root/styles/prosilver/template/portal/modules/topposters_side.html b/root/styles/prosilver/template/portal/modules/topposters_side.html new file mode 100644 index 00000000..91c7324c --- /dev/null +++ b/root/styles/prosilver/template/portal/modules/topposters_side.html @@ -0,0 +1,9 @@ + +{$LR_BLOCK_H_L} {L_TOPPOSTERS}{$LR_BLOCK_H_R} + {L_USERNAME} + {L_POSTS}
+ + {topposters.USERNAME_FULL} + {topposters.POSTER_POSTS}
+ +{$LR_BLOCK_F_L}{$LR_BLOCK_F_R} \ No newline at end of file diff --git a/root/styles/prosilver/template/portal/portal_body.html b/root/styles/prosilver/template/portal/portal_body.html index aacc1095..a1c42f8c 100644 --- a/root/styles/prosilver/template/portal/portal_body.html +++ b/root/styles/prosilver/template/portal/portal_body.html @@ -2,7 +2,6 @@ -
@@ -15,32 +14,42 @@ - + - - - - - + - + - +

- + + + + + +
-
- - + + + +
+
+ + - +

- + + + + +
+