6 * @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
7 * @author Lars Kneschke <l.kneschke@metaways.de>
8 * @copyright Copyright (c) 2010-2012 Metaways Infosystems GmbH (http://www.metaways.de)
12 * class to hold addressbook list data
15 * @property container_id
17 * @property description
20 * @property type type of list
21 * @package Addressbook
23 class Addressbook_Model_List extends Tinebase_Record_Abstract
26 * key in $_validators/$_properties array for the filed which
27 * represents the identifier
31 protected $_identifier = 'id';
34 * application the record belongs to
38 protected $_application = 'Addressbook';
41 * list type: list (user defined lists)
45 const LISTTYPE_LIST = 'list';
48 * list type: group (lists matching a system group)
52 const LISTTYPE_GROUP = 'group';
55 * name of fields which require manage accounts to be updated
57 * @var array list of fields which require manage accounts to be updated
59 protected static $_manageAccountsFields = array(
66 * list of zend validator
68 * this validators get used when validating user generated content with Zend_Input_Filter
72 protected $_validators = array (
73 // tine 2.0 generic fields
74 'id' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::DEFAULT_VALUE => NULL),
75 'container_id' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
77 'created_by' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
78 'creation_time' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
79 'last_modified_by' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
80 'last_modified_time' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
81 'is_deleted' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
82 'deleted_time' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
83 'deleted_by' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
84 'seq' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::DEFAULT_VALUE => 0),
86 // list specific fields
87 'name' => array('presence' => 'required'),
88 'description' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
89 'members' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::DEFAULT_VALUE => array()),
90 'email' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
92 Zend_Filter_Input::ALLOW_EMPTY => true,
93 Zend_Filter_Input::DEFAULT_VALUE => self::LISTTYPE_LIST,
94 array('InArray', array(self::LISTTYPE_LIST, self::LISTTYPE_GROUP)),
96 'list_type' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
97 'group_id' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
98 'tags' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
99 'emails' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
100 'memberroles' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
102 // tine 2.0 generic fields
103 'tags' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
104 'notes' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
105 'relations' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
106 'customfields' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::DEFAULT_VALUE => array()),
110 * name of fields containing datetime or or an array of datetime information
112 * @var array list of datetime fields
114 protected $_datetimeFields = array(
116 'last_modified_time',
123 static public function getManageAccountFields()
125 return self::$_manageAccountsFields;
129 * converts a string or Addressbook_Model_List to a list id
131 * @param string|Addressbook_Model_List $_listId the contact id to convert
134 * @throws UnexpectedValueException if no list id set
136 static public function convertListIdToInt($_listId)
138 if ($_listId instanceof self) {
139 if ($_listId->getId() == null) {
140 throw new UnexpectedValueException('No identifier set.');
142 $id = (string) $_listId->getId();
144 $id = (string) $_listId;
148 throw new UnexpectedValueException('Identifier can not be empty.');