phpMyFAQ PHP Cross Reference Customer Relationship Management

Source: /admin/record.edit.php - 766 lines - 38659 bytes - Summary - Text - Print

Description: The FAQ record editor.

   1  <?php
   2  /**
   3   * The FAQ record editor.
   4   *
   5   * PHP Version 5.3
   6   *
   7   * This Source Code Form is subject to the terms of the Mozilla Public License,
   8   * v. 2.0. If a copy of the MPL was not distributed with this file, You can
   9   * obtain one at http://mozilla.org/MPL/2.0/.
  10   *
  11   * @category  phpMyFAQ
  12   * @package   Administration
  13   * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
  14   * @copyright 2003-2014 phpMyFAQ Team
  15   * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
  16   * @link      http://www.phpmyfaq.de
  17   * @since     2003-02-23
  18   */
  19  
  20  if (!defined('IS_VALID_PHPMYFAQ')) {
  21      $protocol = 'http';
  22      if (isset($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) === 'ON'){
  23          $protocol = 'https';
  24      }
  25      header('Location: ' . $protocol . '://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
  26      exit();
  27  }
  28  
  29  if (($permission['editbt']|| $permission['addbt']) && !PMF_Db::checkOnEmptyTable('faqcategories')) {
  30  
  31      $category = new PMF_Category($faqConfig, array(), false);
  32      $category->setUser($currentAdminUser);
  33      $category->setGroups($currentAdminGroups);
  34      $category->buildTree();
  35  
  36      $categoryHelper = new PMF_Helper_Category();
  37      $categoryHelper->setCategory($category);
  38  
  39      $selectedCategory = '';
  40      $categories       = array();
  41      $faqData          = array(
  42          'id'          => 0,
  43          'lang'        => $LANGCODE,
  44          'revision_id' => 0,
  45          'title'       => '',
  46          'dateStart'   => '',
  47          'dateEnd'     => ''
  48      );
  49  
  50      $tagging = new PMF_Tags($faqConfig);
  51      $date    = new PMF_Date($faqConfig);
  52  
  53      if ('takequestion' === $action) {
  54          $questionId       = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
  55          $question         = $faq->getQuestion($questionId);
  56          $selectedCategory = $question['category_id'];
  57          $faqData['title'] = $question['question'];
  58          $notifyUser       = $question['username'];
  59          $notifyEmail      = $question['email'];
  60          $categories       = array(
  61              'category_id'   => $selectedCategory,
  62              'category_lang' => $faqData['lang']
  63          );
  64      } else {
  65          $questionId  = 0;
  66          $notifyUser  = '';
  67          $notifyEmail = '';
  68      }
  69  
  70      if ('editpreview' === $action) {
  71  
  72          $faqData['id'] = PMF_Filter::filterInput(INPUT_POST, 'id', FILTER_VALIDATE_INT);
  73          if (!is_null($faqData['id'])) {
  74              $queryString = 'saveentry&amp;id=' . $faqData['id'];
  75          } else {
  76              $queryString = 'insertentry';
  77          }
  78          
  79          $faqData['lang']  = PMF_Filter::filterInput(INPUT_POST, 'lang', FILTER_SANITIZE_STRING);
  80          $selectedCategory = PMF_Filter::filterInputArray(
  81              INPUT_POST,
  82              array(
  83                  'rubrik' => array(
  84                      'filter' => FILTER_VALIDATE_INT,
  85                      'flags'  => FILTER_REQUIRE_ARRAY
  86                  )
  87              )
  88          );
  89          if (is_array($selectedCategory)) {
  90              foreach ($selectedCategory as $cats) {
  91                  $categories[] = array('category_id' => $cats, 'category_lang' => $faqData['lang']);
  92              }
  93          }
  94          $faqData['active']      = PMF_Filter::filterInput(INPUT_POST, 'active', FILTER_SANITIZE_STRING);
  95          $faqData['keywords']    = PMF_Filter::filterInput(INPUT_POST, 'keywords', FILTER_SANITIZE_STRING);
  96          $faqData['title']       = PMF_Filter::filterInput(INPUT_POST, 'thema', FILTER_SANITIZE_STRING);
  97          $faqData['content']     = PMF_Filter::filterInput(INPUT_POST, 'content', FILTER_SANITIZE_SPECIAL_CHARS);
  98          $faqData['author']      = PMF_Filter::filterInput(INPUT_POST, 'author', FILTER_SANITIZE_STRING);
  99          $faqData['email']       = PMF_Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
 100          $faqData['comment']     = PMF_Filter::filterInput(INPUT_POST, 'comment', FILTER_SANITIZE_STRING);
 101          $faqData['solution_id'] = PMF_Filter::filterInput(INPUT_POST, 'solution_id', FILTER_VALIDATE_INT);
 102          $faqData['revision_id'] = PMF_Filter::filterInput(INPUT_POST, 'revision_id', FILTER_VALIDATE_INT, 0);
 103          $faqData['sticky']      = PMF_Filter::filterInput(INPUT_POST, 'sticky', FILTER_VALIDATE_INT);
 104          $faqData['tags']        = PMF_Filter::filterInput(INPUT_POST, 'tags', FILTER_SANITIZE_STRING);
 105          $faqData['changed']     = PMF_Filter::filterInput(INPUT_POST, 'changed', FILTER_SANITIZE_STRING);
 106          $faqData['dateStart']   = PMF_Filter::filterInput(INPUT_POST, 'dateStart', FILTER_SANITIZE_STRING);
 107          $faqData['dateEnd']     = PMF_Filter::filterInput(INPUT_POST, 'dateEnd', FILTER_SANITIZE_STRING);
 108          $faqData['content']     = html_entity_decode($faqData['content']);
 109          
 110      } elseif ('editentry' === $action) {
 111  
 112          $id   = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
 113          $lang = PMF_Filter::filterInput(INPUT_GET, 'lang', FILTER_SANITIZE_STRING);
 114          if ((!isset($selectedCategory) && !isset($faqData['title'])) || !is_null($id)) {
 115              $logging = new PMF_Logging($faqConfig);
 116              $logging->logAdmin($user, 'Beitragedit, ' . $id);
 117  
 118              $categories = $category->getCategoryRelationsFromArticle($id, $lang);
 119  
 120              $faq->getRecord($id, null, true);
 121              $faqData         = $faq->faqRecord;
 122              $faqData['tags'] = implode(',', $tagging->getAllTagsById($faqData['id']));
 123              $queryString     = 'saveentry&amp;id=' . $faqData['id'];
 124          } else {
 125              $queryString = 'insertentry';
 126          }
 127  
 128      } elseif ('copyentry' === $action) {
 129  
 130          $faqData['id']   = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
 131          $faqData['lang'] = PMF_Filter::filterInput(INPUT_GET, 'lang', FILTER_SANITIZE_STRING);
 132          $faq->language   = $faqData['lang'];
 133          $categories      = $category->getCategoryRelationsFromArticle($faqData['id'], $faqData['lang']);
 134  
 135          $faq->getRecord($faqData['id'], null, true);
 136  
 137          $faqData     = $faq->faqRecord;
 138          $queryString = 'insertentry';
 139  
 140      } else {
 141          $logging = new PMF_Logging($faqConfig);
 142          $logging->logAdmin($user, 'Beitragcreate');
 143          $queryString = 'insertentry';
 144          if (!is_array($categories)) {
 145              $categories = array();
 146          }
 147      }
 148      
 149      // Revisions
 150      $selectedRevisionId = PMF_Filter::filterInput(INPUT_POST, 'revisionid_selected', FILTER_VALIDATE_INT);
 151      if (is_null($selectedRevisionId)) {
 152          $selectedRevisionId = $faqData['revision_id'];
 153      }
 154  
 155      // User permissions
 156      $userPermission = $faq->getPermission('user', $faqData['id']);
 157      if (count($userPermission) == 0 || $userPermission[0] == -1) {
 158          $allUsers          = true;
 159          $restrictedUsers   = false;
 160          $userPermission[0] = -1;
 161      } else {
 162          $allUsers        = false;
 163          $restrictedUsers = true;
 164      }
 165  
 166      // Group permissions
 167      $groupPermission = $faq->getPermission('group', $faqData['id']);
 168      if (count($groupPermission) == 0 || $groupPermission[0] == -1) {
 169          $allGroups          = true;
 170          $restrictedGroups   = false;
 171          $groupPermission[0] = -1;
 172      } else {
 173          $allGroups        = false;
 174          $restrictedGroups = true;
 175      }
 176  
 177      // Set data for forms
 178      $faqData['title']    = (isset($faqData['title']) ? PMF_String::htmlspecialchars($faqData['title']) : '');
 179      $faqData['content']  = (isset($faqData['content']) ? trim(PMF_String::htmlentities($faqData['content'])) : '');
 180      $faqData['tags']     = (isset($faqData['tags']) ? PMF_String::htmlspecialchars($faqData['tags']) : '');
 181      $faqData['keywords'] = (isset($faqData['keywords']) ? PMF_String::htmlspecialchars($faqData['keywords']) : '');
 182      $faqData['author']   = (isset($faqData['author']) ? PMF_String::htmlspecialchars($faqData['author']) : $user->getUserData('display_name'));
 183      $faqData['email']    = (isset($faqData['email']) ? PMF_String::htmlspecialchars($faqData['email']) : $user->getUserData('email'));
 184      $faqData['date']     = (isset($faqData['date']) ? $date->format($faqData['date']) : $date->format(date('Y-m-d H:i')));
 185      $faqData['changed']  = (isset($faqData['changed']) ? $faqData['changed'] : '');
 186  
 187      if (isset($faqData['comment']) && $faqData['comment'] == 'y') {
 188          $faqData['comment'] = ' checked="checked"';
 189      } elseif ($faqConfig->get('records.defaultAllowComments')) {
 190          $faqData['comment'] = ' checked="checked"';
 191      } else {
 192          $faqData['comment'] = '';
 193      }
 194  
 195      // Start header
 196  ?>
 197          <header>
 198              <h2>
 199  <?php
 200      if (0 !== $faqData['id'] && 'copyentry' !== $action) {
 201          $currentRevision = sprintf(
 202              ' <span class="badge badge-important">%s 1.%d</span> ',
 203              $PMF_LANG['ad_entry_revision'],
 204              $selectedRevisionId
 205          );
 206          printf(
 207              '<i class="icon-pencil"></i> %s <span class="text-error">%s</span> %s %s',
 208              $PMF_LANG['ad_entry_edit_1'],
 209              (0 === $faqData['id'] ? '' : $faqData['id']),
 210              $PMF_LANG['ad_entry_edit_2'],
 211              $currentRevision
 212          );
 213      } else {
 214          printf('<i class="icon-pencil"></i> %s', $PMF_LANG['ad_entry_add']);
 215      }
 216      // Revisions
 217      if ($permission["changebtrevs"]) {
 218  
 219          $revisions = $faq->getRevisionIds($faqData['id'], $faqData['lang']);
 220          if (count($revisions)) {
 221              ?>
 222                  <div class="pull-right">
 223                      <form id="selectRevision" name="selectRevision" method="post" accept-charset="utf-8"
 224                            action="?action=editentry&amp;id=<?php echo $faqData['id'] ?>&amp;lang=<?php echo $faqData['lang'] ?>">
 225                          <select name="revisionid_selected" onchange="selectRevision.submit();">
 226                              <option value="<?php echo $faqData['revision_id']; ?>">
 227                                  <?php echo $PMF_LANG['ad_changerev']; ?>
 228                              </option>
 229                              <?php foreach ($revisions as $revisionId => $revisionData) { ?>
 230                                  <option value="<?php echo $revisionData['revision_id']; ?>" <?php if ($selectedRevisionId == $revisionData['revision_id']) { echo 'selected="selected"'; } ?> >
 231                                      <?php printf(
 232                                          '%s 1.%d: %s - %s',
 233                                          $PMF_LANG['ad_entry_revision'],
 234                                          $revisionData['revision_id'],
 235                                          PMF_Date::createIsoDate($revisionData['datum']),
 236                                          $revisionData['author']
 237                                      ); ?>
 238                                  </option>
 239                              <?php } ?>
 240                          </select>
 241                      </form>
 242                  </div>
 243          <?php
 244          }
 245  
 246          if (isset($selectedRevisionId) &&
 247                  isset($faqData['revision_id']) &&
 248                  $selectedRevisionId != $faqData['revision_id']) {
 249  
 250              $faq->language = $faqData['lang'];
 251              $faq->getRecord($faqData['id'], $selectedRevisionId, true);
 252              $faqData         = $faq->faqRecord;
 253              $faqData['tags'] = implode(',', $tagging->getAllTagsById($faqData['id']));
 254          }
 255      }
 256  ?>
 257              </h2>
 258          </header>
 259  
 260          <div class="row-fluid">
 261  
 262              <form id="faqEditor" action="?action=<?php echo $queryString; ?>" method="post" accept-charset="utf-8">
 263              <input type="hidden" name="revision_id" id="revision_id" value="<?php echo $faqData['revision_id']; ?>" />
 264              <input type="hidden" name="record_id" id="record_id" value="<?php echo $faqData['id']; ?>" />
 265              <input type="hidden" name="csrf" value="<?php echo $user->getCsrfTokenFromSession(); ?>" />
 266              <input type="hidden" name="openQuestionId" id="openQuestionId" value="<?php echo $questionId; ?>" />
 267              <input type="hidden" name="notifyUser" id="notifyUser" value="<?php echo $notifyUser ?>" />
 268              <input type="hidden" name="notifyEmail" id="notifyEmail" value="<?php echo $notifyEmail ?>" />
 269  
 270              <!-- main editor window -->
 271              <div class="span8">
 272                  <fieldset class="form-inline">
 273                      <!-- Question -->
 274                      <div class="control-group">
 275                          <div class="controls">
 276                              <textarea name="question" id="question" class="admin-question span11" rows="2"
 277                                        placeholder="<?php echo $PMF_LANG['ad_entry_theme']; ?>"><?php
 278                                  echo $faqData['title'] ?></textarea>
 279                          </div>
 280                      </div>
 281                      <!-- Answer -->
 282                      <div class="control-group">
 283                          <div class="controls">
 284                              <noscript>Please enable JavaScript to use the WYSIWYG editor!</noscript>
 285                              <textarea id="answer" name="answer" class="span8">
 286                                  <?php echo $faqData['content'] ?>
 287                              </textarea>
 288                          </div>
 289                      </div>
 290                  </fieldset>
 291                  <fieldset class="form-horizontal">
 292                      <!-- Meta data -->
 293                      <div class="control-group">
 294                          <label class="control-label" for="lang"><?php echo $PMF_LANG["ad_entry_locale"]; ?>:</label>
 295                          <div class="controls">
 296                              <?php echo PMF_Language::selectLanguages($faqData['lang'], false, array(), 'lang'); ?>
 297                          </div>
 298                       </div>
 299                  </fieldset>
 300                  <fieldset class="form-horizontal">
 301                      <!-- Attachments -->
 302                      <?php if ($permission['addattachment']): ?>
 303                      <div class="control-group">
 304                          <label class="control-label"><?php echo $PMF_LANG['ad_menu_attachments'] ?>:</label>
 305                          <div class="controls">
 306                              <ul class="adminAttachments">
 307                                  <?php
 308                                  $attList = PMF_Attachment_Factory::fetchByRecordId($faqConfig, $faqData['id']);
 309                                  foreach ($attList as $att) {
 310                                      printf(
 311                                          '<li><a href="../%s">%s</a> ',
 312                                          $att->buildUrl(),
 313                                          $att->getFilename()
 314                                      );
 315                                      if ($permission['delattachment']) {
 316                                          printf(
 317                                              '<a class="label label-important" href="?action=delatt&amp;record_id=%d&amp;id=%d&amp;lang=%s"><i class="icon-trash icon-white"></i></a>',
 318                                              $faqData['id'],
 319                                              $att->getId(),
 320                                              $faqData['lang']
 321                                          );
 322                                      }
 323                                      echo "</li>\n";
 324                                  }
 325                                  ?>
 326                              </ul>
 327                                  <?php
 328                                  if (0 === $faqData['id']) {
 329                                      $faqData['id'] = $faqConfig->getDb()->nextId(
 330                                          PMF_Db::getTablePrefix() . 'faqdata',
 331                                          'id'
 332                                      );
 333                                  }
 334                                  printf(
 335                                      '<a class="btn btn-success" onclick="addAttachment(\'attachment.php?record_id=%d&amp;record_lang=%s\', \'Attachment\');">%s</a>',
 336                                      $faqData['id'],
 337                                      $faqData['lang'],
 338                                      $PMF_LANG['ad_att_add']
 339                                  );
 340                              ?>
 341                          </div>
 342                      </div>
 343                      <?php endif; ?>
 344                      <!-- Tags -->
 345                      <div class="control-group">
 346                          <label class="control-label" for="tags"><?php echo $PMF_LANG['ad_entry_tags']; ?>:</label>
 347                          <div class="controls">
 348                              <input type="text" name="tags" id="tags" value="<?php echo $faqData['tags'] ?>"
 349                                     data-provide="typeahead" data-mode="multiple" autocomplete="off" />
 350                              <span id="tagsHelp" class="hide"><?php echo $PMF_LANG['msgShowHelp']; ?></span>
 351                          </div>
 352                      </div>
 353                      <!-- Keywords -->
 354                      <div class="control-group">
 355                          <label class="control-label" for="keywords"><?php echo $PMF_LANG["ad_entry_keywords"]; ?></label>
 356                          <div class="controls">
 357                              <input type="text" name="keywords" id="keywords"  maxlength="255"
 358                                     value="<?php echo $faqData['keywords'] ?>" />
 359                              <span id="keywordsHelp" class="hide"><?php echo $PMF_LANG['msgShowHelp']; ?></span>
 360                          </div>
 361                      </div>
 362                  </fieldset>
 363                  <fieldset class="form-horizontal">
 364                      <?php
 365                      if ('00000000000000' == $faqData['dateStart']) {
 366                          $faqData['dateStart'] = '';
 367                      } else {
 368                          $faqData['dateStart'] = preg_replace("/(\d{4})(\d{2})(\d{2}).*/", "$1-$2-$3", $faqData['dateStart']);
 369                      }
 370  
 371                      if ('99991231235959' == $faqData['dateEnd']) {
 372                          $faqData['dateEnd'] = '';
 373                      } else {
 374                          $faqData['dateEnd'] = preg_replace("/(\d{4})(\d{2})(\d{2}).*/", "$1-$2-$3", $faqData['dateEnd']);
 375                      }
 376                      ?>
 377                      <legend><?php echo $PMF_LANG['ad_record_expiration_window']; ?></legend>
 378                      <div class="control-group">
 379                          <label class="control-label" for="dateStart"><?php echo $PMF_LANG['ad_news_from']; ?></label>
 380                          <div class="controls">
 381                              <input name="dateStart" id="dateStart" class="date-pick span2"  maxlength="10"
 382                                     value="<?php echo $faqData['dateStart']; ?>" />
 383                          </div>
 384                      </div>
 385                      <div class="control-group">
 386                          <label class="control-label" for="dateEnd"><?php echo $PMF_LANG['ad_news_to']; ?></label>
 387                          <div class="controls">
 388                              <input name="dateEnd" id="dateEnd" class="date-pick span2" maxlength="10"
 389                                     value="<?php echo $faqData['dateEnd']; ?>" />
 390                          </div>
 391                      </div>
 392                  </fieldset>
 393                  <fieldset class="form-horizontal">
 394                      <!-- Author -->
 395                      <div class="control-group">
 396                          <label class="control-label" for="author"><?php echo $PMF_LANG["ad_entry_author"]; ?></label>
 397                          <div class="controls">
 398                              <input type="text" name="author" id="author" value="<?php echo $faqData['author'] ?>" />
 399                          </div>
 400                      </div>
 401                      <!-- E-Mail -->
 402                      <div class="control-group">
 403                          <label class="control-label" for="email"><?php echo $PMF_LANG["ad_entry_email"]; ?></label>
 404                          <div class="controls">
 405                              <input type="email" name="email" id="email" value="<?php echo $faqData['email'] ?>" />
 406                          </div>
 407                      </div>
 408                  </fieldset>
 409                  <fieldset class="form-horizontal">
 410                      <legend><?php echo $PMF_LANG['ad_entry_changelog']; ?></legend>
 411                      <div class="control-group" id="editChangelog">
 412                          <label class="control-label"><?php echo $PMF_LANG["ad_entry_date"]; ?></label>
 413                          <div class="controls">
 414                              <span class="input-medium uneditable-input"><?php echo $faqData['date'] ?></span>
 415                          </div>
 416                      </div>
 417                      <div class="control-group">
 418                          <label class="control-label" for="changed"><?php echo $PMF_LANG["ad_entry_changed"]; ?></label>
 419                          <div class="controls">
 420                              <textarea name="changed" id="changed" class="span8">
 421                                  <?php echo $faqData['changed'] ?>
 422                              </textarea>
 423                          </div>
 424                      </div>
 425                  </fieldset>
 426                  <!-- Changelog -->
 427                  <?php if (is_numeric($faqData['id'])): ?>
 428                  <fieldset>
 429                      <legend>
 430                          <a id="toggleChangelog" class="pointer">
 431                              <?php echo $PMF_LANG['ad_entry_changelog_history']; ?>
 432                          </a>
 433                      </legend>
 434                      <div id="editChangelogHistory" class="hide">
 435                          <?php
 436                          foreach ($faq->getChangeEntries($faqData['id']) as $entry) {
 437                              $user->getUserById($entry['user']);
 438                              ?>
 439                              <p style="font-size: 10px;">
 440                                  <label>
 441                                      <?php printf('%s  1.%d | %s | %s %s',
 442                                      $PMF_LANG['ad_entry_revision'],
 443                                      $entry['revision_id'],
 444                                      $date->format(date('Y-m-d H:i', $entry['date'])),
 445                                      $PMF_LANG['ad_entry_author'],
 446                                      $user->getUserData('display_name')); ?>
 447                                  </label>
 448                                  <?php echo $entry['changelog']; ?>
 449                              </p>
 450                              <?php } ?>
 451                  </fieldset>
 452                  <?php endif; ?>
 453              </div>
 454  
 455              <!-- sidebar -->
 456              <div class="well span3">
 457                  <!-- form actions -->
 458                  <fieldset>
 459                      <div class="control-group">
 460                          <label class="control-label" for="dateActualize"><?php echo $PMF_LANG["ad_entry_date"]; ?></label>
 461                          <div class="controls">
 462                              <label class="radio">
 463                                  <input type="radio" id="dateActualize" checked="checked" name="recordDateHandling"
 464                                         onchange="setRecordDate(this.id);" />
 465                                  <?php echo $PMF_LANG['msgUpdateFaqDate']; ?>
 466                              </label>
 467                              <label class="radio">
 468                                  <input type="radio" id="dateKeep" name="recordDateHandling"
 469                                         onchange="setRecordDate(this.id);" />
 470                                  <?php echo $PMF_LANG['msgKeepFaqDate']; ?>
 471                              </label>
 472                              <label class="radio">
 473                                  <input type="radio" id="dateCustomize" name="recordDateHandling"
 474                                         onchange="setRecordDate(this.id);" />
 475                                  <?php echo $PMF_LANG['msgEditFaqDat']; ?>
 476                              </label>
 477                          </div>
 478                      </div>
 479                      <div id="recordDateInputContainer" class="control-group hide">
 480                          <div class="controls">
 481                              <input type="text" name="date" id="date" maxlength="16" value="" class="input-small" />
 482                          </div>
 483                      </div>
 484                      <?php if ($selectedRevisionId == $faqData['revision_id']): ?>
 485                      <div class="form-actions">
 486                          <button class="btn btn-primary" type="submit">
 487                              <?php echo $PMF_LANG["ad_entry_save"]; ?>
 488                          </button>
 489                          <button class="btn btn-info" type="reset">
 490                              <?php echo $PMF_LANG["ad_gen_reset"]; ?>
 491                          </button>
 492                      </div>
 493                      <?php endif; ?>
 494                  </fieldset>
 495                  <!-- categories -->
 496                  <fieldset>
 497                      <div class="control-group">
 498                          <label class="control-label"><?php echo $PMF_LANG["ad_entry_category"]; ?></label>
 499                          <div class="controls">
 500                              <select name="rubrik[]" id="phpmyfaq-categories" size="5" multiple="multiple"
 501                                      class="input-medium">
 502                                  <?php echo $categoryHelper->renderOptions($categories); ?>
 503                              </select>
 504                          </div>
 505                      </div>
 506                  </fieldset>
 507                  <!-- Activation -->
 508                  <fieldset>
 509                      <div class="control-group">
 510                          <label class="control-label" for="active"><?php echo $PMF_LANG["ad_entry_active"]; ?></label>
 511                          <div class="controls">
 512                          <?php if($permission['approverec']):
 513                          if (isset($faqData['active']) && $faqData['active'] == 'yes') {
 514                              $suf = ' checked="checked"';
 515                              $sul = null;
 516                          } elseif ($faqConfig->get('records.defaultActivation')) {
 517                              $suf = ' checked="checked"';
 518                              $sul = null;
 519                          } else {
 520                              $suf = null;
 521                              $sul = ' checked="checked"';
 522                          }
 523                          ?>
 524                              <label class="radio">
 525                                  <input type="radio" id="active" name="active"  value="yes"<?php if (isset($suf)) { echo $suf; } ?> />
 526                                  <?php echo $PMF_LANG['ad_gen_yes']; ?>
 527                              </label>
 528                              <label class="radio">
 529                                  <input type="radio" name="active"  value="no"<?php if (isset($sul)) { echo $sul; } ?> />
 530                                  <?php echo $PMF_LANG['ad_gen_no']; ?>
 531                              </label>
 532                              <?php else: ?>
 533                              <label class="radio">
 534                                  <input type="radio" name="active"  value="no" checked="checked" />
 535                                  <?php echo $PMF_LANG['ad_gen_no']; ?>
 536                              </label>
 537                          <?php endif; ?>
 538                          </div>
 539                      </div>
 540                      <div class="control-group">
 541                          <label class="control-label" for="sticky"><?php echo $PMF_LANG['ad_entry_sticky']; ?>:</label>
 542                          <div class="controls">
 543                              <label class="checkbox">
 544                                  <input type="checkbox" id="sticky" name="sticky" <?php echo (isset($faqData['sticky']) && $faqData['sticky'] ? 'checked="checked"' : '') ?> />
 545                                  &nbsp;
 546                              </label>
 547                          </div>
 548                      </div>
 549                      <div class="control-group">
 550                          <label class="control-label" for="comment">
 551                              <?php echo $PMF_LANG['ad_entry_allowComments']; ?>
 552                          </label>
 553                          <div class="controls">
 554                              <label class="checkbox">
 555                                  <input type="checkbox" name="comment" id="comment" value="y"<?php echo $faqData['comment'] ?> />
 556                                  <?php echo $PMF_LANG['ad_gen_yes']; ?>
 557                              </label>
 558                          </div>
 559                      </div>
 560                      <?php if ($queryString != 'insertentry'): ?>
 561                      <div class="control-group">
 562                          <label class="control-label" for="revision">
 563                              <?php echo $PMF_LANG['ad_entry_new_revision']; ?>
 564                          </label>
 565                          <?php
 566                          if ($queryString != 'insertentry') {
 567                              $rev_yes = ' checked="checked"';
 568                              $rev_no  = null;
 569                          }
 570                          if (isset($faqData['active']) && $faqData['active'] == 'no') {
 571                              $rev_no  = ' checked="checked"';
 572                              $rev_yes = null;
 573                          }
 574                          ?>
 575                          <div class="controls">
 576                              <label class="radio">
 577                                  <input type="radio" name="revision" id="revision" value="yes"<?php echo isset($rev_yes) ? $rev_yes : ''; ?>/>
 578                                  <?php echo $PMF_LANG["ad_gen_yes"]; ?>
 579                              </label>
 580                              <label class="radio">
 581                                  <input type="radio" name="revision" value="no"<?php echo isset($rev_no) ? $rev_no : ''; ?>/>
 582                                  <?php echo $PMF_LANG["ad_gen_no"]; ?>
 583                              </label>
 584                          </div>
 585                      </div>
 586                      <?php endif; ?>
 587                      <div class="control-group">
 588                          <label class="control-label" for="solution_id"><?php echo $PMF_LANG['ad_entry_solution_id']; ?>:</label>
 589                          <div class="controls">
 590                              <input name="solution_id" id="solution_id" style="width: 50px; text-align: right;" size="5"
 591                                     readonly="readonly" value="<?php echo (isset($faqData['solution_id']) ? $faqData['solution_id'] : $faq->getSolutionId()); ?>"  />
 592                          </div>
 593                      </div>
 594                  </fieldset>
 595                  <!-- Permissions -->
 596                  <fieldset class="form-inline">
 597                      <?php if ($faqConfig->get('security.permLevel') != 'basic'): ?>
 598                      <div class="control-group">
 599                          <label class="control-label" for="grouppermission"><?php echo $PMF_LANG['ad_entry_grouppermission']; ?></label>
 600                          <div class="controls">
 601                              <label class="radio">
 602                                  <input type="radio" id="allgroups" name="grouppermission" value="all" <?php echo ($allGroups ? 'checked="checked"' : ''); ?>/>
 603                                  <?php echo $PMF_LANG['ad_entry_all_groups']; ?>
 604                              </label>
 605                              <label class="radio">
 606                                  <input type="radio" id="restrictedgroups" name="grouppermission" value="restricted" <?php echo ($restrictedGroups ? 'checked="checked"' : ''); ?>/>
 607                                  <?php echo $PMF_LANG['ad_entry_restricted_groups']; ?>
 608                                  <select name="restricted_groups[]" size="3" class="input-medium selected-groups" multiple>
 609                                      <?php echo $user->perm->getAllGroupsOptions($groupPermission); ?>
 610                                  </select>
 611                              </label>
 612                          </div>
 613                      </div>
 614                      <?php else: ?>
 615                      <input type="hidden" name="grouppermission" value="all" />
 616                      <?php endif; ?>
 617                      <div class="control-group">
 618                          <label class="control-label" for="userpermission"><?php echo $PMF_LANG['ad_entry_userpermission']; ?></label>
 619                          <div class="controls">
 620                              <label class="radio">
 621                                  <input type="radio" id="allusers" name="userpermission" value="all" <?php echo ($allUsers ? 'checked="checked"' : ''); ?>/>
 622                                  <?php echo $PMF_LANG['ad_entry_all_users']; ?>
 623                              </label>
 624                              <label class="radio">
 625                                  <input type="radio" id="restrictedusers" name="userpermission" value="restricted" <?php echo ($restrictedUsers ? 'checked="checked"' : ''); ?>/>
 626                                  <?php echo $PMF_LANG['ad_entry_restricted_users']; ?>
 627                                  <select name="restricted_users" size="1" class="input-medium selected-groups">
 628                                      <?php echo $user->getAllUserOptions($userPermission[0]); ?>
 629                                  </select>
 630                              </label>
 631                          </div>
 632                      </div>
 633                  </fieldset>
 634              </div>
 635              </form>
 636          </div>
 637  
 638      <script type="text/javascript">
 639      /* <![CDATA[ */
 640  
 641      function extractor(query) {
 642          var result = /([^,]+)$/.exec(query);
 643          if(result && result[1])
 644              return result[1].trim();
 645          return '';
 646      }
 647  
 648      $('#tags').typeahead({
 649          source: function (query, process) {
 650              return $.get("index.php?action=ajax&ajax=tags_list", { q: query }, function (data) {
 651                  return process(data.tags);
 652              });
 653          },
 654          updater: function(item) {
 655              return this.$element.val().replace(/[^,]*$/,'')+item+',';
 656          },
 657          matcher: function (item) {
 658              var tquery = extractor(this.query.toLowerCase());
 659              if(!tquery) return false;
 660              return ~item.toLowerCase().indexOf(tquery)
 661          },
 662          highlighter: function (item) {
 663              var query = extractor(this.query).replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
 664              return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
 665                  return '<strong>' + match + '</strong>'
 666              })
 667          }
 668      });
 669  
 670      $(function() {
 671          // DatePicker
 672          $('.date-pick').datePicker();
 673          $('#date').datePicker({startDate: '1900-01-01'});
 674          $('#date').bind('dateSelected', function (e, date, $td, status) {
 675              if (status) {
 676                  var dt = new Date();
 677                  var hours   = dt.getHours();
 678                  var minutes = dt.getMinutes();
 679                  
 680                  $('#date').val(
 681                      date.asString() + ' ' + (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes
 682                  );
 683              }
 684          });
 685  
 686          // Show help for keywords and users
 687          $('#keywords').focus(function() { showHelp('keywords'); });
 688          $('#tags').focus(function() { showHelp('tags'); });
 689  
 690          // Override FAQ permissions with Category permission to avoid confused users
 691          $('#phpmyfaq-categories').click(function() {
 692              var categories = $('#phpmyfaq-categories option:selected').map(function() {
 693                  return $(this).val();
 694              }).get();
 695  
 696              $.ajax({
 697                  type: 'POST',
 698                  url:  'index.php?action=ajax&ajax=categories&ajaxaction=getpermissions',
 699                  data: "categories=" + categories,
 700                  success: function(permissions) {
 701                      var perms = jQuery.parseJSON(permissions);
 702  
 703                      if (-1 === parseInt(perms.user[0])) {
 704                          $('#restrictedusers').prop('checked', false).prop("disabled", true);
 705                          $('#allusers').prop('checked', true).prop("disabled", false);
 706                      } else {
 707                          $('#allusers').prop('checked', false).prop("disabled", true);
 708                          $('#restrictedusers').prop('checked', true).prop("disabled", false);
 709                          $.each(perms.user, function(key, value) {
 710                              $(".selected-users option[value='" + value + "']").prop('selected',true);
 711                          });
 712                      }
 713                      if (-1 === parseInt(perms.group[0])) {
 714                          $('#restrictedgroups').prop('checked', false).prop("disabled", true);
 715                          $('#allgroups').prop('checked', true).prop("disabled", false);
 716                      } else {
 717                          $('#allgroups').prop('checked', false).prop("disabled", true);
 718                          $('#restrictedgroups').prop('checked', true).prop("disabled", false);
 719                          $.each(perms.group, function(key, value) {
 720                              $(".selected-groups option[value='" + value + "']").prop('selected',true);
 721                          });
 722                      }
 723                  }
 724              });
 725          });
 726  
 727          // Toggle changelog tab
 728          $("#toggleChangelog").click(function() {
 729              if ("hide" === $("#editChangelogHistory").attr("class")) {
 730                  $("#editChangelogHistory").fadeIn('fast').removeAttr("class");
 731              } else {
 732                  $("#editChangelogHistory").fadeOut('fast').attr("class", "hide");
 733              }
 734          });
 735      });
 736  
 737      function showIDContainer() {
 738          var display = 0 == arguments.length || !!arguments[0] ? 'block' : 'none';
 739          $('#recordDateInputContainer').attr('style', 'display: ' + display);
 740      }
 741  
 742      function setRecordDate(how) {
 743          if ('dateActualize' === how) {
 744              showIDContainer(false);
 745              $('#date').val('');
 746          } else if ('dateKeep' === how) {
 747              showIDContainer(false);
 748              $('#date').val('<?php echo $faqData['date']; ?>');
 749          } else if ('dateCustomize' === how) {
 750              showIDContainer(true);
 751              $('#date').val('');
 752          }
 753      }
 754  
 755      function showHelp(option) {
 756          $('#' + option + 'Help').fadeIn(500);
 757          $('#' + option + 'Help').fadeOut(2500);
 758      }
 759      /* ]]> */
 760      </script>
 761  <?php
 762  } elseif ($permission["editbt"] != 1 && !PMF_Db::checkOnEmptyTable('faqcategories')) {
 763      echo $PMF_LANG["err_NotAuth"];
 764  } elseif ($permission["editbt"] && PMF_Db::checkOnEmptyTable('faqcategories')) {
 765      echo $PMF_LANG["no_cats"];
 766  }

title

Description

title

Description

title

Description

title

title

Body