1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @package org.openpsa.contacts |
4
|
|
|
* @author CONTENT CONTROL http://www.contentcontrol-berlin.de/ |
5
|
|
|
* @copyright CONTENT CONTROL http://www.contentcontrol-berlin.de/ |
6
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Handler addons |
11
|
|
|
* |
12
|
|
|
* @package org.openpsa.contacts |
13
|
|
|
*/ |
14
|
|
|
trait org_openpsa_contacts_handler |
15
|
|
|
{ |
16
|
|
|
public function add_head_elements() |
17
|
|
|
{ |
18
|
|
|
midcom::get()->uimessages->add_head_elements(); |
19
|
|
|
midcom::get()->head->add_jsfile(MIDCOM_STATIC_URL . "/org.openpsa.helpers/editable.js"); |
20
|
|
|
org_openpsa_widgets_contact::add_head_elements(); |
21
|
|
|
} |
22
|
|
|
|
23
|
2 |
|
public function get_group_tree() : org_openpsa_widgets_tree |
24
|
|
|
{ |
25
|
2 |
|
$root_group = org_openpsa_contacts_interface::find_root_group(); |
26
|
2 |
|
$nap = new midcom_helper_nav; |
27
|
2 |
|
$prefix = $nap->get_node($this->_topic->id)[MIDCOM_NAV_ABSOLUTEURL]; |
28
|
|
|
|
29
|
2 |
|
$tree = new org_openpsa_widgets_tree(org_openpsa_contacts_group_dba::class, 'owner'); |
30
|
2 |
|
$tree->link_callback = function ($guid) use ($prefix) { |
31
|
|
|
return $prefix . 'group/' . $guid . '/'; |
32
|
|
|
}; |
33
|
2 |
|
$tree->constraints[] = ['orgOpenpsaObtype', '<', org_openpsa_contacts_group_dba::ORGANIZATION]; |
34
|
2 |
|
$tree->root_node = $root_group->id; |
35
|
2 |
|
$tree->title_fields = ['official', 'name']; |
36
|
2 |
|
return $tree; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Get schema name for person |
41
|
|
|
*/ |
42
|
2 |
|
public function get_person_schema(org_openpsa_contacts_person_dba $contact) : string |
43
|
|
|
{ |
44
|
2 |
|
$my_company_guid = (string) $this->_config->get('owner_organization'); |
45
|
|
|
|
46
|
2 |
|
if (mgd_is_guid($my_company_guid)) { |
47
|
|
|
// Figure out if user is from own organization or other org |
48
|
|
|
$person_user = new midcom_core_user($contact->id); |
49
|
|
|
|
50
|
|
|
if ($person_user->is_in_group("group:{$my_company_guid}")) { |
51
|
|
|
return 'employee'; |
52
|
|
|
} |
53
|
2 |
|
} elseif (midcom::get()->auth->admin) { |
54
|
|
|
midcom::get()->uimessages->add( |
55
|
|
|
$this->_l10n->get($this->_component), |
56
|
|
|
$this->_l10n->get('owner organization couldnt be found'), |
57
|
|
|
'error' |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
2 |
|
return 'default'; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|