/**
  * save
  * @param array $params
  * @throws CTNoPermission
  */
 public function save($params)
 {
     global $user;
     $auth = churchwiki_getAuthForAjax();
     if ($auth["edit"] == false || $auth["edit"][$params["wikicategory_id"]] != $params["wikicategory_id"]) {
         throw new CTNoPermission("edit", "churchwiki");
     }
     $dt = new DateTime();
     $text = $_POST["val"];
     if (!$text) {
         $text = " ";
     }
     // Save an emtpy string, so I know there is some data
     db_query("INSERT INTO {cc_wiki} (doc_id, version_no, wikicategory_id, text, modified_date, modified_pid)\n              VALUES (:doc_id, :version_no, :wikicategory_id, :text, :modified_date, :modified_pid)", array(":doc_id" => urldecode($_POST["doc_id"]), ":version_no" => churchwiki_getCurrentNo(urldecode($_POST["doc_id"]), $_POST["wikicategory_id"]) + 1, ":wikicategory_id" => $_POST["wikicategory_id"], ":text" => $text, ":modified_date" => $dt->format('Y-m-d H:i:s'), ":modified_pid" => $user->id), false);
 }
Ejemplo n.º 2
0
/**
 * load content of wiki page
 *
 * @param string $doc_id
 * @param int $wikicategory_id
 * @param int $version_no
 * @return db result
 */
function churchwiki_load($doc_id, $wikicategory_id, $version_no = null)
{
    if (!$version_no) {
        $version_no = churchwiki_getCurrentNo($doc_id, $wikicategory_id);
    }
    ct_log("Aufruf Hilfeseite {$wikicategory_id}:{$doc_id} ({$version_no})", 2, "-1", "help");
    $data = db_query("SELECT p.vorname, p.name, doc_id, version_no, wikicategory_id, text, modified_date, modified_pid, auf_startseite_yn\n                    FROM {cc_wiki} w LEFT JOIN {cdb_person} p ON (w.modified_pid=p.id)\n                    WHERE version_no=:version_no AND doc_id=:doc_id AND wikicategory_id=:wikicategory_id", array(':doc_id' => $doc_id, ':wikicategory_id' => $wikicategory_id, ':version_no' => $version_no))->fetch();
    if (isset($data->text)) {
        $data->text = preg_replace('/\\\\/', "", $data->text);
        $data->text = preg_replace('/===([^===]*)===/', "<h3>\$1</h3>", $data->text);
        $data->text = preg_replace('/==([^==]*)==/', "<h2>\$1</h2>", $data->text);
        $data->files = churchcore_getFilesAsDomainIdArr("wiki_" . $wikicategory_id, $doc_id);
    }
    return $data;
}