class ForumAdmin extends Error {
var $group_id;
var $p,$g;
-
+
function ForumAdmin($group_id) {
- $this->group_id = $group_id;
+ $this->Error();
+ $this->group_id = $group_id;
if ($group_id) {
$this->group_id = $group_id;
$this->g = group_get_object($group_id);
$this->p =& $this->g->getPermission ();
+ if (!$this->g->usesForum()) {
+ $this->setError(sprintf(_('%s does not use the Forum tool'),
+ $this->g->getPublicName()));
+ return false;
+ }
}
}
-
+
/**
* PrintAdminMessageOptions - prints the different administrator options for a message
*
* @param integer The Forum ID : to return to the message if the user cancels (forumhtml only, not message.php)
* @return The HTML output
*/
-
+
function PrintAdminMessageOptions($msg_id,$group_id,$thread_id=0,$forum_id=0,$return_to_message=0) {
-
+
$return = '<a href="admin/index.php?movethread=' . $thread_id . '&msg_id=' . $msg_id . '&group_id=' . $group_id . '&forum_id=' . $forum_id .
'&return_to_message=' . $return_to_message . '">' . html_image('ic/forum_move.gif','37','15',array('alt'=>_('Move thread'))). "</a>";
// $return .= "<br />";
return $return;
}
-
+
/**
* PrintAdminOptions - prints the different administrator option for the forums (heading).
*
*/
-
+
function PrintAdminOptions() {
global $group_id,$forum_id;
-
+
echo '
<p>
<a href="index.php?group_id='.$group_id.'&add_forum=1">'._('Add forum').'</a>';
echo '
| <a href="pending.php?action=view_pending&group_id=' . $group_id . '">' . _('Manage Pending Messages').'</a><br /></p>';
}
-
+
/**
* PrintAdminOptions - prints the administrator option for an individual forum, to link to the pending messages management
*
* @param int The Forum ID.
*/
-
+
function PrintAdminPendingOption($forum_id) {
echo '
<p>
<a href="pending.php?action=view_pending&group_id=' . $this->group_id . '&forum_id=' . $forum_id . '">' . _('Manage Pending Messages').'</a><br /></p>';
}
-
+
/**
* GetPermission - Gets the permission for the user
*
function &GetPermission() {
return $this->p;
}
-
+
/**
* GetGroupObject - Gets the group object of the forum
*
function &GetGroupObject() {
return $this->g;
}
-
+
/**
* isGroupAdmin - checks whether the authorized user is a group admin for the forums. The user must be authenticated
*
function isGroupAdmin() {
return forge_check_perm ('forum_admin', $this->group_id) ;
}
-
+
/**
* Authorized - authorizes and returns true if the user is authorized for the group, or false.
*
* @param string The group id.
*/
-
+
function Authorized($group_id) {
if (!$group_id) {
$this->setGroupIdError();
}
return true;
}
-
+
/**
* ExecuteAction - Executes the action passed as parameter
*
* @param string action to execute.
*/
function ExecuteAction ($action) {
- global $HTML;
-
+ global $HTML;
+
$feedback='';
if ($action == "change_status") { //change a forum
$forum_name = getStringFromRequest('forum_name');
$description = getStringFromRequest('description');
$send_all_posts_to = getStringFromRequest('send_all_posts_to');
- $allow_anonymous = getIntFromRequest('allow_anonymous');
- $is_public = getIntFromRequest('is_public');
- $moderation_level = getIntFromRequest('moderation_level');
$group_forum_id = getIntFromRequest('group_forum_id');
/*
Change a forum
session_require_perm ('forum_admin', $f->Group->getID()) ;
- if (!$f->update($forum_name,$description,$allow_anonymous,$is_public,$send_all_posts_to,$moderation_level)) {
+ if (!$f->update($forum_name,$description,0,0,$send_all_posts_to,0)) {
exit_error($f->getErrorMessage(),'forums');
} else {
$feedback = _('Forum Info Updated Successfully');
if ($action == "add_forum") { //add forum
$forum_name = getStringFromRequest('forum_name');
$description = getStringFromRequest('description');
- $is_public = getStringFromRequest('is_public');
$send_all_posts_to = getStringFromRequest('send_all_posts_to');
- $allow_anonymous = getStringFromRequest('allow_anonymous');
- $moderation_level = getIntFromRequest('moderation_level');
/*
Adding forums to this group
*/
form_release_key(getStringFromRequest("form_key"));
exit_error($f->getErrorMessage(),'forums');
}
- if (!$f->create($forum_name,$description,$is_public,$send_all_posts_to,1,$allow_anonymous,$moderation_level)) {
+ if (!$f->create($forum_name,$description,0,$send_all_posts_to,1,0,0)) {
form_release_key(getStringFromRequest("form_key"));
exit_error($f->getErrorMessage(),'forums');
} else {
array ($group_id));
if (!$res) {
echo db_error();
- return;
+ return;
}
-
+
$moderated_forums = array();
for ($i=0;$i<db_numrows($res);$i++) {
$aux = db_fetch_array($res);
$moderated_forums[$aux[1]] = $aux[0];
}
-
+
if (count($moderated_forums)==0) {
- echo $HTML->feedback(_('No forums are moderated for this group'));
+ echo $HTML->warning_msg(_('No forums are moderated for this group'));
forum_footer(array());
exit();
}
$keys = array_keys($moderated_forums);
$forum_id = $keys[0];
}
-
+
echo '
- <script type="text/javascript">
-
+ <script language="JavaScript" type="text/javascript">/* <![CDATA[ */
+
function confirmDel() {
var agree=confirm("' . _('Proceed? Actions are permanent!') . '");
if (agree) {
return false;
}
}
- </script>
+ /* ]]> */</script>
<form name="pending" action="pending.php" method="post">
<input type="hidden" name="action" value="update_pending" />
<input type="hidden" name="form_key" value="' . form_generate_key() . '" />
<input type="hidden" name="forum_id" value="' . $forum_id . '" />
';
-
+
echo html_build_select_box_from_assoc($moderated_forums,'forum_id',$forum_id);
echo ' <input name="Go" type="submit" value="Go" />';
-
+
$title = array();
$title[] = _('Forum Name');
$title[] = _('Message');
$title[] = "Action";
-
+
$res = db_query_params ('SELECT msg_id,subject,pm.group_forum_id,gl.forum_name FROM forum_pending_messages pm, forum_group_list gl WHERE pm.group_forum_id=$1 AND pm.group_forum_id=gl.group_forum_id AND gl.group_forum_id=$2',
array ($forum_id,
$forum_id));
if (!$res) {
echo db_error();
- return;
+ return;
}
//array with the supported actions
for($i=0;$i<db_numrows($res);$i++) {
$ids .= db_result($res,$i,'msg_id') . ",";
}
-
+
$i = 2;
echo $HTML->listTableTop($title);
while ($onemsg = db_fetch_array($res)) {
$url = "http://www.google.com";
echo "
<tr" . $HTML->boxGetAltRowStyle($i++). ">
- <td>$onemsg[forum_name]</td>
+ <td>$onemsg[forum_name]</td>
<td><a href=\"#\" onclick=\"window.open('pendingmsgdetail.php?msg_id=$onemsg[msg_id]&forum_id=$onemsg[group_forum_id]&group_id=$group_id','PendingMessageDetail','width=800,height=600,status=no,resizable=yes');\">$onemsg[subject]</a></td>
<td><div align=\"right\">" . html_build_select_box_from_assoc($options,"doaction[]",1) . "</div></td>
</tr>";
}
-
+
echo $HTML->listTableBottom();
echo '
<input type="hidden" name="msgids" value="' . $ids . '" />
$forum_id = getIntFromRequest("forum_id");
$msgids = getStringFromRequest("msgids");//the message ids to update
$doaction = getArrayFromRequest("doaction"); //the actions for the messages
-
+
$msgids = explode(",",$msgids);
array_pop($msgids);//this last one is empty
-
+
/*if ($this->isGroupAdmin()) {
$this->PrintAdminOptions();
}*/
-
+
$results = array(); //messages
for($i=0;$i<count($msgids);$i++) {
switch ($doaction[$i]) {
- case 1 : {
+ case 1 : {
//no action
break;
}
- case 2 : {
+ case 2 : {
//delete
db_begin();
if (!db_query_params ('DELETE FROM forum_pending_attachment WHERE msg_id=$1',
$feedback .= _('Forum deleted');
break;
}
- case 3 : {
+ case 3 : {
//release
$res1 = db_query_params ('SELECT * FROM forum_pending_messages WHERE msg_id=$1',
array ($msgids[$i]));
$deleteok = false;
}
}
-
+
if ( isset($am) && (is_object($am)) ) {
//if there was an attach, check if it was uploaded ok
if ((!$am->isError())) {
$deleteok = false;
}
}
-
+
if ($deleteok) {
//delete the message and attach
db_begin();