Example #1
0
/**
 *	admin_table_add() - present a form for adding a record to the specified table
 *
 *	@param $table - the table to act on
 *	@param $unit - the name of the "units" described by the table's records
 *	@param $primary_key - the primary key of the table
 */
function admin_table_add($table, $unit, $primary_key)
{
    // This query may return no rows, but the field names are needed.
    $result = db_query('SELECT * FROM ' . $table . ' WHERE ' . $primary_key . '=0');
    $fields = array();
    if ($result) {
        $cols = db_numfields($result);
        printf(_('Create a new %1$s below:'), getUnitLabel($unit));
        echo '
			<form name="add" action="' . getStringFromServer('PHP_SELF') . '?function=postadd" method="post">
			<input type="hidden" name="form_key" value="' . form_generate_key() . '">
			<table>';
        for ($i = 0; $i < $cols; $i++) {
            $fieldname = db_fieldname($result, $i);
            $fields[] = $fieldname;
            echo '<tr><td><strong>' . $fieldname . '</strong></td>';
            echo '<td><input type="text" name="' . $fieldname . '" value="" /></td></tr>';
        }
        echo '</table><input type="submit" value="' . _('Add') . '" />
			<input type="hidden" name="__fields__" value="' . implode(',', $fields) . '">
			</form>
			<form name="cancel" action="' . getStringFromServer('PHP_SELF') . '" method="post">
			<input type="submit" value="' . _('Cancel') . '" />
			</form>';
    } else {
        echo db_error();
    }
}
Example #2
0
echo $ah->getSummary();
?>
</h3>

	<form action="<?php 
echo getStringFromServer('PHP_SELF');
?>
?group_id=<?php 
echo $group_id;
?>
&amp;atid=<?php 
echo $ath->getID();
?>
" METHOD="post" enctype="multipart/form-data">
	<input type="hidden" name="form_key" value="<?php 
echo form_generate_key();
?>
" />
	<input type="hidden" name="func" value="postmod" />
	<input type="hidden" name="artifact_id" value="<?php 
echo $ah->getID();
?>
" />

	<table width="80%">
