Thread: [Phpbbproject-svn] SF.net SVN: phpbbproject: [264] trunk
phpBB download manager, mainly aimed at MOD authors
Status: Planning
Brought to you by:
lord_le_brand
From: <lor...@us...> - 2008-04-23 00:26:09
|
Revision: 264 http://phpbbproject.svn.sourceforge.net/phpbbproject/?rev=264&view=rev Author: lord_le_brand Date: 2008-04-22 17:26:14 -0700 (Tue, 22 Apr 2008) Log Message: ----------- Changed column project_start_id to project_owner on table project_projects Merged tables project_actions and project_action_contents Changed column is_active to project_status on table project_projects Made project_create a class Started working on import class Changed private to protected in download class Modified Paths: -------------- trunk/develop/create_schema_files_phpbb3.php trunk/phpbb3/root/includes/project/project_main.php trunk/phpbb3/root/includes/sources_project/constants.php trunk/phpbb3/root/includes/sources_project/create_project.php trunk/phpbb3/root/includes/sources_project/download_project.php trunk/phpbb3/root/styles/prosilver/template/project_viewcat.html Added Paths: ----------- trunk/develop/autopost.temp.php trunk/develop/create_project.temp.php trunk/phpbb3/root/includes/sources_project/import_project.php Added: trunk/develop/autopost.temp.php =================================================================== --- trunk/develop/autopost.temp.php (rev 0) +++ trunk/develop/autopost.temp.php 2008-04-23 00:26:14 UTC (rev 264) @@ -0,0 +1,331 @@ +<? +/** + * Handle autoposting + * + * @param array $info_array + * @param array $authors + * @param boolean|array $history + * @param boolean|array $update + * @return integer|boolean Either post_id or topic_id, depending on $update, or false on failure + */ +function project_autopost($info_array, $authors, $history = false, $update = false) +{ + global $db, $config, $user, $auth; + global $phpbb_root_path, $phpEx; + + include_once("{$phpbb_root_path}includes/functions_posting.$phpEx"); + include_once("{$phpbb_root_path}includes/message_parser.$phpEx"); + + $forum_root_path = generate_board_url(); + + $stages_ary = array( + PROJECT_STAGE_ALPHA => $user->lang['PROJECT_STAGE_ALPHA'], + PROJECT_STAGE_BETA => $user->lang['PROJECT_STAGE_BETA'], + PROJECT_STAGE_DEV => $user->lang['PROJECT_STAGE_DEV'], + PROJECT_STAGE_RC => $user->lang['PROJECT_STAGE_RC'], + PROJECT_STAGE_STABLE => $user->lang['PROJECT_STAGE_STABLE'], + ); + + $post_tpl = new template(); + $post_tpl->set_custom_template("{$phpbb_root_path}store/phpbbproject/autopost", 'project_autopost'); + + if ($update) + { + // Reply to topic $info_array['topic_id'] + $topic_id = $info_array['topic_id']; + + if (!$topic_id) + { + return false; + } + + $post_tpl->set_filenames(array( + 'first_post_body' => 'topic_layout.html', + 'first_post_title' => 'topic_title.html', + 'update_post_body' => 'update_post_layout.html', + 'update_post_title' => 'update_post_title.html', + )); + + if ($history) + { + for ($i = 0, $size = sizeof($history); $i < $size; $i++) + { + $post_tpl->assign_block_vars('history', array( + 'DATE' => date('Y-m-d', $history[$i]['version_time']), + 'VERSION' => "{$history[$i]['version_major']}.{$history[$i]['version_minor']}.{$history[$i]['version_revision']}{$history[$i]['version_release']}", + 'CHANGELOG' => $history[$i]['version_changelog'], + + 'U_UPDATE_POST' => ($history[$i]['version_post_id']) ? "{$forum_root_path}viewtopic.$phpEx?t=$topic_id&p={$history[$i]['version_post_id']}#{$history[$i]['version_post_id']}" : '', + 'U_DIFF' => ($history[$i]['version_id'] && $history[$i]['previous_version_id']) ? "{$forum_root_path}project.$phpEx?i=project&mode=diff&pr={$info_array['project_id']}&dm=normal&nv={$history[$i]['version_id']}&ov={$history[$i]['previous_version_id']}" : '', + )); + } + } + + for ($i = 0, $size = sizeof($authors); $i < $size; $i++) + { + $post_tpl->assign_block_vars('author', array( + 'USERNAME' => $authors[$i]['author_username'], + 'REAL_NAME' => $authors[$i]['author_realname'], + 'EMAIL' => $authors[$i]['author_email'], + 'WEBSITE' => $authors[$i]['author_website'], + 'ROLE' => $authors[$i]['author_role_title'], + + 'S_STARTER' => ($authors[$i]['author_id'] == $info_array['project_start_id']) ? true : false, + + 'U_AUTHOR' => "{$forum_root_path}project.$phpEx?i=author&mode=view&u={$authors[$i]['author_id']}", + )); + } + + $post_tpl->assign_vars(array( + 'PROJECT_TITLE' => $info_array['project_title'], + 'PROJECT_TITLE_CLEAN' => $info_array['project_title_clean'], + 'PROJECT_DESCRIPTION' => $info_array['project_description'], + 'AUTHOR_NOTES' => $info_array['project_notes'], + + 'DATE' => $info_array['project_last_update'], + 'VERSION' => $info_array['project_version'], + 'TARGET_VERSION' => $info_array['project_target_version'], + + 'DEV_STAGE_ID' => $info_array['project_stage'], + 'DEV_STAGE_UC' => strtoupper($stages_ary[$info_array['project_stage']]), + 'DEV_STAGE_LC' => strtolower($stages_ary[$info_array['project_stage']]), + 'DEV_STAGE_NC' => $stages_ary[$info_array['project_stage']], + + 'U_DOWNLOAD' => "{$forum_root_path}project.$phpEx?i=project&mode=download&pr={$info_array['project_id']}", + 'U_PROJECT_INFO' => "{$forum_root_path}project.$phpEx?i=project&mode=view&pr={$info_array['project_id']}", + + // Update post extra vars + 'CHANGELOG' => $update['changelog'], + + 'U_DIFF' => "{$forum_root_path}project.$phpEx?i=project&mode=diff&pr={$info_array['project_id']}&dm=normal&nv={$update['version_id']}&ov={$update['previous_version_id']}", + 'U_TOPIC' => "{$forum_root_path}viewtopic.$phpEx?t=$topic_id", + + 'OLD_TARGET_VERSION' => $update['previous_target_version'], + 'OLD_VERSION' => $update['previous_version'], + 'OLD_DEV_STAGE_ID' => $update['previous_dev_stage'], + )); + + ob_start(); + $post_tpl->display('first_post_body'); + $first_post_contents = ob_get_contents(); + ob_clean(); + $post_tpl->display('first_post_title'); + $first_post_title = ob_get_contents(); + ob_clean(); + $post_tpl->display('update_post_body'); + $update_post_contents = ob_get_contents(); + ob_clean(); + $post_tpl->display('update_post_title'); + $update_post_title = ob_get_clean(); + } + else + { + $post_tpl->set_filenames(array( + 'post_body' => 'topic_layout.html', + 'post_title' => 'topic_title.html', + )); + + if ($history) + { + for ($i = 0, $size = sizeof($history); $i < $size; $i++) + { + $post_tpl->assign_block_vars('history', array( + 'DATE' => date('Y-m-d', $history[$i]['version_time']), + 'VERSION' => "{$history[$i]['version_major']}.{$history[$i]['version_minor']}.{$history[$i]['version_revision']}{$history[$i]['version_release']}", + 'CHANGELOG' => $history[$i]['version_changelog'], + + 'U_UPDATE_POST' => '', + 'U_DIFF' => '', + )); + } + } + + for ($i = 0, $size = sizeof($authors); $i < $size; $i++) + { + $post_tpl->assign_block_vars('author', array( + 'USERNAME' => $authors[$i]['author_username'], + 'REAL_NAME' => $authors[$i]['author_realname'], + 'EMAIL' => $authors[$i]['author_email'], + 'WEBSITE' => $authors[$i]['author_website'], + 'ROLE' => $authors[$i]['author_role_title'], + + 'S_STARTER' => ($authors[$i]['author_id'] == $info_array['project_start_id']) ? true : false, + 'U_AUTHOR' => "{$forum_root_path}project.$phpEx?i=author&mode=view&u={$authors[$i]['author_id']}", + )); + } + + $post_tpl->assign_vars(array( + 'PROJECT_TITLE' => $info_array['project_title'], + 'PROJECT_TITLE_CLEAN' => $info_array['project_title_clean'], + 'PROJECT_DESCRIPTION' => $info_array['project_description'], + 'AUTHOR_NOTES' => $info_array['project_notes'], + + 'DATE' => $info_array['project_last_update'], + 'VERSION' => $info_array['project_version'], + 'TARGET_VERSION' => $info_array['project_target_version'], + + 'DEV_STAGE_ID' => $info_array['project_stage'], + 'DEV_STAGE_UC' => strtoupper($stages_ary[$info_array['project_stage']]), + 'DEV_STAGE_LC' => strtolower($stages_ary[$info_array['project_stage']]), + 'DEV_STAGE_NC' => $stages_ary[$info_array['project_stage']], + + 'U_DOWNLOAD' => "{$forum_root_path}project.$phpEx?i=project&mode=download&pr={$info_array['project_id']}", + 'U_PROJECT_INFO' => "{$forum_root_path}project.$phpEx?i=project&mode=view&pr={$info_array['project_id']}", + )); + + ob_start(); + $post_tpl->display('post_body'); + $first_post_contents = ob_get_contents(); + ob_clean(); + $post_tpl->display('post_title'); + $first_post_title = ob_get_clean(); + } + + // Get forum ID + if ($config['project_autopost_forum_per_category']) + { + $sql = 'SELECT c.forum_id, f.forum_name + FROM ' . PROJECT_CATEGORIES_TABLE . ' c, ' . FORUMS_TABLE . ' f + WHERE c.category_id = ' . (int) $info_array['category_id'] . ' + AND f.forum_id = c.forum_id'; + + $db->sql_query($sql, 604800); + $forum_data = $db->sql_fetchrow(); + $db->sql_freeresult(); + } + else + { + $sql = 'SELECT forum_id, forum_name + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . (int) $config['project_autopost_forum_id']; + + $db->sql_query($sql, 604800); + $forum_data = $db->sql_fetchrow(); + $db->sql_freeresult(); + } + + $forum_id = $forum_data['forum_id']; + $forum_name = $forum_data['forum_name']; + + // submit_post() needs $user to be the info of the posting user, this is not the case here, so make a workaround + $this_user = $user; + + $user->data['is_registered'] = false; + $user->data['user_id'] = $config['project_autopost_user_id']; + + $sql = 'SELECT username, user_colour + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . (int) $user->data['user_id']; + + $db->sql_query($sql, 604800); + $userdata = $db->sql_fetchrow(); + $db->sql_freeresult(); + + $user->data['username'] = $userdata['username']; + $user->data['user_colour'] = $userdata['user_colour']; + $user->data['user_permissions'] = ''; + $user->ip = '127.0.0.1'; + $auth->acl($user->data); + + $message_parser = new parse_message($first_post_contents); + + if ($update) + { + $update_message_parser = new parse_message($update_post_contents); + $update_message_parser->parse(1, 1, 1); + + $sql = 'SELECT t.topic_replies_real, p.post_id, p.bbcode_uid, p.post_time + FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p + WHERE t.topic_id = $topic_id + AND p.post_id = t.topic_first_post_id"; + + $db->sql_query($sql); + $post_data = $db->sql_fetchrow(); + $db->sql_freeresult(); + + $message_parser->bbcode_uid = $post_data['bbcode_uid']; + } + + $message_parser->parse(1, 1, 1); + + + // Build data array + $data = array( + 'topic_title' => $first_post_title, + 'post_subject' => $first_post_title, + 'forum_id' => $forum_id, + 'forum_name' => $forum_name, + 'icon_id' => 0, + + 'enable_bbcode' => 1, + 'enable_smilies' => 1, + 'enable_urls' => 1, + 'enable_sig' => 0, + 'enable_indexing' => 1, + + 'message' => $message_parser->message, + 'message_md5' => md5($message_parser->message), + + 'bbcode_bitfield' => $message_parser->bbcode_bitfield, + 'bbcode_uid' => $message_parser->bbcode_uid, + + 'attachment_data' => array(), + + 'post_edit_locked' => false, + 'post_time' => (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : time(), + + ); + + $poll = array(); + + if ($update) + { + $data = array_merge($data, array('topic_id' => $topic_id, 'topic_first_post_id' => $post_data['post_id'], 'post_id' => $post_data['post_id'], 'topic_replies_real' => $post_data['topic_replies_real'], 'poster_id' => $user->data['user_id'], 'topic_approved' => true, 'post_approved' => true)); + submit_post('edit', $first_post_title, '', POST_NORMAL, $poll, $data); + + $update_data = array( + 'topic_id' => $topic_id, + 'post_subject' => $update_post_title, + 'forum_id' => $forum_id, + 'forum_name' => $forum_name, + 'icon_id' => 0, + + 'enable_bbcode' => 1, + 'enable_smilies' => 1, + 'enable_urls' => 1, + 'enable_sig' => 0, + 'enable_indexing' => 1, + + 'message' => $update_message_parser->message, + 'message_md5' => md5($update_message_parser->message), + + 'bbcode_bitfield' => $update_message_parser->bbcode_bitfield, + 'bbcode_uid' => $update_message_parser->bbcode_uid, + + 'attachment_data' => array(), + + 'post_edit_locked' => false, + 'post_time' => time(), + ); + + submit_post('reply', $update_post_title, '', POST_NORMAL, $poll, $update_data); + } + else + { + submit_post('post', $first_post_title, '', POST_NORMAL, $poll, $data); + } + + $user = $this_user; + $auth->acl($user->data); + + if (!$update) + { + $sql = 'UPDATE ' . PROJECT_PROJECTS_TABLE . ' + SET topic_id = ' . (int) $data['topic_id'] . ' + WHERE project_id = ' . $info_array['project_id']; + $db->sql_query($sql); + } + + return ($update) ? $update_data['post_id'] : $data['topic_id']; +} +?> \ No newline at end of file Added: trunk/develop/create_project.temp.php =================================================================== --- trunk/develop/create_project.temp.php (rev 0) +++ trunk/develop/create_project.temp.php 2008-04-23 00:26:14 UTC (rev 264) @@ -0,0 +1,169 @@ +<? + +/** + * Create a new project + * + * @param string $mode + * @param array $info_array + * @param array $authors + * @param array|boolean $history + * @param array|boolean $actions + * @param array|boolean $old_actions + * @return boolean|string Either false if succesful of the error message + */ +function project_create($mode, $info_array, $authors, $history = false, $actions = false, $old_actions = false) +{ + global $db, $config, $auth, $user; + + // Check permissions + if (!$auth->acl_get('p_add_project')) + { + return $user->lang['PROJECT_NOT_AUTH_CREATE']; + } + if (!$auth->acl_get('p_view_category', $info_array['category_id'])) + { + return $user->lang['PROJECT_NOT_AUTH_CAT']; + } + + // Time & date of project creation + $current_time = time(); + + // History and action information are only needed for importing + if ($mode != 'import') + { + $history = $actions = $old_actions = false; + } + + // Variable types for database protection + $info_vars = array('category_id' => 'int' + , 'project_title' => 'string', + 'project_description' => 'string', + 'project_notes' => 'string', + 'project_license' => 'int', + 'project_target_version' => 'string', + 'project_version' => 'string', + 'project_stage' => 'int', + 'project_logo' => 'string', + 'project_logo_type' => 'int', + 'project_logo_width' => 'int', + 'project_logo_height' => 'int', + 'is_active' => 'int', + 'file_only' => 'int'); + + $error_message = ''; + foreach ($info_vars AS $var => $type) + { + if (!isset($info_array[$var])) + { + $error_message .= (($error_message) ? '<br />' : '') . sprintf($user->lang['FIELD_REQUIRED'], $var); + } + + $$var = ($type == 'string') ? $db->sql_escape($info_array[$var]) : intval($info_array[$var]); + } + if (!empty($error_message)) + { + return $error_message; + } + + // Clean title for uniqueness + $info_array['project_title_clean'] = utf8_clean_string($info_array['project_title']); + $project_title_clean = $db->sql_escape($info_array['project_title_clean']); + + $info_array['project_install_time'] = ($actions) ? project_generate_install_time($actions) : 0; + $info_array['project_level'] = ($actions) ? project_generate_level('actions', $actions) : PROJECT_LEVEL_EASY; + + $info_array['project_start_time'] = (empty($info_array['project_start_time'])) ? $current_time : intval($info_array['project_start_time']); + $info_array['project_start_id'] = (empty($info_array['project_start_id'])) ? $user->data['user_id'] : intval($info_array['project_start_id']); + $info_array['project_start_author'] = (empty($info_array['project_start_author'])) ? project_get_author_name($user->data['user_id']) : $info_array['project_start_author']; + + $project_start_author = $db->sql_escape($info_array['project_start_author']); + + $info_array['project_last_update'] = $current_time; + + /** + * @todo $authors, $history, $actions, $old_actions... Also, add some setting for permissions + */ + + // All set to go into the database :-) + $db->sql_transaction('begin'); + + $sql = 'INSERT INTO ' . PROJECT_PROJECTS_TABLE . " (category_id, project_title, project_title_clean, project_description, project_level, project_install_time, project_notes, project_license, project_target_version, project_version, project_stage, project_logo, project_logo_type, project_logo_width, project_logo_height, project_start_time, project_start_id, project_start_author, project_last_update, is_active, file_only, project_downloads) + VALUES ($category_id, '$project_title', '$project_title_clean', '$project_description', {$info_array['project_level']}, {$info_array['project_install_time']}, '$project_notes', $project_license, '$project_target_version', '$project_version', $project_stage, '$project_logo', $project_logo_type, $project_logo_width, $project_logo_height, {$info_array['project_start_time']}, {$info_array['project_start_id']}, '$project_start_author', {$info_array['project_last_update']}, $is_active, $file_only, 0)"; + $db->sql_query($sql); + + $info_array['project_id'] = $project_id = $db->sql_nextid(); + + for ($i = 0, $size = sizeof($authors); $i < $size; $i++) + { + $db->sql_query('INSERT INTO ' . PROJECT_PROJECT_AUTHORS_TABLE . " (project_id, author_id, author_role) + VALUES ($project_id, {$authors[$i]['author_id']}, {$authors[$i]['author_role_id']})"); + } + + if ($history) + { + for ($i = 0, $size = sizeof($history); $i < $size; $i++) + { + $db->sql_query('INSERT INTO ' . PROJECT_VERSIONS_TABLE . " (project_id, previous_id, version_time, version_major, version_minor, version_revision, version_release, version_stage, version_changelog) + VALUES ($project_id, {$history[$i]['previous_id']}, {$history[$i]['version_time']}, {$history[$i]['version_major']}, {$history[$i]['version_minor']}, {$history[$i]['version_revision']}, '{$history[$i]['version_release']}', {$history[$i]['version_stage']}, {$history[$i]['version_changelog']})"); + } + + $version_time = $history[$i]['version_time']; + } + else + { + $db->sql_query('INSERT INTO ' . PROJECT_VERSIONS_TABLE . " (project_id, previous_id, version_time, version_major, version_minor, version_revision, version_release, version_stage, version_changelog) + VALUES ($project_id, 0, $current_time, 0, 0, 0, '', " . PROJECT_STAGE_DEV . ", '')"); + + $version_time = $current_time; + } + + $version_id = $db->sql_nextid(); + + if ($actions) + { + for ($i = 0, $size = sizeof($actions); $i < $size; $i++) + { + /** + * @todo Something tells me this could be much more efficient... + */ + $db->sql_query('INSERT INTO ' . PROJECT_ACTIONS_TABLE . " (project_id) + VALUES ($project_id)"); + + $actions[$i]['action_id'] = $action_id = $db->sql_nextid(); + + $db->sql_query('INSERT INTO ' . PROJECT_ACTION_CONTENTS_TABLE . " (action_id, version_id, version_time, action_order, action_type, action_content) + VALUES ($action_id, $version_id, $version_time, {$actions[$i]['action_order']}, {$actions[$i]['action_type']}, '{$actions[$i]['action_content']}')"); + } + } + + // Update project count for category + $sql = 'UPDATE ' . PROJECT_CATEGORIES_TABLE . " + SET category_projects = category_projects + 1, + last_update_id = $project_id, + last_update_time = {$info_array['project_last_update']} + WHERE category_id = {$info_array['category_id']}"; + $db->sql_query($sql); + + // And roll it + $db->sql_transaction('commit'); + + // Now post it if needed + if ($config['project_autopost_enable']) + { + $topic_id = project_autopost($info_array, $authors, $history); + + if (!$topic_id) + { + return $user->lang['PROJECT_AUTOPOST_FAILURE']; + } + + $sql = 'UPDATE ' . PROJECT_PROJECTS_TABLE . ' + SET topic_id = ' . (int) $topic_id . ' + WHERE project_id = ' . $project_id; + $db->sql_query($sql); + } + + return false; +} + +?> \ No newline at end of file Modified: trunk/develop/create_schema_files_phpbb3.php =================================================================== --- trunk/develop/create_schema_files_phpbb3.php 2008-04-21 23:17:05 UTC (rev 263) +++ trunk/develop/create_schema_files_phpbb3.php 2008-04-23 00:26:14 UTC (rev 264) @@ -880,8 +880,7 @@ 'project_logo_width' => array('USINT', '0'), 'project_logo_height' => array('USINT', '0'), 'project_start_time' => array('UINT:11', '0'), - 'project_start_id' => array('UINT', '0'), - 'project_start_author' => array('STEXT_UNI', ''), + 'project_owner' => array('UINT', '0'), 'project_last_update' => array('UINT:11', '0'), 'is_active' => array('BOOL', '1'), 'file_only' => array('BOOL', '0'), @@ -899,14 +898,6 @@ // // Actions and versions // - $schema_data['phpbb_project_actions'] = array( - 'COLUMNS' => array( - 'action_id' => array('UINT:11', NULL, 'auto_increment'), - 'project_id' => array('UINT', '0'), - ), - 'PRIMARY_KEY' => 'action_id', - ); - $schema_data['phpbb_project_versions'] = array( 'COLUMNS' => array( 'version_id' => array('UINT:11', NULL, 'auto_increment'), @@ -926,9 +917,10 @@ ) ); - $schema_data['phpbb_project_action_contents'] = array( + $schema_data['phpbb_project_actions'] = array( 'COLUMNS' => array( 'action_id' => array('UINT:11', '0'), + 'project_id' => array('UINT', '0'), 'version_id' => array('UINT:11', '0'), 'version_time' => array('UINT:11', '0'), 'action_order' => array('USINT', '0'), @@ -939,6 +931,7 @@ ), 'PRIMARY_KEY' => array('action_id, version_id'), 'KEYS' => array( + 'project_id' => array('INDEX', 'project_id'), 'action_order' => array('INDEX', 'action_order'), 'version_time' => array('INDEX', 'version_time'), ) Modified: trunk/phpbb3/root/includes/project/project_main.php =================================================================== --- trunk/phpbb3/root/includes/project/project_main.php 2008-04-21 23:17:05 UTC (rev 263) +++ trunk/phpbb3/root/includes/project/project_main.php 2008-04-23 00:26:14 UTC (rev 264) @@ -213,7 +213,6 @@ $sort_by_sql = array( 'lu' => 'project_last_update', - 'sa' => 'project_start_author', 'pt' => 'project_title', 'st' => 'project_start_time', 'it' => 'project_install_time', @@ -232,7 +231,7 @@ $acl_projects = array_keys($auth->acl_getf('p_view_project', true)); $project_ids = $db->sql_in_set('project_id', $acl_projects, false, true); - $sql = "SELECT project_id, topic_id, project_title, project_description, project_level, project_install_time, project_target_version, project_version, project_stage, project_start_time, project_start_id, project_start_author, project_last_update, project_downloads + $sql = "SELECT project_id, topic_id, project_title, project_description, project_level, project_install_time, project_target_version, project_version, project_stage, project_start_time, project_owner, project_last_update, project_downloads FROM " . PROJECT_PROJECTS_TABLE . " WHERE $project_ids AND category_id = $category_id @@ -279,7 +278,7 @@ 'DOWNLOADS' => $projects[$i]['project_downloads'], 'START_DATE' => $user->format_date($projects[$i]['project_start_time']), - 'START_AUTHOR' => get_username_string('full', $projects[$i]['project_start_id'], $projects[$i]['project_start_author']), + 'OWNER' => get_username_string('full', $projects[$i]['project_owner'], project_get_author_name($projects[$i]['project_owner'])), 'LAST_UPDATE' => $user->format_date($projects[$i]['project_last_update']), 'S_ROW_COUNT' => $i, Modified: trunk/phpbb3/root/includes/sources_project/constants.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/constants.php 2008-04-21 23:17:05 UTC (rev 263) +++ trunk/phpbb3/root/includes/sources_project/constants.php 2008-04-23 00:26:14 UTC (rev 264) @@ -23,22 +23,27 @@ define('PROJECT_STAGE_RC', 4); define('PROJECT_STAGE_STABLE', 5); +// Status types +define('PROJECT_STATUS_UNAPPROVED', 0); +define('PROJECT_STATUS_APPROVED', 1); +define('PROJECT_STATUS_DISCONTINUED', 2); + // Action types define('PROJECT_ACTION_DELETED', 0); define('PROJECT_ACTION_SQL', 1); define('PROJECT_ACTION_COPY', 2); define('PROJECT_ACTION_DIY', 3); -//define('PROJECT_ACTION_OPEN', 4); // Deprecated ;) -define('PROJECT_ACTION_FIND', 5); -define('PROJECT_ACTION_AFTER_ADD', 6); -define('PROJECT_ACTION_BEFORE_ADD', 7); -define('PROJECT_ACTION_REPLACE_WITH', 8); -define('PROJECT_ACTION_INCREMENT', 9); -define('PROJECT_ACTION_INLINE_FIND', 10); -define('PROJECT_ACTION_INLINE_AFTER_ADD', 11); -define('PROJECT_ACTION_INLINE_BEFORE_ADD', 12); -define('PROJECT_ACTION_INLINE_REPLACE_WITH', 13); -define('PROJECT_ACTION_INLINE_INCREMENT', 14); +define('PROJECT_ACTION_FIND', 4); +define('PROJECT_ACTION_AFTER_ADD', 5); +define('PROJECT_ACTION_BEFORE_ADD', 6); +define('PROJECT_ACTION_REPLACE_WITH', 7); +define('PROJECT_ACTION_INCREMENT', 8); +define('PROJECT_ACTION_INLINE_FIND', 9); +define('PROJECT_ACTION_INLINE_AFTER_ADD', 10); +define('PROJECT_ACTION_INLINE_BEFORE_ADD', 11); +define('PROJECT_ACTION_INLINE_REPLACE_WITH', 12); +define('PROJECT_ACTION_INLINE_INCREMENT', 13); +//define('PROJECT_ACTION_OPEN', 14); // Not used (anymore / yet?) // Search match types define('PROJECT_MATCH_TITLE', 1); @@ -66,7 +71,6 @@ // Tables define('PROJECT_ACTIONS_TABLE', $table_prefix . 'project_actions'); -define('PROJECT_ACTION_CONTENTS_TABLE', $table_prefix . 'project_action_contents'); define('PROJECT_AUTHORS_TABLE', $table_prefix . 'project_authors'); define('PROJECT_CATEGORIES_TABLE', $table_prefix . 'project_categories'); define('PROJECT_DOCUMENTATION_TABLE', $table_prefix . 'project_documentation'); Modified: trunk/phpbb3/root/includes/sources_project/create_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/create_project.php 2008-04-21 23:17:05 UTC (rev 263) +++ trunk/phpbb3/root/includes/sources_project/create_project.php 2008-04-23 00:26:14 UTC (rev 264) @@ -9,478 +9,258 @@ */ /** - * Create a new project + * Create Project base class * - * @param string $mode - * @param array $info_array - * @param array $authors - * @param array|boolean $history - * @param array|boolean $actions - * @param array|boolean $old_actions - * @return boolean|string Either false if succesful of the error message + * @package create_project */ -function project_create($mode, $info_array, $authors, $history = false, $actions = false, $old_actions = false) +class project_create { - global $db, $config, $auth, $user; + public $current_time; + public $error; + protected $data; + protected $authors; - // Check permissions - if (!$auth->acl_get('p_add_project')) + /** + * Create project constructor + * + * @param array $data + * @param array $authors + */ + public function __construct($data, $authors) { - return $user->lang['PROJECT_NOT_AUTH_CREATE']; - } - if (!$auth->acl_get('p_view_category', $info_array['category_id'])) - { - return $user->lang['PROJECT_NOT_AUTH_CAT']; - } + global $auth, $user, $config; - // Time & date of project creation - $current_time = time(); - - // History and action information are only needed for importing - if ($mode != 'import') - { - $history = $actions = $old_actions = false; - } - - // Variable types for database protection - $info_vars = array('category_id' => 'int', 'project_title' => 'string', 'project_description' => 'string', 'project_notes' => 'string', 'project_license' => 'int', 'project_target_version' => 'string', 'project_version' => 'string', 'project_stage' => 'int', 'project_logo' => 'string', 'project_logo_type' => 'int', 'project_logo_width' => 'int', 'project_logo_height' => 'int', 'is_active' => 'int', 'file_only' => 'int'); - - $error_message = ''; - foreach ($info_vars AS $var => $type) - { - if (!isset($info_array[$var])) + // Check permissions + if (!$auth->acl_get('p_add_project')) { - $error_message .= (($error_message) ? '<br />' : '') . sprintf($user->lang['FIELD_REQUIRED'], $var); + $this->error = $user->lang['PROJECT_NOT_AUTH_CREATE']; + return; } + if (!$auth->acl_get('p_view_category', $data['category_id'])) + { + $this->error = $user->lang['PROJECT_NOT_AUTH_CAT']; + return; + } - $$var = ($type == 'string') ? $db->sql_escape($info_array[$var]) : intval($info_array[$var]); + // Time & date of project creation + $this->current_time = time(); + $this->authors = $authors; + + $this->set_data($data); } - if (!empty($error_message)) - { - return $error_message; - } - // Clean title for uniqueness - $info_array['project_title_clean'] = utf8_clean_string($info_array['project_title']); - $project_title_clean = $db->sql_escape($info_array['project_title_clean']); - - $info_array['project_install_time'] = ($actions) ? project_generate_install_time($actions) : 0; - $info_array['project_level'] = ($actions) ? project_generate_level('actions', $actions) : PROJECT_LEVEL_EASY; - - $info_array['project_start_time'] = (empty($info_array['project_start_time'])) ? $current_time : intval($info_array['project_start_time']); - $info_array['project_start_id'] = (empty($info_array['project_start_id'])) ? $user->data['user_id'] : intval($info_array['project_start_id']); - $info_array['project_start_author'] = (empty($info_array['project_start_author'])) ? project_get_author_name($user->data['user_id']) : $info_array['project_start_author']; - - $project_start_author = $db->sql_escape($info_array['project_start_author']); - - $info_array['project_last_update'] = $current_time; - /** - * @todo $authors, $history, $actions, $old_actions... Also, add some setting for permissions + * Set data array + * + * @param array $data */ - - // All set to go into the database :-) - $db->sql_transaction('begin'); - - $sql = 'INSERT INTO ' . PROJECT_PROJECTS_TABLE . " (category_id, project_title, project_title_clean, project_description, project_level, project_install_time, project_notes, project_license, project_target_version, project_version, project_stage, project_logo, project_logo_type, project_logo_width, project_logo_height, project_start_time, project_start_id, project_start_author, project_last_update, is_active, file_only, project_downloads) - VALUES ($category_id, '$project_title', '$project_title_clean', '$project_description', {$info_array['project_level']}, {$info_array['project_install_time']}, '$project_notes', $project_license, '$project_target_version', '$project_version', $project_stage, '$project_logo', $project_logo_type, $project_logo_width, $project_logo_height, {$info_array['project_start_time']}, {$info_array['project_start_id']}, '$project_start_author', {$info_array['project_last_update']}, $is_active, $file_only, 0)"; - $db->sql_query($sql); - - $info_array['project_id'] = $project_id = $db->sql_nextid(); - - for ($i = 0, $size = sizeof($authors); $i < $size; $i++) + protected function set_data($data) { - $db->sql_query('INSERT INTO ' . PROJECT_PROJECT_AUTHORS_TABLE . " (project_id, author_id, author_role) - VALUES ($project_id, {$authors[$i]['author_id']}, {$authors[$i]['author_role_id']})"); + global $config, $user; + + $this->data = array_merge($data, array( + 'project_clean_title' => utf8_clean_string($data['project_title']), + 'project_install_time' => 0, + 'project_level' => PROJECT_LEVEL_EASY, + 'project_stage' => PROJECT_STAGE_DEV, + 'project_version' => '0.0.0', + 'project_start_time' => $this->current_time, + 'project_last_update' => $this->current_time, + 'project_owner' => $user->data['user_id'], + 'project_status' => ($config['project_approve_creation']) ? PROJECT_STATUS_UNAPPROVED : PROJECT_STATUS_APPROVED, + 'project_downloads' => 0, + )); } - if ($history) + /** + * Process project creation + * + * @return integer Project ID + */ + public function process() { - for ($i = 0, $size = sizeof($history); $i < $size; $i++) - { - $db->sql_query('INSERT INTO ' . PROJECT_VERSIONS_TABLE . " (project_id, previous_id, version_time, version_major, version_minor, version_revision, version_release, version_stage, version_changelog) - VALUES ($project_id, {$history[$i]['previous_id']}, {$history[$i]['version_time']}, {$history[$i]['version_major']}, {$history[$i]['version_minor']}, {$history[$i]['version_revision']}, '{$history[$i]['version_release']}', {$history[$i]['version_stage']}, {$history[$i]['version_changelog']})"); - } + global $db, $config; - $version_time = $history[$i]['version_time']; - } - else - { - $db->sql_query('INSERT INTO ' . PROJECT_VERSIONS_TABLE . " (project_id, previous_id, version_time, version_major, version_minor, version_revision, version_release, version_stage, version_changelog) - VALUES ($project_id, 0, $current_time, 0, 0, 0, '', " . PROJECT_STAGE_DEV . ", '')"); + $db->sql_transaction('begin'); - $version_time = $current_time; - } + // Insert main project data + $db->sql_query('INSERT INTO ' . PROJECT_PROJECTS_TABLE . $db->sql_build_array('INSERT', $this->data)); - $version_id = $db->sql_nextid(); + $this->data['project_id'] = $project_id = $db->sql_nextid(); - if ($actions) - { - for ($i = 0, $size = sizeof($actions); $i < $size; $i++) + // Add all authors + for ($i = 0, $size = sizeof($authors); $i < $size; $i++) { - /** - * @todo Something tells me this could be much more efficient... - */ - $db->sql_query('INSERT INTO ' . PROJECT_ACTIONS_TABLE . " (project_id) - VALUES ($project_id)"); - - $actions[$i]['action_id'] = $action_id = $db->sql_nextid(); - - $db->sql_query('INSERT INTO ' . PROJECT_ACTION_CONTENTS_TABLE . " (action_id, version_id, version_time, action_order, action_type, action_content) - VALUES ($action_id, $version_id, $version_time, {$actions[$i]['action_order']}, {$actions[$i]['action_type']}, '{$actions[$i]['action_content']}')"); + $db->sql_query('INSERT INTO ' . PROJECT_PROJECT_AUTHORS_TABLE . $db->sql_build_array('INSERT', array( + 'project_id' => $project_id, + 'author_id' => $authors[$i]['author_id'], + 'author_role' => $authors[$i]['author_role_id'] + ))); } - } - // Update project count for category - $sql = 'UPDATE ' . PROJECT_CATEGORIES_TABLE . " - SET category_projects = category_projects + 1, - last_update_id = $project_id, - last_update_time = {$info_array['project_last_update']} - WHERE category_id = {$info_array['category_id']}"; - $db->sql_query($sql); + // Add the version entry + $db->sql_query('INSERT INTO ' . PROJECT_VERSIONS_TABLE . $db->sql_build_array('INSERT', array( + 'project_id' => $project_id, + 'previous_id' => 0, + 'version_time' => $this->current_time, + 'version_major' => 0, + 'version_minor' => 0, + 'version_revision' => 0, + 'version_release' => '', + 'version_stage' => PROJECT_STAGE_DEV, + 'version_changelog' => '', + ))); - // And roll it - $db->sql_transaction('commit'); + // Update project count for category + $sql = 'UPDATE ' . PROJECT_CATEGORIES_TABLE . " + SET category_projects = category_projects + 1, + last_update_id = $project_id, + last_update_time = $this->current_time + WHERE category_id = {$this->data['category_id']}"; + $db->sql_query($sql); - // Now post it if needed - if ($config['project_autopost_enable']) - { - $topic_id = project_autopost($info_array, $authors, $history); + // And roll it + $db->sql_transaction('commit'); - if (!$topic_id) + // Now post it if needed + if ($config['project_autopost_enable'] && !$config['project_approve_creation']) { - return $user->lang['PROJECT_AUTOPOST_FAILURE']; + project_autopost($this->data, $this->authors); } - $sql = 'UPDATE ' . PROJECT_PROJECTS_TABLE . ' - SET topic_id = ' . (int) $topic_id . ' - WHERE project_id = ' . $project_id; - $db->sql_query($sql); + return $project_id; } - - return false; } /** - * Handle autoposting + * Create project from import * - * @param array $info_array - * @param array $authors - * @param boolean|array $history - * @param boolean|array $update - * @return integer|boolean Either post_id or topic_id, depending on $update, or false on failure + * @package create_project */ -function project_autopost($info_array, $authors, $history = false, $update = false) +class project_create_import extends project_create { - global $db, $config, $user, $auth; - global $phpbb_root_path, $phpEx; + protected $history = array(); + protected $actions = array(); - include_once("{$phpbb_root_path}includes/functions_posting.$phpEx"); - include_once("{$phpbb_root_path}includes/message_parser.$phpEx"); + /** + * Class constructor + * + * @param array $data + * @param array $authors + * @param array $history + * @param array $actions + */ + public function __construct($data, $authors, $history, $actions) + { + $this->history = $history; + $this->actions = $actions; - $forum_root_path = generate_board_url(); + parent::__construct($data, $authors); + } - $stages_ary = array( - PROJECT_STAGE_ALPHA => $user->lang['PROJECT_STAGE_ALPHA'], - PROJECT_STAGE_BETA => $user->lang['PROJECT_STAGE_BETA'], - PROJECT_STAGE_DEV => $user->lang['PROJECT_STAGE_DEV'], - PROJECT_STAGE_RC => $user->lang['PROJECT_STAGE_RC'], - PROJECT_STAGE_STABLE => $user->lang['PROJECT_STAGE_STABLE'], - ); + /** + * Set data array + * + * @param array $data + */ + protected function set_data($data) + { + global $config, $user; - $post_tpl = new template(); - $post_tpl->set_custom_template("{$phpbb_root_path}store/phpbbproject/autopost", 'project_autopost'); + $this->data = array_merge($data, array( + 'project_clean_title' => utf8_clean_string($data['project_title']), + 'project_install_time' => project_generate_install_time($this->actions), + 'project_level' => project_generate_level('actions', $this->actions), + 'project_last_update' => $this->current_time, + 'project_owner' => $user->data['user_id'], + 'project_status' => ($config['project_approve_creation']) ? PROJECT_STATUS_UNAPPROVED : PROJECT_STATUS_APPROVED, + )); + } - if ($update) + /** + * Process project creation + * + * @return integer Project ID + */ + public function process() { - // Reply to topic $info_array['topic_id'] - $topic_id = $info_array['topic_id']; + global $db, $config; - if (!$topic_id) - { - return false; - } + $db->sql_transaction('begin'); - $post_tpl->set_filenames(array( - 'first_post_body' => 'topic_layout.html', - 'first_post_title' => 'topic_title.html', - 'update_post_body' => 'update_post_layout.html', - 'update_post_title' => 'update_post_title.html', - )); + // Insert main project data + $db->sql_query('INSERT INTO ' . PROJECT_PROJECTS_TABLE . $db->sql_build_array('INSERT', $this->data)); - if ($history) - { - for ($i = 0, $size = sizeof($history); $i < $size; $i++) - { - $post_tpl->assign_block_vars('history', array( - 'DATE' => date('Y-m-d', $history[$i]['version_time']), - 'VERSION' => "{$history[$i]['version_major']}.{$history[$i]['version_minor']}.{$history[$i]['version_revision']}{$history[$i]['version_release']}", - 'CHANGELOG' => $history[$i]['version_changelog'], + $this->data['project_id'] = $project_id = $db->sql_nextid(); - 'U_UPDATE_POST' => ($history[$i]['version_post_id']) ? "{$forum_root_path}viewtopic.$phpEx?t=$topic_id&p={$history[$i]['version_post_id']}#{$history[$i]['version_post_id']}" : '', - 'U_DIFF' => ($history[$i]['version_id'] && $history[$i]['previous_version_id']) ? "{$forum_root_path}project.$phpEx?i=project&mode=diff&pr={$info_array['project_id']}&dm=normal&nv={$history[$i]['version_id']}&ov={$history[$i]['previous_version_id']}" : '', - )); - } - } - + // Add all authors for ($i = 0, $size = sizeof($authors); $i < $size; $i++) { - $post_tpl->assign_block_vars('author', array( - 'USERNAME' => $authors[$i]['author_username'], - 'REAL_NAME' => $authors[$i]['author_realname'], - 'EMAIL' => $authors[$i]['author_email'], - 'WEBSITE' => $authors[$i]['author_website'], - 'ROLE' => $authors[$i]['author_role_title'], - - 'S_STARTER' => ($authors[$i]['author_id'] == $info_array['project_start_id']) ? true : false, - - 'U_AUTHOR' => "{$forum_root_path}project.$phpEx?i=author&mode=view&u={$authors[$i]['author_id']}", - )); + $db->sql_query('INSERT INTO ' . PROJECT_PROJECT_AUTHORS_TABLE . $db->sql_build_array('INSERT', array( + 'project_id' => $project_id, + 'author_id' => $authors[$i]['author_id'], + 'author_role' => $authors[$i]['author_role_id'] + ))); } - $post_tpl->assign_vars(array( - 'PROJECT_TITLE' => $info_array['project_title'], - 'PROJECT_TITLE_CLEAN' => $info_array['project_title_clean'], - 'PROJECT_DESCRIPTION' => $info_array['project_description'], - 'AUTHOR_NOTES' => $info_array['project_notes'], + $version_id = $action_id = array(); - 'DATE' => $info_array['project_last_update'], - 'VERSION' => $info_array['project_version'], - 'TARGET_VERSION' => $info_array['project_target_version'], + // Insert version history + for ($i = 0, $size = sizeof($this->history); $i < $size; $i++) + { + $old_version = $this->history[$i]['version_id']; + unset($this->history[$i]['version_id']); - 'DEV_STAGE_ID' => $info_array['project_stage'], - 'DEV_STAGE_UC' => strtoupper($stages_ary[$info_array['project_stage']]), - 'DEV_STAGE_LC' => strtolower($stages_ary[$info_array['project_stage']]), - 'DEV_STAGE_NC' => $stages_ary[$info_array['project_stage']], + $db->sql_query('INSERT INTO ' . PROJECT_VERSIONS_TABLE . + $db->sql_build_array('INSERT', array_merge($this->history[$i], array( + 'project_id' => $project_id + ))) + ); - 'U_DOWNLOAD' => "{$forum_root_path}project.$phpEx?i=project&mode=download&pr={$info_array['project_id']}", - 'U_PROJECT_INFO' => "{$forum_root_path}project.$phpEx?i=project&mode=view&pr={$info_array['project_id']}", + $version_id[$old_version] = $db->sql_nextid(); + } - // Update post extra vars - 'CHANGELOG' => $update['changelog'], + // Get highest action_id for increment + $sql = 'SELECT MAX(action_id) AS max_action_id + FROM ' . PROJECT_ACTIONS_TABLE; + $result = $db->sql_query($sql); + $max_action_id = $db->sql_fetchfield('max_action_id', false, $result); + $db->sql_freeresult($result); - 'U_DIFF' => "{$forum_root_path}project.$phpEx?i=project&mode=diff&pr={$info_array['project_id']}&dm=normal&nv={$update['version_id']}&ov={$update['previous_version_id']}", - 'U_TOPIC' => "{$forum_root_path}viewtopic.$phpEx?t=$topic_id", - - 'OLD_TARGET_VERSION' => $update['previous_target_version'], - 'OLD_VERSION' => $update['previous_version'], - 'OLD_DEV_STAGE_ID' => $update['previous_dev_stage'], - )); - - ob_start(); - $post_tpl->display('first_post_body'); - $first_post_contents = ob_get_contents(); - ob_clean(); - $post_tpl->display('first_post_title'); - $first_post_title = ob_get_contents(); - ob_clean(); - $post_tpl->display('update_post_body'); - $update_post_contents = ob_get_contents(); - ob_clean(); - $post_tpl->display('update_post_title'); - $update_post_title = ob_get_clean(); - } - else - { - $post_tpl->set_filenames(array( - 'post_body' => 'topic_layout.html', - 'post_title' => 'topic_title.html', - )); - - if ($history) + // Insert actions + for ($i = 0, $size = sizeof($this->actions); $i < $size; $i++) { - for ($i = 0, $size = sizeof($history); $i < $size; $i++) + $old_action = $this->actions[$i]['action_id']; + if (!isset($action_id[$old_action])) { - $post_tpl->assign_block_vars('history', array( - 'DATE' => date('Y-m-d', $history[$i]['version_time']), - 'VERSION' => "{$history[$i]['version_major']}.{$history[$i]['version_minor']}.{$history[$i]['version_revision']}{$history[$i]['version_release']}", - 'CHANGELOG' => $history[$i]['version_changelog'], - - 'U_UPDATE_POST' => '', - 'U_DIFF' => '', - )); + $max_action_id++; + $action_id[$old_action] = $max_action_id; } - } + $this->actions[$i]['action_id'] = $action_id[$old_action]; + $this->actions[$i]['project_id'] = $project_id; - for ($i = 0, $size = sizeof($authors); $i < $size; $i++) - { - $post_tpl->assign_block_vars('author', array( - 'USERNAME' => $authors[$i]['author_username'], - 'REAL_NAME' => $authors[$i]['author_realname'], - 'EMAIL' => $authors[$i]['author_email'], - 'WEBSITE' => $authors[$i]['author_website'], - 'ROLE' => $authors[$i]['author_role_title'], - - 'S_STARTER' => ($authors[$i]['author_id'] == $info_array['project_start_id']) ? true : false, - 'U_AUTHOR' => "{$forum_root_path}project.$phpEx?i=author&mode=view&u={$authors[$i]['author_id']}", - )); + $db->sql_query('INSERT INTO ' . PROJECT_ACTIONS_TABLE . $db->sql_build_array('INSERT', $this->actions[$i])); } - $post_tpl->assign_vars(array( - 'PROJECT_TITLE' => $info_array['project_title'], - 'PROJECT_TITLE_CLEAN' => $info_array['project_title_clean'], - 'PROJECT_DESCRIPTION' => $info_array['project_description'], - 'AUTHOR_NOTES' => $info_array['project_notes'], - - 'DATE' => $info_array['project_last_update'], - 'VERSION' => $info_array['project_version'], - 'TARGET_VERSION' => $info_array['project_target_version'], - - 'DEV_STAGE_ID' => $info_array['project_stage'], - 'DEV_STAGE_UC' => strtoupper($stages_ary[$info_array['project_stage']]), - 'DEV_STAGE_LC' => strtolower($stages_ary[$info_array['project_stage']]), - 'DEV_STAGE_NC' => $stages_ary[$info_array['project_stage']], - - 'U_DOWNLOAD' => "{$forum_root_path}project.$phpEx?i=project&mode=download&pr={$info_array['project_id']}", - 'U_PROJECT_INFO' => "{$forum_root_path}project.$phpEx?i=project&mode=view&pr={$info_array['project_id']}", - )); - - ob_start(); - $post_tpl->display('post_body'); - $first_post_contents = ob_get_contents(); - ob_clean(); - $post_tpl->display('post_title'); - $first_post_title = ob_get_clean(); - } - - // Get forum ID - if ($config['project_autopost_forum_per_category']) - { - $sql = 'SELECT c.forum_id, f.forum_name - FROM ' . PROJECT_CATEGORIES_TABLE . ' c, ' . FORUMS_TABLE . ' f - WHERE c.category_id = ' . (int) $info_array['category_id'] . ' - AND f.forum_id = c.forum_id'; - - $db->sql_query($sql, 604800); - $forum_data = $db->sql_fetchrow(); - $db->sql_freeresult(); - } - else - { - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . (int) $config['project_autopost_forum_id']; - - $db->sql_query($sql, 604800); - $forum_data = $db->sql_fetchrow(); - $db->sql_freeresult(); - } - - $forum_id = $forum_data['forum_id']; - $forum_name = $forum_data['forum_name']; - - // submit_post() needs $user to be the info of the posting user, this is not the case here, so make a workaround - $this_user = $user; - - $user->data['is_registered'] = false; - $user->data['user_id'] = $config['project_autopost_user_id']; - - $sql = 'SELECT username, user_colour - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . (int) $user->data['user_id']; - - $db->sql_query($sql, 604800); - $userdata = $db->sql_fetchrow(); - $db->sql_freeresult(); - - $user->data['username'] = $userdata['username']; - $user->data['user_colour'] = $userdata['user_colour']; - $user->data['user_permissions'] = ''; - $user->ip = '127.0.0.1'; - $auth->acl($user->data); - - $message_parser = new parse_message($first_post_contents); - - if ($update) - { - $update_message_parser = new parse_message($update_post_contents); - $update_message_parser->parse(1, 1, 1); - - $sql = 'SELECT t.topic_replies_real, p.post_id, p.bbcode_uid, p.post_time - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - WHERE t.topic_id = $topic_id - AND p.post_id = t.topic_first_post_id"; - + // Update project count for category + $sql = 'UPDATE ' . PROJECT_CATEGORIES_TABLE . " + SET category_projects = category_projects + 1, + last_update_id = $project_id, + last_update_time = $this->current_time + WHERE category_id = {$this->data['category_id']}"; $db->sql_query($sql); - $post_data = $db->sql_fetchrow(); - $db->sql_freeresult(); - $message_parser->bbcode_uid = $post_data['bbcode_uid']; - } + // And roll it + $db->sql_transaction('commit'); - $message_parser->parse(1, 1, 1); + // Now post it if needed + if ($config['project_autopost_enable'] && !$config['project_approve_creation']) + { + project_autopost($this->data, $this->authors, $this->history); + } - - // Build data array - $data = array( - 'topic_title' => $first_post_title, - 'post_subject' => $first_post_title, - 'forum_id' => $forum_id, - 'forum_name' => $forum_name, - 'icon_id' => 0, - - 'enable_bbcode' => 1, - 'enable_smilies' => 1, - 'enable_urls' => 1, - 'enable_sig' => 0, - 'enable_indexing' => 1, - - 'message' => $message_parser->message, - 'message_md5' => md5($message_parser->message), - - 'bbcode_bitfield' => $message_parser->bbcode_bitfield, - 'bbcode_uid' => $message_parser->bbcode_uid, - - 'attachment_data' => array(), - - 'post_edit_locked' => false, - 'post_time' => (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : time(), - - ); - - $poll = array(); - - if ($update) - { - $data = array_merge($data, array('topic_id' => $topic_id, 'topic_first_post_id' => $post_data['post_id'], 'post_id' => $post_data['post_id'], 'topic_replies_real' => $post_data['topic_replies_real'], 'poster_id' => $user->data['user_id'], 'topic_approved' => true, 'post_approved' => true)); - submit_post('edit', $first_post_title, '', POST_NORMAL, $poll, $data); - - $update_data = array( - 'topic_id' => $topic_id, - 'post_subject' => $update_post_title, - 'forum_id' => $forum_id, - 'forum_name' => $forum_name, - 'icon_id' => 0, - - 'enable_bbcode' => 1, - 'enable_smilies' => 1, - 'enable_urls' => 1, - 'enable_sig' => 0, - 'enable_indexing' => 1, - - 'message' => $update_message_parser->message, - 'message_md5' => md5($update_message_parser->message), - - 'bbcode_bitfield' => $update_message_parser->bbcode_bitfield, - 'bbcode_uid' => $update_message_parser->bbcode_uid, - - 'attachment_data' => array(), - - 'post_edit_locked' => false, - 'post_time' => time(), - ); - - submit_post('reply', $update_post_title, '', POST_NORMAL, $poll, $update_data); + return $project_id; } - else - { - submit_post('post', $first_post_title, '', POST_NORMAL, $poll, $data); - } - - $user = $this_user; - $auth->acl($user->data); - - return ($update) ? $update_data['post_id'] : $data['topic_id']; } ?> \ No newline at end of file Modified: trunk/phpbb3/root/includes/sources_project/download_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/download_project.php 2008-04-21 23:17:05 UTC (rev 263) +++ trunk/phpbb3/root/includes/sources_project/download_project.php 2008-04-23 00:26:14 UTC (rev 264) @@ -20,11 +20,11 @@ public $project_id; public $version_id; public $archive_type = 'zip'; - private $version_time; - private $download_type = PROJECT_DOWNLOAD_NORMAL; - private $version_newest = false; - private $version_oldest = false; - private $package; + protected $version_time; + protected $download_type = PROJECT_DOWNLOAD_NORMAL; + protected $version_newest = false; + protected $version_oldest = false; + protected $package; // parser properties public $open_files = array(); @@ -138,7 +138,7 @@ /** * Get information */ - private function get_info() + protected function get_info() { global $db; @@ -167,7 +167,7 @@ * * @todo Order by role + other sorting methods... */ - private function get_authors() + protected function get_authors() { global $db; @@ -204,7 +204,7 @@ /** * Get history information */ - private function get_history() + protected function get_history() { global $db; @@ -240,7 +240,7 @@ /** * Get actions from database */ - private function get_actions() + protected function get_actions() { global $db; @@ -257,6 +257,9 @@ PROJECT_ACTION_REPLACE_WITH => 'replace with', ); + /** + * @todo Change these queries to work on new SQL schema + */ $sql = 'SELECT action_id FROM ' . PROJECT_ACTIONS_TABLE . " WHERE project_id = $this->project_id @@ -348,7 +351,7 @@ * * @todo see if there is a way to get it out of the while loop... */ - private function generate_files($dirname = false, $relative_dir = 'root') + protected function generate_files($dirname = false, $relative_dir = 'root') { global $phpbb_root_path; if ($dirname === false) Added: trunk/phpbb3/root/includes/sources_project/import_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/import_project.php (rev 0) +++ trunk/phpbb3/root/includes/sources_project/import_project.php 2008-04-23 00:26:14 UTC (rev 264) @@ -0,0 +1,25 @@ +<?php +/** + * phpBB Project + * + * @package phpbbproject + * @version $Id$ + * @copyright (c) 2008 phpBB Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + +/** + * Import Project from SVN Repository + * + * This class will import a project from a Subversion repository. + * It should be able to reconstruct previous versions if there are tags defined in the repository. + * By default it will look for the /trunk and assume it is set up as if it were a mod. + * + * @package create_project + */ +class project_import_svn +{ + +} + +?> \ No newline at end of file Property changes on: trunk/phpbb3/root/includes/sources_project/import_project.php ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Modified: trunk/phpbb3/root/styles/prosilver/template/project_viewcat.html =================================================================== --- trunk/phpbb3/root/styles/prosilver/template/project_viewcat.html 2008-04-21 23:17:05 UTC (rev 263) +++ trunk/phpbb3/root/styles/prosilver/template/project_viewcat.html 2008-04-23 00:26:14 UTC (rev 264) @@ -33,7 +33,7 @@ <!-- IF project_row.U_VIEW_TOPIC --><br /><a href="{project_row.U_VIEW_TOPIC}">{L_VIEW_TOPIC}</a><!-- ENDIF --> </dt> <dd class="posts">{project_row.DOWNLOADS}</dd> - <dd style="width: 17%; font-size: 1.1em;"><span style="display: block; padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->: 5px;">{L_POST_BY_AUTHOR} {project_row.START_AUTHOR} {L_POSTED_ON_DATE} {project_row.START_DATE}</span></dd> + <dd style="width: 17%; font-size: 1.1em;"><span style="display: block; padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->: 5px;">{L_POST_BY_AUTHOR} {project_row.OWNER} {L_POSTED_ON_DATE} {project_row.START_DATE}</span></dd> <dd style="width: 17%; font-size: 1.1em; height: 28px;"><span style="display: block; padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->: 5px;">{project_row.LAST_UPDATE}</span></dd> </dl> </li> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2008-04-23 19:51:20
|
Revision: 265 http://phpbbproject.svn.sourceforge.net/phpbbproject/?rev=265&view=rev Author: lord_le_brand Date: 2008-04-23 12:51:18 -0700 (Wed, 23 Apr 2008) Log Message: ----------- Merged project_actions and project_action_contents Wrote project_import_modx class Modified Paths: -------------- trunk/develop/create_schema_files_phpbb3.php trunk/phpbb3/root/includes/sources_project/download_project.php trunk/phpbb3/root/includes/sources_project/import_project.php trunk/phpbb3/root/project_install/schemas/mysql_41_schema.sql Added Paths: ----------- trunk/phpbb3/root/store/phpbbproject/import/ Modified: trunk/develop/create_schema_files_phpbb3.php =================================================================== --- trunk/develop/create_schema_files_phpbb3.php 2008-04-23 00:26:14 UTC (rev 264) +++ trunk/develop/create_schema_files_phpbb3.php 2008-04-23 19:51:18 UTC (rev 265) @@ -875,6 +875,7 @@ 'project_target_version' => array('VCHAR:10', ''), 'project_version' => array('VCHAR:15', ''), 'project_stage' => array('TINT:2', '0'), + 'project_target' => array('XSTEXT_UNI', ''), 'project_logo' => array('VCHAR', ''), 'project_logo_type' => array('TINT:2', '0'), 'project_logo_width' => array('USINT', '0'), @@ -882,7 +883,7 @@ 'project_start_time' => array('UINT:11', '0'), 'project_owner' => array('UINT', '0'), 'project_last_update' => array('UINT:11', '0'), - 'is_active' => array('BOOL', '1'), + 'project_status' => array('BOOL', '0'), 'file_only' => array('BOOL', '0'), 'project_downloads' => array('UINT:11', '0'), ), Modified: trunk/phpbb3/root/includes/sources_project/download_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/download_project.php 2008-04-23 00:26:14 UTC (rev 264) +++ trunk/phpbb3/root/includes/sources_project/download_project.php 2008-04-23 19:51:18 UTC (rev 265) @@ -14,6 +14,7 @@ * Handles packaging * * @package phpbbproject + * @todo Make downlaod class work woth /templates and /languages */ class download_project { @@ -44,7 +45,13 @@ public $actions_sql = array(); public $actions_diy = array(); - + /** + * Constructor + * + * @param integer $project_id + * @param string $archive_type + * @param integer $download_type + */ function __construct($project_id, $archive_type = 'zip', $download_type = PROJECT_DOWNLOAD_NORMAL) { global $db; @@ -257,32 +264,19 @@ PROJECT_ACTION_REPLACE_WITH => 'replace with', ); - /** - * @todo Change these queries to work on new SQL schema - */ - $sql = 'SELECT action_id - FROM ' . PROJECT_ACTIONS_TABLE . " - WHERE project_id = $this->project_id - AND action_type <> " . PROJECT_ACTION_DELETED; - $db->sql_query($sql, 604800); - $action_ids = array(); - while ($row = $db->sql_fetchrow()) - { - $action_ids[] = $row['action_id']; - } - $db->sql_freeresult(); - - $sql = 'SELECT ac.* - FROM ' . PROJECT_ACTION_CONTENTS_TABLE . ' ac - WHERE ' . $db->sql_in_set('ac.action_id', $action_ids) . ' - AND ac.version_time = + // Get the newest versions of the actions up to $this->version_time + $sql = 'SELECT a.* + FROM ' . PROJECT_ACTIONS_TABLE . " a + WHERE a.project_id = $this->project_id + AND a.action_type <> " . PROJECT_ACTION_DELETED . ' + AND a.version_time = ( - SELECT MAX(ac2.version_time) - FROM ' . PROJECT_ACTION_CONTENTS_TABLE . " ac2 - WHERE ac2.version_time <= $this->version_time - AND ac2.action_id = ac.action_id + SELECT MAX(a2.version_time) + FROM ' . PROJECT_ACTIONS_TABLE . " a2 + WHERE a2.version_time <= $this->version_time + AND a2.action_id = a.action_id ) - ORDER BY action_order ASC"; + ORDER BY action_order"; $db->sql_query($sql, 604800); $open_file = ''; Modified: trunk/phpbb3/root/includes/sources_project/import_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/import_project.php 2008-04-23 00:26:14 UTC (rev 264) +++ trunk/phpbb3/root/includes/sources_project/import_project.php 2008-04-23 19:51:18 UTC (rev 265) @@ -9,6 +9,340 @@ */ /** + * Base import class + * + * @package create_project + */ +abstract class project_import_base +{ + protected $install_file, $install_filetype; + public $data = array(); + public $authors = array(); + public $history = array(); + public $actions = array(); + public $files; + protected $parser; + + public function process() + { + global $phpbb_root_path, $phpEx; + + if (!class_exists('parser_base')) + { + include("{$phpbb_root_path}includes/sources_project/mod/parser.$phpEx"); + } + + switch ($this->install_filetype) + { + case 'mod': + $this->parser = new parser_mod($this->install_file); + break; + + case 'modx': + $this->parser = new parser_modx($this->install_file); + break; + } + + $this->parser->parse(); + + $this->data = array_merge($this->data, array( + 'project_title' => $this->parser->mod_title, + 'project_description' => $this->parser->mod_description, + 'project_notes' => $this->parser->author_notes, + 'project_target_version' => serialize($this->parser->target_version_p), + 'project_version' => $this->parser->mod_version, + 'file_only' => 0, + )); + + $this->process_actions(); + $this->process_authors(); + $this->process_history(); + } + + /** + * Get the actions into place + */ + protected function process_actions() + { + $order = 0; + + for ($i = 0, $size = sizeof($this->parser->actions_copy); $i < $size; $i++) + { + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => '', + 'action_type' => PROJECT_ACTION_COPY, + 'action_content' => 'copy ' . $this->parser->actions_copy[$i][0] . ' to ' . $this->parser->actions_copy[$i][1], + 'action_comment' => '' + ); + + $order++; + } + + for ($i = 0, $size = sizeof($this->parser->actions_sql); $i < $size; $i++) + { + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => '', + 'action_type' => PROJECT_ACTION_SQL, + 'action_content' => $this->parser->actions_sql[$i], + 'action_comment' => '' + ); + + $order++; + } + + for ($i = 0, $size = sizeof($this->parser->actions); $i < $size; $i++) + { + switch ($this->parser->actions[$i]['type']) + { + case 'open': + $file_open = $this->parser->actions[$i]['data']; + break; + + case 'find': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_FIND, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => $this->parser->actions[$i]['comment'] + ); + + $order++; + break; + + case 'after, add': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_AFTER_ADD, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'before, add': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_BEFORE_ADD, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'replace with': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_REPLACE_WITH, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'increment': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_INCREMENT, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'in-line find': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_INLINE_FIND, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => $this->parser->actions[$i]['comment'] + ); + + $order++; + break; + + case 'in-line after, add': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_INLINE_AFTER_ADD, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'in-line before, add': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_INLINE_BEFORE_ADD, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'in-line replace with': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_INLINE_REPLACE_WITH, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'in-line increment': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_INLINE_INCREMENT, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + } + } + + for ($i = 0, $size = sizeof($this->parser->actions_diy); $i < $size; $i++) + { + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => '', + 'action_type' => PROJECT_ACTION_DIY, + 'action_content' => $this->parser->actions_diy[$i], + 'action_comment' => '' + ); + + $order++; + } + } + + /** + * Get the version history + */ + protected function process_history() + { + $stages = array( + 'alpha' => PROJECT_STAGE_ALPHA, + 'beta' => PROJECT_STAGE_BETA, + 'release-candidate' => PROJECT_STAGE_RC, + 'gamma' => PROJECT_STAGE_RC, + 'delta' => PROJECT_STAGE_RC, + 'stable' => PROJECT_STAGE_STABLE, + '' => PROJECT_STAGE_DEV, + ); + + for ($i = 0, $size = sizeof($this->parser->mod_history); $i < $size; $i++) + { + $this->history[] = array( + 'version_time' => $this->parser->mod_history[$i]['time'], + 'version_major' => $this->parser->mod_history[$i]['version_p'][0], + 'version_minor' => $this->parser->mod_history[$i]['version_p'][1], + 'version_revision' => $this->parser->mod_history[$i]['version_p'][2], + 'version_release' => $this->parser->mod_history[$i]['version_p'][3], + 'version_stage' => $stages[$this->parser->mod_history[$i]['stage']], + 'version_changelog' => implode("\n", $this->parser->mod_history[$i]['changelog']), + ); + } + } + + /** + * Get author information + */ + protected function process_authors() + { + for ($i = 0, $size = sizeof($this->parser->mod_authors); $i < $size; $i++) + { + $this->authors[] = array( + 'author_username' => $this->parser->mod_authors[$i]['username'], + 'author_realname' => $this->parser->mod_authors[$i]['realname'], + 'author_email' => $this->parser->mod_authors[$i]['email'], + 'author_website' => $this->parser->mod_authors[$i]['website'], + ); + } + } +} + +/** + * Import Project from MODX package. + * + * This class will import a project from a MODX package. + * It will assume that it is packaged according to the packaging standards. + * + * @package create_project + */ +class project_import_modx extends project_import_base +{ + /** + * Constructor + * + * @param string $input + * @todo make it work with /languages and /templates folders + */ + public function __construct($input) + { + global $phpbb_root_path, $phpEx; + + $this->install_filetype = 'modx'; + $filename = substr(basename($input), 0, strpos(basename($input), '.')); + + if (!class_exists('compress_zip')) + { + include("{$phpbb_root_path}includes/functions_compress.$phpEx"); + } + + $compress = new compress_zip('r', $input); + $compress->extract("{$phpbb_root_path}store/phpbbproject/import/$filename/"); + + $directory = "{$phpbb_root_path}store/phpbbproject/import/$filename"; + + if (is_dir("$directory/$filename")) + { + $directory .= "/$filename"; + } + + $file_content = ''; + + $dir = dir($directory); + while (false !== ($file = $dir->read())) + { + if (preg_match('#(.+)\.xml$#i', $file, $matches)) + { + $file_content = file_get_contents("$directory/{$matches[0]}"); + } + } + + if (empty($file_content)) + { + $this->error = 'PROJECT_IMPORT_FAILED'; + return; + } + + $this->install_file = $file_content; + + } +} + +/** * Import Project from SVN Repository * * This class will import a project from a Subversion repository. @@ -17,9 +351,21 @@ * * @package create_project */ -class project_import_svn +class project_import_svn extends project_import_base { + protected $repository, $path, $revision; + /** + * Constructor + * + * @param string $repository + * @param string|boolean $path + * @param integer|boolean $revision + */ + public function __construct($repository, $path = false, $revision = false) + { + // UNIX/Windows? + } } ?> \ No newline at end of file Modified: trunk/phpbb3/root/project_install/schemas/mysql_41_schema.sql =================================================================== --- trunk/phpbb3/root/project_install/schemas/mysql_41_schema.sql 2008-04-23 00:26:14 UTC (rev 264) +++ trunk/phpbb3/root/project_install/schemas/mysql_41_schema.sql 2008-04-23 19:51:18 UTC (rev 265) @@ -63,10 +63,9 @@ project_logo_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, project_logo_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, project_start_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - project_start_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - project_start_author varchar(255) DEFAULT '' NOT NULL, + project_owner mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, project_last_update int(11) UNSIGNED DEFAULT '0' NOT NULL, - is_active tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + project_status tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, file_only tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, project_downloads int(11) UNSIGNED DEFAULT '0' NOT NULL, PRIMARY KEY (project_id), @@ -75,14 +74,6 @@ ) CHARACTER SET `utf8` COLLATE `utf8_bin`; -# Table: 'phpbb_project_actions' -CREATE TABLE phpbb_project_actions ( - action_id int(11) UNSIGNED NOT NULL auto_increment, - project_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (action_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - # Table: 'phpbb_project_versions' CREATE TABLE phpbb_project_versions ( version_id int(11) UNSIGNED NOT NULL auto_increment, @@ -92,17 +83,18 @@ version_major tinyint(3) DEFAULT '0' NOT NULL, version_minor tinyint(3) DEFAULT '0' NOT NULL, version_revision tinyint(3) DEFAULT '0' NOT NULL, - version_release varchar(1) DEFAULT '' NOT NULL, version_stage tinyint(2) DEFAULT '0' NOT NULL, + version_release varchar(1) DEFAULT '' NOT NULL, version_changelog mediumtext NOT NULL, PRIMARY KEY (version_id), KEY project_id (project_id) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; -# Table: 'phpbb_project_action_contents' -CREATE TABLE phpbb_project_action_contents ( +# Table: 'phpbb_project_actions' +CREATE TABLE phpbb_project_actions ( action_id int(11) UNSIGNED DEFAULT '0' NOT NULL, + project_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, version_id int(11) UNSIGNED DEFAULT '0' NOT NULL, version_time int(11) UNSIGNED DEFAULT '0' NOT NULL, action_order smallint(4) UNSIGNED DEFAULT '0' NOT NULL, @@ -111,6 +103,7 @@ action_content mediumtext NOT NULL, action_comment text NOT NULL, PRIMARY KEY (action_id, version_id), + KEY project_id (project_id), KEY action_order (action_order), KEY version_time (version_time) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2008-04-23 22:53:52
|
Revision: 267 http://phpbbproject.svn.sourceforge.net/phpbbproject/?rev=267&view=rev Author: lord_le_brand Date: 2008-04-23 15:53:55 -0700 (Wed, 23 Apr 2008) Log Message: ----------- Deleted temporary files More work on create project module, finish in sight Modified Paths: -------------- trunk/phpbb3/root/includes/project/project_main.php trunk/phpbb3/root/includes/sources_project/create_project.php trunk/phpbb3/root/includes/sources_project/functions_create.php trunk/phpbb3/root/styles/prosilver/template/project_create.html Removed Paths: ------------- trunk/develop/autopost.temp.php trunk/develop/create_project.temp.php Deleted: trunk/develop/autopost.temp.php =================================================================== --- trunk/develop/autopost.temp.php 2008-04-23 20:21:14 UTC (rev 266) +++ trunk/develop/autopost.temp.php 2008-04-23 22:53:55 UTC (rev 267) @@ -1,331 +0,0 @@ -<? -/** - * Handle autoposting - * - * @param array $info_array - * @param array $authors - * @param boolean|array $history - * @param boolean|array $update - * @return integer|boolean Either post_id or topic_id, depending on $update, or false on failure - */ -function project_autopost($info_array, $authors, $history = false, $update = false) -{ - global $db, $config, $user, $auth; - global $phpbb_root_path, $phpEx; - - include_once("{$phpbb_root_path}includes/functions_posting.$phpEx"); - include_once("{$phpbb_root_path}includes/message_parser.$phpEx"); - - $forum_root_path = generate_board_url(); - - $stages_ary = array( - PROJECT_STAGE_ALPHA => $user->lang['PROJECT_STAGE_ALPHA'], - PROJECT_STAGE_BETA => $user->lang['PROJECT_STAGE_BETA'], - PROJECT_STAGE_DEV => $user->lang['PROJECT_STAGE_DEV'], - PROJECT_STAGE_RC => $user->lang['PROJECT_STAGE_RC'], - PROJECT_STAGE_STABLE => $user->lang['PROJECT_STAGE_STABLE'], - ); - - $post_tpl = new template(); - $post_tpl->set_custom_template("{$phpbb_root_path}store/phpbbproject/autopost", 'project_autopost'); - - if ($update) - { - // Reply to topic $info_array['topic_id'] - $topic_id = $info_array['topic_id']; - - if (!$topic_id) - { - return false; - } - - $post_tpl->set_filenames(array( - 'first_post_body' => 'topic_layout.html', - 'first_post_title' => 'topic_title.html', - 'update_post_body' => 'update_post_layout.html', - 'update_post_title' => 'update_post_title.html', - )); - - if ($history) - { - for ($i = 0, $size = sizeof($history); $i < $size; $i++) - { - $post_tpl->assign_block_vars('history', array( - 'DATE' => date('Y-m-d', $history[$i]['version_time']), - 'VERSION' => "{$history[$i]['version_major']}.{$history[$i]['version_minor']}.{$history[$i]['version_revision']}{$history[$i]['version_release']}", - 'CHANGELOG' => $history[$i]['version_changelog'], - - 'U_UPDATE_POST' => ($history[$i]['version_post_id']) ? "{$forum_root_path}viewtopic.$phpEx?t=$topic_id&p={$history[$i]['version_post_id']}#{$history[$i]['version_post_id']}" : '', - 'U_DIFF' => ($history[$i]['version_id'] && $history[$i]['previous_version_id']) ? "{$forum_root_path}project.$phpEx?i=project&mode=diff&pr={$info_array['project_id']}&dm=normal&nv={$history[$i]['version_id']}&ov={$history[$i]['previous_version_id']}" : '', - )); - } - } - - for ($i = 0, $size = sizeof($authors); $i < $size; $i++) - { - $post_tpl->assign_block_vars('author', array( - 'USERNAME' => $authors[$i]['author_username'], - 'REAL_NAME' => $authors[$i]['author_realname'], - 'EMAIL' => $authors[$i]['author_email'], - 'WEBSITE' => $authors[$i]['author_website'], - 'ROLE' => $authors[$i]['author_role_title'], - - 'S_STARTER' => ($authors[$i]['author_id'] == $info_array['project_start_id']) ? true : false, - - 'U_AUTHOR' => "{$forum_root_path}project.$phpEx?i=author&mode=view&u={$authors[$i]['author_id']}", - )); - } - - $post_tpl->assign_vars(array( - 'PROJECT_TITLE' => $info_array['project_title'], - 'PROJECT_TITLE_CLEAN' => $info_array['project_title_clean'], - 'PROJECT_DESCRIPTION' => $info_array['project_description'], - 'AUTHOR_NOTES' => $info_array['project_notes'], - - 'DATE' => $info_array['project_last_update'], - 'VERSION' => $info_array['project_version'], - 'TARGET_VERSION' => $info_array['project_target_version'], - - 'DEV_STAGE_ID' => $info_array['project_stage'], - 'DEV_STAGE_UC' => strtoupper($stages_ary[$info_array['project_stage']]), - 'DEV_STAGE_LC' => strtolower($stages_ary[$info_array['project_stage']]), - 'DEV_STAGE_NC' => $stages_ary[$info_array['project_stage']], - - 'U_DOWNLOAD' => "{$forum_root_path}project.$phpEx?i=project&mode=download&pr={$info_array['project_id']}", - 'U_PROJECT_INFO' => "{$forum_root_path}project.$phpEx?i=project&mode=view&pr={$info_array['project_id']}", - - // Update post extra vars - 'CHANGELOG' => $update['changelog'], - - 'U_DIFF' => "{$forum_root_path}project.$phpEx?i=project&mode=diff&pr={$info_array['project_id']}&dm=normal&nv={$update['version_id']}&ov={$update['previous_version_id']}", - 'U_TOPIC' => "{$forum_root_path}viewtopic.$phpEx?t=$topic_id", - - 'OLD_TARGET_VERSION' => $update['previous_target_version'], - 'OLD_VERSION' => $update['previous_version'], - 'OLD_DEV_STAGE_ID' => $update['previous_dev_stage'], - )); - - ob_start(); - $post_tpl->display('first_post_body'); - $first_post_contents = ob_get_contents(); - ob_clean(); - $post_tpl->display('first_post_title'); - $first_post_title = ob_get_contents(); - ob_clean(); - $post_tpl->display('update_post_body'); - $update_post_contents = ob_get_contents(); - ob_clean(); - $post_tpl->display('update_post_title'); - $update_post_title = ob_get_clean(); - } - else - { - $post_tpl->set_filenames(array( - 'post_body' => 'topic_layout.html', - 'post_title' => 'topic_title.html', - )); - - if ($history) - { - for ($i = 0, $size = sizeof($history); $i < $size; $i++) - { - $post_tpl->assign_block_vars('history', array( - 'DATE' => date('Y-m-d', $history[$i]['version_time']), - 'VERSION' => "{$history[$i]['version_major']}.{$history[$i]['version_minor']}.{$history[$i]['version_revision']}{$history[$i]['version_release']}", - 'CHANGELOG' => $history[$i]['version_changelog'], - - 'U_UPDATE_POST' => '', - 'U_DIFF' => '', - )); - } - } - - for ($i = 0, $size = sizeof($authors); $i < $size; $i++) - { - $post_tpl->assign_block_vars('author', array( - 'USERNAME' => $authors[$i]['author_username'], - 'REAL_NAME' => $authors[$i]['author_realname'], - 'EMAIL' => $authors[$i]['author_email'], - 'WEBSITE' => $authors[$i]['author_website'], - 'ROLE' => $authors[$i]['author_role_title'], - - 'S_STARTER' => ($authors[$i]['author_id'] == $info_array['project_start_id']) ? true : false, - 'U_AUTHOR' => "{$forum_root_path}project.$phpEx?i=author&mode=view&u={$authors[$i]['author_id']}", - )); - } - - $post_tpl->assign_vars(array( - 'PROJECT_TITLE' => $info_array['project_title'], - 'PROJECT_TITLE_CLEAN' => $info_array['project_title_clean'], - 'PROJECT_DESCRIPTION' => $info_array['project_description'], - 'AUTHOR_NOTES' => $info_array['project_notes'], - - 'DATE' => $info_array['project_last_update'], - 'VERSION' => $info_array['project_version'], - 'TARGET_VERSION' => $info_array['project_target_version'], - - 'DEV_STAGE_ID' => $info_array['project_stage'], - 'DEV_STAGE_UC' => strtoupper($stages_ary[$info_array['project_stage']]), - 'DEV_STAGE_LC' => strtolower($stages_ary[$info_array['project_stage']]), - 'DEV_STAGE_NC' => $stages_ary[$info_array['project_stage']], - - 'U_DOWNLOAD' => "{$forum_root_path}project.$phpEx?i=project&mode=download&pr={$info_array['project_id']}", - 'U_PROJECT_INFO' => "{$forum_root_path}project.$phpEx?i=project&mode=view&pr={$info_array['project_id']}", - )); - - ob_start(); - $post_tpl->display('post_body'); - $first_post_contents = ob_get_contents(); - ob_clean(); - $post_tpl->display('post_title'); - $first_post_title = ob_get_clean(); - } - - // Get forum ID - if ($config['project_autopost_forum_per_category']) - { - $sql = 'SELECT c.forum_id, f.forum_name - FROM ' . PROJECT_CATEGORIES_TABLE . ' c, ' . FORUMS_TABLE . ' f - WHERE c.category_id = ' . (int) $info_array['category_id'] . ' - AND f.forum_id = c.forum_id'; - - $db->sql_query($sql, 604800); - $forum_data = $db->sql_fetchrow(); - $db->sql_freeresult(); - } - else - { - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . (int) $config['project_autopost_forum_id']; - - $db->sql_query($sql, 604800); - $forum_data = $db->sql_fetchrow(); - $db->sql_freeresult(); - } - - $forum_id = $forum_data['forum_id']; - $forum_name = $forum_data['forum_name']; - - // submit_post() needs $user to be the info of the posting user, this is not the case here, so make a workaround - $this_user = $user; - - $user->data['is_registered'] = false; - $user->data['user_id'] = $config['project_autopost_user_id']; - - $sql = 'SELECT username, user_colour - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . (int) $user->data['user_id']; - - $db->sql_query($sql, 604800); - $userdata = $db->sql_fetchrow(); - $db->sql_freeresult(); - - $user->data['username'] = $userdata['username']; - $user->data['user_colour'] = $userdata['user_colour']; - $user->data['user_permissions'] = ''; - $user->ip = '127.0.0.1'; - $auth->acl($user->data); - - $message_parser = new parse_message($first_post_contents); - - if ($update) - { - $update_message_parser = new parse_message($update_post_contents); - $update_message_parser->parse(1, 1, 1); - - $sql = 'SELECT t.topic_replies_real, p.post_id, p.bbcode_uid, p.post_time - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - WHERE t.topic_id = $topic_id - AND p.post_id = t.topic_first_post_id"; - - $db->sql_query($sql); - $post_data = $db->sql_fetchrow(); - $db->sql_freeresult(); - - $message_parser->bbcode_uid = $post_data['bbcode_uid']; - } - - $message_parser->parse(1, 1, 1); - - - // Build data array - $data = array( - 'topic_title' => $first_post_title, - 'post_subject' => $first_post_title, - 'forum_id' => $forum_id, - 'forum_name' => $forum_name, - 'icon_id' => 0, - - 'enable_bbcode' => 1, - 'enable_smilies' => 1, - 'enable_urls' => 1, - 'enable_sig' => 0, - 'enable_indexing' => 1, - - 'message' => $message_parser->message, - 'message_md5' => md5($message_parser->message), - - 'bbcode_bitfield' => $message_parser->bbcode_bitfield, - 'bbcode_uid' => $message_parser->bbcode_uid, - - 'attachment_data' => array(), - - 'post_edit_locked' => false, - 'post_time' => (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : time(), - - ); - - $poll = array(); - - if ($update) - { - $data = array_merge($data, array('topic_id' => $topic_id, 'topic_first_post_id' => $post_data['post_id'], 'post_id' => $post_data['post_id'], 'topic_replies_real' => $post_data['topic_replies_real'], 'poster_id' => $user->data['user_id'], 'topic_approved' => true, 'post_approved' => true)); - submit_post('edit', $first_post_title, '', POST_NORMAL, $poll, $data); - - $update_data = array( - 'topic_id' => $topic_id, - 'post_subject' => $update_post_title, - 'forum_id' => $forum_id, - 'forum_name' => $forum_name, - 'icon_id' => 0, - - 'enable_bbcode' => 1, - 'enable_smilies' => 1, - 'enable_urls' => 1, - 'enable_sig' => 0, - 'enable_indexing' => 1, - - 'message' => $update_message_parser->message, - 'message_md5' => md5($update_message_parser->message), - - 'bbcode_bitfield' => $update_message_parser->bbcode_bitfield, - 'bbcode_uid' => $update_message_parser->bbcode_uid, - - 'attachment_data' => array(), - - 'post_edit_locked' => false, - 'post_time' => time(), - ); - - submit_post('reply', $update_post_title, '', POST_NORMAL, $poll, $update_data); - } - else - { - submit_post('post', $first_post_title, '', POST_NORMAL, $poll, $data); - } - - $user = $this_user; - $auth->acl($user->data); - - if (!$update) - { - $sql = 'UPDATE ' . PROJECT_PROJECTS_TABLE . ' - SET topic_id = ' . (int) $data['topic_id'] . ' - WHERE project_id = ' . $info_array['project_id']; - $db->sql_query($sql); - } - - return ($update) ? $update_data['post_id'] : $data['topic_id']; -} -?> \ No newline at end of file Deleted: trunk/develop/create_project.temp.php =================================================================== --- trunk/develop/create_project.temp.php 2008-04-23 20:21:14 UTC (rev 266) +++ trunk/develop/create_project.temp.php 2008-04-23 22:53:55 UTC (rev 267) @@ -1,169 +0,0 @@ -<? - -/** - * Create a new project - * - * @param string $mode - * @param array $info_array - * @param array $authors - * @param array|boolean $history - * @param array|boolean $actions - * @param array|boolean $old_actions - * @return boolean|string Either false if succesful of the error message - */ -function project_create($mode, $info_array, $authors, $history = false, $actions = false, $old_actions = false) -{ - global $db, $config, $auth, $user; - - // Check permissions - if (!$auth->acl_get('p_add_project')) - { - return $user->lang['PROJECT_NOT_AUTH_CREATE']; - } - if (!$auth->acl_get('p_view_category', $info_array['category_id'])) - { - return $user->lang['PROJECT_NOT_AUTH_CAT']; - } - - // Time & date of project creation - $current_time = time(); - - // History and action information are only needed for importing - if ($mode != 'import') - { - $history = $actions = $old_actions = false; - } - - // Variable types for database protection - $info_vars = array('category_id' => 'int' - , 'project_title' => 'string', - 'project_description' => 'string', - 'project_notes' => 'string', - 'project_license' => 'int', - 'project_target_version' => 'string', - 'project_version' => 'string', - 'project_stage' => 'int', - 'project_logo' => 'string', - 'project_logo_type' => 'int', - 'project_logo_width' => 'int', - 'project_logo_height' => 'int', - 'is_active' => 'int', - 'file_only' => 'int'); - - $error_message = ''; - foreach ($info_vars AS $var => $type) - { - if (!isset($info_array[$var])) - { - $error_message .= (($error_message) ? '<br />' : '') . sprintf($user->lang['FIELD_REQUIRED'], $var); - } - - $$var = ($type == 'string') ? $db->sql_escape($info_array[$var]) : intval($info_array[$var]); - } - if (!empty($error_message)) - { - return $error_message; - } - - // Clean title for uniqueness - $info_array['project_title_clean'] = utf8_clean_string($info_array['project_title']); - $project_title_clean = $db->sql_escape($info_array['project_title_clean']); - - $info_array['project_install_time'] = ($actions) ? project_generate_install_time($actions) : 0; - $info_array['project_level'] = ($actions) ? project_generate_level('actions', $actions) : PROJECT_LEVEL_EASY; - - $info_array['project_start_time'] = (empty($info_array['project_start_time'])) ? $current_time : intval($info_array['project_start_time']); - $info_array['project_start_id'] = (empty($info_array['project_start_id'])) ? $user->data['user_id'] : intval($info_array['project_start_id']); - $info_array['project_start_author'] = (empty($info_array['project_start_author'])) ? project_get_author_name($user->data['user_id']) : $info_array['project_start_author']; - - $project_start_author = $db->sql_escape($info_array['project_start_author']); - - $info_array['project_last_update'] = $current_time; - - /** - * @todo $authors, $history, $actions, $old_actions... Also, add some setting for permissions - */ - - // All set to go into the database :-) - $db->sql_transaction('begin'); - - $sql = 'INSERT INTO ' . PROJECT_PROJECTS_TABLE . " (category_id, project_title, project_title_clean, project_description, project_level, project_install_time, project_notes, project_license, project_target_version, project_version, project_stage, project_logo, project_logo_type, project_logo_width, project_logo_height, project_start_time, project_start_id, project_start_author, project_last_update, is_active, file_only, project_downloads) - VALUES ($category_id, '$project_title', '$project_title_clean', '$project_description', {$info_array['project_level']}, {$info_array['project_install_time']}, '$project_notes', $project_license, '$project_target_version', '$project_version', $project_stage, '$project_logo', $project_logo_type, $project_logo_width, $project_logo_height, {$info_array['project_start_time']}, {$info_array['project_start_id']}, '$project_start_author', {$info_array['project_last_update']}, $is_active, $file_only, 0)"; - $db->sql_query($sql); - - $info_array['project_id'] = $project_id = $db->sql_nextid(); - - for ($i = 0, $size = sizeof($authors); $i < $size; $i++) - { - $db->sql_query('INSERT INTO ' . PROJECT_PROJECT_AUTHORS_TABLE . " (project_id, author_id, author_role) - VALUES ($project_id, {$authors[$i]['author_id']}, {$authors[$i]['author_role_id']})"); - } - - if ($history) - { - for ($i = 0, $size = sizeof($history); $i < $size; $i++) - { - $db->sql_query('INSERT INTO ' . PROJECT_VERSIONS_TABLE . " (project_id, previous_id, version_time, version_major, version_minor, version_revision, version_release, version_stage, version_changelog) - VALUES ($project_id, {$history[$i]['previous_id']}, {$history[$i]['version_time']}, {$history[$i]['version_major']}, {$history[$i]['version_minor']}, {$history[$i]['version_revision']}, '{$history[$i]['version_release']}', {$history[$i]['version_stage']}, {$history[$i]['version_changelog']})"); - } - - $version_time = $history[$i]['version_time']; - } - else - { - $db->sql_query('INSERT INTO ' . PROJECT_VERSIONS_TABLE . " (project_id, previous_id, version_time, version_major, version_minor, version_revision, version_release, version_stage, version_changelog) - VALUES ($project_id, 0, $current_time, 0, 0, 0, '', " . PROJECT_STAGE_DEV . ", '')"); - - $version_time = $current_time; - } - - $version_id = $db->sql_nextid(); - - if ($actions) - { - for ($i = 0, $size = sizeof($actions); $i < $size; $i++) - { - /** - * @todo Something tells me this could be much more efficient... - */ - $db->sql_query('INSERT INTO ' . PROJECT_ACTIONS_TABLE . " (project_id) - VALUES ($project_id)"); - - $actions[$i]['action_id'] = $action_id = $db->sql_nextid(); - - $db->sql_query('INSERT INTO ' . PROJECT_ACTION_CONTENTS_TABLE . " (action_id, version_id, version_time, action_order, action_type, action_content) - VALUES ($action_id, $version_id, $version_time, {$actions[$i]['action_order']}, {$actions[$i]['action_type']}, '{$actions[$i]['action_content']}')"); - } - } - - // Update project count for category - $sql = 'UPDATE ' . PROJECT_CATEGORIES_TABLE . " - SET category_projects = category_projects + 1, - last_update_id = $project_id, - last_update_time = {$info_array['project_last_update']} - WHERE category_id = {$info_array['category_id']}"; - $db->sql_query($sql); - - // And roll it - $db->sql_transaction('commit'); - - // Now post it if needed - if ($config['project_autopost_enable']) - { - $topic_id = project_autopost($info_array, $authors, $history); - - if (!$topic_id) - { - return $user->lang['PROJECT_AUTOPOST_FAILURE']; - } - - $sql = 'UPDATE ' . PROJECT_PROJECTS_TABLE . ' - SET topic_id = ' . (int) $topic_id . ' - WHERE project_id = ' . $project_id; - $db->sql_query($sql); - } - - return false; -} - -?> \ No newline at end of file Modified: trunk/phpbb3/root/includes/project/project_main.php =================================================================== --- trunk/phpbb3/root/includes/project/project_main.php 2008-04-23 20:21:14 UTC (rev 266) +++ trunk/phpbb3/root/includes/project/project_main.php 2008-04-23 22:53:55 UTC (rev 267) @@ -322,41 +322,18 @@ } } - /** - * @todo Decompress archives - * @todo Handle included files - */ - $included_files = false; + $filetype = request_var('filetype', PROJECT_FILETYPE_XML); - $filetype = request_var('filetype', PROJECT_FILETYPE_TEXT); - - // Parse the file given - /** - * @todo change parser class - */ - $parser = new parse_project($project_file, $filetype); - - // If there's anything wrong, display error here... - $message = $parser->validate(); - - if ($parser->error) + if ($filetype == PROJECT_FILETYPE_XML) { - trigger_error($user->lang['PROJECT_IMPORT_FAILURE'] . ':<br /><br />' . $message, E_USER_WARNING); + $import = new project_import_modx($project_file); } + $import->process(); - if (($message = project_create('import', $parser->info_array, $parser->authors, $parser->history, $parser->actions)) !== false) + if ($import->error) { trigger_error($user->lang['PROJECT_IMPORT_FAILURE'] . ':<br /><br />' . $message, E_USER_WARNING); } - - if ($included_files) - { - /** - * @todo Function for included files... - */ - } - - trigger_error($user->lang['PROJECT_IMPORT_SUCCESS']); } $this->tpl_name = 'project_import'; @@ -376,12 +353,16 @@ } // Get the data in + /** + * @todo target_version generation + */ $data = array( 'project_category' => request_var('project_category', 0), 'project_title' => utf8_normalize_nfc(request_var('project_title', '', true)), 'project_description' => utf8_normalize_nfc(request_var('project_description', '', true)), 'project_notes' => utf8_normalize_nfc(request_var('project_notes', '', true)), 'project_license' => request_var('project_license', 0), + 'file_only' => (request_var('file_only', false)) ? true : false, ); // Validate the title (Check duplicate, length, invalid chars, etc.) @@ -390,9 +371,49 @@ $error[] = (isset($user->lang[$title_err])) ? $user->lang[$title_err] : $title_err; } - $file_only = (request_var('file_only', false)) ? true : false; + if (!sizeof($error)) + { + $create = new project_create($data, $authors); + if ($create->error) + { + $error[] = $create->error; + } + else + { + $return_ary = $create->process(); + + if (!$return_ary['project_id']) + { + trigger_error($user->lang['PROJECT_CREATE_FAILURE']); + } + + $project_link = '<a href="' . append_sid("{$phpbb_root_path}project.$phpEx", "i=project&c={$data['project_category']}&pr={$return_ary['project_id']}") . '">'; + $topic_link = (isset($return_ary['topic_id'])) ? '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$return_ary['topic_id']}") . '">' : ''; + $message = $user->lang['PROJECT_CREATE_SUCCESS']; + $message .= '<br /><br />' . sprintf($user->lang['PROJECT_VIEW_PROJECT'], $project_link, '</a>'); + $message .= (isset($return_ary['topic_id'])) ? '<br />' . sprintf($user->lang['PROJECT_VIEW_TOPIC'], $topic_link, '</a>') : ''; + $message .= '<br /><br />' . sprintf($user->lang['PROJECT_BACK_OVERVIEW'], '<a href="' . append_sid("{$phpbb_root_path}project.$phpEx", 'i=main') . '">', '</a>'); + + trigger_error($message); + } + } + + $template->assign_vars(array( + 'ERROR' => implode('<br />', $error), + 'PROJECT_TITLE' => $data['project_title'], + 'PROJECT_DESCRIPTION' => $data['project_description'], + 'PROJECT_NOTES' => $data['project_notes'], + 'PROJECT_LICENSE' => $data['project_license'], + 'FILE_ONLY' => $data['file_only'], + )); } + /** + * @todo Add queries for categories and licenses + */ + + add_form_key('project_create'); + $this->tpl_name = 'project_create'; $this->page_title = 'PROJECT_CREATE_PROJECT'; Modified: trunk/phpbb3/root/includes/sources_project/create_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/create_project.php 2008-04-23 20:21:14 UTC (rev 266) +++ trunk/phpbb3/root/includes/sources_project/create_project.php 2008-04-23 22:53:55 UTC (rev 267) @@ -17,6 +17,7 @@ { public $current_time; public $error; + public $message; protected $data; protected $authors; @@ -125,10 +126,14 @@ // Now post it if needed if ($config['project_autopost_enable'] && !$config['project_approve_creation']) { - project_autopost($this->data, $this->authors); + $topic_id = project_autopost($this->data, $this->authors); + return array( + 'project_id' => $project_id, + 'topic_id' => $topic_id + ); } - return $project_id; + return array('project_id' => $project_id); } } @@ -256,10 +261,14 @@ // Now post it if needed if ($config['project_autopost_enable'] && !$config['project_approve_creation']) { - project_autopost($this->data, $this->authors, $this->history); + $topic_id = project_autopost($this->data, $this->authors, $this->history); + return array( + 'project_id' => $project_id, + 'topic_id' => $topic_id + ); } - return $project_id; + return array('project_id' => $project_id); } } Modified: trunk/phpbb3/root/includes/sources_project/functions_create.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/functions_create.php 2008-04-23 20:21:14 UTC (rev 266) +++ trunk/phpbb3/root/includes/sources_project/functions_create.php 2008-04-23 22:53:55 UTC (rev 267) @@ -3,7 +3,7 @@ * phpBB Project functions_create * * @package phpbbproject - * @version $Id:$ + * @version $Id$ * @copyright (c) 2008 phpBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ Modified: trunk/phpbb3/root/styles/prosilver/template/project_create.html =================================================================== --- trunk/phpbb3/root/styles/prosilver/template/project_create.html 2008-04-23 20:21:14 UTC (rev 266) +++ trunk/phpbb3/root/styles/prosilver/template/project_create.html 2008-04-23 22:53:55 UTC (rev 267) @@ -30,13 +30,13 @@ <dl> <dt><label for="project_license">{L_PROJECT_LICENSE}:</label></dt> <dd><select tabindex="5" name="project_license" id="project_license" title="{L_PROJECT_LICENSE}" onchange="set_description(this.value)"><!-- BEGIN license --> - <option value="{license.LICENSE_ID}"<!-- IF license.S_STANDARD --> selected="selected"<!-- ENDIF -->>{license.LICENSE_TITLE}</option><!-- END --> + <option value="{license.LICENSE_ID}"<!-- IF (license.S_STANDARD && not PROJECT_LICENSE) || license.LICENSE_ID == PROJECT_LICENSE --> selected="selected"<!-- ENDIF -->>{license.LICENSE_TITLE}</option><!-- END --> </select> <span id="license_description">{LICENSE_DESCRIPTION}</span></dd> </dl> <dl> <dt><label for="file_only">{L_PROJECT_FILE_ONLY}:</label><br /><span>{L_PROJECT_FILE_ONLY_EXPLAIN}</span></dt> - <dd><input type="checkbox" tabindex="6" name="file_only" id="file_only" /></dd> + <dd><input type="checkbox" tabindex="6" name="file_only" id="file_only"<!-- IF FILE_ONLY --> checked="checked"<!-- ENDIF --> /></dd> </dl> {S_FORM_TOKEN} </fieldset> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2008-04-24 15:16:09
|
Revision: 270 http://phpbbproject.svn.sourceforge.net/phpbbproject/?rev=270&view=rev Author: lord_le_brand Date: 2008-04-24 08:16:16 -0700 (Thu, 24 Apr 2008) Log Message: ----------- Fixed some nubs in create project and installer Both now work =) (at least for me =P) Modified Paths: -------------- trunk/develop/autopost_test.php trunk/phpbb3/root/includes/project/project_main.php trunk/phpbb3/root/includes/sources_project/create_project.php trunk/phpbb3/root/includes/sources_project/extensions.php trunk/phpbb3/root/includes/sources_project/functions_create.php trunk/phpbb3/root/project.php trunk/phpbb3/root/project_install/install_install.php trunk/phpbb3/root/project_install/schemas/schema_data.sql trunk/phpbb3/root/styles/prosilver/template/project_create.html Modified: trunk/develop/autopost_test.php =================================================================== --- trunk/develop/autopost_test.php 2008-04-24 13:20:07 UTC (rev 269) +++ trunk/develop/autopost_test.php 2008-04-24 15:16:16 UTC (rev 270) @@ -26,8 +26,8 @@ require("{$phpbb_root_path}includes/sources_project/extensions.$phpEx"); // phpBB Project Auth extension -unset($auth); -$auth = new project_auth(); +//unset($auth); +//$auth = new project_auth(); // Basic parameter data $id = request_var('i', ''); Modified: trunk/phpbb3/root/includes/project/project_main.php =================================================================== --- trunk/phpbb3/root/includes/project/project_main.php 2008-04-24 13:20:07 UTC (rev 269) +++ trunk/phpbb3/root/includes/project/project_main.php 2008-04-24 15:16:16 UTC (rev 270) @@ -65,7 +65,7 @@ $project_ids = $db->sql_in_set('project_id', $acl_projects, false, true); $optional_fields = ($config['project_autopost_enable']) ? ', topic_id' : ''; - $sql = "SELECT project_id, project_title, project_downloads $optional_fields + $sql = "SELECT project_id, project_title, project_description, project_downloads $optional_fields FROM " . PROJECT_PROJECTS_TABLE . " WHERE $project_ids ORDER BY project_downloads DESC"; @@ -140,8 +140,9 @@ $folder_image = 'project_cat'; $folder_image .= ($categories[$i]['right_id'] != ($categories[$i]['left_id'] + 1)) ? '_subcats' : ''; - $last_update_id = $categories[$i]['last_update_id']; - $last_update_time = ($last_update_id) ? $user->format_date($categories[$i]['last_update_time']) : 0; + $last_update_id = $categories[$i]['last_update_id']; + $last_update_time = ($last_update_id) ? $user->format_date($categories[$i]['last_update_time']) : 0; + $last_update_title = ''; if ($last_update_id) { @@ -345,6 +346,9 @@ if (isset($_POST['submit'])) { + include_once("{$phpbb_root_path}includes/sources_project/functions_create.$phpEx"); + include_once("{$phpbb_root_path}includes/sources_project/create_project.$phpEx"); + $error = array(); if (!check_form_key('project_create')) @@ -357,7 +361,7 @@ * @todo target_version generation */ $data = array( - 'project_category' => request_var('project_category', 0), + 'category_id' => request_var('project_category', 0), 'project_title' => utf8_normalize_nfc(request_var('project_title', '', true)), 'project_description' => utf8_normalize_nfc(request_var('project_description', '', true)), 'project_notes' => utf8_normalize_nfc(request_var('project_notes', '', true)), @@ -438,14 +442,14 @@ for ($i = 0, $size = sizeof($categories); $i < $size; $i++) { - if ($parent_id != $categories[$i]['category_id']) + if ($parent_id != $categories[$i]['parent_id']) { - $padding += ($categories[$i]['left_id'] > $categories[$i-1]['left_id']) ? 1 : -1; + $padding += ($categories[$i]['parent_id'] == $categories[$i-1]['category_id']) ? 1 : -1; } $template->assign_block_vars('category', array( - 'CATEGORY_ID' => $categories[$i]['category_id'], - 'CATEGORY_NAME' => str_repeat($padding_delimiter, $padding) . $categories[$i]['category_name'], + 'CATEGORY_ID' => $categories[$i]['category_id'], + 'CATEGORY_TITLE' => str_repeat($padding_delimiter, $padding) . $categories[$i]['category_title'], )); } Modified: trunk/phpbb3/root/includes/sources_project/create_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/create_project.php 2008-04-24 13:20:07 UTC (rev 269) +++ trunk/phpbb3/root/includes/sources_project/create_project.php 2008-04-24 15:16:16 UTC (rev 270) @@ -60,7 +60,7 @@ global $config, $user; $this->data = array_merge($data, array( - 'project_clean_title' => utf8_clean_string($data['project_title']), + 'project_title_clean' => utf8_clean_string($data['project_title']), 'project_install_time' => 0, 'project_level' => PROJECT_LEVEL_EASY, 'project_stage' => PROJECT_STAGE_DEV, @@ -95,7 +95,7 @@ $db->sql_query('INSERT INTO ' . PROJECT_PROJECT_AUTHORS_TABLE . $db->sql_build_array('INSERT', array( 'project_id' => $project_id, 'author_id' => $this->authors[$i]['author_id'], - 'author_role' => $this->authors[$i]['author_role_id'] + 'author_role' => $this->authors[$i]['author_role'] ))); } @@ -173,7 +173,7 @@ global $config, $user; $this->data = array_merge($data, array( - 'project_clean_title' => utf8_clean_string($data['project_title']), + 'project_title_clean' => utf8_clean_string($data['project_title']), 'project_install_time' => project_generate_install_time($this->actions), 'project_level' => project_generate_level('actions', $this->actions), 'project_last_update' => $this->current_time, @@ -186,6 +186,7 @@ * Process project creation * * @return integer Project ID + * @todo Change project_project_authors table to acl_roles table */ public function process() { @@ -204,7 +205,7 @@ $db->sql_query('INSERT INTO ' . PROJECT_PROJECT_AUTHORS_TABLE . $db->sql_build_array('INSERT', array( 'project_id' => $project_id, 'author_id' => $this->authors[$i]['author_id'], - 'author_role' => $this->authors[$i]['author_role_id'] + 'author_role' => $this->authors[$i]['author_role'] ))); } Modified: trunk/phpbb3/root/includes/sources_project/extensions.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/extensions.php 2008-04-24 13:20:07 UTC (rev 269) +++ trunk/phpbb3/root/includes/sources_project/extensions.php 2008-04-24 15:16:16 UTC (rev 270) @@ -33,6 +33,8 @@ */ function module_auth($module_auth, $forum_id = false, $category_id = false, $project_id = false) { + global $auth; + $module_auth = trim($module_auth); // Generally allowed to access module if module_auth is empty Modified: trunk/phpbb3/root/includes/sources_project/functions_create.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/functions_create.php 2008-04-24 13:20:07 UTC (rev 269) +++ trunk/phpbb3/root/includes/sources_project/functions_create.php 2008-04-24 15:16:16 UTC (rev 270) @@ -28,12 +28,12 @@ } // Check the length - if ($config['project_title_min_chars'] && $project_title < $config['project_title_min_chars']) + if ($config['project_title_min_chars'] && utf8_strlen($project_title) < $config['project_title_min_chars']) { return 'PROJECT_TITLE_TOO_SHORT'; } - if ($config['project_title_max_chars'] && $project_title > $config['project_title_max_chars']) + if ($config['project_title_max_chars'] && utf8_strlen($project_title) > $config['project_title_max_chars']) { return 'PROJECT_TITLE_TOO_LONG'; } Modified: trunk/phpbb3/root/project.php =================================================================== --- trunk/phpbb3/root/project.php 2008-04-24 13:20:07 UTC (rev 269) +++ trunk/phpbb3/root/project.php 2008-04-24 15:16:16 UTC (rev 270) @@ -17,9 +17,9 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1); require("{$phpbb_root_path}common.$phpEx"); require("{$phpbb_root_path}includes/functions_module.$phpEx"); -require("{$phpbb_root_path}includes/functions_project.$phpEx"); require("{$phpbb_root_path}includes/sources_project/constants.$phpEx"); require("{$phpbb_root_path}includes/sources_project/extensions.$phpEx"); +require("{$phpbb_root_path}includes/sources_project/functions_project.$phpEx"); // phpBB Project Auth extension //unset($auth); Modified: trunk/phpbb3/root/project_install/install_install.php =================================================================== --- trunk/phpbb3/root/project_install/install_install.php 2008-04-24 13:20:07 UTC (rev 269) +++ trunk/phpbb3/root/project_install/install_install.php 2008-04-24 15:16:16 UTC (rev 270) @@ -174,7 +174,7 @@ $team_group_id = 0; $error_message_ary = group_create($team_group_id, GROUP_SPECIAL, 'PROJECT_TEAM', '', array('group_colour' => 'E67300', 'group_receive_pm' => 1, 'group_legend' => 1)); - if (sizeof($error_message_ary)) + if ($error_message_ary !== false) { trigger_error(implode("<br />\n", $error_message_ary)); } Modified: trunk/phpbb3/root/project_install/schemas/schema_data.sql =================================================================== --- trunk/phpbb3/root/project_install/schemas/schema_data.sql 2008-04-24 13:20:07 UTC (rev 269) +++ trunk/phpbb3/root/project_install/schemas/schema_data.sql 2008-04-24 15:16:16 UTC (rev 270) @@ -154,11 +154,8 @@ INSERT INTO phpbb_project_categories (parent_id, left_id, right_id, category_title, category_description) VALUES (0, 0, 1, '{L_PROJECT_TEST_CAT_TITLE}', '{L_PROJECT_TEST_CAT_DESC}'); # Project -INSERT INTO phpbb_project_projects (category_id, topic_id, project_title, project_title_clean, project_description, project_level, project_install_time, project_notes, project_license, project_target_version, project_version, project_stage, project_target, project_logo, project_logo_type, project_logo_width, project_logo_height, project_start_time, project_owner, project_last_update, project_status, file_only, project_downloads) VALUES (1, 1, 0, 'Forum prune move', 'forum prune move', 'Add an option to move posts instead of delete them on pruning.', 1, 180, 'Requested by bulldogg597, one of the best MOD requests i''ve seen.', 1, '3.0.0', '1.0.1', 4, '', '', 0, 0, 0, 1203634800, 2, 1207951200, 1, 0, 0); +INSERT INTO phpbb_project_projects (category_id, topic_id, project_title, project_title_clean, project_description, project_level, project_install_time, project_notes, project_license, project_target_version, project_version, project_stage, project_target, project_logo, project_logo_type, project_logo_width, project_logo_height, project_start_time, project_owner, project_last_update, project_status, file_only, project_downloads) VALUES (1, 0, 'Forum prune move', 'forum prune move', 'Add an option to move posts instead of delete them on pruning.', 1, 180, 'Requested by bulldogg597, one of the best MOD requests i''ve seen.', 1, '3.0.0', '1.0.1', 4, '', '', 0, 0, 0, 1203634800, 2, 1207951200, 1, 0, 0); -# Author - acutally Igor but meh... -INSERT INTO phpbb_project_project_authors (project_id, author_id, author_role) SELECT 1, 2, role_id FROM phpbb_acl_roles WHERE role_name = 'ROLE_PROJECT_MANAGER'; - # Versions INSERT INTO phpbb_project_versions (version_id, project_id, previous_id, version_time, version_major, version_minor, version_revision, version_stage, version_release, version_changelog) VALUES (1, 1, 0, 1203634800, 1, 0, 0, 4, '', 'Initial release'); INSERT INTO phpbb_project_versions (version_id, project_id, previous_id, version_time, version_major, version_minor, version_revision, version_stage, version_release, version_changelog) VALUES (2, 1, 1, 1207432800, 1, 0, 0, 4, 'a', 'MODX file'); Modified: trunk/phpbb3/root/styles/prosilver/template/project_create.html =================================================================== --- trunk/phpbb3/root/styles/prosilver/template/project_create.html 2008-04-24 13:20:07 UTC (rev 269) +++ trunk/phpbb3/root/styles/prosilver/template/project_create.html 2008-04-24 15:16:16 UTC (rev 270) @@ -12,7 +12,7 @@ <dl> <dt><label for="project_category">{L_PROJECT_CATEGORY}</label></dt> <dd><select tabindex="1" name="project_category" id="project_category" title="{L_PROJECT_CATEGORY}"><!-- BEGIN category --> - <option value="{category.CATEGORY_ID}"<!-- IF category.CATEGORY_ID == CATEGORY_ID --> selected="selected"<!-- ENDIF -->>{category.CATEGORY_NAME}</option><!-- END --> + <option value="{category.CATEGORY_ID}"<!-- IF category.CATEGORY_ID == CATEGORY_ID --> selected="selected"<!-- ENDIF -->>{category.CATEGORY_TITLE}</option><!-- END --> </select></dd> </dl> <dl> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2008-04-26 10:41:47
|
Revision: 271 http://phpbbproject.svn.sourceforge.net/phpbbproject/?rev=271&view=rev Author: lord_le_brand Date: 2008-04-26 03:41:49 -0700 (Sat, 26 Apr 2008) Log Message: ----------- Modified Paths: -------------- trunk/develop/create_schema_files_phpbb3.php trunk/develop/modules.txt trunk/develop/permissions.txt trunk/develop/roles.txt trunk/phpbb3/root/includes/project/project_main.php trunk/phpbb3/root/includes/project/project_project.php trunk/phpbb3/root/includes/sources_project/extensions.php trunk/phpbb3/root/project.php Added Paths: ----------- trunk/develop/todo_list.txt trunk/phpbb3/root/includes/project/project_trackers.php Modified: trunk/develop/create_schema_files_phpbb3.php =================================================================== --- trunk/develop/create_schema_files_phpbb3.php 2008-04-24 15:16:16 UTC (rev 270) +++ trunk/develop/create_schema_files_phpbb3.php 2008-04-26 10:41:49 UTC (rev 271) @@ -845,7 +845,7 @@ 'category_description' => array('STEXT_UNI', ''), 'category_projects' => array('UINT:11', '0'), 'last_update_id' => array('UINT', '0'), - 'last_update_time' => array('UINT:11', '0'), + 'last_update_time' => array('TIMESTAMP', '0'), 'forum_id' => array('UINT', '0'), ), 'PRIMARY_KEY' => 'category_id', @@ -880,9 +880,9 @@ 'project_logo_type' => array('TINT:2', '0'), 'project_logo_width' => array('USINT', '0'), 'project_logo_height' => array('USINT', '0'), - 'project_start_time' => array('UINT:11', '0'), + 'project_start_time' => array('TIMESTAMP', '0'), 'project_owner' => array('UINT', '0'), - 'project_last_update' => array('UINT:11', '0'), + 'project_last_update' => array('TIMESTAMP', '0'), 'project_status' => array('BOOL', '0'), 'file_only' => array('BOOL', '0'), 'project_downloads' => array('UINT:11', '0'), @@ -904,7 +904,7 @@ 'version_id' => array('UINT:11', NULL, 'auto_increment'), 'project_id' => array('UINT', '0'), 'previous_id' => array('UINT:11', '0'), - 'version_time' => array('UINT:11', '0'), + 'version_time' => array('TIMESTAMP', '0'), 'version_major' => array('TINT:3', '0'), 'version_minor' => array('TINT:3', '0'), 'version_revision' => array('TINT:3', '0'), @@ -923,7 +923,7 @@ 'action_id' => array('UINT:11', '0'), 'project_id' => array('UINT', '0'), 'version_id' => array('UINT:11', '0'), - 'version_time' => array('UINT:11', '0'), + 'version_time' => array('TIMESTAMP', '0'), 'action_order' => array('USINT', '0'), 'action_file' => array('VCHAR', ''), 'action_type' => array('TINT:2', '0'), @@ -995,19 +995,19 @@ ) ); - // Entries per category/tracker, end-users - $schema_data['phpbb_project_tracker_entries'] = array( + // Tickets per category/tracker, end-users + $schema_data['phpbb_project_tracker_tickets'] = array( 'COLUMNS' => array( - 'entry_id' => array('UINT:11', NULL, 'auto_increment'), - 'tracker_id' => array('UINT:11', '0'), - 'tracker_category' => array('UINT:11', '0'), - 'entry_title' => array('XSTEXT_UNI', ''), - 'entry_description' => array('MTEXT_UNI', ''), - 'entry_status' => array('USINT', '0'), - 'entry_author' => array('UINT', '0'), - 'entry_time' => array('UINT:11', '0'), + 'ticket_id' => array('UINT:11', NULL, 'auto_increment'), + 'tracker_id' => array('UINT:11', '0'), + 'tracker_category' => array('UINT:11', '0'), + 'ticket_title' => array('XSTEXT_UNI', ''), + 'ticket_description' => array('MTEXT_UNI', ''), + 'ticket_status' => array('USINT', '0'), + 'ticket_author' => array('UINT', '0'), + 'ticket_time' => array('TIMESTAMP', '0'), ), - 'PRIMARY_KEY' => 'entry_id', + 'PRIMARY_KEY' => 'ticket_id', 'KEYS' => array( 'tracker_id' => array('INDEX', 'tracker_id'), 'tracker_category' => array('INDEX', 'tracker_category'), @@ -1059,9 +1059,9 @@ 'project_id' => array('UINT', '0'), 'document_title' => array('XSTEXT_UNI', ''), 'document_content' => array('MTEXT_UNI', ''), - 'document_added' => array('UINT:11', '0'), + 'document_added' => array('TIMESTAMP', '0'), 'document_added_by' => array('UINT', '0'), - 'document_edit_time' => array('UINT:11', '0'), + 'document_edit_time' => array('TIMESTAMP', '0'), 'document_edit_user' => array('UINT', '0'), 'document_edit_count' => array('USINT', '0'), 'enable_bbcode' => array('BOOL', '1'), Modified: trunk/develop/modules.txt =================================================================== --- trunk/develop/modules.txt 2008-04-24 15:16:16 UTC (rev 270) +++ trunk/develop/modules.txt 2008-04-26 10:41:49 UTC (rev 271) @@ -17,7 +17,6 @@ Overview View cat {category_id} - [Statistics]* Create project {category_id:0} Import project Modified: trunk/develop/permissions.txt =================================================================== --- trunk/develop/permissions.txt 2008-04-24 15:16:16 UTC (rev 270) +++ trunk/develop/permissions.txt 2008-04-26 10:41:49 UTC (rev 271) @@ -1,24 +1,36 @@ Permissions for phpBB Project: -Assigned by authors: (All local) +We're gonna have to make one or more new tables for permission masks. +This is because, apparently, the forum_id really isn't supposed to be used for something else. >_> +New auth methods: + +- acl_getp($opt, $clean = false) + Like acl_getf($opt, $clean = false) but for projects +- acl_getc($opt, $clean = false) + Like acl_getf($opt, $clean = false) but for categories + +Extend or modify most others (when I understand them all some more...) + +Assigned by authors (All per project): + - View the mod - Edit mod - Delete the mod - Download the mod - Add authors - Remove authors -- Assign roles to authors -- Assign permissions to authors +- Manage project roles and permissions - View docs - Manage docs Assigned by admin: - Create a mod (global) -- View category (local) // How -- Manage category (global) -- Manage roles (global) +- View category (per category) // How (<< What's this about??) +- Add MODs to category (per category) +- Manage categories (global) +- Manage roles/permissions (global) - Approve mod creation (global) Modified: trunk/develop/roles.txt =================================================================== --- trunk/develop/roles.txt 2008-04-24 15:16:16 UTC (rev 270) +++ trunk/develop/roles.txt 2008-04-26 10:41:49 UTC (rev 271) @@ -36,6 +36,8 @@ - Team: + - View anything + - Edit parts of a project (Will have edit-history and mandatory reason field to avoid abuse) - Manage category - Manage roles - Approve mod creation Added: trunk/develop/todo_list.txt =================================================================== --- trunk/develop/todo_list.txt (rev 0) +++ trunk/develop/todo_list.txt 2008-04-26 10:41:49 UTC (rev 271) @@ -0,0 +1,31 @@ +Todo list for phpBB Project + +- Make a TODO tracker!!! +- When at it make a bug tracker and feature tracker :) +- Extend auth class and create new permission tables +- Change the way authors are tied to projects (acl_roles or new equivalent) +- Add /languages and /templates support to download (and import) class +- Author ordering in MOD(X) file/project overview page +- Definitive decision on storing versioned files +- Generate filetree more efficiently (download class) +- Expand validate_project_title() +- Decide on what information will go on view category module +- Target version information +- Decide on better module structure +- Modules: + - Import project + - Manage project + - Diff generator + - Docs (perhaps wiki-style?) + - Trackers script++ (also needed for this todo list, so step on it! xD) + - Projects Team CP (maybe a new *CP?) + - Marx + - Search +- Logo support +- License handler +- phpbb.com MOD database sender +- Add language entries +- Add text and options to installer +- Add links to header (and index?) +- Make modx file... -_-' +- Package & Release! ^_^ Modified: trunk/phpbb3/root/includes/project/project_main.php =================================================================== --- trunk/phpbb3/root/includes/project/project_main.php 2008-04-24 15:16:16 UTC (rev 270) +++ trunk/phpbb3/root/includes/project/project_main.php 2008-04-26 10:41:49 UTC (rev 271) @@ -16,6 +16,8 @@ class project_main { public $u_action; + public $tpl_name; + public $page_title; /** * Main method @@ -31,6 +33,7 @@ if ($mode == 'import' || $mode == 'create_project') { + include("{$phpbb_root_path}includes/sources_project/functions_create.$phpEx"); include("{$phpbb_root_path}includes/sources_project/create_project.$phpEx"); } @@ -121,8 +124,11 @@ if (($mode == 'viewcat' && $category_info['right_id'] != ($category_info['left_id'] + 1)) || $mode != 'viewcat') { // There are categories here, so display them - $acl_categories = array_keys($auth->acl_getf('p_view_category', true)); - $category_ids = $db->sql_in_set('category_id', $acl_categories, false, true); + $acl_categories = array(); + $category_ids = '1 = 1'; + // Rewrite next line when auth class is extended + // $acl_categories = array_keys($auth->acl_getf('p_view_category', true)); + //$category_ids = $db->sql_in_set('category_id', $acl_categories, false, true); $sql = 'SELECT * FROM ' . PROJECT_CATEGORIES_TABLE . " Modified: trunk/phpbb3/root/includes/project/project_project.php =================================================================== --- trunk/phpbb3/root/includes/project/project_project.php 2008-04-24 15:16:16 UTC (rev 270) +++ trunk/phpbb3/root/includes/project/project_project.php 2008-04-26 10:41:49 UTC (rev 271) @@ -17,6 +17,7 @@ { public $u_action; public $tpl_name; + public $page_title; /** * Main method Added: trunk/phpbb3/root/includes/project/project_trackers.php =================================================================== --- trunk/phpbb3/root/includes/project/project_trackers.php (rev 0) +++ trunk/phpbb3/root/includes/project/project_trackers.php 2008-04-26 10:41:49 UTC (rev 271) @@ -0,0 +1,127 @@ +<?php +/** + * phpBB Project + * + * @package phpbbproject + * @version $Id:$ + * @copyright (c) 2008 phpBB Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + +/** + * Trackers module + * + * @package phpbbproject + */ +class project_tracker +{ + public $u_action; + public $tpl_name; + public $page_title; + + /** + * Main method + * + * @param string|integer $id + * @param string $mode + */ + function main($id, $mode) + { + global $db, $user, $template; + global $phpbb_root_path, $phpEx; + global $project_id, $category_id; + + switch ($mode) + { + default: + case 'overview': + + // Get trackers for this project + $sql = 'SELECT t.*, types.*, COUNT(tc.*) AS tracker_categories, COUNT(tickets.*) AS tracker_tickets + FROM ' . PROJECT_TRACKERS_TABLE . ' t, ' . PROJECT_TRACKER_TYPES_TABLE . ' types, ' . PROJECT_TRACKER_CATEGORIES_TABLE . ' tc, ' . PROJECT_TRACKER_ENTRIES_TABLE . " tickets + WHERE t.project_id = $project_id + AND types.tracker_type_id = t.tracker_type + AND tickets.tracker_id = t.tracker_id + AND tc.tracker_id = t.tracker_id + GROUP BY t.tracker_id + ORDER BY types.tracker_type_title ASC"; + + $result = $db->sql_query($sql, 604800); + $trackers = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + for ($i = 0, $size = sizeof($trackers); $i < $size; $i++) + { + $template->assign_block_vars('tracker_row', array( + 'TRACKER_TITLE' => $trackers[$i]['tracker_type_title'], + 'TRACKER_DESCRIPTION' => $trackers[$i]['tracker_type_description'], + 'TRACKER_TICKETS' => $trackers[$i]['tracker_tickets'], + 'TRACKER_CATEGORIES' => $trackers[$i]['tracker_categories'], + + 'U_TRACKER' => append_sid("{$phpbb_root_path}project.$phpEx", "i=trackers&mode=tickets&tid={$trackers[$i]['tracker_id']}"), + )); + } + + break; + + case 'tickets': + + $tracker_id = request_var('tid', 0); + $tracker_category = request_var('tcat', 0); + + // Just redirect if $tracker_id is 0 + if (!$tracker_id) + { + redirect(append_sid("{$phpbb_root_path}project.$phpEx", "i=trackers&mode=overview")); + } + + if ($tracker_category) + { + $sql = 'SELECT * + FROM ' . PROJECT_TRACKER_CATEGORIES_TABLE . " + WHERE category_id = $tracker_category"; + $result = $db->sql_query($sql, 604800); + $category_info = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($category_info['is_private'] && !$is_author) + { + // @todo some error... + } + + $template->assign_vars(array( + // @todo stuff... + )); + } + + $sql = 'SELECT t.*, c.*, s.* + FROM ' . PROJECT_TRACKER_TICKETS_TABLE . ' t, ' . PROJECT_TRACKER_CATEGORIES_TABLE . ' c, ' . PROJECT_TRACKER_STATUS_TABLE . " s + WHERE t.tracker_id = $tracker_id + " . (($tracker_category) ? "AND t.tracker_category = $tracker_category" : '') . ' + AND c.category_id = t.tracker_category + AND s.tracker_status_id = t.ticket_status + ' . ((!$is_author) ? 'AND c.is_private = 0' : '') . ' + ORDER BY ticket.ticket_time DESC'; + $result = $db->sql_query($sql, 604800); + $tickets = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + for ($i = 0, $size = sizeof($tickets); $i < $size; $i++) + { + $template->assign_block_vars('ticket_row', array( + 'TICKET_TITLE' => $tickets[$i]['ticket_title'], + 'CATEGORY_TITLE' => $tickets[$i]['category_title'], + 'TICKET_STATUS' => $tickets[$i]['tracker_status_title'], + 'TICKET_AUTHOR' => get_username_string('full', $tickets[$i]['ticket_author'], project_get_author_name($tickets[$i]['ticket_author'])), + 'TICKET_TIME' => $user->format_date($tickets[$i]['ticket_time']), + + 'U_VIEW_TICKET' => append_sid("{$phpbb_root_path}project.$phpEx", "i=trackers&view_ticket&tid=$tracker_id&ticket={$trackers[$i]['ticket_id']}"), + )); + } + + break; + } + } +} + +?> \ No newline at end of file Property changes on: trunk/phpbb3/root/includes/project/project_trackers.php ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Modified: trunk/phpbb3/root/includes/sources_project/extensions.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/extensions.php 2008-04-24 15:16:16 UTC (rev 270) +++ trunk/phpbb3/root/includes/sources_project/extensions.php 2008-04-26 10:41:49 UTC (rev 271) @@ -15,7 +15,7 @@ */ class project_auth extends auth { - // I don't know why though :P + // Do stuff with extra tables... } /** Modified: trunk/phpbb3/root/project.php =================================================================== --- trunk/phpbb3/root/project.php 2008-04-24 15:16:16 UTC (rev 270) +++ trunk/phpbb3/root/project.php 2008-04-26 10:41:49 UTC (rev 271) @@ -64,6 +64,17 @@ if ($project_id) { $module->acl_project_id = $project_id; + + // Or do we want to overwrite it? + if (!$category_id) + { + $sql = 'SELECT category_id + FROM ' . PROJECT_PROJECTS_TABLE . " + WHERE project_id = $project_id"; + $result = $db->sql_query($sql, 604800); + $category_id = (int) $db->sql_fetchfield('category_id', false, $result); + $db->sql_freeresult($result); + } } if ($category_id) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2008-04-28 12:25:06
|
Revision: 274 http://phpbbproject.svn.sourceforge.net/phpbbproject/?rev=274&view=rev Author: lord_le_brand Date: 2008-04-28 05:25:11 -0700 (Mon, 28 Apr 2008) Log Message: ----------- Added tracker view_ticket mode Added table for commenting on tickets Extra permissions to be added... Modified Paths: -------------- trunk/develop/create_schema_files_phpbb3.php trunk/develop/permissions.txt trunk/phpbb3/root/includes/project/project_trackers.php Modified: trunk/develop/create_schema_files_phpbb3.php =================================================================== --- trunk/develop/create_schema_files_phpbb3.php 2008-04-27 21:53:02 UTC (rev 273) +++ trunk/develop/create_schema_files_phpbb3.php 2008-04-28 12:25:11 UTC (rev 274) @@ -1014,6 +1014,23 @@ ) ); + // Ticket comments + $schema_data['phpbb_project_tracker_comments'] = array( + 'COLUMNS' => array( + 'comment_id' => array('UINT:11', NULL, 'auto_increment'), + 'ticket_id' => array('UINT:11', '0'), + 'comment_title' => array('XSTEXT_UNI', ''), + 'comment_text' => array('TEXT_UNI', ''), + 'comment_author' => array('UINT', '0'), + 'comment_time' => array('TIMESTAMP', '0') + ), + 'PRIMARY_KEY' => 'comment_id', + 'KEYS' => array( + 'ticket_id' => array('INDEX', 'ticket_id'), + 'comment_time' => array('INDEX', 'comment_time'), + ) + ); + //------------------------------------------ // Modified: trunk/develop/permissions.txt =================================================================== --- trunk/develop/permissions.txt 2008-04-27 21:53:02 UTC (rev 273) +++ trunk/develop/permissions.txt 2008-04-28 12:25:11 UTC (rev 274) @@ -12,22 +12,25 @@ Extend or modify most others (when I understand them all some more...) -Assigned by authors (All per project): +Assigned by authors: [?] -- View the mod -- Edit mod -- Delete the mod -- Download the mod -- Add authors -- Remove authors -- Manage project roles and permissions -- View docs -- Manage docs +- View the project (per project) +- Edit project (per project) +- Delete the project (per project) +- Download the project (per project) +- Add authors to project (per project) +- Remove authors from project (per project) +- Manage project roles and permissions (per project) +- View docs (per project [per doc?]) +- Manage docs (per project) +- Add tickets in tracker (per tracker) +- Comment in tickets (per tracker) +- Manage tickets (per tracker) [maybe split up in edit, delete, set status, etc] -Assigned by admin: +Assigned by admin: [?] - Create a mod (global) -- View category (per category) // How (<< What's this about??) +- View category (per category) // How [<- What's this about???] - Add MODs to category (per category) - Manage categories (global) - Manage roles/permissions (global) Modified: trunk/phpbb3/root/includes/project/project_trackers.php =================================================================== --- trunk/phpbb3/root/includes/project/project_trackers.php 2008-04-27 21:53:02 UTC (rev 273) +++ trunk/phpbb3/root/includes/project/project_trackers.php 2008-04-28 12:25:11 UTC (rev 274) @@ -21,7 +21,7 @@ * * @package phpbbproject */ -class project_tracker +class project_trackers { public $u_action; public $tpl_name; @@ -42,6 +42,7 @@ $tracker_id = request_var('tid', 0); $tracker_category = request_var('tcat', 0); $ticket_id = request_var('ticket', 0); + $start = request_var('start', 0); switch ($mode) { @@ -104,6 +105,16 @@ )); } + $sql = 'SELECT COUNT(t.*) AS num_tickets + FROM ' . PROJECT_TRACKER_TICKETS_TABLE . ' t, ' . PROJECT_TRACKER_CATEGORIES_TABLE . " c + WHERE t.tracker_id = $tracker_id + " . (($tracker_category) ? "AND t.tracker_category = $tracker_category" : '') . ' + AND c.category_id = t.tracker_category + ' . ((!$is_author) ? 'AND c.is_private = 0' : ''); + $result = $db->sql_query($sql, 604800); + $num_tickets = $db->sql_fetchfield('num_tickets', false, $result); + $db->sql_freeresult($result); + $sql = 'SELECT t.*, c.*, s.* FROM ' . PROJECT_TRACKER_TICKETS_TABLE . ' t, ' . PROJECT_TRACKER_CATEGORIES_TABLE . ' c, ' . PROJECT_TRACKER_STATUS_TABLE . " s WHERE t.tracker_id = $tracker_id @@ -112,7 +123,7 @@ AND s.tracker_status_id = t.ticket_status ' . ((!$is_author) ? 'AND c.is_private = 0' : '') . ' ORDER BY ticket.ticket_time DESC'; - $result = $db->sql_query($sql, 604800); + $result = $db->sql_query_limit($sql, $config['project_tracker_tickets_per_page'], $start, 604800); $tickets = $db->sql_fetchrowset($result); $db->sql_freeresult($result); @@ -129,7 +140,91 @@ )); } + $pagination = generate_pagination(append_sid(PROJECT_BASE_URL, "i=trackers&mode=tickets" . _module_trackers_url('tickets', array())), $num_tickets, $config['project_tracker_tickets_per_page'], $start); + break; + + case 'view_ticket': + + if (!$ticket_id) + { + if ($tracker_id) + { + redirect(append_sid(PROJECT_BASE_URL, 'i=trackers&mode=tickets' . _module_trackers_url('tickets', array()))); + } + else + { + redirect(append_sid(PROJECT_BASE_URL, 'i=trackers&mode=overview')); + } + } + + // Display: Full ticket, category title, tracker (type) title, ticket status, author + // OMFG! See the size of this baby O_O; + $sql = 'SELECT t.*, c.category_title, c.is_private, type.tracker_type_title, tracker.tracker_id, s.*, u.username, u.user_colour + FROM ' . PROJECT_TRACKER_TICKETS_TABLE . ' t, ' . PROJECT_TRACKER_CATEGORIES_TABLE . ' c, ' . PROJECT_TRACKERS_TABLE . ' tracker, ' . PROJECT_TRACKER_TYPES_TABLE . ' tt, ' . PROJECT_TRACKER_STATUS_TABLE . ' s, ' . USERS_TABLE . " u + WHERE t.ticket_id = $ticket_id + AND c.category_id = t.tracker_category + AND type.tracker_type_id = tracker.tracker_type + AND tracker_tracker_id = t.tracker_id + AND s.status_id = t.ticket_status + AND u.user_id = t.ticket_author"; + $result = $db->sql_query($sql, 604800); + $ticket_info = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($ticket_info['is_private'] && !$is_author) + { + // @todo Die, you hacker! + } + + $sql = 'SELECT COUNT(*) AS num_comments + FROM ' . PROJECT_TRACKER_COMMENTS_TABLE . " + WHERE ticket_id = $ticket_id"; + $result = $db->sql_query($sql, 604800); + $num_comments = $db->sql_fetchfield('num_comments', false, $result); + $db->sql_freeresult($result); + + $sql = 'SELECT c.*, u.username, u.user_colour + FROM ' . PROJECT_TRACKER_COMMENTS_TABLE . ' c, ' . USERS_TABLE . " u + WHERE c.ticket_id = $ticket_id + ORDER BY c.comment_time ASC"; + $result = $db->sql_query_limit($sql, $config['project_tracker_comments_per_page'], $start, 86400); + $comments = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + for ($i = 0, $size = sizeof($comments); $i < $size; $i++) + { + $template->assign_block_vars('comment_row', array( + 'COMMENT_TITLE' => $comments[$i]['comment_title'], + 'COMMENT_TEXT' => $comments[$i]['comment_text'], + 'COMMENT_DATE' => $user->format_date($comments[$i]['comment_time']), + 'COMMENT_AUTHOR' => get_username_string('full', $comments[$i]['comment_author'], $comments[$i]['username'], $comments[$i]['user_colour']), + )); + } + + $template->assign_vars(array( + 'TRACKER_TITLE' => $ticket_info['tracker_title'], + 'CATEGORY_TITLE' => $ticket_info['category_title'], + + 'TICKET_TITLE' => $ticket_info['ticket_title'], + 'TICKET_DESCRIPTION' => $ticket_info['ticket_description'], + 'TICKET_DATE' => $user->format_date($ticket_info['ticket_time']), + 'TICKET_AUTHOR' => get_username_string('full', $ticket_info['ticket_author'], $ticket_info['username'], $ticket_info['user_colour']), + 'TICKET_STATUS' => $ticket_info['status_title'], + + 'PAGINATION' => $pagination, + )); + + // @todo Commenting stuff + + break; + + /** + * @todo Add modes: + * - add ticket + * - manage tickets + * - more... + */ } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2008-05-04 00:34:39
|
Revision: 276 http://phpbbproject.svn.sourceforge.net/phpbbproject/?rev=276&view=rev Author: lord_le_brand Date: 2008-05-03 17:34:46 -0700 (Sat, 03 May 2008) Log Message: ----------- Removed/Commented out all auth stuff for now: wait for poyntesm's patch Updated constants.php and create_schema_files_phpbb3.php Added project_build_select() for buidling dropdown boxes Tracker should be done soonish :) Modified Paths: -------------- trunk/develop/create_schema_files_phpbb3.php trunk/develop/permissions.txt trunk/develop/todo_list.txt trunk/phpbb3/root/includes/project/project_main.php trunk/phpbb3/root/includes/project/project_trackers.php trunk/phpbb3/root/includes/sources_project/constants.php trunk/phpbb3/root/includes/sources_project/create_project.php trunk/phpbb3/root/includes/sources_project/extensions.php trunk/phpbb3/root/includes/sources_project/functions_project.php trunk/phpbb3/root/project.php Modified: trunk/develop/create_schema_files_phpbb3.php =================================================================== --- trunk/develop/create_schema_files_phpbb3.php 2008-04-30 00:35:28 UTC (rev 275) +++ trunk/develop/create_schema_files_phpbb3.php 2008-05-04 00:34:46 UTC (rev 276) @@ -821,15 +821,6 @@ ) ); - $schema_data['phpbb_project_project_authors'] = array( - 'COLUMNS' => array( - 'project_id' => array('UINT', '0'), - 'author_id' => array('UINT', '0'), - 'author_role' => array('UINT', '0'), - ), - 'PRIMARY_KEY' => array('project_id, author_id'), - ); - //------------------------------------------ // @@ -941,6 +932,14 @@ //------------------------------------------ // + // Permissions + // + + // @todo New table to work with poyntesm's auth patch + + //------------------------------------------ + + // // Trackers // Modified: trunk/develop/permissions.txt =================================================================== --- trunk/develop/permissions.txt 2008-04-30 00:35:28 UTC (rev 275) +++ trunk/develop/permissions.txt 2008-05-04 00:34:46 UTC (rev 276) @@ -1,17 +1,7 @@ Permissions for phpBB Project: -We're gonna have to make one or more new tables for permission masks. -This is because, apparently, the forum_id really isn't supposed to be used for something else. >_> +Wait for poyntesm to finish his patch for the auth class -New auth methods: - -- acl_getp($opt, $clean = false) - Like acl_getf($opt, $clean = false) but for projects -- acl_getc($opt, $clean = false) - Like acl_getf($opt, $clean = false) but for categories - -Extend or modify most others (when I understand them all some more...) - Assigned by authors: [?] - View the project (per project) Modified: trunk/develop/todo_list.txt =================================================================== --- trunk/develop/todo_list.txt 2008-04-30 00:35:28 UTC (rev 275) +++ trunk/develop/todo_list.txt 2008-05-04 00:34:46 UTC (rev 276) @@ -2,8 +2,6 @@ - Make a TODO tracker!!! - When at it make a bug tracker and feature tracker :) -- Extend auth class and create new permission tables -- Change the way authors are tied to projects (acl_roles or new equivalent) - Add /languages and /templates support to download (and import) class - Author ordering in MOD(X) file/project overview page - Definitive decision on storing versioned files @@ -11,6 +9,8 @@ - Expand validate_project_title() - Decide on what information will go on view category module - Target version information +- Wait till poyntesm finishes his auth patch + - Change the way authors are tied to projects using acl tables? - Decide on better module structure - Modules: - Import project Modified: trunk/phpbb3/root/includes/project/project_main.php =================================================================== --- trunk/phpbb3/root/includes/project/project_main.php 2008-04-30 00:35:28 UTC (rev 275) +++ trunk/phpbb3/root/includes/project/project_main.php 2008-05-04 00:34:46 UTC (rev 276) @@ -72,8 +72,13 @@ // If top ten should be displayed, do so if ($config['project_display_top_ten']) { + /** + * @todo when auth extended, rewrite $acl_projects = array_keys($auth->acl_getf('p_view_project', true)); $project_ids = $db->sql_in_set('project_id', $acl_projects, false, true); + */ + $project_ids = '1 = 1'; + $optional_fields = ($config['project_autopost_enable']) ? ', topic_id' : ''; $sql = "SELECT project_id, project_title, project_description, project_downloads $optional_fields @@ -134,9 +139,11 @@ // There are categories here, so display them $acl_categories = array(); $category_ids = '1 = 1'; - // Rewrite next line when auth class is extended - // $acl_categories = array_keys($auth->acl_getf('p_view_category', true)); - //$category_ids = $db->sql_in_set('category_id', $acl_categories, false, true); + /** + * @todo when auth extended, rewrite + $acl_categories = array_keys($auth->acl_getf('p_view_category', true)); + $category_ids = $db->sql_in_set('category_id', $acl_categories, false, true); + */ $sql = 'SELECT * FROM ' . PROJECT_CATEGORIES_TABLE . " @@ -243,8 +250,12 @@ $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); + /** + * @todo when auth extended, rewrite $acl_projects = array_keys($auth->acl_getf('p_view_project', true)); $project_ids = $db->sql_in_set('project_id', $acl_projects, false, true); + */ + $project_ids = '1 = 1'; $sql = "SELECT project_id, topic_id, project_title, project_description, project_level, project_install_time, project_target_version, project_version, project_stage, project_start_time, project_owner, project_last_update, project_downloads FROM " . PROJECT_PROJECTS_TABLE . " @@ -438,8 +449,12 @@ )); } + /** + * @todo when auth extended, rewrite $acl_categories = array_keys($auth->acl_getf('p_view_category', true)); $category_ids = $db->sql_in_set('category_id', $acl_categories, false, true); + */ + $category_ids = '1 = 1'; $sql = 'SELECT * FROM ' . PROJECT_CATEGORIES_TABLE . " Modified: trunk/phpbb3/root/includes/project/project_trackers.php =================================================================== --- trunk/phpbb3/root/includes/project/project_trackers.php 2008-04-30 00:35:28 UTC (rev 275) +++ trunk/phpbb3/root/includes/project/project_trackers.php 2008-05-04 00:34:46 UTC (rev 276) @@ -230,8 +230,39 @@ case 'add_ticket': + if (isset($_POST['submit'])) + { + // Check data and insert + } + // General tracker data + $sql = 'SELECT ty.tracker_type_title + FROM ' . PROJECT_TRACKER_TYPES_TABLE . ' ty, ' . PROJECT_TRACKERS_TABLE . " tr + WHERE ty.tracker_type_id = tr.tracker_type + AND tr.tracker_id = $tracker_id"; + $result = $db->sql_query($sql, 604800); + $tracker_title = $db->sql_fetchfield('tracker_type_title', false, $result); + $db->sql_freeresult($result); + // Get category dropdown + $sql = 'SELECT * + FROM ' . PROJECT_TRACKER_CATEGORIES_TABLE . " + WHERE tracker_id = $tracker_id" . ((!$is_author) ? ' AND is_private = 0' : ''); + $result = $db->sql_query($sql, 604800); + + while ($row = $db->sql_fetchrow($result)) + { + $category_select[$row['category_id']] = $row['category_title']; + } + $db->sql_freeresult($result); + + $template->assign_vars(array( + 'PROJECT_TITLE' => $project_title, + 'TRACKER_TITLE' => $tracker_title, + + 'S_CATEGORIES_SELECT' => project_build_select($category_select, $category_id), + )); + break; /** Modified: trunk/phpbb3/root/includes/sources_project/constants.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/constants.php 2008-04-30 00:35:28 UTC (rev 275) +++ trunk/phpbb3/root/includes/sources_project/constants.php 2008-05-04 00:34:46 UTC (rev 276) @@ -81,14 +81,14 @@ define('PROJECT_DOCUMENTATION_TABLE', $table_prefix . 'project_documentation'); define('PROJECT_LICENSES_TABLE', $table_prefix . 'project_licenses'); define('PROJECT_MARX_TABLE', $table_prefix . 'project_marx'); -define('PROJECT_PROJECT_AUTHORS_TABLE', $table_prefix . 'project_project_authors'); define('PROJECT_PROJECTS_TABLE', $table_prefix . 'project_projects'); define('PROJECT_SEARCH_WORDMATCH_TABLE', $table_prefix . 'project_search_wordmatch'); define('PROJECT_TRACKERS_TABLE', $table_prefix . 'project_trackers'); define('PROJECT_TRACKER_CATEGORIES_TABLE', $table_prefix . 'project_tracker_categories'); -define('PROJECT_TRACKER_ENTRIES_TABLE', $table_prefix . 'project_tracker_entries'); +define('PROJECT_TRACKER_COMMENTS_TABLE', $table_prefix . 'project_tracker_comments'); define('PROJECT_TRACKER_STATUS_TABLE', $table_prefix . 'project_tracker_status'); define('PROJECT_TRACKER_TYPES_TABLE', $table_prefix . 'project_tracker_types'); +define('PROJECT_TRACKER_TICKETS_TABLE', $table_prefix . 'project_tracker_tickets'); define('PROJECT_VERSIONS_TABLE', $table_prefix . 'project_versions'); ?> \ No newline at end of file Modified: trunk/phpbb3/root/includes/sources_project/create_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/create_project.php 2008-04-30 00:35:28 UTC (rev 275) +++ trunk/phpbb3/root/includes/sources_project/create_project.php 2008-05-04 00:34:46 UTC (rev 276) @@ -39,7 +39,8 @@ { global $auth, $user; - // Check permissions + /** + * @todo Rewrite this when auth class is extended if (!$auth->acl_get('p_add_project')) { $this->error = $user->lang['PROJECT_NOT_AUTH_CREATE']; @@ -50,6 +51,7 @@ $this->error = $user->lang['PROJECT_NOT_AUTH_CAT']; return; } + */ // Time & date of project creation $this->current_time = time(); Modified: trunk/phpbb3/root/includes/sources_project/extensions.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/extensions.php 2008-04-30 00:35:28 UTC (rev 275) +++ trunk/phpbb3/root/includes/sources_project/extensions.php 2008-05-04 00:34:46 UTC (rev 276) @@ -17,14 +17,8 @@ } /** - * phpBB Project Auth extension - * - * @package phpbbproject + * @todo poyntesm's patch is gonna be here, once it's released */ -class project_auth extends auth -{ - // Do stuff with extra tables... -} /** * phpBB Project Module extension @@ -91,6 +85,7 @@ $project_id = ($project_id === false) ? $this->acl_project_id : $project_id; $is_auth = false; + // @todo Rewrite this for auth extension eval('$is_auth = (int) (' . preg_replace(array('#acl_([a-z_]+)(,\$(?:c_|pr_|)id)?#', '#\$id#', '#\$c_id#', '#\$pr_id#', '#aclf_([a-z_]+)#', '#cfg_([a-z_]+)#', '#request_([a-z_]+)#'), array('(int) $auth->acl_get(\'\\1\'\\2)', '(int) $forum_id', '(int) $category_id', '(int) $project_id', '(int) $auth->acl_getf_global(\'\\1\')', '(int) $config[\'\\1\']', '!empty($_REQUEST[\'\\1\'])'), $module_auth) . ');'); return $is_auth; Modified: trunk/phpbb3/root/includes/sources_project/functions_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/functions_project.php 2008-04-30 00:35:28 UTC (rev 275) +++ trunk/phpbb3/root/includes/sources_project/functions_project.php 2008-05-04 00:34:46 UTC (rev 276) @@ -37,6 +37,39 @@ } /** + * Build proper select box + * + * @param array $select_ary associative array containing the value/title pairs + * @param boolean|string $default Default selected value, false for none + * @param boolean|string $lang_key Key for nested language entries + * @return unknown + */ +function project_build_select($select_ary, $default = false, $lang_key = false) +{ + global $user; + + if ($lang_key) + { + $lang =& $user->lang[$lang_key]; + } + else + { + $lang =& $user->lang; + } + + $html = ''; + + foreach ($select_ary as $value => $title) + { + $title = (isset($lang[$title])) ? $lang[$title] : $title; + $selected = ($default !== false && $default == $value) ? ' selected="selected"' : ''; + $html .= "<option value=\"$value\"$selected>$title</option>\n"; + } + + return $html; +} + +/** * Merge file and diff * * @param string $original Modified: trunk/phpbb3/root/project.php =================================================================== --- trunk/phpbb3/root/project.php 2008-04-30 00:35:28 UTC (rev 275) +++ trunk/phpbb3/root/project.php 2008-05-04 00:34:46 UTC (rev 276) @@ -23,9 +23,9 @@ define('PROJECT_BASE_URL', "{$phpbb_root_path}project.$phpEx"); -// phpBB Project Auth extension -//unset($auth); -//$auth = new project_auth(); +/** + * @todo Initiate poyntesm's auth patch + */ // Basic parameter data $id = request_var('i', ''); @@ -45,6 +45,8 @@ $category_id = request_var('c', 0); $action = request_var('action', ''); +/** + * @todo Rewrite this for auth extension // If the user doesn't have any project permissions (globally or locally) he can't access any modules... if (!$auth->acl_getf_global('p_')) { @@ -62,6 +64,7 @@ { trigger_error($user->lang['PROJECT_NOT_AUTH_CAT']); } + */ if ($project_id) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2008-05-05 19:20:09
|
Revision: 277 http://phpbbproject.svn.sourceforge.net/phpbbproject/?rev=277&view=rev Author: lord_le_brand Date: 2008-05-05 12:20:09 -0700 (Mon, 05 May 2008) Log Message: ----------- Rearrage trackers module Added license_description Use project_build_select() for categories and licenses Modified Paths: -------------- trunk/develop/create_schema_files_phpbb3.php trunk/develop/todo_list.txt trunk/phpbb3/root/includes/project/project_main.php trunk/phpbb3/root/includes/project/project_trackers.php trunk/phpbb3/root/styles/prosilver/template/project_create.html Modified: trunk/develop/create_schema_files_phpbb3.php =================================================================== --- trunk/develop/create_schema_files_phpbb3.php 2008-05-04 00:34:46 UTC (rev 276) +++ trunk/develop/create_schema_files_phpbb3.php 2008-05-05 19:20:09 UTC (rev 277) @@ -1100,11 +1100,12 @@ $schema_data['phpbb_project_licenses'] = array( 'COLUMNS' => array( - 'license_id' => array('TINT:3', NULL, 'auto_increment'), - 'license_title' => array('XSTEXT_UNI', ''), - 'license_acronym' => array('VCHAR:15', ''), - 'license_text' => array('MTEXT_UNI', ''), - 'license_url' => array('STEXT_UNI', ''), + 'license_id' => array('TINT:3', NULL, 'auto_increment'), + 'license_title' => array('XSTEXT_UNI', ''), + 'license_acronym' => array('VCHAR:15', ''), + 'license_description' => array('TEXT_UNI', ''), + 'license_text' => array('MTEXT_UNI', ''), + 'license_url' => array('STEXT_UNI', ''), ), 'PRIMARY_KEY' => 'license_id', ); Modified: trunk/develop/todo_list.txt =================================================================== --- trunk/develop/todo_list.txt 2008-05-04 00:34:46 UTC (rev 276) +++ trunk/develop/todo_list.txt 2008-05-05 19:20:09 UTC (rev 277) @@ -1,7 +1,5 @@ Todo list for phpBB Project -- Make a TODO tracker!!! -- When at it make a bug tracker and feature tracker :) - Add /languages and /templates support to download (and import) class - Author ordering in MOD(X) file/project overview page - Definitive decision on storing versioned files @@ -17,7 +15,12 @@ - Manage project - Diff generator - Docs (perhaps wiki-style?) - - Trackers script++ (also needed for this todo list, so step on it! xD) + - Trackers script + - Ticket actions + - Comments + - Manage actions + - Info file + - Template files - Projects Team CP (maybe a new *CP?) - Marx - Search Modified: trunk/phpbb3/root/includes/project/project_main.php =================================================================== --- trunk/phpbb3/root/includes/project/project_main.php 2008-05-04 00:34:46 UTC (rev 276) +++ trunk/phpbb3/root/includes/project/project_main.php 2008-05-05 19:20:09 UTC (rev 277) @@ -456,7 +456,7 @@ */ $category_ids = '1 = 1'; - $sql = 'SELECT * + $sql = 'SELECT category_id, category_title FROM ' . PROJECT_CATEGORIES_TABLE . " WHERE $category_ids ORDER BY left_id ASC"; @@ -467,7 +467,7 @@ $parent_id = 0; $padding = 0; - $padding_delimiter = '--'; + $padding_delimiter = ' '; for ($i = 0, $size = sizeof($categories); $i < $size; $i++) { @@ -476,30 +476,32 @@ $padding += ($categories[$i]['parent_id'] == $categories[$i-1]['category_id']) ? 1 : -1; } - $template->assign_block_vars('category', array( - 'CATEGORY_ID' => $categories[$i]['category_id'], - 'CATEGORY_TITLE' => str_repeat($padding_delimiter, $padding) . $categories[$i]['category_title'], - )); + $category_select[$categories[$i]['category_id']] = str_repeat($padding_delimiter, $padding) . $categories[$i]['category_title']; } $sql = 'SELECT license_id, license_title FROM ' . PROJECT_LICENSES_TABLE; $result = $db->sql_query($sql, 604800); - $licenses = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - for ($i = 0, $size = sizeof($licenses); $i < $size; $i++) + $license_select = array(); + while ($row = $db->sql_fetchrow($result)) { - $template->assign_block_vars('license', array( - 'LICENSE_ID' => $licenses[$i]['license_id'], - 'LICENSE_TITLE' => $licenses[$i]['license_title'], - )); + $license_select[$row['license_id']] = $row['license_title']; } + $db->sql_freeresult($result); /** * @todo Add description javascript + query */ + $category_id = (isset($data['category_id'])) ? $data['category_id'] : 0; + $license_id = (isset($data['project_license'])) ? $data['project_license'] : 0; + + $template->assign_vars(array( + 'CATEGORY_SELECT' => project_build_select($category_select, $category_id), + 'LICENSE_SELECT' => project_build_select($license_select, $license_id), + )); + add_form_key('project_create'); $this->tpl_name = 'project_create'; Modified: trunk/phpbb3/root/includes/project/project_trackers.php =================================================================== --- trunk/phpbb3/root/includes/project/project_trackers.php 2008-05-04 00:34:46 UTC (rev 276) +++ trunk/phpbb3/root/includes/project/project_trackers.php 2008-05-05 19:20:09 UTC (rev 277) @@ -43,6 +43,7 @@ $tracker_category = request_var('tcat', 0); $ticket_id = request_var('ticket', 0); $start = request_var('start', 0); + $action = request_var('action', ''); $sql = 'SELECT project_title FROM ' . PROJECT_PROJECTS_TABLE . " @@ -56,17 +57,15 @@ switch ($mode) { default: - case 'overview': + case 'main': // Get trackers for this project - $sql = 'SELECT t.*, types.*, COUNT(tc.*) AS tracker_categories, COUNT(tickets.*) AS tracker_tickets - FROM ' . PROJECT_TRACKERS_TABLE . ' t, ' . PROJECT_TRACKER_TYPES_TABLE . ' types, ' . PROJECT_TRACKER_CATEGORIES_TABLE . ' tc, ' . PROJECT_TRACKER_ENTRIES_TABLE . " tickets + $sql = 'SELECT t.*, ty.* + FROM ' . PROJECT_TRACKERS_TABLE . ' t, ' . PROJECT_TRACKER_TYPES_TABLE . " ty WHERE t.project_id = $project_id - AND types.tracker_type_id = t.tracker_type - AND tickets.tracker_id = t.tracker_id - AND tc.tracker_id = t.tracker_id + AND ty.tracker_type_id = t.tracker_type GROUP BY t.tracker_id - ORDER BY types.tracker_type_title ASC"; + ORDER BY ty.tracker_type_title ASC"; $result = $db->sql_query($sql, 604800); $trackers = $db->sql_fetchrowset($result); @@ -77,43 +76,22 @@ $template->assign_block_vars('tracker_row', array( 'TRACKER_TITLE' => $trackers[$i]['tracker_type_title'], 'TRACKER_DESCRIPTION' => $trackers[$i]['tracker_type_description'], - 'TRACKER_TICKETS' => $trackers[$i]['tracker_tickets'], - 'TRACKER_CATEGORIES' => $trackers[$i]['tracker_categories'], - 'U_TRACKER' => append_sid(PROJECT_BASE_URL, "i=trackers&mode=tickets&tid={$trackers[$i]['tracker_id']}"), + 'U_TRACKER' => _module_trackers_url(append_sid(PROJECT_BASE_URL, "i=trackers&mode=tracker&tid={$trackers[$i]['tracker_id']}")), )); } break; - case 'tickets': + case 'tracker': // Just redirect if $tracker_id is 0 if (!$tracker_id) { - $url_extra = _module_trackers_url('tickets', array()); - redirect(append_sid(PROJECT_BASE_URL, "i=trackers&mode=overview")); + $url_extra = _module_trackers_url('tracker', array()); + redirect(_module_trackers_url(append_sid(PROJECT_BASE_URL, 'i=trackers&mode=main'))); } - if ($tracker_category) - { - $sql = 'SELECT * - FROM ' . PROJECT_TRACKER_CATEGORIES_TABLE . " - WHERE category_id = $tracker_category"; - $result = $db->sql_query($sql, 604800); - $category_info = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($category_info['is_private'] && !$is_author) - { - // @todo some error... - } - - $template->assign_vars(array( - // @todo stuff... - )); - } - $sql = 'SELECT COUNT(t.*) AS num_tickets FROM ' . PROJECT_TRACKER_TICKETS_TABLE . ' t, ' . PROJECT_TRACKER_CATEGORIES_TABLE . " c WHERE t.tracker_id = $tracker_id @@ -136,6 +114,21 @@ $tickets = $db->sql_fetchrowset($result); $db->sql_freeresult($result); + // Get category dropdown + $sql = 'SELECT * + FROM ' . PROJECT_TRACKER_CATEGORIES_TABLE . " + WHERE tracker_id = $tracker_id" . ((!$is_author) ? ' AND is_private = 0' : ''); + $result = $db->sql_query($sql, 604800); + + $category_select = array($user->lang['PROJECT_ALL_CATEGORIES']); + while ($row = $db->sql_fetchrow($result)) + { + $category_select[$row['category_id']] = $row['category_title']; + } + $db->sql_freeresult($result); + + $category_select = project_build_select($category_select, $category_id); + for ($i = 0, $size = sizeof($tickets); $i < $size; $i++) { $template->assign_block_vars('ticket_row', array( @@ -145,132 +138,169 @@ 'TICKET_AUTHOR' => get_username_string('full', $tickets[$i]['ticket_author'], project_get_author_name($tickets[$i]['ticket_author'])), 'TICKET_TIME' => $user->format_date($tickets[$i]['ticket_time']), - 'U_VIEW_TICKET' => append_sid(PROJECT_BASE_URL, "i=trackers&mode=view_ticket&tid=$tracker_id&ticket={$trackers[$i]['ticket_id']}"), + 'U_VIEW_TICKET' => _module_trackers_url(append_sid(PROJECT_BASE_URL, "i=trackers&mode=ticket&ticket={$trackers[$i]['ticket_id']}")), )); } - $pagination = generate_pagination(append_sid(PROJECT_BASE_URL, "i=trackers&mode=tickets" . _module_trackers_url('tickets', array())), $num_tickets, $config['project_tracker_tickets_per_page'], $start); + $pagination = generate_pagination(_module_trackers_url(append_sid(PROJECT_BASE_URL, "i=trackers&mode=tracker" . 'tracker', array())), $num_tickets, $config['project_tracker_tickets_per_page'], $start); break; - case 'view_ticket': + case 'ticket': if (!$ticket_id) { if ($tracker_id) { - redirect(append_sid(PROJECT_BASE_URL, 'i=trackers&mode=tickets' . _module_trackers_url('tickets', array()))); + redirect(_module_trackers_url(append_sid(PROJECT_BASE_URL, 'i=trackers&mode=tracker' . 'tracker', array()))); } else { - redirect(append_sid(PROJECT_BASE_URL, 'i=trackers&mode=overview')); + redirect(_module_trackers_url(append_sid(PROJECT_BASE_URL, 'i=trackers&mode=main'))); } } - // Display: Full ticket, category title, tracker (type) title, ticket status, author - // OMFG! See the size of this baby O_O; - $sql = 'SELECT t.*, c.category_title, c.is_private, type.tracker_type_title, tracker.tracker_id, s.*, u.username, u.user_colour - FROM ' . PROJECT_TRACKER_TICKETS_TABLE . ' t, ' . PROJECT_TRACKER_CATEGORIES_TABLE . ' c, ' . PROJECT_TRACKERS_TABLE . ' tracker, ' . PROJECT_TRACKER_TYPES_TABLE . ' tt, ' . PROJECT_TRACKER_STATUS_TABLE . ' s, ' . USERS_TABLE . " u - WHERE t.ticket_id = $ticket_id - AND c.category_id = t.tracker_category - AND type.tracker_type_id = tracker.tracker_type - AND tracker_tracker_id = t.tracker_id - AND s.status_id = t.ticket_status - AND u.user_id = t.ticket_author"; - $result = $db->sql_query($sql, 604800); - $ticket_info = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($ticket_info['is_private'] && !$is_author) + switch ($action) { - // @todo Die, you hacker! - } + default: - $sql = 'SELECT COUNT(*) AS num_comments - FROM ' . PROJECT_TRACKER_COMMENTS_TABLE . " - WHERE ticket_id = $ticket_id"; - $result = $db->sql_query($sql, 604800); - $num_comments = $db->sql_fetchfield('num_comments', false, $result); - $db->sql_freeresult($result); + // Display: Full ticket, category title, tracker (type) title, ticket status, author + // OMFG! See the size of this baby O_O; + $sql = 'SELECT t.*, c.category_title, c.is_private, type.tracker_type_title, tracker.tracker_id, s.*, u.username, u.user_colour, COUNT(tc.*) as num_comments + FROM ' . PROJECT_TRACKER_TICKETS_TABLE . ' t, ' . PROJECT_TRACKER_CATEGORIES_TABLE . ' c, ' . PROJECT_TRACKERS_TABLE . ' tracker, ' . PROJECT_TRACKER_TYPES_TABLE . ' tt, ' . PROJECT_TRACKER_STATUS_TABLE . ' s, ' . USERS_TABLE . ' u, ' . PROJECT_TRACKER_COMMENTS_TABLE . " tc + WHERE t.ticket_id = $ticket_id + AND c.category_id = t.tracker_category + AND type.tracker_type_id = tracker.tracker_type + AND tracker_tracker_id = t.tracker_id + AND s.status_id = t.ticket_status + AND u.user_id = t.ticket_author + AND tc.ticket_id = t.ticket_id + GROUP BY t.ticket_id"; + $result = $db->sql_query($sql, 604800); + $ticket_info = $db->sql_fetchrow($result); + $db->sql_freeresult($result); - $sql = 'SELECT c.*, u.username, u.user_colour - FROM ' . PROJECT_TRACKER_COMMENTS_TABLE . ' c, ' . USERS_TABLE . " u - WHERE c.ticket_id = $ticket_id - ORDER BY c.comment_time ASC"; - $result = $db->sql_query_limit($sql, $config['project_tracker_comments_per_page'], $start, 86400); - $comments = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); + if ($ticket_info['is_private'] && !$is_author) + { + // @todo Die, you hacker! + } - for ($i = 0, $size = sizeof($comments); $i < $size; $i++) - { - $template->assign_block_vars('comment_row', array( - 'COMMENT_TITLE' => $comments[$i]['comment_title'], - 'COMMENT_TEXT' => $comments[$i]['comment_text'], - 'COMMENT_DATE' => $user->format_date($comments[$i]['comment_time']), - 'COMMENT_AUTHOR' => get_username_string('full', $comments[$i]['comment_author'], $comments[$i]['username'], $comments[$i]['user_colour']), - )); - } + $sql = 'SELECT c.*, u.username, u.user_colour + FROM ' . PROJECT_TRACKER_COMMENTS_TABLE . ' c, ' . USERS_TABLE . " u + WHERE c.ticket_id = $ticket_id + ORDER BY c.comment_time ASC"; + $result = $db->sql_query_limit($sql, $config['project_tracker_comments_per_page'], $start, 86400); + $comments = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); - $template->assign_vars(array( - 'TRACKER_TITLE' => $ticket_info['tracker_title'], - 'CATEGORY_TITLE' => $ticket_info['category_title'], + for ($i = 0, $size = sizeof($comments); $i < $size; $i++) + { + $template->assign_block_vars('comment_row', array( + 'COMMENT_TITLE' => $comments[$i]['comment_title'], + 'COMMENT_TEXT' => $comments[$i]['comment_text'], + 'COMMENT_DATE' => $user->format_date($comments[$i]['comment_time']), + 'COMMENT_AUTHOR' => get_username_string('full', $comments[$i]['comment_author'], $comments[$i]['username'], $comments[$i]['user_colour']), + )); + } - 'TICKET_TITLE' => $ticket_info['ticket_title'], - 'TICKET_DESCRIPTION' => $ticket_info['ticket_description'], - 'TICKET_DATE' => $user->format_date($ticket_info['ticket_time']), - 'TICKET_AUTHOR' => get_username_string('full', $ticket_info['ticket_author'], $ticket_info['username'], $ticket_info['user_colour']), - 'TICKET_STATUS' => $ticket_info['status_title'], + $template->assign_vars(array( + 'TRACKER_TITLE' => $ticket_info['tracker_title'], + 'CATEGORY_TITLE' => $ticket_info['category_title'], - 'PAGINATION' => $pagination, - )); + 'TICKET_TITLE' => $ticket_info['ticket_title'], + 'TICKET_DESCRIPTION' => $ticket_info['ticket_description'], + 'TICKET_DATE' => $user->format_date($ticket_info['ticket_time']), + 'TICKET_AUTHOR' => get_username_string('full', $ticket_info['ticket_author'], $ticket_info['username'], $ticket_info['user_colour']), + 'TICKET_STATUS' => $ticket_info['status_title'], - // @todo Commenting stuff + 'PAGINATION' => $pagination, + )); - break; + break; - case 'add_ticket': + case 'new': - if (isset($_POST['submit'])) - { - // Check data and insert + if (isset($_POST['submit'])) + { + // Check data and insert + } + + // General tracker data + $sql = 'SELECT ty.tracker_type_title + FROM ' . PROJECT_TRACKER_TYPES_TABLE . ' ty, ' . PROJECT_TRACKERS_TABLE . " tr + WHERE ty.tracker_type_id = tr.tracker_type + AND tr.tracker_id = $tracker_id"; + $result = $db->sql_query($sql, 604800); + $tracker_title = $db->sql_fetchfield('tracker_type_title', false, $result); + $db->sql_freeresult($result); + + // Get category dropdown + $sql = 'SELECT * + FROM ' . PROJECT_TRACKER_CATEGORIES_TABLE . " + WHERE tracker_id = $tracker_id" . ((!$is_author) ? ' AND is_private = 0' : ''); + $result = $db->sql_query($sql, 604800); + + while ($row = $db->sql_fetchrow($result)) + { + $category_select[$row['category_id']] = $row['category_title']; + } + $db->sql_freeresult($result); + + $template->assign_vars(array( + 'PROJECT_TITLE' => $project_title, + 'TRACKER_TITLE' => $tracker_title, + + 'CATEGORIES_SELECT' => project_build_select($category_select, $category_id), + 'U_ACTION' => $this->u_action . '&action=new', + )); + + break; + + case 'edit': + + + break; + + case 'delete': + + + break; } - // General tracker data - $sql = 'SELECT ty.tracker_type_title - FROM ' . PROJECT_TRACKER_TYPES_TABLE . ' ty, ' . PROJECT_TRACKERS_TABLE . " tr - WHERE ty.tracker_type_id = tr.tracker_type - AND tr.tracker_id = $tracker_id"; - $result = $db->sql_query($sql, 604800); - $tracker_title = $db->sql_fetchfield('tracker_type_title', false, $result); - $db->sql_freeresult($result); + break; - // Get category dropdown - $sql = 'SELECT * - FROM ' . PROJECT_TRACKER_CATEGORIES_TABLE . " - WHERE tracker_id = $tracker_id" . ((!$is_author) ? ' AND is_private = 0' : ''); - $result = $db->sql_query($sql, 604800); + case 'comment': - while ($row = $db->sql_fetchrow($result)) + + break; + + // Manage trackers + case 'manage': + + switch ($action) { - $category_select[$row['category_id']] = $row['category_title']; - } - $db->sql_freeresult($result); + default: - $template->assign_vars(array( - 'PROJECT_TITLE' => $project_title, - 'TRACKER_TITLE' => $tracker_title, - 'S_CATEGORIES_SELECT' => project_build_select($category_select, $category_id), - )); + break; + case 'add': + + + break; + + case 'edit': + + + break; + + case 'delete': + + + break; + } + break; - - /** - * @todo Add modes: - * - add ticket - * - manage tickets - * - more... - */ } } } Modified: trunk/phpbb3/root/styles/prosilver/template/project_create.html =================================================================== --- trunk/phpbb3/root/styles/prosilver/template/project_create.html 2008-05-04 00:34:46 UTC (rev 276) +++ trunk/phpbb3/root/styles/prosilver/template/project_create.html 2008-05-05 19:20:09 UTC (rev 277) @@ -11,8 +11,8 @@ <!-- IF ERROR --><dl><dd class="error">{ERROR}</dd></dl><!-- ENDIF --> <dl> <dt><label for="project_category">{L_PROJECT_CATEGORY}</label></dt> - <dd><select tabindex="1" name="project_category" id="project_category" title="{L_PROJECT_CATEGORY}"><!-- BEGIN category --> - <option value="{category.CATEGORY_ID}"<!-- IF category.CATEGORY_ID == CATEGORY_ID --> selected="selected"<!-- ENDIF -->>{category.CATEGORY_TITLE}</option><!-- END --> + <dd><select tabindex="1" name="project_category" id="project_category" title="{L_PROJECT_CATEGORY}"> + {CATEGORY_SELECT} </select></dd> </dl> <dl> @@ -29,8 +29,8 @@ </dl> <dl> <dt><label for="project_license">{L_PROJECT_LICENSE}:</label></dt> - <dd><select tabindex="5" name="project_license" id="project_license" title="{L_PROJECT_LICENSE}" onchange="set_description(this.value)"><!-- BEGIN license --> - <option value="{license.LICENSE_ID}"<!-- IF (license.S_STANDARD && not PROJECT_LICENSE) || license.LICENSE_ID == PROJECT_LICENSE --> selected="selected"<!-- ENDIF -->>{license.LICENSE_TITLE}</option><!-- END --> + <dd><select tabindex="5" name="project_license" id="project_license" title="{L_PROJECT_LICENSE}" onchange="set_description(this.value)"> + {LICENSE_SELECT} </select> <!--noscript><input type="submit" name="license_description" value="{L_PROJECT_DISPLAY_LICENSE_DESC}" class="button2" /></noscript> <span id="license_description">{LICENSE_DESCRIPTION}</span--></dd> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |