Пример #1
0
 $faqChangelog->create($changelogData);
 // Create the visit entry
 $visits = PMF_Visits::getInstance();
 $visits->add($recordId, $recordData['lang']);
 // Insert the new category relations
 $categoryRelations = new PMF_Category_Relations();
 // Insert the tags
 if ($tags != '') {
     $tagging = new PMF_Tags();
     $tagging->saveTags($recordId, explode(',', $tags));
 }
 // Set record permissions
 $faqUser = new PMF_Faq_User();
 $faqUser->create(array('record_id' => $recordId, 'user_id' => $restricted_users));
 if ($groupSupport) {
     $faqGroup = new PMF_Faq_Group();
     $faqGroup->create(array('record_id' => $recordId, 'group_id' => $restricted_groups));
 }
 // Loop the categories
 $categoryUser = new PMF_Category_User();
 $categoryGroup = new PMF_Category_Group();
 $categoryRelations = new PMF_Category_Relations();
 $categoryRelations->setLanguage($recordData['lang']);
 foreach ($categories['rubrik'] as $categoryId) {
     // Insert the new category relations
     $categoryData = array('category_id' => $categoryId, 'category_lang' => $categoryRelations->getLanguage(), 'record_id' => $recordId, 'record_lang' => $recordData['lang']);
     // save or update the category relations
     $categoryRelations->create($categoryData);
     // Add user permissions
     $userPermission = array('category_id' => $categoryId, 'user_id' => $restricted_users);
     $categoryUser->delete($categoryId);
Пример #2
0
<?php 
        } else {
            print $PMF_LANG['ad_entry_savedfail'] . $db->error();
        }
        // Insert the tags
        $tagging = new PMF_Tags();
        if ($tags != '') {
            $tagging->saveTags($record_id, explode(',', $tags));
        } else {
            $tagging->deleteTagsFromRecordId($record_id);
        }
        // Add record permissions
        $faqUser = new PMF_Faq_User();
        $faqUser->update($record_id, array('user_id' => $restricted_users));
        if ($groupSupport) {
            $faqGroup = new PMF_Faq_Group();
            $faqGroup->update($recordId, array('group_id' => $restricted_groups));
        }
        // Loop the categories
        $categoryUser = new PMF_Category_User();
        $categoryGroup = new PMF_Category_Group();
        $categoryRelations = new PMF_Category_Relations();
        $categoryRelations->setLanguage($record_lang);
        foreach ($categories['rubrik'] as $categoryId) {
            $categoryData = array('category_id' => $categoryId, 'category_lang' => $categoryRelations->getLanguage(), 'record_id' => $record_id, 'record_lang' => $record_lang);
            // delete category relations
            $categoryRelations->delete($categoryId);
            // save or update the category relations
            $categoryRelations->create($categoryData);
            // Add user permissions
            $userPermission = array('category_id' => $categoryId, 'user_id' => $restricted_users);
Пример #3
0
 $search = new PMF_Search($db, $Language);
 $search_result = array();
 $counter = 0;
 foreach ($search_stuff as $word) {
     $tmp = $search->search($word);
     foreach ($tmp as $foundItem) {
         if (!isset($foundItem->id, $search_result[$foundItem->category_id])) {
             $counter++;
             $foundItem->searchterm = PMF_String::htmlspecialchars(stripslashes($word), ENT_QUOTES, 'utf-8');
             $search_result[$foundItem->category_id][$foundItem->id] = $foundItem;
         }
     }
 }
 if ($search_result) {
     $faqUser = new PMF_Faq_User();
     $faqGroup = new PMF_Faq_Group();
     $search_result_html = '<p>' . $plr->GetMsg('plmsgSearchAmount', count($search_result)) . "</p>\n";
     $counter = 0;
     foreach ($search_result as $cat_id => $cat_contents) {
         $tmp_result_html = '';
         foreach ($cat_contents as $cat_content_item) {
             $b_permission = false;
             //Groups Permission Check
             if ($faqconfig->get('main.permLevel') == 'medium') {
                 $perm_group = $faqGroup->fetch($cat_content_item->id);
                 foreach ($current_groups as $index => $value) {
                     if ($value == $perm_group->group_id) {
                         $b_permission = true;
                     }
                 }
             }
Пример #4
0
 /**
  * Check on user and group permissions and on duplicate FAQs
  * 
  * @param array $resultset Array with search results
  * 
  * @return void
  */
 public function reviewResultset(array $resultset)
 {
     $this->setResultset($resultset);
     $faqUser = new PMF_Faq_User();
     $faqGroup = new PMF_Faq_Group();
     $duplicateResults = array();
     $currentUserId = $this->user->getUserId();
     if ('medium' == PMF_Configuration::getInstance()->get('main.permLevel')) {
         $currentGroupIds = $this->user->perm->getUserGroups($currentUserId);
     }
     foreach ($this->rawResultset as $index => $result) {
         $permission = false;
         // check permissions for groups
         if ('medium' == PMF_Configuration::getInstance()->get('main.permLevel')) {
             $groupPerm = $faqGroup->fetch($result->id);
             if (count($groupPerm) && in_array($groupPerm->group_id, $currentGroupIds)) {
                 $permission = true;
             }
         }
         // check permission for user
         if ($permission || 'basic' == PMF_Configuration::getInstance()->get('main.permLevel')) {
             $userPerm = $faqUser->fetch($result->id);
             if (-1 == $userPerm->user_id || $this->user->getUserId() == $userPerm->user_id) {
                 $permission = true;
             } else {
                 $permission = false;
             }
         }
         // check on duplicates
         if (!isset($duplicateResults[$result->id])) {
             $duplicateResults[$result->id] = 1;
         } else {
             ++$duplicateResults[$result->id];
             continue;
         }
         if ($permission) {
             $this->reviewedResultset[] = $result;
         }
     }
     $this->setNumberOfResults($this->reviewedResultset);
 }
Пример #5
0
 // Revisions
 $revisionid_selected = PMF_Filter::filterInput(INPUT_POST, 'revisionid_selected', FILTER_VALIDATE_INT);
 if (is_null($revisionid_selected)) {
     $revisionid_selected = $faqData['revision_id'];
 }
 // Permissions
 $faqUser = new PMF_Faq_User();
 $user_permission = $faqUser->fetch($faqData['id']);
 if (is_object($user_permission) || $user_permission->user_id == -1) {
     $all_users = true;
     $restricted_users = false;
 } else {
     $all_users = false;
     $restricted_users = true;
 }
 $faqGroup = new PMF_Faq_Group();
 $group_permission = $faqGroup->fetch($faqData['id']);
 if (is_object($group_permission) || $group_permission->group_id == -1) {
     $all_groups = true;
     $restricted_groups = false;
 } else {
     $all_groups = false;
     $restricted_groups = true;
 }
 print '<h2>' . $PMF_LANG["ad_entry_edit_1"];
 if ($faqData['id'] != 0 && $action != 'copyentry') {
     printf(' <span style="color: Red;">%d (%s 1.%d) </span> ', $faqData['id'], $PMF_LANG['ad_entry_revision'], $revisionid_selected);
 }
 print ' ' . $PMF_LANG["ad_entry_edit_2"] . '</h2>';
 if ($permission["changebtrevs"]) {
     $revisions = $faq->getRevisionIds($faqData['id'], $faqData['lang']);
Пример #6
0
/**
 * The main search function for the full text search
 *
 * TODO: add filter for (X)HTML tag names and attributes!
 *
 * @param   string  Text/Number (solution id)
 * @param   string  '%' to avoid any category filtering
 * @param   boolean true to search over all languages
 * @param   boolean true to disable the results paging
 * @param   boolean true to use it for Instant Response
 * @return  string
 * @access  public
 * @author  Thorsten Rinne <*****@*****.**>
 * @author  Matteo Scaramuccia <*****@*****.**>
 * @author  Adrianna Musiol <*****@*****.**>
 * @since   2002-09-16
 */
function searchEngine($searchterm, $cat = '%', $allLanguages = true, $hasMore = false, $instantRespnse = false)
{
    global $sids, $PMF_LANG, $plr, $LANGCODE, $faq, $current_user, $current_groups, $categoryLayout;
    $_searchterm = PMF_htmlentities(stripslashes($searchterm), ENT_QUOTES, 'utf-8');
    $seite = 1;
    $output = '';
    $num = 0;
    $searchItems = array();
    $langs = true == $allLanguages ? '&amp;langs=all' : '';
    $seite = PMF_Filter::filterInput(INPUT_GET, 'seite', FILTER_VALIDATE_INT, 1);
    $db = PMF_Db::getInstance();
    $faqconfig = PMF_Configuration::getInstance();
    $result = getSearchData(htmlentities($searchterm, ENT_COMPAT, 'utf-8'), true, $cat, $allLanguages);
    $num = $db->numRows($result);
    if (0 == $num) {
        $output = $PMF_LANG['err_noArticles'];
    }
    $confPerPage = $faqconfig->get('main.numberOfRecordsPerPage');
    $pages = ceil($num / $confPerPage);
    $last = $seite * $confPerPage;
    $first = $last - $confPerPage;
    if ($last > $num) {
        $last = $num;
    }
    if ($num > 0) {
        $output .= '<p>' . $plr->GetMsg('plmsgSearchAmount', $num);
        if ($hasMore && $pages > 1) {
            $output .= sprintf($PMF_LANG['msgInstantResponseMaxRecords'], $confPerPage);
        }
        $output .= "</p>\n";
        if (!$hasMore && $pages > 1) {
            $output .= "<p><strong>" . $PMF_LANG["msgPage"] . $seite . " " . $PMF_LANG["msgVoteFrom"] . " " . $plr->GetMsg('plmsgPagesTotal', $pages) . "</strong></p>";
        }
        $output .= "<ul class=\"phpmyfaq_ul\">\n";
        $faqUser = new PMF_Faq_User();
        $faqGroup = new PMF_Faq_Group();
        $counter = $displayedCounter = 0;
        while (($row = $db->fetchObject($result)) && $displayedCounter < $confPerPage) {
            $counter++;
            if ($counter <= $first) {
                continue;
            }
            $displayedCounter++;
            $b_permission = false;
            //Groups Permission Check
            if ($faqconfig->get('main.permLevel') == 'medium') {
                $perm_group = $faqGroup->fetch($row->id);
                foreach ($current_groups as $value) {
                    if ($value == $perm_group->group_id) {
                        $b_permission = true;
                    }
                }
            }
            if ($faqconfig->get('main.permLevel') == 'basic' || $b_permission) {
                $perm_user = $faqUser->fetch($row->id);
                foreach ($perm_user as $value) {
                    if ($value == -1) {
                        $b_permission = true;
                        break;
                    } elseif ((int) $value == $current_user) {
                        $b_permission = true;
                        break;
                    } else {
                        $b_permission = false;
                    }
                }
            }
            if ($b_permission) {
                $rubriktext = $categoryLayout->renderBreadcrumb(array($row->category_id));
                $thema = chopString($row->thema, 15);
                $content = chopString(strip_tags($row->content), 25);
                $searchterm = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']', '"'), '', $searchterm);
                $searchterm = preg_quote($searchterm, '/');
                $searchItems = explode(' ', $searchterm);
                if (PMF_String::strlen($searchItems[0]) > 1) {
                    foreach ($searchItems as $item) {
                        if (PMF_String::strlen($item) > 2) {
                            $thema = PMF_String::preg_replace_callback('/' . '(' . $item . '="[^"]*")|' . '((href|src|title|alt|class|style|id|name|dir|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup)="[^"]*' . $item . '[^"]*")|' . '(' . $item . ')' . '/mis', "highlight_no_links", $thema);
                            $content = PMF_String::preg_replace_callback('/' . '(' . $item . '="[^"]*")|' . '((href|src|title|alt|class|style|id|name|dir|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup)="[^"]*' . $item . '[^"]*")|' . '(' . $item . ')' . '/mis', "highlight_no_links", $content);
                        }
                    }
                }
                // Print the link to the faq record
                $url = sprintf('?%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s&amp;highlight=%s', $sids, $row->category_id, $row->id, $row->lang, urlencode($_searchterm));
                if ($instantRespnse) {
                    $currentUrl = PMF_Link::getSystemRelativeUri('ajaxresponse.php') . 'index.php';
                } else {
                    $currentUrl = PMF_Link::getSystemRelativeUri();
                }
                $oLink = new PMF_Link($currentUrl . $url);
                $oLink->itemTitle = $row->thema;
                $oLink->text = $thema;
                $oLink->tooltip = $row->thema;
                $output .= '<li><strong>' . $rubriktext . '</strong>: ' . $oLink->toHtmlAnchor() . '<br />' . '<div class="searchpreview"><strong>' . $PMF_LANG['msgSearchContent'] . '</strong> ' . $content . '...</div>' . '<br /></li>' . "\n";
            }
        }
        $output .= "</ul>\n";
    } else {
        $output = $PMF_LANG["err_noArticles"];
    }
    if (!$hasMore && $num > $confPerPage) {
        if ($faqconfig->get('main.enableRewriteRules')) {
            $baseUrl = sprintf("search.html?search=%s&amp;seite=%d%s&amp;searchcategory=%d", urlencode($_searchterm), $seite, $langs, $cat);
        } else {
            $baseUrl = PMF_Link::getSystemRelativeUri() . '?' . (empty($sids) ? '' : "{$sids}&amp;") . 'action=search&amp;search=' . urlencode($_searchterm) . '&amp;seite=' . $seite . $langs . "&amp;searchcategory=" . $cat;
        }
        $options = array('baseUrl' => $baseUrl, 'total' => $num, 'perPage' => $confPerPage, 'pageParamName' => 'seite', 'nextPageLinkTpl' => '<a href="{LINK_URL}">' . $PMF_LANG["msgNext"] . '</a>', 'prevPageLinkTpl' => '<a href="{LINK_URL}">' . $PMF_LANG["msgPrevious"] . '</a>', 'layoutTpl' => '<p align="center"><strong>{LAYOUT_CONTENT}</strong></p>');
        $pagination = new PMF_Pagination($options);
        $output .= $pagination->render();
    }
    return $output;
}