2
OpenChange MAPI PHP bindings
4
Copyright (C) 2013 Javier Amor Garcia.
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 3 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
static zend_function_entry mapi_attachment_table_class_functions[] = {
23
PHP_ME(MAPIAttachmentTable, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
24
PHP_ME(MAPIAttachmentTable, getAttachments, NULL, ZEND_ACC_PUBLIC)
25
PHP_ME(MAPIAttachmentTable, getParentFolder,NULL, ZEND_ACC_PUBLIC)
26
PHP_ME(MAPIAttachmentTable, count, NULL, ZEND_ACC_PUBLIC)
30
static zend_class_entry *mapi_attachment_table_ce;
31
static zend_object_handlers mapi_attachment_table_object_handlers;
33
void MAPIAttachmentTableRegisterClass(TSRMLS_D)
37
INIT_CLASS_ENTRY(ce, "MAPIAttachmentTable", mapi_attachment_table_class_functions);
38
mapi_attachment_table_ce = zend_register_internal_class_ex(&ce, NULL, "mapitable" TSRMLS_CC);
39
mapi_attachment_table_ce->create_object = mapi_table_create_handler;
40
memcpy(&mapi_attachment_table_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
42
MAPITableClassSetObjectHandlers(&mapi_attachment_table_object_handlers);
43
mapi_attachment_table_object_handlers.clone_obj = NULL;
46
zval *create_attachment_table_object(zval* parent, mapi_object_t* attachment_table TSRMLS_DC)
49
struct SPropTagArray *tag_array;
50
mapi_table_object_t *new_obj;
53
mem_ctx = talloc_named(NULL, 0, "attachment_table");
54
tag_array = set_SPropTagArray(mem_ctx, 1, PR_ATTACH_NUM);
56
zval *new_php_obj = create_table_object("mapiattachmenttable", parent, attachment_table,
57
mem_ctx, tag_array, 0 TSRMLS_CC);
58
new_obj = (mapi_table_object_t*) zend_object_store_get_object(new_php_obj TSRMLS_CC);
59
new_obj->type = ATTACHMENTS;
64
PHP_METHOD(MAPIAttachmentTable, __construct)
66
php_error(E_ERROR, "The attachment message object should not be created directly.");
71
PHP_METHOD(MAPIAttachmentTable, getParentFolder)
73
php_error(E_ERROR, "This method cannot be called in an attachment table");
77
PHP_METHOD(MAPIAttachmentTable, getAttachments)
79
struct SRowSet row_set;
80
enum MAPISTATUS retval;
83
const uint32_t *attach_num;
88
mapi_table_object_t *this_obj;
92
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
93
"|l", &countParam) == FAILURE) {
97
count = (countParam > 0) ? (uint32_t) countParam : 50;
98
this_obj = THIS_STORE_OBJECT(mapi_table_object_t*);
99
message = this_obj->parent;
104
while (mapi_table_next_row_set(this_obj->table, &row_set, count TSRMLS_CC)) {
105
for (i = 0; i < row_set.cRows; i++) {
106
attach_num = (const uint32_t *)find_SPropValue_data(&(row_set.aRow[i]), PR_ATTACH_NUM);
107
attachment = mapi_message_get_attachment(message, *attach_num TSRMLS_CC);
109
add_next_index_zval(res, attachment);
113
if (countParam > 0) {
114
break; // no unlimited
118
RETURN_ZVAL(res, 0, 1);
121
PHP_METHOD(MAPIAttachmentTable, count)
123
php_error(E_ERROR, "This method is not available for attachments tables");