Completed
Push — develop ( 989811...4ba2ac )
by Greg
10:44
created

NoteController::getEditMenu()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 21
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 21
rs 9.0534
cc 4
eloc 10
nc 3
nop 0
1
<?php
2
/**
3
 * webtrees: online genealogy
4
 * Copyright (C) 2016 webtrees development team
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
 * GNU General Public License for more details.
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15
 */
16
namespace Fisharebest\Webtrees\Controller;
17
18
use Fisharebest\Webtrees\Auth;
19
use Fisharebest\Webtrees\Filter;
20
use Fisharebest\Webtrees\I18N;
21
use Fisharebest\Webtrees\Menu;
22
use Fisharebest\Webtrees\Module;
23
24
/**
25
 * Controller for the shared note page
26
 */
27
class NoteController extends GedcomRecordController {
28
	/**
29
	 * get edit menu
30
	 */
31
	public function getEditMenu() {
32
		if (!$this->record || $this->record->isPendingDeletion()) {
33
			return null;
34
		}
35
36
		// edit menu
37
		$menu = new Menu(I18N::translate('Edit'), '#', 'menu-note');
38
39
		if (Auth::isEditor($this->record->getTree())) {
40
			$menu->addSubmenu(new Menu(I18N::translate('Edit note'), '#', 'menu-note-edit', array(
41
				'onclick' => 'return edit_note("' . $this->record->getXref() . '");',
42
			)));
43
44
			// delete
45
			$menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-note-del', array(
46
				'onclick' => 'return delete_record("' . I18N::translate('Are you sure you want to delete ā€œ%sā€?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");',
47
			)));
48
		}
49
50
		return $menu;
51
	}
52
}
53