<?php 
if (session_loggedin()) {
    ?>
		<tr>
			<td><?php 
    if ($ah->isMonitoring()) {
Example #3
0
<?php 
$theme_cssfile = $GLOBALS['sys_themeroot'] . $GLOBALS['sys_theme'] . '/css/theme.css';
if (file_exists($theme_cssfile)) {
    echo '
<link rel="stylesheet" type="text/css" href="' . util_make_url('/themes/' . $GLOBALS['sys_theme'] . '/css/theme.css') . '" />
';
}
echo '

</head>
<body>
<h1>' . $feedback . '</h1>

<table border="3" cellpadding="4" rules="groups" frame="box" width="100%" class="tablecontent">
	<form action="' . getStringFromServer('PHP_SELF') . '?func=query&group_id=' . $group_id . '&atid=' . $ath->getID() . '" method="post">
	<input type="hidden" name="form_key" value="' . form_generate_key() . '">
	<tr>
		<td>
			<input type="submit" name="submit" value="' . _('Save Changes') . '" />
		</td>
		<td>';
if (db_numrows($res) > 0) {
    echo html_build_select_box($res, 'query_id', $query_id, false) . '';
}
echo '
		</td>
	</tr>
	<tr class="tablecontent">
		<td>
		<input type="radio" name="query_action" value="1" ' . (!$query_id ? 'checked' : '') . '>' . _('Name and Save Query') . '<br />';
if (db_numrows($res) > 0) {
    /**
     *  ExecuteAction - Executes the action passed as parameter
     *
     *  @param  string	 action to execute.
     */
    function ExecuteAction($action)
    {
        global $HTML;
        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
            */
            $f = new Forum($this->g, $group_forum_id);
            if (!$f || !is_object($f)) {
                exit_error(_('Error'), _('Error getting Forum'));
            } elseif ($f->isError()) {
                exit_error(_('Error'), $f->getErrorMessage());
            }
            if (!$f->userIsAdmin()) {
                exit_permission_denied();
            }
            if (!$f->update($forum_name, $description, $allow_anonymous, $is_public, $send_all_posts_to, $moderation_level)) {
                exit_error(_('Error'), $f->getErrorMessage());
            } else {
                $feedback = _('Forum Info Updated Successfully');
            }
            return $feedback;
        }
        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
            */
            if (!$this->p->isForumAdmin()) {
                form_release_key(getStringFromRequest("form_key"));
                exit_permission_denied();
            }
            $f = new Forum($this->g);
            if (!$f || !is_object($f)) {
                form_release_key(getStringFromRequest("form_key"));
                exit_error(_('Error'), _('Error getting Forum'));
            } elseif ($f->isError()) {
                form_release_key(getStringFromRequest("form_key"));
                exit_error(_('Error'), $f->getErrorMessage());
            }
            if (!$f->create($forum_name, $description, $is_public, $send_all_posts_to, 1, $allow_anonymous, $moderation_level)) {
                form_release_key(getStringFromRequest("form_key"));
                exit_error(_('Error'), $f->getErrorMessage());
            } else {
                $feedback = _('Forum created successfully');
            }
            return $feedback;
        }
        if ($action == "delete") {
            //Deleting messages or threads
            $msg_id = getStringFromRequest('deletemsg');
            $forum_id = getIntFromRequest('forum_id');
            $f = new Forum($this->g, $forum_id);
            if (!$f || !is_object($f)) {
                exit_error(_('Error'), _('Error getting Forum'));
            } elseif ($f->isError()) {
                exit_error(_('Error'), $f->getErrorMessage());
            }
            if (!$f->userIsAdmin()) {
                exit_permission_denied();
            }
            $fm = new ForumMessage($f, $msg_id);
            if (!$fm || !is_object($fm)) {
                exit_error(_('Error'), _('Error Getting ForumMessage'));
            } elseif ($fm->isError()) {
                exit_error(_('Error'), $fm->getErrorMessage());
            }
            $count = $fm->delete();
            if (!$count || $fm->isError()) {
                exit_error(_('Error'), $fm->getErrorMessage());
            } else {
                $feedback = sprintf(ngettext('%1$s message deleted', '%1$s messages deleted', $count), $count);
            }
            return $feedback;
        }
        if ($action == "delete_forum") {
            //delete the forum
            /*
            	Deleting entire forum
            */
            $group_forum_id = getIntFromRequest('group_forum_id');
            $f = new Forum($this->g, $group_forum_id);
            if (!$f || !is_object($f)) {
                exit_error(_('Error'), _('Error getting Forum'));
            } elseif ($f->isError()) {
                exit_error(_('Error'), $f->getErrorMessage());
            }
            if (!$f->userIsAdmin()) {
                exit_permission_denied();
            }
            if (!$f->delete(getStringFromRequest('sure'), getStringFromRequest('really_sure'))) {
                exit_error(_('Error'), $f->getErrorMessage());
            } else {
                $feedback = _('Successfully Deleted');
            }
            return $feedback;
        }
        if ($action == "view_pending") {
            //show the pending messages, awaiting moderation
            $group_id = $this->group_id;
            $forum_id = getStringFromRequest("forum_id");
            if ($this->isGroupAdmin()) {
                $this->PrintAdminOptions();
            }
            $sql = "SELECT forum_name, group_forum_id FROM forum_group_list WHERE group_id='{$group_id}' and moderation_level > 0";
            $res = db_query($sql);
            if (!$res) {
                echo db_error();
                return;
            }
            global $sys_db_row_pointer;
            $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'));
                forum_footer(array());
                exit;
            }
            if (!$forum_id) {
                //get the first one
                $keys = array_keys($moderated_forums);
                $forum_id = $keys[0];
            }
            echo '
			<script language="JavaScript" type="text/javascript">
		
			function confirmDel() {
				var agree=confirm("Proceed? Actions are permanent!");
				if (agree) {
					return true;
				} else {
					return false;
				}
			}
			</script>
			<p><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="group_id" value="' . getIntFromRequest("group_id") . '" />
			<input type="hidden" name="forum_id" value="' . $forum_id . '" />

			';
            //$moderated_forums["A"] = "All Forums for this group"; // to show all
            echo html_build_select_box_from_assoc($moderated_forums, forum_id, $forum_id);
            echo '    <input name="Go" type="submit" value="Go"><p>';
            $title = array();
            $title[] = _('Forum Name');
            $title[] = _('Message');
            $title[] = "Action";
            $sql = "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='{$forum_id}' AND pm.group_forum_id=gl.group_forum_id AND gl.group_forum_id='{$forum_id}'";
            $res = db_query($sql);
            if (!$res) {
                echo db_error();
                return;
            }
            $options = array("1" => "No action", "2" => "Delete", "3" => "Release");
            //array with the supported actions
            //i�ll make a hidden variable, helps to determine when the user updates the info, which action corresponds to which msgID
            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 = 'pendingmsgdetail.php?msg_id=' . $onemsg[msg_id];
                //<a href=\"javascript:msgdetail('$url');\">$onemsg[subject]</a>
                $url = "http://www.google.com";
                echo "\n\t\t\t\t<tr" . $HTML->boxGetAltRowStyle($i++) . ">\n\t\t\t\t\t<td>{$onemsg['forum_name']}</td>\t\n\t\t\t\t\t<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>\n\t\t\t\t\t<td><div align=\"right\">" . html_build_select_box_from_assoc($options, "doaction[]", 1) . "</div></td>\n\t\t\t\t</tr>";
            }
            echo $HTML->listTableBottom();
            echo '
			<p>
			<input type="hidden" name="msgids" value="' . $ids . '">
			<div align="right"><input type="submit" onClick="return confirmDel();" name="update" value="' . _('Update') . '"></div>
			</form>
			';
        }
        if ($action == "update_pending") {
            $group_id = getIntFromRequest("group_id");
            $forum_id = getIntFromRequest("forum_id");
            $msgids = getStringFromRequest("msgids");
            //the message ids to update
            $doaction = getArrayFromRequest("doaction");
            //the actions for the messages
            $msgids = split(",", $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:
                        //no action
                        break;
                    case 2:
                        //delete
                        db_begin();
                        $sql = "DELETE FROM forum_pending_attachment WHERE msg_id='{$msgids[$i]}'";
                        if (!db_query($sql)) {
                            $feedback .= "DB Error ";
                            $feedback .= db_error() . "<br>";
                            db_rollback();
                            break;
                        }
                        $sql = "DELETE FROM forum_pending_messages WHERE msg_id='{$msgids[$i]}'";
                        if (!db_query($sql)) {
                            $feedback .= "DB Error ";
                            $feedback .= db_error() . "<br>";
                            db_rollback();
                            break;
                        }
                        db_commit();
                        $feedback .= _('Forum deleted');
                        break;
                    case 3:
                        //release
                        $sql = "SELECT * FROM forum_pending_messages WHERE msg_id='{$msgids[$i]}'";
                        $res1 = db_query($sql);
                        if (!$res1) {
                            $feedback .= "DB Error " . db_error() . "<br>";
                            break;
                        }
                        $sql = "SELECT * FROM forum_pending_attachment WHERE msg_id='{$msgids[$i]}'";
                        $res2 = db_query($sql);
                        if (!$res2) {
                            $feedback .= "DB Error " . db_error() . "<br>";
                            break;
                        }
                        $f = new Forum($this->g, $forum_id);
                        if (!$f || !is_object($f)) {
                            exit_error(_('Error'), _('Error getting new Forum'));
                        } elseif ($f->isError()) {
                            exit_error(_('Error'), $f->getErrorMessage());
                        }
                        $fm = new ForumMessage($f);
                        // pending = false
                        if (!$fm || !is_object($fm)) {
                            exit_error(_('Error'), "Error getting new ForumMessage");
                        } elseif ($fm->isError()) {
                            exit_error(_('Error'), "Error getting new ForumMessage: " . $fm->getErrorMessage());
                        }
                        $group_forum_id = db_result($res1, 0, "group_forum_id");
                        $subject = db_result($res1, 0, "subject");
                        $body = db_result($res1, 0, "body");
                        $post_date = db_result($res1, 0, "post_date");
                        $thread_id = db_result($res1, 0, "thread_id");
                        $is_followup_to = db_result($res1, 0, "is_followup_to");
                        $posted_by = db_result($res1, 0, "posted_by");
                        $has_followups = db_result($res1, 0, "has_followups");
                        $most_recent_date = db_result($res1, 0, "most_recent_date");
                        if ($fm->insertreleasedmsg($group_forum_id, $subject, $body, $post_date, $thread_id, $is_followup_to, $posted_by, $has_followups, time())) {
                            $feedback .= "( {$subject} ) " . _('Pending forum released') . "<br>";
                            if (db_numrows($res2) > 0) {
                                //if there�s an attachment
                                $am = new AttachManager();
                                //object that will handle and insert the attachment into the db
                                $am->SetForumMsg($fm);
                                $userid = db_result($res2, 0, "userid");
                                $dateline = db_result($res2, 0, "dateline");
                                $filename = db_result($res2, 0, "filename");
                                $filedata = db_result($res2, 0, "filedata");
                                $filesize = db_result($res2, 0, "filesize");
                                $visible = db_result($res2, 0, "visible");
                                $msg_id = db_result($res2, 0, "msg_id");
                                $filehash = db_result($res2, 0, "filehash");
                                $mimetype = db_result($res2, 0, "mimetype");
                                $am->AddToDBOnly($userid, $dateline, $filename, $filedata, $filesize, $visible, $filehash, $mimetype);
                                foreach ($am->Getmessages() as $item) {
                                    $feedback .= "{$msg_id} - " . $item . "<br>";
                                }
                            }
                            $deleteok = true;
                        } else {
                            if ($fm->isError()) {
                                if ($fm->getErrorMessage() == _('Couldn\'t Update Master Thread parent with current time')) {
                                    //the thread which the message was replying to doesn�t exist any more
                                    $feedback .= "( " . $subject . " ) " . _('The thread which the message was posted to doesn\'t exist anymore, please delete the message.') . "<br>";
                                } else {
                                    $feedback .= "{$msg_id} - " . $fm->getErrorMessage() . "<br>";
                                }
                                $deleteok = false;
                            }
                        }
                        if (isset($am) && is_object($am)) {
                            //if there was an attach, check if it was uploaded ok
                            if (!$am->isError()) {
                                $deleteok = true;
                            } else {
                                //undo the changes to the forum table
                                db_begin();
                                $sql = "DELETE FROM forum WHERE msg_id='{$fm->getID}()'";
                                if (!db_query($sql)) {
                                    $feedback .= "DB Error ";
                                    $feedback .= db_error() . "<br>";
                                    db_rollback();
                                    break;
                                }
                                db_commit();
                                $deleteok = false;
                            }
                        }
                        if ($deleteok) {
                            //delete the message and attach
                            db_begin();
                            $sql = "DELETE FROM forum_pending_attachment WHERE msg_id='{$msgids[$i]}'";
                            if (!db_query($sql)) {
                                $feedback .= "DB Error ";
                                $feedback .= db_error() . "<br>";
                                db_rollback();
                                break;
                            }
                            $sql = "DELETE FROM forum_pending_messages WHERE msg_id='{$msgids[$i]}'";
                            if (!db_query($sql)) {
                                $feedback .= "DB Error ";
                                $feedback .= db_error() . "<br>";
                                db_rollback();
                                break;
                            }
                            db_commit();
                        }
                }
            }
            html_feedback_top($feedback);
            $page = 0;
            $this->ExecuteAction("view_pending");
        }
    }
