<commit_before><?php
class TodoListModule extends Controller {
	private $moduleName = "todolist";
	public function getSettingsLinkText() {
		return get_translation ( "open" );
	}
	public function getSettingsHeadline() {
		return get_translation ( "todolist" );
	}
	public function settings() {
		return Template::executeModuleTemplate ( $this->moduleName, "list.php" );
	}
	public function addItem() {
		$acl = new ACL ();
		if ($acl->hasPermission ( getModuleMeta ( $this->moduleName, "admin_permission" ) ) and Request::getVar ( "title" )) {
			$item = new TodoListItem ();
			$item->setTitle ( Request::getVar ( "title" ) );
			$item->setUserId ( get_user_id () );
			$item->save ();
			ViewBag::set ( "item", $item );
			HTMLResult ( Template::executeModuleTemplate ( $this->moduleName, "item.php" ) );
		}
		HTMLResult ( get_translation ( "no_permissions" ), 403 );
	}
	public function updateItem() {
		$acl = new ACL ();
		if ($acl->hasPermission ( getModuleMeta ( $this->moduleName, "admin_permission" ) ) and Request::getVar ( "title" ) and Request::getVar ( "id" )) {
			$item = new TodoListItem ( Request::getVar ( "id" ) );
			if ($item->getUserID () == get_user_id ()) {
				$item->setTitle ( Request::getVar ( "title" ) );
				$item->save ();
				HTMLResult ( "ok", 200 );
			}
			HTMLResult ( get_translation ( "no_permissions" ), 403 );
		}
		HTMLResult ( get_translation ( "no_permissions" ), 403 );
	}
	public function deleteItem() {
		$acl = new ACL ();
		if ($acl->hasPermission ( getModuleMeta ( $this->moduleName, "admin_permission" ) ) and Request::getVar ( "id" )) {
			$item = new TodoListItem ( Request::getVar ( "id" ) );
			if ($item->getUserID () == get_user_id ()) {
				$item->delete ();
				HTMLResult ( "ok", 200 );
			}
			HTMLResult ( get_translation ( "no_permissions" ), 403 );
		}
		HTMLResult ( get_translation ( "no_permissions" ), 403 );
	}
	public function checkItem() {
		if (! get_user_id ()) {
			HTMLResult ( get_translation ( "no_permissions" ), 403 );
		}
		$acl = new ACL ();
		if (! $acl->hasPermission ( getModuleMeta ( $this->moduleName, "admin_permission" ) )) {
			HTMLResult ( get_translation ( "no_permissions" ), 403 );
		}
		$item = new TodoListItem ( Request::GetVar ( "id" ) );
		if ($item->getUserId () == get_user_id ()) {
			$item->setDone ( Request::getVar ( "done" ) );
			$item->save ();
			HTMLResult ( get_translation ( "ok" ), 200 );
		}
		HTMLResult ( get_translation ( "no_permissions" ), 403 );
	}
}<commit_msg>up und down actions implementiert<commit_after><?php
class TodoListModule extends Controller {
	private $moduleName = "todolist";
	public function getSettingsLinkText() {
		return get_translation ( "open" );
	}
	public function getSettingsHeadline() {
		return get_translation ( "todolist" );
	}
	public function settings() {
		return Template::executeModuleTemplate ( $this->moduleName, "list.php" );
	}
	public function addItem() {
		$acl = new ACL ();
		if ($acl->hasPermission ( getModuleMeta ( $this->moduleName, "admin_permission" ) ) and Request::getVar ( "title" )) {
			$item = new TodoListItem ();
			$item->setTitle ( Request::getVar ( "title" ) );
			$item->setUserId ( get_user_id () );
			$item->save ();
			ViewBag::set ( "item", $item );
			HTMLResult ( Template::executeModuleTemplate ( $this->moduleName, "item.php" ) );
		}
		HTMLResult ( get_translation ( "no_permissions" ), 403 );
	}
	public function updateItem() {
		$acl = new ACL ();
		if ($acl->hasPermission ( getModuleMeta ( $this->moduleName, "admin_permission" ) ) and Request::getVar ( "title" ) and Request::getVar ( "id" )) {
			$item = new TodoListItem ( Request::getVar ( "id" ) );
			if ($item->getUserID () == get_user_id ()) {
				$item->setTitle ( Request::getVar ( "title" ) );
				$item->save ();
				HTMLResult ( "ok", 200 );
			}
			HTMLResult ( get_translation ( "no_permissions" ), 403 );
		}
		HTMLResult ( get_translation ( "no_permissions" ), 403 );
	}
	public function deleteItem() {
		$acl = new ACL ();
		if ($acl->hasPermission ( getModuleMeta ( $this->moduleName, "admin_permission" ) ) and Request::getVar ( "id" )) {
			$item = new TodoListItem ( Request::getVar ( "id" ) );
			if ($item->getUserID () == get_user_id ()) {
				$item->delete ();
				HTMLResult ( "ok", 200 );
			}
			HTMLResult ( get_translation ( "no_permissions" ), 403 );
		}
		HTMLResult ( get_translation ( "no_permissions" ), 403 );
	}
	public function checkItem() {
		if (! get_user_id ()) {
			HTMLResult ( get_translation ( "no_permissions" ), 403 );
		}
		$acl = new ACL ();
		if (! $acl->hasPermission ( getModuleMeta ( $this->moduleName, "admin_permission" ) )) {
			HTMLResult ( get_translation ( "no_permissions" ), 403 );
		}
		$item = new TodoListItem ( Request::GetVar ( "id" ) );
		if ($item->getUserId () == get_user_id ()) {
			$item->setDone ( Request::getVar ( "done" ) );
			$item->save ();
			HTMLResult ( get_translation ( "ok" ), 200 );
		}
		HTMLResult ( get_translation ( "no_permissions" ), 403 );
	}
	public function up() {
		if (! get_user_id ()) {
			HTMLResult ( get_translation ( "no_permissions" ), 403 );
		}
		$acl = new ACL ();
		if (! $acl->hasPermission ( getModuleMeta ( $this->moduleName, "admin_permission" ) )) {
			HTMLResult ( get_translation ( "no_permissions" ), 403 );
		}
		$item = new TodoListItem ( Request::GetVar ( "id" ) );
		if ($item->getUserId () == get_user_id ()) {
			$otherItem = $item->getNext ();
			if ($otherItem) {
				$position1 = $item->getPosition ();
				$position2 = $otherItem->getPosition ();
				$item->setPosition ( $position2 );
				$otherItem->setPosition ( $position1 );
				$item->save ();
				$otherItem->save ();
				HTMLResult ( get_translation ( "ok" ), 200 );
			}
			
			HTMLResult ( get_translation ( "not_found" ), 404 );
		}
		HTMLResult ( get_translation ( "no_permissions" ), 403 );
	}
	public function down() {
		if (! get_user_id ()) {
			HTMLResult ( get_translation ( "no_permissions" ), 403 );
		}
		$acl = new ACL ();
		if (! $acl->hasPermission ( getModuleMeta ( $this->moduleName, "admin_permission" ) )) {
			HTMLResult ( get_translation ( "no_permissions" ), 403 );
		}
		$item = new TodoListItem ( Request::GetVar ( "id" ) );
		if ($item->getUserId () == get_user_id ()) {
			$otherItem = $item->getPrevious ();
			if ($otherItem) {
				$position1 = $item->getPosition ();
				$position2 = $otherItem->getPosition ();
				$item->setPosition ( $position2 );
				$otherItem->setPosition ( $position1 );
				$item->save ();
				$otherItem->save ();
				HTMLResult ( get_translation ( "ok" ), 200 );
			}
				
			HTMLResult ( get_translation ( "not_found" ), 404 );
		}
		HTMLResult ( get_translation ( "no_permissions" ), 403 );
	}
}
{'fraction_non_alphanumeric': 0.1756170531039641, 'fraction_numerical': 0.01555721765145849, 'mean_word_length': 3.775714285714286, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6535043', 'n_tokens_mistral': 2557, 'n_tokens_neox': 2212, 'n_words': 466}