1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15: class IMP_Flag_User extends IMP_Flag_Imap
16: {
17: 18:
19: protected $_canset = true;
20:
21: 22:
23: protected $_css = 'flagUser';
24:
25: 26: 27: 28: 29:
30: protected $_label;
31:
32: 33: 34: 35: 36: 37: 38:
39: public function __construct($label, $flag = null, $bgcolor = null)
40: {
41: $this->label = $label;
42: $this->imapflag = is_null($flag)
43: ? $label
44: : $flag;
45: if (isset($bgcolor)) {
46: $this->bgcolor = $bgcolor;
47: }
48: }
49:
50: 51:
52: public function __set($name, $value)
53: {
54: switch ($name) {
55: case 'imapflag':
56: 57:
58: $this->_imapflag = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getUtils()->stripNonAtomChars(Horde_String::convertCharset(strtr($value, ' ', '_'), 'UTF-8', 'UTF7-IMAP'));
59: break;
60:
61: case 'label':
62: $this->_label = $value;
63: break;
64:
65: default:
66: parent::__set($name, $value);
67: break;
68: }
69: }
70:
71: 72:
73: protected function _getLabel()
74: {
75: return $this->_label;
76: }
77:
78:
79:
80: 81:
82: public function serialize()
83: {
84: return json_encode(array(
85: parent::serialize(),
86: $this->_label,
87: $this->_imapflag
88: ));
89: }
90:
91: 92:
93: public function unserialize($data)
94: {
95: $data = json_decode($data, true);
96:
97: parent::unserialize($data[0]);
98: $this->_label = $data[1];
99: $this->_imapflag = $data[2];
100: }
101:
102: }
103: