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.
|