} if ($cmd == 'manage') { $user = get_logged_in_user(); require_founder_login($user, $team); $forum = BoincForum::lookup("parent_type=1 and category={$teamid}"); if (!$forum) { create_confirm($user, $team); } else { edit_form($user, $team, $forum, false); } } else { if ($cmd == 'create') { $user = get_logged_in_user(); check_tokens($user->authenticator); require_founder_login($user, $team); create_forum($user, $team); } else { if ($cmd == 'edit_action') { $user = get_logged_in_user(); require_founder_login($user, $team); check_tokens($user->authenticator); $forum = BoincForum::lookup("parent_type=1 and category={$teamid}"); if (!$forum) { error_page("No forum"); } edit_action($forum); } else { if ($cmd == "remove_confirm") { $user = get_logged_in_user(); require_founder_login($user, $team); remove_confirm($user, $team);
function create_topic() { global $db, $lang; static $topic_created = false; static $topic_id = 0; $forum_id = create_forum(); if (!$topic_created) { $sql = 'INSERT INTO ' . TOPICS_TABLE . " (forum_id, topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_status, topic_type, topic_first_post_id, topic_last_post_id, topic_moved_id)\n\t\t\tVALUES ({$forum_id}, '" . $db->sql_escape($lang['New_topic_name']) . "', -1, " . time() . ", 0, 0, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ", 0, 0, 0)"; $db->sql_return_on_error(true); $result = $db->sql_query($sql); $db->sql_return_on_error(false); if (!$result) { throw_error("Couldn't update topics data!", __LINE__, __FILE__, $sql); } $topic_id = $db->sql_nextid(); $topic_created = true; } return $topic_id; }
$view = array(); $topics = array(); $replies = array(); $result = $db->query('SELECT g_id AS id,g_view_forums,g_post_topics,g_post_replies FROM `#^user_groups`') or enhanced_error('Failed to find user groups', true); while ($group = $db->fetch_assoc($result)) { if ($group['g_view_forums']) { $view[] = $group['id']; } if ($group['g_post_topics']) { $topics[] = $group['id']; } if ($group['g_post_replies']) { $replies[] = $group['id']; } } create_forum($_POST['category'], $_POST['name'], $view, $topics, $replies); } if (!isset($dirs[3])) { $dirs[3] = ''; } if ($dirs[3] == 'edit') { //this file is included because it can also be a stand-alone pop-up include FORUM_ROOT . '/app_resources/pages/admin/includes/edit_forum.php'; return; } if (isset($_POST['form_sent_forums'])) { foreach ($_POST['pos'] as $id => $pos) { $db->query('UPDATE `#^forums` SET sort_position=' . intval($pos) . ' WHERE id=' . intval($id)) or error('Failed to update forum', __FILE__, __LINE__, $db->error()); } $result = $db->query('SELECT id,url,name FROM `#^forums` ORDER BY id ASC') or error('Failed to get forums', __FILE__, __LINE__, $db->error()); while (list($id, $oldurl, $oldtitle) = $db->fetch_row($result)) {
} return mysql_insert_id(); } function create_forum($category, $orderID, $title, $description, $is_dev_blog = 0) { $q = "insert into forum (category, orderID, title, description, is_dev_blog) values ({$category}, {$orderID}, '{$title}', '{$description}', {$is_dev_blog})"; $result = mysql_query($q); if (!$result) { echo "can't create forum\n"; echo mysql_error(); exit; } return mysql_insert_id(); } db_init(); $catid = create_category(0, "", 0); create_forum($catid, 0, "News", "News from this project", 1); create_forum($catid, 1, "Science", "Discussion of this project\\'s science"); create_forum($catid, 2, "Number crunching", "Credit, leaderboards, CPU performance"); create_forum($catid, 3, "Cafe", "Meet and greet other participants"); $catid = create_category(0, "Platform-specific problems", 1); create_forum($catid, 0, "Windows", "Installing and running BOINC on Windows"); create_forum($catid, 1, "Unix/Linux", "Installing and running BOINC on Unix and Linux"); create_forum($catid, 2, "Macintosh", "Installing and running BOINC on Mac OS/X"); $catid = create_category(1, "General issues", 1); create_forum($catid, 3, "Getting started", "Creating your account"); create_forum($catid, 4, "Preferences", "Using preferences"); create_forum($catid, 5, "Wish list", "What new features would you like to see?"); create_forum($catid, 6, "Web site", "Issues involving this web site"); $cvs_version_tracker[] = "\$Id\$"; //Generated automatically - do not edit
exit; } return $db->insert_id(); } function create_forum($category, $orderID, $title, $description, $is_dev_blog = 0) { $q = "(category, orderID, title, description, is_dev_blog) values ({$category}, {$orderID}, '{$title}', '{$description}', {$is_dev_blog})"; $db = BoincDB::get(); $result = $db->insert("forum", $q); if (!$result) { $forum = BoincForum::lookup("category={$category} and title='{$title}'"); if ($forum) { return $forum->id; } echo "can't create forum\n"; echo $db->base_error(); exit; } return $db->insert_id(); } db_init(); $catid = create_category(0, "", 0); $catid = create_category(1, "General Discussion", 0); create_forum($catid, 0, "Announcements", "Announcements about Cosmology@Home"); create_forum($catid, 1, "General Topics", "General Discussion related to Cosmology@Home"); create_forum($catid, 2, "Wish list", "What features would you like to see in BOINC and Cosmology@Home"); create_forum($catid, 3, "Technical Support", "Problems with running Cosmology@Home"); $catid = create_category(2, "Cosmology@Home Science", 0); create_forum($catid, 4, "Cosmology and Astronomy", "Questions about the Science behind Cosmology@Home"); $cvs_version_tracker[] = "\$Id\$"; //Generated automatically - do not edit
$form->assign('catId', $catId); $dialogBox->form($form->render()); } catch (Exception $ex) { if (claro_debug_mode()) { $dialogBox->error('<pre>' . $ex->__toString() . '</pre>'); } else { $dialogBox->error($ex->getMessage()); } } } else { $dialogBox->error(get_lang('Unknown category')); } } if ('exMkForum' == $cmd) { if ($catId != 0) { if (create_forum($forumName, $forumDesc, $forumPostAllowed, $catId, $anonymityType)) { $dialogBox->success(get_lang('Forum created')); } else { $dialogBox->error(get_lang('Unable to create forum')); $cmd = 'rqMkForum'; } } else { $dialogBox->error(get_lang('Unknown category')); $cmd = 'rqMkForum'; } } if ('rqMkForum' == $cmd) { $categoryList = get_category_list(); if (count($categoryList) > 0) { try { $form = new ModuleTemplate('CLFRM', 'forum_editforum.tpl.php');
$cmd = 'rqMkCat'; } } if ($cmd == 'rqMkCat') { if (isset($_REQUEST['catName'])) { $catName = $_REQUEST['catName']; } else { $catName = ''; } $htmlAddCat = '<strong>' . get_lang('Add a category') . '</strong>' . '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">' . "\n" . '<input type="hidden" name="claroFormId" value="' . uniqid('') . '" />' . "\n" . '<input type="hidden" name="cmd" value="exMkCat" />' . "\n" . '<label for="catName">' . get_lang('Name') . ' : </label><br />' . "\n" . '<input type="text" name="catName" id="catName"' . ' value="' . $catName . '" /><br /><br />' . "\n" . '<input type="submit" value="' . get_lang('Ok') . '" /> ' . claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel')) . '</form>' . "\n"; $dialogBox->form($htmlAddCat); } if ($cmd == 'exMkForum') { $forumPostAllowed = isset($_REQUEST['forumPostUnallowed']) ? false : true; if (trim($_REQUEST['forumName']) != '' && 0 < (int) $_REQUEST['forumCatId']) { if (create_forum(trim($_REQUEST['forumName']), trim($_REQUEST['forumDesc']), $forumPostAllowed, (int) $_REQUEST['forumCatId'])) { $dialogBox->success(get_lang('Forum created')); } else { $dialogBox->error(get_lang('Unable to create forum')); $cmd = 'rqMkForum'; } } else { $dialogBox->error(get_lang('Missing field(s)')); $cmd = 'rqMkForum'; } } if ($cmd == 'rqMkForum') { $formCategoryList = get_category_list(); if (count($formCategoryList) > 0) { $catSelectBox = get_lang('Category') . ' : <br />' . "\n" . '<select name="forumCatId">'; foreach ($formCategoryList as $thisFormCategory) {
/** * Get or create team forum */ function get_or_create_team_forum($details, $parent_pid, $owner_gid) { // Get forum ID $fid = get_forum_id(PREFIX_FORUM . $details['t_name'], $parent_pid); if ($fid !== false) { return $fid; } // Not found? Create new $fid = create_forum(PREFIX_FORUM . $details['t_name'], $parent_pid, DESC_TEAM_FORUM); if (!$fid) { return false; } // Synchronize all forum permissions update_all_forum_permissions(); // Return forum ID return $fid; }
/** * Create a new group * * @param string $groupName - name of the group * @param integer $maxMember - max user allowed for this group * @return integer : id of the new group * * @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) */ function create_group($prefixGroupName, $maxMember) { require_once dirname(__FILE__) . '/forum.lib.php'; require_once dirname(__FILE__) . '/fileManage.lib.php'; $tbl_cdb_names = claro_sql_get_course_tbl(); $tbl_groups = $tbl_cdb_names['group_team']; // Check name of group $sql = "SELECT name FROM `" . $tbl_groups . "` WHERE name LIKE '" . claro_sql_escape($prefixGroupName) . "%'"; $existingGroupList = claro_sql_query_fetch_all_cols($sql); $existingGroupList = $existingGroupList['name']; $i = 1; do { $groupName = $prefixGroupName . str_pad($i, 4, ' ', STR_PAD_LEFT); $i++; if ($i - 2 > count($existingGroupList)) { die($groupName . 'infiniteloop'); } } while (in_array($groupName, $existingGroupList)); /** * Create a directory allowing group student to upload documents */ // Create a Unique ID path preventing other enter $globalPath = $GLOBALS['coursesRepositorySys'] . $GLOBALS['currentCourseRepository'] . '/group/'; do { $groupRepository = str_replace(' ', '_', substr(uniqid(substr($groupName, 0, 19) . ' ', ''), 0, 30)); } while (check_name_exist($globalPath . $groupRepository)); claro_mkdir($globalPath . $groupRepository, CLARO_FILE_PERMISSIONS); /* * Insert a new group in the course group table and keep its ID */ $sql = "INSERT INTO `" . $tbl_groups . "`\n SET name = '" . $groupName . "',\n `maxStudent` = " . (is_null($maxMember) ? 'NULL' : "'" . (int) $maxMember . "'") . ",\n secretDirectory = '" . claro_sql_escape($groupRepository) . "'"; $createdGroupId = claro_sql_query_insert_id($sql); /* * Create a forum for the group in the forum table */ if (is_tool_activated_in_course(get_tool_id_from_module_label('CLFRM'), claro_get_current_course_id()) && is_tool_activated_in_groups(claro_get_current_course_id(), 'CLFRM')) { create_forum($groupName . ' - ' . strtolower(get_lang('Forum')), '', 2, (int) GROUP_FORUMS_CATEGORY, '', $createdGroupId); } if (is_tool_activated_in_course(get_tool_id_from_module_label('CLWIKI'), claro_get_current_course_id()) && is_tool_activated_in_groups(claro_get_current_course_id(), 'CLWIKI')) { require_once get_module_path('CLWIKI') . '/lib/lib.createwiki.php'; create_wiki($createdGroupId, $groupName . ' - Wiki'); } return $createdGroupId; }
} else { echo $lang['Nothing_to_do']; } // Check for texts without a post echo "<p class=\"gen\"><b>" . $lang['Checking_texts_wo_post'] . "</b></p>\n"; $sql = "SELECT pt.post_id, pt.bbcode_uid, pt.post_text\n\t\t\t\t\tFROM " . POSTS_TEXT_TABLE . " pt\n\t\t\t\t\t\tLEFT JOIN " . POSTS_TABLE . " p ON pt.post_id = p.post_id\n\t\t\t\t\tWHERE p.post_id IS NULL"; $result = $db->sql_query($sql); if (!$result) { throw_error("Couldn't get post and text data!", __LINE__, __FILE__, $sql); } while ($row = $db->sql_fetchrow($result)) { if (!$list_open) { echo "<p class=\"gen\">" . $lang['Invalid_texts_found'] . ":</p>\n"; echo "<font class=\"gen\"><ul>\n"; $list_open = TRUE; $new_forum = create_forum(); $new_topic = create_topic(); $enable_html = $board_config['allow_html']; $enable_smilies = $board_config['allow_smilies']; } $enable_bbcode = $board_config['allow_bbcode'] && $row['bbcode_uid'] != '' ? 1 : 0; echo "<li>" . sprintf($lang['Recreating_post'], $row['post_id'], $lang['New_topic_name'], $lang['New_forum_name'], substr(htmlspecialchars(strip_tags($row['post_text'])), 0, 30)) . "</li>\n"; $sql2 = "INSERT INTO " . POSTS_TABLE . ' (post_id, topic_id, forum_id, poster_id, post_time, poster_ip, post_username, enable_bbcode, enable_html, enable_smilies, enable_sig, post_edit_time, post_edit_count) VALUES (' . $row['post_id'] . ", {$new_topic}, {$new_forum}, " . ANONYMOUS . ', ' . time() . ', \'\', \'' . $lang['New_poster_name'] . "', {$enable_bbcode}, {$enable_html}, {$enable_smilies}, 0, NULL, 0)"; $result2 = $db->sql_query($sql2); if (!$result2) { throw_error("Couldn't update post information!", __LINE__, __FILE__, $sql2); } } $db->sql_freeresult($result); if ($list_open) {
if ($group['g_view_forums']) { $view[] = $group['id']; } if ($group['g_post_topics']) { $topics[] = $group['id']; } if ($group['g_post_replies']) { $replies[] = $group['id']; } } foreach ($_POST['new_forum'] as $key => $forum_name) { $cat_id = intval($_POST['new_forum_cat'][$key]); if (isset($cat_mappings[$cat_id])) { $cat_id = $cat_mappings[$cat_id]; } create_forum($cat_id, $forum_name, $view, $topics, $replies, intval($_POST['sort_order'][$key])); } } //any categories to change? $result = $db->query('SELECT id,cat_id FROM `#^forums`') or enhanced_error('Failed to get forum list', true); while (list($forum, $cat) = $db->fetch_row($result)) { if (isset($_POST['cat'][$forum]) && $_POST['cat'][$forum] != '' && $cat != $_POST['cat'][$forum]) { $db->query('UPDATE `#^forums` SET cat_id=' . intval($_POST['cat'][$forum]) . ' WHERE id=' . $forum) or enhanced_error('Failed to update forum category', true); } } print_r($_POST); die; header('Refresh: 0'); return; } ?>