It will mean that the change log will have to honour our privacy settings.. * * * oK - uses new mtrack_wiki table.. * */ require_once 'MTrack/Attachment.php'; require_once 'MTrackWeb.php'; class MTrackWeb_Wiki extends MTrackWeb { var $conflicted = 0; var $message = false; var $hasHistory = false; var $title; var $authUserArray; function getAuth() { return parent::getAuth(); } function get($pi='') { // non 'json' request... if (!isset($_REQUEST['ajax_body'])) { $this->title = "Browse: " . $pi; return; } $p = DB_DataObject::Factory('Mtrack_wiki'); $p->project_id = $this->currentProject(); $p->path = $pi; // we add stuff on the end.. if (empty($pi)) { $px = DB_DataObject::Factory('Mtrack_wiki'); $px->project_id = $this->currentProject(); $px->orderBy('path'); $pr = DB_DataObject::factory('core_project'); $pr->get($px->project_id); $ar = $px->fetchAll('path'); $wikidata = "## Index of pages in Wiki - {$pr->name} \n\n"; foreach($ar as $pp) { $wikidata .= " * [$pp](wiki:$pp)\n"; } $p->wikidata = $wikidata; $this->jdata($p->toArray()); } //var_dump($p); if (!$p->find(true)) { $p->id = 0; $this->jdata($p->toArray()); } $this->jdata($p->toArray()); //echo '
';print_r($this);echo '
'; } function returnNotFound($p) { } function post($request) { //DB_DataObject::debugLevel(1); $au = $this->getAuthUser(); if (!$au) { // autherr? $this->jerr("permission denied"); } $p = DB_DataObject::factory('mtrack_wiki'); $p->project_id = $this->currentProject(); $id = empty($_REQUEST['id']) ? 0 : $_REQUEST['id'] * 1; if (!empty($id) && !$p->get($id)) { $this->jerr('invalid id'); } $o = clone($p); $p->setFrom($_POST); if ($o->project_id != $p->project_id) { $this->jerr("changing project id not permitted"); } // check change of path... if (!$o->id || ($o->path != $p->path)) { $c = DB_DataObject::factory('mtrack_wiki'); $c->project_id = $p->project_id; $c->path = $p->path; if ($c->count()) { $this->jerr("Path is not valid - that path already exists"); } } call_user_func(array($p, $o->id ? 'update' : 'insert'), $o); $this->jok($p->toArray()); } }