本文整理汇总了PHP中mapi_last_hresult函数的典型用法代码示例。如果您正苦于以下问题:PHP mapi_last_hresult函数的具体用法?PHP mapi_last_hresult怎么用?PHP mapi_last_hresult使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mapi_last_hresult函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_mapi_error_name
/**
* Function to get a human readable string from a MAPI error code
*
*@param int $errcode the MAPI error code, if not given, we use mapi_last_hresult
*@return string The defined name for the MAPI error code
*/
function get_mapi_error_name($errcode = null)
{
if ($errcode === null) {
$errcode = mapi_last_hresult();
}
if ($errcode !== 0) {
// get_defined_constants(true) is preferred, but crashes PHP
// https://bugs.php.net/bug.php?id=61156
$allConstants = get_defined_constants();
foreach ($allConstants as $key => $value) {
/**
* If PHP encounters a number beyond the bounds of the integer type,
* it will be interpreted as a float instead, so when comparing these error codes
* we have to manually typecast value to integer, so float will be converted in integer,
* but still its out of bound for integer limit so it will be auto adjusted to minus value
*/
if ($errcode == (int) $value) {
// Check that we have an actual MAPI error or warning definition
$prefix = substr($key, 0, 7);
if ($prefix == "MAPI_E_" || $prefix == "MAPI_W_") {
return $key;
}
}
}
} else {
return "NOERROR";
}
// error code not found, return hex value (this is a fix for 64-bit systems, we can't use the dechex() function for this)
$result = unpack("H*", pack("N", $errcode));
return "0x" . $result[1];
}
示例2: checkMapiError
function checkMapiError($msg)
{
global $log;
if (mapi_last_hresult() != 0) {
$log->warn("MAPI error {$msg}: " . get_mapi_error_name());
exit;
}
}
示例3: renamefolder
function renamefolder($store, $entryid, $name)
{
if (!$entryid) {
print "Unable to find {$name} folder\n";
return;
}
$folder = mapi_msgstore_openentry($store, $entryid);
if (!$folder) {
print "Unable to open folder " . bin2hex($entryid) . "\n";
return;
}
mapi_setprops($folder, array(PR_DISPLAY_NAME => $name));
if (mapi_last_hresult() != 0) {
print "Unable to rename " . bin2hex($entryid) . " to '{$name}'\n";
} else {
print "Renamed " . bin2hex($entryid) . " to '{$name}'\n";
}
}
示例4: openMsgStore
function openMsgStore($username, $password)
{
$session = mapi_logon_zarafa($username, $password, SERVER);
if (mapi_last_hresult() != 0) {
trigger_error(sprintf("MAPI Error: 0x%x", mapi_last_hresult()), E_USER_ERROR);
}
$storesTable = mapi_getmsgstorestable($session);
$stores = mapi_table_queryallrows($storesTable, array(PR_ENTRYID, PR_MDB_PROVIDER));
for ($i = 0; $i < count($stores); $i++) {
if ($stores[$i][PR_MDB_PROVIDER] == ZARAFA_SERVICE_GUID) {
$storeEntryid = $stores[$i][PR_ENTRYID];
break;
}
}
if (!isset($storeEntryid)) {
trigger_error("Default store not found", E_USER_ERROR);
}
$store = mapi_openmsgstore($session, $storeEntryid);
isUnicodeStore($store);
return $store;
}
示例5: getuserlist
function getuserlist()
{
$this->companylist = mapi_zarafa_getcompanylist($this->defaultstore);
if (mapi_last_hresult() == NOERROR && is_array($this->companylist)) {
// multi company setup, get all users from all companies
if ($this->options->company != "") {
foreach ($this->companylist as $companyName => $companyData) {
if ($companyName == $this->options->company) {
$this->userlist = mapi_zarafa_getuserlist($this->defaultstore, $companyData["companyid"]);
break;
}
}
} else {
// Sanity check: multi-company setup, but no company in options
print "Running in a multi-company environment, but no company specified in command line.\n";
exit(RESULT_ERROR_NOCOMPANYSPECIFIED);
}
} else {
// single company setup, get list of all zarafa users
print "Getting user list\n";
$this->userlist = mapi_zarafa_getuserlist($this->defaultstore);
}
if (count($this->userlist) <= 0) {
print "Unable to get user list\n";
exit(RESULT_ERROR_USERLIST);
}
}
示例6: GetState
/**
* Reads the current state from the Exporter
*
* @access public
* @return string
* @throws StatusException
*/
public function GetState()
{
$error = false;
if (!isset($this->statestream) || $this->exporter === false) {
$error = true;
}
if ($error === true || mapi_exportchanges_updatestate($this->exporter, $this->statestream) != true) {
throw new StatusException(sprintf("ExportChangesICS->GetState(): Error, state not available or unable to update: 0x%X", mapi_last_hresult()), $this->folderid ? SYNC_STATUS_FOLDERHIERARCHYCHANGED : SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_WARN);
}
mapi_stream_seek($this->statestream, 0, STREAM_SEEK_SET);
$state = "";
while (true) {
$data = mapi_stream_read($this->statestream, 4096);
if (strlen($data)) {
$state .= $data;
} else {
break;
}
}
return $state;
}
示例7: deleteCard
/**
* Deletes a card
*
* @param mixed $addressBookId
* @param string $cardUri
* @return bool
*/
public function deleteCard($addressBookId, $cardUri)
{
$this->logger->info("deleteCard({$cardUri})");
if (READ_ONLY) {
$this->logger->warn("Cannot delete card: read-only");
return false;
}
$folder = mapi_msgstore_openentry($this->bridge->getStore($addressBookId), $addressBookId);
$entryId = $this->getContactEntryId($addressBookId, $cardUri);
if ($entryId === 0) {
$this->logger->warn("Contact not found!");
return false;
}
// $folder = mapi_msgstore_openentry($this->bridge->getStore($addressBookId), $addressBookId);
mapi_folder_deletemessages($folder, array($entryId));
if (mapi_last_hresult() > 0) {
return false;
}
return true;
}
示例8: readPropStream
/**
* Reads data of large properties from a stream
*
* @param MAPIMessage $message
* @param long $prop
*
* @access public
* @return string
*/
public static function readPropStream($message, $prop)
{
$stream = mapi_openproperty($message, $prop, IID_IStream, 0, 0);
$ret = mapi_last_hresult();
if ($ret == MAPI_E_NOT_FOUND) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("MAPIUtils->readPropStream: property 0x%s not found. It is either empty or not set. It will be ignored.", str_pad(dechex($prop), 8, 0, STR_PAD_LEFT)));
return "";
} elseif ($ret) {
ZLog::Write(LOGLEVEL_ERROR, "MAPIUtils->readPropStream error opening stream: 0X%X", $ret);
return "";
}
$data = "";
$string = "";
while (1) {
$data = mapi_stream_read($stream, 1024);
if (strlen($data) == 0) {
break;
}
$string .= $data;
}
return $string;
}
示例9: zpa_remove_device
function zpa_remove_device($adminStore, $session, $user, $deviceid)
{
$userEntryId = @mapi_msgstore_createentryid($adminStore, $user);
$userStore = @mapi_openmsgstore($session, $userEntryId);
$hresult = mapi_last_hresult();
if ($hresult != NOERROR) {
echo "Could not open store for {$user}. The script will exit.\n";
exit(1);
}
$devicesprops = mapi_getprops($userStore, array(0x6880101e, 0x6881101e, 0x6882101e, 0x6883101e, 0x68841003, 0x6885101e, 0x6886101e, 0x6887101e, 0x68881040, 0x68891040));
if (isset($devicesprops[0x6881101e]) && is_array($devicesprops[0x6881101e])) {
$ak = array_search($deviceid, $devicesprops[0x6881101e]);
if ($ak !== false) {
if (count($devicesprops[0x6880101e]) == 1) {
mapi_deleteprops($userStore, array(0x6880101e, 0x6881101e, 0x6882101e, 0x6883101e, 0x68841003, 0x6885101e, 0x6886101e, 0x6887101e, 0x68881040, 0x68891040));
} else {
unset($devicesprops[0x6880101e][$ak], $devicesprops[0x6881101e][$ak], $devicesprops[0x6882101e][$ak], $devicesprops[0x6883101e][$ak], $devicesprops[0x68841003][$ak], $devicesprops[0x6885101e][$ak], $devicesprops[0x6886101e][$ak], $devicesprops[0x6887101e][$ak], $devicesprops[0x68881040][$ak], $devicesprops[0x68891040][$ak]);
mapi_setprops($userStore, array(0x6880101e => isset($devicesprops[0x6880101e]) ? $devicesprops[0x6880101e] : array(), 0x6881101e => isset($devicesprops[0x6881101e]) ? $devicesprops[0x6881101e] : array(), 0x6882101e => isset($devicesprops[0x6882101e]) ? $devicesprops[0x6882101e] : array(), 0x6883101e => isset($devicesprops[0x6883101e]) ? $devicesprops[0x6883101e] : array(), 0x68841003 => isset($devicesprops[0x68841003]) ? $devicesprops[0x68841003] : array(), 0x6885101e => isset($devicesprops[0x6885101e]) ? $devicesprops[0x6885101e] : array(), 0x6886101e => isset($devicesprops[0x6886101e]) ? $devicesprops[0x6886101e] : array(), 0x6887101e => isset($devicesprops[0x6887101e]) ? $devicesprops[0x6887101e] : array(), 0x68881040 => isset($devicesprops[0x68881040]) ? $devicesprops[0x68881040] : array(), 0x68891040 => isset($devicesprops[0x68891040]) ? $devicesprops[0x68891040] : array()));
}
$hresult = mapi_last_hresult();
if ($hresult != NOERROR) {
echo "Could not remove device from list for {$user}. Errorcode 0x" . sprintf("%x", $hresult) . ". The script will exit.\n";
exit(1);
} else {
echo "Removed device from list.\n";
}
} else {
echo "No device found with the given id.\n";
exit(1);
}
} else {
echo "No devices found for the user {$user}.\n";
exit(1);
}
}
示例10: mapi_openmsgstore
$store = mapi_openmsgstore($l_rSession, $storeEntryId);
$root = mapi_msgstore_openentry($store, null);
$spamStoreProps = mapi_getprops($root, array(PR_ADDITIONAL_REN_ENTRYIDS));
$spamFolder = mapi_msgstore_openentry($store, $spamStoreProps[PR_ADDITIONAL_REN_ENTRYIDS][4]);
$table = mapi_folder_getcontentstable($spamFolder);
$spamRows = mapi_table_queryallrows($table, array(PR_ENTRYID, PR_CREATION_TIME));
echo (mapi_last_hresult() == 0 ? "Fetching messages from Junk Folder..." : "Some error in fetching...") . "\n";
if (count($spamRows) > 0) {
$spamEntryIds = array();
echo "\nTotal messages in Junk folder found are : " . count($spamRows) . "\n";
for ($i = 0; $i < count($spamRows); $i++) {
if (greaterDate(date("Y-m-d G:i:s", $spamRows[$i][PR_CREATION_TIME]), $daysBeforeDeleted)) {
array_push($spamEntryIds, $spamRows[$i][PR_ENTRYID]);
}
}
if (count($spamEntryIds) > 0) {
echo "\nDeleting all " . count($spamEntryIds) . " message(s)...\n";
mapi_folder_deletemessages($spamFolder, $spamEntryIds);
echo "" . (mapi_last_hresult() == 0 ? "\nHooray! there is no spam." : "Some error in deleting... There are still some spam messages.") . "\n";
} else {
echo "\nNo message found before " . $daysBeforeDeleted . " days in Junk Folder.";
}
} else {
echo "\nNo message found in Junk Folder.";
}
} else {
echo "No default store found... Terminating process.\n";
}
?>
示例11: define
define("FIELD_NAMES", true);
//the format of date values: true if they are as unix timestamps, false otherwise
define("DATES_AS_TIMESTAMPS", false);
// mapping for the csv column number to contact field (first field is 0)
$csv_mapping = array("given_name" => 0, "middle_name" => 1, "surname" => 2, "display_name_prefix" => 3, "webpage" => 6, "birthday" => 8, "wedding_anniversary" => 9, "notes" => 13, "email_address_1" => 14, "email_address_2" => 15, "email_address_3" => 16, "home_telephone_number" => 18, "home2_telephone_number" => 19, "cellular_telephone_number" => 20, "pager_telephone_number" => 21, "home_fax_number" => 22, "home_address" => 23, "home_address_street" => 24, "home_address_street2" => 25, "home_address_street3" => 26, "home_address_pobox" => 27, "home_address_city" => 28, "home_address_state" => 29, "home_address_postal_code" => 30, "home_address_country" => 31, "spouse_name" => 32, "manager_name" => 34, "assistant" => 35, "company_telephone_number" => 37, "office_telephone_number" => 38, "business2_telephone_number" => 39, "business_fax_number" => 40, "assistant_telephone_number" => 41, "company_name" => 42, "job_title" => 43, "department_name" => 44, "office_location" => 45, "profession" => 47, "business_address" => 49, "business_address_street" => 50, "business_address_street2" => 51, "business_address_street3" => 52, "business_address_pobox" => 53, "business_address_city" => 54, "business_address_state" => 55, "business_address_postal_code" => 56, "business_address_country" => 57, "other_telephone_number" => 58, "other_address" => 60, "other_address_street" => 61, "other_address_street2" => 62, "other_address_street3" => 63, "other_address_pobox" => 64, "other_address_city" => 65, "other_address_state" => 66, "other_address_postal_code" => 67, "other_address_country" => 68, "callback_telephone_number" => 69, "car_telephone_number" => 70, "isdn_number" => 71, "radio_telephone_number" => 72, "ttytdd_telephone_number" => 73, "telex_telephone_number" => 74, "sensitivity" => 84, "categories" => 87);
##########################
## end of configuration ##
##########################
error_reporting(E_ALL);
ini_set("display_errors", true);
ini_set("html_errors", false);
mapidefs();
mapitags();
$session = mapi_logon_zarafa($username, $password, SERVER);
if (mapi_last_hresult() != 0) {
trigger_error(sprintf("MAPI Error: 0x%x", mapi_last_hresult()), E_USER_ERROR);
}
$storesTable = mapi_getmsgstorestable($session);
$stores = mapi_table_queryallrows($storesTable, array(PR_ENTRYID, PR_MDB_PROVIDER));
for ($i = 0; $i < count($stores); $i++) {
if ($stores[$i][PR_MDB_PROVIDER] == ZARAFA_SERVICE_GUID) {
$storeEntryid = $stores[$i][PR_ENTRYID];
break;
}
}
if (!isset($storeEntryid)) {
trigger_error("Default store not found", E_USER_ERROR);
}
$store = mapi_openmsgstore($session, $storeEntryid);
$root = mapi_msgstore_openentry($store, null);
$rootProps = mapi_getprops($root, array(PR_IPM_CONTACT_ENTRYID));
示例12: setContactPicture
/**
* Assign a contact picture to a contact
* @param entryId contact entry id
* @param contactPicture must be a valid jpeg file. If contactPicture is NULL will remove contact picture from contact if exists
*/
public function setContactPicture(&$contact, $contactPicture)
{
$this->logger->trace("setContactPicture");
// Find if contact picture is already set
$contactAttachment = -1;
$hasattachProp = mapi_getprops($contact, array(PR_HASATTACH));
if ($hasattachProp) {
$attachmentTable = mapi_message_getattachmenttable($contact);
$attachments = mapi_table_queryallrows($attachmentTable, array(PR_ATTACH_NUM, PR_ATTACH_SIZE, PR_ATTACH_LONG_FILENAME, PR_ATTACH_FILENAME, PR_ATTACHMENT_HIDDEN, PR_DISPLAY_NAME, PR_ATTACH_METHOD, PR_ATTACH_CONTENT_ID, PR_ATTACH_MIME_TAG, PR_ATTACHMENT_CONTACTPHOTO, PR_EC_WA_ATTACHMENT_HIDDEN_OVERRIDE));
foreach ($attachments as $attachmentRow) {
if (isset($attachmentRow[PR_ATTACHMENT_CONTACTPHOTO]) && $attachmentRow[PR_ATTACHMENT_CONTACTPHOTO]) {
$contactAttachment = $attachmentRow[PR_ATTACH_NUM];
break;
}
}
}
// Remove existing attachment if necessary
if ($contactAttachment != -1) {
$this->logger->trace("removing existing contact picture");
$attach = mapi_message_deleteattach($contact, $contactAttachment);
}
if ($contactPicture !== NULL) {
$this->logger->debug("Saving contact picture as attachment");
// Create attachment
$attach = mapi_message_createattach($contact);
// Update contact attachment properties
$properties = array(PR_ATTACH_SIZE => strlen($contactPicture), PR_ATTACH_LONG_FILENAME => 'ContactPicture.jpg', PR_ATTACHMENT_HIDDEN => false, PR_DISPLAY_NAME => 'ContactPicture.jpg', PR_ATTACH_METHOD => ATTACH_BY_VALUE, PR_ATTACH_MIME_TAG => 'image/jpeg', PR_ATTACHMENT_CONTACTPHOTO => true, PR_ATTACH_DATA_BIN => $contactPicture, PR_ATTACHMENT_FLAGS => 1, PR_ATTACH_EXTENSION_A => '.jpg', PR_ATTACH_NUM => 1);
mapi_setprops($attach, $properties);
mapi_savechanges($attach);
}
// Test
if (mapi_last_hresult() > 0) {
$this->logger->warn("Error saving contact picture: " . get_mapi_error_name());
} else {
$this->logger->trace("contact picture done");
}
}
示例13: clearSuggestionList
function clearSuggestionList($session, $store, $userName)
{
// create entryid of user's store
$userStoreEntryId = mapi_msgstore_createentryid($store, $userName);
if (!$userStoreEntryId) {
print "Error in creating entryid for user's store - " . $userName . "\n";
return false;
}
// open user's store
$userStore = mapi_openmsgstore($session, $userStoreEntryId);
if (!$userStore) {
print "Error in opening user's store - " . $userName . "\n";
return false;
}
// we are not checking here that property exists or not because it could happen that getprops will return
// MAPI_E_NOT_ENOUGH_MEMORY for very large property, if property does not exists then it will be created
// remove property data, overwirte existing data with a blank string (PT_STRING8)
mapi_setprops($userStore, array(PR_EC_RECIPIENT_HISTORY => ""));
$result = mapi_last_hresult();
if ($result == NOERROR) {
// Save changes
mapi_savechanges($userStore);
return mapi_last_hresult() == NOERROR ? true : false;
}
return false;
}
示例14: listfolders_getlist
function listfolders_getlist($adminStore, $session, $user)
{
global $supported_classes;
if (strtoupper($user) == 'SYSTEM') {
// Find the public store store
$storestables = @mapi_getmsgstorestable($session);
$result = @mapi_last_hresult();
if ($result == NOERROR) {
$rows = @mapi_table_queryallrows($storestables, array(PR_ENTRYID, PR_MDB_PROVIDER));
foreach ($rows as $row) {
if (isset($row[PR_MDB_PROVIDER]) && $row[PR_MDB_PROVIDER] == ZARAFA_STORE_PUBLIC_GUID) {
if (!isset($row[PR_ENTRYID])) {
echo "Public folder are not available.\nIf this is a multi-tenancy system, use -u and -p and login with an admin user of the company.\nThe script will exit.\n";
exit(1);
}
$entryid = $row[PR_ENTRYID];
break;
}
}
}
} else {
$entryid = @mapi_msgstore_createentryid($adminStore, $user);
}
$userStore = @mapi_openmsgstore($session, $entryid);
$hresult = mapi_last_hresult();
// Cache the store for later use
if ($hresult != NOERROR) {
echo "Could not open store for '{$user}'. The script will exit.\n";
exit(1);
}
if (strtoupper($user) != 'SYSTEM') {
$inbox = mapi_msgstore_getreceivefolder($userStore);
if (mapi_last_hresult() != NOERROR) {
printf("Could not open inbox for %s (0x%08X). The script will exit.\n", $user, mapi_last_hresult());
exit(1);
}
$inboxProps = mapi_getprops($inbox, array(PR_SOURCE_KEY));
}
$storeProps = mapi_getprops($userStore, array(PR_IPM_OUTBOX_ENTRYID, PR_IPM_SENTMAIL_ENTRYID, PR_IPM_WASTEBASKET_ENTRYID));
$root = @mapi_msgstore_openentry($userStore, null);
$h_table = @mapi_folder_gethierarchytable($root, CONVENIENT_DEPTH);
$subfolders = @mapi_table_queryallrows($h_table, array(PR_ENTRYID, PR_DISPLAY_NAME, PR_CONTAINER_CLASS, PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY, PR_FOLDER_TYPE, PR_ATTR_HIDDEN));
echo "Available folders in store '{$user}':\n" . str_repeat("-", 50) . "\n";
foreach ($subfolders as $folder) {
// do not display hidden and search folders
if (isset($folder[PR_ATTR_HIDDEN]) && $folder[PR_ATTR_HIDDEN] || isset($folder[PR_FOLDER_TYPE]) && $folder[PR_FOLDER_TYPE] == FOLDER_SEARCH) {
continue;
}
// handle some special folders
if (strtoupper($user) != 'SYSTEM' && (isset($inboxProps[PR_SOURCE_KEY]) && $folder[PR_SOURCE_KEY] == $inboxProps[PR_SOURCE_KEY] || $folder[PR_ENTRYID] == $storeProps[PR_IPM_SENTMAIL_ENTRYID] || $folder[PR_ENTRYID] == $storeProps[PR_IPM_WASTEBASKET_ENTRYID])) {
$folder[PR_CONTAINER_CLASS] = "IPF.Note";
}
if (isset($folder[PR_CONTAINER_CLASS]) && array_key_exists($folder[PR_CONTAINER_CLASS], $supported_classes)) {
echo "Folder name:\t" . $folder[PR_DISPLAY_NAME] . "\n";
echo "Folder ID:\t" . bin2hex($folder[PR_SOURCE_KEY]) . "\n";
echo "Type:\t\t" . $supported_classes[$folder[PR_CONTAINER_CLASS]] . "\n";
echo "\n";
}
}
}
示例15: _openDefaultMessageStore
function _openDefaultMessageStore($session)
{
// Find the default store
$storestables = mapi_getmsgstorestable($session);
$result = mapi_last_hresult();
$entryid = false;
if ($result == NOERROR) {
$rows = mapi_table_queryallrows($storestables, array(PR_ENTRYID, PR_DEFAULT_STORE, PR_MDB_PROVIDER));
foreach ($rows as $row) {
if (isset($row[PR_DEFAULT_STORE]) && $row[PR_DEFAULT_STORE] == true) {
$entryid = $row[PR_ENTRYID];
break;
}
}
}
if ($entryid) {
return mapi_openmsgstore($session, $entryid);
} else {
return false;
}
}