本文整理汇总了PHP中OCP\Util::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::write方法的具体用法?PHP Util::write怎么用?PHP Util::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Util
的用法示例。
在下文中一共展示了Util::write方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: all
/**
* @brief Returns the list of addressbooks for a specific user.
* @param string $uid
* @param boolean $active Only return addressbooks with this $active state, default(=false) is don't care
* @param boolean $shared Whether to also return shared addressbook. Defaults to true.
* @return array or false.
*/
public static function all($uid, $active = false, $shared = true)
{
$values = array($uid);
$active_where = '';
if ($active) {
$active_where = ' AND `active` = ?';
$values[] = 1;
}
try {
$stmt = \OCP\DB::prepare('SELECT * FROM `*PREFIX*contacts_addressbooks` WHERE `userid` = ? ' . $active_where . ' ORDER BY `displayname`');
$result = $stmt->execute($values);
if (\OC_DB::isError($result)) {
\OCP\Util::write('contacts', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
return false;
}
} catch (\Exception $e) {
\OCP\Util::writeLog('contacts', __METHOD__ . ' exception: ' . $e->getMessage(), \OCP\Util::ERROR);
\OCP\Util::writeLog('contacts', __METHOD__ . ' uid: ' . $uid, \OCP\Util::DEBUG);
return false;
}
$addressbooks = array();
while ($row = $result->fetchRow()) {
$row['permissions'] = \OCP\PERMISSION_ALL;
$addressbooks[] = $row;
}
if ($shared === true) {
$addressbooks = array_merge($addressbooks, \OCP\Share::getItemsSharedWith('addressbook', Share_Backend_Addressbook::FORMAT_ADDRESSBOOKS));
}
if (!$active && !count($addressbooks)) {
$id = self::addDefault($uid);
return array(self::find($id));
}
return $addressbooks;
}
示例2: all
/**
* @brief Returns the list of addressbooks for a specific user.
* @param string $uid
* @param boolean $active Only return addressbooks with this $active state, default(=false) is don't care
* @param boolean $shared Whether to also return shared addressbook. Defaults to true.
* @return array or false.
*/
public static function all($uid, $active = false, $shared = true, $sync = false)
{
$values = array($uid);
$active_where = '';
if ($active) {
$active_where = ' AND `active` = ?';
$values[] = 1;
}
$sqlOrder = '`displayname` ASC';
if ($sync === true) {
$sqlOrder = '`sync` DESC';
}
try {
$stmt = \OCP\DB::prepare('SELECT * FROM `' . App::AddrBookTable . '` WHERE `userid` = ? ' . $active_where . ' ORDER BY ' . $sqlOrder);
$result = $stmt->execute($values);
if (\OCP\DB::isError($result)) {
\OCP\Util::write(App::$appname, __METHOD__ . 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
return false;
}
} catch (\Exception $e) {
\OCP\Util::writeLog(App::$appname, __METHOD__ . ' exception: ' . $e->getMessage(), \OCP\Util::ERROR);
\OCP\Util::writeLog(App::$appname, __METHOD__ . ' uid: ' . $uid, \OCP\Util::DEBUG);
return false;
}
$addressbooks = array();
while ($row = $result->fetchRow()) {
$row['permissions'] = \OCP\PERMISSION_ALL;
$addressbooks[] = $row;
}
if ($shared === true) {
$sharedAddressbooks = \OCP\Share::getItemsSharedWith(App::SHAREADDRESSBOOK, \OCA\ContactsPlus\Share\Backend\Addressbook::FORMAT_ADDRESSBOOKS);
// workaround for https://github.com/owncloud/core/issues/2814
foreach ($sharedAddressbooks as $sharedAddressbook) {
if (isset($sharedAddressbook['id']) && self::find($sharedAddressbook['id'])) {
$addressbooks[] = $sharedAddressbook;
}
}
}
if (!$active && !count($addressbooks)) {
$id = self::addDefault($uid);
return array(self::find($id));
}
return $addressbooks;
}
示例3: getAddressBook
public function getAddressBook($addressbookid, array $options = array())
{
//\OCP\Util::writeLog('contacts', __METHOD__.' id: '
// . $addressbookid, \OCP\Util::DEBUG);
if ($this->addressbooks && isset($this->addressbooks[$addressbookid])) {
//print(__METHOD__ . ' ' . __LINE__ .' addressBookInfo: ' . print_r($this->addressbooks[$addressbookid], true));
return $this->addressbooks[$addressbookid];
}
// Hmm, not found. Lets query the db.
try {
$query = 'SELECT `id`, `displayname`, `description`, `userid` AS `owner`, `ctag` AS `lastmodified`, `uri` FROM `' . $this->addressBooksTableName . '` WHERE `id` = ?';
if (!isset(self::$preparedQueries['getaddressbook'])) {
self::$preparedQueries['getaddressbook'] = \OCP\DB::prepare($query);
}
$result = self::$preparedQueries['getaddressbook']->execute(array($addressbookid));
if (\OCP\DB::isError($result)) {
\OCP\Util::write('contacts', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
return null;
}
if ((int) $result->numRows() === 0) {
throw new \Exception('Address Book not found', 404);
}
$row = $result->fetchRow();
$row['permissions'] = \OCP\PERMISSION_ALL;
$row['backend'] = $this->name;
$this->addressbooks[$addressbookid] = $row;
return $row;
} catch (\Exception $e) {
\OCP\Util::writeLog('contacts', __METHOD__ . ' exception: ' . $e->getMessage(), \OCP\Util::ERROR);
return null;
}
return null;
}
示例4: getAddressBooksForUser
/**
* Returns the list of active addressbooks for a specific user.
*
* @param string $userid
* @return array
*/
public function getAddressBooksForUser(array $options = array())
{
try {
if (!isset(self::$preparedQueries['addressbooksforuser'])) {
$sql = 'SELECT `configkey` from *PREFIX*preferences where `configkey` like ?';
$configkeyPrefix = $this->name . "_%_uri";
self::$preparedQueries['addressbooksforuser'] = \OCP\DB::prepare($sql);
$result = self::$preparedQueries['addressbooksforuser']->execute(array($configkeyPrefix));
if (\OC_DB::isError($result)) {
\OCP\Util::write('contacts', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
return $this->addressbooks;
}
$this->addressbooks = array();
while ($row = $result->fetchRow()) {
$id = str_replace("_uri", "", str_replace($this->name . "_", "", $row['configkey']));
$this->addressbooks[] = self::getAddressBook($id);
}
return $this->addressbooks;
}
} catch (\Exception $e) {
\OC_Log::write('contacts', __METHOD__ . ' exception: ' . $e->getMessage(), \OCP\Util::ERROR);
return $this->addressbooks;
}
}