本文整理汇总了PHP中u2w函数的典型用法代码示例。如果您正苦于以下问题:PHP u2w函数的具体用法?PHP u2w怎么用?PHP u2w使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了u2w函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayCatalog
function displayCatalog($catalog, &$lnk, $deep = 0, $count)
{
//
foreach ($catalog->{u('Группа')} as $group) {
$d = array('id' => u2w($group->{u('Ид')}), 'name' => u2w($group->{u('Наименование')}));
?>
<tr>
<td style="padding-left:<?php
echo $deep * 20;
?>
px;">
<?php
echo $d['name'];
?>
<?php
//=print_r($count)
?>
<?php
if (!empty($count[$d['id']])) {
?>
[<?php
echo $count[$d['id']];
?>
]<?php
}
?>
</td>
<td>
<input style="font-size:7pt;width:50px" name="lnk[<?php
echo $d['id'];
?>
]" value="<?php
echo !empty($lnk[$d['id']]) ? $lnk[$d['id']] : '';
?>
">
</td>
<td style="white-space:nowrap">
<?php
echo $d['id'];
?>
</td>
<td>
<?php
/*a class="move" rel="<?=$d['id']?>" title="Переместить дочерние узлы" href="#"><img src="/img/pic/move_16.gif"/></a*/
?>
<a class="move_to" rel="<?php
echo $d['id'];
?>
" title="Переместить дочерние узлы в текущий каталог" href="#"><img src="/img/pic/move_16.gif"/></a>
</td>
</tr>
<?php
if (!empty($group->{u('Группы')})) {
displayCatalog($group->{u('Группы')}, $lnk, $deep + 1, $count);
}
}
}
示例2: fill_ext_catalog
function fill_ext_catalog($groups)
{
$res = array();
foreach ($groups->{u('Группа')} as $group) {
$d = array('id' => u2w($group->{u('Ид')}), 'name' => u2w($group->{u('Наименование')}), 'ch' => array());
if (!empty($group->{u('Группы')})) {
$d['ch'] = fill_ext_catalog($group->{u('Группы')});
}
$res[] = $d;
}
return $res;
}
示例3: _storeAttachment
function _storeAttachment($mapimessage, $part)
{
// attachment
$attach = mapi_message_createattach($mapimessage);
// Filename is present in both Content-Type: name=.. and in Content-Disposition: filename=
if (isset($part->ctype_parameters["name"])) {
$filename = $part->ctype_parameters["name"];
} else {
if (isset($part->d_parameters["name"])) {
$filename = $part->d_parameters["filename"];
} else {
if (isset($part->d_parameters["filename"])) {
//sending appointment with nokia only filename is set
$filename = $part->d_parameters["filename"];
} else {
$filename = "untitled";
}
}
}
// Set filename and attachment type
mapi_setprops($attach, array(PR_ATTACH_LONG_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE));
// Set attachment data
mapi_setprops($attach, array(PR_ATTACH_DATA_BIN => $part->body));
// Set MIME type
mapi_setprops($attach, array(PR_ATTACH_MIME_TAG => $part->ctype_primary . "/" . $part->ctype_secondary));
mapi_savechanges($attach);
}
示例4: getSearchResults
function getSearchResults($searchquery, $searchrange)
{
// only return users from who the displayName or the username starts with $name
//TODO: use PR_ANR for this restriction instead of PR_DISPLAY_NAME and PR_ACCOUNT
$addrbook = mapi_openaddressbook($this->_session);
$ab_entryid = mapi_ab_getdefaultdir($addrbook);
$ab_dir = mapi_ab_openentry($addrbook, $ab_entryid);
$table = mapi_folder_getcontentstable($ab_dir);
$restriction = $this->_getSearchRestriction(u2w($searchquery));
mapi_table_restrict($table, $restriction);
mapi_table_sort($table, array(PR_DISPLAY_NAME => TABLE_SORT_ASCEND));
//range for the search results, default symbian range end is 50, wm 99,
//so we'll use that of nokia
$rangestart = 0;
$rangeend = 50;
if ($searchrange != '0') {
$pos = strpos($searchrange, '-');
$rangestart = substr($searchrange, 0, $pos);
$rangeend = substr($searchrange, $pos + 1);
}
$items = array();
$querycnt = mapi_table_getrowcount($table);
//do not return more results as requested in range
$querylimit = $rangeend + 1 < $querycnt ? $rangeend + 1 : $querycnt;
$items['range'] = $rangestart . '-' . ($querylimit - 1);
$abentries = mapi_table_queryrows($table, array(PR_ACCOUNT, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_BUSINESS_TELEPHONE_NUMBER), $rangestart, $querylimit);
for ($i = 0; $i < $querylimit; $i++) {
$items[$i]["username"] = w2u($abentries[$i][PR_ACCOUNT]);
$items[$i]["fullname"] = w2u($abentries[$i][PR_DISPLAY_NAME]);
if (strlen(trim($items[$i]["fullname"])) == 0) {
$items[$i]["fullname"] = $items[$i]["username"];
}
$items[$i]["emailaddress"] = w2u($abentries[$i][PR_SMTP_ADDRESS]);
$items[$i]["nameid"] = $searchquery;
//check if an user has a business phone or it might produce warnings in the log
$items[$i]["businessphone"] = isset($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER]) ? w2u($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER]) : "";
}
return $items;
}
示例5: KolabWriteTask
private function KolabWriteTask($message, $id)
{
if (!$id) {
$uid = strtoupper(md5(uniqid(time())));
} else {
$uid = $id;
}
$object = array('uid' => $uid, 'start' => $message->utcstartdate, 'due' => $message->utcduedate, 'name' => u2w($message->subject));
if (isset($message->rtf)) {
$object['body'] = $this->rtf2text($message->rtf);
}
if ($message->reminderset == 1) {
$object['alarm'] = ($message->remindertime - $message->utcstartdate) / 60;
}
//categories
if (isset($message->categories)) {
$object['categories'] = u2w(join(',', $message->categories));
}
switch ($message->importance) {
case 0:
$object["priority"] = 5;
break;
case 1:
$object["priority"] = 3;
break;
case 2:
$object["priority"] = 1;
break;
}
if ($message->complete == 1) {
$object['completed'] = 100;
$object['completed_date'] = $message->datecompleted;
} else {
$object['completed'] = 0;
}
switch ($message->sensitivity) {
case 1:
case 2:
$object["sensitivity"] = "private";
break;
case 3:
$object["sensitivity"] = "confidential";
}
//recurence
if (isset($message->recurrence)) {
$object["recurrence"] = $this->kolabWriteReccurence($message->reccurence);
}
$format = Horde_Kolab_Format::factory('XML', 'task');
$xml = $format->save($object);
unset($format);
// set the mail
// attach the XML file
$mail = $this->mail_attach("kolab.xml", 0, $xml, "kolab message", "text/plain", "plain", "application/x-vnd.kolab.task");
//add header
$h["from"] = $this->_email;
$h["to"] = $this->_email;
$h["X-Mailer"] = "z-push-Kolab Backend";
$h["subject"] = $object["uid"];
$h["message-id"] = "<" . strtoupper(md5(uniqid(time()))) . ">";
$h["date"] = date(DATE_RFC2822);
foreach (array_keys($h) as $i) {
$header = $header . $i . ": " . $h[$i] . "\r\n";
}
//return the mail formatted
return array($object['uid'], $h['date'], $header . $mail[0] . "\r\n" . $mail[1]);
}
示例6: _storeAttachment
function _storeAttachment($mapimessage, $part)
{
// attachment
$attach = mapi_message_createattach($mapimessage);
$filename = "";
// Filename is present in both Content-Type: name=.. and in Content-Disposition: filename=
debugLog("_storeAttachment: " . print_r($part, true));
if (isset($part->ctype_parameters["name"])) {
$filename = $part->ctype_parameters["name"];
} else {
if (isset($part->d_parameters["name"])) {
$filename = $part->d_parameters["filename"];
} else {
if (isset($part->d_parameters["filename"])) {
// sending appointment with nokia & android only filename is set
$filename = $part->d_parameters["filename"];
} else {
if (isset($part->d_parameters["filename*0"])) {
for ($i = 0; $i < count($part->d_parameters); $i++) {
if (isset($part->d_parameters["filename*" . $i])) {
$filename .= $part->d_parameters["filename*" . $i];
}
}
} else {
$filename = "untitled";
}
}
}
}
// Android just doesn't send content-type, so mimeDecode doesn't performs base64 decoding
// on meeting requests text/calendar somewhere inside content-transfer-encoding
if (isset($part->headers['content-transfer-encoding']) && strpos($part->headers['content-transfer-encoding'], 'base64')) {
if (strpos($part->headers['content-transfer-encoding'], 'text/calendar') !== false) {
$part->ctype_primary = 'text';
$part->ctype_secondary = 'calendar';
}
if (!isset($part->headers['content-type'])) {
$part->body = base64_decode($part->body);
}
}
if ($part->ctype_primary == 'multipart' && $part->ctype_secondary == 'signed') {
// Set filename and attachment type
$filename = "smime.p7m";
mapi_setprops($attach, array(PR_ATTACH_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE, PR_ATTACH_TAG => hex2bin("2A864886F714030A04")));
} else {
if ($part->ctype_primary == 'application' && $part->ctype_secondary == 'x-pkcs7-mime') {
$filename = "smime.p7m";
mapi_setprops($attach, array(PR_ATTACH_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE, PR_ATTACH_TAG => hex2bin("2A864886F714030A04")));
} else {
// Set filename and attachment type
mapi_setprops($attach, array(PR_ATTACH_LONG_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE));
}
}
// Set attachment data
mapi_setprops($attach, array(PR_ATTACH_DATA_BIN => $part->body));
// Set MIME type
mapi_setprops($attach, array(PR_ATTACH_MIME_TAG => $part->ctype_primary . "/" . $part->ctype_secondary));
mapi_savechanges($attach);
}
示例7: setAddress
/**
* Sets the properties for an address string.
*
* @param string $type which address is being set
* @param string $city
* @param string $country
* @param string $postalcode
* @param string $state
* @param string $street
* @param array &$props
* @param array &$properties
*
* @access private
* @return
*/
private function setAddress($type, &$city, &$country, &$postalcode, &$state, &$street, &$props, &$properties)
{
if (isset($city)) {
$props[$properties[$type . "city"]] = $city = u2w($city);
}
if (isset($country)) {
$props[$properties[$type . "country"]] = $country = u2w($country);
}
if (isset($postalcode)) {
$props[$properties[$type . "postalcode"]] = $postalcode = u2w($postalcode);
}
if (isset($state)) {
$props[$properties[$type . "state"]] = $state = u2w($state);
}
if (isset($street)) {
$props[$properties[$type . "street"]] = $street = u2w($street);
}
//set composed address
$address = Utils::BuildAddressString($street, $postalcode, $city, $state, $country);
if ($address) {
$props[$properties[$type . "address"]] = $address;
}
}
示例8: createResolveRecipient
/**
* Creates SyncResolveRecipient object for ResolveRecipientsResponse.
* @param int $type
* @param string $email
* @param array $recipientProperties
* @param int $recipientCount
*
* @return SyncResolveRecipient
*/
private function createResolveRecipient($type, $email, $recipientProperties, $recipientCount = 0)
{
$recipient = new SyncResolveRecipient();
$recipient->type = $type;
$recipient->displayname = u2w($recipientProperties[PR_DISPLAY_NAME]);
$recipient->emailaddress = $email;
if ($type == SYNC_RESOLVERECIPIENTS_TYPE_GAL) {
$certificateProp = PR_EMS_AB_TAGGED_X509_CERT;
} elseif ($type == SYNC_RESOLVERECIPIENTS_TYPE_CONTACT) {
$certificateProp = PR_USER_X509_CERTIFICATE;
} else {
$certificateProp = null;
}
if (isset($recipientProperties[$certificateProp]) && is_array($recipientProperties[$certificateProp]) && !empty($recipientProperties[$certificateProp])) {
$certificates = $this->getCertificates($recipientProperties[$certificateProp], $recipientCount);
} else {
$certificates = $this->getCertificates(false);
ZLog::Write(LOGLEVEL_INFO, sprintf("No certificate found for '%s' (requested email address: '%s')", $recipientProperties[PR_DISPLAY_NAME], $email));
}
$recipient->certificates = $certificates;
if (isset($recipientProperties[PR_ENTRYID])) {
$recipient->id = $recipientProperties[PR_ENTRYID];
}
return $recipient;
}
示例9: import1c_old
static function import1c_old($params = array())
{
global $CONFIG, $ST;
set_time_limit(1000);
$start_time = time();
$result = "Не найден контрольный файл";
// $PRICE_EXPR=$CONFIG['SHOP_SRV_PRICE_EXPR'];
// $PRICE_EXPR_ACT=$CONFIG['SHOP_SRV_PRICE_EXPR_ACT'];
$dir = CATALOG_DIR;
$save_dir = $dir . '/save';
$goods = $dir . '/' . GOODS_FILE_NAME;
// $goods_skidki=$dir.'/'.GOODS_SKIDKI_FILE_NAME;
$goods_price = $dir . '/' . GOODS_PRICE_FILE_NAME;
$ok_file = $dir . '/' . CATALOG_FILE_CONFIRM;
$log_file = $dir . '/log.txt';
if (file_exists($ok_file) || true) {
//&& extract_files(CATALOG_DIR.'/'.CATALOG_ARCHIV_NAME)
///////////////////////////////////////////////////////////////////
//товары
if (file_exists($goods) && file_exists($goods_price)) {
$cnt_imp = 0;
$lnk = array();
$rs = $ST->select("SELECT * FROM sc_shop_srv_extcat");
while ($rs->next()) {
$lnk[$rs->get('id')] = $rs->getInt('lnk');
}
// $ST->exec("TRUNCATE TABLE sc_shop_item_tmp");
$i = 0;
$j = 0;
$rows = array();
$xml = simplexml_load_file($goods);
$goods_list = $xml->{u('Каталог')}->{u('Товар')};
foreach ($goods_list as $data) {
break;
$d = array('id' => u2w($data->{u('Ид')}), 'category' => u2w($data->{u('Группы')}->{u('Ид')}), 'name' => str_replace('.', '. ', u2w($data->{u('Наименование')})), 'description' => str_replace('.', '. ', u2w($data->{u('Наименование')})), 'product' => ($p = u2w($data->{u('Артикул')})) ? $p : '', 'barcode' => u2w($data->{u('Штрихкод')}), 'unit' => intval(1), 'pack_size' => 0, 'pack_only' => 0, 'img' => '');
// if('133a0fa1-4694-11e2-922a-00155d0a010e'==$d['id']){
// file_put_contents(dirname(__FILE__).'/test.txt',$d['id'],FILE_APPEND);
// }
if (!empty($data->{u('ЗначенияСвойств')}->{u('ЗначенияСвойства')})) {
foreach ($data->{u('ЗначенияСвойств')}->{u('ЗначенияСвойства')} as $data) {
if ($data->{u('Ид')} == u('НоменклатураКод')) {
// $d['img']=trim(u2w($data->{u('Значение')}));
// $d['product']=$d['img'];
//22.11.2012
$d['img'] = trim(u2w($data->{u('Значение')}));
// $d['kod']=$d['img'];
// break;
}
if ($data->{u('Ид')} == u('НоменклатураКоличествоВУпаковке')) {
$d['pack_size'] = u2w($data->{u('Значение')});
// break;
}
if ($data->{u('Ид')} == u('НоменклатураОтгружаетсяТолькоУпаковками')) {
$d['pack_only'] = u2w($data->{u('Значение')}) == 'true' ? 1 : 0;
// break;
}
}
}
if (isset($lnk[$d['category']])) {
$d['category'] = $lnk[$d['category']];
} elseif ($d['category'] == '00000000-0000-0000-0000-000000000000') {
$d['category'] = 0;
//Нераспределённый товар
} else {
continue;
}
$rows[] = $d;
// if('133a0fa1-4694-11e2-922a-00155d0a010e'==$d['id']){
// file_put_contents(dirname(__FILE__).'/test.txt',print_r($d,true),FILE_APPEND);
//
// $ST->insert("sc_shop_item_tmp",$d);
// }
if (++$i && $i % 200 == 0) {
$ST->insertArr("sc_shop_item_tmp", $rows);
$rows = array();
}
$cnt_imp++;
}
if ($rows) {
$ST->insertArr("sc_shop_item_tmp", $rows);
}
//цены
$xml = simplexml_load_file($goods_price);
$goods_list = $xml->{u('ПакетПредложений')}->{u('Предложения')}->{u('Предложение')};
foreach ($goods_list as $data) {
break;
$id = u2w($data->{u('Ид')});
$d = array('price' => u2w($data->{u('Цены')}->{u('Цена')}->{u('ЦенаЗаЕдиницу')}), 'in_stock' => u2w($data->{u('Количество')}));
if (floatval($d['price'])) {
//только при наличии цены(скорее всего в любом случае)
// if($new_price=floatval(@eval('return '.str_replace('PRICE',$d['price'],$PRICE_EXPR).';'))){
// $d['price']=round($new_price,2);
// }
$ST->update("sc_shop_item_tmp", $d, "id='{$id}'");
}
}
$cnt_upd = 0;
$cnt_ins = 0;
//Обнулим что нужно
$ST->update("sc_shop_item i", array('in_stock' => 0), "EXISTS(SELECT id FROM sc_shop_item_tmp t WHERE t.id=i.ext_id AND (t.in_stock=0))");
//.........这里部分代码省略.........
示例10: actTmpImpCartshop
function actTmpImpCartshop()
{
set_time_limit(0);
global $ST;
echo "test";
// exit;
/*
1 = (string:121) http://www.farmcosmetica.ru/image/cache/data/avene/AVENE D-Pigment ЛЕЖЕР Средство для осветления темных пятен-228x228.jpg
*/
$rs = $ST->select("SELECT * FROM sc_shop_item WHERE img='' ");
//AND id=717
while ($rs->next()) {
$c = file_get_contents("http://www.farmcosmetica.ru/index.php?route=product/product&product_id={$rs->getInt('id')}");
$c = u2w($c);
if (preg_match('|src="(.+)".*id="image"|Um', $c, $res)) {
$img_src = str_replace('cache/', '', $res[1]);
$img_src = str_replace('-228x228', '', $img_src);
if ($img = @get_url(iconv('cp1251', 'utf-8', $img_src))) {
$img_name = preg_replace('|.*data/|', '', $img_src);
$img_name = str_replace('/', '_', $img_name);
$img_name = "storage/catalog/goods/" . $img_name;
if (!file_exists($img_name)) {
file_put_contents($img_name, $img);
}
$field_ext['img'] = "/" . $img_name;
} else {
$field_ext['img'] = "";
}
$ST->update('sc_shop_item', array('img' => $field_ext['img']), "id={$rs->getInt('id')}");
}
}
}
示例11: import1cV2
static function import1cV2($params = array())
{
global $CONFIG, $ST;
set_time_limit(1000);
$start_time = time();
$dir = CATALOG_DIR;
$goods_price = $dir . '/' . GOODS_PRICE_FILE_NAME;
$log_file = $dir . '/log.txt';
$cnt_upd_price = 0;
$cnt_ins = 0;
$cnt_upd = 0;
///////////////////////////////////////////////////////////////////
//остатки
if (file_exists($goods_price)) {
$result = date('Y-m-d H:i:s') . "\r\n";
file_put_contents($log_file, $result, FILE_APPEND);
//цены
$xml = simplexml_load_file($goods_price);
//Склад
// $sklad=$xml->{u('ПакетПредложений')}->{u('Владелец')}->{u('Ид')};
$goods_list = $xml->{u('ПакетПредложений')}->{u('Предложения')}->{u('Предложение')};
foreach ($goods_list as $data) {
$id = u2w($data->{u('Ид')});
$d = array('price' => u2w($data->{u('Цены')}->{u('Цена')}->{u('ЦенаЗаЕдиницу')}), 'in_stock' => u2w($data->{u('Количество')}));
$rs = $ST->select("SELECT * FROM sc_shop_item WHERE ext_id='" . $id . "' LIMIT 1");
if ($rs->next()) {
$itemid = $rs->getInt('id');
if ($d['price'] != $rs->get('price')) {
$ST->update('sc_shop_item', array('price' => (double) $d['price']), "ext_id='" . $id . "'");
$cnt_upd_price++;
}
$rs = $ST->select("SELECT * FROM sc_shop_offer WHERE itemid={$itemid} AND region='ekt' LIMIT 1");
/* @TODO region*/
if ($rs->next()) {
if ($d['in_stock'] != $rs->get('in_stock')) {
$ST->update('sc_shop_offer', array('in_stock' => (int) $d['in_stock']), "itemid={$itemid} AND region='ekt'");
$cnt_upd++;
}
} else {
$ST->insert('sc_shop_offer', array('in_stock' => (int) $d['in_stock'], 'itemid' => $itemid, 'region' => 'ekt'));
$cnt_ins++;
}
} else {
file_put_contents($log_file, "{$id} не найден\n", FILE_APPEND);
}
}
$stop_time = time();
$t = $stop_time - $start_time;
$result = ' - Время загрузки=' . $t . '; Обновлено остатков=' . $cnt_upd . '; Добавлено=' . $cnt_ins . '; Обновлено цен=' . $cnt_upd_price . "\r\n";
file_put_contents($log_file, $result, FILE_APPEND);
} else {
$result = date('Y-m-d H:i:s') . " - не найден один из файлов {$goods_price}\r\n";
file_put_contents($log_file, $result, FILE_APPEND);
}
return $result;
}
示例12: getRssData
function getRssData($url, $guid = null)
{
$xml = get_url($url);
$xml = simplexml_load_string($xml);
$data = array();
foreach ($xml->channel->item as $item) {
$i = array('title' => u2w($item->title), 'content' => u2w($item->description), 'img' => (string) @$item->enclosure->attributes()->url, 'date' => date('Y-m-d', strtotime($item->pubDate)), 'guid' => (string) $item->guid);
if ($guid && $guid == (string) $item->guid) {
return $i;
}
$data[] = $i;
}
return $data;
}
示例13: getURI
/**
* URI компоненты
*
* @return string
*/
function getURI($params = array(), $p = null)
{
$uri = u2w(urldecode($this->uri));
if ($params) {
foreach ($params as $key => $val) {
if ($val === null) {
$uri = preg_replace('|(' . $key . ')/([^/]+/)?|', '', $uri);
continue;
}
if ($val === false) {
$uri = preg_replace('|' . $key . '/|', '', $uri);
continue;
}
if (is_int($val)) {
$uri = preg_replace('|' . $key . '/\\d*/?|', "{$key}/{$val}/", $uri);
continue;
}
if (preg_match('|/' . $key . '/([^/]+)/|', $uri)) {
$uri = preg_replace('|/(' . $key . ')/([^/]+)/|', '/\\1/' . $val . '/', $uri);
} else {
$uri .= $key . '/' . $val . '/';
}
}
}
if ($p === true) {
$uri .= $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '';
} elseif (is_string($p)) {
$uri .= '?' . $p;
} elseif (is_array($p)) {
$uri .= '?' . http_build_query($p);
}
return $uri;
}
示例14: getSearchResults
function getSearchResults($searchquery, $searchrange)
{
// only return users from who the displayName or the username starts with $name
//TODO: use PR_ANR for this restriction instead of PR_DISPLAY_NAME and PR_ACCOUNT
$addrbook = mapi_openaddressbook($this->_session);
$ab_entryid = mapi_ab_getdefaultdir($addrbook);
$ab_dir = mapi_ab_openentry($addrbook, $ab_entryid);
$table = mapi_folder_getcontentstable($ab_dir);
$restriction = $this->_getSearchRestriction(u2w($searchquery));
mapi_table_restrict($table, $restriction);
mapi_table_sort($table, array(PR_DISPLAY_NAME => TABLE_SORT_ASCEND));
//range for the search results, default symbian range end is 50, wm 99,
//so we'll use that of nokia
$rangestart = 0;
$rangeend = 50;
if ($searchrange != '0') {
$pos = strpos($searchrange, '-');
$rangestart = substr($searchrange, 0, $pos);
$rangeend = substr($searchrange, $pos + 1);
}
$items = array();
$querycnt = mapi_table_getrowcount($table);
//do not return more results as requested in range
$querylimit = $rangeend + 1 < $querycnt ? $rangeend + 1 : $querycnt;
$items['range'] = $rangestart . '-' . ($querylimit - 1);
$items['searchtotal'] = $querycnt;
if ($querycnt > 0) {
$abentries = mapi_table_queryrows($table, array(PR_ACCOUNT, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_BUSINESS_TELEPHONE_NUMBER, PR_GIVEN_NAME, PR_SURNAME, PR_MOBILE_TELEPHONE_NUMBER, PR_HOME_TELEPHONE_NUMBER, PR_TITLE, PR_COMPANY_NAME, PR_OFFICE_LOCATION), $rangestart, $querylimit);
}
for ($i = 0; $i < $querylimit; $i++) {
$items[$i][SYNC_GAL_DISPLAYNAME] = w2u($abentries[$i][PR_DISPLAY_NAME]);
if (strlen(trim($items[$i][SYNC_GAL_DISPLAYNAME])) == 0) {
$items[$i][SYNC_GAL_DISPLAYNAME] = w2u($abentries[$i][PR_ACCOUNT]);
}
$items[$i][SYNC_GAL_ALIAS] = w2u($abentries[$i][PR_ACCOUNT]);
//it's not possible not get first and last name of an user
//from the gab and user functions, so we just set lastname
//to displayname and leave firstname unset
//this was changed in Zarafa 6.40, so we try to get first and
//last name and fall back to the old behaviour if these values are not set
if (isset($abentries[$i][PR_GIVEN_NAME])) {
$items[$i][SYNC_GAL_FIRSTNAME] = w2u($abentries[$i][PR_GIVEN_NAME]);
}
if (isset($abentries[$i][PR_SURNAME])) {
$items[$i][SYNC_GAL_LASTNAME] = w2u($abentries[$i][PR_SURNAME]);
}
if (!isset($items[$i][SYNC_GAL_LASTNAME])) {
$items[$i][SYNC_GAL_LASTNAME] = $items[$i][SYNC_GAL_DISPLAYNAME];
}
$items[$i][SYNC_GAL_EMAILADDRESS] = w2u($abentries[$i][PR_SMTP_ADDRESS]);
//check if an user has an office number or it might produce warnings in the log
if (isset($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER])) {
$items[$i][SYNC_GAL_PHONE] = w2u($abentries[$i][PR_BUSINESS_TELEPHONE_NUMBER]);
}
//check if an user has a mobile number or it might produce warnings in the log
if (isset($abentries[$i][PR_MOBILE_TELEPHONE_NUMBER])) {
$items[$i][SYNC_GAL_MOBILEPHONE] = w2u($abentries[$i][PR_MOBILE_TELEPHONE_NUMBER]);
}
//check if an user has a home number or it might produce warnings in the log
if (isset($abentries[$i][PR_HOME_TELEPHONE_NUMBER])) {
$items[$i][SYNC_GAL_HOMEPHONE] = w2u($abentries[$i][PR_HOME_TELEPHONE_NUMBER]);
}
if (isset($abentries[$i][PR_COMPANY_NAME])) {
$items[$i][SYNC_GAL_COMPANY] = w2u($abentries[$i][PR_COMPANY_NAME]);
}
if (isset($abentries[$i][PR_TITLE])) {
$items[$i][SYNC_GAL_TITLE] = w2u($abentries[$i][PR_TITLE]);
}
if (isset($abentries[$i][PR_OFFICE_LOCATION])) {
$items[$i][SYNC_GAL_OFFICE] = w2u($abentries[$i][PR_OFFICE_LOCATION]);
}
}
return $items;
}
示例15: resolveRecipientContact
/**
* Resolves recipient from the contact list and gets his certificates.
*
* @param string $to
*
* @return SyncResolveRecipient|boolean
*/
private function resolveRecipientContact($to)
{
// go through all contact folders of the user and
// check if there's a contact with the given email address
$root = mapi_msgstore_openentry($this->defaultstore);
if (!$root) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("Unable to open default store: 0x%X", mapi_last_hresult));
}
$rootprops = mapi_getprops($root, array(PR_IPM_CONTACT_ENTRYID));
$contacts = $this->getContactsFromFolder($this->defaultstore, $rootprops[PR_IPM_CONTACT_ENTRYID], $to);
$recipients = array();
if ($contacts !== false) {
// create resolve recipient object
foreach ($contacts as $contact) {
$certificates = isset($contact[PR_USER_X509_CERTIFICATE]) && is_array($contact[PR_USER_X509_CERTIFICATE]) && count($contact[PR_USER_X509_CERTIFICATE]) ? $this->getCertificates($contact[PR_USER_X509_CERTIFICATE], 1) : false;
if ($certificates !== false) {
return $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_CONTACT, u2w($contact[PR_DISPLAY_NAME]), $to, $certificates);
}
}
}
$contactfolder = mapi_msgstore_openentry($this->defaultstore, $rootprops[PR_IPM_CONTACT_ENTRYID]);
$subfolders = MAPIUtils::GetSubfoldersForType($contactfolder, "IPF.Contact");
foreach ($subfolders as $folder) {
$contacts = $this->getContactsFromFolder($this->defaultstore, $folder[PR_ENTRYID], $to);
if ($contacts !== false) {
foreach ($contacts as $contact) {
$certificates = isset($contact[PR_USER_X509_CERTIFICATE]) && is_array($contact[PR_USER_X509_CERTIFICATE]) && count($contact[PR_USER_X509_CERTIFICATE]) ? $this->getCertificates($contact[PR_USER_X509_CERTIFICATE], 1) : false;
if ($certificates !== false) {
return $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_CONTACT, u2w($contact[PR_DISPLAY_NAME]), $to, $certificates);
}
}
}
}
// search contacts in public folders
$storestables = mapi_getmsgstorestable($this->session);
$result = mapi_last_hresult();
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_MDB_PROVIDER]) && $row[PR_MDB_PROVIDER] == ZARAFA_STORE_PUBLIC_GUID) {
// TODO refactor public store
$publicstore = mapi_openmsgstore($this->session, $row[PR_ENTRYID]);
$publicfolder = mapi_msgstore_openentry($publicstore);
$subfolders = MAPIUtils::GetSubfoldersForType($publicfolder, "IPF.Contact");
if ($subfolders !== false) {
foreach ($subfolders as $folder) {
$contacts = $this->getContactsFromFolder($publicstore, $folder[PR_ENTRYID], $to);
if ($contacts !== false) {
foreach ($contacts as $contact) {
$certificates = isset($contact[PR_USER_X509_CERTIFICATE]) && is_array($contact[PR_USER_X509_CERTIFICATE]) && count($contact[PR_USER_X509_CERTIFICATE]) ? $this->getCertificates($contact[PR_USER_X509_CERTIFICATE], 1) : false;
if ($certificates !== false) {
return $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_CONTACT, u2w($contact[PR_DISPLAY_NAME]), $to, $certificates);
}
}
}
}
}
break;
}
}
} else {
ZLog::Write(LOGLEVEL_WARN, sprintf("Unable to open public store: 0x%X", $result));
}
$certificates = $this->getCertificates(false);
return $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_CONTACT, $to, $to, $certificates);
}