1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* FlexiPeeHP - Document Default Address support |
4
|
|
|
* |
5
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
6
|
|
|
* @copyright (C) 2018 Spoje.Net |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace FlexiPeeHP; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Add for Objects use with "firma" data column |
13
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
trait Stitky |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Get all labels for current record |
20
|
|
|
* |
21
|
|
|
* @return array |
22
|
|
|
*/ |
23
|
|
|
public function getLabels() |
24
|
|
|
{ |
25
|
|
|
return Stitek::listToArray($this->getDataValue('stitky')); |
|
|
|
|
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Set one of availble Labels for current record |
30
|
|
|
* |
31
|
|
|
* @param string $label |
32
|
|
|
* |
33
|
|
|
* @return boolean Operation success |
34
|
|
|
*/ |
35
|
|
|
public function setLabel($label) |
36
|
|
|
{ |
37
|
|
|
$this->insertToFlexiBee(['id' => $this->getRecordID(), 'stitky' => $label]); |
|
|
|
|
38
|
|
|
return $this->lastResultCode == 201; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* UnSet Label for Current Object record |
43
|
|
|
* |
44
|
|
|
* @param string $label |
45
|
|
|
* @param FlexiBeeRW $this |
46
|
|
|
* |
47
|
|
|
* @return boolean success result ? |
48
|
|
|
*/ |
49
|
|
|
public function unsetLabel($label) |
50
|
|
|
{ |
51
|
|
|
$result = true; |
52
|
|
|
$labels = self::getLabels($this); |
|
|
|
|
53
|
|
|
if (array_key_exists($label, $labels)) { |
54
|
|
|
unset($labels[$label]); |
55
|
|
|
$this->insertToFlexiBee(['id' => $this->getMyKey(), 'stitky@removeAll' => 'true', |
|
|
|
|
56
|
|
|
'stitky' => $labels]); |
57
|
|
|
$result = ($this->lastResponseCode == 201); |
58
|
|
|
} |
59
|
|
|
return $result; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* UnSet all Labels for Current Object record |
64
|
|
|
* |
65
|
|
|
* @return boolean success result ? |
66
|
|
|
*/ |
67
|
|
|
public function unsetLabels() |
68
|
|
|
{ |
69
|
|
|
$this->insertToFlexiBee(['id' => $this->getMyKey(), 'stitky@removeAll' => 'true']); |
70
|
|
|
return $this->lastResponseCode == 201; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|