Example #1
0
 /**
  * Returns the single instance
  *
  * @access static
  * @return PMF_Visits
  */
 public static function getInstance()
 {
     if (null == self::$instance) {
         $className = __CLASS__;
         self::$instance = new $className();
     }
     return self::$instance;
 }
Example #2
0
     $category->addPermission('user', $categories['rubrik'], $restricted_users);
     if ($faqConfig->get('security.permLevel') != 'basic') {
         $faq->deletePermission('group', $record_id);
         $faq->addPermission('group', $record_id, $restricted_groups);
         $category->deletePermission('group', $categories['rubrik']);
         $category->addPermission('group', $categories['rubrik'], $restricted_groups);
     }
 } else {
     if ('insertentry' == $do) {
         unset($recordData['id']);
         unset($recordData['revision_id']);
         $revision_id = 1;
         $record_id = $faq->addRecord($recordData);
         if ($record_id) {
             $faq->createChangeEntry($record_id, $user->getUserId(), nl2br($changed), $recordData['lang']);
             $visits = new PMF_Visits($faqConfig);
             $visits->add($record_id);
             $faq->addCategoryRelations($categories['rubrik'], $record_id, $recordData['lang']);
             if ($tags != '') {
                 $tagging->saveTags($record_id, explode(',', $tags));
             }
             $faq->addPermission('user', $record_id, $restricted_users);
             $category->addPermission('user', $categories['rubrik'], $restricted_users);
             if ($faqConfig->get('security.permLevel') != 'basic') {
                 $faq->addPermission('group', $record_id, $restricted_groups);
                 $category->addPermission('group', $categories['rubrik'], $restricted_groups);
             }
         }
     }
 }
 $response->setData(array('msg' => sprintf("Item autosaved at revision %d", $revision_id), 'revision_id' => $revision_id, 'record_id' => $record_id));
