?>Please upgrade!"; $nl = chr(13) . chr(10); if (POSEIDON_VERSION >= "0.6" && !getPluginByName("QandA")) { $QandACode = "\$qanda = new plugin();" . $nl; $QandACode .= "\$qanda->name = \"QandA\";" . $nl; $QandACode .= "\$qanda->version = \"" . $QandAVersion."\";" . $nl; $QandACode .= "\$qanda->createMenuItem(\"" . $MenuSection . "\", \"" . $MenuItemText . "\", \"content.php?title=" . urlencode($item->title) . "\", \"" . $MenuItemTooltip . "\", 10);" . $nl; if (!installPlugin ("QandA", $QandAVersion, "", $QandACode, 1)) { print "

" . $MenuErrorText . ".

" . $nl; } else { print "

" . $MenuSuccessText . ".

" . $nl; } } elseif (POSEIDON_VERSION >= "0.6") { print "
" . $nl; global $qanda; $questions = array(); $s_questions = $qanda->getSetting("questions"); if ($s_questions) $questions = unserialize($s_questions); if (@$_POST['qanda_op'] == 'Submit') { if (array_key_exists($_POST['question'], $questions)) { print "
$QandATheQ (".stripslashes($_POST['question']).") $QandAAlready
" . $nl; } else { $questions[$_POST['question']] = 0; $qanda->saveSetting("questions", serialize($questions)); print "
$QandATheQ (".stripslashes($_POST['question']).") $QandAIsFiled
$QandAThanks
" . $nl; $_POST['question'] = ""; } } if ($userinfo->userlevel >= $QandAAdminLevel) { if (@$_POST['qanda_op'] == "Create") { $qtitle = $_POST['qstrings'][$_POST['createindex']]; $occurrences = contentExists($qtitle); if ($occurrences !== false) { if ($occurrences == 0) postContent($qtitle, "", "html", 1, 10, $QandAComments); if ($occurrences <= 1) $questions[$qtitle] = getContentIdByTitle($qtitle); } } elseif (@$_POST['qanda_op'] == "Update") { $strkeys = $_POST['qstrings']; $qkeys = array_keys($questions); for($idx = 0; $idx < count($strkeys); ++$idx) { if (@$_POST['qdelete'][$idx]) { if ($questions[$qkeys[$idx]]) deleteContent($questions[$qkeys[$idx]]); } else { $qnew[$strkeys[$idx]] = $questions[$qkeys[$idx]]; if ($strkeys[$idx] != $qkeys[$idx]) updateContentTitle($qnew[$strkeys[$idx]], $strkeys[$idx]); } } if (is_array(@$qnew)) $questions = $qnew; else $questions = array(); } if (count($questions)) { $qanda->saveSetting("questions", serialize($questions)); ?>
$heading" . $nl; ?>
deleteSetting("questions"); print "
$QandANoneYet
" . $nl; } } ?>


" . $nl; foreach(array_reverse(array_keys($questions)) as $question) { if ($questions[$question]) { $strquestion = stripslashes($question); print "
  • $strquestion/a>
  • " . $nl; } } print "" . $nl; } else { print "

    " . $PoseidonErrorText . "

    " . $nl; } /** * Function: getPluginByName * * Retrieves the specified plugin object from the database. * * Parameters: * * name - Plugin name. * * Returns: * * Plugin object on success, *false* on error. * * See Also: * */ function getPluginByName($name) { global $db; $result = $db->query("SELECT * FROM ".DBTABLEPREFIX."plugins WHERE name = '$name'"); if (count($result) == 1) return $result[0]; else return false; } /** * Function: contentExists * * Determines whether a given title exists in the content table. * * Parameters: * * title - Content title. * * Returns: * * Number of occurrences of the specified title, *false* on error. * */ function contentExists($title) { global $db; $result = $db->query("SELECT count(*) AS occurences FROM ".DBTABLEPREFIX."content WHERE title = '".$title."'"); if (count($result) == 1) return $result[0]->occurences; else return false; } /** * Function: getContentIdByTitle * * Get content id associated with a title. * * Parameters: * * title - Content title. * * Returns: * * Content id, *false* on error (i.e. if multiple items are found). * */ function getContentIdByTitle($title) { global $db; $result = $db->query("SELECT id FROM ".DBTABLEPREFIX."content WHERE title = '".$title."'"); if (count($result) == 1) return $result[0]->id; else return false; } /** * Function: updateContentTitle * * Change the title of a given content item. * * Parameters: * * id - Content id. * title - Content title. * * Returns: * * *true* on success, *false* on error. * */ function updateContentTitle($id, $title) { global $db; return $db->execute("UPDATE ".DBTABLEPREFIX."content SET title='".$title."' WHERE id=".$id); }