Example #5
0
    function showPostForm($thread_id = 0, $is_followup_to = 0, $subject = "")
    {
        global $group_id;
        $body = '';
        if ($this->Forum->userCanPost()) {
            if ($subject) {
                //if this is a followup, put a RE: before it if needed
                if (!eregi('RE:', $subject, $test)) {
                    $subject = 'RE: ' . $subject;
                }
            }
            echo notepad_func();
            ?>
<div align="center">
<form "enctype="multipart/form-data"
	action="<?php 
            echo util_make_url('/forum/forum.php?forum_id=' . $this->Forum->getID() . '&group_id=' . $group_id);
            ?>
"
	method="post"><?php 
            $objid = $this->Forum->getID();
            ?>
 <input
	type="hidden" name="post_message" value="y" /> <input type="hidden"
	name="thread_id" value="<?php 
            echo $thread_id;
            ?>
" /> <input
	type="hidden" name="msg_id" value="<?php 
            echo $is_followup_to;
            ?>
" /> <input
	type="hidden" name="is_followup_to"
	value="<?php 
            echo $is_followup_to;
            ?>
" /> <input type="hidden"
	name="form_key" value="<?php 
            echo form_generate_key();
            ?>
">
<fieldset class="fieldset">
<table>
	<tr>
		<td valign="top"></td>
		<td valign="top"><br>
		<strong><?php 
            echo _('Subject:');
            ?>
</strong><?php 
            echo utils_requiredField();
            ?>
<br />
		<input type="text" name="subject" value="<?php 
            echo $subject;
            ?>
"
			size="45" maxlength="45" /> <br>
		<br>
		<strong><?php 
            echo _('Message:');
            ?>
</strong><?php 
            echo notepad_button('document.forms[1].body');
            echo utils_requiredField();
            ?>
<br />

		<?php 
            $GLOBALS['editor_was_set_up'] = false;
            $params = array();
            $params['body'] = $body;
            $params['width'] = "800";
            $params['height'] = "500";
            $params['group'] = $group_id;
            plugin_hook("text_editor", $params);
            if (!$GLOBALS['editor_was_set_up']) {
                //if we don't have any plugin for text editor, display a simple textarea edit box
                echo '<textarea name="body"  rows="10" cols="50" wrap="soft">' . $body . '</textarea>';
            }
            unset($GLOBALS['editor_was_set_up']);
            ?>
 <?php 
            //$text_support->displayTextField('body');
            ?>
 <br>
		<br>
		<!--		<span class="selected"><?php 
            echo _('HTML tags will display in your post as text');
            ?>
</span> -->
		<p><?php 
            $this->LinkAttachForm();
            ?>
		
		
		<p><?php 
            if (!session_loggedin()) {
                echo '<span class="highlight">';
                printf(_('You are posting anonymously because you are not <a href="%1$s">logged in</a>'), util_make_url('/account/login.php?return_to=' . urlencode(getStringFromServer('REQUEST_URI')))) . '</span>';
            }
            ?>
 <br />
		<input type="submit" name="submit"
			value="<?php 
            echo _('Post Comment');
            echo !session_loggedin() ? ' ' . _('Anonymously') : '';
            ?>
" /><?php 
            echo session_loggedin() ? '&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="monitor" />&nbsp;' . _('Receive followups via email') . '.' : '';
            ?>
		</p>
		</td>
	</tr>
</table>
</fieldset>
</form>
</div>
			<?php 
        } elseif ($this->Forum->allowAnonymous()) {
            echo '<span class="error">';
            printf(_('You could post if you were <a href="%1$s">logged in</a>.'), util_make_url('/account/login.php?return_to=' . urlencode(getStringFromServer('REQUEST_URI'))));
        } elseif (!session_loggedin()) {
            echo '
			<span class="error">' . sprintf(_('Please <a href="%1$s">log in</a>'), util_make_url('/account/login.php?return_to=' . urlencode(getStringFromServer('REQUEST_URI')))) . '</span><br/></p>';
        } else {
            //do nothing
        }
    }
