| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
function forum_pagesetup() |
|---|
| 6 |
{ |
|---|
| 7 |
global $CFG, $PAGE, $page_owner; |
|---|
| 8 |
|
|---|
| 9 |
if (defined("context") && (context == "weblog") && run("users:type:get", page_owner()) == "community") |
|---|
| 10 |
{ |
|---|
| 11 |
// Add to the submenu |
|---|
| 12 |
$num = count($PAGE->menu_sub) + 1; |
|---|
| 13 |
|
|---|
| 14 |
$PAGE->menu_sub[$num]['name'] = "weblog:forum"; |
|---|
| 15 |
$PAGE->menu_sub[$num]['html'] = '<a href="'.$CFG->wwwroot . 'mod/forum/forum.php?weblog='.user_info('username',page_owner()).'">' . __gettext("View as Forum") . '</a>'; |
|---|
| 16 |
} |
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
} |
|---|
| 21 |
|
|---|
| 22 |
function forum_init() |
|---|
| 23 |
{ |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
global $function, $CFG, $page_owner, $profile_id, $db, $METATABLES; |
|---|
| 27 |
include(dirname(__FILE__) . '/config.php'); |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
if (in_array($CFG->prefix . "weblog_posts", $METATABLES)) { |
|---|
| 33 |
$messagesTable = $db->MetaColumnNames($CFG->prefix . "weblog_posts", true); |
|---|
| 34 |
// If dosn't exists adding the colummns 'last_updated' |
|---|
| 35 |
if (!in_array("last_updated", $messagesTable)) { |
|---|
| 36 |
if (file_exists($CFG->dirroot . "mod/forum/$CFG->dbtype.sql")) { |
|---|
| 37 |
modify_database($CFG->dirroot . "mod/forum/$CFG->dbtype.sql"); |
|---|
| 38 |
} else { |
|---|
| 39 |
error("Error: Your database ($CFG->dbtype) is not yet fully supported by the Elgg forum plug-in. See the mod/forum directory."); |
|---|
| 40 |
} |
|---|
| 41 |
print_continue($CFG->wwwroot); |
|---|
| 42 |
exit(); |
|---|
| 43 |
} |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
listen_for_event("weblog_post","publish","forum_publish_blog"); |
|---|
| 47 |
listen_for_event("weblog_post","republish","forum_publish_blog"); |
|---|
| 48 |
listen_for_event("weblog_post","delete","forum_publish_blog"); |
|---|
| 49 |
listen_for_event("weblog_comment","publish","forum_publish_blog"); |
|---|
| 50 |
listen_for_event("weblog_comment","delete","forum_publish_blog"); |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
//redirect some functions to use our custom pages for community details... |
|---|
| 55 |
$function['userdetails:edit:details'][] = $CFG->dirroot . "mod/forum/userdetails_edit.php"; |
|---|
| 56 |
$function['userdetails:init'][] = $CFG->dirroot . "mod/forum/userdetails_actions.php"; |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
foreach($function['display:sidebar'] as $key => $file) |
|---|
| 60 |
{ |
|---|
| 61 |
|
|---|
| 62 |
if ($file == $CFG->dirroot . "mod/blog/lib/weblogs_user_info_menu.php") |
|---|
| 63 |
{ |
|---|
| 64 |
$custom_sidebar=$CFG->dirroot . 'mod/forum/forum_user_info_menu.php'; |
|---|
| 65 |
$function['display:sidebar'][$key] = $custom_sidebar; |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
} // end function forum_init |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
function forum_publish_blog($object_type, $event, $object) |
|---|
| 75 |
{ |
|---|
| 76 |
global $CFG, $PAGE, $profile_id, $page_owner; |
|---|
| 77 |
global $redirect_url; |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
include(dirname(__FILE__) . '/config.php'); |
|---|
| 81 |
|
|---|
| 82 |
//echo run("users:type:get", page_owner()); |
|---|
| 83 |
|
|---|
| 84 |
if ($object_type == "weblog_comment") { |
|---|
| 85 |
$post = get_record('weblog_posts','ident',$object->post_id); |
|---|
| 86 |
$post_id = $post->ident; |
|---|
| 87 |
$community=$post->weblog; |
|---|
| 88 |
|
|---|
| 89 |
if ($forum_sort == 1){ |
|---|
| 90 |
//NOW UPDATE THE LAST_MODIFIED STATUS OF THE WEBLOG_POST TO BE NOW SO THAT WE CAN SORT ON THIS IN THE FORUM VIEW... |
|---|
| 91 |
$post->last_updated=time(); |
|---|
| 92 |
update_record('weblog_posts',$post); |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
} |
|---|
| 96 |
|
|---|
| 97 |
if ($object_type == "weblog_post") { |
|---|
| 98 |
$post_id = $object->ident; |
|---|
| 99 |
$community=$object->weblog; |
|---|
| 100 |
|
|---|
| 101 |
if ($forum_sort == 1){ |
|---|
| 102 |
//NOW UPDATE THE LAST_MODIFIED STATUS OF THE WEBLOG_POST TO BE NOW SO THAT WE CAN SORT ON THIS IN THE FORUM VIEW... |
|---|
| 103 |
$object->last_updated=time(); |
|---|
| 104 |
update_record('weblog_posts',$object); |
|---|
| 105 |
} |
|---|
| 106 |
} |
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
$forum_flag = user_flag_get('forum', $community); |
|---|
| 111 |
|
|---|
| 112 |
//echo $forum_flag; |
|---|
| 113 |
//echo $forum_default; |
|---|
| 114 |
|
|---|
| 115 |
if ((!$forum_flag) && ($forum_default == 0)) |
|---|
| 116 |
{ |
|---|
| 117 |
$use_forum= "yes"; |
|---|
| 118 |
} |
|---|
| 119 |
else if ((!$forum_flag) && ($forum_default == 1)) |
|---|
| 120 |
{ |
|---|
| 121 |
$use_forum= "no"; |
|---|
| 122 |
} |
|---|
| 123 |
else |
|---|
| 124 |
{ |
|---|
| 125 |
$use_forum= $forum_flag; |
|---|
| 126 |
} |
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
if ($use_forum == "yes" && run('users:type:get', $community) == 'community') |
|---|
| 130 |
{ |
|---|
| 131 |
if ($object_type == 'weblog_post') { |
|---|
| 132 |
if ($event == 'delete') { |
|---|
| 133 |
$community_record=get_record('users','ident',$community); |
|---|
| 134 |
$redirect_url = $CFG->wwwroot . 'mod/forum/forum.php?weblog=' . $community_record->username; |
|---|
| 135 |
define('redirect_url',$redirect_url); |
|---|
| 136 |
} else { |
|---|
| 137 |
$redirect_url = $CFG->wwwroot . 'mod/forum/forum_view_thread.php?post=' . $post_id; |
|---|
| 138 |
define('redirect_url',$redirect_url); |
|---|
| 139 |
} |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
if ($object_type == 'weblog_comment') { |
|---|
| 143 |
$redirect_url = $CFG->wwwroot . 'mod/forum/forum_view_thread.php?post=' . $post_id; |
|---|
| 144 |
define('redirect_url',$redirect_url); |
|---|
| 145 |
} |
|---|
| 146 |
|
|---|
| 147 |
} |
|---|
| 148 |
|
|---|
| 149 |
return $object; |
|---|
| 150 |
} |
|---|
| 151 |
|
|---|
| 152 |
?> |
|---|