Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

new class for interacting with posts #153

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
715e132
new class for interacting with posts
TamaroWalter Jun 13, 2023
6eece3e
WIP: class diagram for new structure
TamaroWalter Jun 19, 2023
e6298dd
WIP: class diagram
TamaroWalter Jun 20, 2023
82fd83e
WIP: better class diagram
TamaroWalter Jun 20, 2023
be057c9
WIP write post_control class
TamaroWalter Jun 26, 2023
f9bac43
First stage of post_control ready
TamaroWalter Jun 27, 2023
3b7842d
Merge branch 'master' into redesign/post
TamaroWalter Jul 3, 2023
c100a20
WIP: writing new post class for interacting with posts
TamaroWalter Jul 3, 2023
c4c3128
run grunt
TamaroWalter Jul 5, 2023
c8ace61
WIP: building post class
TamaroWalter Jul 5, 2023
c120ca4
WIP: building the new post class
TamaroWalter Jul 10, 2023
fad5329
WIP: new post class. Adjusting print function
TamaroWalter Jul 11, 2023
c54fb26
new Discussion class as part of the redesign
TamaroWalter Jul 13, 2023
66f77e5
WIP: updating discussion functions in new discussion.php
TamaroWalter Jul 17, 2023
437e6ea
WIP: new functions in discussion and post for editing posts
TamaroWalter Jul 18, 2023
0e3c972
WIP: post and discussion class ready, post_control refactoring
TamaroWalter Jul 21, 2023
5ea9221
WIP: new post.php file, post control is almost ready
TamaroWalter Jul 26, 2023
70ac6d6
new post.php complete
TamaroWalter Jul 27, 2023
d99ec28
new post structure ready
TamaroWalter Jul 28, 2023
b71565e
change includes
NinaHerrmann Jul 28, 2023
0eed562
WIP: fixing errors
TamaroWalter Jul 28, 2023
ebc4be9
Testing new structure: replies works
TamaroWalter Aug 3, 2023
8961316
first testing completed and successful. Test classes still needed
TamaroWalter Aug 9, 2023
29e3a09
little compatibility fixes with new post structure
TamaroWalter Aug 10, 2023
5b61489
deleting unnecessary functions in the locallib
TamaroWalter Aug 10, 2023
1ffeb5b
new post_test class
TamaroWalter Aug 17, 2023
104a8dc
new phpunit tests for discussion class
TamaroWalter Aug 18, 2023
95b665c
behat fails in older versions fixed
TamaroWalter Sep 7, 2023
e5131ea
capability fixed in post_control
TamaroWalter Sep 7, 2023
8ffc2f0
replace html with html_writer
TamaroWalter Sep 7, 2023
ac61679
edit a discussion subject fixed
TamaroWalter Sep 7, 2023
aedb836
moodlechecker fixes
TamaroWalter Sep 7, 2023
1c7c208
function in locallib changed for behat testing environment
TamaroWalter Sep 7, 2023
2379466
fix in post control for behat testing environment
TamaroWalter Sep 7, 2023
eaa2611
code cleaning: long array syntax to short array syntax
TamaroWalter Oct 27, 2023
a6917ad
codechecker fix in subscriptions_test
TamaroWalter Nov 2, 2023
ef6bef8
grammar fix in comments
TamaroWalter Nov 30, 2023
0e75bcd
Merge branch 'master' into redesign/post
TamaroWalter Apr 23, 2024
c03c799
Change anonymous name from Anonymous to Questioner in attachment
TamaroWalter Apr 23, 2024
0a6d181
fix for behat test
TamaroWalter Apr 26, 2024
9b99c25
pull from update/m4.4
TamaroWalter May 30, 2024
0eb6130
check for php version
TamaroWalter May 30, 2024
121957e
use moodle function to check php version
TamaroWalter May 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
new class for interacting with posts
  • Loading branch information
TamaroWalter committed Jun 13, 2023
commit 715e1320ea7bfda7c4a770767b2b1fc6b88a6807
96 changes: 96 additions & 0 deletions classes/post.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Class for working with posts
*
* @package mod_moodleoverflow
* @copyright 2023 Tamaro Walter
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/


namespace mod_moodleoverflow;

// Import namespace from the locallib, needs a check later which namespaces are really needed
use mod_moodleoverflow\anonymous;
use mod_moodleoverflow\capabilities;
use mod_moodleoverflow\review;

defined('MOODLE_INTERNAL') || die();

require_once(dirname(__FILE__) . '/lib.php');

/**
* Class that represents a post.
*
* @package mod_moodleoverflow
* @copyright 2023 Tamaro Walter
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class post {
/**
* Wie funktioniert das erstellen, ändern und löschen eines posts?
* Was mach die post.php und die classes/post_form.php, wozu sind post.mustache und post_dummy.mustache da?
* Welche funktionen zu den posts hat die locallib.php?
*
* => Was sollte in diese Klasse (classes/post.php) integriert werden, was sollte sie können? Was lässt man in der post.php/locallib.php, braucht man später die postform noch?
*
* Funktionen aus der Locallib, die mit posts zu tun haben:
* - function moodleoverflow_get_post_full($postid) -> holt infos um einen post zu printen
* - function moodleoverflow_user_can_see_post($moodleoverflow, $discussion, $post, $cm)
* - function moodleoverflow_get_all_discussion_posts($discussionid, $tracking, $modcontext) -> holt sich die posts einer discussion
* - function moodleoverflow_print_post(...)
* - function moodleoverflow_print_posts_nested
* - function get_attachments($post, $cm) ->
* - function moodleoverflow_add_attachment($post, $forum, $cm) {
* - function moodleoverflow_add_new_post($post) {
* - function moodleoverflow_update_post($newpost) {
* - function moodleoverflow_count_replies($post, $onlyreviewed) -> zählt antworten auf eine frage
* - function moodleoverflow_delete_post($post, $deletechildren, $cm, $moodleoverflow) {
* - function moodleoverflow_add_discussion($discussion, $modulecontext, $userid = null) {
*
*
* Vorüberlegung zu classes/post.php:
* - Jeder Post im moodleoverflow ist ein Objekt identifizierbar über seine ID
* - Bei der erstellung einer neuen Diskussion (automatisch mit einem post) oder beim antworten/kommentieren soll ein neues objekt DIESER Klasse erstellt werden
* => realisierung der funktionen add_new_post, update_post, delete_post
*
* - Die funkionen:
* - get_post_full, print_post,
* - add_attachment und get_attachments
* sollten auch hier programmiert sein.
*
* - Diese Funktionen sollten in der Locallib bleiben:
* - user_can_see_post, da es von außen nur auf einen existierenden post zugreift
* - get_all_discussion_posts, da ein post nicht weitere posts in seiner umgebung kennt (außer seinen Elternpost)
* - print_post_nested, auch hier der gleiche grund, außerdem ruft print_post_nested auch nur print_posts_nested und geht zum nächsten Post
* - count_replies, da hier eine sammlung von posts abgeprüft wird.
* - vielleicht auch noch add_discussion()
*
*
*
* Wie funktionieren post.php und classes/post_form.php?
*
* post.php:
* Bei jeder art von Interaktion (erstellen, ändern, löschen) wird die post.php aufgerufen
* => Im 1. Schritt wird geprüft, welche Art von Interaktion vorliegt. -> vielliecht auch das in classes/post.php auslagern
* => Im 2. Schritt wird ein neues post_form Objekt gebaut (Was macht das objekt genau? Wahrscheinlich kann man das auch auslagern)
*
*
* classes/post_form.php:
*/
}