Ejemplo n.º 1
0
 /**
  * displayForm 
  * 
  * Displays the form for posting: new, reply and edit
  *  
  * @param   string  $type       new, reply or edit
  * @param   int     $thread_id  used for reply and edit
  * @param   int     $post_id    used for reply and edit
  * @param   string  $post       used for edit
  * @return  void
  */
 function displayForm($type, $thread_id = 0, $post_id = 0, $post = 'error')
 {
     $thread_id = (int) $thread_id;
     $post_id = (int) $post_id;
     $tab = 1;
     // New
     if ($type == 'new') {
         $reply = '';
         $header = T_('New Message');
         $sticky = '';
         $post = '';
         $subject = '
             <div>
                 <label for="subject">' . T_('Subject') . '</label>: 
                 <input type="text" name="subject" id="subject" size="50" tabindex="' . $tab . '"/>
             </div>
             <script type="text/javascript">
                 var fsub = new LiveValidation(\'subject\', {onlyOnSubmit: true});
                 fsub.add(Validate.Presence, {failureMessage: ""});
             </script>';
         $tab++;
         if ($this->fcmsUser->access <= 2) {
             $sticky = '
             <p>
                 <label for="sticky">' . T_('Admin Tools') . '</label>: 
                 <input type="checkbox" name="sticky" id="sticky" value="sticky"/>' . T_('Make Announcement') . '
             </p>';
         }
         $post_js = '
             <script type="text/javascript">
                 var fpost = new LiveValidation(\'post\', {onlyOnSubmit: true});
                 fpost.add(Validate.Presence, {failureMessage: ""});
             </script>';
         $hidden_submit = '
             <div><input type="hidden" name="name" id="name" value="' . $this->fcmsUser->id . '"/></div>
             <p>
                 <input class="sub1" type="submit" name="post_submit" id="post_submit" tabindex="' . ($tab + 1) . '" value="' . T_('Submit') . '"/>
                 &nbsp; <a href="messageboard.php">' . T_('Cancel') . '</a>
             </p>';
     } elseif ($type == 'reply') {
         $header = T_('Reply');
         $subject = '';
         $sticky = '';
         $post_js = '';
         // Get last post in the thread to display above reply
         $sql = "SELECT `post`, `user` \n                    FROM `fcms_board_posts` \n                    WHERE `thread` = ?\n                    ORDER BY `date` DESC \n                    LIMIT 1";
         $row = $this->fcmsDatabase->getRow($sql, $thread_id);
         if ($row === false) {
             $this->fcmsError->displayError();
             return;
         }
         $displayname = getUserDisplayName($row['user']);
         $reply = '
         <div class="lastpost">
             <b>' . sprintf(T_('Last post written by %s'), $displayname) . '</b><br />
             <p>' . parse($row['post']) . '</p>
         </div>';
         // Get the text of ther post that the user is quoting
         // We know we are quoting someone if type is reply and we have a post_id
         if ($post_id > 0) {
             $sql = "SELECT `post`, `user` \n                        FROM `fcms_board_posts` \n                        WHERE `id` = '{$post_id}'\n                        LIMIT 1";
             $qrow = $this->fcmsDatabase->getRow($sql, $post_id);
             if ($qrow == false) {
                 $this->fcmsError->displayError();
                 return;
             }
             $post = '[SPAN=q]' . T_('Quoting') . ': ' . getUserDisplayName($qrow['user']) . '[/SPAN][QUOTE]' . cleanOutput($qrow['post']) . '[/QUOTE]';
         } else {
             $post = '';
         }
         $hidden_submit = '
             <div><input type="hidden" name="name" id="name" value="' . $this->fcmsUser->id . '"/></div>
             <div><input type="hidden" name="thread_id" value="' . $thread_id . '"/></div>
             <p>
                 <input class="sub1" type="submit" name="reply_submit" id="reply_submit" tabindex="' . ($tab + 1) . '" value="' . T_('Reply') . '"/>
                 &nbsp; <a href="?thread=' . $thread_id . '">' . T_('Cancel') . '</a>
             </p>';
     } elseif ($type == 'edit') {
         $reply = '';
         $header = T_('Edit');
         $subject = '';
         $sticky = '';
         $post_js = '';
         // Remove the previous edited by string so we can add a new one
         $pos = strpos($post, "[size=small][i]" . T_('Edited'));
         if ($pos !== false) {
             $post = substr($post, 0, $pos);
         }
         $hidden_submit = '
             <div><input type="hidden" name="id" id="id" value="' . $post_id . '"/></div>
             <div><input type="hidden" name="thread_id" id="thread_id" value="' . $thread_id . '"/></div>
             <p>
                 <input class="sub1" type="submit" name="edit_submit" id="edit_submit" tabindex="' . ($tab + 1) . '" value="' . T_('Edit') . '"/>
                 &nbsp; <a href="?thread=' . $thread_id . '">' . T_('Cancel') . '</a>
             </p>';
     }
     // Display the form
     echo '
         <script type="text/javascript" src="ui/js/livevalidation.js"></script>
         <script type="text/javascript" src="ui/js/fcms.js"></script>
         <form id="postform" method="post" action="messageboard.php">
             <fieldset>
                 <legend><span>' . $header . '</span></legend>
                 ' . $subject . '
                 <div>
                     <label for="showname">' . T_('Name') . '</label>: 
                     <input type="text" disabled="disabled" name="showname" id="showname" value="' . getUserDisplayName($this->fcmsUser->id) . '" size="50"/>
                 </div>
                 ' . $sticky . '
                 <script type="text/javascript">var bb = new BBCode();</script>';
     echo "\n";
     displayBBCodeToolbar();
     echo '
                 <div>
                     <textarea name="post" id="post" rows="10" cols="63" tabindex="' . $tab . '">' . $post . '</textarea>
                 </div>
                 ' . $post_js . '
                 <script type="text/javascript">bb.init(\'post\');</script>
                 ' . $hidden_submit . '
             </fieldset>
         </form>
         ' . $reply;
 }
Ejemplo n.º 2
0
 /**
  * displayComposeForm 
  * 
  * @return void
  */
 function displayComposeForm()
 {
     $this->displayHeader();
     $id = '';
     $title = '';
     if (isset($_GET['id'])) {
         $id = (int) $_GET['id'];
     }
     if (isset($_GET['title'])) {
         $title = strip_tags($_GET['title']);
         $title = 'RE: ' . cleanOutput($title);
     }
     $sql = "SELECT `id`\n                FROM `fcms_users` \n                WHERE `activated` > 0\n                AND `phpass` != 'NONMEMBER'";
     $rows = $this->fcmsDatabase->getRows($sql);
     if ($rows === false) {
         $this->fcmsError->displayError();
         $this->displayFooter();
         return;
     }
     // TODO - optimize sql query above to get display name info instead
     foreach ($rows as $r) {
         $displayNameList[$r['id']] = getUserDisplayName($r['id'], 2);
     }
     asort($displayNameList);
     $user_options = buildHtmlSelectOptions($displayNameList, $id);
     echo '
         <script type="text/javascript" src="ui/js/livevalidation.js"></script>
         <form method="post" id="newpmform" action="privatemsg.php">
             <fieldset>
                 <legend><span>' . T_('New PM') . '</span></legend>
                 <div>
                     <label for="title">' . T_('Subject') . '</label>: 
                     <input type="text" id="title" name="title" size="50" value="' . $title . '"/>
                 </div><br/>
                 <script type="text/javascript">
                     var ftitle = new LiveValidation(\'title\', { onlyOnSubmit: true });
                     ftitle.add(Validate.Presence, { failureMessage: "" });
                 </script>
                 <div>
                     <label for="to">' . T_('To') . '</label>: 
                     <select name="to">
                         ' . $user_options . '
                     </select>
                 </div><br/>
                 <script type="text/javascript">var bb = new BBCode();</script>';
     displayBBCodeToolbar();
     echo '
                 <div><textarea name="post" id="post" rows="10" cols="63"></textarea></div>
                 <script type="text/javascript">bb.init(\'post\');</script>
                 <script type="text/javascript">
                     var fpost = new LiveValidation(\'post\', { onlyOnSubmit: true });
                     fpost.add(Validate.Presence, { failureMessage: "" });
                 </script>
                 <p>
                     <input class="sub1" type="submit" name="submit" value="' . T_('Send') . '"/> &nbsp;
                     <a href="privatemsg.php">' . T_('Cancel') . '</a>
                 </p>
             </fieldset>
         </form>
         <p>&nbsp;</p>';
     $this->displayFooter();
 }
Ejemplo n.º 3
0
 /**
  * displayForm 
  * 
  * @param   string  $type 
  * @param   int     $user 
  * @param   int     $newsid 
  * @param   string  $title 
  * @param   string  $news 
  * 
  * @return  void
  */
 function displayForm($type, $user = 0, $newsid = 0, $title = 'error', $news = 'error')
 {
     echo '
         <script type="text/javascript" src="ui/js/livevalidation.js"></script>';
     if ($type == 'edit') {
         echo '
         <form method="post" id="editform" action="familynews.php">
             <fieldset>
                 <legend><span>' . T_('Edit News') . '</span></legend>';
     } else {
         echo '
         <form method="post" id="addform" action="familynews.php">
             <fieldset>
                 <legend><span>' . T_('Add News') . '</span></legend>';
     }
     echo '
                 <p>
                     <label for="title">' . T_('Title') . '</label>:
                     <input type="text" name="title" id="title" title="' . T_('Title of your Family News') . '"';
     if ($type == 'edit') {
         echo ' value="' . cleanOutput($title) . '"';
     }
     echo ' tabindex="1" size="50"/>
                 </p>
                 <script type="text/javascript">
                     var ftitle = new LiveValidation(\'title\', { onlyOnSubmit:true });
                     ftitle.add(Validate.Presence, { failureMessage: "" });
                 </script>
                 <script type="text/javascript">var bb = new BBCode();</script>';
     displayBBCodeToolbar();
     echo '
                 <div><textarea name="post" id="post" rows="10" cols="63" tabindex="2">';
     if ($type == 'edit') {
         echo cleanOutput($news);
     }
     echo '</textarea></div>
                 <script type="text/javascript">bb.init(\'post\');</script>
                 <p>';
     if ($type == 'add') {
         echo '
                     <input class="sub1" type="submit" name="submitadd" tabindex="3" value="' . T_('Add') . '"/>';
     } else {
         echo '
                     <input type="hidden" name="id" value="' . (int) $newsid . '"/>
                     <input type="hidden" name="user" value="' . (int) $user . '"/>
                     <input class="sub1" type="submit" name="submitedit" tabindex="3" value="' . T_('Edit') . '"/>';
     }
     echo '
                      &nbsp;' . T_('or') . ' &nbsp;
                     <a href="familynews.php">' . T_('Cancel') . '</a>
                 </p>
             </fieldset>
         </form>';
 }