[ PHPXref.com ] [ Generated: Sun Jul 20 19:47:34 2008 ] [ phpMyFAQ 1.6.1 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/admin/ -> record.edit.php (source)

   1  <?php
   2  /**
   3  * $Id: record.edit.php,v 1.19.2.14.2.15 2006/04/27 20:59:53 matteo Exp $
   4  *
   5  * @author       Thorsten Rinne <thorsten@phpmyfaq.de>
   6  * @since        2003-02-23
   7  * @license      Mozilla Public License 1.1
   8  * @copyright    (c) 2001-2006 phpMyFAQ Team
   9  *
  10  * The contents of this file are subject to the Mozilla Public License
  11  * Version 1.1 (the "License"); you may not use this file except in
  12  * compliance with the License. You may obtain a copy of the License at
  13  * http://www.mozilla.org/MPL/
  14  *
  15  * Software distributed under the License is distributed on an "AS IS"
  16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  17  * License for the specific language governing rights and limitations
  18  * under the License.
  19  */
  20  
  21  if (!defined('IS_VALID_PHPMYFAQ_ADMIN')) {
  22      header('Location: http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']));
  23      exit();
  24  }
  25  
  26  if ($permission["editbt"] && !emptyTable(SQLPREFIX."faqcategories")) {
  27      $tree = new Category();
  28      $tree->buildTree();
  29      $rubrik = '';
  30      $thema = '';
  31      $categories = array('category_id', 'category_lang');
  32  
  33      if (isset($_REQUEST["aktion"]) && $_REQUEST["aktion"] == "takequestion") {
  34  
  35          $id_question = intval( $_REQUEST['id']);
  36          $query_questions = sprintf('SELECT ask_rubrik, ask_content FROM %sfaqfragen WHERE id = %d', SQLPREFIX, $id_question);
  37          $result_questions = $db->query($query_questions);
  38          $row = $db->fetch_object($result_questions);
  39          $rubrik = $row->ask_rubrik;
  40          $thema = $row->ask_content;
  41          $lang = $LANGCODE;
  42          $categories = array(array('category_id' => $rubrik, 'category_lang' => $lang));
  43      }
  44  
  45      if (isset($_REQUEST["aktion"]) && $_REQUEST["aktion"] == "editpreview") {
  46  
  47          if (isset($_REQUEST["id"]) && $_REQUEST["id"] != "") {
  48              $id = $_REQUEST["id"];
  49              $acti = "saveentry&amp;id=".$id;
  50          } else {
  51              $id = 0;
  52              $acti = "insertentry";
  53          }
  54          $lang = $_REQUEST["lang"];
  55          $rubrik = isset($_POST['rubrik']) ? $_POST['rubrik'] : null;
  56          if (is_array($rubrik)) {
  57              foreach ($rubrik as $cats) {
  58                  $categories[] = array('category_id' => $cats, 'category_lang' => $lang);
  59              }
  60          }
  61          $active = $_REQUEST["active"];
  62          $keywords = $_REQUEST["keywords"];
  63          $thema = $_REQUEST["thema"];
  64          $content = htmlspecialchars($_REQUEST["content"]);
  65          $author = $_REQUEST["author"];
  66          $email = $_REQUEST["email"];
  67          $comment = $_REQUEST["comment"];
  68          $changed = $_REQUEST["changed"];
  69          $solution_id = $_REQUEST['solution_id'];
  70          $revision_id = isset($_REQUEST['revision_id']) ? $_REQUEST['revision_id'] : 0;
  71  
  72      } elseif (isset($_REQUEST["aktion"]) && $_REQUEST["aktion"] == "editentry") {
  73  
  74          if ((!isset($rubrik) && !isset($thema)) || (isset($_REQUEST["id"]) && $_REQUEST["id"] != "")) {
  75              adminlog("Beitragedit, ".$_REQUEST["id"]);
  76              $id = intval($_GET["id"]);
  77              $lang = $_GET["lang"];
  78  
  79              // Get the category
  80              $resultCategory = $db->query('SELECT category_id, category_lang FROM '.SQLPREFIX.'faqcategoryrelations WHERE record_id = '.$id.' AND record_lang = \''.$lang.'\'');
  81              while ($row = $db->fetch_object($resultCategory)) {
  82                  $categories[] = array('category_id' => $row->category_id, 'category_lang' => $row->category_lang);
  83              }
  84  
  85              // Get the record
  86              $resultRecord = $db->query('SELECT '.SQLPREFIX.'faqdata.id AS id, '.SQLPREFIX.'faqdata.lang AS lang, '.SQLPREFIX.'faqdata.solution_id AS solution_id, '.SQLPREFIX.'faqdata.revision_id AS revision_id, '.SQLPREFIX.'faqdata.active AS active, '.SQLPREFIX.'faqdata.keywords AS keywords, '.SQLPREFIX.'faqdata.thema AS thema, '.SQLPREFIX.'faqdata.content AS content, '.SQLPREFIX.'faqdata.author AS author, '.SQLPREFIX.'faqdata.email AS email, '.SQLPREFIX.'faqdata.comment AS comment, '.SQLPREFIX.'faqdata.datum AS datum FROM '.SQLPREFIX.'faqdata WHERE id = '.$id.' AND lang = \''.$lang.'\'');
  87  
  88              $row = $db->fetch_object($resultRecord);
  89              $id = $row->id;
  90              $lang = $row->lang;
  91              $solution_id = $row->solution_id;
  92              $revision_id = $row->revision_id;
  93              $active = $row->active;
  94              $keywords = $row->keywords;
  95              $thema = $row->thema;
  96              $content = htmlspecialchars($row->content);
  97              $author = $row->author;
  98              $email = $row->email;
  99              $comment = $row->comment;
 100              $date = $row->datum;
 101              $acti = 'saveentry&amp;id='.$_REQUEST['id'];
 102          } else {
 103              $acti = 'insertentry';
 104              $id = 0;
 105              $lang = $LANGCODE;
 106              $revision_id = 0; // Default start value for revisions
 107          }
 108  
 109      } else {
 110  
 111          adminlog('Beitragcreate');
 112          $acti = 'insertentry';
 113          if (!is_array($categories)) {
 114              $categories = array();
 115          }
 116          $id = 0;
 117          $lang = $LANGCODE;
 118          $revision_id = 0; // Default start value for revisions
 119      }
 120  
 121      // Revisions
 122      if (isset($_REQUEST['revisionid_selected'])){
 123          $revisionid_selected = $_REQUEST['revisionid_selected'];
 124      } elseif (isset($revision_id)) {
 125          $revisionid_selected = $revision_id;
 126      }
 127  
 128      print '<h2>'.$PMF_LANG["ad_entry_edit_1"];
 129      if (0 != $id) {
 130          print ' <span style="color: Red;">'.$id.' ('.$PMF_LANG['ad_entry_revision'].' 1.'.$revisionid_selected.') </span> ';
 131      }
 132      print ' '.$PMF_LANG["ad_entry_edit_2"].'</h2>';
 133  
 134      if ($permission["changebtrevs"]){
 135          $query = sprintf("SELECT revision_id, datum, author FROM %sfaqdata_revisions WHERE id = %d ORDER BY revision_id", SQLPREFIX, $id);
 136          $result2 = $db->query($query);
 137          if ($db->num_rows($result2) > 0) {
 138  ?>
 139      <form id="selectRevision" name="selectRevision" action="<?php print $_SERVER["PHP_SELF"].$linkext; ?>&amp;aktion=editentry&amp;id=<?php print $id; ?>&amp;lang=<?php print $lang; ?>" method="post" />
 140      <fieldset>
 141      <legend><?php print $PMF_LANG['ad_changerev']; ?></legend>
 142          <select name="revisionid_selected" onChange="selectRevision.submit();" />
 143              <option value="<?php print $revision_id; ?>"><?php print $PMF_LANG['ad_changerev']; ?></option>
 144  <?php
 145              while ($row2 = $db->fetch_object($result2)){
 146  ?>
 147              <option value="<?php print $row2->revision_id; ?>" <?php if ($revisionid_selected == $row2->revision_id) { print 'selected="selected"'; } ?> ><?php print $PMF_LANG['ad_entry_revision'].' 1.'.$row2->revision_id.': '.makeDate($row2->datum)." - ".$row2->author; ?></option>
 148  <?php
 149              }
 150  ?>
 151          </select>
 152      </fieldset>
 153      </form>
 154      <br />
 155  <?php
 156          }
 157  
 158          if (isset($revisionid_selected) && isset($revision_id) && $revisionid_selected != $revision_id) {
 159  
 160              $result2 = $db->query("SELECT id, lang, solution_id, revision_id, active, keywords, thema, content, comment, datum, author, email FROM ".SQLPREFIX."faqdata_revisions WHERE id = ".$id." AND lang = '".$lang."' AND revision_id = ".$revisionid_selected);
 161              $row = $db->fetch_object($result2);
 162              $id = $row->id;
 163              $lang = $row->lang;
 164              $solution_id = $row->solution_id;
 165              $revision_id = $row->revision_id;
 166              $active = $row->active;
 167              $keywords = $row->keywords;
 168              $thema = $row->thema;
 169              $content = htmlspecialchars($row->content);
 170              $author = $row->author;
 171              $email = $row->email;
 172              $comment = $row->comment;
 173              $date = $row->datum;
 174  
 175          }
 176      }
 177  ?>
 178  
 179      <form style="float: left;" action="<?php print $_SERVER["PHP_SELF"].$linkext; ?>&amp;aktion=<?php print $acti; ?>" method="post">
 180      <input type="hidden" name="revision_id" id="revision_id" value="<?php print $revision_id; ?>" />
 181  
 182      <fieldset>
 183      <legend><?php print $PMF_LANG['ad_entry_faq_record']; ?></legend>
 184  
 185      <label class="lefteditor" for="rubrik"><?php print $PMF_LANG["ad_entry_category"]; ?></label>
 186      <select name="rubrik[]" id="rubrik" size="5" multiple="multiple">
 187  <?php print $tree->printCategoryOptions($categories); ?>
 188      </select><br />
 189  
 190      <label class="lefteditor" for="thema"><?php print $PMF_LANG["ad_entry_theme"]; ?></label>
 191      <textarea name="thema" id="thema" style="width: 390px; height: 50px;" cols="2" rows="50"><?php if (isset($thema)) { print $thema; } ?></textarea><br />
 192  
 193      <label for="content"><?php print $PMF_LANG["ad_entry_content"]; ?></label>
 194      <noscript>Please enable JavaScript to use the WYSIWYG editor!</noscript><textarea id="content" name="content" cols="50" rows="10"><?php if (isset($content)) { print trim($content); } ?></textarea><br />
 195  
 196  <?php
 197      if ($permission["addatt"]) {
 198  ?>
 199      <label><?php print $PMF_LANG["ad_att_att"]; ?></label>
 200  <?php
 201          if (isset($id) && $id != "") {
 202  ?>
 203          <strong><?php print "../attachments/".$id."/" ?></strong><br />
 204  <?php
 205              if (@is_dir(PMF_ROOT_DIR."/attachments/".$id."/")) {
 206                  $do = dir(PMF_ROOT_DIR."/attachments/".$id."/");
 207                  while ($dat = $do->read()) {
 208                      if ($dat != "." && $dat != "..") {
 209                          print "<a href=\""."../attachments/".$id."/".$dat."\">".$dat."</a>";
 210                          if ($permission["delatt"]) {
 211                              print "[&amp;<a href=\"".$_SERVER["PHP_SELF"].$linkext."&amp;aktion=delatt&amp;id=".$id."&amp;which=".rawurlencode($dat)."&amp;lang=".$lang."\">".$PMF_LANG["ad_att_del"]."</a>&amp;]";
 212                          }
 213                          print "<br />\n";
 214                      }
 215                  }
 216              } else {
 217                  print "<br />\n";
 218                  print "<em>".$PMF_LANG["ad_att_none"]."</em> ";
 219              }
 220              print "<a href=\"#\" onclick=\"Picture('attachment.php?uin=".$uin."&amp;id=".$id."&amp;rubrik=".$rubrik."', 'Attachment', 400,80)\">".$PMF_LANG["ad_att_add"]."</a>";
 221          } else {
 222              print "&nbsp;".$PMF_LANG["ad_att_nope"];
 223          }
 224  ?><br />
 225  
 226  <?php
 227      }
 228  ?>
 229  
 230      <label class="lefteditor" for="keywords"><?php print $PMF_LANG["ad_entry_keywords"]; ?></label>
 231      <input name="keywords" id="keywords" style="width: 390px;" value="<?php if (isset($keywords)) { print htmlspecialchars($keywords); } ?>" /><br />
 232  
 233      <label class="lefteditor" for="author"><?php print $PMF_LANG["ad_entry_author"]; ?></label>
 234      <input name="author" id="author" style="width: 390px;" value="<?php if (isset($author)) { print htmlspecialchars($author); } else { print $auth_realname; } ?>" /><br />
 235  
 236      <label class="lefteditor" for="email"><?php print $PMF_LANG["ad_entry_email"]; ?></label>
 237      <input name="email" id="email" style="width: 390px;" value="<?php if (isset($email)) { print htmlspecialchars($email); } else { print $auth_email; } ?>" /><br />
 238  
 239      </fieldset>
 240  
 241      <fieldset>
 242      <legend><?php print $PMF_LANG['ad_entry_record_administration']; ?></legend>
 243  
 244      <label class="left" for="language"><?php print $PMF_LANG["ad_entry_locale"]; ?>:</label>
 245      <?php print selectLanguages($lang); ?><br />
 246  
 247      <label class="left" for="solution_id"><?php print $PMF_LANG['ad_entry_solution_id']; ?>:</label>
 248      <input name="solution_id" id="solution_id" style="width: 50px; text-align: right;" value="<?php print (isset($solution_id) ? $solution_id : getSolutionId()); ?>" size="5" readonly="readonly" /><br />
 249  
 250  <?php
 251      if (isset($active) && $active == 'yes') {
 252          $suf = ' checked="checked"';
 253          unset($sul);
 254      } else {
 255          unset($suf);
 256          $sul = ' checked="checked"';
 257      }
 258  ?>
 259      <label class="left" for="active"><?php print $PMF_LANG["ad_entry_active"]; ?></label>
 260      <input type="radio" name="active" class="active" value="yes"<?php if (isset($suf)) { print $suf; } ?> /> <?php print $PMF_LANG["ad_gen_yes"]; ?> <input type="radio" name="active" class="active" value="no"<?php if (isset($sul)) { print $sul; } ?> /> <?php print $PMF_LANG["ad_gen_no"]; ?><br />
 261  
 262      <label class="left" for="comment"><?php print $PMF_LANG["ad_entry_allowComments"]; ?></label>
 263      <input type="checkbox" name="comment" id="comment" value="y"<?php if (isset($comment) && $comment == "y") { print " checked"; } ?> /> <?php print $PMF_LANG["ad_gen_yes"]; ?><br />
 264  <?php
 265      if ($acti != 'insertentry') {
 266          $rev_yes = ' checked="checked"';
 267          unset($rev_no);
 268      }
 269      if (isset($active) && $active == 'no') {
 270          $rev_no = ' checked="checked"';
 271          unset($rev_yes);
 272      }
 273      if ($acti != 'insertentry') {
 274  ?>
 275      <label class="left" for="revision"><?php print $PMF_LANG['ad_entry_new_revision']; ?></label>
 276      <input type="radio" name="revision" class="active" value="yes"<?php print isset($rev_yes) ? $rev_yes : ''; ?>/> <?php print $PMF_LANG["ad_gen_yes"]; ?> <input type="radio" name="revision" class="active" value="no"<?php print isset($rev_no) ? $rev_no : ''; ?>/> <?php print $PMF_LANG["ad_gen_no"]; ?><br />
 277  <?php
 278      }
 279  ?>
 280  
 281      </fieldset>
 282  
 283      <fieldset>
 284      <legend><?php print $PMF_LANG['ad_entry_changelog']; ?></legend>
 285  
 286      <label class="lefteditor"><?php print $PMF_LANG["ad_entry_date"]; ?></label>
 287      <?php if (isset($date)) { print makeDate($date); } else { print makeDate(date("YmdHis")); } ?><br />
 288  
 289      <label class="lefteditor" for="changed"><?php print $PMF_LANG["ad_entry_changed"]; ?></label>
 290      <textarea name="changed" id="changed" style="width: 390px; height: 50px;" cols="40" rows="4"><?php if (isset($changed)) { print $changed; } ?></textarea><br />
 291  
 292      </fieldset><br />
 293  
 294  <?php
 295      if ($revisionid_selected == $revision_id) {
 296  ?>
 297      <input class="submit" type="submit" value="<?php print $PMF_LANG["ad_entry_save"]; ?>" name="submit[1]" />
 298      <input class="submit" type="submit" value="<?php print $PMF_LANG["ad_entry_preview"]; ?>" name="submit[2]" />
 299      <input class="submit" type="reset" value="<?php print $PMF_LANG["ad_gen_reset"]; ?>" />
 300  <?php
 301      }
 302      if ($acti != "insertentry") {
 303  ?>
 304      <input class="submit" type="submit" value="<?php print $PMF_LANG["ad_entry_delete"]; ?>" name="submit[0]" />
 305  <?php
 306      }
 307  ?>
 308  <br />
 309  <?php
 310      if (is_numeric($id)) {
 311  
 312          $_user = array(0 => 'n/a');
 313          $_result = $db->query("SELECT id, name FROM ".SQLPREFIX."faquser");
 314          while ($row = $db->fetch_object($_result)) {
 315              $_user[$row->id] = $row->name;
 316          }
 317  ?>
 318      <h3><?php print $PMF_LANG["ad_entry_changelog"]; ?></h3>
 319  <?php
 320          $result = $db->query("SELECT revision_id, usr, datum, what FROM ".SQLPREFIX."faqchanges WHERE beitrag = ".$id." ORDER BY id DESC");
 321          while ($row = $db->fetch_object($result)) {
 322  ?>
 323      <div style="font-size: 10px;"><strong><?php print date("Y-m-d H:i:s", $row->datum).": ".$_user[$row->usr]; ?></strong><br /><?php print $row->what; ?><br /><?php print $PMF_LANG['ad_entry_revision'].' 1.'.$row->revision_id; ?></div>
 324  <?php
 325          }
 326  ?>
 327      </form>
 328  <?php
 329      $result = $db->query("SELECT id, id_comment, usr, email, comment, datum FROM ".SQLPREFIX."faqcomments WHERE id = ".$id." ORDER BY datum DESC");
 330          if ($db->num_rows($result) > 0) {
 331  ?>
 332      <p><strong><?php print $PMF_LANG["ad_entry_comment"] ?></strong></p>
 333  <?php
 334              while ($row = $db->fetch_object($result)) {
 335  ?>
 336      <p><?php print $PMF_LANG["ad_entry_commentby"] ?> <a href="mailto:<?php print $row->email; ?>"><?php print $row->usr; ?></a>:<br /><?php print $row->comment; ?><br /><a href="<?php print $_SERVER["PHP_SELF"].$linkext; ?>&amp;aktion=delcomment&amp;artid=<?php print $row->id; ?>&amp;cmtid=<?php print $row->id_comment; ?>&amp;lang=<?php print $lang; ?>"><img src="images/delete.gif" alt="<?php print $PMF_LANG["ad_entry_delete"] ?>" title="<?php print $PMF_LANG["ad_entry_delete"] ?>" border="0" width="17" height="18" align="right" /></a></p>
 337  <?php
 338              }
 339          }
 340      }
 341  } elseif ($permission["editbt"] != 1 && !emptyTable(SQLPREFIX."faqcategories")) {
 342      print $PMF_LANG["err_NotAuth"];
 343  } elseif ($permission["editbt"] && emptyTable(SQLPREFIX."faqcategories")) {
 344      print $PMF_LANG["no_cats"];
 345  }
 346  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]