Example #6
0
    site_admin_footer(array());
    exit;
}
site_admin_header(array('title' => _('Massmail admin')));
print '
<h4>' . sprintf(_('Mail Engine for %1$s Subscribers'), $GLOBALS['sys_name']) . '</h4>
';
print '
<p>
<a href="#active">' . _('Active Deliveries') . '</a>
</p>

<p>' . _('Be <span class="important">VERY</span> careful with this form, because submitting it WILL lead to sending email to lots of users.') . '</p>
';
print '
<form action="' . getStringFromServer('PHP_SELF') . '" method="post">' . '<input type="hidden" name="form_key" value="' . form_generate_key() . '">' . '<strong>Target Audience:</strong>' . utils_requiredField() . '<br />' . html_build_select_box_from_arrays(array(0, 'SITE', 'COMMNTY', 'DVLPR', 'ADMIN', 'ALL', 'SFDVLPR'), array(_('(select)'), _('Subscribers to "Site Updates"'), _('Subscribers to "Additional Community Mailings"'), _('All Project Developers'), _('All Project Admins'), _('All Users'), $GLOBALS['sys_name'] . _('Developers (test)')), 'mail_type', false, false) . '<br />';
print '

<p>
<strong>' . _('Subject') . ':</strong>' . utils_requiredField() . '
<br /><input type="text" name="mail_subject" size="50" value="[' . $GLOBALS['sys_name'] . '] " /></p>

