phpbbproject-svn Mailing List for phpBB Project (Page 3)
phpBB download manager, mainly aimed at MOD authors
Status: Planning
Brought to you by:
lord_le_brand
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
(13) |
May
(6) |
Jun
|
Jul
(7) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(3) |
Oct
(19) |
Nov
|
Dec
|
From: <lor...@us...> - 2008-04-23 23:59:38
|
Revision: 268 http://phpbbproject.svn.sourceforge.net/phpbbproject/?rev=268&view=rev Author: lord_le_brand Date: 2008-04-23 16:59:42 -0700 (Wed, 23 Apr 2008) Log Message: ----------- Create project functionally done (if it works that is...) Fixed small errors in download class Tidied up some code Modified Paths: -------------- trunk/phpbb3/root/includes/project/project_main.php trunk/phpbb3/root/includes/project/project_project.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/includes/sources_project/extensions.php trunk/phpbb3/root/styles/prosilver/template/project_create.html Modified: trunk/phpbb3/root/includes/project/project_main.php =================================================================== --- trunk/phpbb3/root/includes/project/project_main.php 2008-04-23 22:53:55 UTC (rev 267) +++ trunk/phpbb3/root/includes/project/project_main.php 2008-04-23 23:59:42 UTC (rev 268) @@ -15,7 +15,7 @@ */ class project_main { - var $u_action; + public $u_action; /** * Main method @@ -332,7 +332,7 @@ if ($import->error) { - trigger_error($user->lang['PROJECT_IMPORT_FAILURE'] . ':<br /><br />' . $message, E_USER_WARNING); + trigger_error($user->lang['PROJECT_IMPORT_FAILURE'] . ':<br /><br />' . $import->error, E_USER_WARNING); } } @@ -365,6 +365,18 @@ 'file_only' => (request_var('file_only', false)) ? true : false, ); + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . ' + WHERE role_name = \'ROLE_PROJECT_MANAGER\''; + $result = $db->sql_query($sql, 604800); + $role_manager = $db->sql_fetchfield('role_id', false, $result); + $db->sql_freeresult($result); + + $authors = array(array( + 'author_id' => $user->data['user_id'], + 'author_role' => $role_manager, + )); + // Validate the title (Check duplicate, length, invalid chars, etc.) if (false !== ($title_err = validate_project_title($data['project_title']))) { @@ -408,8 +420,51 @@ )); } + $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 . " + WHERE $category_ids + ORDER BY left_id ASC"; + $result = $db->sql_query($sql, 604800); + $categories = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + $parent_id = 0; + $padding = 0; + + $padding_delimiter = '--'; + + for ($i = 0, $size = sizeof($categories); $i < $size; $i++) + { + if ($parent_id != $categories[$i]['category_id']) + { + $padding += ($categories[$i]['left_id'] > $categories[$i-1]['left_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'], + )); + } + + $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++) + { + $template->assign_block_vars('license', array( + 'LICENSE_ID' => $licenses[$i]['license_id'], + 'LICENSE_TITLE' => $licenses[$i]['license_title'], + )); + } + /** - * @todo Add queries for categories and licenses + * @todo Add description javascript + query */ add_form_key('project_create'); Modified: trunk/phpbb3/root/includes/project/project_project.php =================================================================== --- trunk/phpbb3/root/includes/project/project_project.php 2008-04-23 22:53:55 UTC (rev 267) +++ trunk/phpbb3/root/includes/project/project_project.php 2008-04-23 23:59:42 UTC (rev 268) @@ -15,8 +15,8 @@ */ class project_project { - var $u_action; - var $tpl_name; + public $u_action; + public $tpl_name; /** * Main method @@ -26,8 +26,8 @@ */ function main($id, $mode) { - global $auth, $db, $user, $template; - global $config, $phpbb_root_path, $phpEx; + global $db, $user, $template; + global $phpbb_root_path, $phpEx; global $project_id, $category_id; switch ($mode) Modified: trunk/phpbb3/root/includes/sources_project/constants.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/constants.php 2008-04-23 22:53:55 UTC (rev 267) +++ trunk/phpbb3/root/includes/sources_project/constants.php 2008-04-23 23:59:42 UTC (rev 268) @@ -4,7 +4,6 @@ * * @package phpbbproject * @version $Id$ - * @author Lord Le Brand <lor...@ho...> * @copyright (c) 2008 phpBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ Modified: trunk/phpbb3/root/includes/sources_project/create_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/create_project.php 2008-04-23 22:53:55 UTC (rev 267) +++ trunk/phpbb3/root/includes/sources_project/create_project.php 2008-04-23 23:59:42 UTC (rev 268) @@ -29,7 +29,7 @@ */ public function __construct($data, $authors) { - global $auth, $user, $config; + global $auth, $user; // Check permissions if (!$auth->acl_get('p_add_project')) @@ -90,12 +90,12 @@ $this->data['project_id'] = $project_id = $db->sql_nextid(); // Add all authors - for ($i = 0, $size = sizeof($authors); $i < $size; $i++) + for ($i = 0, $size = sizeof($this->authors); $i < $size; $i++) { $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'] + 'author_id' => $this->authors[$i]['author_id'], + 'author_role' => $this->authors[$i]['author_role_id'] ))); } @@ -199,12 +199,12 @@ $this->data['project_id'] = $project_id = $db->sql_nextid(); // Add all authors - for ($i = 0, $size = sizeof($authors); $i < $size; $i++) + for ($i = 0, $size = sizeof($this->authors); $i < $size; $i++) { $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'] + 'author_id' => $this->authors[$i]['author_id'], + 'author_role' => $this->authors[$i]['author_role_id'] ))); } Modified: trunk/phpbb3/root/includes/sources_project/download_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/download_project.php 2008-04-23 22:53:55 UTC (rev 267) +++ trunk/phpbb3/root/includes/sources_project/download_project.php 2008-04-23 23:59:42 UTC (rev 268) @@ -57,6 +57,7 @@ global $db; $this->project_id = $project_id; + $this->archive_type = $archive_type; $this->download_type = ($download_type == PROJECT_DOWNLOAD_EXPORT) ? PROJECT_DOWNLOAD_EXPORT : PROJECT_DOWNLOAD_NORMAL; $version_id = request_var('version_id', 0); @@ -103,7 +104,7 @@ if (in_array($this->archive_type, array('tar.gz', 'tar.bz2', 'tgz'))) { $mode = (file_exists("{$phpbb_root_path}store/phpbbproject/projects/downloads/$filename.$this->archive_type")) ? 'r' : 'w'; - $package = new compress_tar($mode, "{$phpbb_root_path}store/phpbbproject/projects/downloads/$filename.$this->archive_type"); + $this->package = new compress_tar($mode, "{$phpbb_root_path}store/phpbbproject/projects/downloads/$filename.$this->archive_type"); } else { @@ -213,7 +214,7 @@ */ protected function get_history() { - global $db; + global $db, $user; $stages_ary = array( PROJECT_STAGE_ALPHA => $user->lang['PROJECT_STAGE_ALPHA'], Modified: trunk/phpbb3/root/includes/sources_project/extensions.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/extensions.php 2008-04-23 22:53:55 UTC (rev 267) +++ trunk/phpbb3/root/includes/sources_project/extensions.php 2008-04-23 23:59:42 UTC (rev 268) @@ -33,8 +33,6 @@ */ function module_auth($module_auth, $forum_id = false, $category_id = false, $project_id = false) { - global $auth, $config; - $module_auth = trim($module_auth); // Generally allowed to access module if module_auth is empty Modified: trunk/phpbb3/root/styles/prosilver/template/project_create.html =================================================================== --- trunk/phpbb3/root/styles/prosilver/template/project_create.html 2008-04-23 22:53:55 UTC (rev 267) +++ trunk/phpbb3/root/styles/prosilver/template/project_create.html 2008-04-23 23:59:42 UTC (rev 268) @@ -2,11 +2,11 @@ <h2>{L_PROJECT_CREATE_PROJECT}</h2> -<div class="panel"> - <div class="inner"> - <span class="corners-top"><span></span></span> +<form id="project_create" action="{U_ACTION}" method="post"{S_FORM_ENCTYPE}> + <div class="panel"> + <div class="inner"> + <span class="corners-top"><span></span></span> - <form action="{U_ACTION}" method="post"> <fieldset class="fields2"> <!-- IF ERROR --><dl><dd class="error">{ERROR}</dd></dl><!-- ENDIF --> <dl> @@ -32,18 +32,23 @@ <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 --> </select> - <span id="license_description">{LICENSE_DESCRIPTION}</span></dd> + <!--noscript><input type="submit" name="license_description" value="{L_PROJECT_DISPLAY_LICENSE_DESC}" class="button2" /></noscript> + <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"<!-- IF FILE_ONLY --> checked="checked"<!-- ENDIF --> /></dd> </dl> - {S_FORM_TOKEN} </fieldset> - </form> - - <span class="corners-bottom"><span></span></span> + <span class="corners-bottom"><span></span></span> + </div> </div> -</div> + <fieldset class="submit-buttons"> + {S_HIDDEN_FIELDS}<input type="reset" value="{L_RESET}" name="reset" class="button2" /> + <input type="submit" name="submit" value="{L_SUBMIT}" class="button1" /> + {S_FORM_TOKEN} + </fieldset> +</form> + <!-- INCLUDE project_footer.html --> \ No newline at end of file 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-23 20:21:09
|
Revision: 266 http://phpbbproject.svn.sourceforge.net/phpbbproject/?rev=266&view=rev Author: lord_le_brand Date: 2008-04-23 13:21:14 -0700 (Wed, 23 Apr 2008) Log Message: ----------- Moved functions_project.php to /includes/sources_project Moved functions used in creating/updating projects (including autopost) to /includes/sources_project/functions_create.php Added Paths: ----------- trunk/phpbb3/root/includes/sources_project/functions_create.php trunk/phpbb3/root/includes/sources_project/functions_project.php Removed Paths: ------------- trunk/phpbb3/root/includes/functions_project.php Deleted: trunk/phpbb3/root/includes/functions_project.php =================================================================== --- trunk/phpbb3/root/includes/functions_project.php 2008-04-23 19:51:18 UTC (rev 265) +++ trunk/phpbb3/root/includes/functions_project.php 2008-04-23 20:21:14 UTC (rev 266) @@ -1,259 +0,0 @@ -<?php -/** - * phpBB Project functions - * - * @package phpbbproject - * @version $Id$ - * @copyright (c) 2008 phpBB Project Team - * @license http://opensource.org/licenses/gpl-license.php GNU Public License - */ - -/** - * Validate project title - * - * @param string $project_title - * @param mixed $allowed_title - * @return mixed Either false if validation succeeds, or the error message - */ -function validate_project_title($project_title, $allowed_title = false) -{ - global $config, $db; - - $clean_title = utf8_clean_string($project_title); - $allowed_title = ($allowed_title === false) ? false : utf8_clean_string($allowed_title); - - if ($allowed_title !== false && $clean_title == $allowed_title) - { - return false; - } - - // Check the length - if ($config['project_title_min_chars'] && $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']) - { - return 'PROJECT_TITLE_TOO_LONG'; - } - - // Check if the title exists already in the database - $sql = 'SELECT project_id - FROM ' . PROJECT_PROJECTS_TABLE . ' - WHERE project_title_clean = \'' . $db->sql_escape($clean_title) . "'"; - - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - return 'PROJECT_TITLE_TAKEN'; - } - - /** - * @todo check invalid chars, and disallowed titles... - */ - - // All safe :-) - return false; -} - -/** - * Place included files in the correct folder with the correct filenames - * - * @param array $file_ary - * @param array $project_info - * @todo Decide on storing method, see {@link http://phpbbmodders.net/viewtopic.php?f=55&t=2450}. For now: the third method. - */ -function project_move_included_files($file_ary, $project_info) -{ - global $phpbb_root_path, $phpEx; - - // Include the diff engine - if (!class_exists('diff')) - { - require("{$phpbb_root_path}includes/diff/diff.$phpEx"); - require("{$phpbb_root_path}includes/diff/engine.$phpEx"); - require("{$phpbb_root_path}includes/diff/renderer.$phpEx"); - } - - // Set the store pathaccording to project ID - $store_path = "{$phpbb_root_path}store/phpbbproject/projects/{$project_info['project_id']}/files/"; - - // loop through files and store them - foreach ($file_ary as $file) - { - $file_path = $store_path . $file['file_path'] . '/' . $file['filename']; - - // If the directory exists, the file exists, get the oldest and diff it - if (is_dir($file_path)) - { - file_put_contents($file_path . '/newest', $file['file_content']); - $oldest = file_get_contents($file_path . '/oldest'); - - $diff = new diff($oldest, $file['file_content']); - $diff->get_diff(); - - $render = new diff_renderer_raw(); - $file_content = $render->render($diff); - file_put_contents($file_path . '/' . $project_info['version_time'], $file_content); - } - else - { - if (!@mkdir($file_path, 0755, true)) - { - trigger_error("Could not create directory $file_path", E_USER_ERROR); - } - - // Cool eh? Two files the same. Hurray for efficiency ;-) - file_put_contents($file_path . '/newest', $file['file_content']); - file_put_contents($file_path . '/oldest', $file['file_content']); - } - } -} - -/** - * Generate install time from action array - * - * @param array $actions - * @return integer - */ -function project_generate_install_time($actions) -{ - $time = 0; - - /** - * @todo Action-to-time ratio - */ - - return $time; -} - -/** - * Generate install level from action array or install time - * - * @param string $type - * @param mixed $parameter - * @return integer - */ -function project_generate_level($type, $parameter) -{ - global $user; - - $level = PROJECT_LEVEL_EASY; - - // Are we generating from actions, or from install time? - switch ($type) - { - case 'actions': - - if (!is_array($parameter)) - { - trigger_error('<strong>project_generate_level():</strong> type of $parameter not correct'); - } - - /** - * @todo Action-to-level ratio - */ - - break; - - case 'time': - - $time = (int) $parameter; - if ($time < 600) - { - $level = PROJECT_LEVEL_EASY; - } - if ($time >= 600 && $time < 1800) - { - $level = PROJECT_LEVEL_INTERMEDIATE; - } - if ($time >= 1800) - { - $level = PROJECT_LEVEL_ADVANCED; - } - - break; - - default: - - trigger_error('<strong>project_generate_level():</strong> $type not correct'); - - break; - } - - return $level; -} - -/** - * Get the author_username - * - * @param integer $user_id - * @return string - */ -function project_get_author_name($user_id) -{ - global $db; - - $sql = 'SELECT author_username - FROM ' . PROJECT_AUTHORS_TABLE . " - WHERE author_id = $user_id"; - $result = $db->sql_query($sql, 2592000); // Cache for a month O_O; - $author_name = $db->sql_fetchfield('author_username', false, $result); - $db->sql_freeresult($result); - - return $author_name; -} - -/** - * Merge file and diff - * - * @param string $original - * @param array $diff - * @return string - */ -function merge_file_diff($original, $diff) -{ - $search_string = array(); - $new_string = array(); - - for ($i = 0, $size = sizeof($diff); $i < $size; $i += 3) - { - $class_name = get_class($diff[$i+1]); - - switch ($class_name) - { - case 'diff_op_add': - - $search_string[] = implode("\n", $diff[$i]->orig) . "\n" . implode("\n", $diff[$i+2]->orig); - $new_string[] = implode("\n", $diff[$i]->orig) . "\n" . implode("\n", $diff[$i+1]->final) . "\n" . implode("\n", $diff[$i+2]->orig); - - break; - - case 'diff_op_delete': - - $search_string[] = implode("\n", $diff[$i]->orig) . "\n" . implode("\n", $diff[$i+1]->orig) . "\n" . implode("\n", $diff[$i+2]->orig); - $new_string[] = implode("\n", $diff[$i]->orig) . "\n" . implode("\n", $diff[$i+2]->orig); - - break; - - case 'diff_op_change': - - $search_string[] = implode("\n", $diff[$i]->orig) . "\n" . implode("\n", $diff[$i+1]->orig) . "\n" . implode("\n", $diff[$i+2]->orig); - $new_string[] = implode("\n", $diff[$i]->orig) . "\n" . implode("\n", $diff[$i+1]->final) . "\n" . implode("\n", $diff[$i+2]->orig); - - break; - - default: - - break; - } - } - - return str_replace($search_string, $new_string, $original); -} - -?> \ No newline at end of file Added: trunk/phpbb3/root/includes/sources_project/functions_create.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/functions_create.php (rev 0) +++ trunk/phpbb3/root/includes/sources_project/functions_create.php 2008-04-23 20:21:14 UTC (rev 266) @@ -0,0 +1,521 @@ +<?php +/** + * phpBB Project functions_create + * + * @package phpbbproject + * @version $Id:$ + * @copyright (c) 2008 phpBB Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + +/** + * Validate project title + * + * @param string $project_title + * @param mixed $allowed_title + * @return mixed Either false if validation succeeds, or the error message + */ +function validate_project_title($project_title, $allowed_title = false) +{ + global $config, $db; + + $clean_title = utf8_clean_string($project_title); + $allowed_title = ($allowed_title === false) ? false : utf8_clean_string($allowed_title); + + if ($allowed_title !== false && $clean_title == $allowed_title) + { + return false; + } + + // Check the length + if ($config['project_title_min_chars'] && $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']) + { + return 'PROJECT_TITLE_TOO_LONG'; + } + + // Check if the title exists already in the database + $sql = 'SELECT project_id + FROM ' . PROJECT_PROJECTS_TABLE . ' + WHERE project_title_clean = \'' . $db->sql_escape($clean_title) . "'"; + + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row) + { + return 'PROJECT_TITLE_TAKEN'; + } + + /** + * @todo check invalid chars, and disallowed titles... + */ + + // All safe :-) + return false; +} + +/** + * Place included files in the correct folder with the correct filenames + * + * @param array $file_ary + * @param array $project_info + * @todo Decide on storing method, see {@link http://phpbbmodders.net/viewtopic.php?f=55&t=2450}. For now: the third method. + */ +function project_move_included_files($file_ary, $project_info) +{ + global $phpbb_root_path, $phpEx; + + // Include the diff engine + if (!class_exists('diff')) + { + require("{$phpbb_root_path}includes/diff/diff.$phpEx"); + require("{$phpbb_root_path}includes/diff/engine.$phpEx"); + require("{$phpbb_root_path}includes/diff/renderer.$phpEx"); + } + + // Set the store pathaccording to project ID + $store_path = "{$phpbb_root_path}store/phpbbproject/projects/{$project_info['project_id']}/files/"; + + // loop through files and store them + foreach ($file_ary as $file) + { + $file_path = $store_path . $file['file_path'] . '/' . $file['filename']; + + // If the directory exists, the file exists, get the oldest and diff it + if (is_dir($file_path)) + { + file_put_contents($file_path . '/newest', $file['file_content']); + $oldest = file_get_contents($file_path . '/oldest'); + + $diff = new diff($oldest, $file['file_content']); + $diff->get_diff(); + + $render = new diff_renderer_raw(); + $file_content = $render->render($diff); + file_put_contents($file_path . '/' . $project_info['version_time'], $file_content); + } + else + { + if (!@mkdir($file_path, 0755, true)) + { + trigger_error("Could not create directory $file_path", E_USER_ERROR); + } + + // Cool eh? Two files the same. Hurray for efficiency ;-) + file_put_contents($file_path . '/newest', $file['file_content']); + file_put_contents($file_path . '/oldest', $file['file_content']); + } + } +} + +/** + * Generate install time from action array + * + * @param array $actions + * @return integer + */ +function project_generate_install_time($actions) +{ + $time = 0; + + /** + * @todo Action-to-time ratio + */ + + return $time; +} + +/** + * Generate install level from action array or install time + * + * @param string $type + * @param mixed $parameter + * @return integer + */ +function project_generate_level($type, $parameter) +{ + global $user; + + $level = PROJECT_LEVEL_EASY; + + // Are we generating from actions, or from install time? + switch ($type) + { + case 'actions': + + if (!is_array($parameter)) + { + trigger_error('<strong>project_generate_level():</strong> type of $parameter not correct'); + } + + /** + * @todo Action-to-level ratio + */ + + break; + + case 'time': + + $time = (int) $parameter; + if ($time < 600) + { + $level = PROJECT_LEVEL_EASY; + } + if ($time >= 600 && $time < 1800) + { + $level = PROJECT_LEVEL_INTERMEDIATE; + } + if ($time >= 1800) + { + $level = PROJECT_LEVEL_ADVANCED; + } + + break; + + default: + + trigger_error('<strong>project_generate_level():</strong> $type not correct'); + + break; + } + + return $level; +} + +/** + * 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 Property changes on: trunk/phpbb3/root/includes/sources_project/functions_create.php ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Copied: trunk/phpbb3/root/includes/sources_project/functions_project.php (from rev 261, trunk/phpbb3/root/includes/functions_project.php) =================================================================== --- trunk/phpbb3/root/includes/sources_project/functions_project.php (rev 0) +++ trunk/phpbb3/root/includes/sources_project/functions_project.php 2008-04-23 20:21:14 UTC (rev 266) @@ -0,0 +1,79 @@ +<?php +/** + * phpBB Project functions + * + * @package phpbbproject + * @version $Id$ + * @copyright (c) 2008 phpBB Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + +/** + * Get the author_username + * + * @param integer $user_id + * @return string + */ +function project_get_author_name($user_id) +{ + global $db; + + $sql = 'SELECT author_username + FROM ' . PROJECT_AUTHORS_TABLE . " + WHERE author_id = $user_id"; + $result = $db->sql_query($sql, 2592000); // Cache for a month O_O; + $author_name = $db->sql_fetchfield('author_username', false, $result); + $db->sql_freeresult($result); + + return $author_name; +} + +/** + * Merge file and diff + * + * @param string $original + * @param array $diff + * @return string + */ +function merge_file_diff($original, $diff) +{ + $search_string = array(); + $new_string = array(); + + for ($i = 0, $size = sizeof($diff); $i < $size; $i += 3) + { + $class_name = get_class($diff[$i+1]); + + switch ($class_name) + { + case 'diff_op_add': + + $search_string[] = implode("\n", $diff[$i]->orig) . "\n" . implode("\n", $diff[$i+2]->orig); + $new_string[] = implode("\n", $diff[$i]->orig) . "\n" . implode("\n", $diff[$i+1]->final) . "\n" . implode("\n", $diff[$i+2]->orig); + + break; + + case 'diff_op_delete': + + $search_string[] = implode("\n", $diff[$i]->orig) . "\n" . implode("\n", $diff[$i+1]->orig) . "\n" . implode("\n", $diff[$i+2]->orig); + $new_string[] = implode("\n", $diff[$i]->orig) . "\n" . implode("\n", $diff[$i+2]->orig); + + break; + + case 'diff_op_change': + + $search_string[] = implode("\n", $diff[$i]->orig) . "\n" . implode("\n", $diff[$i+1]->orig) . "\n" . implode("\n", $diff[$i+2]->orig); + $new_string[] = implode("\n", $diff[$i]->orig) . "\n" . implode("\n", $diff[$i+1]->final) . "\n" . implode("\n", $diff[$i+2]->orig); + + break; + + default: + + break; + } + } + + return str_replace($search_string, $new_string, $original); +} + +?> \ No newline at end of file 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 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-21 23:16:58
|
Revision: 263 http://phpbbproject.svn.sourceforge.net/phpbbproject/?rev=263&view=rev Author: lord_le_brand Date: 2008-04-21 16:17:05 -0700 (Mon, 21 Apr 2008) Log Message: ----------- renamed /branch to /branches added /tags Added Paths: ----------- branches/ tags/ Removed Paths: ------------- branch/ Copied: branches (from rev 260, branch) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |