Skip to content

Commit

Permalink
feat!: php7.4 (#4)
Browse files Browse the repository at this point in the history
- Added PHP 7.4 support.
  • Loading branch information
twje authored Mar 17, 2021
1 parent 94848a6 commit 34e3cb9
Show file tree
Hide file tree
Showing 180 changed files with 64 additions and 63 deletions.
2 changes: 1 addition & 1 deletion wiki/actions/createwiki.php → actions/createwiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function createwiki_POST(Web &$w)
$is_public = $w->request("is_public");
$type = $w->request("type");
try {
$wiki = $w->Wiki->createWiki($title, $is_public, $type);
$wiki = WikiService::getInstance($w)->createWiki($title, $is_public, $type);
} catch (WikiException $ex) {
$w->error($ex->getMessage(), "/wiki/createwiki");
}
Expand Down
4 changes: 2 additions & 2 deletions wiki/actions/delmember.php → actions/delmember.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ function delmember_GET(&$w)
{
try {
$pm = $w->pathMatch("wid", "mid");
$wiki = $w->Wiki->getWikiById($pm['wid']);
if (!$wiki || !$wiki->isOwner($w->Auth->user())) {
$wiki = WikiService::getInstance($w)->getWikiById($pm['wid']);
if (!$wiki || !$wiki->isOwner(AuthService::getInstance($w)->user())) {
$w->error("No access to delete this wiki.");
}
$mem = $wiki->getUserById($pm['mid']);
Expand Down
4 changes: 2 additions & 2 deletions wiki/actions/delwiki.php → actions/delwiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ function delwiki_GET(&$w)
{
try {
$pm = $w->pathMatch("wid");
$wiki = $w->Wiki->getWikiById($pm['wid']);
if ($wiki && ($wiki->isOwner($w->Auth->user()) || $w->Auth->user()->is_admin)) {
$wiki = WikiService::getInstance($w)->getWikiById($pm['wid']);
if ($wiki && ($wiki->isOwner(AuthService::getInstance($w)->user()) || AuthService::getInstance($w)->user()->is_admin)) {
$wiki->delete();
$w->msg("Wiki deleted.", "/wiki/");
} else {
Expand Down
2 changes: 1 addition & 1 deletion wiki/actions/edit.php → actions/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function edit_POST(Web &$w)
{
try {
$pm = $w->pathMatch("wikiname", "pagename");
$wiki = $w->Wiki->getWikiByName($pm['wikiname']);
$wiki = WikiService::getInstance($w)->getWikiByName($pm['wikiname']);
if (!$wiki) {
$w->error("Wiki does not exist.");
}
Expand Down
8 changes: 4 additions & 4 deletions wiki/actions/editmember.php → actions/editmember.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ function editmember_GET(Web &$w)
{
try {
$pm = $w->pathMatch("wid", "mid");
$wiki = $w->Wiki->getWikiById($pm['wid']);
if (!$wiki || !$wiki->isOwner($w->Auth->user())) {
$wiki = WikiService::getInstance($w)->getWikiById($pm['wid']);
if (!$wiki || !$wiki->isOwner(AuthService::getInstance($w)->user())) {
$w->error("No access to this wiki.");
}
$mem = $wiki->getUserById($pm['mid']);
Expand All @@ -23,8 +23,8 @@ function editmember_POST(&$w)
{
try {
$pm = $w->pathMatch("wid", "mid");
$wiki = $w->Wiki->getWikiById($pm['wid']);
if (!$wiki || !$wiki->isOwner($w->Auth->user())) {
$wiki = WikiService::getInstance($w)->getWikiById($pm['wid']);
if (!$wiki || !$wiki->isOwner(AuthService::getInstance($w)->user())) {
$w->error("No access to this wiki.");
}
$mem = $wiki->getUserById($pm['mid']);
Expand Down
4 changes: 2 additions & 2 deletions wiki/actions/history.php → actions/history.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function history_GET(Web &$w)
}

// Get wiki object and check for existance
$wiki = $w->Wiki->getWikiByName($pm['wikiname']);
$wiki = WikiService::getInstance($w)->getWikiByName($pm['wikiname']);
// Register for timelog

if (empty($wiki->id)) {
Expand All @@ -30,7 +30,7 @@ function history_GET(Web &$w)
}

// Set navigation
$w->Wiki->navigation($w, $wiki, $pm["pagename"]);
WikiService::getInstance($w)->navigation($w, $wiki, $pm["pagename"]);

$w->ctx("wiki", $wiki);
$w->ctx("page", $wp);
Expand Down
4 changes: 2 additions & 2 deletions wiki/actions/index.php → actions/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
function index_ALL(Web $w)
{
$wiki = $page = null;
$w->Wiki->navigation($w, $wiki, $page);
WikiService::getInstance($w)->navigation($w, $wiki, $page);
History::add("Wiki List");
try {
$w->ctx("wikis", $w->Wiki->getWikis());
$w->ctx("wikis", WikiService::getInstance($w)->getWikis());
} catch (Exception $ex) {
$w->error($ex->getMessage(), "/");
}
Expand Down
4 changes: 2 additions & 2 deletions wiki/actions/pagehistory.php → actions/pagehistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function pagehistory_GET(Web &$w)
}

// Get wiki object and check for existance
$wiki = $w->Wiki->getWikiByName($pm['wikiname']);
$wiki = WikiService::getInstance($w)->getWikiByName($pm['wikiname']);
// Register for timelog

if (empty($wiki->id)) {
Expand All @@ -30,7 +30,7 @@ function pagehistory_GET(Web &$w)
}

// Set navigation
$w->Wiki->navigation($w, $wiki, $pm["pagename"]);
WikiService::getInstance($w)->navigation($w, $wiki, $pm["pagename"]);

$w->ctx("wiki", $wiki);
$w->ctx("page", $wp);
Expand Down
2 changes: 1 addition & 1 deletion wiki/actions/preview.php → actions/preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function preview_GET(Web &$w)
{
try {
$pm = $w->pathMatch("wikiname", "pagename");
$wiki = $w->Wiki->getWikiByName($pm['wikiname']);
$wiki = WikiService::getInstance($w)->getWikiByName($pm['wikiname']);
if (!$wiki) {
$w->error("Wiki does not exist.");
}
Expand Down
8 changes: 4 additions & 4 deletions wiki/actions/view.php → actions/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function view_GET(Web &$w)
}

// Get wiki object and check for existance
$wiki = $w->Wiki->getWikiByName($pm['wikiname']);
$wiki = WikiService::getInstance($w)->getWikiByName($pm['wikiname']);

if (empty($wiki->id)) {
$w->error("Wiki does not exist.");
Expand All @@ -23,7 +23,7 @@ function view_GET(Web &$w)
}
$wp = $wiki->getPage($pm['pagename']);
// Register for timelog
$w->Timelog->registerTrackingObject($wp);
TimelogService::getInstance($w)->registerTrackingObject($wp);

if (!$wp) {
$wp = $wiki->addPage($pm['pagename'], "New Page.");
Expand All @@ -38,7 +38,7 @@ function view_GET(Web &$w)
}

// Set navigation
$w->Wiki->navigation($w, $wiki, $pm["pagename"]);
WikiService::getInstance($w)->navigation($w, $wiki, $pm["pagename"]);

// Set edt wiki form
$editForm = [
Expand All @@ -64,7 +64,7 @@ function view_GET(Web &$w)
$w->ctx("wiki_hist", $wiki->getHistory());
$w->ctx("page_hist", $wp->getHistory());
$w->ctx("wiki_users", $wiki->getUsers());
$w->ctx("attachments", $w->service("File")->getAttachments($wp));
$w->ctx("attachments", FileService::getInstance($w)->getAttachments($wp));
$w->ctx("title", $wiki->title . " - " . $wp->name);

// render form without form tag or buttons (which have been moved into the template) by using the false value for the last parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function viewhistoryversion_POST(Web &$w)
}

// Get wiki object and check for existance
$wiki = $w->Wiki->getWikiByName($pm['wikiname']);
$wiki = WikiService::getInstance($w)->getWikiByName($pm['wikiname']);
// Register for timelog

if (empty($wiki->id)) {
Expand All @@ -35,9 +35,9 @@ function viewhistoryversion_POST(Web &$w)
}

// Set navigation
$w->Wiki->navigation($w, $wiki, $pm["pagename"]);
WikiService::getInstance($w)->navigation($w, $wiki, $pm["pagename"]);

$wikiHistory = $w->Wiki->getObject("WikiPageHistory", $pm["historyid"]);
$wikiHistory = WikiService::getInstance($w)->getObject("WikiPageHistory", $pm["historyid"]);
if (!$wikiHistory) {
$w->error('No such history item');
}
Expand Down Expand Up @@ -67,9 +67,9 @@ function viewhistoryversion_GET(Web &$w)
}

// Get wiki object and check for existance
$wiki = $w->Wiki->getWikiByName($pm['wikiname']);
$wiki = WikiService::getInstance($w)->getWikiByName($pm['wikiname']);
// Register for timelog
$w->Timelog->registerTrackingObject($wiki);
TimelogService::getInstance($w)->registerTrackingObject($wiki);

if (empty($wiki->id)) {
$w->error("Wiki does not exist.");
Expand All @@ -92,9 +92,9 @@ function viewhistoryversion_GET(Web &$w)
}

// Set navigation
$w->Wiki->navigation($w, $wiki, $pm["pagename"]);
WikiService::getInstance($w)->navigation($w, $wiki, $pm["pagename"]);

$wikiHistory = $w->Wiki->getObject("WikiPageHistory", $pm["historyid"]);
$wikiHistory = WikiService::getInstance($w)->getObject("WikiPageHistory", $pm["historyid"]);
if (!$wikiHistory) {
$w->error('No such history item');
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions wiki/models/Wiki.php → models/Wiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function insert($force_validation = false)
throw new WikiException("This wiki needs a title.");
}
$this->name = $this->getName();
$this->owner_id = $this->w->Auth->user()->id;
$this->owner_id = AuthService::getInstance($this->w)->user()->id;

// check if wiki of the same name exists!
$ow = $this->Wiki->getWikiByName($this->getName());
Expand All @@ -122,7 +122,7 @@ public function insert($force_validation = false)
} else {
$this->addPage("HomePage", "#This is the HomePage");
}
$this->addUser($this->w->Auth->user(), "editor");
$this->addUser(AuthService::getInstance($this->w)->user(), "editor");
}

/*****************************
Expand Down Expand Up @@ -185,7 +185,7 @@ public function canView(User $user)
public function canEdit(User $user)
{
$wu = $this->getObject("WikiUser", ["user_id" => $user->id, "wiki_id" => $this->id, "role" => "editor"]);
return $this->Auth->user()->is_admin || $this->isOwner($user) || (!empty($wu) && $wu->role == "editor");
return AuthService::getInstance($this->w)->user()->is_admin || $this->isOwner($user) || (!empty($wu) && $wu->role == "editor");
}

/*****************************
Expand All @@ -194,7 +194,7 @@ public function canEdit(User $user)
*****************************/
public function canDelete(User $user)
{
if ($this->isOwner($user) || $this->Auth->user()->is_admin) {
if ($this->isOwner($user) || AuthService::getInstance($this->w)->user()->is_admin) {
return true;
} else {
return false;
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions wiki/models/WikiINode.php → models/WikiINode.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function getChildren()
$children = $this->getDBObject()->getPages();
if (is_array($children)) {
foreach ($children as $object) {
if ($object->canList($this->w->Auth->user())) {
if ($object->canList(AuthService::getInstance($this->w)->user())) {
$iNode = new WikiPageINode($this->w, $object);
$result[] = $iNode;
}
Expand All @@ -33,7 +33,7 @@ public function getChild($name)
$children = $this->getDBObject()->getPages();
if (is_array($children)) {
foreach ($children as $object) {
if ($object->canView($this->w->Auth->user())) {
if ($object->canView(AuthService::getInstance($this->w)->user())) {
if ($object->getSelectOptionTitle() == $name) {
$result = new WikiPageINode($this->w, $object);
} else {
Expand All @@ -48,7 +48,7 @@ public function getChild($name)
if (is_array($children)) {
foreach ($children as $object) {
if ($object->filename == $name) {
if ($object->canView($this->w->Auth->user())) {
if ($object->canView(AuthService::getInstance($this->w)->user())) {
$result = new AttachmentINode($this->w, $object);
} else {
throw new Exception('No access to this attachment');
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion wiki/models/WikiPage.php → models/WikiPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function printSearchListing()
{
$txt = "Last Modified: ";
$txt .= formatDateTime($this->dt_modified);
$txt .= " by " . $this->Auth->getUser($this->modifier_id)->getFullName();
$txt .= " by " . AuthService::getInstance($this->w)->getUser($this->modifier_id)->getFullName();
return $txt;
}

Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions wiki/models/WikiService.php → models/WikiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class WikiService extends DbService
public function getWikiById($wiki_id)
{
$wiki = $this->getObject("Wiki", $wiki_id);
if ($wiki && $wiki->canRead($this->w->Auth->user())) {
if ($wiki && $wiki->canRead(AuthService::getInstance($this->w)->user())) {
return $wiki;
} else {
throw new WikiNoAccessException("You have no access to this wiki.");
Expand All @@ -33,7 +33,7 @@ public function getWikiByName($name)
return null;
}

if ($wiki->canRead($this->w->Auth->user())) {
if ($wiki->canRead(AuthService::getInstance($this->w)->user())) {
return $wiki;
} else {
throw new WikiNoAccessException("You have no access to this wiki.");
Expand All @@ -48,7 +48,7 @@ public function getWikis()
$wikis = $this->getObjects("Wiki", ["is_deleted" => 0]);
if (!empty($wikis)) {
foreach ($wikis as $wiki) {
if ($wiki->canRead($this->w->Auth->user())) {
if ($wiki->canRead(AuthService::getInstance($this->w)->user())) {
$ret[] = $wiki;
}
}
Expand Down
2 changes: 1 addition & 1 deletion wiki/models/WikiUser.php → models/WikiUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class WikiUser extends DbObject

public function getUser()
{
return $this->Auth->getUser($this->user_id);
return AuthService::getInstance($this->w)->getUser($this->user_id);
}

public function getFullName()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

$lines = [
"Create Wiki" => [
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

$lines[] = ["Wiki Member", "section"];
$lines[] = ["User", "autocomplete", "user_id", $mem->user_id, $w->Auth->getUsersForRole("wiki_user")];
$lines[] = ["User", "autocomplete", "user_id", $mem->user_id, AuthService::getInstance($w)->getUsersForRole("wiki_user")];
$lines[] = ["Role", "select", "role", $mem->role, ["reader", "editor"]];

echo Html::form($lines, $w->localUrl("/wiki/editmember/" . $wiki->id . "/" . $mem->id), "POST", "Save");
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
$table[] = [
formatDateTime($wh["dt_created"]),
Html::a(WEBROOT . "/wiki/viewhistoryversion/" . $wiki->name . "/" . $page->name . "/" . $wh['id'], "<b>" . $page->name . "</b>"),
$w->Auth->getUser($wh['creator_id'])->getFullName()
AuthService::getInstance($w)->getUser($wh['creator_id'])->getFullName()
];
}
echo Html::table($table, "history", "tablesorter", true);
Expand Down
8 changes: 4 additions & 4 deletions wiki/templates/index.tpl.php → templates/index.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
];

foreach ($wikis as $wi) {
if ($wi->canView($w->Auth->user())) {
if ($wi->canView(AuthService::getInstance($w)->user())) {
$wikiCount++;
$lastModifiedPage = "";
$lastModifiedPageUser = "";
$lastModifiedDate = "";
if ($wi->last_modified_page_id > 0) {
$p = $wi->getPageById($wi->last_modified_page_id);
if (!empty($p)) {
$wuser = $w->Auth->getUser($p->modifier_id);
$lastModifiedPageUser = empty($wuser) ? '' : $w->Auth->getUser($p->modifier_id)->getFullName();
$wuser = AuthService::getInstance($w)->getUser($p->modifier_id);
$lastModifiedPageUser = empty($wuser) ? '' : AuthService::getInstance($w)->getUser($p->modifier_id)->getFullName();
$lastModifiedPage = $p->name;
$lastModifiedDate = $p->dt_modified;
}
}
$delLink = "";
if ($wi->canDelete($w->Auth->user())) {
if ($wi->canDelete(AuthService::getInstance($w)->user())) {
$delLink = Html::ab(WEBROOT . "/wiki/delwiki/" . $wi->id, 'Delete', 'deletebutton', '', 'Do you really want to delete this wiki and all of its pages?');
}
$table[] = [
Expand Down
File renamed without changes.
Loading

0 comments on commit 34e3cb9

Please sign in to comment.