<p><strong>' . _('Text of Message') . ':</strong>' . utils_requiredField() . _('(will be appended with unsubscription information, if applicable)') . '</p>
<pre><textarea name="mail_message" cols="70" rows="20">
</textarea>
</pre>

<p><input type="submit" name="submit" value="' . _('Schedule for Mailing') . '" /></p>

</form>
';
 /**
  * Show Add/Modify Question Forums
  * @param Survey Question Question Object
  * Return string 
  */
 function showAddSurveyForm(&$s)
 {
     global $group_id;
     global $survey_id;
     /* Default is add */
     $title = _('Add A Survey');
     $survey_button = _('Add This Survey');
     $active = ' checked="checked" ';
     $inactive = '';
     /* If we have a survey object, it is a Modify */
     if ($s && is_object($s) && !$s->isError() && $s->getID()) {
         $title = _('Edit A Survey');
         $warning = '<span class="warning">' . _('WARNING! It is a bad idea to edit a survey after responses have been posted') . '</span>';
         $survey_id = $s->getID();
         $survey_title = $s->getTitle();
         $survey_questions = $s->getQuestionString();
         $survey_button = _('Submit Changes');
         if (!$s->isActive()) {
             $inactive = 'checked ="checked" ';
             $active = '';
         }
     } else {
         $warning = '';
         $survey_questions = '';
         $survey_title = '';
     }
     $ret = '<h2>' . $title . '</h2>';
     $ret .= $warning;
     $ret .= '<form action="' . getStringFromServer('PHP_SELF') . '" method="post">';
     $ret .= '<input type="hidden" name="post" value="Y" />';
     $ret .= '<input type="hidden" name="group_id" value="' . $group_id . '" />';
     $ret .= '<input type="hidden" name="survey_id" value="' . $survey_id . '" />';
     $ret .= '<input type="hidden" name="survey_questions" value="' . $survey_questions . '" />';
     $ret .= '<input type="hidden" name="form_key" value="' . form_generate_key() . '">';
     $ret .= '<strong>' . _('Name Of Survey:') . '</strong>' . utils_requiredField();
     $ret .= '<input type="text" name="survey_title" value="' . $survey_title . '" length="60" maxlength="150" /><p>';
     $ret .= '<p><strong>' . _('Is Active?') . '</strong>';
     $ret .= '<br /><input type="radio" name="is_active" value="1"' . $active . '/>' . _('Yes');
     $ret .= '<br /><input type="radio" name="is_active" value="0"' . $inactive . '/>' . _('No');
     $arr_to_add =& $s->getAddableQuestionInstances();
     $arr_to_del =& $s->getQuestionInstances();
     if (count($arr_to_add) > 0) {
         $ret .= '<p><strong>' . _('Addable Questions') . '</strong>';
         $title_arr[] = "&nbsp;";
         $title_arr[] = _('Questions');
         $title_arr[] = "&nbsp;";
         $ret .= $GLOBALS['HTML']->listTableTop($title_arr);
     }
     for ($i = 0; $i < count($arr_to_add); $i++) {
         if ($arr_to_add[$i]->isError()) {
             echo $arr_to_add[$i]->getErrorMessage();
             continue;
         }
         if ($i % 3 == 0) {
             $ret .= "<tr " . $GLOBALS['HTML']->boxGetAltRowStyle($i) . ">\n";
         }
         $ret .= '<td><input type="checkbox" name="to_add[]" value="' . $arr_to_add[$i]->getID() . '">' . $arr_to_add[$i]->getQuestion() . ' (' . $arr_to_add[$i]->getQuestionStringType() . ')</td>';
         if ($i % 3 == 2) {
             $ret .= "</tr>";
         }
     }
     if (count($arr_to_add) > 0) {
         /* Fill the remain cells */
         if ($i % 3 == 1) {
             $ret .= '<td>&nbsp;</td><td>&nbsp;</td></tr>';
         } else {
             if ($i % 3 == 2) {
                 $ret .= '<td>&nbsp;</td></tr>';
             }
         }
         $ret .= $GLOBALS['HTML']->listTableBottom();
     }
     /* Deletable questions */
     if (count($arr_to_del) > 0) {
         $ret .= '<p><strong>' . _('Questions in this Survey') . '</strong>';
         $title_arr = array('Question ID', 'Question', 'Type', 'Order', 'Delete from this Survey');
         $ret .= $GLOBALS['HTML']->listTableTop($title_arr);
     }
     for ($i = 0; $i < count($arr_to_del); $i++) {
         if ($arr_to_del[$i]->isError()) {
             echo $arr_to_del[$i]->getErrorMessage();
             continue;
         }
         $ret .= "<tr " . $GLOBALS['HTML']->boxGetAltRowStyle($i) . ">\n";
         $ret .= '<td>' . $arr_to_del[$i]->getID() . '</td>';
         $ret .= '<td>' . $arr_to_del[$i]->getQuestion() . '</td>';
         $ret .= '<td>' . $arr_to_del[$i]->getQuestionStringType() . '</td>';
         $ret .= '[' . util_make_link('/survey/admin/survey.php?group_id=' . $group_id . '&amp;survey_id=' . $survey_id . '&amp;is_up=1&amp;updown=Y' . '&amp;question_id=' . $arr_to_del[$i]->getID(), _('Up')) . ']</center></td>';
         $ret .= '[' . util_make_link('/survey/admin/survey.php?group_id=' . $group_id . '&amp;survey_id=' . $survey_id . '&amp;is_up=0&amp;updown=Y' . '&amp;question_id=' . $arr_to_del[$i]->getID(), _('Down')) . ']</center></td>';
         $ret .= '<td><center><input type="checkbox" name="to_del[]" value="' . $arr_to_del[$i]->getID() . '"></center></td>';
         $ret .= '</tr>';
     }
     if (count($arr_to_del)) {
         $ret .= $GLOBALS['HTML']->listTableBottom();
     }
     /* Privous style question input text box. deprecated.		
     		$ret.= _('List question numbers, in desired order, separated by commas. <strong>Refer to your list of questions</strong> so you can view the question id\'s. Do <strong>not</strong> include spaces or end your list with a comma. <br />Ex: 1,2,3,4,5,6,7');
     		$ret.='<br /><input type="text" name="survey_questions" value="" length="90" maxlength="1500" /></p>';
     		*/
     $ret .= '<p><input type="submit" name="submit" value="' . $survey_button . '"></p>';
     $ret .= '</form>';
     return $ret;
 }