From 44dcb29060ee0a3d39f23ab6c7215e9ebe135eaa Mon Sep 17 00:00:00 2001 From: Joey Kimsey Date: Thu, 15 Aug 2024 12:49:34 -0400 Subject: [PATCH] remove non-standard plugins --- .../bookmarks/controllers/bookmarks.php | 402 ---------- app/plugins/bookmarks/forms.php | 122 --- app/plugins/bookmarks/models/bookmarks.php | 705 ------------------ .../bookmarks/models/bookmarkviews.php | 149 ---- app/plugins/bookmarks/models/folders.php | 157 ---- app/plugins/bookmarks/plugin.php | 50 -- .../bookmarks/views/bookmarks/create.html | 45 -- .../bookmarks/views/bookmarks/edit.html | 45 -- .../bookmarks/views/bookmarks/list.html | 37 - .../bookmarks/views/bookmarks/view.html | 84 --- .../views/components/bookmarkListPanel.html | 21 - .../views/components/bookmarkListRows.html | 18 - .../views/components/folderPanelList.html | 10 - app/plugins/bookmarks/views/dash.html | 16 - .../bookmarks/views/folders/create.html | 39 - app/plugins/bookmarks/views/folders/edit.html | 39 - app/plugins/bookmarks/views/folders/list.html | 33 - app/plugins/bookmarks/views/folders/view.html | 47 -- .../bookmarks/views/nav/folderTabs.html | 5 - .../bookmarks/views/nav/userFolderTabs.html | 9 - app/plugins/bugtracker/config/constants.php | 7 - .../controllers/admin/bugtracker.php | 206 ----- app/plugins/bugtracker/forms.php | 92 --- app/plugins/bugtracker/models/bugtracker.php | 142 ---- app/plugins/bugtracker/plugin.php | 48 -- .../bugtracker/views/admin/create.html | 6 - .../bugtracker/views/admin/dashboard.html | 30 - app/plugins/bugtracker/views/admin/edit.html | 6 - app/plugins/bugtracker/views/admin/list.html | 45 -- app/plugins/bugtracker/views/admin/view.html | 74 -- app/plugins/calendar/controllers/calendar.php | 593 --------------- app/plugins/calendar/css/calendar.css | 153 ---- app/plugins/calendar/forms.php | 136 ---- app/plugins/calendar/models/calendars.php | 157 ---- app/plugins/calendar/models/events.php | 509 ------------- app/plugins/calendar/plugin.php | 84 --- .../calendar/templates/calendar.inc.php | 41 - app/plugins/calendar/templates/calendar.tpl | 96 --- app/plugins/calendar/views/byDay.html | 25 - app/plugins/calendar/views/byMonth.html | 34 - app/plugins/calendar/views/byWeek.html | 25 - app/plugins/calendar/views/byYear.html | 42 -- .../calendar/views/calendar/create.html | 34 - app/plugins/calendar/views/calendar/edit.html | 29 - app/plugins/calendar/views/calendar/list.html | 45 -- app/plugins/calendar/views/calendar/view.html | 42 -- app/plugins/calendar/views/dateSelect.html | 20 - app/plugins/calendar/views/events/create.html | 37 - app/plugins/calendar/views/events/edit.html | 31 - app/plugins/calendar/views/events/list.html | 34 - app/plugins/calendar/views/events/view.html | 52 -- .../calendar/views/nav/calendarDropdown.html | 16 - app/plugins/calendar/views/nav/cell.html | 23 - .../calendar/views/nav/dateDropdown.html | 18 - app/plugins/calendar/views/nav/row.html | 12 - app/plugins/calendar/views/nav/topTabs.html | 8 - app/plugins/calendar/views/nav/week.html | 9 - app/plugins/chat/controllers/admin/chat.php | 37 - app/plugins/chat/controllers/api/messages.php | 45 -- app/plugins/chat/controllers/chat.php | 191 ----- app/plugins/chat/css/chat.css | 116 --- app/plugins/chat/forms.php | 52 -- app/plugins/chat/js/chat.js | 116 --- app/plugins/chat/models/chat.php | 145 ---- app/plugins/chat/plugin.php | 55 -- app/plugins/chat/templates/chat.inc.php | 32 - app/plugins/chat/templates/chat.tpl | 88 --- app/plugins/chat/views/admin/index.html | 0 app/plugins/chat/views/chat.html | 10 - app/plugins/chat/views/create.html | 9 - app/plugins/chat/views/index.html | 18 - app/plugins/chat/views/upload.html | 9 - app/plugins/contacts/controllers/contacts.php | 92 --- app/plugins/contacts/forms.php | 99 --- app/plugins/contacts/models/contact.php | 88 --- app/plugins/contacts/models/phonebook.php | 165 ---- app/plugins/contacts/plugin.php | 57 -- .../contacts/views/contacts/create.html | 162 ---- app/plugins/contacts/views/contacts/edit.html | 162 ---- app/plugins/contacts/views/contacts/list.html | 40 - app/plugins/contacts/views/contacts/view.html | 87 --- app/plugins/contacts/views/dashboard.html | 3 - .../contacts/views/phonebooks/create.html | 35 - .../contacts/views/phonebooks/edit.html | 33 - .../contacts/views/phonebooks/list.html | 33 - .../contacts/views/phonebooks/view.html | 45 -- .../fileshare/controllers/fileshare.php | 121 --- app/plugins/fileshare/forms.php | 47 -- app/plugins/fileshare/models/upload.php | 181 ----- app/plugins/fileshare/plugin.php | 45 -- app/plugins/fileshare/views/create.html | 22 - app/plugins/fileshare/views/edit.html | 22 - app/plugins/fileshare/views/list.html | 24 - .../controllers/initiative.php | 43 -- .../initiativetracker/css/initiative.css | 35 - .../initiativetracker/js/initiative.js | 414 ---------- .../initiativetracker/models/inithistory.php | 105 --- app/plugins/initiativetracker/plugin.php | 49 -- .../views/historyElement.html | 0 .../initiativetracker/views/index.html | 210 ------ app/plugins/notes/controllers/notes.php | 436 ----------- app/plugins/notes/css/notes.css | 231 ------ app/plugins/notes/forms.php | 136 ---- app/plugins/notes/js/notes.js | 32 - app/plugins/notes/models/notebooks.php | 169 ----- app/plugins/notes/models/notes.php | 222 ------ app/plugins/notes/plugin.php | 57 -- app/plugins/notes/templates/notes.inc.php | 32 - app/plugins/notes/templates/notes.tpl | 112 --- app/plugins/notes/views/dashboard.html | 12 - app/plugins/notes/views/nav/menuItem.html | 1 - app/plugins/notes/views/nav/menuItemList.html | 18 - app/plugins/notes/views/nav/noteSidebar.html | 19 - .../notes/views/nav/notebookDropdown.html | 11 - .../notes/views/nav/notebookSidebar.html | 19 - app/plugins/notes/views/nav/topTabs.html | 10 - app/plugins/notes/views/notebooks/create.html | 41 - app/plugins/notes/views/notebooks/edit.html | 39 - app/plugins/notes/views/notebooks/list.html | 35 - app/plugins/notes/views/notes/create.html | 32 - app/plugins/notes/views/notes/edit.html | 29 - app/plugins/notes/views/notes/list.html | 35 - .../reviews/controllers/admin/reviews.php | 140 ---- app/plugins/reviews/controllers/reviews.php | 89 --- app/plugins/reviews/css/reviews.css | 9 - app/plugins/reviews/forms.php | 93 --- app/plugins/reviews/js/reviews.js | 20 - app/plugins/reviews/models/review.php | 149 ---- app/plugins/reviews/models/reviewcategory.php | 112 --- app/plugins/reviews/plugin.php | 51 -- app/plugins/reviews/views/admin/category.html | 35 - .../reviews/views/admin/categoryCreate.html | 22 - .../reviews/views/admin/categoryEdit.html | 22 - .../reviews/views/admin/categoryList.html | 33 - .../reviews/views/admin/dashboard.html | 9 - app/plugins/reviews/views/admin/review.html | 42 -- .../reviews/views/admin/reviewList.html | 32 - app/plugins/reviews/views/admin/view.html | 0 app/plugins/reviews/views/create.html | 29 - app/plugins/reviews/views/index.html | 1 - app/plugins/reviews/views/list.html | 32 - .../controllers/admin/suggestions.php | 119 --- .../suggestions/controllers/suggestions.php | 133 ---- app/plugins/suggestions/forms.php | 68 -- .../suggestions/models/suggestions.php | 183 ----- app/plugins/suggestions/plugin.php | 47 -- app/plugins/suggestions/views/admin/edit.html | 22 - app/plugins/suggestions/views/admin/list.html | 56 -- app/plugins/suggestions/views/admin/view.html | 17 - app/plugins/suggestions/views/create.html | 16 - app/plugins/suggestions/views/edit.html | 15 - app/plugins/suggestions/views/list.html | 19 - app/plugins/suggestions/views/view.html | 18 - app/plugins/todo/controllers/api/lists.php | 62 -- app/plugins/todo/controllers/api/tasks.php | 62 -- app/plugins/todo/controllers/todo.php | 371 --------- app/plugins/todo/forms.php | 96 --- app/plugins/todo/models/tasklists.php | 199 ----- app/plugins/todo/models/tasks.php | 392 ---------- app/plugins/todo/plugin.php | 41 - app/plugins/todo/views/dashboard.html | 36 - app/plugins/todo/views/lists/create.html | 19 - app/plugins/todo/views/lists/edit.html | 14 - app/plugins/todo/views/lists/list.html | 32 - app/plugins/todo/views/nav/listTabs.html | 9 - app/plugins/todo/views/nav/userListTabs.html | 9 - app/plugins/todo/views/tasks/create.html | 25 - app/plugins/todo/views/tasks/daily.html | 35 - app/plugins/todo/views/tasks/edit.html | 20 - app/plugins/todo/views/tasks/list.html | 37 - app/plugins/todo/views/tasks/monthly.html | 35 - app/plugins/todo/views/tasks/view.html | 1 - app/plugins/todo/views/tasks/weekly.html | 35 - app/plugins/todo/views/tasks/yearly.html | 35 - 174 files changed, 13262 deletions(-) delete mode 100644 app/plugins/bookmarks/controllers/bookmarks.php delete mode 100644 app/plugins/bookmarks/forms.php delete mode 100644 app/plugins/bookmarks/models/bookmarks.php delete mode 100644 app/plugins/bookmarks/models/bookmarkviews.php delete mode 100644 app/plugins/bookmarks/models/folders.php delete mode 100644 app/plugins/bookmarks/plugin.php delete mode 100644 app/plugins/bookmarks/views/bookmarks/create.html delete mode 100644 app/plugins/bookmarks/views/bookmarks/edit.html delete mode 100644 app/plugins/bookmarks/views/bookmarks/list.html delete mode 100644 app/plugins/bookmarks/views/bookmarks/view.html delete mode 100644 app/plugins/bookmarks/views/components/bookmarkListPanel.html delete mode 100644 app/plugins/bookmarks/views/components/bookmarkListRows.html delete mode 100644 app/plugins/bookmarks/views/components/folderPanelList.html delete mode 100644 app/plugins/bookmarks/views/dash.html delete mode 100644 app/plugins/bookmarks/views/folders/create.html delete mode 100644 app/plugins/bookmarks/views/folders/edit.html delete mode 100644 app/plugins/bookmarks/views/folders/list.html delete mode 100644 app/plugins/bookmarks/views/folders/view.html delete mode 100644 app/plugins/bookmarks/views/nav/folderTabs.html delete mode 100644 app/plugins/bookmarks/views/nav/userFolderTabs.html delete mode 100644 app/plugins/bugtracker/config/constants.php delete mode 100644 app/plugins/bugtracker/controllers/admin/bugtracker.php delete mode 100644 app/plugins/bugtracker/forms.php delete mode 100644 app/plugins/bugtracker/models/bugtracker.php delete mode 100644 app/plugins/bugtracker/plugin.php delete mode 100644 app/plugins/bugtracker/views/admin/create.html delete mode 100644 app/plugins/bugtracker/views/admin/dashboard.html delete mode 100644 app/plugins/bugtracker/views/admin/edit.html delete mode 100644 app/plugins/bugtracker/views/admin/list.html delete mode 100644 app/plugins/bugtracker/views/admin/view.html delete mode 100644 app/plugins/calendar/controllers/calendar.php delete mode 100644 app/plugins/calendar/css/calendar.css delete mode 100644 app/plugins/calendar/forms.php delete mode 100644 app/plugins/calendar/models/calendars.php delete mode 100644 app/plugins/calendar/models/events.php delete mode 100644 app/plugins/calendar/plugin.php delete mode 100644 app/plugins/calendar/templates/calendar.inc.php delete mode 100644 app/plugins/calendar/templates/calendar.tpl delete mode 100644 app/plugins/calendar/views/byDay.html delete mode 100644 app/plugins/calendar/views/byMonth.html delete mode 100644 app/plugins/calendar/views/byWeek.html delete mode 100644 app/plugins/calendar/views/byYear.html delete mode 100644 app/plugins/calendar/views/calendar/create.html delete mode 100644 app/plugins/calendar/views/calendar/edit.html delete mode 100644 app/plugins/calendar/views/calendar/list.html delete mode 100644 app/plugins/calendar/views/calendar/view.html delete mode 100644 app/plugins/calendar/views/dateSelect.html delete mode 100644 app/plugins/calendar/views/events/create.html delete mode 100644 app/plugins/calendar/views/events/edit.html delete mode 100644 app/plugins/calendar/views/events/list.html delete mode 100644 app/plugins/calendar/views/events/view.html delete mode 100644 app/plugins/calendar/views/nav/calendarDropdown.html delete mode 100644 app/plugins/calendar/views/nav/cell.html delete mode 100644 app/plugins/calendar/views/nav/dateDropdown.html delete mode 100644 app/plugins/calendar/views/nav/row.html delete mode 100644 app/plugins/calendar/views/nav/topTabs.html delete mode 100644 app/plugins/calendar/views/nav/week.html delete mode 100644 app/plugins/chat/controllers/admin/chat.php delete mode 100644 app/plugins/chat/controllers/api/messages.php delete mode 100644 app/plugins/chat/controllers/chat.php delete mode 100644 app/plugins/chat/css/chat.css delete mode 100644 app/plugins/chat/forms.php delete mode 100644 app/plugins/chat/js/chat.js delete mode 100644 app/plugins/chat/models/chat.php delete mode 100644 app/plugins/chat/plugin.php delete mode 100644 app/plugins/chat/templates/chat.inc.php delete mode 100644 app/plugins/chat/templates/chat.tpl delete mode 100644 app/plugins/chat/views/admin/index.html delete mode 100644 app/plugins/chat/views/chat.html delete mode 100644 app/plugins/chat/views/create.html delete mode 100644 app/plugins/chat/views/index.html delete mode 100644 app/plugins/chat/views/upload.html delete mode 100644 app/plugins/contacts/controllers/contacts.php delete mode 100644 app/plugins/contacts/forms.php delete mode 100644 app/plugins/contacts/models/contact.php delete mode 100644 app/plugins/contacts/models/phonebook.php delete mode 100644 app/plugins/contacts/plugin.php delete mode 100644 app/plugins/contacts/views/contacts/create.html delete mode 100644 app/plugins/contacts/views/contacts/edit.html delete mode 100644 app/plugins/contacts/views/contacts/list.html delete mode 100644 app/plugins/contacts/views/contacts/view.html delete mode 100644 app/plugins/contacts/views/dashboard.html delete mode 100644 app/plugins/contacts/views/phonebooks/create.html delete mode 100644 app/plugins/contacts/views/phonebooks/edit.html delete mode 100644 app/plugins/contacts/views/phonebooks/list.html delete mode 100644 app/plugins/contacts/views/phonebooks/view.html delete mode 100644 app/plugins/fileshare/controllers/fileshare.php delete mode 100644 app/plugins/fileshare/forms.php delete mode 100644 app/plugins/fileshare/models/upload.php delete mode 100644 app/plugins/fileshare/plugin.php delete mode 100644 app/plugins/fileshare/views/create.html delete mode 100644 app/plugins/fileshare/views/edit.html delete mode 100644 app/plugins/fileshare/views/list.html delete mode 100644 app/plugins/initiativetracker/controllers/initiative.php delete mode 100644 app/plugins/initiativetracker/css/initiative.css delete mode 100644 app/plugins/initiativetracker/js/initiative.js delete mode 100644 app/plugins/initiativetracker/models/inithistory.php delete mode 100644 app/plugins/initiativetracker/plugin.php delete mode 100644 app/plugins/initiativetracker/views/historyElement.html delete mode 100644 app/plugins/initiativetracker/views/index.html delete mode 100644 app/plugins/notes/controllers/notes.php delete mode 100644 app/plugins/notes/css/notes.css delete mode 100644 app/plugins/notes/forms.php delete mode 100644 app/plugins/notes/js/notes.js delete mode 100644 app/plugins/notes/models/notebooks.php delete mode 100644 app/plugins/notes/models/notes.php delete mode 100644 app/plugins/notes/plugin.php delete mode 100644 app/plugins/notes/templates/notes.inc.php delete mode 100644 app/plugins/notes/templates/notes.tpl delete mode 100644 app/plugins/notes/views/dashboard.html delete mode 100644 app/plugins/notes/views/nav/menuItem.html delete mode 100644 app/plugins/notes/views/nav/menuItemList.html delete mode 100644 app/plugins/notes/views/nav/noteSidebar.html delete mode 100644 app/plugins/notes/views/nav/notebookDropdown.html delete mode 100644 app/plugins/notes/views/nav/notebookSidebar.html delete mode 100644 app/plugins/notes/views/nav/topTabs.html delete mode 100644 app/plugins/notes/views/notebooks/create.html delete mode 100644 app/plugins/notes/views/notebooks/edit.html delete mode 100644 app/plugins/notes/views/notebooks/list.html delete mode 100644 app/plugins/notes/views/notes/create.html delete mode 100644 app/plugins/notes/views/notes/edit.html delete mode 100644 app/plugins/notes/views/notes/list.html delete mode 100644 app/plugins/reviews/controllers/admin/reviews.php delete mode 100644 app/plugins/reviews/controllers/reviews.php delete mode 100644 app/plugins/reviews/css/reviews.css delete mode 100644 app/plugins/reviews/forms.php delete mode 100644 app/plugins/reviews/js/reviews.js delete mode 100644 app/plugins/reviews/models/review.php delete mode 100644 app/plugins/reviews/models/reviewcategory.php delete mode 100644 app/plugins/reviews/plugin.php delete mode 100644 app/plugins/reviews/views/admin/category.html delete mode 100644 app/plugins/reviews/views/admin/categoryCreate.html delete mode 100644 app/plugins/reviews/views/admin/categoryEdit.html delete mode 100644 app/plugins/reviews/views/admin/categoryList.html delete mode 100644 app/plugins/reviews/views/admin/dashboard.html delete mode 100644 app/plugins/reviews/views/admin/review.html delete mode 100644 app/plugins/reviews/views/admin/reviewList.html delete mode 100644 app/plugins/reviews/views/admin/view.html delete mode 100644 app/plugins/reviews/views/create.html delete mode 100644 app/plugins/reviews/views/index.html delete mode 100644 app/plugins/reviews/views/list.html delete mode 100644 app/plugins/suggestions/controllers/admin/suggestions.php delete mode 100644 app/plugins/suggestions/controllers/suggestions.php delete mode 100644 app/plugins/suggestions/forms.php delete mode 100644 app/plugins/suggestions/models/suggestions.php delete mode 100644 app/plugins/suggestions/plugin.php delete mode 100644 app/plugins/suggestions/views/admin/edit.html delete mode 100644 app/plugins/suggestions/views/admin/list.html delete mode 100644 app/plugins/suggestions/views/admin/view.html delete mode 100644 app/plugins/suggestions/views/create.html delete mode 100644 app/plugins/suggestions/views/edit.html delete mode 100644 app/plugins/suggestions/views/list.html delete mode 100644 app/plugins/suggestions/views/view.html delete mode 100644 app/plugins/todo/controllers/api/lists.php delete mode 100644 app/plugins/todo/controllers/api/tasks.php delete mode 100644 app/plugins/todo/controllers/todo.php delete mode 100644 app/plugins/todo/forms.php delete mode 100644 app/plugins/todo/models/tasklists.php delete mode 100644 app/plugins/todo/models/tasks.php delete mode 100644 app/plugins/todo/plugin.php delete mode 100644 app/plugins/todo/views/dashboard.html delete mode 100644 app/plugins/todo/views/lists/create.html delete mode 100644 app/plugins/todo/views/lists/edit.html delete mode 100644 app/plugins/todo/views/lists/list.html delete mode 100644 app/plugins/todo/views/nav/listTabs.html delete mode 100644 app/plugins/todo/views/nav/userListTabs.html delete mode 100644 app/plugins/todo/views/tasks/create.html delete mode 100644 app/plugins/todo/views/tasks/daily.html delete mode 100644 app/plugins/todo/views/tasks/edit.html delete mode 100644 app/plugins/todo/views/tasks/list.html delete mode 100644 app/plugins/todo/views/tasks/monthly.html delete mode 100644 app/plugins/todo/views/tasks/view.html delete mode 100644 app/plugins/todo/views/tasks/weekly.html delete mode 100644 app/plugins/todo/views/tasks/yearly.html diff --git a/app/plugins/bookmarks/controllers/bookmarks.php b/app/plugins/bookmarks/controllers/bookmarks.php deleted file mode 100644 index 3641faa..0000000 --- a/app/plugins/bookmarks/controllers/bookmarks.php +++ /dev/null @@ -1,402 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers; - -use TheTempusProject\Hermes\Functions\Redirect; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Session; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Classes\Controller; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Models\Bookmarks as Bookmark; -use TheTempusProject\Models\Folders; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Forms as HoudiniForms; -use TheTempusProject\Houdini\Classes\Navigation; - -class Bookmarks extends Controller { - protected static $bookmarks; - protected static $folders; - - public function __construct() { - parent::__construct(); - if ( !App::$isLoggedIn ) { - Session::flash( 'notice', 'You must be logged in to create or manage bookmarks.' ); - return Redirect::home(); - } - self::$bookmarks = new Bookmark; - self::$folders = new Folders; - self::$title = 'Bookmarks - {SITENAME}'; - self::$pageDescription = 'Add and save url bookmarks here.'; - - $folderTabs = Views::simpleView( 'bookmarks.nav.folderTabs' ); - if ( stripos( Input::get('url'), 'bookmarks/bookmarks' ) !== false ) { - $tabsView = Navigation::activePageSelect( $folderTabs, '/bookmarks/folders/', false, true ); - $userFolderTabs = Views::simpleView('bookmarks.nav.userFolderTabs', self::$folders->simpleObjectByUser(true) ); - $userFolderTabsView = Navigation::activePageSelect( $userFolderTabs, Input::get( 'url' ), false, true ); - } else { - $tabsView = Navigation::activePageSelect( $folderTabs, Input::get( 'url' ), false, true ); - $userFolderTabsView = ''; - } - Components::set( 'userFolderTabs', $userFolderTabsView ); - Views::raw( $tabsView ); - } - - public function index() { - $bookmarks = self::$bookmarks->noFolder(); - $folders = self::$folders->byUser(); - - $panelArray = []; - if ( !empty( $folders ) ) { - foreach ( $folders as $folder ) { - $panel = new \stdClass(); - $folderObject = new \stdClass(); - $folderObject->bookmarks = self::$bookmarks->byFolder( $folder->ID ); - $folderObject->ID = $folder->ID; - $folderObject->title = $folder->title; - $folderObject->color = $folder->color; - $folderObject->bookmarkListRows = Views::simpleView( 'bookmarks.components.bookmarkListRows', $folderObject->bookmarks ); - $panel->panel = Views::simpleView( 'bookmarks.components.bookmarkListPanel', [$folderObject] ); - $panelArray[] = $panel; - } - } - Components::set( 'foldersList', Views::simpleView( 'bookmarks.folders.list', $folders ) ); - Components::set( 'folderPanels', Views::simpleView( 'bookmarks.components.folderPanelList', $panelArray ) ); - Components::set( 'bookmarksList', Views::simpleView( 'bookmarks.bookmarks.list', $bookmarks ) ); - return Views::view( 'bookmarks.dash' ); - } - - /** - * Bookmarks - */ - public function bookmark( $id = 0 ) { - $bookmark = self::$bookmarks->findById( $id ); - if ( $bookmark == false ) { - Session::flash( 'error', 'Bookmark not found.' ); - return Redirect::to( 'bookmarks/index' ); - } - if ( $bookmark->createdBy != App::$activeUser->ID ) { - Session::flash( 'error', 'You do not have permission to modify this bookmark.' ); - return Redirect::to( 'bookmarks/index' ); - } - Navigation::setCrumbComponent( 'BookmarkBreadCrumbs', 'bookmarks/bookmark/' . $id ); - return Views::view( 'bookmarks.bookmarks.view', $bookmark ); - } - - public function bookmarks( $id = null ) { - $folder = self::$folders->findById( $id ); - if ( $folder == false ) { - Session::flash( 'error', 'Folder not found.' ); - return Redirect::to( 'bookmarks/index' ); - } - if ( $folder->createdBy != App::$activeUser->ID ) { - Session::flash( 'error', 'You do not have permission to view this folder.' ); - return Redirect::to( 'bookmarks/index' ); - } - Navigation::setCrumbComponent( 'BookmarkBreadCrumbs', 'bookmarks/bookmarks/' . $id ); - - - $bookmarks = self::$bookmarks->noFolder(); - - $panelArray = []; - $panel = new \stdClass(); - $folderObject = new \stdClass(); - $folderObject->bookmarks = self::$bookmarks->byFolder( $folder->ID ); - $folderObject->ID = $folder->ID; - $folderObject->title = $folder->title; - $folderObject->color = $folder->color; - $folderObject->bookmarkListRows = Views::simpleView( 'bookmarks.components.bookmarkListRows', $folderObject->bookmarks ); - $panel->panel = Views::simpleView( 'bookmarks.components.bookmarkListPanel', [$folderObject] ); - $panelArray[] = $panel; - - return Views::view( 'bookmarks.components.folderPanelList', $panelArray ); - } - - public function createBookmark( $id = null ) { - $folderID = Input::get('folder_id') ? Input::get('folder_id') : $id; - $folderID = Input::post('folder_id') ? Input::post('folder_id') : $id; - $folderSelect = HoudiniForms::getFormFieldHtml( 'folder_id', 'Folder', 'select', $folderID, self::$folders->simpleByUser() ); - Components::set( 'folderSelect', $folderSelect ); - - if ( ! Input::exists() ) { - return Views::view( 'bookmarks.bookmarks.create' ); - } - if ( ! Forms::check( 'createBookmark' ) ) { - Issues::add( 'error', [ 'There was an error with your form.' => Check::userErrors() ] ); - return Views::view( 'bookmarks.bookmarks.create' ); - } - - $result = self::$bookmarks->create( - Input::post('title'), - Input::post('url'), - $folderID, - Input::post('description'), - Input::post('color'), - Input::post('privacy'), - ); - - if ( ! $result ) { - Issues::add( 'error', [ 'There was an error creating your bookmark.' => Check::userErrors() ] ); - return Views::view( 'bookmarks.bookmarks.create' ); - } - self::$bookmarks->refreshInfo( $result ); - Session::flash( 'success', 'Your Bookmark has been created.' ); - Redirect::to( 'bookmarks/bookmarks/'. $folderID ); - } - - public function editBookmark( $id = null ) { - $folderID = Input::exists('folder_id') ? Input::post('folder_id') : ''; - - $bookmark = self::$bookmarks->findById( $id ); - if ( $bookmark == false ) { - Issues::add( 'error', 'Bookmark not found.' ); - return Redirect::to( 'bookmarks/index' ); - } - if ( $bookmark->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this bookmark.' ); - return Redirect::to( 'bookmarks/index' ); - } - if ( empty( $folderID ) ) { - $folderID = $bookmark->folderID; - } - - $folderSelect = HoudiniForms::getFormFieldHtml( 'folder_id', 'Folder', 'select', $folderID, self::$folders->simpleByUser() ); - Components::set( 'folderSelect', $folderSelect ); - Components::set( 'color', $bookmark->color ); - - if ( ! Input::exists( 'submit' ) ) { - return Views::view( 'bookmarks.bookmarks.edit', $bookmark ); - } - if ( ! Forms::check( 'editBookmark' ) ) { - Issues::add( 'error', [ 'There was an error updating your bookmark.' => Check::userErrors() ] ); - return Views::view( 'bookmarks.bookmarks.edit', $bookmark ); - } - - $result = self::$bookmarks->update( - $id, - Input::post('title'), - Input::post('url'), - $folderID, - Input::post('description'), - Input::post('color'), - Input::post('privacy'), - ); - if ( ! $result ) { - Issues::add( 'error', [ 'There was an error updating your bookmark.' => Check::userErrors() ] ); - return Views::view( 'bookmarks.bookmarks.edit', $bookmark ); - } - Session::flash( 'success', 'Your Bookmark has been updated.' ); - Redirect::to( 'bookmarks/folders/'. $bookmark->folderID ); - } - - public function deleteBookmark( $id = null ) { - $bookmark = self::$bookmarks->findById( $id ); - if ( $bookmark == false ) { - Issues::add( 'error', 'Bookmark not found.' ); - return $this->index(); - } - if ( $bookmark->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this bookmark.' ); - return $this->index(); - } - $result = self::$bookmarks->delete( $id ); - if ( !$result ) { - Session::flash( 'error', 'There was an error deleting the bookmark(s)' ); - } else { - Session::flash( 'success', 'Bookmark deleted' ); - } - Redirect::to( 'bookmarks/folders/'. $bookmark->folderID ); - } - - /** - * Folders - */ - public function folders( $id = null) { - $folder = self::$folders->findById( $id ); - if ( $folder == false ) { - $folders = self::$folders->byUser(); - return Views::view( 'bookmarks.folders.list', $folders ); - } - if ( $folder->createdBy != App::$activeUser->ID ) { - Session::flash( 'error', 'You do not have permission to view this folder.' ); - return Redirect::to( 'bookmarks/index' ); - } - Navigation::setCrumbComponent( 'BookmarkBreadCrumbs', 'bookmarks/folders/' . $id ); - return Views::view( 'bookmarks.folders.view', $folder ); - } - - public function createFolder( $id = 0 ) { - $folderID = Input::exists('folder_id') ? Input::post('folder_id') : $id; - $folders = self::$folders->simpleByUser(); - if ( ! empty( $folders ) ) { - $folderSelect = HoudiniForms::getFormFieldHtml( 'folder_id', 'Folder', 'select', $folderID, $folders ); - } else { - $folderSelect = ''; - } - Components::set( 'folderSelect', $folderSelect ); - if ( ! Input::exists() ) { - return Views::view( 'bookmarks.folders.create' ); - } - if ( ! Forms::check( 'createFolder' ) ) { - Issues::add( 'error', [ 'There was an error creating your folder.' => Check::userErrors() ] ); - return Views::view( 'bookmarks.folders.create' ); - } - $folder = self::$folders->create( Input::post('title'), $folderID, Input::post('description'), Input::post('color'), Input::post('privacy') ); - if ( ! $folder ) { - return Views::view( 'bookmarks.folders.create' ); - } - Session::flash( 'success', 'Your Folder has been created.' ); - Redirect::to( 'bookmarks/folders' ); - } - - public function editFolder( $id = null ) { - $folder = self::$folders->findById( $id ); - - if ( $folder == false ) { - Issues::add( 'error', 'Folder not found.' ); - return $this->index(); - } - - if ( $folder->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this folder.' ); - return $this->index(); - } - $folderID = ( false === Input::exists('folder_id') ) ? $folder->ID : Input::post('folder_id'); - - $folderSelect = HoudiniForms::getFormFieldHtml( 'folder_id', 'Folder', 'select', $folderID, self::$folders->simpleByUser() ); - Components::set( 'folderSelect', $folderSelect ); - Components::set( 'color', $folder->color ); - - if ( ! Input::exists( 'submit' ) ) { - return Views::view( 'bookmarks.folders.edit', $folder ); - } - - if ( !Forms::check( 'editFolder' ) ) { - Issues::add( 'error', [ 'There was an error editing your folder.' => Check::userErrors() ] ); - return Views::view( 'bookmarks.folders.edit', $folder ); - } - - $result = self::$folders->update( $id, Input::post('title'), $folderID, Input::post('description'), Input::post('color'), Input::post('privacy') ); - if ( !$result ) { - Issues::add( 'error', [ 'There was an error updating your folder.' => Check::userErrors() ] ); - return Views::view( 'bookmarks.folders.edit', $folder ); - } - Session::flash( 'success', 'Your Folder has been updated.' ); - Redirect::to( 'bookmarks/folders/'. $folder->ID ); - } - - public function deleteFolder( $id = null ) { - $folder = self::$folders->findById( $id ); - if ( $folder == false ) { - Issues::add( 'error', 'Folder not found.' ); - return $this->index(); - } - if ( $folder->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this folder.' ); - return $this->index(); - } - $results = self::$bookmarks->deleteByFolder( $id ); - $result = self::$folders->delete( $id ); - if ( !$result ) { - Session::flash( 'error', 'There was an error deleting the folder(s)' ); - } else { - Session::flash( 'success', 'Folder deleted' ); - } - Redirect::to( 'bookmarks/folders' ); - } - - /** - * Functionality - */ - public function hideBookmark( $id = null ) { - $bookmark = self::$bookmarks->findById( $id ); - if ( $bookmark == false ) { - Session::flash( 'error', 'Bookmark not found.' ); - return Redirect::to( 'bookmarks/index' ); - } - if ( $bookmark->createdBy != App::$activeUser->ID ) { - Session::flash( 'error', 'You do not have permission to modify this bookmark.' ); - return Redirect::to( 'bookmarks/index' ); - } - self::$bookmarks->hide( $id ); - Session::flash( 'success', 'Bookmark hidden.' ); - return Redirect::to( 'bookmarks/index' ); - } - - public function archiveBookmark( $id = null ) { - $bookmark = self::$bookmarks->findById( $id ); - if ( $bookmark == false ) { - Session::flash( 'error', 'Bookmark not found.' ); - return Redirect::to( 'bookmarks/index' ); - } - if ( $bookmark->createdBy != App::$activeUser->ID ) { - Session::flash( 'error', 'You do not have permission to modify this bookmark.' ); - return Redirect::to( 'bookmarks/index' ); - } - self::$bookmarks->archive( $id ); - Session::flash( 'success', 'Bookmark archived.' ); - return Redirect::to( 'bookmarks/index' ); - } - - public function showBookmark( $id = null ) { - $bookmark = self::$bookmarks->findById( $id ); - if ( $bookmark == false ) { - Session::flash( 'error', 'Bookmark not found.' ); - return Redirect::to( 'bookmarks/index' ); - } - if ( $bookmark->createdBy != App::$activeUser->ID ) { - Session::flash( 'error', 'You do not have permission to modify this bookmark.' ); - return Redirect::to( 'bookmarks/index' ); - } - self::$bookmarks->show( $id ); - Session::flash( 'success', 'Bookmark shown.' ); - return Redirect::to( 'bookmarks/index' ); - } - - public function unarchiveBookmark( $id = null ) { - $bookmark = self::$bookmarks->findById( $id ); - if ( $bookmark == false ) { - Session::flash( 'error', 'Bookmark not found.' ); - return Redirect::to( 'bookmarks/index' ); - } - if ( $bookmark->createdBy != App::$activeUser->ID ) { - Session::flash( 'error', 'You do not have permission to modify this bookmark.' ); - return Redirect::to( 'bookmarks/index' ); - } - self::$bookmarks->unarchive( $id ); - Session::flash( 'success', 'Bookmark un-archived.' ); - return Redirect::to( 'bookmarks/index' ); - } - - public function refreshBookmark( $id = null ) { - $bookmark = self::$bookmarks->findById( $id ); - if ( $bookmark == false ) { - Session::flash( 'error', 'Bookmark not found.' ); - return Redirect::to( 'bookmarks/index' ); - } - if ( $bookmark->createdBy != App::$activeUser->ID ) { - Session::flash( 'error', 'You do not have permission to modify this bookmark.' ); - return Redirect::to( 'bookmarks/index' ); - } - $info = self::$bookmarks->refreshInfo( $id ); - if ( false == $info ) { - Session::flash( 'error', 'Issue refreshing your bookmark.' ); - return Redirect::to( 'bookmarks/bookmark/' . $bookmark->ID ); - } - Session::flash( 'success', 'Bookmark data refreshed.' ); - return Redirect::to( 'bookmarks/bookmark/' . $bookmark->ID ); - } -} diff --git a/app/plugins/bookmarks/forms.php b/app/plugins/bookmarks/forms.php deleted file mode 100644 index d0fd2b5..0000000 --- a/app/plugins/bookmarks/forms.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins\Bookmarks; - -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Classes\Forms; - -class BookmarksForms extends Forms { - /** - * Adds these functions to the form list. - */ - public function __construct() { - self::addHandler( 'createBookmark', __CLASS__, 'createBookmark' ); - self::addHandler( 'createFolder', __CLASS__, 'createFolder' ); - self::addHandler( 'editBookmark', __CLASS__, 'editBookmark' ); - self::addHandler( 'editFolder', __CLASS__, 'editFolder' ); - } - - public static function createBookmark() { - // if ( ! Input::exists( 'title' ) ) { - // Check::addUserError( 'You must include a title.' ); - // return false; - // } - if ( ! Input::exists( 'url' ) ) { - Check::addUserError( 'You must include a url.' ); - return false; - } - // if ( ! Input::exists( 'color' ) ) { - // Check::addUserError( 'You must include a color.' ); - // return false; - // } - // if ( ! Input::exists( 'privacy' ) ) { - // Check::addUserError( 'You must include a privacy.' ); - // return false; - // } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function createFolder() { - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - // if ( ! Input::exists( 'color' ) ) { - // Check::addUserError( 'You must include a color.' ); - // return false; - // } - // if ( ! Input::exists( 'privacy' ) ) { - // Check::addUserError( 'You must include a privacy.' ); - // return false; - // } - // if ( ! self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function editBookmark() { - // if ( ! Input::exists( 'title' ) ) { - // Check::addUserError( 'You must include a title.' ); - // return false; - // } - if ( ! Input::exists( 'url' ) ) { - Check::addUserError( 'You must include a url.' ); - return false; - } - // if ( ! Input::exists( 'color' ) ) { - // Check::addUserError( 'You must include a color.' ); - // return false; - // } - // if ( ! Input::exists( 'privacy' ) ) { - // Check::addUserError( 'You must include a privacy.' ); - // return false; - // } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function editFolder() { - if ( ! Input::exists( 'submit' ) ) { - return false; - } - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - // if ( ! Input::exists( 'color' ) ) { - // Check::addUserError( 'You must include a color.' ); - // return false; - // } - // if ( ! Input::exists( 'privacy' ) ) { - // Check::addUserError( 'You must include a privacy.' ); - // return false; - // } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } -} - -new BookmarksForms; \ No newline at end of file diff --git a/app/plugins/bookmarks/models/bookmarks.php b/app/plugins/bookmarks/models/bookmarks.php deleted file mode 100644 index 2738fe9..0000000 --- a/app/plugins/bookmarks/models/bookmarks.php +++ /dev/null @@ -1,705 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Filters; -use TheTempusProject\Bedrock\Classes\CustomException; - -class Bookmarks extends DatabaseModel { - public $tableName = 'bookmarks'; - public $linkTypes = [ - 'Open in New Tab' => 'external', - 'Open in Same Tab' => 'internal', - ]; - - public $databaseMatrix = [ - [ 'title', 'varchar', '256' ], - [ 'url', 'text', '' ], - [ 'color', 'varchar', '48' ], - [ 'privacy', 'varchar', '48' ], - [ 'folderID', 'int', '11' ], - [ 'description', 'text', '' ], - [ 'createdBy', 'int', '11' ], - [ 'createdAt', 'int', '11' ], - [ 'meta', 'text', '' ], - [ 'icon', 'text', '' ], - [ 'archivedAt', 'int', '11' ], - [ 'refreshedAt', 'int', '11' ], - [ 'hiddenAt', 'int', '11' ], - [ 'order', 'int', '11' ], - [ 'linkType', 'varchar', '32' ], - ]; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - } - - public function create( $title, $url, $folderID = 0, $description = '', $color = 'default', $privacy = 'private', $type = 'external' ) { - $fields = [ - 'title' => $title, - 'url' => $url, - 'description' => $description, - 'color' => $color, - 'privacy' => $privacy, - 'createdBy' => App::$activeUser->ID, - 'createdAt' => time(), - ]; - if ( !empty( $folderID ) ) { - $fields['folderID'] = $folderID; - } else { - $fields['folderID'] = null; - } - if ( ! self::$db->insert( $this->tableName, $fields ) ) { - new CustomException( 'bookmarkCreate' ); - Debug::error( "Bookmarks: not created " . var_export($fields,true) ); - return false; - } - return self::$db->lastId(); - } - - public function update( $id, $title, $url, $folderID = 0, $description = '', $color = 'default', $privacy = 'private', $type = 'external', $order = 0 ) { - if ( !Check::id( $id ) ) { - Debug::info( 'Bookmarks: illegal ID.' ); - return false; - } - $fields = [ - 'title' => $title, - 'url' => $url, - 'description' => $description, - 'color' => $color, - 'privacy' => $privacy, - // 'linkType' => $type, - // 'order' => $order, - ]; - if ( !empty( $folderID ) ) { - $fields['folderID'] = $folderID; - } - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'bookmarkUpdate' ); - Debug::error( "Bookmarks: $id not updated" ); - return false; - } - return true; - } - - public function byUser( $limit = null ) { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - if ( empty( $limit ) ) { - $bookmarks = self::$db->get( $this->tableName, $whereClause ); - } else { - $bookmarks = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$bookmarks->count() ) { - Debug::info( 'No Bookmarks found.' ); - return false; - } - return $this->filter( $bookmarks->results() ); - } - - public function byFolder( $id, $limit = null ) { - $whereClause = ['createdBy', '=', App::$activeUser->ID, 'AND']; - - $whereClause = array_merge( $whereClause, [ 'folderID', '=', $id ] ); - if ( empty( $limit ) ) { - $bookmarks = self::$db->get( $this->tableName, $whereClause ); - } else { - $bookmarks = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$bookmarks->count() ) { - Debug::info( 'No Bookmarks found.' ); - return false; - } - return $this->filter( $bookmarks->results() ); - } - - public function noFolder( $id = 0, $limit = 10 ) { - $whereClause = ['createdBy', '=', App::$activeUser->ID, 'AND']; - if ( !empty( $id ) ) { - $whereClause = array_merge( $whereClause, ['folderID', '!=', $id] ); - } else { - $whereClause = array_merge( $whereClause, [ 'folderID', 'IS', null] ); - } - if ( empty( $limit ) ) { - $bookmarks = self::$db->get( $this->tableName, $whereClause ); - } else { - $bookmarks = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [ 0, $limit ] ); - } - if ( !$bookmarks->count() ) { - Debug::info( 'No Bookmarks found.' ); - return false; - } - return $this->filter( $bookmarks->results() ); - } - - public function getName( $id ) { - $bookmarks = self::findById( $id ); - if (false == $bookmarks) { - return 'unknown'; - } - return $bookmarks->title; - } - - public function getColor( $id ) { - $bookmarks = self::findById( $id ); - if (false == $bookmarks) { - return 'default'; - } - return $bookmarks->color; - } - - public function simpleByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $bookmarks = self::$db->get( $this->tableName, $whereClause ); - if ( !$bookmarks->count() ) { - Debug::warn( 'Could not find any bookmarks' ); - return false; - } - - $bookmarks = $bookmarks->results(); - $out = []; - foreach ( $bookmarks as $bookmarks ) { - $out[ $bookmarks->title ] = $bookmarks->ID; - } - return $out; - } - - public function simpleObjectByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $bookmarks = self::$db->get( $this->tableName, $whereClause ); - if ( !$bookmarks->count() ) { - Debug::warn( 'Could not find any bookmarks' ); - return false; - } - - $bookmarks = $bookmarks->results(); - $out = []; - foreach ( $bookmarks as $bookmarks ) { - $obj = new \stdClass(); - $obj->title = $bookmarks->title; - $obj->ID = $bookmarks->ID; - $out[] = $obj; - } - return $out; - } - - public function deleteByFolder( $folderID ) { - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND' ]; - $whereClause = array_merge( $whereClause, [ 'folderID', '=', $folderID ] ); - $bookmarks = self::$db->get( $this->tableName, $whereClause ); - if ( ! $bookmarks->count() ) { - Debug::info( 'No ' . $this->tableName . ' data found.' ); - return []; - } - foreach( $bookmarks->results() as $bookmark ) { - $this->delete( $bookmark->ID ); - } - return true; - } - - private function resolveShortenedUrl( $url ) { - $ch = curl_init($url); - - // Set curl options - curl_setopt($ch, CURLOPT_NOBODY, true); // We don't need the body - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Follow redirects - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response - curl_setopt($ch, CURLOPT_TIMEOUT, 30); // Set a timeout - // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); // Maybe sketchy? - // Maybe sketchy? - // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Disable SSL host verification - // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disable SSL peer verification - // curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); - - // added to support the regex site - // curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - - // = - // curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'AES256+EECDH:AES256+EDH' ); - - - - - // Execute curl - $response = curl_exec( $ch ); - - // Check if there was an error - if ( curl_errno( $ch ) ) { - - - // Get error details - $errorCode = curl_errno($ch); - $errorMessage = curl_error($ch); - // Log or display the error details - dv('cURL Error: ' . $errorMessage . ' (Error Code: ' . $errorCode . ')'); - - curl_close($ch); - // return $url; // Return the original URL if there was an error - - - $url = rtrim( $url, '/' ); - $ch2 = curl_init($url); - curl_setopt($ch2, CURLOPT_NOBODY, true); // We don't need the body - curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, true); // Follow redirects - curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true); // Return the response - curl_setopt($ch2, CURLOPT_TIMEOUT, 5); // Set a timeout - curl_exec($ch2); - - if ( curl_errno( $ch2 ) ) { - - } - curl_close( $ch ); - return $url; - } - - // Get the effective URL (the final destination after redirects) - $finalUrl = curl_getinfo( $ch, CURLINFO_EFFECTIVE_URL ); - curl_close( $ch ); - - return $finalUrl; - - - - - - - - - - - // $headers = get_headers( $url, 1 ); - $headers = @get_headers($url, 1); - if ( $headers === false ) { - } - if ( isset( $headers['Location'] ) ) { - if (is_array($headers['Location'])) { - return end($headers['Location']); - } else { - return $headers['Location']; - } - } else { - return $url; - } - } - - public function filter( $data, $params = [] ) { - foreach ( $data as $instance ) { - if ( !is_object( $instance ) ) { - $instance = $data; - $end = true; - } - $base_url = $this->getBaseUrl( $instance->url ); - - if ( empty( $instance->icon ) ) { - $instance->iconHtml = ''; - } else { - if (strpos($instance->icon, 'http') !== false) { - $instance->iconHtml = ''; - } else { - $instance->iconHtml = ''; - } - } - if ( empty( $instance->hiddenAt ) ) { - $instance->hideBtn = ' - - - '; - } else { - $instance->hideBtn = ' - - - '; - } - if ( empty( $instance->archivedAt ) ) { - $instance->archiveBtn = ' - - - '; - } else { - $instance->archiveBtn = ' - - - '; - } - if ( ! empty( $instance->refreshedAt ) && time() < ( $instance->refreshedAt + ( 60 * 10 ) ) ) { - $instance->refreshBtn = ' - - - '; - } else { - $instance->refreshBtn = ' - - - '; - } - - $out[] = $instance; - if ( !empty( $end ) ) { - $out = $out[0]; - break; - } - } - return $out; - } - - public function hide( $id ) { - if ( !Check::id( $id ) ) { - Debug::info( 'Bookmarks: illegal ID.' ); - return false; - } - $fields = [ - 'hiddenAt' => time(), - ]; - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'bookmarkUpdate' ); - Debug::error( "Bookmarks: $id not updated" ); - return false; - } - return true; - } - - public function show( $id ) { - if ( !Check::id( $id ) ) { - Debug::info( 'Bookmarks: illegal ID.' ); - return false; - } - $fields = [ - 'hiddenAt' => 0, - ]; - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'bookmarkUpdate' ); - Debug::error( "Bookmarks: $id not updated" ); - return false; - } - return true; - } - - public function archive( $id ) { - if ( !Check::id( $id ) ) { - Debug::info( 'Bookmarks: illegal ID.' ); - return false; - } - $fields = [ - 'archivedAt' => time(), - ]; - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'bookmarkUpdate' ); - Debug::error( "Bookmarks: $id not updated" ); - return false; - } - return true; - } - - public function unarchive( $id ) { - if ( !Check::id( $id ) ) { - Debug::info( 'Bookmarks: illegal ID.' ); - return false; - } - $fields = [ - 'archivedAt' => 0, - ]; - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'bookmarkUpdate' ); - Debug::error( "Bookmarks: $id not updated" ); - return false; - } - return true; - } - - public function extractMetaTags($htmlContent) { - $doc = new \DOMDocument(); - @$doc->loadHTML($htmlContent); - $metaTags = []; - foreach ($doc->getElementsByTagName('meta') as $meta) { - $name = $meta->getAttribute('name') ?: $meta->getAttribute('property'); - $content = $meta->getAttribute('content'); - if ($name && $content) { - $metaTags[$name] = $content; - } - } - return $metaTags; - } - - public function fetchUrlData($url) { - $ch = curl_init(); - - // Set cURL options - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HEADER, true); // Include headers in the output - curl_setopt($ch, CURLOPT_NOBODY, false); // Include the body in the output - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Follow redirects - curl_setopt($ch, CURLOPT_TIMEOUT, 30); // Set a timeout - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Disable SSL host verification for testing - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disable SSL peer verification for testing - - // Execute cURL request - $response = curl_exec($ch); - - // Check if there was an error - if (curl_errno($ch)) { - $errorMessage = curl_error($ch); - curl_close($ch); - throw new \Exception('cURL Error: ' . $errorMessage); - } - - // Get HTTP status code - $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - - // Separate headers and body - $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); - $headers = substr($response, 0, $headerSize); - $body = substr($response, $headerSize); - - curl_close($ch); - - // Parse headers into an associative array - $headerLines = explode("\r\n", trim($headers)); - $headerArray = []; - foreach ($headerLines as $line) { - $parts = explode(': ', $line, 2); - if (count($parts) == 2) { - $headerArray[$parts[0]] = $parts[1]; - } - } - - return [ - 'http_code' => $httpCode, - 'headers' => $headerArray, - 'body' => $body, - ]; - } - - private function getMetaTagsAndFavicon( $url ) { - try { - // $url = 'https://runescape.wiki'; - $data = $this->fetchUrlData($url); - - // iv($data); - - // Get headers - $headers = $data['headers']; - iv($headers); - - // Get meta tags - $metaTags = $this->extractMetaTags($data['body']); - } catch (Exception $e) { - dv( 'Error: ' . $e->getMessage()); - - } - $metaInfo = [ - 'url' => $url, - 'title' => null, - 'description' => null, - 'image' => null, - 'favicon' => null - ]; - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $html = curl_exec($ch); - curl_close($ch); - - if ($html === false) { - return null; - } - - $meta = @get_meta_tags( $url ); - - $dom = new \DOMDocument('1.0', 'utf-8'); - $dom->strictErrorChecking = false; - $dom->loadHTML($html, LIBXML_NOERROR); - $xml = simplexml_import_dom($dom); - $arr = $xml->xpath('//link[@rel="shortcut icon"]'); - - // Get the title of the page - $titles = $dom->getElementsByTagName('title'); - if ($titles->length > 0) { - $metaInfo['title'] = $titles->item(0)->nodeValue; - } - - // Get the meta tags - $metaTags = $dom->getElementsByTagName('meta'); - $metadata = []; - foreach ($metaTags as $meta) { - $metadata[] = [ - 'name' => $meta->getAttribute('name'), - 'property' => $meta->getAttribute('property'), - 'content' => $meta->getAttribute('content') - ]; - if ($meta->getAttribute('name') === 'description') { - $metaInfo['description'] = $meta->getAttribute('content'); - } - if ($meta->getAttribute('itemprop') === 'image') { - $metaInfo['google_image'] = $meta->getAttribute('content'); - } - if ($meta->getAttribute('property') === 'og:image') { - $metaInfo['image'] = $meta->getAttribute('content'); - } - } - - // Get the link tags to find the favicon - $linkTags = $dom->getElementsByTagName('link'); - $metadata['links'] = []; - foreach ($linkTags as $link) { - $metadata['links'][] = [ $link->getAttribute('rel') => $link->getAttribute('href') ]; - if ( $link->getAttribute('rel') === 'icon' || $link->getAttribute('rel') === 'shortcut icon') { - $metaInfo['favicon'] = $link->getAttribute('href'); - break; - } - } - - $metaInfo['metadata'] = $metadata; - - return $metaInfo; - } - - public function retrieveInfo( $url ) { - $finalDestination = $this->resolveShortenedUrl( $url ); - $info = $this->getMetaTagsAndFavicon( $finalDestination ); - $base_url = $this->getBaseUrl( $finalDestination ); - - if ( ! empty( $info['favicon'] ) ) { - echo 'favicon exists' . PHP_EOL; - if ( stripos( $info['favicon'], 'http' ) !== false) { - echo 'favicon is full url' . PHP_EOL; - $imageUrl = $info['favicon']; - } else { - echo 'favicon is not full url' . PHP_EOL; - $imageUrl = trim( $base_url, '/' ) . '/' . ltrim( $info['favicon'], '/' ); - } - if ( $this->isValidImageUrl( $imageUrl ) ) { - echo 'image is valid' . PHP_EOL; - $info['favicon'] = $imageUrl; - } else { - echo 'image is not valid' . PHP_EOL; - $base_info = $this->getMetaTagsAndFavicon( $base_url ); - if ( ! empty( $base_info['favicon'] ) ) { - echo 'parent favicon exists!'; - if ( stripos( $base_info['favicon'], 'http' ) !== false) { - echo 'parent favicon is full url' . PHP_EOL; - $imageUrl = $base_info['favicon']; - } else { - echo 'parent favicon is not full url' . PHP_EOL; - $imageUrl = trim( $base_url, '/' ) . '/' . ltrim( $base_info['favicon'], '/' ); - } - if ( $this->isValidImageUrl( $imageUrl ) ) { - echo 'parent favicon image is valid' . PHP_EOL; - $info['favicon'] = $imageUrl; - } else { - echo 'parent favicon image is not valid' . PHP_EOL; - } - } - } - } else { - echo 'favicon does not exist' . PHP_EOL; - $base_info = $this->getMetaTagsAndFavicon( $base_url ); - if ( ! empty( $base_info['favicon'] ) ) { - echo 'parent favicon exists!' . PHP_EOL; - if ( stripos( $base_info['favicon'], 'http' ) !== false) { - echo 'parent favicon is full url' . PHP_EOL; - $imageUrl = $base_info['favicon']; - } else { - echo 'parent favicon is not full url' . PHP_EOL; - $imageUrl = trim( $base_url, '/' ) . '/' . ltrim( $base_info['favicon'], '/' ); - } - if ( $this->isValidImageUrl( $imageUrl ) ) { - echo 'parent favicon image is valid' . PHP_EOL; - $info['favicon'] = $imageUrl; - } else { - echo 'parent favicon image is not valid' . PHP_EOL; - } - } - } - - return $info; - } - - public function refreshInfo( $id ) { - if ( !Check::id( $id ) ) { - Debug::info( 'Bookmarks: illegal ID.' ); - return false; - } - $bookmark = self::findById( $id ); - if ( $bookmark == false ) { - Debug::info( 'Bookmarks not found.' ); - return false; - } - if ( $bookmark->createdBy != App::$activeUser->ID ) { - Debug::info( 'You do not have permission to modify this bookmark.' ); - return false; - } - if ( time() < ( $bookmark->refreshedAt + ( 60 * 10 ) ) ) { - Debug::info( 'You may only fetch bookmarks once every 10 minutes.' ); - return false; - } - - $info = $this->retrieveInfo( $bookmark->url ); - - $fields = [ - // 'refreshedAt' => time(), - ]; - - if ( empty( $bookmark->title ) && ! empty( $info['title'] ) ) { - $fields['title'] = $info['title']; - } - if ( empty( $bookmark->description ) && ! empty( $info['description'] ) ) { - $fields['description'] = $info['description']; - } - - if ( ( empty( $bookmark->icon ) || ! $this->isValidImageUrl( $bookmark->icon ) ) && ! empty( $info['favicon'] ) ) { - $fields['icon'] = $info['favicon']; - } - $fields['meta'] = json_encode( $info['metadata'] ); - - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'bookmarkUpdate' ); - Debug::error( "Bookmarks: $id not updated" ); - return false; - } - return true; - } - - private function getBaseUrl ($url ) { - $parsedUrl = parse_url($url); - - if (isset($parsedUrl['scheme']) && isset($parsedUrl['host'])) { - return $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . '/'; - } else { - return null; // URL is not valid or cannot be parsed - } - } - - function isValidImageUrl($url) { - $headers = @get_headers($url); - if ($headers && strpos($headers[0], '200') !== false) { - - return true; - // Further check to ensure it's an image - foreach ($headers as $header) { - if (strpos(strtolower($header), 'content-type:') !== false) { - if (strpos(strtolower($header), 'image/') !== false) { - return true; - } - } - } - } - return false; - } -} diff --git a/app/plugins/bookmarks/models/bookmarkviews.php b/app/plugins/bookmarks/models/bookmarkviews.php deleted file mode 100644 index 8541f21..0000000 --- a/app/plugins/bookmarks/models/bookmarkviews.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Filters; -use TheTempusProject\Bedrock\Classes\CustomException; - -class Bookmarkviews extends DatabaseModel { - public $tableName = 'bookmark_views'; - public $databaseMatrix = [ - [ 'title', 'varchar', '256' ], - [ 'description', 'text', '' ], - [ 'privacy', 'varchar', '48' ], - - - - - - - - - - - [ 'createdBy', 'int', '11' ], - [ 'createdAt', 'int', '11' ], - [ 'updatedAt', 'int', '11' ], - ]; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - } - - public function create( $title, $description = '', $privacy = 'private' ) { - if ( ! Check::dataTitle( $title ) ) { - Debug::info( 'Views: illegal title.' ); - return false; - } - $fields = [ - 'title' => $title, - 'description' => $description, - 'privacy' => $privacy, - 'createdBy' => App::$activeUser->ID, - 'createdAt' => time(), - ]; - if ( ! self::$db->insert( $this->tableName, $fields ) ) { - new CustomException( 'viewCreate' ); - Debug::error( "Views: not created " . var_export($fields,true) ); - return false; - } - return self::$db->lastId(); - } - - public function update( $id, $title, $description = '', $privacy = 'private' ) { - if ( !Check::id( $id ) ) { - Debug::info( 'Views: illegal ID.' ); - return false; - } - if ( !Check::dataTitle( $title ) ) { - Debug::info( 'Views: illegal title.' ); - return false; - } - $fields = [ - 'title' => $title, - 'description' => $description, - 'privacy' => $privacy, - ]; - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'viewUpdate' ); - Debug::error( "Views: $id not updated: $fields" ); - return false; - } - return true; - } - - public function byUser( $limit = null ) { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - if ( empty( $limit ) ) { - $views = self::$db->get( $this->tableName, $whereClause ); - } else { - $views = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$views->count() ) { - Debug::info( 'No Views found.' ); - return false; - } - return $this->filter( $views->results() ); - } - - public function getName( $id ) { - $views = self::findById( $id ); - if (false == $views) { - return 'unknown'; - } - return $views->title; - } - - public function simpleByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $views = self::$db->get( $this->tableName, $whereClause ); - if ( !$views->count() ) { - Debug::warn( 'Could not find any Views' ); - return false; - } - - $views = $views->results(); - $out = []; - foreach ( $views as $view ) { - $out[ $view->title ] = $view->ID; - } - return $out; - } - - public function simpleObjectByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $views = self::$db->get( $this->tableName, $whereClause ); - if ( !$views->count() ) { - Debug::warn( 'Could not find any Views' ); - return false; - } - - $views = $views->results(); - $out = []; - foreach ( $views as $view ) { - $obj = new \stdClass(); - $obj->title = $view->title; - $obj->ID = $view->ID; - $out[] = $obj; - } - return $out; - } -} diff --git a/app/plugins/bookmarks/models/folders.php b/app/plugins/bookmarks/models/folders.php deleted file mode 100644 index 2402c12..0000000 --- a/app/plugins/bookmarks/models/folders.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Filters; -use TheTempusProject\Bedrock\Classes\CustomException; - -class Folders extends DatabaseModel { - public $tableName = 'folders'; - public $databaseMatrix = [ - [ 'title', 'varchar', '256' ], - [ 'color', 'varchar', '48' ], - [ 'privacy', 'varchar', '48' ], - [ 'description', 'text', '' ], - [ 'folderID', 'int', '11' ], - [ 'createdBy', 'int', '11' ], - [ 'createdAt', 'int', '11' ], - ]; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - } - - public function create( $title, $folderID = 0, $description = '', $color = 'default', $privacy = 'private' ) { - if ( ! Check::dataTitle( $title ) ) { - Debug::info( 'Folders: illegal title.' ); - return false; - } - $fields = [ - 'title' => $title, - 'description' => $description, - 'color' => $color, - 'privacy' => $privacy, - 'createdBy' => App::$activeUser->ID, - 'createdAt' => time(), - ]; - if ( !empty( $folderID ) ) { - $fields['folderID'] = $folderID; - } - if ( ! self::$db->insert( $this->tableName, $fields ) ) { - new CustomException( 'folderCreate' ); - Debug::error( "Folders: not created " . var_export($fields,true) ); - return false; - } - return self::$db->lastId(); - } - - public function update( $id, $title, $folderID = 0, $description = '', $color = 'default', $privacy = 'private' ) { - if ( !Check::id( $id ) ) { - Debug::info( 'Folders: illegal ID.' ); - return false; - } - if ( !Check::dataTitle( $title ) ) { - Debug::info( 'Folders: illegal title.' ); - return false; - } - $fields = [ - 'title' => $title, - 'description' => $description, - 'color' => $color, - 'privacy' => $privacy, - ]; - if ( !empty( $folderID ) ) { - $fields['folderID'] = $folderID; - } - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'folderUpdate' ); - Debug::error( "Folders: $id not updated: $fields" ); - return false; - } - return true; - } - - public function byUser( $limit = null ) { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - if ( empty( $limit ) ) { - $folders = self::$db->get( $this->tableName, $whereClause ); - } else { - $folders = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$folders->count() ) { - Debug::info( 'No Folders found.' ); - return false; - } - return $this->filter( $folders->results() ); - } - - public function getName( $id ) { - $folder = self::findById( $id ); - if (false == $folder) { - return 'unknown'; - } - return $folder->title; - } - - public function getColor( $id ) { - $folder = self::findById( $id ); - if (false == $folder) { - return 'default'; - } - return $folder->color; - } - - public function simpleByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $folders = self::$db->get( $this->tableName, $whereClause ); - if ( !$folders->count() ) { - Debug::warn( 'Could not find any folders' ); - return false; - } - - $folders = $folders->results(); - $out = []; - $out[ 'No Folder' ] = 0; - foreach ( $folders as $folder ) { - $out[ $folder->title ] = $folder->ID; - } - return $out; - } - - public function simpleObjectByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $folders = self::$db->get( $this->tableName, $whereClause ); - if ( !$folders->count() ) { - Debug::warn( 'Could not find any folders' ); - return false; - } - - $folders = $folders->results(); - $out = []; - foreach ( $folders as $folder ) { - $obj = new \stdClass(); - $obj->title = $folder->title; - $obj->ID = $folder->ID; - $out[] = $obj; - } - return $out; - } -} diff --git a/app/plugins/bookmarks/plugin.php b/app/plugins/bookmarks/plugin.php deleted file mode 100644 index 44e5a62..0000000 --- a/app/plugins/bookmarks/plugin.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins; - -use TheTempusProject\Classes\Plugin; -use TheTempusProject\Models\Events; -use TheTempusProject\Models\Bookmarks as Bookmark; -use TheTempusProject\Models\Folders; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Template; - -class Bookmarks extends Plugin { - public $pluginName = 'TP Bookmarks'; - public $configName = 'bookmarks'; - public $pluginAuthor = 'JoeyK'; - public $pluginWebsite = 'https://TheTempusProject.com'; - public $modelVersion = '1.0'; - public $pluginVersion = '3.0'; - public $pluginDescription = 'A simple plugin which adds a site wide bookmark system.'; - public $permissionMatrix = [ - 'useBookmarks' => [ - 'pretty' => 'Can use the bookmarks feature', - 'default' => false, - ], - ]; - public $main_links = [ - [ - 'text' => 'Bookmarks', - 'url' => '{ROOT_URL}bookmarks/index', - 'filter' => 'loggedin', - ], - ]; - public $configMatrix = [ - 'enabled' => [ - 'type' => 'radio', - 'pretty' => 'Enable Bookmarks.', - 'default' => true, - ], - ]; -} diff --git a/app/plugins/bookmarks/views/bookmarks/create.html b/app/plugins/bookmarks/views/bookmarks/create.html deleted file mode 100644 index 2a42103..0000000 --- a/app/plugins/bookmarks/views/bookmarks/create.html +++ /dev/null @@ -1,45 +0,0 @@ -Create Bookmark -{BookmarkBreadCrumbs} -
- -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- {folderSelect} -
- -
- -
-
-
- -
- {colorSelect} -
-
-
- -
- -
-
-
\ No newline at end of file diff --git a/app/plugins/bookmarks/views/bookmarks/edit.html b/app/plugins/bookmarks/views/bookmarks/edit.html deleted file mode 100644 index e804d91..0000000 --- a/app/plugins/bookmarks/views/bookmarks/edit.html +++ /dev/null @@ -1,45 +0,0 @@ -Edit Bookmark -{BookmarkBreadCrumbs} -
- -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- {folderSelect} -
- -
- -
-
-
- -
- {colorSelect} -
-
-
- -
- -
-
-
\ No newline at end of file diff --git a/app/plugins/bookmarks/views/bookmarks/list.html b/app/plugins/bookmarks/views/bookmarks/list.html deleted file mode 100644 index 32b8a5e..0000000 --- a/app/plugins/bookmarks/views/bookmarks/list.html +++ /dev/null @@ -1,37 +0,0 @@ -{BookmarkBreadCrumbs} - - - - - - - - - - - - {LOOP} - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
Bookmark
- - {title} - - - {privacy} -
- No results to show. -
-Create \ No newline at end of file diff --git a/app/plugins/bookmarks/views/bookmarks/view.html b/app/plugins/bookmarks/views/bookmarks/view.html deleted file mode 100644 index 7b4e431..0000000 --- a/app/plugins/bookmarks/views/bookmarks/view.html +++ /dev/null @@ -1,84 +0,0 @@ -{BookmarkBreadCrumbs}
-
-
-
-
-

Bookmark

-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Title{title}
URL{url}
Type{linkType}
Privacy{privacy}
Color{color}
Description
{description}
Icon
{iconHtml}
{icon}
Meta
{meta}
Created{DTC}{createdAt}{/DTC}
Archived{DTC}{archivedAt}{/DTC}
Hidden{DTC}{hiddenAt}{/DTC}
Last Refreshed{DTC}{refreshedAt}{/DTC}
-
-
-
- -
-
-
\ No newline at end of file diff --git a/app/plugins/bookmarks/views/components/bookmarkListPanel.html b/app/plugins/bookmarks/views/components/bookmarkListPanel.html deleted file mode 100644 index 29d7398..0000000 --- a/app/plugins/bookmarks/views/components/bookmarkListPanel.html +++ /dev/null @@ -1,21 +0,0 @@ -
-
- {title} -
-
-
-
    - {bookmarkListRows} -
-
- -
-
\ No newline at end of file diff --git a/app/plugins/bookmarks/views/components/bookmarkListRows.html b/app/plugins/bookmarks/views/components/bookmarkListRows.html deleted file mode 100644 index fcfb01f..0000000 --- a/app/plugins/bookmarks/views/components/bookmarkListRows.html +++ /dev/null @@ -1,18 +0,0 @@ - -{LOOP} -
  • - {iconHtml} - {title} - - {hideBtn} - {archiveBtn} - - - -
  • -{/LOOP} -{ALT} -
  • - No Bookmarks -
  • -{/ALT} \ No newline at end of file diff --git a/app/plugins/bookmarks/views/components/folderPanelList.html b/app/plugins/bookmarks/views/components/folderPanelList.html deleted file mode 100644 index 9188a1e..0000000 --- a/app/plugins/bookmarks/views/components/folderPanelList.html +++ /dev/null @@ -1,10 +0,0 @@ -{LOOP} -
    - {panel} -
    -{/LOOP} -{ALT} -
    -

    no folders

    -
    -{/ALT} \ No newline at end of file diff --git a/app/plugins/bookmarks/views/dash.html b/app/plugins/bookmarks/views/dash.html deleted file mode 100644 index 030da69..0000000 --- a/app/plugins/bookmarks/views/dash.html +++ /dev/null @@ -1,16 +0,0 @@ - -{BookmarkBreadCrumbs} -
    -
    - Unsorted Bookmarks - {bookmarksList} -
    -
    - Folders List - {foldersList} -
    -
    -Folders -
    - {folderPanels} -
    \ No newline at end of file diff --git a/app/plugins/bookmarks/views/folders/create.html b/app/plugins/bookmarks/views/folders/create.html deleted file mode 100644 index 42f4adf..0000000 --- a/app/plugins/bookmarks/views/folders/create.html +++ /dev/null @@ -1,39 +0,0 @@ -Create Folder -{BookmarkBreadCrumbs} -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    - {folderSelect} -
    - -
    - -
    -
    -
    - -
    - {colorSelect} -
    -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/bookmarks/views/folders/edit.html b/app/plugins/bookmarks/views/folders/edit.html deleted file mode 100644 index 6c9fa3f..0000000 --- a/app/plugins/bookmarks/views/folders/edit.html +++ /dev/null @@ -1,39 +0,0 @@ -Edit Folder -{BookmarkBreadCrumbs} -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    - {folderSelect} -
    - -
    - -
    -
    -
    - -
    - {colorSelect} -
    -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/bookmarks/views/folders/list.html b/app/plugins/bookmarks/views/folders/list.html deleted file mode 100644 index 8e5f510..0000000 --- a/app/plugins/bookmarks/views/folders/list.html +++ /dev/null @@ -1,33 +0,0 @@ -{BookmarkBreadCrumbs} - - - - - - - - - - - - - {LOOP} - - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    TitlePrivacyDescription
    {title}{privacy}{description}
    - No results to show. -
    -Create \ No newline at end of file diff --git a/app/plugins/bookmarks/views/folders/view.html b/app/plugins/bookmarks/views/folders/view.html deleted file mode 100644 index d4aca97..0000000 --- a/app/plugins/bookmarks/views/folders/view.html +++ /dev/null @@ -1,47 +0,0 @@ -{BookmarkBreadCrumbs}
    -
    -
    -
    -
    -

    Bookmark Folder

    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    Title{title}
    Privacy{privacy}
    Color{color}
    Description
    {description}
    Created{DTC}{createdAt}{/DTC}
    -
    -
    -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/bookmarks/views/nav/folderTabs.html b/app/plugins/bookmarks/views/nav/folderTabs.html deleted file mode 100644 index 2ab6a13..0000000 --- a/app/plugins/bookmarks/views/nav/folderTabs.html +++ /dev/null @@ -1,5 +0,0 @@ - -{userFolderTabs} \ No newline at end of file diff --git a/app/plugins/bookmarks/views/nav/userFolderTabs.html b/app/plugins/bookmarks/views/nav/userFolderTabs.html deleted file mode 100644 index 45a5a93..0000000 --- a/app/plugins/bookmarks/views/nav/userFolderTabs.html +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/app/plugins/bugtracker/config/constants.php b/app/plugins/bugtracker/config/constants.php deleted file mode 100644 index cc96513..0000000 --- a/app/plugins/bugtracker/config/constants.php +++ /dev/null @@ -1,7 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers\Admin; - -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Functions\Upload; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Houdini\Classes\Navigation; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Forms as FormGen; -use TheTempusProject\Classes\AdminController; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Models\Bugtracker as BugtrackerModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Models\Comments; - -class Bugtracker extends AdminController { - protected static $tracker; - protected static $comments; - - public function __construct() { - parent::__construct(); - self::$tracker = new BugtrackerModel; - self::$title = 'Admin - Bug-Tracker'; - $view = Navigation::activePageSelect( 'nav.admin', '/admin/bugtracker' ); - Components::set( 'ADMINNAV', $view ); - } - - public function index( $data = null ) { - Views::view( 'bugtracker.admin.list', self::$tracker->list() ); - } - - public function create( $data = null ) { - $form = ''; - $form .= FormGen::getFormFieldHtml( 'title', 'Title', 'text', Input::post('title') ); - $form .= FormGen::getFormFieldHtml( 'description', 'Description', 'block', Input::post('description') ); - $form .= FormGen::getFormFieldHtml( 'bugImage', 'Screenshot', 'file', '' ); - $form .= FormGen::getFormFieldHtml( 'url', 'URL (if possible)', 'text', '' ); - $form .= FormGen::getFormFieldHtml( 'repeat', 'Has this happened more than once', 'radio' ); - Components::set( 'TRACKER_FORM', $form ); - if ( !Input::exists( 'submit' ) ) { - return Views::view( 'bugtracker.admin.create' ); - } - if ( !Forms::check( 'newBugTracker' ) ) { - Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] ); - return Views::view( 'bugtracker.admin.create' ); - } - $image = ''; - if ( Input::exists( 'bugImage' ) ) { - $folder = IMAGE_UPLOAD_DIRECTORY . App::$activeUser->username . DIRECTORY_SEPARATOR; - if ( !Upload::image( 'bugImage', $folder ) ) { - Issues::add( 'error', [ 'There was an error with your upload.' => Check::systemErrors() ] ); - } else { - $route = str_replace( APP_ROOT_DIRECTORY, '', $folder ); - $image = $route . Upload::last(); - } - } - $result = self::$tracker->create( - App::$activeUser->ID, - Input::post( 'url' ), - $image, - Input::post( 'repeat' ), - Input::post( 'description' ), - Input::post( 'title' ), - ); - if ( $result ) { - Issues::add( 'success', 'Your tracker has been created.' ); - return $this->index(); - } else { - Issues::add( 'error', [ 'There was an unknown error submitting your data.' => Check::userErrors() ] ); - return $this->index(); - } - } - - public function edit( $data = null ) { - if ( !Input::exists( 'submit' ) ) { - $bug = self::$tracker->findById( $data ); - $statusList = [ - TRACKER_STATUS_IN_PROGRESS => TRACKER_STATUS_IN_PROGRESS, - TRACKER_STATUS_TESTING => TRACKER_STATUS_TESTING, - TRACKER_STATUS_NEW => TRACKER_STATUS_NEW, - TRACKER_STATUS_FIXED => TRACKER_STATUS_FIXED, - TRACKER_STATUS_CLOSED => TRACKER_STATUS_CLOSED, - ]; - $form = ''; - $form .= FormGen::getFormFieldHtml( 'title', 'Title', 'text', $bug->title ); - $form .= FormGen::getFormFieldHtml( 'description', 'Description', 'block', $bug->description ); - $form .= FormGen::getFormFieldHtml( 'bugImage', 'Screenshot', 'file', $bug->image ); - $form .= FormGen::getFormFieldHtml( 'url', 'Page you were on', 'text', $bug->url ); - $form .= FormGen::getFormFieldHtml( 'repeat', 'Has this happened more than once', 'radio', $bug->repeatable ); - $form .= FormGen::getFormFieldHtml( 'status', 'Status', 'customSelect', $bug->status, $statusList ); - Components::set( 'TRACKER_FORM', $form ); - return Views::view( 'bugtracker.admin.edit', $bug ); - } - if ( !Forms::check( 'editBugTracker' ) ) { - Issues::add( 'error', [ 'There was an error with your form.' => Check::userErrors() ] ); - return $this->index(); - } - $image = ''; - if ( Input::exists( 'bugImage' ) ) { - $folder = IMAGE_UPLOAD_DIRECTORY . App::$activeUser->username . DIRECTORY_SEPARATOR; - if ( !Upload::image( 'bugImage', $folder ) ) { - Issues::add( 'error', [ 'There was an error with your upload.' => Check::systemErrors() ] ); - } else { - $image = $folder . Upload::last(); - } - } - $tracker = self::$tracker->updateTracker( - $data, - Input::post( 'url' ), - $image, - Input::post( 'repeat' ), - Input::post( 'description' ), - Input::post( 'title' ), - Input::post( 'status' ) - ); - if ( true === $tracker ) { - Issues::add( 'success', 'Tracker Updated.' ); - return $this->index(); - } - Issues::add( 'error', 'There was an error with your request.' ); - $this->index(); - } - - public function view( $id = null ) { - if ( empty( self::$comments ) ) { - self::$comments = new Comments; - } - $data = self::$tracker->findById( $id ); - if ( $data === false ) { - Issues::add( 'error', 'Tracker not found.' ); - return $this->index(); - } - if ( Input::exists( 'contentId' ) ) { - $this->comments( 'post', Input::post( 'contentId' ) ); - } - if ( empty( self::$comments ) ) { - self::$comments = new Comments; - } - Components::set( 'CONTENT_ID', $id ); - Components::set( 'COMMENT_TYPE', 'admin/bugtracker' ); - Components::set( 'count', self::$comments->count( 'tracker', $id ) ); - Components::set( 'NEWCOMMENT', Views::simpleView( 'comments.create' ) ); - Components::set( 'COMMENTS', Views::simpleView( 'comments.list', self::$comments->display( 10, 'tracker', $id ) ) ); - Views::view( 'bugtracker.admin.view', $data ); - } - - public function delete( $data = null ) { - if ( $data == null ) { - if ( Input::exists( 'T_' ) ) { - $data = Input::post( 'T_' ); - } - } - if ( !self::$tracker->delete( $data ) ) { - Issues::add( 'error', 'There was an error with your request.' ); - } else { - Issues::add( 'success', 'Tracker has been deleted' ); - } - $this->index(); - } - - public function comments( $sub = null, $data = null ) { - if ( empty( self::$comments ) ) { - self::$comments = new Comments; - } - if ( empty( $sub ) || empty( $data ) ) { - Session::flash( 'error', 'Whoops, try again.' ); - Redirect::to( 'admin/bugtracker' ); - } - switch ( $sub ) { - case 'post': - $content = self::$tracker->findById( $data ); - if ( empty( $content ) ) { - Session::flash( 'error', 'Unknown Post.' ); - Redirect::to( 'admin/bugtracker' ); - } - return self::$comments->formPost( 'tracker', $content, 'admin/bugtracker/view/' ); - case 'edit': - $content = self::$comments->findById( $data ); - if ( empty( $content ) ) { - Session::flash( 'error', 'Unknown Comment.' ); - Redirect::to( 'admin/bugtracker' ); - } - return self::$comments->formEdit( 'tracker', $content, 'admin/bugtracker/view/' ); - case 'delete': - $content = self::$comments->findById( $data ); - if ( empty( $content ) ) { - Session::flash( 'error', 'Unknown Comment.' ); - Redirect::to( 'admin/bugtracker' ); - } - return self::$comments->formDelete( 'tracker', $content, 'admin/bugtracker/view/' ); - } - } -} diff --git a/app/plugins/bugtracker/forms.php b/app/plugins/bugtracker/forms.php deleted file mode 100644 index dc4ca6d..0000000 --- a/app/plugins/bugtracker/forms.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins\Bugreport; - -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Classes\Forms; - -class BugTrackerForms extends Forms { - /** - * Adds these functions to the form list. - */ - public function __construct() { - self::addHandler( 'newBugTracker', __CLASS__, 'newBugTracker' ); - self::addHandler( 'editBugTracker', __CLASS__, 'editBugTracker' ); - } - - /** - * Validates the bug tracker create form. - * - * @return {bool} - */ - public static function newBugTracker() { - if ( !empty(Input::post( 'url' )) && !self::url( Input::post( 'url' ) ) ) { - self::addUserError( 'Invalid url: ' . Input::post( 'url' ) . '' ); - return false; - } - if ( !self::tf( Input::post( 'repeat' ) ) ) { - self::addUserError( 'Invalid repeat value: ' . Input::post( 'repeat' ) ); - return false; - } - if ( !Input::exists( 'title' ) ) { - self::addUserError( 'You must specify title' ); - return false; - } - if ( !self::dataTitle( Input::post( 'title' ) ) ) { - self::addUserError( 'Invalid title' ); - return false; - } - if ( !Input::exists( 'description' ) ) { - self::addUserError( 'You must specify a description' ); - return false; - } - // if ( !self::token() ) { - // return false; - // } - return true; - } - - /** - * Validates the bug tracker create form. - * - * @return {bool} - */ - public static function editBugTracker() { - if ( !empty(Input::post( 'url' )) && !self::url( Input::post( 'url' ) ) ) { - self::addUserError( 'Invalid url.' . Input::post( 'url' ) ); - return false; - } - if ( !self::tf( Input::post( 'repeat' ) ) ) { - self::addUserError( 'Invalid repeat value.' ); - return false; - } - if ( !Input::exists( 'title' ) ) { - self::addUserError( 'You must specify title' ); - return false; - } - if ( !self::dataTitle( Input::post( 'title' ) ) ) { - self::addUserError( 'Invalid title' ); - return false; - } - if ( !Input::exists( 'description' ) ) { - self::addUserError( 'You must specify a description' ); - return false; - } - // if ( !self::token() ) { - // return false; - // } - return true; - } -} - -new BugTrackerForms; diff --git a/app/plugins/bugtracker/models/bugtracker.php b/app/plugins/bugtracker/models/bugtracker.php deleted file mode 100644 index 999d715..0000000 --- a/app/plugins/bugtracker/models/bugtracker.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Bedrock\Classes\CustomException; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Plugins\Bugtracker as Plugin; - -class Bugtracker extends DatabaseModel { - public $tableName = 'bugs'; - public $databaseMatrix = [ - [ 'userID', 'int', '11' ], - [ 'time', 'int', '10' ], - [ 'title', 'varchar', '128' ], - [ 'status', 'varchar', '64' ], - [ 'description', 'text', '' ], - [ 'image', 'varchar', '256' ], - [ 'repeatable', 'varchar', '5' ], - [ 'url', 'varchar', '256' ], - ]; - public $plugin; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - $this->plugin = new Plugin; - } - - /** - * This function parses the bug reports description and - * separates it into separate keys in the array. - * - * @param array $data - The data being parsed. - * - * @return array - */ - public function filter( $data, $params = [] ) { - foreach ( $data as $instance ) { - if ( !is_object( $instance ) ) { - $instance = $data; - $end = true; - } - $instance->submittedBy = self::$user->getUsername( $instance->userID ); - $instance->repeatText = ( 'false' == $instance->repeatable ? 'no' : 'yes' ); - $out[] = $instance; - if ( !empty( $end ) ) { - $out = $out[0]; - break; - } - } - return $out; - } - - /** - * Logs a Bug Report form. - * - * @param int $ID the user ID submitting the form - * @param string $url the url - * @param string $o_url the original url - * @param int $repeat is repeatable? - * @param string $description_ description of the event. - * - * @return null - */ - public function create( $ID, $url, $image, $repeat, $description, $title ) { - if ( !$this->plugin->checkEnabled() ) { - Debug::info( 'Bug Tracking is disabled in the config.' ); - return false; - } - if ( !Check::dataTitle( $title ) ) { - Debug::info( 'bugTracker: illegal title.' ); - return false; - } - $fields = [ - 'userID' => App::$activeUser->ID, - 'time' => time(), - 'title' => $title, - 'status' => TRACKER_STATUS_NEW, - 'description' => $description, - 'image' => $image, - 'repeatable' => $repeat, - 'url' => $url, - ]; - if ( !self::$db->insert( $this->tableName, $fields ) ) { - new CustomException( $this->tableName ); - return false; - } - return self::$db->lastId(); - } - - public function updateTracker( $ID, $url, $image, $repeat, $description, $title, $status ) { - if ( !$this->plugin->checkEnabled() ) { - Debug::info( 'Bug Tracking is disabled in the config.' ); - return false; - } - if ( empty( self::$log ) ) { - self::$log = new Log; - } - if ( !Check::id( $ID ) ) { - Debug::info( 'bugTracker: illegal ID.' ); - return false; - } - if ( !Check::dataTitle( $title ) ) { - Debug::info( 'bugTracker: illegal title.' ); - return false; - } - $fields = [ - 'url' => $url, - 'description' => $description, - 'repeatable' => $repeat, - 'title' => $title, - 'status' => $status, - ]; - if ( !empty( $image ) ) { - $fields['image'] = $image; - } - if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - new CustomException( $this->tableName ); - Debug::error( "Tracker Post: $ID not updated: $fields" ); - - return false; - } - self::$log->admin( "Updated Tracker Post: $ID" ); - return true; - } -} diff --git a/app/plugins/bugtracker/plugin.php b/app/plugins/bugtracker/plugin.php deleted file mode 100644 index 6ad244c..0000000 --- a/app/plugins/bugtracker/plugin.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins; - -use ReflectionClass; -use TheTempusProject\Classes\Installer; -use TheTempusProject\Houdini\Classes\Navigation; -use TheTempusProject\Classes\Plugin; -use TheTempusProject\TheTempusProject as App; - -class Bugtracker extends Plugin { - public $pluginName = 'TP BugTracker'; - public $pluginAuthor = 'JoeyK'; - public $pluginWebsite = 'https://TheTempusProject.com'; - public $modelVersion = '1.0'; - public $pluginVersion = '3.0'; - public $pluginDescription = ''; - public $configName = 'bugtracker'; - public $configMatrix = [ - 'enabled' => [ - 'type' => 'radio', - 'pretty' => 'Enable Bug tracking.', - 'default' => true, - ], - ]; - public $permissionMatrix = [ - 'bugTrack' => [ - 'pretty' => 'Can Track Bugs', - 'default' => false, - ], - ]; - public $admin_links = [ - [ - 'text' => ' Bug Tracker', - 'url' => '{ROOT_URL}admin/bugtracker', - ], - ]; -} diff --git a/app/plugins/bugtracker/views/admin/create.html b/app/plugins/bugtracker/views/admin/create.html deleted file mode 100644 index 61e1863..0000000 --- a/app/plugins/bugtracker/views/admin/create.html +++ /dev/null @@ -1,6 +0,0 @@ -
    - Create Bug Tracker - {TRACKER_FORM} - -
    -
    \ No newline at end of file diff --git a/app/plugins/bugtracker/views/admin/dashboard.html b/app/plugins/bugtracker/views/admin/dashboard.html deleted file mode 100644 index 35254d3..0000000 --- a/app/plugins/bugtracker/views/admin/dashboard.html +++ /dev/null @@ -1,30 +0,0 @@ -New Bugs - - - - - - - - - - - - {LOOP} - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    {title}{description}
    - No results to show. -
    \ No newline at end of file diff --git a/app/plugins/bugtracker/views/admin/edit.html b/app/plugins/bugtracker/views/admin/edit.html deleted file mode 100644 index 223c27e..0000000 --- a/app/plugins/bugtracker/views/admin/edit.html +++ /dev/null @@ -1,6 +0,0 @@ -
    - Edit Bug Tracker - {TRACKER_FORM} - -
    -
    \ No newline at end of file diff --git a/app/plugins/bugtracker/views/admin/list.html b/app/plugins/bugtracker/views/admin/list.html deleted file mode 100644 index 9cce665..0000000 --- a/app/plugins/bugtracker/views/admin/list.html +++ /dev/null @@ -1,45 +0,0 @@ -Bug Trackers -{PAGINATION} -
    - - - - - - - - - - - - - - {LOOP} - - - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    TitleDescriptionStatusTime Submitted - -
    {title}{description}{status}{DTC}{time}{/DTC} - -
    - No results to show. -
    - - Create -
    -
    -clear all \ No newline at end of file diff --git a/app/plugins/bugtracker/views/admin/view.html b/app/plugins/bugtracker/views/admin/view.html deleted file mode 100644 index bc2b8d0..0000000 --- a/app/plugins/bugtracker/views/admin/view.html +++ /dev/null @@ -1,74 +0,0 @@ -
    -
    -
    -
    -
    -

    Bug Tracker

    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Title
    {title}
    Description
    {description}
    -
    - Screenshot -
    -
    Status{status}
    ID{ID}
    Time submitted{DTC}{time}{/DTC}
    Submitted by{submittedBy}
    URL:{URL}
    Multiple occurrences?{repeatText}
    -
    -
    -
    - -
    - {COMMENTS} - {NEWCOMMENT} -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/calendar/controllers/calendar.php b/app/plugins/calendar/controllers/calendar.php deleted file mode 100644 index 76d12b1..0000000 --- a/app/plugins/calendar/controllers/calendar.php +++ /dev/null @@ -1,593 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers; - -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Session; -use TheTempusProject\Bedrock\Functions\Date; -use TheTempusProject\Classes\Controller; -use TheTempusProject\Houdini\Classes\Forms as HoudiniForms; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Houdini\Classes\Template; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Hermes\Functions\Redirect; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Models\Events; -use TheTempusProject\Models\Calendars; -use TheTempusProject\Houdini\Classes\Navigation; - -class Calendar extends Controller { - protected static $events; - protected static $calendars; - protected static $defaultView; - protected static $defaultCalendar; - protected static $selectedDate; - - public function __construct() { - if ( !App::$isLoggedIn ) { - Session::flash( 'notice', 'You must be logged in to create or manage calendars.' ); - return Redirect::home(); - } - parent::__construct(); - self::$title = 'Calendar - {SITENAME}'; - self::$pageDescription = 'The {SITENAME} calendar is where you can find various features for creating and managing events and schedules.'; - self::$events = new Events; - self::$calendars = new Calendars; - - $prefs = App::$activePrefs; - if ( ! empty( $prefs['calendarPreference'] ) ) { - $view = $prefs['calendarPreference']; - } else { - Session::flash( 'info', 'You can select a default view for this page in your user settings in the top right.' ); - $view = 'byMonth'; - } - self::$defaultView = $view; - self::$selectedDate = intval( strtotime( Date::determineDateInput() ) ); - - Template::setTemplate( 'calendar' ); - - // Date Dropdown - $dateDropdownView = Views::simpleView('calendar.nav.dateDropdown', Date::getDateBreakdown( self::$selectedDate ) ); - Components::set( 'dateDropdown', $dateDropdownView ); - - // Calendar Top Tabs - $calendarTabs = Views::simpleView('calendar.nav.topTabs'); - $tabsView = Navigation::activePageSelect( $calendarTabs, Input::get( 'url' ), false, true ); - // must be done after top-nav gets selected - $calendarDropdown = Views::simpleView('calendar.nav.calendarDropdown', self::$calendars->simpleObjectByUser() ); - $calendarDropdownView = Navigation::activePageSelect( $calendarDropdown, Input::get( 'url' ), false, true ); // add notebookID as second param - Components::set( 'calendarDropdown', $calendarDropdownView); - // must be done after dropdown gets added - Components::set( 'CalendarNav', Template::parse( $calendarTabs ) ); - } - public function index() { - if ( method_exists( $this, self::$defaultView ) ) { - Redirect::to( 'calendar/'.self::$defaultView.'/' ); - } else { - Redirect::to( 'calendar/byMonth/' ); - } - } - - /** - * Events - */ - public function event( $id = null ) { - $event = $this->findEventOrFail( $id ); - Views::view( 'calendar.events.view', $event ); - } - public function createEvent() { - // get the url calendar input - $newCalendar = Input::get('calendar_id') ? Input::get('calendar_id') : '';// for loading the form - $calendarSelect = HoudiniForms::getFormFieldHtml( 'calendar_id', 'Calendar', 'select', $newCalendar, self::$calendars->simpleByUser() ); - Components::set( 'calendarSelect', $calendarSelect ); - - $repeatSelect = HoudiniForms::getFormFieldHtml( 'repeats', 'Frequency', 'select', 'none', self::$events->repeatOptions ); - Components::set( 'repeatSelect', $repeatSelect ); - - $dateSelect = Views::simpleView( 'calendar.dateSelect', $this->getEventBreakdown( self::$selectedDate ) ); - Components::set( 'dateSelect', $dateSelect ); - - if ( ! Input::exists() ) { - return Views::view( 'calendar.events.create' ); - } - - /** Attempt to save the form data somewhat */ - // get the form calendar input - $calendarID = Input::post('calendar_id') ? Input::post('calendar_id') : ''; // for submitting the form - $calendarSelect = HoudiniForms::getFormFieldHtml( 'calendar_id', 'Calendar', 'select', $calendarID, self::$calendars->simpleByUser() ); - Components::set( 'calendarSelect', $calendarSelect ); - - $repeatSelect = HoudiniForms::getFormFieldHtml( 'repeats', 'Frequency', 'select', Input::post('repeats'), self::$events->repeatOptions ); - Components::set( 'repeatSelect', $repeatSelect ); - - if ( ! Forms::check( 'createEvent' ) ) { - Issues::add( 'error', [ 'There was an error with your form.' => Check::userErrors() ] ); - return Views::view( 'calendar.events.create' ); - } - - $event_id = self::$events->create( - $calendarID, - Input::post('title'), - Date::applyUtcToDate( Date::determineDateInput() ), - Input::post('description'), - Input::post('location'), - Input::post('repeats'), - Input::post('color'), - 0, - ); - if ( ! $event_id ) { - Issues::add( 'error', [ 'There was an error creating your event.' => Check::userErrors() ] ); - return Views::view( 'calendar.events.create' ); - } - - if ( Input::post('repeats') != 'none' ) { - $childrens = self::$events->generateChildEvents( $event_id, true, true ); - } - - Session::flash( 'success', 'Your Event has been created.' ); - Redirect::to( 'calendar/'.self::$defaultView.'/'. $calendarID ); - } - public function editEvent( $id = null ) { - $calendar = Input::exists('calendar_id') ? Input::post('calendar_id') : ''; - $event = self::$events->findById( $id ); - $readableDate = date('Y-m-d H:i:s', $event->event_time); - - if ( $event == false ) { - Session::flash( 'error', 'Event not found.' ); - return Redirect::to( 'calendar/'.self::$defaultView.'/' ); - } - if ( $event->createdBy != App::$activeUser->ID ) { - Session::flash( 'error', 'You do not have permission to modify this event.' ); - return Redirect::to( 'calendar/'.self::$defaultView.'/' ); - } - - $repeatSelect = HoudiniForms::getFormFieldHtml( 'repeats', 'Frequency', 'select', $event->repeats, self::$events->repeatOptions ); - Components::set( 'repeatSelect', $repeatSelect ); - - // there should be a way to do this natively - $event_at = Date::getDateBreakdown( $event->event_time, true ); - - // $readableDate = date('Y-m-d H:i:s', $readableDate); - $dateSelect = Views::simpleView( 'calendar.dateSelect', $event_at ); - Components::set( 'dateSelect', $dateSelect ); - Components::set( 'color', $event->color ); - - if ( ! Input::exists( 'submit' ) ) { - return Views::view( 'calendar.events.edit', $event ); - } - if ( ! Forms::check( 'editEvent' ) ) { - Issues::add( 'error', [ 'There was an error updating your event.' => Check::userErrors() ] ); - return Views::view( 'calendar.events.edit', $event ); - } - $result = self::$events->update( - $id, - Input::post('title'), - Date::applyUtcToDate( Date::determineDateInput() ), - Input::post('description'), - Input::post('location'), - Input::post('repeats'), - Input::post('color'), - ); - - if ( Input::post('repeats') != 'none' && $event->parent_id == 0 ) { - $childrens = self::$events->generateChildEvents( $event->ID, true, true ); - } - - if ( ! $result ) { - Issues::add( 'error', [ 'There was an error updating your event.' => Check::userErrors() ] ); - return Views::view( 'calendar.events.edit', $event->ID ); - } - Session::flash( 'success', 'Your Event has been updated.' ); - Redirect::to( 'calendar/'.self::$defaultView.'/'. $event->calendar_id ); - } - public function deleteEvent( $id = null ) { - $event = self::$events->findById( $id ); - if ( $event == false ) { - Issues::add( 'error', 'Event not found.' ); - return $this->index(); - } - if ( $event->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this event.' ); - return $this->index(); - } - $result = self::$events->delete( $id ); - if ( !$result ) { - Session::flash( 'error', 'There was an error deleting the event(s)' ); - } else { - Session::flash( 'success', 'Event deleted' ); - } - return $this->index(); - } - - /** - * Calendars - */ - public function calendar( $id = null ) { - $calendar = $this->findCalendarOrFail( $id ); - Views::view( 'calendar.calendar.view', $calendar ); - } - public function createCalendar() { - $timezoneSelect = HoudiniForms::getTimezoneHtml( Date::getTimezone() ); - Components::set( 'timezoneSelect', $timezoneSelect ); - if ( ! Input::exists() ) { - return Views::view( 'calendar.calendar.create' ); - } - if ( ! Forms::check( 'createCalendar' ) ) { - Issues::add( 'error', [ 'There was an error creating your calendar111.' => Check::userErrors() ] ); - return Views::view( 'calendar.calendar.create' ); - } - $calendar = self::$calendars->create( Input::post('title'), Input::post('description'), Input::post('timezone'), Input::post('color') ); - if ( ! $calendar ) { - return Views::view( 'calendar.calendar.create' ); - } - Session::flash( 'success', 'Your Calendar has been created.' ); - Redirect::to( 'calendar/'.self::$defaultView.'/'); - } - public function editCalendar( $id = null ) { - $calendar = $this->findCalendarOrFail( $id ); - - $timezoneSelect = HoudiniForms::getTimezoneHtml( Date::getTimezone() ); - Components::set( 'timezoneSelect', $timezoneSelect ); - Components::set( 'color', $calendar->color ); - - if ( ! Input::exists( 'submit' ) ) { - return Views::view( 'calendar.calendar.edit', $calendar ); - } - - if ( !Forms::check( 'editCalendar' ) ) { - Issues::add( 'error', [ 'There was an error editing your calendar.' => Check::userErrors() ] ); - return Views::view( 'calendar.calendar.edit', $calendar ); - } - $result = self::$calendars->update( $id, Input::post('title'), Input::post('description'), Input::post('timezone'), Input::post('color') ); - if ( !$result ) { - Issues::add( 'error', [ 'There was an error updating your calendar.' => Check::userErrors() ] ); - return Views::view( 'calendar.calendar.edit', $calendar ); - } - Session::flash( 'success', 'Your Calendar has been updated.' ); - Redirect::to( 'calendar/'.self::$defaultView.'/'. $calendar->ID ); - } - public function deleteCalendar( $id = null ) { - $calendar = self::$calendars->findById( $id ); - if ( $calendar == false ) { - Issues::add( 'error', 'Calendar not found.' ); - return $this->index(); - } - if ( $calendar->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this calendar.' ); - return $this->index(); - } - $results = self::$events->deleteByCalendar( $id ); - $result = self::$calendars->delete( $id ); - if ( !$result ) { - Session::flash( 'error', 'There was an error deleting the calendar(s)' ); - } else { - Session::flash( 'success', 'Calendar deleted' ); - } - Redirect::to( 'calendar/'.self::$defaultView.'/' ); - } - - /** - * Views - */ - public function byDay( $id = 0 ) { - // Set base components - Components::set( 'currentView', __FUNCTION__ ); - Components::set( 'calendarID', $id ); - - // Set components for next / back arrows - $nextDayMonth = date( 'M', strtotime( 'tomorrow', self::$selectedDate ) ); - $nextDay = date( 'd', strtotime( 'tomorrow', self::$selectedDate ) ); - $lastDayMonth = date( 'M', strtotime( 'yesterday', self::$selectedDate ) ); - $lastDay = date( 'd', strtotime( 'yesterday', self::$selectedDate ) ); - Components::set( 'nextDayMonth', $nextDayMonth ); - Components::set( 'nextDay', $nextDay ); - Components::set( 'lastDayMonth', $lastDayMonth ); - Components::set( 'lastDay', $lastDay ); - - // Get the data - $dayArray = self::$events->dayArray( $id, self::$selectedDate ); - - // build the results - $selectedHour = Date::getCurrentHour(); - $day = date( 'd', self::$selectedDate ); - $month = date( 'M', self::$selectedDate ); - $year = date( 'Y', self::$selectedDate ); - $fullDay = []; - foreach ( $dayArray as $hour => $events ) { - Components::set( 'hour', $hour ); - $hourCell = new \stdClass(); - $hourCell->hour = $hour; - if ( $hour == $selectedHour ) { - $hourCell->hourSelected = ' hour-active'; - } else { - $hourCell->hourSelected = ''; - } - $hourCell->day = $day; - $hourCell->month = $month; - $hourCell->year = $year; - $hourCell->EventCells = Views::simpleView( 'calendar.nav.row', $events ); - $fullDay[] = $hourCell; - } - - // Calendar Top Tabs - Components::unset( 'calendarDropdown'); - $calendarTabs = Views::simpleView('calendar.nav.topTabs'); - $tabsView = Navigation::activePageSelect( $calendarTabs, '/calendar/byDay/', false, true ); - // must be done after top-nav gets selected - $calendarDropdown = Views::simpleView('calendar.nav.calendarDropdown', self::$calendars->simpleObjectByUser() ); - $calendarDropdownView = Navigation::activePageSelect( $calendarDropdown, Input::get( 'url' ), false, true ); // add notebookID as second param - Components::set( 'calendarDropdown', $calendarDropdownView); - Components::set( 'CalendarNav', Template::parse( $tabsView ) ); - - Components::set( 'activeDate', date( 'F d, Y', self::$selectedDate ) ); - Views::view( 'calendar.byDay', $fullDay ); - } - public function byWeek( $id = 0 ) { - // Set base components - Components::set( 'currentView', __FUNCTION__ ); - Components::set( 'calendarID', $id ); - - // Set components for next / back arrows - $lastWeekMonth = date( 'M', strtotime( '-7 days', self::$selectedDate) ); - $lastWeekDay = date( 'd', strtotime( '-7 days', self::$selectedDate) ); - $lastWeekYear = date( 'Y', strtotime( '-7 days', self::$selectedDate) ); - $nextWeekMonth = date( 'M', strtotime( '+7 days', self::$selectedDate) ); - $nextWeekDay = date( 'd', strtotime( '+7 days', self::$selectedDate) ); - $nextWeekYear = date( 'Y', strtotime( '+7 days', self::$selectedDate) ); - Components::set( 'lastWeekMonth', $lastWeekMonth ); - Components::set( 'lastWeek', $lastWeekDay ); - Components::set( 'lastYear', $lastWeekYear ); - Components::set( 'nextWeekMonth', $nextWeekMonth ); - Components::set( 'nextWeek', $nextWeekDay ); - Components::set( 'nextYear', $nextWeekYear ); - - // Get the data - $weekArray = self::$events->weekArray( $id, self::$selectedDate ); - - // build the results - $presentMonth = date( 'F', self::$selectedDate ); - $presentDay = date( 'd', self::$selectedDate ); - foreach ( $weekArray as $week => $days ) { - $weekFormat = []; - foreach ( $days as $day => $events ) { - if ( empty( $first ) ) { - $first = true; - if ( intval( $presentDay ) >= $day ) { - $month = date( 'F', self::$selectedDate ); - } else { - $month = date( 'F', strtotime( '-7 days', self::$selectedDate ) ); - } - } - if ( $day == '01' ) { - $month = date( 'F', strtotime( '+7 days', self::$selectedDate ) ); - } - Components::set( 'currentMonth', $month ); - Components::set( 'currentDay', $day ); - $dayCell = new \stdClass(); - if ( $presentDay == $day && $presentMonth == $month ) { - $dayCell->highlightedDate = ' today'; - } else { - $dayCell->highlightedDate = ''; - } - $dayCell->day = $day; - $dayCell->dayEventList = Views::simpleView( 'calendar.nav.cell', $events ); - $weekFormat[] = $dayCell; - } - $weekView = Views::simpleView( 'calendar.nav.week', $weekFormat ); - Components::set( $week . 'Element', $weekView ); - } - - // Calendar Top Tabs - Components::unset( 'calendarDropdown'); - $calendarTabs = Views::simpleView('calendar.nav.topTabs'); - $tabsView = Navigation::activePageSelect( $calendarTabs, '/calendar/byWeek/', false, true ); - // must be done after top-nav gets selected - $calendarDropdown = Views::simpleView('calendar.nav.calendarDropdown', self::$calendars->simpleObjectByUser() ); - $calendarDropdownView = Navigation::activePageSelect( $calendarDropdown, Input::get( 'url' ), false, true ); // add notebookID as second param - Components::set( 'calendarDropdown', $calendarDropdownView); - Components::set( 'CalendarNav', Template::parse( $tabsView ) ); - - Components::set( 'dateWeek', 'Week of ' . date( 'F d, Y', self::$selectedDate ) ); - Views::view( 'calendar.byWeek' ); - } - public function byMonth( $id = 0 ) { - // Set base components - Components::set( 'currentView', __FUNCTION__ ); - Components::set( 'calendarID', $id ); - - // Set components for next / back arrows - $month = date( 'F', strtotime( 'first day of last month', self::$selectedDate ) ); - $lastMonthYear = date( 'Y', strtotime( 'first day of last month', self::$selectedDate ) ); - $nextMonth = date( 'F', strtotime( 'first day of next month', self::$selectedDate ) ); - $nextMonthYear = date( 'Y', strtotime( 'first day of next month', self::$selectedDate ) ); - Components::set( 'lastMonth', $month ); - Components::set( 'lastMonthYear', $lastMonthYear ); - Components::set( 'nextMonth', $nextMonth ); - Components::set( 'nextMonthYear', $nextMonthYear ); - - // Get the data - $monthArray = self::$events->monthArray( $id, self::$selectedDate ); - - // build the results - $lastMonth = strtotime( 'last month', self::$selectedDate ); - $presentMonth = date( 'F', self::$selectedDate ); - $presentDay = date( 'd', self::$selectedDate ); - foreach ( $monthArray as $week => $days ) { - $weekFormat = []; - foreach ( $days as $day => $events ) { - if ( $day == '01' ) { - $month = date( 'F', strtotime( '+1 month', $lastMonth ) ); - $lastMonth = strtotime( '+1 month', $lastMonth) ; - } - Components::set( 'currentMonth', $month ); - Components::set( 'currentDay', $day ); - $dayCell = new \stdClass(); - if ( $presentDay == $day && $presentMonth == $month ) { - $dayCell->highlightedDate = ' today'; - } else { - $dayCell->highlightedDate = ''; - } - $dayCell->day = $day; - // prevent duplicated entries for previous/next month - if ( $lastMonth < strtotime( 'this month',self::$selectedDate ) || $lastMonth == strtotime( 'next month',self::$selectedDate )) { - $events = []; - } - $dayCell->dayEventList = Views::simpleView( 'calendar.nav.cell', $events ); - $weekFormat[] = $dayCell; - } - - $weekView = Views::simpleView( 'calendar.nav.week', $weekFormat ); - Components::set( $week . 'Element', $weekView ); - } - - // Calendar Top Tabs - Components::unset( 'calendarDropdown'); - $calendarTabs = Views::simpleView('calendar.nav.topTabs'); - $tabsView = Navigation::activePageSelect( $calendarTabs, '/calendar/byMonth/', false, true ); - // must be done after top-nav gets selected - $calendarDropdown = Views::simpleView('calendar.nav.calendarDropdown', self::$calendars->simpleObjectByUser() ); - $calendarDropdownView = Navigation::activePageSelect( $calendarDropdown, Input::get( 'url' ), false, true ); // add notebookID as second param - Components::set( 'calendarDropdown', $calendarDropdownView); - Components::set( 'CalendarNav', Template::parse( $tabsView ) ); - - Components::set( 'dateMonth', date( 'F Y', self::$selectedDate ) ); - Views::view( 'calendar.byMonth' ); - } - public function byYear( $id = 0 ) { - // Set base components - Components::set( 'calendarID', $id ); - Components::set( 'currentView', __FUNCTION__ ); - - // Set components for next / back arrows - $nextYear = date( 'Y', strtotime( 'next year', self::$selectedDate ) ); - $lastYear = date( 'Y', strtotime( 'last year', self::$selectedDate ) ); - Components::set( 'lastYear', $lastYear ); - Components::set( 'nextYear', $nextYear ); - - // Get the data - $eventList = self::$events->yearArray( $id, self::$selectedDate ); - - // Calendar Top Tabs - Components::unset( 'calendarDropdown'); - $calendarTabs = Views::simpleView('calendar.nav.topTabs'); - $tabsView = Navigation::activePageSelect( $calendarTabs, '/calendar/byYear/', false, true ); - // must be done after top-nav gets selected - $calendarDropdown = Views::simpleView('calendar.nav.calendarDropdown', self::$calendars->simpleObjectByUser() ); - $calendarDropdownView = Navigation::activePageSelect( $calendarDropdown, Input::get( 'url' ), false, true ); // add notebookID as second param - Components::set( 'calendarDropdown', $calendarDropdownView); - Components::set( 'CalendarNav', Template::parse( $tabsView ) ); - - Components::set( 'dateYear', date( 'Y', self::$selectedDate ) ); - Views::view( 'calendar.byYear', $eventList ); - } - public function events( $id = 0 ) { - Components::set( 'currentView', __FUNCTION__ ); - Components::set( 'calendarID', $id ); - if ( ! empty( $id ) ) { - $calendar = self::$calendars->findById( $id ); - if ( $calendar == false ) { - Issues::add( 'error', 'Calendar not found.' ); - return $this->index(); - } - if ( $calendar->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to view this calendar.' ); - return $this->index(); - } - Components::set( 'calendarName', $calendar->title ); - $eventList = self::$events->findByCalendar( $id ); - } else { - $eventList = self::$events->userEvents( 5 ); - } - - // Calendar Top Tabs - Components::unset( 'calendarDropdown'); - $calendarTabs = Views::simpleView('calendar.nav.topTabs'); - $tabsView = Navigation::activePageSelect( $calendarTabs, '/calendar/events/', false, true ); - // must be done after top-nav gets selected - $calendarDropdown = Views::simpleView('calendar.nav.calendarDropdown', self::$calendars->simpleObjectByUser() ); - $calendarDropdownView = Navigation::activePageSelect( $calendarDropdown, Input::get( 'url' ), false, true ); // add notebookID as second param - Components::set( 'calendarDropdown', $calendarDropdownView); - Components::set( 'CalendarNav', Template::parse( $tabsView ) ); - - Views::view( 'calendar.events.list', $eventList ); - } - - /** - * Support Functions - */ - private function findCalendarOrFail( $id = null ) { - $calendar = self::$calendars->findById( $id ); - if ( $calendar == false ) { - Session::flash( 'error', 'Calendar not found.' ); - Redirect::to( 'calendar/'.self::$defaultView.'/' ); - } - if ( $calendar->createdBy != App::$activeUser->ID ) { - Session::flash( 'error', 'Permissions Error.' ); - Redirect::to( 'calendar/'.self::$defaultView.'/' ); - } - return $calendar; - } - private function findEventOrFail( $id = null ) { - $event = self::$events->findById( $id ); - if ( $event == false ) { - Session::flash( 'error', 'Event not found.' ); - Redirect::to( 'calendar/'.self::$defaultView.'/' ); - } - if ( $event->createdBy != App::$activeUser->ID ) { - Session::flash( 'error', 'Permissions Error.' ); - Redirect::to( 'calendar/'.self::$defaultView.'/' ); - } - return $event; - } - private function getEventBreakdown( $start_timestamp = 0, $end_timestamp = 0, $with_timezone = false ) { - - - - $out = new \stdClass(); - if ( empty( $end_timestamp ) ) { - $out->allDay = 'true'; - // $out->date = ; - // $out->time = ; - $out->endDate = $out->date; - $out->endTime = $out->time; - } else { - $out->allDay = 'false'; - - // $out->date = ; - // $out->time = ; - $out->endDate = $out->date; - $out->endTime = $out->time; - } - - - $timestamp = intval( $timestamp ); - $init = date('Y-m-d H:i:s', $timestamp); - if ( true === $with_timezone ) { - $readableDate = self::applyTimezoneToTimestamp( $timestamp ); - } else { - $readableDate = date('Y-m-d H:i:s', $timestamp); - } - $date = date( 'Y-m-d', strtotime( $readableDate ) ); - $time = date( 'H:i', strtotime( $readableDate ) ); - return [ - 'time' => $time, - 'date' => $date, - ]; - - - - } -} diff --git a/app/plugins/calendar/css/calendar.css b/app/plugins/calendar/css/calendar.css deleted file mode 100644 index c2bed6e..0000000 --- a/app/plugins/calendar/css/calendar.css +++ /dev/null @@ -1,153 +0,0 @@ -.calendar-container { - margin-left: 20px; - margin-right: 20px; -} - -.calendar-row { - display: flex; - justify-content: space-between; - width: 100%; -} - -.calendar-cell { - flex: 1; - border: 1px solid #ddd; - text-align: center; - padding: 10px 0; - margin: 0 5px; -} - -.calendar-cell h4 { - margin: 0; - padding: 5px; - border-radius: 4px; - background-color: #f8f8f8; -} - -.hour-row { - display: flex; - justify-content: space-between; - width: 100%; -} - -.hour-body { - display: flex; /* Add this line to use flexbox */ - flex-direction: row; /* Ensure the direction is row */ - flex: 4; - border: 1px solid #ddd; - text-align: center; - padding: 10px 0; - margin-left: 5px; - margin-right: 5px; - align-items: center; -} - -.hour-cell { - flex: 1; - border: 1px solid #ddd; - text-align: center; - padding: 10px 0; - margin-left: 5px; - margin-right: 5px; - align-items: center; - max-width: 250px; -} - -.today { - background-color: #5cb85c !important; -} - -.hour-header, .hour-footer { - flex: 0 0 10%; - background-color: #f8f8f8; - text-align: center; - padding: 10px 0; - margin: 0 5px; - display: flex; - align-items: center; - justify-content: center; - flex-shrink: 0; -} - -/* Adjusting the first and last cell margins to align with the container edges */ -.calendar-cell:first-child { - margin-left: 0; -} - -.calendar-cell:last-child { - margin-right: 0; -} - -.select-container { - color: white; -} -.custom-select { - /* color: red; */ - color: #000; -} -.custom-select .white { - background-color: #ffffff; -} -.custom-select .primary { - background-color: #337ab7; -} -.custom-select .success { - background-color: #5cb85c; -} -.custom-select .info { - background-color: #5bc0de; -} -.custom-select .warning { - background-color: #f0ad4e; -} -.custom-select .danger { - background-color: #d9534f; -} -.select-container .primary { - background-color: #337ab7; -} -.select-container .white { - background-color: #ffffff; -} -.select-container .success { - background-color: #5cb85c; -} -.select-container .info { - background-color: #5bc0de; -} -.select-container .warning { - background-color: #f0ad4e; -} -.select-container .danger { - background-color: #d9534f; -} - -.dateDayContainer { - width: 250px; - display: inline-block; - text-align: center; -} - -.dateWeekContainer { - width: 450px; - display: inline-block; - text-align: center; -} - -.dateMonthContainer { - width: 250px; - display: inline-block; - text-align: center; -} - -.dateYearContainer { - width: 150px; - display: inline-block; - text-align: center; -} - -.hour-active { - background-color: #217025 !important; - /* color: #00ff0d !important; */ - background-image:none; -} \ No newline at end of file diff --git a/app/plugins/calendar/forms.php b/app/plugins/calendar/forms.php deleted file mode 100644 index 34ad86b..0000000 --- a/app/plugins/calendar/forms.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins\Calendar; - -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Classes\Forms; - -class CalendarForms extends Forms { - /** - * Adds these functions to the form list. - */ - public function __construct() { - self::addHandler( 'calendarSelect', __CLASS__, 'calendarSelect' ); - self::addHandler( 'createEvent', __CLASS__, 'createEvent' ); - self::addHandler( 'createCalendar', __CLASS__, 'createCalendar' ); - self::addHandler( 'editEvent', __CLASS__, 'editEvent' ); - self::addHandler( 'editCalendar', __CLASS__, 'editCalendar' ); - } - - /** - * Validates the password re-send form. - * - * @return {bool} - */ - public static function calendarSelect() { - if ( ! Input::exists( 'calendar_id' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function createEvent() { - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - if ( ! Input::exists( 'date' ) ) { - Check::addUserError( 'You must include a date.' ); - return false; - } - if ( ! Input::exists( 'time' ) ) { - Check::addUserError( 'You must include a time.' ); - return false; - } - if ( ! Input::exists( 'repeats' ) ) { - Check::addUserError( 'You must include a frequency.' ); - return false; - } - if ( ! Input::exists( 'calendar_id' ) ) { - Check::addUserError( 'You must select a calendar.' ); - return false; - } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function createCalendar() { - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - if ( ! Input::exists( 'timezone' ) ) { - Check::addUserError( 'You must include a timezone.' ); - return false; - } - // if ( ! self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function editEvent() { - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - if ( ! Input::exists( 'date' ) ) { - Check::addUserError( 'You must include a date.' ); - return false; - } - if ( ! Input::exists( 'time' ) ) { - Check::addUserError( 'You must include a time.' ); - return false; - } - if ( ! Input::exists( 'repeats' ) ) { - Check::addUserError( 'You must include a frequency.' ); - return false; - } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function editCalendar() { - if ( ! Input::exists( 'submit' ) ) { - return false; - } - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - if ( ! Input::exists( 'timezone' ) ) { - Check::addUserError( 'You must include a timezone.' ); - return false; - } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } -} - -new CalendarForms; \ No newline at end of file diff --git a/app/plugins/calendar/models/calendars.php b/app/plugins/calendar/models/calendars.php deleted file mode 100644 index 0804653..0000000 --- a/app/plugins/calendar/models/calendars.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Functions\Date; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Filters; -use TheTempusProject\Bedrock\Classes\CustomException; - -class Calendars extends DatabaseModel { - public $tableName = 'calendars'; - public $databaseMatrix = [ - [ 'title', 'varchar', '256' ], - [ 'color', 'varchar', '48' ], - [ 'privacy', 'varchar', '48' ], - [ 'description', 'text', '' ], - [ 'createdBy', 'int', '11' ], - [ 'createdAt', 'int', '11' ], - [ 'timezone', 'varchar', '256' ], - ]; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - } - - public function create( $title, $description = '', $timezone = '', $color = 'default' ) { - if ( ! Check::dataTitle( $title ) ) { - Debug::info( 'Calendars: illegal title.' ); - return false; - } - if ( empty( $timezone ) ) { - $timezone = Date::getTimezone(); - } - $fields = [ - 'title' => $title, - 'description' => $description, - 'timezone' => $timezone, - 'color' => $color, - 'createdBy' => App::$activeUser->ID, - 'createdAt' => time(), - ]; - if ( ! self::$db->insert( $this->tableName, $fields ) ) { - new CustomException( 'calendarCreate' ); - Debug::error( "Calendar: not created " . var_export($fields,true) ); - return false; - } - return self::$db->lastId(); - } - - public function update( $id, $title, $description = '', $timezone = '', $color = 'default' ) { - if ( empty( $timezone ) ) { - $timezone = Date::getTimezone(); - } - if ( !Check::id( $id ) ) { - Debug::info( 'Calendars: illegal ID.' ); - return false; - } - if ( !Check::dataTitle( $title ) ) { - Debug::info( 'Calendars: illegal title.' ); - return false; - } - $fields = [ - 'title' => $title, - 'description' => $description, - 'timezone' => $timezone, - 'color' => $color, - ]; - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'calendarUpdate' ); - Debug::error( "Calendar: $id not updated: $fields" ); - return false; - } - return true; - } - - public function byUser( $limit = null ) { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - if ( empty( $limit ) ) { - $calendars = self::$db->get( $this->tableName, $whereClause ); - } else { - $calendars = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$calendars->count() ) { - Debug::info( 'No Calendars found.' ); - return false; - } - return $this->filter( $calendars->results() ); - } - - public function getName( $id ) { - $calendar = self::findById( $id ); - if (false == $calendar) { - return 'unknown'; - } - return $calendar->title; - } - - public function getColor( $id ) { - $calendar = self::findById( $id ); - if (false == $calendar) { - return 'default'; - } - return $calendar->color; - } - - public function simpleByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $calendars = self::$db->get( $this->tableName, $whereClause ); - if ( !$calendars->count() ) { - Debug::warn( 'Could not find any calendars' ); - return false; - } - - $calendars = $calendars->results(); - $out = []; - foreach ( $calendars as &$calendar ) { - $out[ $calendar->title ] = $calendar->ID; - } - return $out; - } - - public function simpleObjectByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $calendars = self::$db->get( $this->tableName, $whereClause ); - if ( !$calendars->count() ) { - Debug::warn( 'Could not find any calendars' ); - return false; - } - - $calendars = $calendars->results(); - $out = []; - foreach ( $calendars as &$calendar ) { - $obj = new \stdClass(); - $obj->title = $calendar->title; - $obj->ID = $calendar->ID; - $out[] = $obj; - } - return $out; - } -} diff --git a/app/plugins/calendar/models/events.php b/app/plugins/calendar/models/events.php deleted file mode 100644 index c56c3d4..0000000 --- a/app/plugins/calendar/models/events.php +++ /dev/null @@ -1,509 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Filters; -use TheTempusProject\Models\Calendars; -use TheTempusProject\Bedrock\Classes\CustomException; -use TheTempusProject\Bedrock\Functions\Date; -use TheTempusProject\Bedrock\Classes\Pagination; - -class Events extends DatabaseModel { - public $tableName = 'events'; - public $repeatOptions = [ - 'Does Not Repeat' => 'none', - 'Every Day' => 'daily', - 'Every Week' => 'weekly', - 'Every Month' => 'monthly', - 'Every Year' => 'yearly', - ]; - public $databaseMatrix = [ - [ 'calendar_id', 'int', '11' ], - [ 'title', 'varchar', '256' ], - [ 'event_time', 'int', '11' ], - [ 'event_ends', 'int', '11' ], - [ 'description', 'text', '' ], - [ 'location', 'varchar', '256' ], - [ 'repeats', 'varchar', '48' ], - [ 'color', 'varchar', '48' ], - [ 'parent_id', 'int', '11' ], - [ 'createdBy', 'int', '11' ], - [ 'createdAt', 'int', '11' ], - ]; - protected static $calendars; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - self::$calendars = new Calendars; - } - - /** - * Saves a chat form to the db. - * - * @param string $message -contents of the chat form. - * @return bool - */ - public function create( $calendar_id, $title, $event_time, $description = '', $location = '', $repeats = 'none', $color = 'default', $parent_id = 0 ) { - if ( ! Check::id( $calendar_id ) ) { - Debug::info( 'calendar event: illegal calendar ID.' ); - return false; - } - $fields = [ - 'calendar_id' => $calendar_id, - 'title' => $title, - 'event_time' => $event_time, - 'description' => $description, - 'location' => $location, - 'repeats' => $repeats, - 'color' => $color, - 'parent_id' => $parent_id, - 'createdBy' => App::$activeUser->ID, - 'createdAt' => time(), - ]; - if ( !self::$db->insert( $this->tableName, $fields ) ) { - Debug::info( 'Events::create - failed to insert to db' ); - return false; - } - return self::$db->lastId(); - } - - public function update( $id, $title, $event_time, $description = '', $location ='', $repeats = 'none', $color = 'default', $parent_id = 0, $calendar_id = '' ) { - if ( ! Check::id( $id ) ) { - Debug::info( 'calendar event: illegal ID.' ); - return false; - } - $fields = [ - 'title' => $title, - 'event_time' => $event_time, - 'description' => $description, - 'location' => $location, - 'repeats' => $repeats, - 'color' => $color, - 'parent_id' => $parent_id, - ]; - if ( ! self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'calendarEventUpdate' ); - Debug::error( "Event: $id not updated: $fields" ); - - return false; - } - return true; - } - - public function dayArray( $calendar_id = 0, $date = 0 ) { - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND' ]; - if ( ! empty( $calendar_id ) ) { - $whereClause = array_merge( $whereClause, [ 'calendar_id', '=', $calendar_id, 'AND' ] ); - } - - $whereClause = array_merge( $whereClause, [ - 'event_time', '>=', Date::getDayStartTimestamp( $date, true ), 'AND', - 'event_time', '<=', Date::getDayEndTimestamp( $date, true ), - ] ); - - $events = self::$db->get( $this->tableName, $whereClause ); - if ( ! $events->count() ) { - $results = []; - } else { - $results = $events->results(); - } - $events = $this->sortByEventTimeHour( - $this->filter( - $results - ) - ); - // Generate day array - $currentDay = []; - $currentHour = Date::getDayStartTimestamp( $date ); - $lastHour = Date::getDayEndTimestamp( $date ); - while ( $currentHour <= $lastHour ) { - $hour = date( 'H', $currentHour ); - if ( ! empty( $events[ $hour ] ) ) { - $dailyEvents = $events[ $hour ]; - } else { - $dailyEvents = []; - } - $currentDay[ $hour ] = $dailyEvents; - $currentHour = strtotime('+1 hour', $currentHour); - } - return $currentDay; - } - - public function weekArray( $calendar_id = 0, $date = null ) { - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND' ]; - if ( ! empty( $calendar_id ) ) { - $whereClause = array_merge( $whereClause, [ 'calendar_id', '=', $calendar_id, 'AND' ] ); - } - - $whereClause = array_merge( $whereClause, [ - 'event_time', '>=', Date::getWeekStartTimestamp( $date, true ), 'AND', - 'event_time', '<=', Date::getWeekEndTimestamp( $date, true ), - ] ); - $events = self::$db->get( $this->tableName, $whereClause ); - if ( ! $events->count() ) { - $results = []; - } else { - $results = $events->results(); - } - $events = $this->sortByEventTime( - $this->filter( - $results - ), - ); - - // Generate weeks array - $output = []; - $currentWeek = []; - $currentDay = Date::getWeekStartTimestamp( $date ); - $weekCounter = 1; - $dayCounter = 1; - - // Re-index the array using the date derived from event_time as the key - while ( $currentDay <= Date::getWeekEndTimestamp( $date ) ) { - $month = date( 'F', $currentDay ); - $dayOfMonth = date( 'd', $currentDay ); - if ( ! empty( $events[ $month ][ $dayOfMonth ] ) ) { - $dailyEvents = $events[ $month ][ $dayOfMonth ]; - } else { - $dailyEvents = []; - } - $currentWeek[ $dayOfMonth ] = $dailyEvents; - $currentDay = strtotime('+1 day', $currentDay); - } - - // Handle any remaining days in the last week - if ( ! empty( $currentWeek ) ) { - $output["week$weekCounter"] = $currentWeek; - } - - return $output; - } - - public function monthArray( $calendar_id = 0, $date = null ) { - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND' ]; - if ( ! empty( $calendar_id ) ) { - $whereClause = array_merge( $whereClause, [ 'calendar_id', '=', $calendar_id, 'AND' ] ); - } - $whereClause = array_merge( $whereClause, [ - 'event_time', '>=', Date::getMonthStartTimestamp( $date, true ), 'AND', - 'event_time', '<=', Date::getMonthEndTimestamp( $date, true ), - ] ); - - $events = self::$db->get( $this->tableName, $whereClause ); - if ( ! $events->count() ) { - $results = []; - } else { - $results = $events->results(); - } - $events = $this->sortByEventTime( - $this->filter( - $results - ), - ); - - // Generate weeks array - $output = []; - $currentWeek = []; - $currentDay = Date::getMonthStartTimestamp( $date ); - $weekCounter = 1; - $dayCounter = 1; - - // Re-index the array using the date derived from event_time as the key - while ( $currentDay <= Date::getMonthEndTimestamp( $date ) ) { - $month = date( 'F', $currentDay ); - $dayOfMonth = date( 'd', $currentDay ); - if ( ! empty( $events[ $month ][ $dayOfMonth ] ) ) { - $dailyEvents = $events[ $month ][ $dayOfMonth ]; - } else { - $dailyEvents = []; - } - $currentWeek[$dayOfMonth] = $dailyEvents; - if (count($currentWeek) == 7) { - $output["week$weekCounter"] = $currentWeek; - $currentWeek = []; - $weekCounter++; - } - $currentDay = strtotime('+1 day', $currentDay); - } - - // Handle any remaining days in the last week - if ( ! empty( $currentWeek ) ) { - $output["week$weekCounter"] = $currentWeek; - } - while ( $weekCounter < 7 ) { - $output["week$weekCounter"] = []; - $weekCounter++; - } - return $output; - } - - public function yearArray( $calendar_id = 0, $date = null ) { - if ( empty( $date ) ) { - $date = time(); - } - $year = date( 'Y', $date ); - $firstDayUnix = date( 'U', strtotime( "Jan 1, $year" ) ); - $lastDayUnix = date( 'U', strtotime( "December 31, $year" ) ); - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND' ]; - if ( ! empty( $calendar_id ) ) { - $whereClause = array_merge( $whereClause, [ 'calendar_id', '=', $calendar_id, 'AND' ] ); - } - $whereClause = array_merge( $whereClause, [ - 'event_time', '<=', $lastDayUnix, 'AND', - 'event_time', '>=', $firstDayUnix, - ] ); - $events = self::$db->get( $this->tableName, $whereClause ); - if ( ! $events->count() ) { - Debug::info( 'No ' . $this->tableName . ' data found.' ); - return []; - } - return $this->filter( $events->results() ); - } - - public function compareEventTime($a, $b) { - return $a->event_time - $b->event_time; - } - - public function sortByEventTimeHour( $results ) { - usort( $results, [ $this,'compareEventTime' ] ); - - $sortedResults = array(); - foreach ( $results as $result ) { - $date = new \DateTime(); - $date->setTimestamp( $result->event_time ); - $timezone = new \DateTimeZone( Date::getTimezone() ); - $date->setTimezone( $timezone ); - $dateKey = $date->format('H'); - $sortedResults[ $dateKey ][] = $result; - } - return $sortedResults; - } - - public function sortByEventTime( $results ) { - usort( $results, [ $this,'compareEventTime' ] ); - - $sortedResults = array(); - foreach ( $results as $result ) { - $date = new \DateTime(); - $date->setTimestamp( $result->event_time ); - $timezone = new \DateTimeZone( Date::getTimezone() ); - $date->setTimezone( $timezone ); - $month = $date->format('F'); - $dateKey = $date->format('d'); - if ( ! isset( $sortedResults[ $month ] ) ) { - $sortedResults[ $month ] = []; - } - if ( ! isset( $sortedResults[ $month ][ $dateKey ] ) ) { - $sortedResults[ $month ][ $dateKey ] = []; - } - $sortedResults[ $month ][ $dateKey ][] = $result; - } - return $sortedResults; - } - - public function findByCalendar( $id ) { - $calendar = $this->verifyCalendar( $id ); - if ( empty( $calendar ) ) { - return []; - } - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND' ]; - $whereClause = array_merge( $whereClause, [ 'calendar_id', '=', $id ] ); - $events = self::$db->getPaginated( $this->tableName, $whereClause ); - if ( ! $events->count() ) { - Debug::info( 'No ' . $this->tableName . ' data found.' ); - return []; - } - return $this->filter( $events->results() ); - } - - public function userEvents( $limit = 0 ) { - $whereClause = [ 'createdBy', '=', App::$activeUser->ID ]; - $events = self::$db->getPaginated( $this->tableName, $whereClause ); - if ( ! $events->count() ) { - Debug::info( 'No ' . $this->tableName . ' data found.' ); - return []; - } - return $this->filter( $events->results() ); - } - - public function filter( $data, $params = [] ) { - $out = []; - foreach ( $data as $instance ) { - if ( !is_object( $instance ) ) { - $instance = $data; - $end = true; - } - $instance->repeatsText = array_search('none', $this->repeatOptions); - $instance->calendarName = self::$calendars->getName( $instance->calendar_id ); - if ( empty( $instance->color ) || $instance->color == 'default' || $instance->color == 'none') { - $instance->displayColor = self::$calendars->getColor( $instance->calendar_id ); - } else { - $instance->displayColor = $instance->color; - } - $out[] = $instance; - if ( !empty( $end ) ) { - $out = $out[0]; - break; - } - } - return $out; - } - - public function today( $limit = 0 ) { - $date = time(); - $day = date('d', $date); - $month = date('M', $date); - $year = date( 'Y', $date ); - $firstDayUnix = date( 'U', strtotime( "00:00:00 $day $month $year" ) ); - $lastDayUnix = date( 'U', strtotime( "23:59:59 $day $month $year" ) ); - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND' ]; - $whereClause = array_merge( $whereClause, [ - 'event_time', '<=', $lastDayUnix, 'AND', - 'event_time', '>=', $firstDayUnix, - ] ); - if ( empty( $limit ) ) { - $events = self::$db->get( $this->tableName, $whereClause ); - } else { - $events = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( ! $events->count() ) { - Debug::info( 'No ' . $this->tableName . ' data found.' ); - return []; - } - return $this->filter( $events->results() ); - } - - private function verifyCalendar( $calendar_id ) { - if ( ! Check::id( $calendar_id ) ) { - Debug::info( 'Invalid Calendar ID' ); - return false; - } - $calendar = self::$calendars->findById( $calendar_id ); - if ( $calendar == false ) { - Debug::info( 'Calendar not found' ); - return false; - } - if ( $calendar->createdBy != App::$activeUser->ID ) { - Debug::info( 'You do not have permission to view this calendar' ); - return false; - } - return $calendar; - } - - public function deleteByCalendar( $calendar_id ) { - $calendar = $this->verifyCalendar( $calendar_id ); - if ( empty( $calendar ) ) { - return []; - } - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND' ]; - $whereClause = array_merge( $whereClause, [ 'calendar_id', '=', $calendar_id ] ); - $events = self::$db->get( $this->tableName, $whereClause ); - if ( ! $events->count() ) { - Debug::info( 'No ' . $this->tableName . ' data found.' ); - return []; - } - foreach( $events->results() as $event ) { - $this->deleteByParent( $event->ID ); - } - return true; - } - - public function deleteByParent( $event_id ) { - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND' ]; - $whereClause = array_merge( $whereClause, [ 'parent_id', '=', $event_id ] ); - $events = self::$db->get( $this->tableName, $whereClause ); - if ( ! $events->count() ) { - Debug::info( 'No ' . $this->tableName . ' data found.' ); - return []; - } - foreach( $events->results() as $event ) { - $this->delete( $event->ID ); - } - // need to delete all child events accordingly - return true; - } - - public function delete( $idArray ) { - if ( !is_array( $idArray ) ) { - $idArray = [ $idArray ]; - } - return parent::delete( $idArray ); - } - - public function generateChildEvents( $event_id, $remove_existing_children = true, $remove_history = false ) { - $event = self::findById( $event_id ); - if (empty($event)) { - return false; - } - if ($event->parent_id != 0) { - return false; - } - if (!in_array($event->repeats, $this->repeatOptions)) { - return false; - } - $startDate = time(); - $whereClause = [ - 'parent_id', '=', $event_id, - ]; - if ( $remove_history && ! $remove_existing_children) { - $whereClause = array_merge( $whereClause, [ 'AND', 'event_time', '<=', $startDate ] ); - } elseif ( $remove_existing_children && ! $remove_history ) { - $whereClause = array_merge( $whereClause, [ 'AND', 'event_time', '>=', $startDate ] ); - } elseif ( !$remove_existing_children && !$remove_history ) { - return false; - } - self::$db->delete($this->tableName, $whereClause); - - switch ($event->repeats) { - case 'daily': - return $this->generateEvents( $event, 'P90D' ); - case 'weekly': - return $this->generateEvents( $event, 'P1W' ); - case 'monthly': - return $this->generateEvents( $event, 'P1M' ); - case 'yearly': - return $this->generateEvents( $event, 'P1Y' ); - default: - return false; - } - } - - private function generateEvents( $event, $interval, $years = 2 ) { - $endDate = strtotime('+'.$years.' years'); - $interval = new \DateInterval( $interval ); - $period = new \DatePeriod(new \DateTime('@' . $event->event_time), $interval, new \DateTime('@' . $endDate)); - foreach ($period as $date) { - if ( $date->getTimestamp() <= time() ) { - continue; - } - $result = $this->create( - $event->calendar_id, - $event->title, - $date->getTimestamp(), - $event->description, - $event->location, - $event->repeats, - $event->color, - $event->ID, - ); - } - } -} \ No newline at end of file diff --git a/app/plugins/calendar/plugin.php b/app/plugins/calendar/plugin.php deleted file mode 100644 index b0811cf..0000000 --- a/app/plugins/calendar/plugin.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins; - -use TheTempusProject\Classes\Plugin; -use TheTempusProject\Models\Events; -use TheTempusProject\Models\Calendars; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Template; - -class Calendar extends Plugin { - public $pluginName = 'TP Calendar'; - public $configName = 'calendar'; - public $pluginAuthor = 'JoeyK'; - public $pluginWebsite = 'https://TheTempusProject.com'; - public $modelVersion = '1.0'; - public $pluginVersion = '3.0'; - public $pluginDescription = 'A simple plugin which adds a site wide calendar system.'; - public $permissionMatrix = [ - 'useCalendar' => [ - 'pretty' => 'Can use the calendar feature', - 'default' => false, - ], - 'createEvents' => [ - 'pretty' => 'Can add events to calendars', - 'default' => false, - ], - ]; - public $main_links = [ - [ - 'text' => 'Calendar', - 'url' => '{ROOT_URL}calendar/index', - 'filter' => 'loggedin', - ], - ]; - public $configMatrix = [ - 'enabled' => [ - 'type' => 'radio', - 'pretty' => 'Enable Calendar.', - 'default' => true, - ], - ]; - public $preferenceMatrix = [ - 'calendarPreference' => [ - 'pretty' => 'Default Calendar View', - 'type' => 'select', - 'default' => 'byMonth', - 'options' => [ - 'Daily' => 'byDay', - 'Weekly' => 'byWeek', - 'Monthly' => 'byMonth', - 'Yearly' => 'byYear', - 'All Events' => 'events', - ], - ], - 'weekStart' => [ - 'pretty' => 'First day of the week for the Calendar', - 'type' => 'select', - 'default' => 'sunday', - 'options' => [ - 'Sunday' => '6', - 'Monday' => '7', - ], - ], - ]; - public $events; - public $calendars; - - public function __construct( $load = false ) { - $this->events = new Events; - $this->calendars = new Calendars; - parent::__construct( $load ); - } -} diff --git a/app/plugins/calendar/templates/calendar.inc.php b/app/plugins/calendar/templates/calendar.inc.php deleted file mode 100644 index c0c7e08..0000000 --- a/app/plugins/calendar/templates/calendar.inc.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Templates; - -use TheTempusProject\Plugins\Calendar; - -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Navigation; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Houdini\Classes\Template; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Models\Events; -use TheTempusProject\Models\Calendars; - -class CalendarLoader extends DefaultLoader { - /** - * This is the function used to generate any components that may be - * needed by this template. - */ - public function __construct() { - $events = new Events; - $calendars = new Calendars; - Navigation::setCrumbComponent( 'CALENDAR_BREADCRUMBS', Input::get( 'url' ) ); - Components::set( 'todaysDate', date( 'F d, Y', time()) ); - Components::set( 'currentDay', date( 'F d, Y', time()) ); - Components::set( 'weekOf', 'Week of ' . date( 'F d, Y', strtotime( 'this week' ) ) ); - Components::set( 'year', date( 'Y', time() )); - Components::set( 'month', date( 'F', time() )); - parent::__construct(); - } -} diff --git a/app/plugins/calendar/templates/calendar.tpl b/app/plugins/calendar/templates/calendar.tpl deleted file mode 100644 index 9323f42..0000000 --- a/app/plugins/calendar/templates/calendar.tpl +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - {TITLE} - - - - - - - - - - - - - {ROBOT} - - - - - - - - - - {TEMPLATE_CSS_INCLUDES} - - - - -
    -
    - {ISSUES} -
    -
    - {ERROR} - {NOTICE} - {SUCCESS} -
    -
    - {/ISSUES} -
    -
    -
    - {CalendarNav} - {CONTENT} -
    -
    -
    -
    -
    - - - - - - {TEMPLATE_JS_INCLUDES} - - \ No newline at end of file diff --git a/app/plugins/calendar/views/byDay.html b/app/plugins/calendar/views/byDay.html deleted file mode 100644 index 8e678f5..0000000 --- a/app/plugins/calendar/views/byDay.html +++ /dev/null @@ -1,25 +0,0 @@ -

    - - - - {activeDate} - - - -

    -{dateDropdown} -
    - {LOOP} -
    -

    {hour}:00

    - {EventCells} - - - -
    - {/LOOP} - {ALT} -
    -
    - {/ALT} -
    \ No newline at end of file diff --git a/app/plugins/calendar/views/byMonth.html b/app/plugins/calendar/views/byMonth.html deleted file mode 100644 index c7febef..0000000 --- a/app/plugins/calendar/views/byMonth.html +++ /dev/null @@ -1,34 +0,0 @@ -

    - - - - {dateMonth} - - - -

    -{dateDropdown} -
    - -
    -

    Sunday

    -

    Monday

    -

    Tuesday

    -

    Wednesday

    -

    Thursday

    -

    Friday

    -

    Saturday

    -
    - - {week1Element} - - {week2Element} - - {week3Element} - - {week4Element} - - {week5Element} - - {week6Element} -
    \ No newline at end of file diff --git a/app/plugins/calendar/views/byWeek.html b/app/plugins/calendar/views/byWeek.html deleted file mode 100644 index 7ecd1ce..0000000 --- a/app/plugins/calendar/views/byWeek.html +++ /dev/null @@ -1,25 +0,0 @@ - -

    - - - - {dateWeek} - - - -

    -{dateDropdown} -
    - -
    -

    Sunday

    -

    Monday

    -

    Tuesday

    -

    Wednesday

    -

    Thursday

    -

    Friday

    -

    Saturday

    -
    - - {week1Element} -
    \ No newline at end of file diff --git a/app/plugins/calendar/views/byYear.html b/app/plugins/calendar/views/byYear.html deleted file mode 100644 index 4ba31c4..0000000 --- a/app/plugins/calendar/views/byYear.html +++ /dev/null @@ -1,42 +0,0 @@ -

    - - - - {dateYear} - - - -

    -{dateDropdown} - - - - - - - - - - - - - {LOOP} - - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    IDTimeTitle
    {ID}{DTC}{event_time}{/DTC}{title}
    - No results to show. -
    -Create \ No newline at end of file diff --git a/app/plugins/calendar/views/calendar/create.html b/app/plugins/calendar/views/calendar/create.html deleted file mode 100644 index 42d712c..0000000 --- a/app/plugins/calendar/views/calendar/create.html +++ /dev/null @@ -1,34 +0,0 @@ -Create Calendar -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - {timezoneSelect} -
    -
    -
    - -
    - {colorSelect} -
    -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/calendar/views/calendar/edit.html b/app/plugins/calendar/views/calendar/edit.html deleted file mode 100644 index 795f8bb..0000000 --- a/app/plugins/calendar/views/calendar/edit.html +++ /dev/null @@ -1,29 +0,0 @@ -Edit Calendar -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - {timezoneSelect} -
    -
    -
    - -
    - {colorSelect} -
    -
    - - -
    \ No newline at end of file diff --git a/app/plugins/calendar/views/calendar/list.html b/app/plugins/calendar/views/calendar/list.html deleted file mode 100644 index 2770804..0000000 --- a/app/plugins/calendar/views/calendar/list.html +++ /dev/null @@ -1,45 +0,0 @@ -Calendars -
    - - - - - - - - - - - - - - - {LOOP} - - - - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    IDTitleDescription - -
    {ID}{title}{description} - -
    - No results to show. -
    - Create - -
    -
    \ No newline at end of file diff --git a/app/plugins/calendar/views/calendar/view.html b/app/plugins/calendar/views/calendar/view.html deleted file mode 100644 index aaf1f89..0000000 --- a/app/plugins/calendar/views/calendar/view.html +++ /dev/null @@ -1,42 +0,0 @@ -
    -
    -
    -
    -

    Calendar

    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    Title{title}
    Created{DTC}{createdAt}{/DTC}
    Description
    {description}
    TimeZone{timezone}
    -
    -
    -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/calendar/views/dateSelect.html b/app/plugins/calendar/views/dateSelect.html deleted file mode 100644 index 94f42e8..0000000 --- a/app/plugins/calendar/views/dateSelect.html +++ /dev/null @@ -1,20 +0,0 @@ -
    - -
    - -
    -
    -
    - -
    - - -
    -
    -
    - -
    - - -
    -
    \ No newline at end of file diff --git a/app/plugins/calendar/views/events/create.html b/app/plugins/calendar/views/events/create.html deleted file mode 100644 index 369413a..0000000 --- a/app/plugins/calendar/views/events/create.html +++ /dev/null @@ -1,37 +0,0 @@ -Create Event -
    - - {calendarSelect} -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - {colorSelect} -
    -
    - {dateSelect} - {repeatSelect} -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/calendar/views/events/edit.html b/app/plugins/calendar/views/events/edit.html deleted file mode 100644 index 9b9146e..0000000 --- a/app/plugins/calendar/views/events/edit.html +++ /dev/null @@ -1,31 +0,0 @@ -Edit Event -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - {colorSelect} -
    -
    - {dateSelect} - {repeatSelect} - - -
    \ No newline at end of file diff --git a/app/plugins/calendar/views/events/list.html b/app/plugins/calendar/views/events/list.html deleted file mode 100644 index 8dd4f9c..0000000 --- a/app/plugins/calendar/views/events/list.html +++ /dev/null @@ -1,34 +0,0 @@ -{PAGINATION} - - - - - - - - - - - - - {LOOP} - - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    IDTimeTitle
    {ID}{DTC}{event_time}{/DTC}{title}
    - No results to show. -
    -{PAGINATION} -Create \ No newline at end of file diff --git a/app/plugins/calendar/views/events/view.html b/app/plugins/calendar/views/events/view.html deleted file mode 100644 index e0eaa97..0000000 --- a/app/plugins/calendar/views/events/view.html +++ /dev/null @@ -1,52 +0,0 @@ -
    -
    -
    -
    -

    Event

    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Title{title}
    Created{DTC}{createdAt}{/DTC}
    Event Time{DTC}{event_time}{/DTC}
    Description
    {description}
    Location{location}
    Frequency{repeatsText}
    Calendar{calendarName}
    -
    -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/calendar/views/nav/calendarDropdown.html b/app/plugins/calendar/views/nav/calendarDropdown.html deleted file mode 100644 index fd6ba9b..0000000 --- a/app/plugins/calendar/views/nav/calendarDropdown.html +++ /dev/null @@ -1,16 +0,0 @@ - \ No newline at end of file diff --git a/app/plugins/calendar/views/nav/cell.html b/app/plugins/calendar/views/nav/cell.html deleted file mode 100644 index 088fca1..0000000 --- a/app/plugins/calendar/views/nav/cell.html +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/app/plugins/calendar/views/nav/dateDropdown.html b/app/plugins/calendar/views/nav/dateDropdown.html deleted file mode 100644 index e1874ab..0000000 --- a/app/plugins/calendar/views/nav/dateDropdown.html +++ /dev/null @@ -1,18 +0,0 @@ - \ No newline at end of file diff --git a/app/plugins/calendar/views/nav/row.html b/app/plugins/calendar/views/nav/row.html deleted file mode 100644 index 8d11893..0000000 --- a/app/plugins/calendar/views/nav/row.html +++ /dev/null @@ -1,12 +0,0 @@ - - {LOOP} -
    -

    {title}

    - - - -
    - {/LOOP} - {ALT} - {/ALT} -
    \ No newline at end of file diff --git a/app/plugins/calendar/views/nav/topTabs.html b/app/plugins/calendar/views/nav/topTabs.html deleted file mode 100644 index 67956c3..0000000 --- a/app/plugins/calendar/views/nav/topTabs.html +++ /dev/null @@ -1,8 +0,0 @@ - \ No newline at end of file diff --git a/app/plugins/calendar/views/nav/week.html b/app/plugins/calendar/views/nav/week.html deleted file mode 100644 index 102f017..0000000 --- a/app/plugins/calendar/views/nav/week.html +++ /dev/null @@ -1,9 +0,0 @@ -
    - {LOOP} -
    -

    {day}

    {dayEventList} -
    - {/LOOP} - {ALT} - {/ALT} -
    \ No newline at end of file diff --git a/app/plugins/chat/controllers/admin/chat.php b/app/plugins/chat/controllers/admin/chat.php deleted file mode 100644 index d7d84f8..0000000 --- a/app/plugins/chat/controllers/admin/chat.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers\Admin; - -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Houdini\Classes\Navigation; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Classes\AdminController; -use TheTempusProject\Models\Chat as ChatModel; - -class Chat extends AdminController { - protected static $chat; - - public function __construct() { - parent::__construct(); - self::$title = 'Admin - Chat'; - self::$chat = new ChatModel; - $view = Navigation::activePageSelect( 'nav.admin', '/admin/chat' ); - Components::set( 'ADMINNAV', $view ); - } - - public function index() { - // Views::view( 'chat.admin.list', self::$chat->list() ); - } -} diff --git a/app/plugins/chat/controllers/api/messages.php b/app/plugins/chat/controllers/api/messages.php deleted file mode 100644 index 8ef0744..0000000 --- a/app/plugins/chat/controllers/api/messages.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers\Api; - -use TheTempusProject\Models\User; -use TheTempusProject\Classes\ApiController; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Houdini\Classes\Template; -use TheTempusProject\Models\Chat; - -class Messages extends ApiController { - public static $chat; - - public function __construct() { - parent::__construct(); - self::$chat = new Chat; - Template::setTemplate( 'api' ); - } - - public function sendMessage() { - $response = true; - if ( ! Forms::check( 'newChatMessage' ) ) { - $response = 'Invalid Form'; - } else { - $response = self::$chat->create( Input::post( 'chatMessage' ) ); - } - Views::view( 'api.response', ['response' => json_encode( [ 'data' => $response ], true )]); - } - - public function getMessages() { - $response = Views::simpleView( 'chat.chat', self::$chat->recent( 50 ) ); - Views::view( 'api.response', ['response' => json_encode( [ 'data' => $response ], true )]); - } -} \ No newline at end of file diff --git a/app/plugins/chat/controllers/chat.php b/app/plugins/chat/controllers/chat.php deleted file mode 100644 index 3c204b2..0000000 --- a/app/plugins/chat/controllers/chat.php +++ /dev/null @@ -1,191 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers; - -use TheTempusProject\Hermes\Functions\Redirect; -use TheTempusProject\Bedrock\Functions\Upload; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Session; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Classes\Controller; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Models\Chat as ChatModel; -use TheTempusProject\Models\Upload as UploadModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Template; -use TheTempusProject\Canary\Bin\Canary as Debug; - -class Chat extends Controller { - protected static $chat; - public function __construct() { - parent::__construct(); - self::$chat = new ChatModel; - Template::setTemplate( 'chat' ); - } - - public function index() { - if ( !App::$isMember ) { - Session::flash( 'error', 'You do not have permission to view this page.' ); - return Redirect::home(); - } - self::$title = '{SITENAME} Chat'; - self::$pageDescription = 'One of the privleges of membership is the ability to chat with your fellow members.'; - - if ( App::$isLoggedIn ) { - Components::set( 'CREATE_MESSAGE', Views::simpleView( 'chat.create' ) ); - } else { - Components::set( 'CREATE_MESSAGE', '' ); - } - - $upload = ''; - $sharePlugin = 'TheTempusProject\Plugins\Fileshare'; - if ( class_exists( $sharePlugin ) ) { - $plugin = new $sharePlugin; - if ( $plugin->checkEnabled() ) { - $upload = Views::simpleView( 'chat.upload' ); - } - } - Components::set( 'FILE_UPLOAD', $upload ); - - Components::set( 'CHAT', Views::simpleView( 'chat.chat' ) ); - return Views::view( 'chat.index' ); - } - - public function sendMessage() { - Template::setTemplate( 'api' ); - $out = [ 'response' => true ]; - if ( !Forms::check( 'newChatMessage' ) ) { - $out = [ 'response' => false ]; - echo json_encode($out); - return; - } - self::$chat->create( - Input::post( 'chatMessage' ), - ); - echo json_encode($out); - return; - } - - public function uploadFile() { - Template::setTemplate( 'api' ); - $out = [ 'response' => true ]; - if ( ! Forms::check( 'newFileUpload' ) ) { - $out = [ 'response' => false ]; - echo json_encode($out); - return; - } - - $sharePlugin = 'TheTempusProject\Plugins\Fileshare'; - if ( ! class_exists( $sharePlugin ) ) { - $out = [ 'error' => 'Fileshare must be installed and enabled for this feature to work1.' ]; - echo json_encode($out); - return; - } - - $plugin = new $sharePlugin; - - if ( ! $plugin->checkEnabled() ) { - $out = [ 'error' => 'Fileshare must be installed and enabled for this feature to work2.' ]; - echo json_encode($out); - return; - } - - $folder = UPLOAD_DIRECTORY . App::$activeUser->username . DIRECTORY_SEPARATOR; - if ( ! Upload::image( 'file', $folder ) ) { - $out = [ 'error' => 'could not upload image' ]; - echo json_encode($out); - return; - } - - $route = str_replace( APP_ROOT_DIRECTORY, '', $folder ); - $location = $route . Upload::last(); - $uploads = new UploadModel; - $result = $uploads->create( 'Chat Upload', $location ); - - if ( ! $result ) { - $out = [ 'error' => 'could not add upload to fileshare.' ]; - echo json_encode( $out ); - return; - } - - self::$chat->create( - 'Shared a file with the chat: ' . - 'Upload' - ); - echo json_encode($out); - return; - } - - public function getMessages() { - Template::setTemplate( 'api' ); - echo Views::simpleView( 'chat.chat', self::$chat->recent( 50 ) ); - return; - } - - public function getMessageEvents() { - if ($_SERVER['HTTP_ACCEPT'] !== 'text/event-stream') { - Debug::info( 'connection refused, wrong HTTP_ACCEPT' ); - exit(); - } - - header("X-Accel-Buffering: no"); - header('Content-Type: text/event-stream'); - header('Cache-Control: no-cache'); - header('Connection: keep-alive'); - - // Ensure unlimited script execution time - set_time_limit(0); - - // Disable output buffering - ini_set('output_buffering', 'off'); - ini_set('zlib.output_compression', false); - - if (Input::exists('lastId')) { - $lastId = Input::get('lastId'); - } else { - $lastId = 0; - } - - while ( true ) { - echo "id: 0\n"; - echo "event: ping\n"; - echo 'data: {"time": "' . time() . '"}'; - echo "\n\n"; - if ( connection_aborted() ) { - Debug::info( 'getMessageEvents connection aborted' ); - break; - } - - $newMessages = self::$chat->sinceMessage( $lastId ); - if ( ! empty( $newMessages )) { - foreach ( $newMessages as $message ) { - $lastId = $message->ID; - echo "id: {$message->ID}\n"; - echo "data: " . json_encode($message) . "\n\n"; - } - } - - // If there were any messages added, flush the output buffer - if (ob_get_contents()) { - ob_end_flush(); - } - flush(); - // sessions will block the end-user from sending messages unless we close the session - session_write_close(); - sleep(1); - } - } -} diff --git a/app/plugins/chat/css/chat.css b/app/plugins/chat/css/chat.css deleted file mode 100644 index 42db653..0000000 --- a/app/plugins/chat/css/chat.css +++ /dev/null @@ -1,116 +0,0 @@ -* { - margin: 0; - padding: 0; - } - - body { - margin: 20px auto; - font-family: "Lato"; - font-weight: 300; - } - - form { - padding: 15px 25px; - display: flex; - gap: 10px; - justify-content: center; - } - - form label { - font-size: 1.5rem; - font-weight: bold; - } - - input { - font-family: "Lato"; - } - - a { - color: #0000ff; - text-decoration: none; - } - - a:hover { - text-decoration: underline; - } - - #chatMessages { - text-align: left; - margin: 0 auto; - padding: 10px; - height: 300px; - border: 1px solid #a7a7a7; - overflow: auto; - } - - #usermsg { - flex: 1; - border-radius: 4px; - border: 1px solid #ff9800; - } - - #name { - border-radius: 4px; - border: 1px solid #ff9800; - padding: 2px 8px; - } - - #submitmsg, - #enter{ - background: #ff9800; - border: 2px solid #e65100; - color: white; - padding: 4px 10px; - font-weight: bold; - border-radius: 4px; - } - - .error { - color: #ff0000; - } - - #menu { - padding: 15px 25px; - display: flex; - } - - #menu p.welcome { - flex: 1; - } - - a#exit { - color: white; - background: #c62828; - padding: 4px 8px; - border-radius: 4px; - font-weight: bold; - } - - .msgln { - margin: 0 0 5px 0; - } - - .span.left-info { - color: orangered; - } - - span .chat-time { - color: #666; - font-size: 80%; - vertical-align: super; - width: 100px; - } - - .msgln b.user-name, .msgln b.user-name-left { - font-weight: bold; - background: #546e7a; - color: white; - padding: 2px 4px; - font-size: 90%; - border-radius: 4px; - margin: 0 5px 0 0; - } - - .msgln b.user-name-left { - background: orangered; - } \ No newline at end of file diff --git a/app/plugins/chat/forms.php b/app/plugins/chat/forms.php deleted file mode 100644 index 99e5ec7..0000000 --- a/app/plugins/chat/forms.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins\Chat; - -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Classes\Forms; - -class ChatForms extends Forms { - /** - * Adds these functions to the form list. - */ - public function __construct() { - self::addHandler( 'newChatMessage', __CLASS__, 'newChatMessage' ); - self::addHandler( 'newFileUpload', __CLASS__, 'newFileUpload' ); - } - - /** - * Validates the new blog post form. - * - * @return {bool} - */ - public static function newChatMessage() { - if ( !Input::exists( 'chatMessage' ) ) { - self::addUserError( 'You must includes a message' ); - return false; - } - // if (!self::token()) { - // return false; - // } - return true; - } - public static function newFileUpload() { - if ( !Input::exists( 'file' ) ) { - self::addUserError( 'You must includes a file' ); - return false; - } - return true; - } -} - -new ChatForms; diff --git a/app/plugins/chat/js/chat.js b/app/plugins/chat/js/chat.js deleted file mode 100644 index 8dca810..0000000 --- a/app/plugins/chat/js/chat.js +++ /dev/null @@ -1,116 +0,0 @@ -$(document).ready(function() { - var chatform = $('#sendChatMessage'); - var uploadForm = $('#uploadFile'); - - chatform.bind('submit', function(event) { - event.preventDefault(); // Prevent page reload - var msg = $("#chatMessage").val(); - - console.log("Submitting message:", msg); - - var ajax_params = { - url: '/chat/sendMessage', - type: 'POST', - data: { chatMessage: msg }, - success: function(response) { - console.log("Message sent successfully:", response); - $("#chatMessage").val(""); - }, - error: function(xhr, status, error) { - console.error("Error sending message:", error, status, xhr); - }, - complete: function() { - console.log("AJAX request complete"); - } - }; - - $.ajax(ajax_params); - return false; - }); - - uploadForm.bind('submit', function(event) { - event.preventDefault(); // Prevent page reload - - var formData = new FormData(this); // Create FormData object - - $.ajax({ - url: '/chat/uploadFile', - type: 'POST', - data: formData, - processData: false, // Don't process the files - contentType: false, // Set content type to false as jQuery will tell the server its a query string request - success: function(response) { - console.log("File uploaded successfully:", response); - $("#file").val(""); - }, - error: function(xhr, status, error) { - console.error("Error uploading file:", error, status, xhr); - }, - complete: function() { - console.log("AJAX request complete"); - } - }); - - return false; - }); - - const eventSource = new EventSource('/chat/getMessageEvents'); - eventSource.onmessage = function( event ) { - const message = JSON.parse( event.data ); - - var userPopup = "
    " + - "" + - "" + - "" + - "
    " + - "
    " + - ""+message.submittedByName+"" + - "
    " + - " View Profile" + - "
    " + - "
    "; - - $("#chatMessages").append( - "" + - new Date(message.submittedAt * 1000).toLocaleString('en-US', { month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', hour12: true }) + - // new Date(message.submittedAt * 1000).toLocaleString() + - " " + - '' + - message.submittedByName + - ' ' + - message.chatMessage + "
    " - ); - $("[data-toggle=popover]").popover(); - $("#chatMessages").scrollTop($("#chatMessages")[0].scrollHeight); - }; - - eventSource.onerror = function(event) { - console.error('EventSource failed:', event); - }; - - window.addEventListener('beforeunload', function() { - eventSource.close(); - }); - - window.addEventListener('unload', function() { - eventSource.close(); - }); - - // function getUserProfile( id ) { - // var ajax_params = { - // url: '/api/users/find/' + id, - // type: 'GET', - // success: function(response) { - // console.log("User retrieved:", response); - // $("#chatMessage").val(""); - // }, - // error: function(xhr, status, error) { - // console.error("Error retrieved user:", error, status, xhr); - // }, - // complete: function() { - // console.log("AJAX request complete"); - // } - // }; - // $.ajax(ajax_params); - // } -}); diff --git a/app/plugins/chat/models/chat.php b/app/plugins/chat/models/chat.php deleted file mode 100644 index 689318f..0000000 --- a/app/plugins/chat/models/chat.php +++ /dev/null @@ -1,145 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Filters; - -class Chat extends DatabaseModel { - public $tableName = 'chat'; - public $databaseMatrix = [ - [ 'submittedAt', 'int', '10' ], - [ 'submittedBy', 'int', '11' ], - [ 'chatMessage', 'text', '' ], - ]; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - } - - /** - * Saves a chat form to the db. - * - * @param string $message -contents of the chat form. - * @return bool - */ - public function create( $message ) { - $fields = [ - 'submittedBy' => App::$activeUser->ID, - 'submittedAt' => time(), - 'chatMessage' => $message, - ]; - if ( !self::$db->insert( $this->tableName, $fields ) ) { - Debug::info( 'Chat::create - failed to insert to db' ); - return false; - } - return self::$db->lastId(); - } - - public function filter( $data, $params = [] ) { - foreach ( $data as $instance ) { - if ( !is_object( $instance ) ) { - $instance = $data; - $end = true; - } - $instance->chatMessage = Filters::applyOne( 'mentions.0', $instance->chatMessage, true ); - $instance->chatMessage = Filters::applyOne( 'hashtags.0', $instance->chatMessage, true ); - $user = self::$user->findById( $instance->submittedBy ); - if ( ! empty( $user ) ) { - $instance->submittedByName = $user->username; - $instance->profileUrl = '/home/profile/' . $user->username; - } else { - $instance->submittedByName = 'Unknown'; - $instance->profileUrl = '#'; - } - $instance->avatar = self::$user->getAvatar( $instance->submittedBy ); - $out[] = $instance; - if ( !empty( $end ) ) { - $out = $out[0]; - break; - } - } - return $out; - } - - /** - * Function to clear chat from the DB. - * - * @todo is there a way i could check for success here I'm pretty sure this is just a bad idea? - * @return bool - */ - public function clear() { - if ( empty( self::$log ) ) { - self::$log = new Log; - } - self::$db->delete( $this->tableName, ['ID', '>=', '0'] ); - self::$log->admin( 'Cleared Chat' ); - Debug::info( 'Chat Cleared' ); - return true; - } - - public function recent( $limit = null ) { - if ( empty( $limit ) ) { - $postData = self::$db->get( $this->tableName, '*' ); - } else { - $postData = self::$db->get( $this->tableName, '*', 'ID', 'ASC', [0, $limit] ); - } - if ( !$postData->count() ) { - Debug::info( 'No messages found.' ); - return false; - } - return $this->filter( $postData->results() ); - } - - public function sinceMessage($id = 0) { - if (empty($id)) { - $postData = self::$db->get($this->tableName, '*', 'ID', 'DESC', [0, 20]); - } else { - $postData = self::$db->get($this->tableName, ['ID', '>', $id], 'ID', 'ASC', [0, 20]); - } - if ( ! $postData->count() ) { - Debug::debug( 'No messages found.' ); - return false; - } - - if (empty($id)) { - $results = array_reverse($postData->results()); // Reverse the order to get ascending IDs - } else { - $results = $postData->results(); - } - - return $this->filter($results); - } - - public function sinceMessageSingle( $id = 0 ) { - if ( empty( $id ) ) { - $postData = self::$db->get( $this->tableName, '*', 'ID', 'ASC', [0, 1] ); - } else { - $postData = self::$db->get( $this->tableName, [ 'ID', '>', $id ], 'ID', 'ASC', [0, 1] ); - } - if ( ! $postData->count() ) { - Debug::debug( 'No messages found.' ); - return false; - } - return $this->filter( $postData->results() ); - } -} diff --git a/app/plugins/chat/plugin.php b/app/plugins/chat/plugin.php deleted file mode 100644 index 02039a0..0000000 --- a/app/plugins/chat/plugin.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins; - -use TheTempusProject\Classes\Plugin; -use TheTempusProject\TheTempusProject as App; - -class Chat extends Plugin { - public $pluginName = 'TP Chat'; - public $configName = 'chat'; - public $pluginAuthor = 'JoeyK'; - public $pluginWebsite = 'https://TheTempusProject.com'; - public $modelVersion = '1.0'; - public $pluginVersion = '3.0'; - public $pluginDescription = 'A simple plugin which adds a site wide chat system.'; - public $permissionMatrix = [ - 'chat' => [ - 'pretty' => 'Can use chat', - 'default' => false, - ], - ]; - public $admin_links = [ - [ - 'text' => ' Chat', - 'url' => '{ROOT_URL}admin/chat', - ], - ]; - public $main_links = [ - [ - 'text' => 'Chat', - 'url' => '{ROOT_URL}chat/index', - 'filter' => 'loggedin', - ], - ]; - public $configMatrix = [ - 'enabled' => [ - 'type' => 'radio', - 'pretty' => 'Enable Chat.', - 'default' => true, - ], - ]; - public function __construct( $load = false ) { - parent::__construct( $load ); - } -} \ No newline at end of file diff --git a/app/plugins/chat/templates/chat.inc.php b/app/plugins/chat/templates/chat.inc.php deleted file mode 100644 index 89b32be..0000000 --- a/app/plugins/chat/templates/chat.inc.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Templates; - -use TheTempusProject\Plugins\Calendar; - -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Navigation; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Houdini\Classes\Template; -use TheTempusProject\Bedrock\Functions\Input; - -class ChatLoader extends DefaultLoader { - /** - * This is the function used to generate any components that may be - * needed by this template. - */ - public function __construct() { - $this->addJs( '' ); - parent::__construct(); - } -} diff --git a/app/plugins/chat/templates/chat.tpl b/app/plugins/chat/templates/chat.tpl deleted file mode 100644 index 22b1267..0000000 --- a/app/plugins/chat/templates/chat.tpl +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - {TITLE} - - - - - - - - - - - - {AUTHOR} - {ROBOT} - - - - - - - {TEMPLATE_CSS_INCLUDES} - - - -
    - {ISSUES} -
    -
    - {ERROR} - {NOTICE} - {SUCCESS} - {INFO} -
    -
    - {/ISSUES} -
    -
    - {CONTENT} -
    -
    -
    - - - - - - {TEMPLATE_JS_INCLUDES} - - \ No newline at end of file diff --git a/app/plugins/chat/views/admin/index.html b/app/plugins/chat/views/admin/index.html deleted file mode 100644 index e69de29..0000000 diff --git a/app/plugins/chat/views/chat.html b/app/plugins/chat/views/chat.html deleted file mode 100644 index 84300b9..0000000 --- a/app/plugins/chat/views/chat.html +++ /dev/null @@ -1,10 +0,0 @@ -{LOOP} -
    - {DTC time}{submittedAt}{/DTC} {submittedByName}: {chatMessage}
    -
    -{/LOOP} -{ALT} -
    - No messages Found.
    -
    -{/ALT} \ No newline at end of file diff --git a/app/plugins/chat/views/create.html b/app/plugins/chat/views/create.html deleted file mode 100644 index b5f2859..0000000 --- a/app/plugins/chat/views/create.html +++ /dev/null @@ -1,9 +0,0 @@ -
    - -
    - -
    -
    - -
    -
    \ No newline at end of file diff --git a/app/plugins/chat/views/index.html b/app/plugins/chat/views/index.html deleted file mode 100644 index 5cc8330..0000000 --- a/app/plugins/chat/views/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/plugins/chat/views/upload.html b/app/plugins/chat/views/upload.html deleted file mode 100644 index ffe34ab..0000000 --- a/app/plugins/chat/views/upload.html +++ /dev/null @@ -1,9 +0,0 @@ -
    - -
    - -
    -
    - -
    -
    \ No newline at end of file diff --git a/app/plugins/contacts/controllers/contacts.php b/app/plugins/contacts/controllers/contacts.php deleted file mode 100644 index eff058b..0000000 --- a/app/plugins/contacts/controllers/contacts.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers; - -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Houdini\Classes\Forms as FormBuilder; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Classes\Config; - - - -use TheTempusProject\Classes\Controller; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Bedrock\Functions\Session; -use TheTempusProject\Hermes\Functions\Redirect; -use TheTempusProject\Models\Contact; -use TheTempusProject\Models\Phonebook; -use TheTempusProject\Houdini\Classes\Template; -use TheTempusProject\Houdini\Classes\Navigation; - -class Contacts extends Controller { - protected static $contacts; - protected static $phonebooks; - - public function __construct() { - parent::__construct(); - if ( !App::$isLoggedIn ) { - Session::flash( 'notice', 'You must be logged in to use this feature.' ); - return Redirect::home(); - } - self::$contacts = new Contact; - self::$phonebooks = new Phonebook; - self::$title = 'Contacts - {SITENAME}'; - self::$pageDescription = 'On this page you can create and manage contacts and phonebooks.'; - } - - public function index() { - $phonebooks = Views::simpleView( 'contacts.phonebooks.list', self::$phonebooks->byUser() ); - Components::set( 'phonebookList', $phonebooks ); - - $contacts = Views::simpleView( 'contacts.contacts.list', self::$contacts->byUser() ); - Components::set( 'contactList', $contacts ); - - Views::view( 'contacts.dashboard' ); - } - - /** - * Contacts - */ - public function viewContact( $id = null ) { - // stuff here - } - public function createContact( $id = null ) { - // stuff here - } - public function editContact( $id = null ) { - // stuff here - } - public function deleteContact( $id = null ) { - // stuff here - } - - /** - * Phonebooks - */ - public function viewPhonebook( $id = null ) { - // stuff here - } - public function createPhonebook() { - // stuff here - } - public function editPhonebook( $id = null ) { - // stuff here - } - public function deletePhonebook( $id = null ) { - // stuff here - } -} diff --git a/app/plugins/contacts/forms.php b/app/plugins/contacts/forms.php deleted file mode 100644 index b826938..0000000 --- a/app/plugins/contacts/forms.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins\Notes; - -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Classes\Forms; - -class ContactsForms extends Forms { - /** - * Adds these functions to the form list. - */ - public function __construct() { - self::addHandler( 'createContact', __CLASS__, 'createContact' ); - self::addHandler( 'createPhonebook', __CLASS__, 'createPhonebook' ); - self::addHandler( 'editContact', __CLASS__, 'editContact' ); - self::addHandler( 'editPhonebook', __CLASS__, 'editPhonebook' ); - } - - public static function createContact() { - if ( ! Input::exists( 'submit' ) ) { - return false; - } - if ( ! Input::exists( 'first_name' ) && ! Input::exists( 'last_name' ) && ! Input::exists( 'nickname' ) ) { - Check::addUserError( 'You must include a first, last, or nick-name.' ); - return false; - } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function createPhonebook() { - if ( ! Input::exists( 'submit' ) ) { - return false; - } - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - if ( ! Input::exists( 'color' ) ) { - Check::addUserError( 'You must include a color.' ); - return false; - } - // if ( ! self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function editContact() { - if ( ! Input::exists( 'submit' ) ) { - return false; - } - if ( ! Input::exists( 'first_name' ) && ! Input::exists( 'last_name' ) && ! Input::exists( 'nickname' ) ) { - Check::addUserError( 'You must include a first, last, or nick-name.' ); - return false; - } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function editPhonebook() { - if ( ! Input::exists( 'submit' ) ) { - return false; - } - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - if ( ! Input::exists( 'color' ) ) { - Check::addUserError( 'You must include a color.' ); - return false; - } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } -} - -new ContactsForms; \ No newline at end of file diff --git a/app/plugins/contacts/models/contact.php b/app/plugins/contacts/models/contact.php deleted file mode 100644 index a52dc78..0000000 --- a/app/plugins/contacts/models/contact.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; - -class Contact extends DatabaseModel { - public $tableName = 'contacts'; - - public $databaseMatrix = [ - [ 'avatar', 'text', ''], - [ 'first_name', 'varchar', '128'], - [ 'middle_name', 'varchar', '128'], - [ 'last_name', 'varchar', '128'], - [ 'nickname', 'varchar', '128'], - [ 'company', 'varchar', '128'], - [ 'job_title', 'varchar', '128'], - [ 'email', 'varchar', '128'], - [ 'email_2', 'varchar', '128'], - [ 'phone', 'varchar', '128'], - [ 'phone_2', 'varchar', '128'], - [ 'address_1_primary', 'varchar', '128'], - [ 'address_1_secondary', 'varchar', '128'], - [ 'city', 'varchar', '128'], - [ 'state', 'varchar', '128'], - [ 'zipcode', 'varchar', '128'], - [ 'country', 'varchar', '128'], - [ 'address_2_primary', 'varchar', '128'], - [ 'address_2_secondary', 'varchar', '128'], - [ 'city_2', 'varchar', '128'], - [ 'state_2', 'varchar', '128'], - [ 'zipcode_2', 'varchar', '128'], - [ 'country_2', 'varchar', '128'], - [ 'notes', 'text', ''], - [ 'color', 'varchar', '48' ], - [ 'icon', 'varchar', '48' ], - [ 'createdAt', 'int', '11'], - [ 'createdBy', 'int', '11'], - [ 'phonebookID', 'int', '11'], - ]; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - } - - public function byUser( $limit = null ) { - $whereClause = [ 'createdBy', '=', App::$activeUser->ID ]; - if ( empty( $limit ) ) { - $phonebooks = self::$db->get( $this->tableName, $whereClause ); - } else { - $phonebooks = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$phonebooks->count() ) { - Debug::info( 'No Phonebooks found.' ); - return false; - } - return $this->filter( $phonebooks->results() ); - } - - public function byPhonebook( $phonebookID, $limit = null ) { - $whereClause = [ 'phonebookID', '=', $phonebookID ]; - if ( empty( $limit ) ) { - $phonebooks = self::$db->get( $this->tableName, $whereClause ); - } else { - $phonebooks = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$phonebooks->count() ) { - Debug::info( 'No Phonebooks found.' ); - return false; - } - return $this->filter( $phonebooks->results() ); - } -} diff --git a/app/plugins/contacts/models/phonebook.php b/app/plugins/contacts/models/phonebook.php deleted file mode 100644 index 287e4ce..0000000 --- a/app/plugins/contacts/models/phonebook.php +++ /dev/null @@ -1,165 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Filters; -use TheTempusProject\Bedrock\Classes\CustomException; - -class Phonebook extends DatabaseModel { - public $tableName = 'phonebooks'; - - public $databaseMatrix = [ - [ 'title', 'varchar', '128' ], - [ 'description', 'text', '' ], - [ 'color', 'varchar', '48' ], - [ 'icon', 'varchar', '48' ], - [ 'createdBy', 'int', '11' ], - [ 'createdAt', 'int', '11' ], - ]; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - } - - public function create( $title, $description = '', $color = 'default', $icon = '' ) { - if ( ! Check::dataTitle( $title ) ) { - Debug::info( 'Phonebooks: illegal title.' ); - return false; - } - $fields = [ - 'title' => $title, - 'description' => $description, - 'color' => $color, - 'icon' => $icon, - 'createdBy' => App::$activeUser->ID, - 'createdAt' => time(), - ]; - if ( ! self::$db->insert( $this->tableName, $fields ) ) { - new CustomException( 'phonebookCreate' ); - Debug::error( "Phonebooks: not created " . var_export($fields,true) ); - return false; - } - return self::$db->lastId(); - } - - public function update( $id, $title, $description = '', $color = 'default', $icon = '' ) { - if ( !Check::id( $id ) ) { - Debug::info( 'Phonebooks: illegal ID.' ); - return false; - } - if ( !Check::dataTitle( $title ) ) { - Debug::info( 'Phonebooks: illegal title.' ); - return false; - } - $fields = [ - 'title' => $title, - 'description' => $description, - 'color' => $color, - 'icon' => $icon, - ]; - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'phonebookUpdate' ); - Debug::error( "Phonebooks: $id not updated" ); - return false; - } - return true; - } - - public function byUser( $limit = null ) { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - if ( empty( $limit ) ) { - $phonebooks = self::$db->get( $this->tableName, $whereClause ); - } else { - $phonebooks = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$phonebooks->count() ) { - Debug::info( 'No Phonebooks found.' ); - return false; - } - return $this->filter( $phonebooks->results() ); - } - - public function getName( $id ) { - $phonebook = self::findById( $id ); - return $phonebook->title; - } - - public function simpleList( $param = '') { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $phonebooks = self::$db->get( $this->tableName, $whereClause ); - if ( !$phonebooks->count() ) { - Debug::warn( 'Could not find any Phonebooks' ); - return []; - } - - $phonebooks = $phonebooks->results(); - $out = [ 'None' => '0']; - foreach ( $phonebooks as &$phonebook ) { - $out[ $phonebook->title ] = $phonebook->ID; - } - return $out; - } - - public function simpleObjectByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $phonebooks = self::$db->get( $this->tableName, $whereClause ); - if ( !$phonebooks->count() ) { - Debug::warn( 'Could not find any Phonebooks' ); - return false; - } - - $phonebooks = $phonebooks->results(); - $out = []; - foreach ( $phonebooks as &$phonebook ) { - $obj = new \stdClass(); - $obj->title = $phonebook->title; - $obj->ID = $phonebook->ID; - $out[] = $obj; - } - return $out; - } - - public function getTree() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $phonebooks = self::$db->get( $this->tableName, $whereClause ); - if ( !$phonebooks->count() ) { - Debug::warn( 'Could not find any Phonebooks' ); - return []; - } - - $phonebooks = $phonebooks->results(); - $formattedPhonebooks = []; - foreach ($phonebooks as $phonebook) { - if ( !empty($phonebook->phonebookID) ) { - $phonebookID = $phonebook->phonebookID; - if ( ! isset( $formattedPhonebooks[ $phonebookID ])) { - $formattedPhonebooks[ $phonebookID ][ 'phonebooks' ] = []; - } - $formattedPhonebooks[ $phonebookID ][ 'phonebooks' ][] = $phonebook; - } else { - $phonebookID = $phonebook->ID; - $formattedPhonebooks[ $phonebookID ][ 'phonebook' ] = $phonebook; - } - } - return $formattedPhonebooks; - } - -} diff --git a/app/plugins/contacts/plugin.php b/app/plugins/contacts/plugin.php deleted file mode 100644 index 3735702..0000000 --- a/app/plugins/contacts/plugin.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins; - -use TheTempusProject\Classes\Plugin; -use TheTempusProject\Models\Contact; -use TheTempusProject\Models\Phonebook; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Template; - -class Contacts extends Plugin { - public $pluginName = 'TP Contacts'; - public $configName = 'contacts'; - public $pluginAuthor = 'JoeyK'; - public $pluginWebsite = 'https://TheTempusProject.com'; - public $modelVersion = '1.0'; - public $pluginVersion = '3.0'; - public $pluginDescription = 'A simple plugin which adds a site wide contacts system.'; - public $permissionMatrix = [ - 'useContacts' => [ - 'pretty' => 'Can use the contacts feature', - 'default' => false, - ], - ]; - public $main_links = [ - [ - 'text' => 'Contacts', - 'url' => '{ROOT_URL}contacts/index/', - 'filter' => 'loggedin', - ], - ]; - public $configMatrix = [ - 'enabled' => [ - 'type' => 'radio', - 'pretty' => 'Enable Contacts.', - 'default' => true, - ], - ]; - // public $contacts; - // public $phonebooks; - - public function __construct( $load = false ) { - // $this->contacts = new Contact; - // $this->phonebooks = new Phonebook; - parent::__construct( $load ); - } -} diff --git a/app/plugins/contacts/views/contacts/create.html b/app/plugins/contacts/views/contacts/create.html deleted file mode 100644 index 7a58de5..0000000 --- a/app/plugins/contacts/views/contacts/create.html +++ /dev/null @@ -1,162 +0,0 @@ -New Contact -
    - -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    - -
    -
    -
    -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/contacts/views/contacts/edit.html b/app/plugins/contacts/views/contacts/edit.html deleted file mode 100644 index f097d7a..0000000 --- a/app/plugins/contacts/views/contacts/edit.html +++ /dev/null @@ -1,162 +0,0 @@ -Edit Contact -
    - -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    - -
    -
    -
    -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/contacts/views/contacts/list.html b/app/plugins/contacts/views/contacts/list.html deleted file mode 100644 index 676b7cb..0000000 --- a/app/plugins/contacts/views/contacts/list.html +++ /dev/null @@ -1,40 +0,0 @@ -
    -
    - - - - - - - - - - - - - - - {LOOP} - - - - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    IDNicknameFirst NameLast NameEmailPhone
    {ID}{nickname}{first_name}{last_name}{email}{phone}
    - No Contacts -
    - Add Contact -
    -
    \ No newline at end of file diff --git a/app/plugins/contacts/views/contacts/view.html b/app/plugins/contacts/views/contacts/view.html deleted file mode 100644 index 5f99cdd..0000000 --- a/app/plugins/contacts/views/contacts/view.html +++ /dev/null @@ -1,87 +0,0 @@ -
    -
    -
    -
    -

    Contact

    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    First Name{first_name}
    Middle Name{middle_name}
    Last Name{last_name}
    Nickname{nickname}
    Company{company}
    Job Title{job_title}
    Email - {email}
    - {email_2} -
    Phone - {phone}
    - {phone_2} -
    Address 1 - {address_1_primary}
    - {address_1_secondary}
    - {city} {state} {country} {zipcode} -
    Address 2 - {address_2_primary}
    - {address_2_secondary}
    - {city_2} {state_2} {country_2} {zipcode_2} -
    Notes
    {notes}
    Created{DTC}{createdAt}{/DTC}
    -
    -
    -
    - -
    -
    -
    diff --git a/app/plugins/contacts/views/dashboard.html b/app/plugins/contacts/views/dashboard.html deleted file mode 100644 index 27ed755..0000000 --- a/app/plugins/contacts/views/dashboard.html +++ /dev/null @@ -1,3 +0,0 @@ -Contacts -{phonebookList} -{contactList} \ No newline at end of file diff --git a/app/plugins/contacts/views/phonebooks/create.html b/app/plugins/contacts/views/phonebooks/create.html deleted file mode 100644 index bd7e51e..0000000 --- a/app/plugins/contacts/views/phonebooks/create.html +++ /dev/null @@ -1,35 +0,0 @@ -Create Phonebook -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - {colorSelect} -
    -
    -
    - -
    - {iconSelect} -
    - -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/contacts/views/phonebooks/edit.html b/app/plugins/contacts/views/phonebooks/edit.html deleted file mode 100644 index 9b26b41..0000000 --- a/app/plugins/contacts/views/phonebooks/edit.html +++ /dev/null @@ -1,33 +0,0 @@ -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - {colorSelect} -
    -
    -
    - -
    - {iconSelect} -
    -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/contacts/views/phonebooks/list.html b/app/plugins/contacts/views/phonebooks/list.html deleted file mode 100644 index 98f3bfe..0000000 --- a/app/plugins/contacts/views/phonebooks/list.html +++ /dev/null @@ -1,33 +0,0 @@ -
    -
    - - - - - - - - - - - {LOOP} - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    TitleDescription
    {title}{description}
    - No Phonebooks -
    - New Phonebook -
    -
    - diff --git a/app/plugins/contacts/views/phonebooks/view.html b/app/plugins/contacts/views/phonebooks/view.html deleted file mode 100644 index 2ec1df4..0000000 --- a/app/plugins/contacts/views/phonebooks/view.html +++ /dev/null @@ -1,45 +0,0 @@ -
    -
    -
    -
    -

    Phonebook

    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    Title{title}
    Icon{icon}
    Color{color}
    Description
    {description}
    Created{DTC}{createdAt}{/DTC}
    -
    -
    -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/fileshare/controllers/fileshare.php b/app/plugins/fileshare/controllers/fileshare.php deleted file mode 100644 index fbdca45..0000000 --- a/app/plugins/fileshare/controllers/fileshare.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers; - -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Upload; -use TheTempusProject\Classes\Controller; -use TheTempusProject\Models\Upload as UploadModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Bedrock\Functions\Session; -use TheTempusProject\Hermes\Functions\Redirect; - -class Fileshare extends Controller { - protected static $uploads; - - public function __construct() { - parent::__construct(); - self::$uploads = new UploadModel; - self::$title = 'FileShare - {SITENAME}'; - self::$pageDescription = 'Your saved Files for the site.'; - } - - public function index() { - $uploads = self::$uploads->getByUser(); - Views::view( 'fileshare.list', $uploads ); - } - - public function delete( $id = null ) { - $upload = self::$uploads->findById( $id ); - if ( $upload == false ) { - Issues::add( 'error', 'Upload not found.' ); - return $this->index(); - } - if ( $upload->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this upload.' ); - return $this->index(); - } - $result = self::$uploads->delete( $id ); - if ( $result == true ) { - Issues::add( 'success', 'Upload deleted.' ); - } else { - Issues::add( 'notice', 'There was an problem deleting your upload.' ); - } - return $this->index(); - } - - public function edit( $id = null ) { - $upload = self::$uploads->findById( $id ); - if ( $upload == false ) { - Issues::add( 'error', 'Upload not found.' ); - return $this->index(); - } - - if ( ! Input::exists( 'submit' ) ) { - return Views::view( 'calendar.calendar.edit', $upload ); - } - - if ( ! Forms::check( 'editUpload' ) ) { - Issues::add( 'error', [ 'There was an error editing your upload.' => Check::userErrors() ] ); - return Views::view( 'fileshare.edit', $upload ); - } - - if ( Input::exists( 'file' ) ) { - $folder = UPLOAD_DIRECTORY . App::$activeUser->username . DIRECTORY_SEPARATOR; - if ( ! Upload::image( 'file', $folder ) ) { - Issues::add( 'error', [ 'There was an error with your upload.' => Check::systemErrors() ] ); - return Views::view( 'fileshare.edit', $upload ); - } else { - $route = str_replace( APP_ROOT_DIRECTORY, '', $folder ); - $location = $route . Upload::last(); - } - } else { - $location = ''; - } - - $result = self::$uploads->update( $id, Input::post('name'), $location ); - if ( ! $result ) { - Issues::add( 'error', [ 'There was an error updating your upload.' => Check::userErrors() ] ); - return Views::view( 'fileshare.edit', $upload ); - } - Session::flash( 'success', 'Your Upload has been updated.' ); - Redirect::to( 'fileshare/index/'); - } - - public function upload( $id = null ) { - if ( ! Input::exists() ) { - return Views::view( 'fileshare.create' ); - } - if ( ! Forms::check( 'newUpload' ) ) { - Issues::add( 'error', [ 'There was an error creating your upload.' => Check::userErrors() ] ); - return Views::view( 'fileshare.create' ); - } - $folder = UPLOAD_DIRECTORY . App::$activeUser->username . DIRECTORY_SEPARATOR; - if ( ! Upload::image( 'file', $folder ) ) { - Issues::add( 'error', [ 'There was an error with your upload.' => Check::systemErrors() ] ); - return Views::view( 'fileshare.create' ); - } else { - $route = str_replace( APP_ROOT_DIRECTORY, '', $folder ); - $location = $route . Upload::last(); - } - $upload = self::$uploads->create( Input::post('name'), $location ); - if ( ! $upload ) { - return Views::view( 'fileshare.create' ); - } - Session::flash( 'success', 'Your Upload has been saved.' ); - Redirect::to( 'fileshare/index/'); - } -} diff --git a/app/plugins/fileshare/forms.php b/app/plugins/fileshare/forms.php deleted file mode 100644 index 583591a..0000000 --- a/app/plugins/fileshare/forms.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins\Feedback; - -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Classes\Forms; - -class FileShareForms extends Forms { - /** - * Adds these functions to the form list. - */ - public function __construct() { - self::addHandler( 'newUpload', __CLASS__, 'newUpload' ); - self::addHandler( 'editUpload', __CLASS__, 'editUpload' ); - } - public static function newUpload() { - if ( ! Input::exists( 'name' ) ) { - Check::addUserError( 'You must provide a name.' ); - return false; - } - if ( ! Input::exists( 'file' ) ) { - Check::addUserError( 'You must provide a file.' ); - return false; - } - return true; - } - public static function editUpload() { - if ( ! Input::exists( 'name' ) ) { - Check::addUserError( 'You must provide a name.' ); - return false; - } - return true; - } -} - -new FileShareForms; diff --git a/app/plugins/fileshare/models/upload.php b/app/plugins/fileshare/models/upload.php deleted file mode 100644 index 42a61b1..0000000 --- a/app/plugins/fileshare/models/upload.php +++ /dev/null @@ -1,181 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Bedrock\Classes\CustomException; - -class Upload extends DatabaseModel { - public $tableName = 'uploads'; - public $databaseMatrix = [ - [ 'name', 'varchar', '256' ], - [ 'location', 'text', '64' ], - [ 'size', 'int', '20' ], - [ 'file_type', 'varchar', '64' ], - [ 'createdBy', 'int', '11' ], - [ 'createdAt', 'int', '11' ], - ]; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - } - - public function create( $name, $location ) { - $info = $this->getFileInfo( $location ); - $size = $info['size']; - $file_type = $info['file_type']; - $fields = [ - 'name' => $name, - 'location' => '/' . $location, - 'size' => $size, - 'file_type' => $file_type, - 'createdAt' => time(), - 'createdBy' => App::$activeUser->ID, - ]; - if ( ! self::$db->insert( $this->tableName, $fields ) ) { - Debug::info( 'Uploads::create - failed to insert to db' ); - return false; - } - return self::$db->lastId(); - } - - public function update( $id, $name, $location = '' ) { - $fields = [ - 'name' => $name, - ]; - if ( ! empty( $location ) ) { - $info = $this->getFileInfo( $location ); - $fields['location'] = $location; - $fields['size'] = $info['size']; - $fields['file_type'] = $info['file_type']; - } - if ( ! self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'UploadsUpdate' ); - Debug::error( "Uploads: $id not updated: $fields" ); - return false; - } - return true; - } - - public function simple() { - $uploads = self::$db->get( $this->tableName, '*' ); - if ( !$uploads->count() ) { - Debug::warn( 'Could not find any uploads' ); - return false; - } - - $uploads = $uploads->results(); - $out = []; - foreach ( $uploads as $upload ) { - $out[ $upload->name ] = $upload->location; - } - return $out; - } - - // public function processFileUpload() { - - // } - - public function getByUser( $limit = 0 ) { - $whereClause = [ - 'createdBy', '=', App::$activeUser->ID, - ]; - if ( empty( $limit ) ) { - $uploads = self::$db->get( $this->tableName, $whereClause ); - } else { - $uploads = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( ! $uploads->count() ) { - Debug::info( 'No Uploads found.' ); - return false; - } - return $this->filter( $uploads->results() ); - } - - public function delete( $idArray ) { - if ( !is_array( $idArray ) ) { - $idArray = [ $idArray ]; - } - - foreach ( $idArray as $id ) { - $upload = self::findById( $id ); - if ( $upload ) { - $fileLocation = APP_ROOT_DIRECTORY . ltrim( $upload->location, '/' ); - if (file_exists($fileLocation)) { - if (!unlink($fileLocation)) { - Debug::error("Failed to delete file: $fileLocation"); - return false; - } - } else { - Debug::warn("File does not exist: $fileLocation"); - } - } - } - return parent::delete( $idArray ); - } - - private function getFileInfo( $imagePath ) - { - $data = []; - $fileLocation = APP_ROOT_DIRECTORY . ltrim( $imagePath, '/' ); - if ( file_exists( $fileLocation ) ) { - $fileInfo = finfo_open(FILEINFO_MIME_TYPE); - $mimeType = finfo_file($fileInfo, $fileLocation); - finfo_close($fileInfo); - - $fileSize = filesize($fileLocation); - - $data['file_type'] = $mimeType; - $data['size'] = $fileSize; - $data['path'] = $fileLocation; - } else { - Debug::warn("File does not exist: $fileLocation"); - } - return $data; - } - - public function filter( $data, $params = [] ) { - foreach ( $data as $instance ) { - if ( !is_object( $instance ) ) { - $instance = $data; - $end = true; - } - if (isset($instance->size)) { - $instance->readableSize = $this->formatSize($instance->size); - } - $out[] = $instance; - if ( !empty( $end ) ) { - $out = $out[0]; - break; - } - } - return $out; - } - - public function formatSize($size) { - $units = ['B', 'KB', 'MB', 'GB', 'TB']; - $i = 0; - while ($size >= 1024 && $i < count($units) - 1) { - $size /= 1024; - $i++; - } - return round($size, 2) . ' ' . $units[$i]; - } -} diff --git a/app/plugins/fileshare/plugin.php b/app/plugins/fileshare/plugin.php deleted file mode 100644 index f5a8e92..0000000 --- a/app/plugins/fileshare/plugin.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins; - -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Classes\Plugin; -use TheTempusProject\Models\Upload; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Views; - -class Fileshare extends Plugin { - public $pluginName = 'TP FileShare'; - public $configName = 'fileshare'; - public $pluginAuthor = 'JoeyK'; - public $pluginWebsite = 'https://TheTempusProject.com'; - public $modelVersion = '1.0'; - public $pluginVersion = '3.0'; - public $pluginDescription = 'A simple plugin which adds a site wide file-sharing system.'; - public $permissionMatrix = [ - 'uploadFiles' => [ - 'pretty' => 'Can upload files', - 'default' => false, - ], - ]; - private static $loaded = false; - public function __construct( $load = false ) { - parent::__construct( $load ); - if ( $this->checkEnabled() && App::$isLoggedIn ) { - if ( ! self::$loaded ) { - App::$topNavRightDropdown .= '
  • FileShare
  • '; - self::$loaded = true; - } - } - } -} \ No newline at end of file diff --git a/app/plugins/fileshare/views/create.html b/app/plugins/fileshare/views/create.html deleted file mode 100644 index 67b5bc0..0000000 --- a/app/plugins/fileshare/views/create.html +++ /dev/null @@ -1,22 +0,0 @@ -File Upload -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/fileshare/views/edit.html b/app/plugins/fileshare/views/edit.html deleted file mode 100644 index 0ab1760..0000000 --- a/app/plugins/fileshare/views/edit.html +++ /dev/null @@ -1,22 +0,0 @@ -Edit File -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/fileshare/views/list.html b/app/plugins/fileshare/views/list.html deleted file mode 100644 index 4dd2424..0000000 --- a/app/plugins/fileshare/views/list.html +++ /dev/null @@ -1,24 +0,0 @@ -
    - {LOOP} -
    -
    - {name} -
    -

    {name}

    -

    {readableSize}

    -

    {file_type}

    -

    - edit - Delete -

    -
    -
    -
    - {/LOOP} - {ALT} -
    - No Uploads Found -
    - {/ALT} -
    -Upload File \ No newline at end of file diff --git a/app/plugins/initiativetracker/controllers/initiative.php b/app/plugins/initiativetracker/controllers/initiative.php deleted file mode 100644 index 6ad712d..0000000 --- a/app/plugins/initiativetracker/controllers/initiative.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers; - -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Classes\Controller; -use TheTempusProject\Models\Inithistory; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\TheTempusProject as App; - -class Initiative extends Controller { - protected static $initiativeHistory; - - public function __construct() { - self::$title = 'Initiative Tracker - {SITENAME}'; - self::$pageDescription = 'This is for tracking player and creature turns and initiatives.'; - self::$initiativeHistory = new Inithistory; - if ( ! App::$isLoggedIn ) { - Issues::add( 'info', 'If you register an account and log in, you can save your initiatives.' ); - Components::set( 'initiativeHistory', '' ); - } else { - $history = self::$initiativeHistory->userHistory(); - $historyView = Views::simpleView( 'initiativetracker.historyElement', $history ); - Components::set( 'initiativeHistory', $historyView ); - } - parent::__construct(); - } - - public function index() { - Views::view( 'initiativetracker.index' ); - } -} diff --git a/app/plugins/initiativetracker/css/initiative.css b/app/plugins/initiativetracker/css/initiative.css deleted file mode 100644 index a08bcf9..0000000 --- a/app/plugins/initiativetracker/css/initiative.css +++ /dev/null @@ -1,35 +0,0 @@ -.initiative-container { - margin-bottom: 50px; -} - -.character-form { - margin-bottom: 50px; -} - -.list-controls { - margin-bottom: 30px; -} - -.round-footer { - padding-right: 15px; - padding-bottom: 20px; - padding-left: 15px; -} - -.list-controls-center,.list-controls,.character-form { - display: flex; - justify-content: center; - align-items: center; -} - -.list-controls-last { - display: flex; - justify-content: right; - align-items: right; -} - -.list-controls-first { - display: flex; - justify-content: left; - align-items: left; -} \ No newline at end of file diff --git a/app/plugins/initiativetracker/js/initiative.js b/app/plugins/initiativetracker/js/initiative.js deleted file mode 100644 index eeaaff8..0000000 --- a/app/plugins/initiativetracker/js/initiative.js +++ /dev/null @@ -1,414 +0,0 @@ -$(document).ready(function() { - // Top Checkbox Controls - $('input[type="checkbox"]').change(function() { - var name = $(this).attr('name'); - if ( 'trackAC' == name ) { - var eles = document.getElementsByClassName('ac-tracker'); - } - if ( 'trackHP' == name ) { - var eles = document.getElementsByClassName('hp-tracker'); - } - if ( 'trackRounds' == name ) { - var eles = document.getElementsByClassName('rounds-tracker'); - } - if ($(this).is(':checked')) { - Array.prototype.forEach.call(eles, function(ele) { - ele.style.display = ''; - }); - } else { - Array.prototype.forEach.call(eles, function(ele) { - ele.style.display = 'none'; - }); - } - }); - - $(document).on('click', '.character-remove', function() { - var characterId = $(this).closest('tr').data('character-id'); - - var allTrsWithCharacterId = document.querySelectorAll(`tr[data-round-character-id="${characterId}"]`); - allTrsWithCharacterId.forEach(function(tr) { - tr.remove(); - }); - var allTrsWithCharacterId = document.querySelectorAll(`tr[data-character-id="${characterId}"]`); - allTrsWithCharacterId.forEach(function(tr) { - tr.remove(); - }); - - findByIdAndRemove( characterId, characterInitiativeList ); - }); - - $(document).on('click', '.hp-minus', function() { - var characterId = $(this).closest('tr').data('character-id'); - var dataValue = parseInt($(this).data('value'), 10); - var allTrsWithCharacterId = document.querySelectorAll(`tr[data-character-id="${characterId}"]`); - - allTrsWithCharacterId.forEach(function(tr) { - var $input = $(tr).find('input[name="hp"]'); - var newValue = parseInt($input.val(), 10) - dataValue; - $input.val(newValue); - }); - - var hpIndex = findById( characterId ); - hpIndex.hp = parseInt(hpIndex.hp) - dataValue; - }); - - $(document).on('click', '.hp-plus', function() { - var characterId = $(this).closest('tr').data('character-id'); - var dataValue = parseInt($(this).data('value'), 10); - var allTrsWithCharacterId = document.querySelectorAll(`tr[data-character-id="${characterId}"]`); - - allTrsWithCharacterId.forEach(function(tr) { - var $input = $(tr).find('input[name="hp"]'); - var newValue = parseInt($input.val(), 10) + dataValue; - $input.val(newValue); - }); - - var hpIndex = findById( characterId ); - hpIndex.hp = parseInt(hpIndex.hp) + dataValue; - }); -}); - -let currentCharacter; -let roundCount = 0; -let roundHistory = []; -let characterInitiativeList = []; - -function findById(id) { - return characterInitiativeList.find(item => item.id === id); -} -function findByIdAndRemove(id, array) { - const index = array.findIndex(item => item.id === id); - if (index !== -1) { - array.splice(index, 1); - } -} - -const resetCharBtn = document.getElementById('character-reset'); -const resetCharacter = async function (event) { - formReset(); -} - -const resetListBtn = document.getElementById('list-reset'); -const resetListEvent = async function (event) { - resetList(); -} - -const nextCharBtn = document.getElementById('list-next'); -const nextCharacter = async function (event) { - cycleCharacter(); -} -function cycleCharacter() { - if ( !currentCharacter ) { - currentCharacter = 0; - } - if ( currentCharacter == characterInitiativeList.length ) { - currentCharacter = 0; - roundCount++; - addRoundHistory(); - updateRoundCount(); - } - if ( !characterInitiativeList[currentCharacter] ) { - currentCharacter = 0; - } - - var allTrs = document.querySelectorAll(`tr`); - allTrs.forEach(function(tr) { - tr.classList.remove("success"); - }); - - var allTrsWithCharacterId = document.querySelectorAll(`tr[data-character-id="${characterInitiativeList[currentCharacter].id}"]`); - - allTrsWithCharacterId.forEach(function(tr) { - tr.classList.add("success"); - }); - currentCharacter++; -} - -const clearListBtn = document.getElementById('list-clear'); -const clearListEvent = async function (event) { - clearList(); - hideList(); -} - -const sortCharBtn = document.getElementById('character-sort'); -const sortCharacters = async function (event) { - event.preventDefault(); - sortthem(); -} -function sortthem() { - var fieldName = document.getElementById('sortBy').value; - - clearListHTML(); - resetList(); - - var newList = sortCharacterListByField( fieldName, characterInitiativeList ); - - for (let i = 0; i < newList.length; i++) { - addCharacterRow( newList[i] ); - } -} -function sortCharacterListByField( fieldName, list ) { - if ( 'id' == fieldName ) { - return list; - } - - let sortedList = [...list]; - sortedList.sort( ( a, b ) => { - let fieldA = a[fieldName]; - let fieldB = b[fieldName]; - if ( 'type' == fieldName || 'name' == fieldName ) { - return fieldA.localeCompare(fieldB); - } - if (fieldA > fieldB) { - return -1; - } - if (fieldA < fieldB) { - return 1; - } - return 0; - }); - return sortedList; -} - -const addCharBtn = document.getElementById('character-add'); -const addCharacter = function (event) { - createCharacterFromForm(); -} -function createCharacterFromForm() { - showList(); - var id = Date.now().toString(36) + Math.random().toString(36).substring(2);; - var name = document.getElementById('name').value; - if ( !name ) { - name = '4816'; - } - var initiative = document.getElementById('initiative').value; - if ( !initiative ) { - initiative = getRandomInt( 1, 21 ); - } - initiative = parseInt( initiative ); - var ac = document.getElementById('ac').value; - if ( !ac ) { - ac = 0; - } - ac = parseInt( ac ); - var hp = document.getElementById('hp').value; - if ( !hp ) { - hp = 0; - } - hp = parseInt( hp ); - var characterType = document.querySelector('input[name="characterType"]:checked').value; - var character = { - id: id, - name: name, - initiative: initiative, - ac: ac, - hp: hp, - type: characterType, - }; - characterInitiativeList.push( character ); - - // re-order the list by initiative to keep the next character working properly - characterInitiativeList = sortCharacterListByField( 'initiative', characterInitiativeList ); - - addCharacterRow( character ); - addRoundRow( character ); -} - -const d20Btn = document.getElementById('d20-roll'); -const rollD20 = async function (event) { - event.preventDefault(); - var resultDiv = document.getElementById('initiative'); - resultDiv.value = getRandomInt( 1, 21 ); -} - -const resetRoundsBtn = document.getElementById('rounds-reset'); -const resetRoundsEvent = async function (event) { - resetRoundCount(); -} - -const clearRoundsBtn = document.getElementById('rounds-clear'); -const clearRoundsEvent = async function (event) { - clearRounds(); -} - -window.addEventListener('DOMContentLoaded', (event) => { - d20Btn.addEventListener('click', rollD20); - addCharBtn.addEventListener('click', addCharacter); - resetCharBtn.addEventListener('click', resetCharacter); - resetListBtn.addEventListener('click', resetListEvent); - clearListBtn.addEventListener('click', clearListEvent); - nextCharBtn.addEventListener('click', nextCharacter); - resetRoundsBtn.addEventListener('click', resetRoundsEvent); - clearRoundsBtn.addEventListener('click', clearRoundsEvent); - sortCharBtn.addEventListener('click', sortCharacters); - updateRoundCount(); -}); - -function formReset() { - document.getElementById('name').value = null; - document.getElementById('initiative').value = null; - document.getElementById('ac').value = null; - document.getElementById('hp').value = null; -} - -function showList() { - var tbody = document.getElementById('character-container'); - tbody.style.display = ''; -} - -function addCharacterRow( character ) { - var characterList = document.getElementById('character-list'); - var pcList = document.getElementById('character-list-pc'); - var npcList = document.getElementById('character-list-npc'); - var row = document.createElement('tr'); - row.setAttribute('data-character-id', character.id); - - var hpStyle = ''; - var acStyle = ''; - - var checkbox = document.getElementById('trackHP'); - if ( !checkbox.checked ) { - var hpStyle = 'style="display: none;"'; - } - - var checkbox = document.getElementById('trackAC'); - if ( !checkbox.checked ) { - var acStyle = 'style="display: none;"'; - } - - row.innerHTML = ` - ${character.name} - ${character.initiative} - ${character.ac} - -
    -
    -
    - - - -
    - -
    - - - -
    -
    -
    - - ${character.type} - - `; - - // Append the new row to the table body - characterList.appendChild(row); - - if ( 'pc' == character.type ) { - var pc_row = row.cloneNode(true); - pcList.appendChild(pc_row); - } - - if ( 'npc' == character.type ) { - var npc_row = row.cloneNode(true); - npcList.appendChild(npc_row); - } -} - -function hideList() { - var tbody = document.getElementById('character-container'); - tbody.style.display = 'none'; -} - -function clearList() { - characterInitiativeList = []; - clearListHTML(); -} - -function clearListHTML() { - var tbody = document.getElementById('character-list'); - tbody.innerHTML = ''; - var tbody = document.getElementById('character-list-pc'); - tbody.innerHTML = ''; - var tbody = document.getElementById('character-list-npc'); - tbody.innerHTML = ''; -} - -function resetList() { - currentCharacter = 0; - var allTrsWithCharacterId = document.querySelectorAll(`tr`); - allTrsWithCharacterId.forEach(function(tr) { - tr.classList.remove("success"); - }); -} - -function clearRounds() { - var headers = document.getElementById('rounds-history-header-row'); - var thElements = headers.getElementsByTagName('th'); - - // Loop through the th elements in reverse order to safely remove them without affecting the iteration - for (var i = thElements.length - 1; i > 0; i--) { - thElements[i].parentNode.removeChild(thElements[i]); - } - - var history = document.getElementById('rounds-history'); - var trElements = history.getElementsByTagName('tr'); - - for (var i = 0; i < trElements.length; i++) { - - var elements = trElements[i].getElementsByTagName('td'); - for (var x = elements.length - 1; x > 0; x--) { - elements[x].parentNode.removeChild(elements[x]); - } - - } - roundCount = 0; - updateRoundCount(); -} - -function clearCharacters() { - var history = document.getElementById('rounds-history'); - var trElements = history.getElementsByTagName('tr'); - - for (var i = 0; i < trElements.length; i++) { - trElements[i].remove(); - } -} - -function resetRoundCount() { - roundCount = 0; - updateRoundCount(); -} - -function updateRoundCount() { - var round = document.getElementById('round-count'); - round.innerText = roundCount; -} - -function addRoundRow( character ) { - var characterList = document.getElementById('rounds-history'); - var row = document.createElement('tr'); - - row.setAttribute('data-round-character-id', character.id); - row.innerHTML = `${character.name}`; - characterList.appendChild(row); -} - -function addRoundHistory() { - var headers = document.getElementById('rounds-history-header'); - var newHeader = document.createElement('th'); - newHeader.innerText = "Round " + roundCount; - newHeader.classList.add("text-center"); - headers.after( newHeader ); - - for (let i = 0; i < characterInitiativeList.length; i++) { - var char = characterInitiativeList[i]; - var newCol = document.createElement('td'); - newCol.innerText = char.hp; - newCol.classList.add("text-center"); - - var allTrsWithCharacterId = document.querySelector(`tr[data-round-character-id="${char.id}"]`); - var indexd = allTrsWithCharacterId.getElementsByClassName('char-name'); - indexd[0].after( newCol ); - } -} diff --git a/app/plugins/initiativetracker/models/inithistory.php b/app/plugins/initiativetracker/models/inithistory.php deleted file mode 100644 index 76ae078..0000000 --- a/app/plugins/initiativetracker/models/inithistory.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\Plugins\Feedback as Plugin; -use TheTempusProject\TheTempusProject as App; - -class Inithistory extends DatabaseModel { - public $tableName = 'initiative_history'; - public $databaseMatrix = [ - [ 'name', 'varchar', '128' ], - [ 'time', 'int', '10' ], - [ 'email', 'varchar', '128' ], - [ 'ip', 'varchar', '64' ], - [ 'feedback', 'text', '' ], - ]; - public $plugin; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - $this->plugin = new Plugin; - } - - /** - * Saves a feedback form to the db. - * - * @param string $name -the name on the form - * @param string $email -the email provided - * @param string $feedback -contents of the feedback form. - * @return bool - */ - public function create( $name, $email, $feedback ) { - if ( !$this->plugin->checkEnabled() ) { - Debug::info( 'Feedback is disabled in the config.' ); - return false; - } - $fields = [ - 'name' => $name, - 'email' => $email, - 'feedback' => $feedback, - 'time' => time(), - 'ip' => $_SERVER['REMOTE_ADDR'], - ]; - if ( !self::$db->insert( $this->tableName, $fields ) ) { - Debug::info( 'Feedback::create - failed to insert to db' ); - return false; - } - return self::$db->lastId(); - } - - /** - * Function to clear feedback from the DB. - * - * @todo is there a way i could check for success here I'm pretty sure this is just a bad idea? - * @return bool - */ - public function clear() { - if ( empty( self::$log ) ) { - self::$log = new Log; - } - self::$db->delete( $this->tableName, ['ID', '>=', '0'] ); - self::$log->admin( 'Cleared Feedback' ); - Debug::info( 'Feedback Cleared' ); - return true; - } - - public function userHistory( $limit = 0 ) { - $whereClause = [ - 'userID', '=', App::$activeUser->ID, - 'AND', - 'deletedAt', '=', '0', - 'AND', - 'expiresAt', '<', time(), - ]; - if ( empty( $limit ) ) { - $notifications = self::$db->get( $this->tableName, $whereClause ); - } else { - $notifications = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$notifications->count() ) { - Debug::info( 'No Notifications found.' ); - return false; - } - return $this->filter( $notifications->results() ); - } -} diff --git a/app/plugins/initiativetracker/plugin.php b/app/plugins/initiativetracker/plugin.php deleted file mode 100644 index 2c5de99..0000000 --- a/app/plugins/initiativetracker/plugin.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins; - -use TheTempusProject\Classes\Plugin; - -class Initiativetracker extends Plugin { - public $pluginName = 'TP InitiativeTracker'; - public $pluginAuthor = 'JoeyK'; - public $pluginWebsite = 'https://TheTempusProject.com'; - public $modelVersion = '1.0'; - public $pluginVersion = '3.0'; - public $pluginDescription = 'A simple plugin which adds a simple initiative tracker.'; - public $configName = 'initiativeTracker'; - public $configMatrix = [ - 'enabled' => [ - 'type' => 'radio', - 'pretty' => 'Enable tracker usage.', - 'default' => true, - ], - ]; - public $permissionMatrix = [ - 'useInitiativeTracker' => [ - 'pretty' => 'Can use the tracker', - 'default' => true, - ], - ]; - public $main_links = [ - [ - 'text' => 'Initiative', - 'url' => '{ROOT_URL}initiative/index', - ], - ]; -} - -// need to add a way to save the initiative history ( both personal, and for the table ) -// need a way to save characters for the autofill -// need to add a "clear" button for initiative roller -// if you have tables, and are a DM, your group can access the initiative history \ No newline at end of file diff --git a/app/plugins/initiativetracker/views/historyElement.html b/app/plugins/initiativetracker/views/historyElement.html deleted file mode 100644 index e69de29..0000000 diff --git a/app/plugins/initiativetracker/views/index.html b/app/plugins/initiativetracker/views/index.html deleted file mode 100644 index ca4dac3..0000000 --- a/app/plugins/initiativetracker/views/index.html +++ /dev/null @@ -1,210 +0,0 @@ - - - -
    - -
    -

    Initiative Tracker

    -
    - - -
    -
    - -
    -
    - -
    -
    - -
    -
    - - -
    -
    - - -
    -
    - -
    -
    - -
    - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - - - -
    \ No newline at end of file diff --git a/app/plugins/notes/controllers/notes.php b/app/plugins/notes/controllers/notes.php deleted file mode 100644 index 055b5bd..0000000 --- a/app/plugins/notes/controllers/notes.php +++ /dev/null @@ -1,436 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers; - -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Houdini\Classes\Forms as FormBuilder; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Classes\Config; - - - -use TheTempusProject\Classes\Controller; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Bedrock\Functions\Session; -use TheTempusProject\Hermes\Functions\Redirect; -use TheTempusProject\Models\Notes as Note; -use TheTempusProject\Models\Notebooks; -use TheTempusProject\Houdini\Classes\Template; -use TheTempusProject\Houdini\Classes\Navigation; - -class Notes extends Controller { - protected static $notes; - protected static $notebooks; - protected static $defaultView; - - public function __construct() { - parent::__construct(); - if ( !App::$isLoggedIn ) { - Session::flash( 'notice', 'You must be logged in to use this feature.' ); - return Redirect::home(); - } - self::$notes = new Note; - self::$notebooks = new Notebooks; - self::$title = 'Notes - {SITENAME}'; - self::$pageDescription = 'On this page you can create and manage tasks and lists.'; - self::$defaultView = 'byNotebook'; - Components::set( 'notebookID', '' ); - Components::set( 'notebookName', 'All' ); - Components::set( 'notebookName', 'default' ); - Template::setTemplate( 'notes' ); - } - - public function index() { - $this->setupMenus(); - - $notebooks = Views::simpleView( 'notes.notebooks.list', self::$notebooks->byUser() ); - Components::set( 'notebookList', $notebooks ); - - $notes = Views::simpleView( 'notes.notes.list', self::$notes->byUser( 20 ) ); - Components::set( 'noteList', $notes ); - - Views::view( 'notes.dashboard' ); - } - - /** - * Notes - */ - public function notes( $id = null ) { - self::$defaultView = __FUNCTION__; - Components::set( 'currentView', self::$defaultView ); - - $this->setupMenus( 0, $id ); - - Navigation::setCrumbComponent( 'NotebookBreadCrumbs', 'notes/byNotebook' ); - - $notes = self::$notes->findByNotebook( $id ); - Views::view( 'notes.notes.list', $notes ); - } - public function createNote( $id = null ) { - $this->setupMenus( 0, $id ); - $select = FormBuilder::getSelectHtml( - 'notebookID', - self::$notebooks->simpleList(true), - $id, - ); - Components::set( 'notebookSelect', $select ); - if ( !Input::exists() ) { - return Views::view( 'notes.notes.create' ); - } - if ( !Forms::check( 'createNote' ) ) { - Issues::add( 'error', [ 'There was an error with your form.' => Check::userErrors() ] ); - return Views::view( 'notes.notes.create' ); - } - if ( !self::$notes->create( Input::post( 'title' ), Input::post( 'note' ), Input::post( 'color' ), Input::post( 'notebookID' ) ) ) { - Issues::add( 'error', [ 'There was an error with your note.' => Check::userErrors() ] ); - return Views::view( 'notes.notes.create' ); - } - Session::flash( 'success', 'Your note has been created.' ); - if ( Input::exists( 'notebookID' ) ) { - Redirect::to( 'notes/byNotebook/' . Input::post( 'notebookID' ) ); - } else { - Redirect::to( 'notes/index' ); - } - } - public function editNote( $id = null ) { - $note = self::$notes->findById( $id ); - if ( $note == false ) { - Issues::add( 'error', 'Note not found.' ); - return $this->index(); - } - if ( $note->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this note.' ); - return $this->index(); - } - - $this->setupMenus( $id ); - $select = FormBuilder::getSelectHtml( - 'notebookID', - self::$notebooks->simpleList(true), - $note->notebookID, - ); - Components::set( 'notebookSelect', $select ); - Components::set( 'color', $note->color ); - - if ( !Input::exists( 'submit' ) ) { - return Views::view( 'notes.notes.edit', $note ); - } - if ( !Forms::check( 'editNote' ) ) { - Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] ); - return Views::view( 'notes.notes.edit', $note ); - } - if ( self::$notes->update( $id, Input::post( 'title' ), Input::post( 'note' ), Input::post( 'color' ), Input::post( 'notebookID' ) ) ) { - Session::flash( 'success', 'Note updated' ); - } else { - return Views::view( 'notes.notes.edit', self::$notes->findById( $data ) ); - } - if ( !empty( $note->notebookID ) ) { - Redirect::to( 'notes/byNotebook/' . $note->notebookID ); - } else { - Redirect::to( 'notes/index' ); - } - } - public function deleteNote( $id = null ) { - $note = self::$notes->findById( $id ); - if ( $note == false ) { - Issues::add( 'error', 'Note not found.' ); - return $this->index(); - } - if ( $note->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this note.' ); - return $this->index(); - } - $result = self::$notes->delete( $id ); - if ( !$result ) { - Session::flash( 'error', 'There was an error deleting the note(s)' ); - } else { - Session::flash( 'success', 'Note deleted' ); - } - if ( !empty( $note->notebookID ) ) { - Redirect::to( 'notes/byNotebook/' . $note->notebookID ); - } else { - Redirect::to( 'notes/index' ); - } - } - - /** - * Notebooks - */ - public function notebook( $id = null ) { - self::$defaultView = __FUNCTION__; - Components::set( 'currentView', self::$defaultView ); - $notebook = self::$notebooks->findById( $id ); - if ( $notebook == false ) { - Issues::add( 'error', 'Notebook not found.' ); - return $this->index(); - } - Components::set( 'notebookID', $id ); - - $notes = self::$notes->findByNotebook( $notebook->ID ); - Components::set( 'notebookName', $notebook->title ); - Components::set( 'notebookIcon', $notebook->icon ); - Components::set( 'notebookColor', $notebook->color ); - Views::view( 'notes.notes.list', $notes ); - } - public function createNotebook($id = null) { - $this->setupMenus( 0, $id ); - $select = FormBuilder::getSelectHtml( - 'notebookID', - self::$notebooks->simpleList(true), - $id, - ); - Components::set( 'notebookSelect', $select ); - if ( !Input::exists() ) { - return Views::view( 'notes.notebooks.create' ); - } - if ( !Forms::check( 'createNotebook' ) ) { - Issues::add( 'error', [ 'There was an error creating your notebook.' => Check::userErrors() ] ); - return Views::view( 'notes.notebooks.create' ); - } - if ( ! input::exists('notebookID') ) { - $notebookID = 0; - } else { - $notebookID = Input::post( 'notebookID' ); - } - if ( !self::$notebooks->create( Input::post( 'title' ), Input::post( 'description' ), Input::post( 'color' ), $notebookID, Input::post( 'icon' ) ) ) { - Issues::add( 'error', [ 'There was an error creating your notebook.' => Check::userErrors() ] ); - return Views::view( 'notes.notebooks.create' ); - } - Session::flash( 'success', 'Your notebook has been created.' ); - Redirect::to( 'notes/index' ); - } - public function editNotebook( $id = null ) { - $notebook = self::$notebooks->findById( $id ); - $this->setupMenus( 0, $id ); - if ( $notebook == false ) { - Issues::add( 'error', 'Notebook not found.' ); - return Views::view( 'notes.notebooks.list', self::$notebooks->byUser() ); - - } - $select = FormBuilder::getSelectHtml( - 'notebookID', - self::$notebooks->simpleList(true), - $notebook->notebookID, - ); - Components::set( 'notebookSelect', $select ); - Components::set( 'color', $notebook->color ); - - if ( !Input::exists() ) { - return Views::view( 'notes.notebooks.edit', $notebook ); - } - if ( !Forms::check( 'editNotebook' ) ) { - Issues::add( 'error', [ 'There was an error with your notebook.' => Check::userErrors() ] ); - return Views::view( 'notes.notebooks.edit', $notebook ); - } - if ( ! Input::exists('notebookID') || $id == Input::post( 'notebookID' ) ) { - $notebookID = 0; - } else { - $notebookID = Input::post( 'notebookID' ); - } - - if ( !self::$notebooks->update( $id, Input::post( 'title' ), Input::post( 'description' ), Input::post( 'color' ), $notebookID, Input::post( 'icon' ) )) { - Issues::add( 'error', [ 'There was an error with your notebook.' => Check::userErrors() ] ); - return Views::view( 'notes.notebooks.edit', $notebook ); - } - Session::flash( 'success', 'Your Notebook has been saved.' ); - Redirect::to( 'notes/byNotebook/' . $id ); - } - public function deleteNotebook( $id = null ) { - $notebook = self::$notebooks->findById( $id ); - if ( $notebook == false ) { - Issues::add( 'error', 'Notebook not found.' ); - return $this->index(); - } - if ( $notebook->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this calendar.' ); - return $this->index(); - } - $result = self::$notebooks->delete( $id ); - if ( !$result ) { - Issues::add( 'error', 'There was an error deleting the notebook(s)' ); - } else { - Issues::add( 'success', 'Notebook deleted' ); - } - return $this->index(); - } - - /** - * Views - */ - public function byNotebook( $id = null ) { - self::$defaultView = __FUNCTION__; - Components::set( 'currentView', self::$defaultView ); - - $this->setupMenus( 0, $id ); - - Navigation::setCrumbComponent( 'NotebookBreadCrumbs', 'notes/byNotebook' ); - - $notes = self::$notes->findByNotebook( $id ); - Views::view( 'notes.notes.list', $notes ); - } - public function byNote( $id = null ) { - self::$defaultView = __FUNCTION__; - Components::set( 'currentView', self::$defaultView ); - $note = self::$notes->findById( $id ); - if ( $note == false ) { - Issues::add( 'error', 'Note not found.' ); - return $this->index(); - } - if ( $note->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this note.' ); - return $this->index(); - } - - $this->setupMenus( $id ); - $select = FormBuilder::getSelectHtml( - 'notebookID', - self::$notebooks->simpleList(true), - $note->notebookID, - ); - Components::set( 'notebookSelect', $select ); - Components::set( 'noteID', $note->ID ); - Components::set( 'color', $note->color ); - - if ( !Input::exists( 'submit' ) ) { - return Views::view( 'notes.notes.edit', $note ); - } - if ( !Forms::check( 'editNoteSimple' ) ) { - Issues::add( 'error', [ 'There was an error with your form.' => Check::userErrors() ] ); - return Views::view( 'notes.notes.edit', $note ); - } - if ( self::$notes->update( $id, Input::post( 'title' ), Input::post( 'note' ), Input::post( 'color' ), Input::post( 'notebookID' ) ) ) { - Issues::add( 'success', 'Note updated' ); - } else { - Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] ); - } - - return Views::view( 'notes.notes.edit', self::$notes->findById( $id ) ); - } - public function duplicateNote( $id = null ) { - $note = self::$notes->findById( $id ); - if ( $note == false ) { - Issues::add( 'error', 'Note not found.' ); - return $this->index(); - } - if ( $note->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this note.' ); - return $this->index(); - } - if ( ! self::$notes->duplicate( $id ) ) { - Session::flash( 'error', [ 'There was an error duplicating your note.'] ); - } else { - Session::flash( 'success', 'Your Note has been duplicated.' ); - } - if ( !empty( $note->notebookID ) ) { - Redirect::to( 'notes/byNotebook/' . $note->notebookID ); - } else { - Redirect::to( 'notes/index' ); - } - } - public function autoUpdate( $id = null ) { - Template::setTemplate( 'api' ); - $note = self::$notes->findById( $id ); - if ( $note == false ) { - return Views::view( 'api.response', ['response' => json_encode( [ 'error' => 'Note not found.' ], true )]); - } - if ( $note->createdBy != App::$activeUser->ID ) { - return Views::view( 'api.response', ['response' => json_encode( [ 'error' => 'Note not found.' ], true )]); - } - if ( !Forms::check( 'autoUpdateNote' ) ) { - return Views::view( 'api.response', ['response' => json_encode( [ 'error' => 'Error with your form.' ], true )]); - } - if ( ! self::$notes->update( $id, Input::post( 'title' ), Input::post( 'note' ), Input::post( 'color' ), Input::post( 'notebookID' ) ) ) { - return Views::view( 'api.response', ['response' => json_encode( [ 'error' => 'Error updating your note.' ], true )]); - } - return Views::view( 'api.response', ['response' => json_encode( [ 'data' => 'Note Updated.' ], true )]); - } - private function setupMenus( $note_id = 0, $notebook_id = 0 ) { - if ( ! empty( $note_id ) ) { - $note = self::$notes->findById( $note_id ); - } - - if ( ! empty( $note ) ) { - $notebook_id = $note->notebookID; - } - - $tree = self::$notebooks->getTree(); - $trunk = []; - - // Get the menu - foreach( $tree as $id => $notebook ) { - if ( ! isset( $notebook['notebook'] ) ) { - continue; - } - Components::set( 'notebookID', $notebook['notebook']->ID ); - Components::set( 'notebookName', $notebook['notebook']->title ); - Components::set( 'notebookIcon', $notebook['notebook']->icon ); - Components::set( 'notebookColor', $notebook['notebook']->color ); - if ( !empty( $notebook['notebooks'] ) ) { - $menuItem = Views::simpleView( 'notes.nav.menuItemList', $notebook['notebooks'] ); - } else { - $menuItem = Views::simpleView( 'notes.nav.menuItem', $notebook['notebook'] ); - } - - $obj = new \stdClass(); - $obj->menuItem = $menuItem; - $obj->menuItem = $menuItem; - $trunk[] = $obj; - } - - $notebook = self::$notebooks->findById( $notebook_id ); - if ( $notebook == false ) { - $notebook_id = ''; - $notebook_title = 'All'; - $notebookIcon = ''; - $notebookColor = 'none'; - } else { - $notebook_id = $notebook->ID; - $notebook_title = $notebook->title; - $notebookIcon = $notebook->icon; - $notebookColor = $notebook->color; - } - Components::set( 'notebookID', $notebook_id ); - Components::set( 'notebookName', $notebook_title ); - Components::set( 'notebookIcon', $notebookIcon ); - Components::set( 'notebookColor', $notebookColor ); - - // Notebook Sidebar - $notebookSidebar = Views::simpleView('notes.nav.notebookSidebar', $trunk ); - $notebookSidebarView = Navigation::activePageSelect( $notebookSidebar, '/notes/byNotebook/' . $notebook_id, false, true ); - Components::set( 'notebookSidebar', $notebookSidebarView ); - - // Notes Sidebar - $noteSidebar = Views::simpleView('notes.nav.noteSidebar', self::$notes->simpleObjectByNotebook( $notebook_id ) ); - $noteSidebarView = Navigation::activePageSelect( $noteSidebar, '/notes/byNote/' . $note_id, false, true ); - Components::set( 'notesSidebar', $noteSidebarView ); - - // Page Crumbs - Navigation::setCrumbComponent( 'NotebookBreadCrumbs', 'notes/byNotebook' ); - - // Top Tabs - $notesTabs = Views::simpleView('notes.nav.topTabs'); - $tabsView = Navigation::activePageSelect( $notesTabs, Input::get( 'url' ), false, true ); - - // Notebook Dropdown - $notebookDropdown = Views::simpleView('notes.nav.notebookDropdown', self::$notebooks->simpleObjectByUser() ); - $notebookDropdownView = Navigation::activePageSelect( $notebookDropdown, $notebook_id, false, true ); - Components::set( 'notebookDropdown', $notebookDropdownView ); - - // Re- Parse the top tabs - Components::set( 'NotesNav', Template::parse( $tabsView ) ); - } -} \ No newline at end of file diff --git a/app/plugins/notes/css/notes.css b/app/plugins/notes/css/notes.css deleted file mode 100644 index aa488f8..0000000 --- a/app/plugins/notes/css/notes.css +++ /dev/null @@ -1,231 +0,0 @@ - -/* Custom styles for your specific layout */ - -.content-area { - margin-left: 400px; /* Adjust for the width of left sidebar */ - padding: 20px; /* Adjust as per your design */ - padding-bottom: 50px; -} - -.float-bottom { - position: absolute; - bottom: 0; - width: 100%; - background-color: #f8f9fa; /* Background color for visibility */ - padding: 10px 0; /* Padding for aesthetic spacing */ - text-align: center; /* Centering the content */ -} - -.full-width-footer { - width: 100%; - background-color: #333; - color: #fff; - padding: 20px 0; - text-align: center; - position: fixed; - bottom: 0; - left: 0; -} - -.side-nav { - width: 200px; - bottom: 50px; - height: 100%; /* Adjust based on your layout, could be 100vh or another value */ -} - -.notes-sidebar .nav li a { - padding: 10px 10px; /* Provides padding to make links easier to click */ -} -.notebook-sidebar .nav li a { - /* padding: 10px 10px; /* Provides padding to make links easier to click */ -} - -.note { - padding-left: 0px !important; - padding-right: 0px !important; -} - -#notebook-sidebar ul { - /* background-color: #000; */ - /* background-color: #898989; */ - background-color: #323232; -} - -.navbar-inverse .navbar-nav li a.label.label-none { - --bg-color: #222; -} - -.navbar-inverse .navbar-nav li a.label.label-info { - --bg-color: #5bc0de; -} - -.navbar-inverse .navbar-nav li a.label.label-danger { - --bg-color: #d9534f; -} - -.navbar-inverse .navbar-nav li a.label.label-success { - --bg-color: #5cb85c; -} - -.navbar-inverse .navbar-nav li a.label.label-primary { - --bg-color: #337ab7; -} - -.navbar-inverse .navbar-nav li a.label.label-warning { - --bg-color: #f0ad4e; -} - -.navbar-inverse .navbar-nav li a.label { - color: #ffffff; - background-color: var(--bg-color) !important; - background-image:none !important; -} - -.navbar-inverse .navbar-nav li.active a.label { - color: #ffffff !important; - background-image:none !important; - font-weight: bold; - box-shadow: inset 2px -1px 2px 1px rgb(255, 255, 255) !important; -} - -.notebook-sidebar { - position: fixed; - top: 0; - bottom: 0; - left: 0; - width: 200px; /* 1/6 width */ - background-color: #00ff0d; - padding-top: 50px; /* Adjust as per your design */ -} - -.navbar-inverse.nav-stack .navbar-nav li a:hover, -.navbar-inverse.nav-stack .navbar-nav li a:focus { - background-color: #5a5a5a; -} - -.notebook-sidebar .navbar-nav li a { - padding-top: 10px; - padding-bottom: 10px; - width: 200px; -} - -.notes-sidebar .navbar-nav li.sidebar-brand a { - padding-top: 10px; - padding-bottom: 10px; - width: 200px; - background-color: #666666; - background-image:none !important; -} - -.notes-sidebar .nav .sidebar-brand a { - color: #fff; -} - -.notes-sidebar { - position: fixed; - top: 0; - bottom: 0; - left: 200px; /* Width of first sidebar */ - width: 200px; /* 1/6 width */ - background-color: #c7c7c7; - padding-left: 0px !important; - padding-right: 0px !important; - padding-top: 50px; /* Adjust as per your design */ - overflow-y: auto; /* Makes vertical overflow scrollable */ - overflow-x: hidden; /* Hides horizontal overflow */ -} - -.notes-sidebar-width { - width: 200px; -} - -.notes-sidebar .nav li { - width: 200px; - padding-left: 0 !important; - padding-right: 0 !important; -} - -.notes-sidebar .nav li a { - color:#5a5a5a; - display: block; - padding-left: 10px !important; - padding-right: 0px !important; -} - -.notes-sidebar .nav { - position: relative; - height: calc(100% - 50px); /* Reduce the height by the padding-top value or any other header/footer within the sidebar */ - padding-bottom: 50px; /* Space for the bottom anchored item */ - margin-bottom: 0; /* Removes default margin */ -} - - -.outlined-element, .submenu { - border-bottom: 1px solid #575757; -} - -li.submenu a.label { - margin-left: 15px; - padding-left: 25px; - padding-top: 10px; - padding-bottom: 10px; - text-align: left; - line-height: 20px; -} - - - -/* .sidebar .notes-sidebar .nav li.sidebar-brand { - background-image:none; - background-color: #00ff0d !important; -} */ - -/* .notebook-sidebar .navbar-inverse .navbar-nav li a .label, -.notebook-sidebar .navbar-inverse .navbar-nav li a .label:hover, -.notebook-sidebar .navbar-inverse .navbar-nav li a .label:focus { - background-color: #f129d7 !important; - color: #f129d7 !important; - background-image:none !important; -} */ -/* .navbar-inverse .navbar-nav li a.label:hover, -.navbar-inverse .navbar-nav li a.label:focus { - background-color: #00ff0d !important; - color: #00ff0d !important; - background-image:none; -} */ - - - - - - - - -/* .sidebar .notes-sidebar .navbar-inverse .navbar-nav li .active { - background-color: #00ff0d !important; - color: #00ff0d !important; - background-image:none; -} */ - -/* .sidebar .notes-sidebar .navbar-inverse .navbar-nav li .active { - background-color: #f129d7 !important; - color: #f129d7 !important; - background-image:none; -} */ -/* .dateMonthContainer { - background-color: #f129d7 !important; - color: #f129d7 !important; - background-image:none; -} */ -/* .sidebar .notes-sidebar .navbar-inverse .navbar-nav li .active { - background-image: none; - background-color: #00ff0d !important; - color: #00ff0d !important; -} */ - -.side-bar-brand, -.sidebar-brand { - /* background-image: none !important; */ - /* background-color: #f129d7 !important; - color: #f129d7 !important; */ -} diff --git a/app/plugins/notes/forms.php b/app/plugins/notes/forms.php deleted file mode 100644 index 75a9165..0000000 --- a/app/plugins/notes/forms.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins\Notes; - -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Classes\Forms; - -class NotesForms extends Forms { - /** - * Adds these functions to the form list. - */ - public function __construct() { - self::addHandler( 'createNote', __CLASS__, 'createNote' ); - self::addHandler( 'createNotebook', __CLASS__, 'createNotebook' ); - self::addHandler( 'editNote', __CLASS__, 'editNote' ); - self::addHandler( 'editNoteSimple', __CLASS__, 'editNoteSimple' ); - self::addHandler( 'editNotebook', __CLASS__, 'editNotebook' ); - self::addHandler( 'autoUpdateNote', __CLASS__, 'autoUpdateNote' ); - } - - public static function createNote() { - if ( ! Input::exists( 'submit' ) ) { - return false; - } - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - if ( ! Input::exists( 'color' ) ) { - Check::addUserError( 'You must include a color.' ); - return false; - } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function createNotebook() { - if ( ! Input::exists( 'submit' ) ) { - return false; - } - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - if ( ! Input::exists( 'color' ) ) { - Check::addUserError( 'You must include a color.' ); - return false; - } - // if ( ! self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function autoUpdateNote() { - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - // if ( ! self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function editNote() { - if ( ! Input::exists( 'submit' ) ) { - return false; - } - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - if ( ! Input::exists( 'color' ) ) { - Check::addUserError( 'You must include a color.' ); - return false; - } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function editNoteSimple() { - if ( ! Input::exists( 'submit' ) ) { - return false; - } - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } - - public static function editNotebook() { - if ( ! Input::exists( 'submit' ) ) { - return false; - } - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must include a title.' ); - return false; - } - if ( ! Input::exists( 'color' ) ) { - Check::addUserError( 'You must include a color.' ); - return false; - } - // if ( !self::token() ) { - // Check::addUserError( 'token - comment out later.' ); - // return false; - // } - return true; - } -} - -new NotesForms; \ No newline at end of file diff --git a/app/plugins/notes/js/notes.js b/app/plugins/notes/js/notes.js deleted file mode 100644 index 005e0e7..0000000 --- a/app/plugins/notes/js/notes.js +++ /dev/null @@ -1,32 +0,0 @@ - -function setIcon(iconName, iconText) { - document.getElementById('iconValue').value = iconName; - document.getElementById('selected-icon').innerHTML = ' ' + iconText; -} - - -$( document ).ready( function () { - function autosave() { - var title = $( "#title" ).val(); - var color = $( "#color" ).val(); - var notebookID = $( "#notebookID" ).val(); - var noteID = $( "#noteID" ).val(); - var note = $( "#note" ).val(); - - $.post( "/notes/autoUpdate/" + noteID, { - title: title, - color: color, - notebookID: notebookID, - note: note, - }); - console.log( 'note saved' ); - } - - var lastSegment = window.location.pathname.split('/').pop(); - if (!isNaN(lastSegment)) { - if (window.location.pathname.endsWith('/notes/byNote/'+lastSegment)) { - console.log( 'autosave enabled' ); - setInterval(autosave, 60 * 1000); - } - } -}); \ No newline at end of file diff --git a/app/plugins/notes/models/notebooks.php b/app/plugins/notes/models/notebooks.php deleted file mode 100644 index e4f3f8c..0000000 --- a/app/plugins/notes/models/notebooks.php +++ /dev/null @@ -1,169 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Filters; -use TheTempusProject\Bedrock\Classes\CustomException; - -class Notebooks extends DatabaseModel { - public $tableName = 'notebooks'; - - public $databaseMatrix = [ - [ 'title', 'varchar', '256' ], - [ 'description', 'text', '' ], - [ 'color', 'varchar', '48' ], - [ 'icon', 'varchar', '48' ], - [ 'createdBy', 'int', '11' ], - [ 'createdAt', 'int', '11' ], - [ 'notebookID', 'int', '11' ], - [ 'order', 'int', '11' ], - ]; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - } - - public function create( $title, $description = '', $color = 'default', $notebookID = 0, $icon = '' ) { - if ( ! Check::dataTitle( $title ) ) { - Debug::info( 'Notebooks: illegal title.' ); - return false; - } - $fields = [ - 'title' => $title, - 'description' => $description, - 'color' => $color, - 'notebookID' => $notebookID, - 'icon' => $icon, - 'createdBy' => App::$activeUser->ID, - 'createdAt' => time(), - ]; - if ( ! self::$db->insert( $this->tableName, $fields ) ) { - new CustomException( 'notebookCreate' ); - Debug::error( "Notebooks: not created " . var_export($fields,true) ); - return false; - } - return self::$db->lastId(); - } - - public function update( $id, $title, $description = '', $color = 'default', $notebookID = 0, $icon = '' ) { - if ( !Check::id( $id ) ) { - Debug::info( 'Notebooks: illegal ID.' ); - return false; - } - if ( !Check::dataTitle( $title ) ) { - Debug::info( 'Notebooks: illegal title.' ); - return false; - } - $fields = [ - 'title' => $title, - 'notebookID' => $notebookID, - 'description' => $description, - 'color' => $color, - 'icon' => $icon, - ]; - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'notebooksUpdate' ); - Debug::error( "Notebooks: $id not updated" ); - return false; - } - return true; - } - - public function byUser( $limit = null ) { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - if ( empty( $limit ) ) { - $notebooks = self::$db->get( $this->tableName, $whereClause ); - } else { - $notebooks = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$notebooks->count() ) { - Debug::info( 'No Notebooks found.' ); - return false; - } - return $this->filter( $notebooks->results() ); - } - - public function getName( $id ) { - $notebooks = self::findById( $id ); - return $notebooks->title; - } - - public function simpleList( $param = '') { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $notebooks = self::$db->get( $this->tableName, $whereClause ); - if ( !$notebooks->count() ) { - Debug::warn( 'Could not find any notebooks' ); - return []; - } - - $notebooks = $notebooks->results(); - $out = [ 'None' => '0']; - foreach ( $notebooks as &$notebook ) { - $out[ $notebook->title ] = $notebook->ID; - } - return $out; - } - - public function simpleObjectByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $notebooks = self::$db->get( $this->tableName, $whereClause ); - if ( !$notebooks->count() ) { - Debug::warn( 'Could not find any notebooks' ); - return false; - } - - $notebooks = $notebooks->results(); - $out = []; - foreach ( $notebooks as &$notebook ) { - $obj = new \stdClass(); - $obj->title = $notebook->title; - $obj->ID = $notebook->ID; - $out[] = $obj; - } - return $out; - } - - public function getTree() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $notebooks = self::$db->get( $this->tableName, $whereClause ); - if ( !$notebooks->count() ) { - Debug::warn( 'Could not find any notebooks' ); - return []; - } - - $notebooks = $notebooks->results(); - $formattedNotebooks = []; - foreach ($notebooks as $notebook) { - if ( !empty($notebook->notebookID) ) { - $notebookID = $notebook->notebookID; - if ( ! isset( $formattedNotebooks[ $notebookID ])) { - $formattedNotebooks[ $notebookID ][ 'notebooks' ] = []; - } - $formattedNotebooks[ $notebookID ][ 'notebooks' ][] = $notebook; - } else { - $notebookID = $notebook->ID; - $formattedNotebooks[ $notebookID ][ 'notebook' ] = $notebook; - } - } - return $formattedNotebooks; - } - -} diff --git a/app/plugins/notes/models/notes.php b/app/plugins/notes/models/notes.php deleted file mode 100644 index 621f48a..0000000 --- a/app/plugins/notes/models/notes.php +++ /dev/null @@ -1,222 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Filters; -use TheTempusProject\Bedrock\Classes\CustomException; -use TheTempusProject\Bedrock\Functions\Sanitize; - -class Notes extends DatabaseModel { - public $tableName = 'notes'; - public $databaseMatrix = [ - [ 'title', 'varchar', '256' ], - [ 'note', 'text', '' ], - [ 'color', 'varchar', '48' ], - [ 'notebookID', 'int', '11' ], - [ 'createdBy', 'int', '11' ], - [ 'createdAt', 'int', '11' ], - [ 'order', 'int', '11' ], - ]; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - } - - public function create( $title, $note = '', $color = 'default', $notebookID = 0 ) { - $fields = [ - 'title' => $title, - 'note' => $note, - 'color' => $color, - 'notebookID' => $notebookID, - 'createdBy' => App::$activeUser->ID, - 'createdAt' => time(), - ]; - if ( ! self::$db->insert( $this->tableName, $fields ) ) { - new CustomException( 'noteCreate' ); - Debug::error( "Notes: not created " . var_export($fields,true) ); - return false; - } - return self::$db->lastId(); - } - - public function update( $id, $title, $note = '', $color = 'default', $notebookID= 0 ) { - if ( !Check::id( $id ) ) { - Debug::info( 'Notes: illegal ID.' ); - return false; - } - if ( !Check::id( $notebookID ) ) { - Debug::info( 'Notes: illegal ID.' ); - return false; - } - $fields = [ - 'title' => $title, - 'note' => $note, - 'color' => $color, - 'notebookID' => $notebookID, - ]; - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'noteUpdate' ); - Debug::error( "Notes: $id not updated: $fields" ); - return false; - } - return true; - } - - public function byUser( $limit = null ) { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - if ( empty( $limit ) ) { - $notes = self::$db->get( $this->tableName, $whereClause ); - } else { - $notes = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$notes->count() ) { - Debug::info( 'No Notes found.' ); - return false; - } - return $this->filter( $notes->results() ); - } - - public function getName( $id ) { - $note = self::findById( $id ); - return $note->title; - } - - public function simpleByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $notes = self::$db->get( $this->tableName, $whereClause ); - if ( !$notes->count() ) { - Debug::warn( 'Could not find any notes' ); - return false; - } - - $notes = $notes->results(); - $out = []; - foreach ( $notes as &$note ) { - $out[ $note->title ] = $note->ID; - } - return $out; - } - - public function simpleObjectByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $notes = self::$db->get( $this->tableName, $whereClause ); - if ( !$notes->count() ) { - Debug::warn( 'Could not find any notes' ); - return false; - } - - $notes = $notes->results(); - $out = []; - foreach ( $notes as &$note ) { - $obj = new \stdClass(); - $obj->title = $note->title; - $obj->ID = $note->ID; - $out[] = $obj; - } - return $out; - } - - public function simpleObjectByNotebook( $id = 0 ) { - $whereClause = []; - if ( ! empty( $id ) ) { - $whereClause = [ - 'notebookID', '=', $id, 'AND', - ]; - } - $whereClause = array_merge( $whereClause, [ - 'createdBy', '=', App::$activeUser->ID, - ] ); - $notes = self::$db->get( $this->tableName, $whereClause ); - if ( !$notes->count() ) { - Debug::warn( 'Could not find any notes' ); - return false; - } - - $notes = $notes->results(); - $out = []; - foreach ( $notes as &$note ) { - $obj = new \stdClass(); - $obj->title = $note->title; - $obj->ID = $note->ID; - $out[] = $obj; - } - return $out; - } - - public function findByNotebook( $id = 0 ) { - $whereClause = []; - if ( ! empty( $id ) ) { - $whereClause = [ - 'notebookID', '=', $id, 'AND', - ]; - } - $whereClause = array_merge( $whereClause, [ - 'createdBy', '=', App::$activeUser->ID, - ] ); - $notes = self::$db->get( $this->tableName, $whereClause ); - if ( ! $notes->count() ) { - Debug::info( 'No ' . $this->tableName . ' data found.' ); - return []; - } - return $this->filter( $notes->results() ); - } - - public function filter( $postArray, $params = [] ) { - foreach ( $postArray as $instance ) { - if ( !is_object( $instance ) ) { - $instance = $postArray; - $end = true; - } - $cleanPost = Sanitize::contentShort( $instance->note ); - $postSpace = explode( ' ', $cleanPost ); - $postLine = explode( "\n", $cleanPost ); - // summary by words: 100 - $spaceSummary = implode( ' ', array_splice( $postSpace, 0, 100 ) ); - // summary by lines: 5 - $lineSummary = implode( "\n", array_splice( $postLine, 0, 5 ) ); - if ( strlen( $spaceSummary ) < strlen( $lineSummary ) ) { - $contentSummary = $spaceSummary; - $contentSummaryNoLink = $contentSummary; - if ( count( $postSpace, 1 ) <= 100 ) { - $contentSummaryNoLink = $contentSummary; - $contentSummary .= '... Read More'; - } - } else { - // @todo: need to refine this after testing - $contentSummaryNoLink = $lineSummary; - $contentSummary = $lineSummary . '... Read More'; - } - $instance->contentSummaryNoLink = $contentSummaryNoLink; - $instance->contentSummary = $contentSummary; - if ( isset( $params['stripHtml'] ) && $params['stripHtml'] === true ) { - $instance->contentSummary = strip_tags( $instance->content ); - } - // $instance->content = Filters::applyOne( 'mentions.0', $instance->content, true ); - // $instance->content = Filters::applyOne( 'hashtags.0', $instance->content, true ); - $out[] = $instance; - if ( !empty( $end ) ) { - $out = $out[0]; - break; - } - } - return $out; - } -} diff --git a/app/plugins/notes/plugin.php b/app/plugins/notes/plugin.php deleted file mode 100644 index b9665cd..0000000 --- a/app/plugins/notes/plugin.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins; - -use TheTempusProject\Classes\Plugin; -use TheTempusProject\Models\Notes as Note; -use TheTempusProject\Models\Notebooks; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Template; - -class Notes extends Plugin { - public $pluginName = 'TP Notes'; - public $configName = 'notes'; - public $pluginAuthor = 'JoeyK'; - public $pluginWebsite = 'https://TheTempusProject.com'; - public $modelVersion = '1.0'; - public $pluginVersion = '3.0'; - public $pluginDescription = 'A simple plugin which adds a site wide notes system.'; - public $permissionMatrix = [ - 'useNotes' => [ - 'pretty' => 'Can use the notes feature', - 'default' => false, - ], - ]; - public $main_links = [ - [ - 'text' => 'Notes', - 'url' => '{ROOT_URL}notes/index/', - 'filter' => 'loggedin', - ], - ]; - public $configMatrix = [ - 'enabled' => [ - 'type' => 'radio', - 'pretty' => 'Enable Notes.', - 'default' => true, - ], - ]; - public $notes; - public $notebooks; - - public function __construct( $load = false ) { - // $this->notes = new Note; - // $this->notebooks = new Notebooks; - parent::__construct( $load ); - } -} diff --git a/app/plugins/notes/templates/notes.inc.php b/app/plugins/notes/templates/notes.inc.php deleted file mode 100644 index b452f87..0000000 --- a/app/plugins/notes/templates/notes.inc.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Templates; - -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Navigation; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Models\Notebooks; - -class NotesLoader extends DefaultLoader { - /** - * This is the function used to generate any components that may be - * needed by this template. - */ - public function __construct() { - $notebooks = new Notebooks; - Navigation::setCrumbComponent( 'NotebookBreadCrumbs', Input::get( 'url' ) ); - $this->addJs( '' ); - parent::__construct(); - } -} diff --git a/app/plugins/notes/templates/notes.tpl b/app/plugins/notes/templates/notes.tpl deleted file mode 100644 index 88dea7b..0000000 --- a/app/plugins/notes/templates/notes.tpl +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - {TITLE} - - - - - - - - - - - - - {ROBOT} - - - - - - - - - - - {TEMPLATE_CSS_INCLUDES} - - - - - - -
    -
    - {ISSUES} -
    -
    - {ERROR} - {NOTICE} - {SUCCESS} -
    -
    - {/ISSUES} -
    -
    - {NotesNav} - {CONTENT} -
    -
    -
    -
    - - - - - - - {TEMPLATE_JS_INCLUDES} - - \ No newline at end of file diff --git a/app/plugins/notes/views/dashboard.html b/app/plugins/notes/views/dashboard.html deleted file mode 100644 index 0e56375..0000000 --- a/app/plugins/notes/views/dashboard.html +++ /dev/null @@ -1,12 +0,0 @@ -

    Notebooks

    -
    -
    - {notebookList} -
    -
    -

    Notes

    -
    -
    - {noteList} -
    -
    \ No newline at end of file diff --git a/app/plugins/notes/views/nav/menuItem.html b/app/plugins/notes/views/nav/menuItem.html deleted file mode 100644 index ba48267..0000000 --- a/app/plugins/notes/views/nav/menuItem.html +++ /dev/null @@ -1 +0,0 @@ - {title} \ No newline at end of file diff --git a/app/plugins/notes/views/nav/menuItemList.html b/app/plugins/notes/views/nav/menuItemList.html deleted file mode 100644 index d560311..0000000 --- a/app/plugins/notes/views/nav/menuItemList.html +++ /dev/null @@ -1,18 +0,0 @@ - - {notebookName} - - - \ No newline at end of file diff --git a/app/plugins/notes/views/nav/noteSidebar.html b/app/plugins/notes/views/nav/noteSidebar.html deleted file mode 100644 index a5f186f..0000000 --- a/app/plugins/notes/views/nav/noteSidebar.html +++ /dev/null @@ -1,19 +0,0 @@ - \ No newline at end of file diff --git a/app/plugins/notes/views/nav/notebookDropdown.html b/app/plugins/notes/views/nav/notebookDropdown.html deleted file mode 100644 index 5b2a487..0000000 --- a/app/plugins/notes/views/nav/notebookDropdown.html +++ /dev/null @@ -1,11 +0,0 @@ - \ No newline at end of file diff --git a/app/plugins/notes/views/nav/notebookSidebar.html b/app/plugins/notes/views/nav/notebookSidebar.html deleted file mode 100644 index 6d9176c..0000000 --- a/app/plugins/notes/views/nav/notebookSidebar.html +++ /dev/null @@ -1,19 +0,0 @@ - \ No newline at end of file diff --git a/app/plugins/notes/views/nav/topTabs.html b/app/plugins/notes/views/nav/topTabs.html deleted file mode 100644 index 92389a5..0000000 --- a/app/plugins/notes/views/nav/topTabs.html +++ /dev/null @@ -1,10 +0,0 @@ - \ No newline at end of file diff --git a/app/plugins/notes/views/notebooks/create.html b/app/plugins/notes/views/notebooks/create.html deleted file mode 100644 index 8d444ce..0000000 --- a/app/plugins/notes/views/notebooks/create.html +++ /dev/null @@ -1,41 +0,0 @@ -Create Notebook -
    - -
    - -
    - {notebookSelect} -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - {colorSelect} -
    -
    -
    - -
    - {iconSelect} -
    - -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/notes/views/notebooks/edit.html b/app/plugins/notes/views/notebooks/edit.html deleted file mode 100644 index 9a3afb8..0000000 --- a/app/plugins/notes/views/notebooks/edit.html +++ /dev/null @@ -1,39 +0,0 @@ -
    - -
    - -
    - {notebookSelect} -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - {colorSelect} -
    -
    -
    - -
    - {iconSelect} -
    -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/notes/views/notebooks/list.html b/app/plugins/notes/views/notebooks/list.html deleted file mode 100644 index ea056e2..0000000 --- a/app/plugins/notes/views/notebooks/list.html +++ /dev/null @@ -1,35 +0,0 @@ -
    -
    - - - - - - - - - - - - {LOOP} - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    TitleDescription
    {title}{description}
    - No Notebooks -
    - New Notebook -
    -
    - diff --git a/app/plugins/notes/views/notes/create.html b/app/plugins/notes/views/notes/create.html deleted file mode 100644 index a2d9c57..0000000 --- a/app/plugins/notes/views/notes/create.html +++ /dev/null @@ -1,32 +0,0 @@ -Create Note -
    - -
    - - {notebookSelect} -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - {colorSelect} -
    -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/notes/views/notes/edit.html b/app/plugins/notes/views/notes/edit.html deleted file mode 100644 index 07c830f..0000000 --- a/app/plugins/notes/views/notes/edit.html +++ /dev/null @@ -1,29 +0,0 @@ -Edit Note -
    - - -
    -
    - - -
    -
    - -
    - {colorSelect} -
    -
    -
    - - {notebookSelect} -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/notes/views/notes/list.html b/app/plugins/notes/views/notes/list.html deleted file mode 100644 index 26538f1..0000000 --- a/app/plugins/notes/views/notes/list.html +++ /dev/null @@ -1,35 +0,0 @@ -
    -
    - - - - - - - - - - - - {LOOP} - - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    TitleNoteCreated
    {title}{contentSummaryNoLink}{DTC}{createdAt}{/DTC}
    - No Notes -
    - New Note -
    -
    \ No newline at end of file diff --git a/app/plugins/reviews/controllers/admin/reviews.php b/app/plugins/reviews/controllers/admin/reviews.php deleted file mode 100644 index 6edae63..0000000 --- a/app/plugins/reviews/controllers/admin/reviews.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers\Admin; - -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Houdini\Classes\Navigation; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Classes\AdminController; -use TheTempusProject\Models\Review; -use TheTempusProject\Models\Reviewcategory; -use TheTempusProject\Classes\Forms; - -class Reviews extends AdminController { - protected static $reviews; - protected static $categories; - - public function __construct() { - parent::__construct(); - self::$title = 'Admin - Reviews'; - self::$reviews = new Review; - self::$categories = new Reviewcategory; - $view = Navigation::activePageSelect( 'nav.admin', '/admin/reviews' ); - Components::set( 'ADMINNAV', $view ); - } - - public function index( $data = null ) { - $reviews = Views::simpleView( 'reviews.admin.reviewList', self::$reviews->list() ); - $categories = Views::simpleView( 'reviews.admin.categoryList', self::$categories->list() ); - Components::set( 'reviews', $reviews ); - Components::set( 'reviewCategories', $categories ); - Views::view( 'reviews.admin.dashboard' ); - } - - public function categoryView( $id = null ) { - $category = self::$categories->findById( $id ); - if ( ! $category ) { - Issues::add( 'error', 'Unknown Category.' ); - return $this->index(); - } - Views::view( 'reviews.admin.category', $category ); - } - - public function categoryCreate( ) { - if ( ! Input::exists( 'submit' ) ) { - return Views::view( 'reviews.admin.categoryCreate' ); - } - if ( ! Forms::check( 'categoryCreate' ) ) { - Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] ); - return Views::view( 'reviews.admin.categoryCreate' ); - } - $result = self::$categories->create( - Input::post( 'name' ), - Input::post( 'slug' ), - ); - if ( $result ) { - Issues::add( 'success', 'Your review category has been created.' ); - return $this->index(); - } - Issues::add( 'error', [ 'There was an unknown error submitting your data.' => Check::userErrors() ] ); - Views::view( 'reviews.admin.categoryCreate' ); - } - - public function categoryEdit( $id = null ) { - $category = self::$categories->findById( $id ); - if ( ! $category ) { - Issues::add( 'error', 'Unknown Category.' ); - return $this->index(); - } - if ( ! Input::exists( 'submit' ) ) { - return Views::view( 'reviews.admin.categoryEdit', $category ); - } - if ( ! Forms::check( 'categoryEdit' ) ) { - Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] ); - return Views::view( 'reviews.admin.categoryEdit', $category ); - } - $result = self::$categories->update( - $id, - Input::post( 'name' ), - Input::post( 'slug' ), - ); - if ( $result ) { - Issues::add( 'success', 'Your review category has been updated.' ); - return $this->index(); - } - Issues::add( 'error', [ 'There was an unknown error submitting your data.' => Check::userErrors() ] ); - Views::view( 'reviews.admin.categoryEdit', $category ); - } - - public function categoryDelete( $id = null ) { - if ( self::$categories->delete( $id ) ) { - Issues::add( 'success', 'review category deleted' ); - } else { - Issues::add( 'error', 'There was an error with your request.' ); - } - $this->index(); - } - - public function reviewView( $id = null ) { - Views::view( 'reviews.admin.review', self::$reviews->findById( $id ) ); - } - - public function reviewApprove( $id = null ) { - if ( self::$reviews->approve( $id ) ) { - Issues::add( 'success', 'review approved' ); - } else { - Issues::add( 'error', 'There was an error with your request.' ); - } - $this->index(); - } - - public function reviewHide( $id = null ) { - if ( self::$reviews->hide( $id ) ) { - Issues::add( 'success', 'review hidden' ); - } else { - Issues::add( 'error', 'There was an error with your request.' ); - } - $this->index(); - } - - public function reviewDelete( $id = null ) { - if ( self::$reviews->delete( $id ) ) { - Issues::add( 'success', 'review deleted' ); - } else { - Issues::add( 'error', 'There was an error with your request.' ); - } - $this->index(); - } -} diff --git a/app/plugins/reviews/controllers/reviews.php b/app/plugins/reviews/controllers/reviews.php deleted file mode 100644 index cd4d0ea..0000000 --- a/app/plugins/reviews/controllers/reviews.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers; - -use TheTempusProject\Hermes\Functions\Redirect; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Session; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Classes\Controller; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Models\Review; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Houdini\Classes\Template; -use TheTempusProject\Models\Reviewcategory; -use TheTempusProject\Houdini\Classes\Forms as HoudiniForms; - -class Reviews extends Controller { - protected static $reviews; - protected static $categories; - - public function __construct() { - self::$title = 'Reviews - {SITENAME}'; - self::$pageDescription = 'On this page you can submit a reviews for a product from the site.'; - - if ( ! App::$isLoggedIn ) { - Session::flash( 'notice', 'You must be logged in to review products.' ); - return Redirect::home(); - } - - parent::__construct(); - self::$reviews = new Review; - self::$categories = new Reviewcategory; - Components::append( 'TEMPLATE_JS_INCLUDES', Template::parse('' ) ); - Components::append( 'TEMPLATE_CSS_INCLUDES', Template::parse('') ); - } - - public function index() { - $reviews = Views::simpleView( 'reviews.list', self::$reviews->byUser() ); - Components::set( 'reviews', $reviews ); - Views::view( 'reviews.index' ); - } - - public function review( $slug = null ) { - $category = self::$categories->findBySlug( $slug ); - if ( ! $category ) { - $selectedCategory = '0'; - $reviewCategorySelect = HoudiniForms::getSelectHtml( - 'review_category_id', - self::$categories->simple(), - $selectedCategory, - ); - Components::set( 'reviewCategorySelect', $reviewCategorySelect ); - } else { - $selectedCategory = $category->ID; - Components::set( - 'reviewCategorySelect', - '' - ); - } - if ( ! Input::exists('submit') ) { - return Views::view( 'reviews.create' ); - } - if ( ! Forms::check( 'createReview' ) ) { - Issues::add( 'error', [ 'There was an error with your review.' => Check::userErrors() ] ); - return Views::view( 'reviews.create' ); - } - $result = self::$reviews->create( Input::post('title'), Input::post('rating'), Input::post('review'), Input::post('review_category_id') ); - if ( true === $result ) { - Session::flash( 'success', 'Your review has been received.' ); - Redirect::to( 'home/index' ); - } else { - Issues::add( 'error', 'There was an unresolved error while submitting your review.' ); - return Views::view( 'reviews.create' ); - } - } -} \ No newline at end of file diff --git a/app/plugins/reviews/css/reviews.css b/app/plugins/reviews/css/reviews.css deleted file mode 100644 index 30d7809..0000000 --- a/app/plugins/reviews/css/reviews.css +++ /dev/null @@ -1,9 +0,0 @@ - - .star-rating .fa-star { - font-size: 24px; - color: grey; - cursor: pointer; - } - .star-rating .fa-star.checked { - color: gold; - } \ No newline at end of file diff --git a/app/plugins/reviews/forms.php b/app/plugins/reviews/forms.php deleted file mode 100644 index 03ccdcd..0000000 --- a/app/plugins/reviews/forms.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins\Reviews; - -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Classes\Forms; - -class ReviewForms extends Forms { - /** - * Adds these functions to the form list. - */ - public function __construct() { - self::addHandler( 'createReview', __CLASS__, 'createReview' ); - self::addHandler( 'editReview', __CLASS__, 'editReview' ); - self::addHandler( 'categoryCreate', __CLASS__, 'categoryCreate' ); - self::addHandler( 'categoryEdit', __CLASS__, 'categoryEdit' ); - } - - /** - * Validates the createReview form. - * - * @return {bool} - */ - public static function createReview() { - if ( ! Input::exists( 'review' ) ) { - Check::addUserError( 'You must provide a review.' ); - return false; - } - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must provide a title.' ); - return false; - } - if ( ! Input::exists( 'rating' ) ) { - Check::addUserError( 'You must provide a rating.' ); - return false; - } - if ( ! Input::exists( 'review_category_id' ) ) { - Check::addUserError( 'You must provide a review_category_id.' ); - return false; - } - return true; - } - public static function editReview() { - if ( ! Input::exists( 'review' ) ) { - Check::addUserError( 'You must provide a review.' ); - return false; - } - if ( ! Input::exists( 'title' ) ) { - Check::addUserError( 'You must provide a title.' ); - return false; - } - if ( ! Input::exists( 'rating' ) ) { - Check::addUserError( 'You must provide a rating.' ); - return false; - } - return true; - } - public static function categoryCreate() { - if ( ! Input::exists( 'name' ) ) { - Check::addUserError( 'You must provide a name.' ); - return false; - } - if ( ! Input::exists( 'slug' ) ) { - Check::addUserError( 'You must provide a slug.' ); - return false; - } - return true; - } - public static function categoryEdit() { - if ( ! Input::exists( 'name' ) ) { - Check::addUserError( 'You must provide a name.' ); - return false; - } - if ( ! Input::exists( 'slug' ) ) { - Check::addUserError( 'You must provide a slug.' ); - return false; - } - return true; - } -} - -new ReviewForms; diff --git a/app/plugins/reviews/js/reviews.js b/app/plugins/reviews/js/reviews.js deleted file mode 100644 index dfd6ad2..0000000 --- a/app/plugins/reviews/js/reviews.js +++ /dev/null @@ -1,20 +0,0 @@ -$(document).ready(function() { - var $star_rating = $('.star-rating .fa-star'); - - var SetRatingStar = function() { - return $star_rating.each(function() { - if (parseInt($(this).siblings('input.rating-value').val()) >= parseInt($(this).data('rating'))) { - return $(this).addClass('checked'); - } else { - return $(this).removeClass('checked'); - } - }); - }; - - $star_rating.on('click', function() { - $(this).siblings('input.rating-value').val($(this).data('rating')); - return SetRatingStar(); - }); - - SetRatingStar(); -}); \ No newline at end of file diff --git a/app/plugins/reviews/models/review.php b/app/plugins/reviews/models/review.php deleted file mode 100644 index 2f21ee1..0000000 --- a/app/plugins/reviews/models/review.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\Plugins\Reviews as Plugin; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Bedrock\Classes\CustomException; - -class Review extends DatabaseModel { - public $tableName = 'reviews'; - public $databaseMatrix = [ - [ 'review_category_id', 'int', '11' ], - [ 'title', 'varchar', '128' ], - [ 'rating', 'int', '1' ], - [ 'review', 'text', '' ], - [ 'createdBy', 'int', '11' ], - [ 'createdAt', 'int', '11' ], - [ 'approvedAt', 'int', '11' ], - [ 'approvedBy', 'int', '11' ], - ]; - public $plugin; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - $this->plugin = new Plugin; - } - - public function create( $title, $rating, $review, $review_category_id = '0' ) { - if ( ! $this->plugin->checkEnabled() ) { - Debug::info( 'Reviews are disabled in the config.' ); - return false; - } - $fields = [ - 'title' => $title, - 'rating' => $rating, - 'review' => $review, - 'review_category_id' => $review_category_id, - 'createdAt' => time(), - 'createdBy' => App::$activeUser->ID, - ]; - if ( ! self::$db->insert( $this->tableName, $fields ) ) { - Debug::info( 'Reviews::create - failed to insert to db' ); - return false; - } - return self::$db->lastId(); - } - - public function update( $id, $title, $rating, $review, $review_category_id = '0' ) { - if ( ! $this->plugin->checkEnabled() ) { - Debug::info( 'Reviews are disabled in the config.' ); - return false; - } - if ( !Check::dataTitle( $slug ) ) { - Debug::info( 'Review Categories: illegal title.' ); - return false; - } - $fields = [ - 'title' => $title, - 'rating' => $rating, - 'review' => $review, - 'review_category_id' => $review_category_id, - ]; - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'reviewUpdate' ); - Debug::error( "Review: $id not updated: $fields" ); - return false; - } - return true; - } - - public function approve( $ID ) { - if ( !Check::id( $ID ) ) { - Debug::info( 'Review Categories: illegal ID.' ); - return false; - } - $fields = [ - 'approvedAt' => time(), - 'approvedBy' => App::$activeUser->ID, - ]; - if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - new CustomException( $this->tableName ); - Debug::error( "Review Categories: $ID Approved: $fields" ); - return false; - } - return true; - } - - public function hide( $ID ) { - // if ( !Check::id( $ID ) ) { - // Debug::info( 'Review Categories: illegal ID.' ); - // return false; - // } - // $fields = [ - // 'approvedAt' => null, - // 'approvedBy' => null, - // ]; - // if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - // new CustomException( $this->tableName ); - // Debug::error( "Review Categories: $ID not Approved: $fields" ); - // return false; - // } - return true; - } - - public function byUser( $limit = null ) { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - if ( empty( $limit ) ) { - $reviews = self::$db->get( $this->tableName, $whereClause ); - } else { - $reviews = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$reviews->count() ) { - Debug::info( 'No Reviews found.' ); - return false; - } - return $this->filter( $reviews->results() ); - } - - public function byCategory( $id, $limit = null ) { - $whereClause = [ 'review_category_id', '=', $id ]; - if ( empty( $limit ) ) { - $reviews = self::$db->get( $this->tableName, $whereClause ); - } else { - $reviews = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$reviews->count() ) { - Debug::info( 'No Reviews found.' ); - return false; - } - return $this->filter( $reviews->results() ); - } -} diff --git a/app/plugins/reviews/models/reviewcategory.php b/app/plugins/reviews/models/reviewcategory.php deleted file mode 100644 index eb4271f..0000000 --- a/app/plugins/reviews/models/reviewcategory.php +++ /dev/null @@ -1,112 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\Plugins\Reviews as Plugin; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Bedrock\Classes\CustomException; - -class Reviewcategory extends DatabaseModel { - public $tableName = 'review_categories'; - public $databaseMatrix = [ - [ 'name', 'varchar', '128' ], - [ 'slug', 'varchar', '64' ], - [ 'createdBy', 'int', '11' ], - [ 'createdAt', 'int', '11' ], - ]; - public $plugin; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - $this->plugin = new Plugin; - } - - public function create( $name, $slug ) { - if ( ! $this->plugin->checkEnabled() ) { - Debug::info( 'Reviews are disabled in the config.' ); - return false; - } - if ( !Check::dataTitle( $slug ) ) { - Debug::info( 'Review Categories: illegal title.' ); - return false; - } - $fields = [ - 'name' => $name, - 'slug' => $slug, - 'createdAt' => time(), - 'createdBy' => App::$activeUser->ID, - ]; - if ( ! self::$db->insert( $this->tableName, $fields ) ) { - Debug::info( 'ReviewCategories::create - failed to insert to db' ); - return false; - } - return self::$db->lastId(); - } - - public function update( $id, $name, $slug ) { - if ( ! $this->plugin->checkEnabled() ) { - Debug::info( 'Reviews are disabled in the config.' ); - return false; - } - if ( !Check::dataTitle( $slug ) ) { - Debug::info( 'Review Categories: illegal title.' ); - return false; - } - $fields = [ - 'name' => $name, - 'slug' => $slug, - ]; - if ( !self::$db->update( $this->tableName, $id, $fields ) ) { - new CustomException( 'reviewCategoryUpdate' ); - Debug::error( "Review Categories: $id not updated: $fields" ); - return false; - } - return true; - } - - public function findBySlug( $slug, $limit = null ) { - $whereClause = [ 'slug', '=', $slug ]; - if ( empty( $limit ) ) { - $categories = self::$db->get( $this->tableName, $whereClause ); - } else { - $categories = self::$db->get( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] ); - } - if ( !$categories->count() ) { - Debug::info( 'No categories found.' ); - return false; - } - return $this->filter( $categories->first() ); - } - - public function simple() { - $categories = self::$db->get( $this->tableName, '*' ); - if ( !$categories->count() ) { - Debug::warn( 'Could not find any categories' ); - return false; - } - - $categories = $categories->results(); - $out = []; - foreach ( $categories as &$category ) { - $out[ $category->name ] = $category->ID; - } - return $out; - } -} diff --git a/app/plugins/reviews/plugin.php b/app/plugins/reviews/plugin.php deleted file mode 100644 index bde0fcc..0000000 --- a/app/plugins/reviews/plugin.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins; - -use TheTempusProject\Classes\Plugin; - -class Reviews extends Plugin { - public $pluginName = 'TP Reviews'; - public $pluginAuthor = 'JoeyK'; - public $pluginWebsite = 'https://TheTempusProject.com'; - public $modelVersion = '1.0'; - public $pluginVersion = '3.0'; - public $pluginDescription = 'A simple plugin which adds a site wide review system.'; - public $permissionMatrix = [ - 'review' => [ - 'pretty' => 'Can create reviews', - 'default' => false, - ], - 'createReviewCategory' => [ - 'pretty' => 'Can create review categories', - 'default' => false, - ], - ]; - public $admin_links = [ - [ - 'text' => ' Reviews', - 'url' => '{ROOT_URL}admin/reviews', - ], - ]; - public $footer_links = [ - [ - 'text' => 'Reviews', - 'url' => '{ROOT_URL}reviews/index/', - 'filter' => 'loggedin', - ], - ]; -} - -// need a setting to allow reviewing a category from the dropdown -// if disabled, "I'm sorry but reviews are invite only. If you have been asked to review a product, double check the link and make sure its been entered correctly -// if you have not been invited to review a product, please feel free to leave any feedback in the feedback section. \ No newline at end of file diff --git a/app/plugins/reviews/views/admin/category.html b/app/plugins/reviews/views/admin/category.html deleted file mode 100644 index 9d4717a..0000000 --- a/app/plugins/reviews/views/admin/category.html +++ /dev/null @@ -1,35 +0,0 @@ -
    -
    -
    -
    -

    Review Category

    -
    -
    -
    -
    - - - - - - - - - - - - - - - -
    Name{name}
    Slug{slug}
    Created{DTC}{createdAt}{/DTC}
    -
    -
    -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/reviews/views/admin/categoryCreate.html b/app/plugins/reviews/views/admin/categoryCreate.html deleted file mode 100644 index ff77224..0000000 --- a/app/plugins/reviews/views/admin/categoryCreate.html +++ /dev/null @@ -1,22 +0,0 @@ -Create Review Category -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/reviews/views/admin/categoryEdit.html b/app/plugins/reviews/views/admin/categoryEdit.html deleted file mode 100644 index 6be8a5d..0000000 --- a/app/plugins/reviews/views/admin/categoryEdit.html +++ /dev/null @@ -1,22 +0,0 @@ -Edit Review Category -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/reviews/views/admin/categoryList.html b/app/plugins/reviews/views/admin/categoryList.html deleted file mode 100644 index 93ec77e..0000000 --- a/app/plugins/reviews/views/admin/categoryList.html +++ /dev/null @@ -1,33 +0,0 @@ -Review Categories - - - - - - - - - - - - - {LOOP} - - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    IDNameSlug
    {ID}{name}{slug}
    - No results to show. -
    -Create \ No newline at end of file diff --git a/app/plugins/reviews/views/admin/dashboard.html b/app/plugins/reviews/views/admin/dashboard.html deleted file mode 100644 index 52682fa..0000000 --- a/app/plugins/reviews/views/admin/dashboard.html +++ /dev/null @@ -1,9 +0,0 @@ - -
    -
    - {reviews} -
    -
    - {reviewCategories} -
    -
    \ No newline at end of file diff --git a/app/plugins/reviews/views/admin/review.html b/app/plugins/reviews/views/admin/review.html deleted file mode 100644 index 37aad42..0000000 --- a/app/plugins/reviews/views/admin/review.html +++ /dev/null @@ -1,42 +0,0 @@ -
    -
    -
    -
    -

    Review

    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    Title{title}
    Rating{rating}
    Created{DTC}{createdAt}{/DTC}
    Review
    {review}
    -
    -
    -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/reviews/views/admin/reviewList.html b/app/plugins/reviews/views/admin/reviewList.html deleted file mode 100644 index b3fb56c..0000000 --- a/app/plugins/reviews/views/admin/reviewList.html +++ /dev/null @@ -1,32 +0,0 @@ -Reviews - - - - - - - - - - - - - {LOOP} - - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    IDTitleRating
    {ID}{title}{rating}
    - No results to show. -
    \ No newline at end of file diff --git a/app/plugins/reviews/views/admin/view.html b/app/plugins/reviews/views/admin/view.html deleted file mode 100644 index e69de29..0000000 diff --git a/app/plugins/reviews/views/create.html b/app/plugins/reviews/views/create.html deleted file mode 100644 index 6852a83..0000000 --- a/app/plugins/reviews/views/create.html +++ /dev/null @@ -1,29 +0,0 @@ -
    -

    Write a Review

    -
    -
    - - {reviewCategorySelect} -
    -
    - - -
    -
    - -
    - - - - - - -
    -
    -
    - - -
    - -
    -
    \ No newline at end of file diff --git a/app/plugins/reviews/views/index.html b/app/plugins/reviews/views/index.html deleted file mode 100644 index 4338bc5..0000000 --- a/app/plugins/reviews/views/index.html +++ /dev/null @@ -1 +0,0 @@ -{reviews} \ No newline at end of file diff --git a/app/plugins/reviews/views/list.html b/app/plugins/reviews/views/list.html deleted file mode 100644 index b3fb56c..0000000 --- a/app/plugins/reviews/views/list.html +++ /dev/null @@ -1,32 +0,0 @@ -Reviews - - - - - - - - - - - - - {LOOP} - - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    IDTitleRating
    {ID}{title}{rating}
    - No results to show. -
    \ No newline at end of file diff --git a/app/plugins/suggestions/controllers/admin/suggestions.php b/app/plugins/suggestions/controllers/admin/suggestions.php deleted file mode 100644 index ed238ba..0000000 --- a/app/plugins/suggestions/controllers/admin/suggestions.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers\Admin; - -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Classes\AdminController; -use TheTempusProject\Models\Suggestions as SuggestionsModel; -use TheTempusProject\Models\Comments; -use TheTempusProject\Houdini\Classes\Forms as TemplateForm; - -class Suggestions extends AdminController { - protected static $suggestions; - protected static $comments; - - public function __construct() { - parent::__construct(); - self::$title = 'Admin - Suggestions'; - self::$suggestions = new SuggestionsModel; - } - - public function index( $data = null ) { - Views::view( 'suggestions.admin.list', self::$suggestions->list() ); - } - - public function view( $id = null ) { - $data = self::$suggestions->findById( $id ); - if ( $data == false ) { - Issues::add( 'error', 'Suggestion not found.' ); - return $this->index(); - } - if ( empty( self::$comments ) ) { - self::$comments = new Comments; - } - Components::set( 'COMMENT_TYPE', 'suggestions' ); - Components::set( 'count', self::$comments->count( 'suggestion', $id ) ); - Components::set( 'COMMENTS', Views::simpleView( 'comments.list', self::$comments->display( 10, 'suggestion', $id ) ) ); - Views::view( 'suggestions.admin.view', $data ); - } - - public function approve( $id = null ) { - $data = self::$suggestions->findById( $id ); - if ( $data == false ) { - Issues::add( 'error', 'Suggestion not found.' ); - return $this->index(); - } - if ( !self::$suggestions->approve( $id ) ) { - Issues::add( 'error', 'Suggestion not approved.' ); - return $this->index(); - } - Issues::add( 'success', 'Suggestion Approved' ); - return $this->index(); - } - - public function reject( $id = null ) { - $data = self::$suggestions->findById( $id ); - if ( $data == false ) { - Issues::add( 'error', 'Suggestion not found.' ); - return $this->index(); - } - if ( !self::$suggestions->reject( $id ) ) { - Issues::add( 'error', 'Suggestion not rejected.' ); - return $this->index(); - } - Issues::add( 'success', 'Suggestion Rejected' ); - return $this->index(); - } - - public function edit( $id = null ) { - $data = self::$suggestions->findById( $id ); - if ( false == $data ) { - return $this->index(); - } - TemplateForm::selectRadio( 'approved', $data->approved ); - if ( !Input::exists( 'submit' ) ) { - return Views::view( 'suggestions.admin.edit', $data ); - } - if ( !Forms::check( 'editSuggestion' ) ) { - Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] ); - return Views::view( 'suggestions.admin.edit', $data ); - } - if ( self::$suggestions->update( $id, Input::post( 'title' ), Input::post( 'suggestion' ), Input::post( 'approved' ) ) ) { - Issues::add( 'success', 'Suggestion updated' ); - } else { - return Views::view( 'suggestions.edit', $data ); - } - } - - public function delete( $data = null ) { - if ( Input::exists( 'submit' ) ) { - $data = Input::post( 'S_' ); - } - if ( !self::$suggestions->delete( $data ) ) { - Issues::add( 'error', 'There was an error with your request.' ); - } else { - Issues::add( 'success', 'Suggestions has been deleted' ); - } - $this->index(); - } - - public function clear( $data = null ) { - self::$suggestions->empty(); - $this->index(); - } -} diff --git a/app/plugins/suggestions/controllers/suggestions.php b/app/plugins/suggestions/controllers/suggestions.php deleted file mode 100644 index 1b843ce..0000000 --- a/app/plugins/suggestions/controllers/suggestions.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers; - -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Hermes\Functions\Redirect; -use TheTempusProject\Bedrock\Functions\Session; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Classes\Controller; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Models\Suggestions as SuggestionModel; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Models\Comments as CommentsModel; -use TheTempusProject\Plugins\Comments; -use TheTempusProject\Houdini\Classes\Components; - -class Suggestions extends Controller { - protected static $suggestions; - protected static $comments; - - public function __construct() { - parent::__construct(); - if ( !App::$isLoggedIn ) { - Session::flash( 'notice', 'You must be logged in to view suggestions.' ); - return Redirect::home(); - } - self::$suggestions = new SuggestionModel; - self::$title = 'Suggestions - {SITENAME}'; - self::$pageDescription = 'On this page you can view, submit, or comment-on suggestions for the site.'; - } - - public function index() { - Views::view( 'suggestions.list', self::$suggestions->recent() ); - } - - public function view( $id = null ) { - $data = self::$suggestions->findById( $id ); - if ( $data == false ) { - Issues::add( 'error', 'Suggestion not found.' ); - return $this->index(); - } - if ( empty( self::$comments ) ) { - self::$comments = new CommentsModel; - } - if ( Input::exists( 'contentId' ) ) { - $this->comments( 'post', Input::post( 'contentId' ) ); - } - Components::set( 'CONTENT_ID', $id ); - Components::set( 'COMMENT_TYPE', 'suggestions' ); - Components::set( 'NEWCOMMENT', Views::simpleView( 'comments.create' ) ); - Components::set( 'count', self::$comments->count( 'suggestion', $id ) ); - Components::set( 'COMMENTS', Views::simpleView( 'comments.list', self::$comments->display( 10, self::$suggestions->tableName, $id ) ) ); - Views::view( 'suggestions.view', $data ); - } - - public function create() { - if ( !Input::exists() ) { - return Views::view( 'suggestions.create' ); - } - if ( !Forms::check( 'newSuggestion' ) ) { - Issues::add( 'error', [ 'There was an error with your suggestion.' => Check::userErrors() ] ); - return Views::view( 'suggestions.create' ); - } - if ( !self::$suggestions->create( Input::post( 'title' ), Input::post( 'suggestion' ) ) ) { - Issues::add( 'error', [ 'There was an error with your suggestion.' => Check::userErrors() ] ); - return Views::view( 'suggestions.create' ); - } - Session::flash( 'success', 'Your Suggestion has been received. We must verify all suggestions before they are published, but as long as it doesn\'t violate our code of conduct, it should be available to view and comment on publicly within 24 hours.' ); - Redirect::to( 'suggestions/index' ); - } - - public function edit( $data = null ) { - if ( !Input::exists( 'submit' ) ) { - return Views::view( 'suggestions.edit', self::$suggestions->findById( $data ) ); - } - if ( !Forms::check( 'editSuggestion' ) ) { - Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] ); - return Views::view( 'suggestions.edit', self::$suggestions->findById( $data ) ); - } - if ( self::$suggestions->update( $data, Input::post( 'title' ), Input::post( 'suggestion' ) ) ) { - Issues::add( 'success', 'Suggestion updated' ); - } else { - return Views::view( 'suggestions.edit', self::$suggestions->findById( $data ) ); - } - $this->index(); - } - - public function comments( $sub = null, $data = null ) { - if ( empty( self::$comments ) ) { - self::$comments = new CommentsModel; - } - $commentsPlugin = new Comments; - if ( empty( $sub ) || empty( $data ) ) { - Session::flash( 'error', 'Whoops, try again.' ); - Redirect::to( 'suggestions' ); - } - switch ( $sub ) { - case 'post': - $content = self::$suggestions->findById( $data ); - if ( empty( $content ) ) { - Session::flash( 'error', 'Unknown Content.' ); - Redirect::to( 'suggestions' ); - } - return $commentsPlugin->formPost( self::$suggestions->tableName, $content, 'suggestions/view/' ); - case 'edit': - $content = self::$comments->findById( $data ); - if ( empty( $content ) ) { - Session::flash( 'error', 'Unknown Comment.' ); - Redirect::to( 'suggestions' ); - } - return $commentsPlugin->formEdit( self::$suggestions->tableName, $content, 'suggestions/view/' ); - case 'delete': - $content = self::$comments->findById( $data ); - if ( empty( $content ) ) { - Session::flash( 'error', 'Unknown Comment.' ); - Redirect::to( 'suggestions' ); - } - return $commentsPlugin->formDelete( self::$suggestions->tableName, $content, 'suggestions/view/' ); - } - } -} \ No newline at end of file diff --git a/app/plugins/suggestions/forms.php b/app/plugins/suggestions/forms.php deleted file mode 100644 index 2b206b0..0000000 --- a/app/plugins/suggestions/forms.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins\Suggestions; - -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Classes\Forms; - -class SuggestionForms extends Forms { - /** - * Adds these functions to the form list. - */ - public function __construct() { - self::addHandler( 'newSuggestion', __CLASS__, 'newSuggestion' ); - self::addHandler( 'editSuggestion', __CLASS__, 'editSuggestion' ); - } - - /** - * Validates the suggestion create form. - * - * @return {bool} - */ - public static function newSuggestion() { - if ( !Input::exists( 'title' ) ) { - self::addUserError( 'You must specify title' ); - return false; - } - if ( !Input::exists( 'suggestion' ) ) { - self::addUserError( 'You must write a Suggestion' ); - return false; - } - if ( !self::token() ) { - return false; - } - return true; - } - - /** - * Validates the suggestion create form. - * - * @return {bool} - */ - public static function editSuggestion() { - if ( !Input::exists( 'title' ) ) { - self::addUserError( 'You must specify title' ); - return false; - } - if ( !Input::exists( 'suggestion' ) ) { - self::addUserError( 'You must write a Suggestion' ); - return false; - } - if ( !self::token() ) { - return false; - } - return true; - } -} - -new SuggestionForms; diff --git a/app/plugins/suggestions/models/suggestions.php b/app/plugins/suggestions/models/suggestions.php deleted file mode 100644 index b93b9b8..0000000 --- a/app/plugins/suggestions/models/suggestions.php +++ /dev/null @@ -1,183 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Bedrock\Classes\CustomException; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\TheTempusProject as App; - -class Suggestions extends DatabaseModel { - public $tableName = 'suggestions'; - public $databaseMatrix = [ - [ 'title', 'varchar', '86' ], - [ 'suggestion', 'text', '' ], - [ 'suggestedOn', 'int', '10' ], - [ 'approved', 'varchar', '5' ], - [ 'approvedOn', 'int', '10' ], - [ 'approvedBy', 'int', '11' ], - [ 'author', 'int', '11' ], - ]; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - } - - // @TODO: Add a config for some of these things - // public function enabled() { - // if ( true === parent::enabled() ) { - // return Config::getValue( $this->configName . '/enabled' ) === true; - // } - // return false; - // } - public function filter( $data, $params = [] ) { - foreach ( $data as $instance ) { - if ( !is_object( $instance ) ) { - $instance = $data; - $end = true; - } - if ( !empty($instance->approvedBy)) { - $instance->approvedByName = self::$user->getUsername( $instance->approvedBy ); - } else { - $instance->approvedByName = ''; - } - $instance->submittedBy = self::$user->getUsername( $instance->author ); - $out[] = $instance; - if ( !empty( $end ) ) { - $out = $out[0]; - break; - } - } - return $out; - } - - /** - * Logs a Suggestion form. - * - * @param int $ID the user ID submitting the form - * @param string $url the url - * @param string $o_url the original url - * @param int $repeat is repeatable? - * @param string $description_ description of the event. - * - * @return null - */ - public function create( $title, $suggestion, $approved = 'false' ) { - if ( !$this->enabled() ) { - Debug::info( 'Suggestions are disabled in the config.' ); - return false; - } - $fields = [ - 'author' => App::$activeUser->ID, - 'suggestedOn' => time(), - 'suggestion' => $suggestion, - 'approved' => $approved, - 'title' => $title, - ]; - if ( !self::$db->insert( $this->tableName, $fields ) ) { - new CustomException( $this->tableName ); - return false; - } - return self::$db->lastId(); - } - - public function update( $ID, $title, $suggestion, $approved = 'false' ) { - if ( empty( self::$log ) ) { - self::$log = new Log; - } - if ( !Check::id( $ID ) ) { - Debug::info( 'Suggestion: illegal ID.' ); - return false; - } - $fields = [ - 'suggestion' => $suggestion, - 'approved' => $approved, - 'title' => $title, - ]; - if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - new CustomException( $this->tableName ); - Debug::error( "Suggestion: $ID not updated: $fields" ); - - return false; - } - self::$log->admin( "Updated Suggestion: $ID" ); - return true; - } - - public function approve( $ID ) { - if ( empty( self::$log ) ) { - self::$log = new Log; - } - if ( !Check::id( $ID ) ) { - Debug::info( 'Suggestion: illegal ID.' ); - return false; - } - $fields = [ - 'approved' => 'true', - 'approvedOn' => time(), - 'approvedBy' => App::$activeUser->ID, - ]; - if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - new CustomException( $this->tableName ); - Debug::error( "Suggestion: $ID not Rejected: $fields" ); - return false; - } - self::$log->admin( "Suggestion Rejected: $ID" ); - return true; - } - - public function reject( $ID ) { - if ( empty( self::$log ) ) { - self::$log = new Log; - } - if ( !Check::id( $ID ) ) { - Debug::info( 'Suggestion: illegal ID.' ); - return false; - } - $fields = [ - 'approved' => 'false', - 'approvedOn' => null, - 'approvedBy' => null, - ]; - if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - new CustomException( $this->tableName ); - Debug::error( "Suggestion: $ID not Approved: $fields" ); - return false; - } - self::$log->admin( "Suggestion Approved: $ID" ); - return true; - } - - public function recent( $approvedOnly = true, $limit = 0 ) { - if ( true === $approvedOnly ) { - $where = ['approved', '=', 'true']; - } else { - $where = ['ID', '>', '0']; - } - if ( empty( $limit ) ) { - $data = self::$db->getPaginated( $this->tableName, $where, 'suggestedOn', 'DESC' ); - } else { - $data = self::$db->get( $this->tableName, $where, 'suggestedOn', 'DESC', [0, $limit] ); - } - if ( !$data->count() ) { - Debug::info( 'No Suggestions found.' ); - return false; - } - return $this->filter( $data->results() ); - } -} diff --git a/app/plugins/suggestions/plugin.php b/app/plugins/suggestions/plugin.php deleted file mode 100644 index f12e737..0000000 --- a/app/plugins/suggestions/plugin.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins; - -use ReflectionClass; -use TheTempusProject\Classes\Installer; -use TheTempusProject\Houdini\Classes\Navigation; -use TheTempusProject\Classes\Plugin; -use TheTempusProject\TheTempusProject as App; - -class Suggestions extends Plugin { - public $pluginName = 'TP Suggest'; - public $pluginAuthor = 'JoeyK'; - public $pluginWebsite = 'https://TheTempusProject.com'; - public $modelVersion = '1.0'; - public $pluginVersion = '3.0'; - public $pluginDescription = 'A simple plugin which adds a site wide suggestion system.'; - public $permissionMatrix = [ - 'suggest' => [ - 'pretty' => 'Can create suggestions', - 'default' => false, - ], - ]; - public $admin_links = [ - [ - 'text' => ' Suggestions', - 'url' => '{ROOT_URL}admin/suggestions', - ], - ]; - public $footer_links = [ - [ - 'text' => 'Suggestions', - 'url' => '{ROOT_URL}suggestions/index', - 'filter' => 'loggedin', - ], - ]; -} diff --git a/app/plugins/suggestions/views/admin/edit.html b/app/plugins/suggestions/views/admin/edit.html deleted file mode 100644 index 8346454..0000000 --- a/app/plugins/suggestions/views/admin/edit.html +++ /dev/null @@ -1,22 +0,0 @@ -
    -
    -
    - - -
    -
    -
    -
    - - -
    -
    -
    -
    - - -
    -
    - - -
    \ No newline at end of file diff --git a/app/plugins/suggestions/views/admin/list.html b/app/plugins/suggestions/views/admin/list.html deleted file mode 100644 index 7e11444..0000000 --- a/app/plugins/suggestions/views/admin/list.html +++ /dev/null @@ -1,56 +0,0 @@ -Suggestions -{PAGINATION} -
    - - - - - - - - - - - - - - - - - {LOOP} - - - - - - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    IDSuggestionSuggested OnSuggested ByApprovedApproved OnApproved By - -
    {ID}{suggestion}{DTC}{suggestedOn}{/DTC}{submittedBy}{approved}{DTC}{approvedOn}{/DTC}{approvedByName} - - - - - - - -
    - No results to show. -
    - -
    -
    -clear all \ No newline at end of file diff --git a/app/plugins/suggestions/views/admin/view.html b/app/plugins/suggestions/views/admin/view.html deleted file mode 100644 index 0d044b3..0000000 --- a/app/plugins/suggestions/views/admin/view.html +++ /dev/null @@ -1,17 +0,0 @@ -
    -
    -
    -

    Suggestion

    -
    - - {suggestion} - {ADMIN} -
    - Delete - Edit -
    - {/ADMIN} -
    - {COMMENTS} -
    -
    \ No newline at end of file diff --git a/app/plugins/suggestions/views/create.html b/app/plugins/suggestions/views/create.html deleted file mode 100644 index 479bfaa..0000000 --- a/app/plugins/suggestions/views/create.html +++ /dev/null @@ -1,16 +0,0 @@ -
    - Submit a Suggestion -
    - -
    - -
    -
    -
    -
    - -
    -
    - - -
    \ No newline at end of file diff --git a/app/plugins/suggestions/views/edit.html b/app/plugins/suggestions/views/edit.html deleted file mode 100644 index 63d2d70..0000000 --- a/app/plugins/suggestions/views/edit.html +++ /dev/null @@ -1,15 +0,0 @@ -
    -
    - -
    - -
    -
    -
    -
    - -
    -
    - - -
    \ No newline at end of file diff --git a/app/plugins/suggestions/views/list.html b/app/plugins/suggestions/views/list.html deleted file mode 100644 index ee7ac85..0000000 --- a/app/plugins/suggestions/views/list.html +++ /dev/null @@ -1,19 +0,0 @@ -Suggestions -{PAGINATION} -{LOOP} -
    -

    {title}

    -
    - {suggestion} - -
    -
    -{/LOOP} -{ALT} -
    - -
    -{/ALT} -Create \ No newline at end of file diff --git a/app/plugins/suggestions/views/view.html b/app/plugins/suggestions/views/view.html deleted file mode 100644 index c3645b9..0000000 --- a/app/plugins/suggestions/views/view.html +++ /dev/null @@ -1,18 +0,0 @@ -
    -
    -
    -

    {title}

    -
    - - {suggestion} - {ADMIN} -
    - Delete - Edit -
    - {/ADMIN} -
    - {COMMENTS} - {NEWCOMMENT} -
    -
    \ No newline at end of file diff --git a/app/plugins/todo/controllers/api/lists.php b/app/plugins/todo/controllers/api/lists.php deleted file mode 100644 index e02252c..0000000 --- a/app/plugins/todo/controllers/api/lists.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers\Api; - -use TheTempusProject\Models\Tasklists as ListModel; -use TheTempusProject\Classes\ApiController; -use TheTempusProject\Houdini\Classes\Views; - -class Lists extends ApiController { - protected static $lists; - - public function __construct() { - parent::__construct(); - self::$lists = new ListModel; - } - - public function hide( $id = null ) { - $list = self::$lists->get( $id ); - if ( ! $list ) { - $responseType = 'error'; - $response = 'No list found.'; - } else { - $responseType = 'data'; - $response = self::$lists->hide( $id ); - } - Views::view( 'api.response', ['response' => json_encode( [ $responseType => $response ], true )]); - } - - public function delete( $id = null ) { - $list = self::$lists->get( $id ); - if ( ! $list ) { - $responseType = 'error'; - $response = 'No list found.'; - } else { - $responseType = 'data'; - $response = self::$lists->delete( $id ); - } - Views::view( 'api.response', ['response' => json_encode( [ $responseType => $response ], true )]); - } - - public function home( $id = null ) { - $list = self::$lists->get( $id ); - if ( ! $list ) { - $responseType = 'error'; - $response = 'No list found.'; - } else { - $responseType = 'data'; - $response = $list; - } - Views::view( 'api.response', ['response' => json_encode( [ $responseType => $response ], true )]); - } -} diff --git a/app/plugins/todo/controllers/api/tasks.php b/app/plugins/todo/controllers/api/tasks.php deleted file mode 100644 index 0d1f03d..0000000 --- a/app/plugins/todo/controllers/api/tasks.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers\Api; - -use TheTempusProject\Models\Tasks as TaskModel; -use TheTempusProject\Classes\ApiController; -use TheTempusProject\Houdini\Classes\Views; - -class Tasks extends ApiController { - protected static $tasks; - - public function __construct() { - parent::__construct(); - self::$tasks = new TaskModel; - } - - public function complete( $id = null ) { - $task = self::$tasks->get( $id ); - if ( ! $task ) { - $responseType = 'error'; - $response = 'No task found.'; - } else { - $responseType = 'data'; - $response = self::$tasks->complete( $id ); - } - Views::view( 'api.response', ['response' => json_encode( [ $responseType => $response ], true )]); - } - - public function delete( $id = null ) { - $task = self::$tasks->get( $id ); - if ( ! $task ) { - $responseType = 'error'; - $response = 'No task found.'; - } else { - $responseType = 'data'; - $response = self::$tasks->delete( $id ); - } - Views::view( 'api.response', ['response' => json_encode( [ $responseType => $response ], true )]); - } - - public function home( $id = null ) { - $task = self::$tasks->get( $id ); - if ( ! $task ) { - $responseType = 'error'; - $response = 'No task found.'; - } else { - $responseType = 'data'; - $response = $task; - } - Views::view( 'api.response', ['response' => json_encode( [ $responseType => $response ], true )]); - } -} diff --git a/app/plugins/todo/controllers/todo.php b/app/plugins/todo/controllers/todo.php deleted file mode 100644 index 86b5b60..0000000 --- a/app/plugins/todo/controllers/todo.php +++ /dev/null @@ -1,371 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Controllers; - -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Hermes\Functions\Redirect; -use TheTempusProject\Bedrock\Functions\Session; -use TheTempusProject\Houdini\Classes\Issues; -use TheTempusProject\Houdini\Classes\Views; -use TheTempusProject\Classes\Controller; -use TheTempusProject\Classes\Forms; -use TheTempusProject\Houdini\Classes\Forms as FormBuilder; -use TheTempusProject\Models\Tasks; -use TheTempusProject\Models\Tasklists; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Houdini\Classes\Components; -use TheTempusProject\Classes\Config; -use TheTempusProject\Houdini\Classes\Navigation; -use TheTempusProject\Houdini\Classes\Template; - -class Todo extends Controller { - protected static $tasks; - protected static $lists; - protected static $showHidden; - protected static $listView; - - public function __construct() { - parent::__construct(); - if ( !App::$isLoggedIn ) { - Session::flash( 'notice', 'You must be logged in to use this feature.' ); - return Redirect::home(); - } - self::$tasks = new Tasks; - self::$lists = new Tasklists; - self::$title = 'To-Do - {SITENAME}'; - self::$pageDescription = 'On this page you can create and manage tasks and lists.'; - - - if ( Input::exists('includeCompleted') && 'true' == Input::get('includeCompleted') ) { - self::$showHidden = true; - Components::set( 'completedToggleText', 'Hide' ); - Components::set( 'completedToggle', 'false' ); - } else { - self::$showHidden = false; - Components::set( 'completedToggleText', 'Show' ); - Components::set( 'completedToggle', 'true' ); - } - - $taskTabs = Views::simpleView( 'todo.nav.listTabs' ); - if ( stripos( Input::get('url'), 'todo/list' ) !== false ) { - $tabsView = Navigation::activePageSelect( $taskTabs, '/todo/list/', false, true ); - $userListTabs = Views::simpleView('todo.nav.userListTabs', self::$lists->simpleObjectByUser(true) ); - $userListTabsView = Navigation::activePageSelect( $userListTabs, Input::get( 'url' ), false, true ); - } else { - $tabsView = Navigation::activePageSelect( $taskTabs, Input::get( 'url' ), false, true ); - $userListTabsView = ''; - } - Components::set( 'userListTabs', $userListTabsView ); - Views::raw( $tabsView ); - } - public function index() { - Components::set( 'listName', 'All' ); - Components::set( 'listID', '' ); - - $recentlyCompleted = Views::simpleView( 'todo.tasks.list', self::$tasks->recentlyCompleted( 10 ) ); - Components::set( 'recentlyCompleted', $recentlyCompleted ); - - $dailyTasks = Views::simpleView( 'todo.tasks.daily', self::$tasks->dailyTasks( 10 ) ); - Components::set( 'dailyTasks', $dailyTasks ); - - $weeklyTasks = Views::simpleView( 'todo.tasks.weekly', self::$tasks->weeklyTasks( 10 ) ); - Components::set( 'weeklyTasks', $weeklyTasks ); - - $monthlyTasks = Views::simpleView( 'todo.tasks.monthly', self::$tasks->monthlyTasks( 10 ) ); - Components::set( 'monthlyTasks', $monthlyTasks ); - - $yearlyTasks = Views::simpleView( 'todo.tasks.yearly', self::$tasks->yearlyTasks( 10 ) ); - Components::set( 'yearlyTasks', $yearlyTasks ); - - $tasks = Views::simpleView( 'todo.tasks.list', self::$tasks->recent( 10 ) ); - Components::set( 'taskList', $tasks ); - - $lists = Views::simpleView( 'todo.lists.list', self::$lists->recent() ); - Components::set( 'listList', $lists ); - - Views::view( 'todo.dashboard' ); - } - public function daily() { - Views::view( 'todo.tasks.daily', self::$tasks->dailyTasks( 10, self::$showHidden ) ); - } - public function weekly() { - Views::view( 'todo.tasks.weekly', self::$tasks->weeklyTasks( 10, self::$showHidden ) ); - } - public function monthly() { - Views::view( 'todo.tasks.monthly', self::$tasks->monthlyTasks( 10, self::$showHidden ) ); - } - public function yearly() { - Views::view( 'todo.tasks.yearly', self::$tasks->yearlyTasks( 10, self::$showHidden ) ); - } - - /** - * Lists - */ - public function list( $id = 0 ) { - $list = self::$lists->findById( $id ); - if ( $list == false ) { - $lists = self::$lists->recent(); - return Views::view( 'todo.lists.list', $lists ); - } - Components::set( 'listID', $id ); - if ( Input::exists('includeCompleted') && 'true' == Input::get('includeCompleted') ) { - $include_completed = true; - } else { - $include_completed = false; - } - $tasks = self::$tasks->findByListId( $id, $include_completed ); - Components::set( 'listName', $list->title ); - Components::set( 'CONTENT_ID', $id ); - Components::set( 'COMMENT_TYPE', 'tasklist' ); - Views::view( 'todo.tasks.list', $tasks ); - } - public function createList() { - if ( !Input::exists() ) { - return Views::view( 'todo.lists.create' ); - } - if ( !Forms::check( 'createTaskList' ) ) { - Issues::add( 'error', [ 'There was an error creating your task list.' => Check::userErrors() ] ); - return Views::view( 'todo.lists.create' ); - } - if ( !self::$lists->create( Input::post( 'listName' )) ) { - Issues::add( 'error', [ 'There was an error creating your task list.' => Check::userErrors() ] ); - return Views::view( 'todo.lists.create' ); - } - Session::flash( 'success', 'Your Task List has been created.' ); - Redirect::to( 'todo/index' ); - } - public function editList( $id = null ) { - $list = self::$lists->findById( $id ); - if ( $list == false ) { - Issues::add( 'error', 'TaskList not found.' ); - return $this->index(); - } - if ( !Input::exists() ) { - return Views::view( 'todo.lists.edit', $list ); - } - if ( !Forms::check( 'editTaskList' ) ) { - Issues::add( 'error', [ 'There was an error with your todo task.' => Check::userErrors() ] ); - return Views::view( 'todo.lists.edit', $list ); - } - if ( !self::$lists->update( $id, Input::post( 'listName' ) ) ) { - Issues::add( 'error', [ 'There was an error with your todo task.' => Check::userErrors() ] ); - return Views::view( 'todo.lists.edit', $list ); - } - Session::flash( 'success', 'Your Task List has been saved.' ); - Redirect::to( 'todo/list/' . $id ); - } - public function deleteList( $id = null ) { - $list = self::$lists->findById( $id ); - if ( $list == false ) { - Issues::add( 'error', 'TaskList not found.' ); - return $this->index(); - } - if ( $list->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this calendar.' ); - return $this->index(); - } - $result = self::$lists->delete( $id ); - if ( !$result ) { - Issues::add( 'error', 'There was an error deleting the list(s)' ); - } else { - Issues::add( 'success', 'List deleted' ); - } - return $this->index(); - } - - /** - * Tasks - */ - public function task( $id = null ) { - $task = self::$tasks->findById( $id ); - if ( $task == false ) { - $tasks = self::$tasks->recent(); - return Views::view( 'todo.tasks.list', $tasks ); - } - Components::set( 'CONTENT_ID', $id ); - Components::set( 'COMMENT_TYPE', 'task' ); - Views::view( 'todo.tasks.view', $task ); - } - public function createTask( $id = null ) { - if ( in_array( $id, self::$tasks->repeatOptions ) ) { - $repeat = $id; - $id = 'non'; - } else { - $repeat = 'none'; - $id = $id; - } - - // @todo need to make this change if it 'id' is actually a repeats value - $select = FormBuilder::getFormFieldHtml( - 'listID', - 'Task List', - 'select', - $id, - self::$lists->getSimpleList(true), - ); - Components::set( 'listSelect', $select ); - - $repeatSelect = FormBuilder::getFormFieldHtml( 'repeats', 'Frequency', 'select', $repeat, self::$tasks->repeatOptions ); - Components::set( 'repeatSelect', $repeatSelect ); - if ( !Input::exists() ) { - return Views::view( 'todo.tasks.create' ); - } - if ( !Forms::check( 'createTask' ) ) { - Issues::add( 'error', [ 'There was an error with your form.' => Check::userErrors() ] ); - return Views::view( 'todo.tasks.create' ); - } - if ( !self::$tasks->create( Input::post( 'task' ), 'false', Input::post( 'dueDate' ), Input::post( 'listID' ), Input::post( 'repeats' ) ) ) { - Issues::add( 'error', [ 'There was an error with your todo task.' => Check::userErrors() ] ); - return Views::view( 'todo.tasks.create' ); - } - Session::flash( 'success', 'Your Task has been created.' ); - if ( Input::exists( 'listID' ) ) { - Redirect::to( 'todo/list/' . Input::post( 'listID' ) ); - } else { - Redirect::to( 'todo/index' ); - } - } - public function editTask( $id = null ) { - $task = self::$tasks->findById( $id ); - if ( $task == false ) { - Issues::add( 'error', 'Task not found.' ); - return $this->index(); - } - if ( $task->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this task.' ); - return $this->index(); - } - - $select = FormBuilder::getFormFieldHtml( - 'listID', - 'Task List', - 'select', - $task->listID, - self::$lists->getSimpleList(true), - ); - Components::set( 'listSelect', $select ); - - $repeatSelect = FormBuilder::getFormFieldHtml( 'repeats', 'Frequency', 'select', $task->repeats, self::$tasks->repeatOptions ); - Components::set( 'repeatSelect', $repeatSelect ); - - if ( !Input::exists( 'submit' ) ) { - return Views::view( 'todo.tasks.edit', $task ); - } - if ( !Forms::check( 'editTask' ) ) { - Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] ); - return Views::view( 'todo.tasks.edit', $task ); - } - if ( self::$tasks->update( $id, Input::post( 'task' ), $task->completed, Input::post( 'dueDate' ), Input::post( 'listID' ), Input::post( 'repeats' ) ) ) { - Session::flash( 'success', 'Task updated' ); - } else { - return Views::view( 'todo.tasks.edit', self::$tasks->findById( $data ) ); - } - if ( !empty( $task->listID ) ) { - Redirect::to( 'todo/list/' . $task->listID ); - } else { - Redirect::to( 'todo/index' ); - } - } - public function deleteTask( $id = null ) { - $task = self::$tasks->findById( $id ); - if ( $task == false ) { - Issues::add( 'error', 'Task not found.' ); - return $this->index(); - } - if ( $task->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this task.' ); - return $this->index(); - } - $result = self::$tasks->delete( $id ); - if ( !$result ) { - Session::flash( 'error', 'There was an error deleting the task(s)' ); - } else { - Session::flash( 'success', 'Task deleted' ); - } - if ( !empty( $task->listID ) ) { - Redirect::to( 'todo/list/' . $task->listID ); - } else { - Redirect::to( 'todo/index' ); - } - } - public function duplicateTask( $id = null ) { - $task = self::$tasks->findById( $id ); - if ( $task == false ) { - Issues::add( 'error', 'Task not found.' ); - return $this->index(); - } - if ( $task->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this task.' ); - return $this->index(); - } - if ( $task->repeats != 'none' ) { - Issues::add( 'error', 'You cannot duplicate a repeating task.' ); - return $this->index(); - } - if ( ! self::$tasks->duplicate( $id ) ) { - Session::flash( 'error', [ 'There was an error duplicating your todo task.'] ); - } else { - Session::flash( 'success', 'Your Task has been duplicated.' ); - } - if ( !empty( $task->listID ) ) { - Redirect::to( 'todo/list/' . $task->listID ); - } else { - Redirect::to( 'todo/index' ); - } - } - public function completeTask( $id = null ) { - $task = self::$tasks->findById( $id ); - if ( $task == false ) { - Issues::add( 'error', 'Task not found.' ); - return $this->index(); - } - if ( $task->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this task.' ); - return $this->index(); - } - $result = self::$tasks->complete( $id ); - if ( !$result ) { - Session::flash( 'error', 'There was an error completing the task(s)' ); - } else { - Session::flash( 'success', 'Task completed' ); - } - if ( !empty( $task->listID ) ) { - Redirect::to( 'todo/list/' . $task->listID ); - } else { - Redirect::to( 'todo/index' ); - } - } - public function incompleteTask( $id = null ) { - $task = self::$tasks->findById( $id ); - if ( $task == false ) { - Issues::add( 'error', 'Task not found.' ); - return $this->index(); - } - if ( $task->createdBy != App::$activeUser->ID ) { - Issues::add( 'error', 'You do not have permission to modify this task.' ); - return $this->index(); - } - $result = self::$tasks->incomplete( $id ); - if ( ! $result ) { - Session::flash( 'error', 'There was an error un-completing the task(s)' ); - } else { - Session::flash( 'success', 'Task un-completed' ); - } - if ( !empty( $task->listID ) ) { - Redirect::to( 'todo/list/' . $task->listID ); - } else { - Redirect::to( 'todo/index' ); - } - } -} \ No newline at end of file diff --git a/app/plugins/todo/forms.php b/app/plugins/todo/forms.php deleted file mode 100644 index ba209bb..0000000 --- a/app/plugins/todo/forms.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins\Todo; - -use TheTempusProject\Bedrock\Functions\Input; -use TheTempusProject\Classes\Forms; - -class TodoForms extends Forms { - /** - * Adds these functions to the form list. - */ - public function __construct() { - self::addHandler( 'createTask', __CLASS__, 'createTask' ); - self::addHandler( 'editTask', __CLASS__, 'editTask' ); - self::addHandler( 'createTaskList', __CLASS__, 'createTaskList' ); - self::addHandler( 'editTaskList', __CLASS__, 'editTaskList' ); - } - - /** - * Validates the bug tracker create form. - * - * @return {bool} - */ - public static function createTask() { - if ( ! empty(Input::post( 'dueDate' )) && !self::date( Input::post( 'dueDate' ) ) ) { - self::addUserError( 'Invalid Date.' . Input::post( 'dueDate' ) ); - return false; - } - if ( ! empty( Input::post( 'listID' ) ) && !self::id( Input::post( 'listID' ) ) ) { - self::addUserError( 'Invalid Date.' . Input::post( 'dueDate' ) ); - return false; - } - if ( !Input::exists( 'task' ) ) { - self::addUserError( 'You must specify a task' ); - return false; - } - // if ( !self::token() ) { - // return false; - // } - return true; - } - - public static function createTaskList() { - if ( !Input::exists( 'listName' ) ) { - self::addUserError( 'You must specify a title' ); - return false; - } - // if ( !self::token() ) { - // return false; - // } - return true; - } - - public static function editTaskList() { - if ( !Input::exists( 'listName' ) ) { - self::addUserError( 'You must specify a title' ); - return false; - } - // if ( !self::token() ) { - // return false; - // } - return true; - } - - /** - * Validates the bug tracker create form. - * - * @return {bool} - */ - public static function editTask() { - if ( !empty(Input::post( 'dueDate' )) && !self::date( Input::post( 'dueDate' ) ) ) { - self::addUserError( 'Invalid Date.' . Input::post( 'dueDate' ) ); - return false; - } - if ( !Input::exists( 'task' ) ) { - self::addUserError( 'You must specify a task' ); - return false; - } - // if ( !self::token() ) { - // return false; - // } - return true; - } -} - -new TodoForms; diff --git a/app/plugins/todo/models/tasklists.php b/app/plugins/todo/models/tasklists.php deleted file mode 100644 index d922adc..0000000 --- a/app/plugins/todo/models/tasklists.php +++ /dev/null @@ -1,199 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Bedrock\Classes\CustomException; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\Plugins\Bugreport as Plugin; -use TheTempusProject\TheTempusProject as App; - -class Tasklists extends DatabaseModel { - public $tableName = 'tasklists'; - public $databaseMatrix = [ - [ 'title', 'varchar', '128' ], - [ 'active', 'varchar', '5' ], - [ 'createdAt', 'int', '10' ], - [ 'color', 'varchar', '48' ], - [ 'createdBy', 'int', '11' ], - ]; - public $plugin; - - /** - * The model constructor. - */ - public function __construct() { - parent::__construct(); - $this->plugin = new Plugin; - } - - /** - * This function parses the bug reports description and - * separates it into separate keys in the array. - * - * @param array $data - The data being parsed. - * - * @return array - */ - public function filter( $data, $params = [] ) { - foreach ( $data as $instance ) { - if ( !is_object( $instance ) ) { - $instance = $data; - $end = true; - } - $instance->submittedBy = self::$user->getUsername( $instance->createdBy ); - $out[] = $instance; - if ( !empty( $end ) ) { - $out = $out[0]; - break; - } - } - return $out; - } - - /** - * Logs a Bug Report form. - * - * @param int $ID the user ID submitting the form - * @param string $url the url - * @param string $o_url the original url - * @param int $repeat is repeatable? - * @param string $description_ description of the event. - * - * @return null - */ - public function create( $title, $active = 'true' ) { - if ( !$this->plugin->checkEnabled() ) { - Debug::info( 'ToDo Plugin is disabled in the config.' ); - return false; - } - $fields = [ - 'createdBy' => App::$activeUser->ID, - 'createdAt' => time(), - 'title' => $title, - 'active' => $active, - ]; - if ( !self::$db->insert( $this->tableName, $fields ) ) { - new CustomException( $this->tableName ); - return false; - } - return self::$db->lastId(); - } - - public function update( $ID, $title, $active = 'true' ) { - if ( !$this->plugin->checkEnabled() ) { - Debug::info( 'ToDo Plugin is disabled in the config.' ); - return false; - } - if ( !Check::id( $ID ) ) { - Debug::info( 'ToDo List: illegal ID.' ); - return false; - } - $data = $this->findById( $ID ); - if ( $data == false ) { - Debug::info( 'ToDo List: not found.' ); - return false; - } - $fields = [ - 'title' => $title, - 'active' => $active, - ]; - if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - new CustomException( $this->tableName ); - Debug::error( "ToDo List: $ID not updated: $fields" ); - return false; - } - return true; - } - - public function activate( $ID ) { - if ( !Check::id( $ID ) ) { - Debug::info( 'TaskList: illegal ID.' ); - return false; - } - $fields = [ - 'active' => 'true', - ]; - if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - new CustomException( $this->tableName ); - Debug::error( "TaskList: $ID not activated: $fields" ); - return false; - } - return true; - } - - public function hide( $ID ) { - if ( !Check::id( $ID ) ) { - Debug::info( 'TaskList: illegal ID.' ); - return false; - } - $fields = [ - 'active' => 'false', - ]; - if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - new CustomException( $this->tableName ); - Debug::error( "TaskList: $ID not Hidden: $fields" ); - return false; - } - return true; - } - - public function recent( $limit = null ) { - $where = ['createdBy', '=', App::$activeUser->ID]; - $data = self::$db->get( $this->tableName, $where, 'createdAt', 'DESC', [0, $limit] ); - if ( !$data->count() ) { - Debug::info( 'No tasks found.' ); - - return []; - } - return $this->filter( $data->results() ); - } - - public function getSimpleList( $includeDefault = false ) { - $out = []; - if ( $includeDefault === true ) { - $out[ 'No List' ] = 0; - } - $lists = self::$db->get( $this->tableName, [ 'createdBy', '=', App::$activeUser->ID ] ); - if ( !$lists->count() ) { - Debug::warn( 'Could not find any ' . $this->tableName ); - return $out; - } - $taskLists = $lists->results(); - foreach ( $taskLists as &$list ) { - $out[ $list->title ] = $list->ID; - } - return $out; - } - - public function simpleObjectByUser() { - $whereClause = ['createdBy', '=', App::$activeUser->ID]; - $lists = self::$db->get( $this->tableName, $whereClause ); - if ( !$lists->count() ) { - Debug::warn( 'Could not find any tasklists' ); - return false; - } - - $taskLists = $lists->results(); - $out = []; - foreach ( $taskLists as &$list ) { - $obj = new \stdClass(); - $obj->title = $list->title; - $obj->ID = $list->ID; - $out[] = $obj; - } - return $out; - } -} diff --git a/app/plugins/todo/models/tasks.php b/app/plugins/todo/models/tasks.php deleted file mode 100644 index 50a6863..0000000 --- a/app/plugins/todo/models/tasks.php +++ /dev/null @@ -1,392 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Models; - -use TheTempusProject\Bedrock\Functions\Check; -use TheTempusProject\Bedrock\Classes\Config; -use TheTempusProject\Canary\Bin\Canary as Debug; -use TheTempusProject\Bedrock\Classes\CustomException; -use TheTempusProject\Classes\DatabaseModel; -use TheTempusProject\Plugins\Bugreport as Plugin; -use TheTempusProject\TheTempusProject as App; -use TheTempusProject\Bedrock\Functions\Date; -use TheTempusProject\Houdini\Classes\Template; - -class Tasks extends DatabaseModel { - public $tableName = 'tasks'; - public $databaseMatrix = [ - [ 'task', 'varchar', '128' ], - [ 'completed', 'varchar', '5' ], - [ 'completedAt', 'int', '10' ], - [ 'completedBy', 'int', '10' ], - [ 'dueDate', 'int', '10' ], - [ 'createdAt', 'int', '10' ], - [ 'createdBy', 'int', '11' ], - [ 'listID', 'int', '11' ], - [ 'color', 'varchar', '48' ], - [ 'parentID', 'int', '11' ], - [ 'repeats', 'varchar', '48' ], - ]; - public $plugin; - public $repeatOptions = [ - 'Does Not Repeat' => 'none', - 'Every Day' => 'daily', - 'Every Week' => 'weekly', - 'Every Month' => 'monthly', - 'Every Year' => 'yearly', - ]; - - public function __construct() { - parent::__construct(); - $this->plugin = new Plugin; - } - - public function filter( $data, $params = [] ) { - foreach ( $data as $instance ) { - if ( !is_object( $instance ) ) { - $instance = $data; - $end = true; - } - - if ( 'true' == $instance->completed ) { - $url = Template::parse( - '' - ); - $instance->completedUrl = $url; - } else { - $url = Template::parse( - '' - ); - $instance->completedUrl = $url; - } - - $out[] = $instance; - if ( !empty( $end ) ) { - $out = $out[0]; - break; - } - } - return $out; - } - - public function create( $task, $completed = 'false', $dueDate = null, $list = 0, $repeats = 'none') { - if ( !$this->plugin->checkEnabled() ) { - Debug::info( 'ToDo Plugin is disabled in the config.' ); - return false; - } - $fields = [ - 'task' => $task, - 'completed' => $completed, - 'listID' => intval($list), - 'repeats' => $repeats, - 'createdBy' => App::$activeUser->ID, - 'createdAt' => time(), - ]; - if ( !empty( $dueDate ) ) { - $fields['dueDate'] = strtotime($dueDate); - } - if ( 'false' !== $completed ) { - $fields['completedBy'] = App::$activeUser->ID; - $fields['completedAt'] = time(); - } else { - $fields['completedAt'] = '0'; - } - if ( !self::$db->insert( $this->tableName, $fields ) ) { - new CustomException( $this->tableName ); - return false; - } - return self::$db->lastId(); - } - public function update( $ID, $task, $completed = "false", $dueDate = null, $list = 0, $repeats = 'none' ) { - if ( !Check::id( $ID ) ) { - Debug::info( 'ToDo Task: illegal ID.' ); - return false; - } - $data = $this->findById( $ID ); - if ( $data == false ) { - Debug::info( 'ToDo Task: not found.' ); - return false; - } - $fields = [ - 'task' => $task, - 'completed' => $completed, - 'listID' => intval($list), - 'repeats' => $repeats, - ]; - if ( !empty( $dueDate ) ) { - $fields['dueDate'] = strtotime($dueDate); - } - if ( 'false' !== $completed && 'false' === $data->completed ) { - $fields['completedBy'] = App::$activeUser->ID; - $fields['completedAt'] = time(); - } - if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - new CustomException( $this->tableName ); - Debug::error( "ToDo: $ID not updated: $fields" ); - return false; - } - return true; - } - public function setActive( $ID ) { - if ( !Check::id( $ID ) ) { - Debug::info( 'ToDo Task: illegal ID.' ); - return false; - } - $fields = [ - 'completed' => 'false', - 'completedAt' => '0', - 'completedBy' => null, - ]; - if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - new CustomException( $this->tableName ); - Debug::error( "Task: $ID not Activated: $fields" ); - return false; - } - return true; - } - public function recent( $limit = null, $include_completed = false ) { - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND', 'ID', '>', '0']; - if ( false == $include_completed ) { - $whereClause = array_merge( $whereClause, [ - 'AND', 'completed', '!=', 'true' - ] ); - } - if ( empty( $limit ) ) { - $data = self::$db->getPaginated( $this->tableName, $whereClause, 'createdAt', 'DESC' ); - } else { - $data = self::$db->get( $this->tableName, $whereClause, 'createdAt', 'DESC', [0, $limit] ); - } - if ( !$data->count() ) { - Debug::info( 'No tasks found.' ); - - return false; - } - return $this->filter( $data->results() ); - } - public function recentlyCompleted( $limit = null ) { - $whereClause = ['createdBy', '=', App::$activeUser->ID, 'AND', 'completed', '=', 'true']; - if ( empty( $limit ) ) { - $data = self::$db->getPaginated( $this->tableName, $whereClause, 'completedAt', 'DESC' ); - } else { - $data = self::$db->get( $this->tableName, $whereClause, 'completedAt', 'DESC', [0, $limit] ); - } - if ( !$data->count() ) { - Debug::info( 'No tasks found.' ); - return false; - } - return $this->filter( $data->results() ); - } - public function dailyTasks( $limit = null, $include_completed = false ) { - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND', 'repeats', '=', 'daily' ]; - if ( false == $include_completed ) { - $whereClause = array_merge( $whereClause, [ - // 'AND', 'completedAt', '<', Date::getDayStartTimestamp( '1735736400000', true ), - 'AND', 'completedAt', '<', Date::getDayStartTimestamp( time(), true ), - ] ); - } - if ( empty( $limit ) ) { - $data = self::$db->getPaginated( $this->tableName, $whereClause, 'createdAt', 'DESC' ); - } else { - $data = self::$db->get( $this->tableName, $whereClause, 'createdAt', 'DESC', [0, $limit] ); - } - if ( !$data->count() ) { - Debug::info( 'No tasks found.' ); - return false; - } - return $this->filter( $data->results() ); - } - public function weeklyTasks( $limit = null, $include_completed = false ) { - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND', 'repeats', '=', 'weekly' ]; - if ( false == $include_completed ) { - $whereClause = array_merge( $whereClause, [ - 'AND', 'completedAt', '<', Date::getWeekStartTimestamp( time(), true ), - ] ); - } - if ( empty( $limit ) ) { - $data = self::$db->getPaginated( $this->tableName, $whereClause, 'createdAt', 'DESC' ); - } else { - $data = self::$db->get( $this->tableName, $whereClause, 'createdAt', 'DESC', [0, $limit] ); - } - if ( !$data->count() ) { - Debug::info( 'No tasks found.' ); - - return false; - } - return $this->filter( $data->results() ); - } - public function monthlyTasks( $limit = null, $include_completed = false ) { - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND', 'repeats', '=', 'monthly' ]; - if ( false == $include_completed ) { - $whereClause = array_merge( $whereClause, [ - 'AND', 'completedAt', '<', Date::getMonthStartTimestamp( time(), true ), - ] ); - } - if ( empty( $limit ) ) { - $data = self::$db->getPaginated( $this->tableName, $whereClause, 'createdAt', 'DESC' ); - } else { - $data = self::$db->get( $this->tableName, $whereClause, 'createdAt', 'DESC', [0, $limit] ); - } - if ( !$data->count() ) { - Debug::info( 'No tasks found.' ); - - return false; - } - return $this->filter( $data->results() ); - } - public function yearlyTasks( $limit = null, $include_completed = false ) { - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND', 'repeats', '=', 'yearly' ]; - if ( false == $include_completed ) { - $whereClause = array_merge( $whereClause, [ - 'AND', 'completedAt', '<', Date::getYearStartTimestamp( time(), true ), - ] ); - } - if ( empty( $limit ) ) { - $data = self::$db->getPaginated( $this->tableName, $whereClause, 'createdAt', 'DESC' ); - } else { - $data = self::$db->get( $this->tableName, $whereClause, 'createdAt', 'DESC', [ 0, $limit ] ); - } - if ( !$data->count() ) { - Debug::info( 'No tasks found.' ); - - return false; - } - return $this->filter( $data->results() ); - } - public function findByListId( $id, $include_completed = false ) { - $data = []; - if ( !Check::id( $id ) ) { - Debug::warn( "$this->tableName findByListId: illegal ID: $id" ); - return $data; - } - $whereClause = [ 'createdBy', '=', App::$activeUser->ID, 'AND' ]; - $whereClause = array_merge( $whereClause, [ - 'listID', '=', $id, - ] ); - if ( false == $include_completed ) { - $whereClause = array_merge( $whereClause, [ - 'AND', 'completed', '!=', 'true' - ] ); - } - $tasks = self::$db->get( $this->tableName, $whereClause ); - if ( ! $tasks->count() ) { - Debug::info( 'No ' . $this->tableName . ' data found.' ); - return []; - } - return $this->filter( $tasks->results() ); - } - public function duplicate( $ID, $completed = 'false' ) { - if ( ! Check::id( $ID ) ) { - Debug::info( 'ToDo Task: illegal ID.' ); - return false; - } - $task = $this->findById( $ID ); - if ( $task == false ) { - Debug::info( 'ToDo Task: not found.' ); - return false; - } - return $this->create( $task->task, $completed, $task->dueDate, $task->listID ); - } - public function complete( $ID ) { - if ( !Check::id( $ID ) ) { - Debug::info( 'ToDo Task: illegal ID.' ); - return false; - } - $data = $this->findById( $ID ); - if ( $data == false ) { - Debug::info( 'ToDo Task: not found.' ); - return false; - } - if ( 'none' == $data->repeats ) { - $completed = 'true'; - $completedBy = App::$activeUser->ID; - } else { - $completed = 'false'; - $completedBy = $data->completedBy; - $this->duplicate( $data->ID, 'true' ); - } - $fields = [ - 'completed' => $completed, - 'completedAt' => time(), - 'completedBy' => $completedBy, - ]; - if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - new CustomException( $this->tableName ); - Debug::error( "Task: $ID not Completed: $fields" ); - return false; - } - return true; - } - public function incomplete( $ID ) { - if ( !Check::id( $ID ) ) { - Debug::info( 'ToDo Task: illegal ID.' ); - return false; - } - $data = $this->findById( $ID ); - if ( $data == false ) { - Debug::info( 'ToDo Task: not found.' ); - return false; - } - if ( 'none' != $data->repeats ) { - // this should not be possible as completing a repeating task duplicates it as a completed normal task - Debug::info( 'There was an error with your request' ); - return false; - } - $fields = [ - 'completed' => 'false', - 'completedAt' => '0', - 'completedBy' => null, - ]; - if ( !self::$db->update( $this->tableName, $ID, $fields ) ) { - new CustomException( $this->tableName ); - Debug::error( "Task: $ID not Completed: $fields" ); - return false; - } - return true; - } - private function isTaskCompleted( $repeats, $completedAt ) { - if ( ! intval( $completedAt ) > 0 ) { - return false; - } - switch ($repeats) { - case 'none': - return true; - case 'daily': - $start = Date::getDayStartTimestamp( time(), true ); - if ( $completedAt > $start ) { - return true; - } - return false; - case 'weekly': - $start = Date::getWeekStartTimestamp( time(), true ); - if ( $completedAt > $start ) { - return true; - } - return false; - case 'monthly': - $start = Date::getMonthStartTimestamp( time(), true ); - if ( $completedAt > $start ) { - return true; - } - return false; - case 'yearly': - $start = Date::getYearStartTimestamp( time(), true ); - if ( $completedAt > $start ) { - return true; - } - return false; - default: - return true; - } - return false; - } -} \ No newline at end of file diff --git a/app/plugins/todo/plugin.php b/app/plugins/todo/plugin.php deleted file mode 100644 index a15cded..0000000 --- a/app/plugins/todo/plugin.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @link https://TheTempusProject.com - * @license https://opensource.org/licenses/MIT [MIT LICENSE] - */ -namespace TheTempusProject\Plugins; - -use TheTempusProject\Classes\Plugin; - -class Todo extends Plugin { - public $pluginName = 'TP ToDo'; - public $pluginAuthor = 'JoeyK'; - public $pluginWebsite = 'https://TheTempusProject.com'; - public $modelVersion = '1.0'; - public $pluginVersion = '3.0'; - public $pluginDescription = 'A simple plugin which adds a site wide to-do list.'; - public $permissionMatrix = [ - 'createTas' => [ - 'pretty' => 'Can create todo items', - 'default' => false, - ], - 'createList' => [ - 'pretty' => 'Can create todo lists', - 'default' => false, - ], - ]; - public $main_links = [ - [ - 'text' => 'To-Do', - 'url' => '{ROOT_URL}todo/index/', - 'filter' => 'loggedin', - ], - ]; -} diff --git a/app/plugins/todo/views/dashboard.html b/app/plugins/todo/views/dashboard.html deleted file mode 100644 index c522894..0000000 --- a/app/plugins/todo/views/dashboard.html +++ /dev/null @@ -1,36 +0,0 @@ - - -
    -
    -

    Recently Completed

    - {recentlyCompleted} -
    -
    -

    Daily Tasks

    - {dailyTasks} -
    -
    -

    Weekly Tasks

    - {weeklyTasks} -
    -
    -
    -
    -

    Monthly Tasks

    - {monthlyTasks} -
    -
    -

    Yearly Tasks

    - {yearlyTasks} -
    -
    -
    -

    Task Lists

    -
    - {listList} -
    -

    Recently Created Tasks

    -
    - {taskList} -
    -
    \ No newline at end of file diff --git a/app/plugins/todo/views/lists/create.html b/app/plugins/todo/views/lists/create.html deleted file mode 100644 index 33a55f5..0000000 --- a/app/plugins/todo/views/lists/create.html +++ /dev/null @@ -1,19 +0,0 @@ -New Task List -{BREADCRUMB} -
    - -
    -
    - -
    - -
    -
    -
    - -
    -
    -
    -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/todo/views/lists/edit.html b/app/plugins/todo/views/lists/edit.html deleted file mode 100644 index 03a0f70..0000000 --- a/app/plugins/todo/views/lists/edit.html +++ /dev/null @@ -1,14 +0,0 @@ -
    - Edit Task List - {BREADCRUMB} -
    -
    - -
    - -
    -
    -
    - -
    -
    \ No newline at end of file diff --git a/app/plugins/todo/views/lists/list.html b/app/plugins/todo/views/lists/list.html deleted file mode 100644 index 4b12f09..0000000 --- a/app/plugins/todo/views/lists/list.html +++ /dev/null @@ -1,32 +0,0 @@ -
    -
    - - - - - - - - - - - {LOOP} - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    List Name
    {title}
    - No Task Lists -
    - New List -
    -
    \ No newline at end of file diff --git a/app/plugins/todo/views/nav/listTabs.html b/app/plugins/todo/views/nav/listTabs.html deleted file mode 100644 index c64e327..0000000 --- a/app/plugins/todo/views/nav/listTabs.html +++ /dev/null @@ -1,9 +0,0 @@ - -{userListTabs} \ No newline at end of file diff --git a/app/plugins/todo/views/nav/userListTabs.html b/app/plugins/todo/views/nav/userListTabs.html deleted file mode 100644 index f97d99e..0000000 --- a/app/plugins/todo/views/nav/userListTabs.html +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/app/plugins/todo/views/tasks/create.html b/app/plugins/todo/views/tasks/create.html deleted file mode 100644 index fc35ca5..0000000 --- a/app/plugins/todo/views/tasks/create.html +++ /dev/null @@ -1,25 +0,0 @@ -New Task -{BREADCRUMB} -
    - - {listSelect} -
    - -
    - -
    -
    - {repeatSelect} -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/app/plugins/todo/views/tasks/daily.html b/app/plugins/todo/views/tasks/daily.html deleted file mode 100644 index 9390d1c..0000000 --- a/app/plugins/todo/views/tasks/daily.html +++ /dev/null @@ -1,35 +0,0 @@ -
    -
    - - - - - - - - - - - - {LOOP} - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    TaskDue
    {task}{DTC}{dueDate}{/DTC}{completedUrl}
    - No Tasks -
    - New Task - {completedToggleText} Completed -
    -
    \ No newline at end of file diff --git a/app/plugins/todo/views/tasks/edit.html b/app/plugins/todo/views/tasks/edit.html deleted file mode 100644 index 896fc90..0000000 --- a/app/plugins/todo/views/tasks/edit.html +++ /dev/null @@ -1,20 +0,0 @@ -Edit Task -{BREADCRUMB} -
    - {listSelect} -
    - -
    - -
    -
    - {repeatSelect} -
    - -
    - -
    -
    - -
    -
    \ No newline at end of file diff --git a/app/plugins/todo/views/tasks/list.html b/app/plugins/todo/views/tasks/list.html deleted file mode 100644 index 907b953..0000000 --- a/app/plugins/todo/views/tasks/list.html +++ /dev/null @@ -1,37 +0,0 @@ -
    -
    - - - - - - - - - - - - - {LOOP} - - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    TaskDue
    {task}{DTC}{dueDate}{/DTC}{completedUrl}
    - No Tasks -
    - New Task - {completedToggleText} Completed -
    -
    \ No newline at end of file diff --git a/app/plugins/todo/views/tasks/monthly.html b/app/plugins/todo/views/tasks/monthly.html deleted file mode 100644 index 963a506..0000000 --- a/app/plugins/todo/views/tasks/monthly.html +++ /dev/null @@ -1,35 +0,0 @@ -
    -
    - - - - - - - - - - - - {LOOP} - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    TaskDue
    {task}{DTC}{dueDate}{/DTC}
    - No Tasks -
    - New Task - {completedToggleText} Completed -
    -
    \ No newline at end of file diff --git a/app/plugins/todo/views/tasks/view.html b/app/plugins/todo/views/tasks/view.html deleted file mode 100644 index 1fa261c..0000000 --- a/app/plugins/todo/views/tasks/view.html +++ /dev/null @@ -1 +0,0 @@ -i don't think this file should ever really be reached normally \ No newline at end of file diff --git a/app/plugins/todo/views/tasks/weekly.html b/app/plugins/todo/views/tasks/weekly.html deleted file mode 100644 index 88ddcd8..0000000 --- a/app/plugins/todo/views/tasks/weekly.html +++ /dev/null @@ -1,35 +0,0 @@ -
    -
    - - - - - - - - - - - - {LOOP} - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    TaskDue
    {task}{DTC}{dueDate}{/DTC}
    - No Tasks -
    - New Task - {completedToggleText} Completed -
    -
    \ No newline at end of file diff --git a/app/plugins/todo/views/tasks/yearly.html b/app/plugins/todo/views/tasks/yearly.html deleted file mode 100644 index c505d44..0000000 --- a/app/plugins/todo/views/tasks/yearly.html +++ /dev/null @@ -1,35 +0,0 @@ -
    -
    - - - - - - - - - - - - {LOOP} - - - - - - - - {/LOOP} - {ALT} - - - - {/ALT} - -
    TaskDue
    {task}{DTC}{dueDate}{/DTC}
    - No Tasks -
    - New Task - {completedToggleText} Completed -
    -
    \ No newline at end of file