Example #3
0
     while ($row = $db->fetchObject($result)) {
         if ($searchcat != 0 && $searchcat != (int) $row->category_id) {
             continue;
         }
         $faq->faqRecords[] = array('id' => $row->id, 'category_id' => $row->category_id, 'solution_id' => $row->solution_id, 'lang' => $row->lang, 'active' => $row->active, 'sticky' => $row->sticky, 'title' => $row->thema, 'content' => $row->content, 'date' => PMF_Date::createIsoDate($row->date));
         if (!isset($numActiveByCat[$row->category_id])) {
             $numActiveByCat[$row->category_id] = 0;
         }
         $numActiveByCat[$row->category_id] += $row->active ? 1 : 0;
     }
 }
 $num = count($faq->faqRecords);
 if ($num > 0) {
     $old = 0;
     $all_ids = $visits = array();
     foreach (PMF_Visits::getInstance()->getAllData() as $visit) {
         $visits[$visit['id']] = $visit['lang'];
     }
     foreach ($faq->faqRecords as $record) {
         $catInfo = '';
         $isBracketOpened = false;
         $needComma = false;
         $cid = $record['category_id'];
         if (isset($numRecordsByCat[$cid]) && $numRecordsByCat[$cid] > 0) {
             if (!$isBracketOpened) {
                 $catInfo .= ' (';
                 $isBracketOpened = true;
             }
             $catInfo .= sprintf('<span id="category_%d_item_count">%d</span> %s', $cid, $numRecordsByCat[$cid], $PMF_LANG['msgEntries']);
         }
         if (isset($numRecordsByCat[$cid]) && $numRecordsByCat[$cid] > $numActiveByCat[$cid]) {
Example #4
0
if (!is_null($showCaptcha)) {
    $captcha->showCaptchaImg();
    exit;
}
$currentCategory = $cat;
$record_id = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
$solution_id = PMF_Filter::filterInput(INPUT_GET, 'solution_id', FILTER_VALIDATE_INT);
$highlight = PMF_Filter::filterInput(INPUT_GET, 'highlight', FILTER_SANITIZE_STRIPPED);
$faqsession->userTracking('article_view', $record_id);
// Get all data from the FAQ record
if (0 == $solution_id) {
    $faq->getRecord($record_id);
} else {
    $faq->getRecordBySolutionId($solution_id);
}
$faqvisits = PMF_Visits::getInstance();
$faqvisits->logViews($faq->faqRecord['id']);
$content = $faq->faqRecord['content'];
$thema = $faq->getRecordTitle($faq->faqRecord['id']);
// Add Glossary entries
$content = $oGlossary->insertItemsIntoContent($content);
$thema = $oGlossary->insertItemsIntoContent($thema);
// Set the path of the current category
$categoryName = $categoryLayout->renderBreadcrumb($categoryPath);
$changeLanguagePath = PMF_Link::getSystemRelativeUri() . sprintf('?%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s', $sids, $currentCategory, $id, $LANGCODE);
$oLink = new PMF_Link($changeLanguagePath);
$oLink->itemTitle = $faq->getRecordTitle($record_id, false);
$changeLanguagePath = $oLink->toString();
$highlight = PMF_Filter::filterInput(INPUT_GET, 'highlight', FILTER_SANITIZE_STRIPPED);
if (!is_null($highlight) && $highlight != "/" && $highlight != "<" && $highlight != ">" && PMF_String::strlen($highlight) > 3) {
    $highlight = str_replace("'", "´", $highlight);
 // new entry
 $logging = new PMF_Logging($faqConfig);
 $logging->logAdmin($user, 'Beitragcreatesave');
 printf("<h2>%s</h2>\n", $PMF_LANG['ad_entry_aor']);
 $category = new PMF_Category($faqConfig, array(), false);
 $category->setUser($currentAdminUser);
 $category->setGroups($currentAdminGroups);
 $tagging = new PMF_Tags($faqConfig);
 $recordData = array('lang' => $recordLang, 'active' => $active, 'sticky' => !is_null($sticky) ? 1 : 0, 'thema' => html_entity_decode($question), 'content' => html_entity_decode($content), 'keywords' => $keywords, 'author' => $author, 'email' => $email, 'comment' => !is_null($comment) ? 'y' : 'n', 'date' => date('YmdHis'), 'dateStart' => empty($dateStart) ? '00000000000000' : str_replace('-', '', $dateStart) . '000000', 'dateEnd' => empty($dateEnd) ? '99991231235959' : str_replace('-', '', $dateEnd) . '235959', 'linkState' => '', 'linkDateCheck' => 0);
 // Add new record and get that ID
 $recordId = $faq->addRecord($recordData);
 if ($recordId) {
     // Create ChangeLog entry
     $faq->createChangeEntry($recordId, $user->getUserId(), nl2br($changed), $recordData['lang']);
     // Create the visit entry
     $visits = new PMF_Visits($faqConfig);
     $visits->add($recordId);
     // Insert the new category relations
     $faq->addCategoryRelations($categories['rubrik'], $recordId, $recordData['lang']);
     // Insert the tags
     if ($tags != '') {
         $tagging->saveTags($recordId, explode(',', trim($tags)));
     }
     // Add user permissions
     $faq->addPermission('user', $recordId, $permissions['restricted_user']);
     $category->addPermission('user', $categories['rubrik'], $permissions['restricted_user']);
     // Add group permission
     if ($faqConfig->get('security.permLevel') != 'basic') {
         $faq->addPermission('group', $recordId, $permissions['restricted_groups']);
         $category->addPermission('group', $categories['rubrik'], $permissions['restricted_groups']);
     }
Example #6
0
     $newData['id'] = $faqid;
     $categories = $category->getCategoryIdsFromArticle($newData['id']);
 }
 $recordId = $faq->addRecord($newData, $isNew);
 $faq->addCategoryRelations($categories, $recordId, $newData['lang']);
 $openQuestionId = PMF_Filter::filterInput(INPUT_POST, 'openQuestionID', FILTER_VALIDATE_INT);
 if ($openQuestionId) {
     if ($faqConfig->get('records.enableDeleteQuestion')) {
         $faq->deleteQuestion($openQuestionId);
     } else {
         // adds this faq record id to the related open question
         $faq->updateQuestionAnswer($openQuestionId, $recordId, $categories[0]);
     }
 }
 // Activate visits
 $visits = new PMF_Visits($faqConfig);
 $visits->add($recordId, $newData['lang']);
 if ($autoActivate) {
     // Add user permissions
     $faq->addPermission('user', $recordId, array(-1));
     $category->addPermission('user', $categories['rubrik'], array(-1));
     // Add group permission
     if ($faqConfig->get('security.permLevel') != 'basic') {
         $faq->addPermission('group', $recordId, array(-1));
         $category->addPermission('group', $categories['rubrik'], array(-1));
     }
 }
 // Let the PMF Administrator and the Category Owner to be informed by email of this new entry
 $send = [];
 $mail = new PMF_Mail($faqConfig);
 $mail->setReplyTo($email, $name);
Example #7
0
$currentCategory = $cat;
$recordId = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
$solutionId = PMF_Filter::filterInput(INPUT_GET, 'solution_id', FILTER_VALIDATE_INT);
// Get all data from the FAQ record
if (0 == $solutionId) {
    $faq->getRecord($recordId);
} else {
    $faq->getRecordBySolutionId($solutionId);
}
$recordId = $faq->faqRecord['id'];
try {
    $faqsession->userTracking('article_view', $recordId);
} catch (PMF_Exception $e) {
    // @todo handle the exception
}
$faqVisits = new PMF_Visits($faqConfig);
$faqVisits->logViews($recordId);
// Add Glossary entries for answers only
$question = $faq->getRecordTitle($recordId);
$answer = $oGlossary->insertItemsIntoContent($faq->faqRecord['content']);
// Set the path of the current category
$categoryName = $category->getPath($currentCategory, ' &raquo; ', true);
$changeLanguagePath = PMF_Link::getSystemRelativeUri() . sprintf('?%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s', $sids, $currentCategory, $recordId, $LANGCODE);
$oLink = new PMF_Link($changeLanguagePath, $faqConfig);
$oLink->itemTitle = $faq->getRecordTitle($recordId, false);
$changeLanguagePath = $oLink->toString();
$highlight = PMF_Filter::filterInput(INPUT_GET, 'highlight', FILTER_SANITIZE_STRIPPED);
if (!is_null($highlight) && $highlight != "/" && $highlight != "<" && $highlight != ">" && PMF_String::strlen($highlight) > 3) {
    $highlight = str_replace("'", "´", $highlight);
    $highlight = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']'), '', $highlight);
    $highlight = preg_quote($highlight, '/');
         }
         $numActiveByCat[$row->category_id] += $row->active ? 1 : 0;
         $idsFound[] = $row->id;
     }
     // Sort search result ordered by category ID
     ksort($faqsFound);
     foreach ($faqsFound as $categoryId => $faqFound) {
         foreach ($faqFound as $singleFaq) {
             $faq->faqRecords[] = $singleFaq;
         }
     }
 }
 if (count($faq->faqRecords) > 0) {
     $old = 0;
     $faqIds = array();
     $visits = new PMF_Visits($faqConfig);
     $numVisits = array();
     foreach ($visits->getAllData() as $visit) {
         $numVisits[$visit['id']] = $visit['lang'];
     }
     foreach ($faq->faqRecords as $record) {
         $catInfo = '';
         $cid = $record['category_id'];
         if (isset($numRecordsByCat[$cid]) && $numRecordsByCat[$cid] > 0) {
             $catInfo .= sprintf('<span class="label label-info" id="category_%d_item_count">%d %s</span> ', $cid, $numRecordsByCat[$cid], $PMF_LANG['msgEntries']);
         }
         if (isset($numRecordsByCat[$cid]) && $numRecordsByCat[$cid] > $numActiveByCat[$cid]) {
             $catInfo .= sprintf('<span class="label label-important"><span id="js-active-records-%d">%d</span> %s</span> ', $cid, $numRecordsByCat[$cid] - $numActiveByCat[$cid], $PMF_LANG['ad_record_inactive']);
         }
         if (isset($numCommentsByCat[$cid]) && $numCommentsByCat[$cid] > 0) {
             $catInfo .= sprintf('<span class="label label-inverse">%d %s</span>', $numCommentsByCat[$cid], $PMF_LANG['ad_start_comments']);