本文整理汇总了PHP中Notice类的典型用法代码示例。如果您正苦于以下问题:PHP Notice类的具体用法?PHP Notice怎么用?PHP Notice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Notice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* @param Notice $notice
* @return string
**/
public function send(Notice $notice)
{
$curl = curl_init();
$xml = $notice->toXml($this->configuration);
curl_setopt($curl, CURLOPT_URL, $this->configuration->get('apiEndPoint'));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, $this->configuration->get('timeout'));
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
// HTTP proxy support
$proxyHost = $this->configuration->get('proxyHost');
$proxyUser = $this->configuration->get('proxyUser');
if (null !== $proxyHost) {
curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $this->configuration->get('proxyPort'));
if (null !== $proxyUser) {
curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUser . ':' . $this->configuration->get('proxyPass'));
}
}
$return = curl_exec($curl);
curl_close($curl);
return $return;
}
示例2: onStartNoticeDistribute
/**
* If poster is in one of the forced groups, make sure their notice
* gets saved into that group even if not explicitly mentioned.
*
* @param Notice $notice
* @return boolean event hook return
*/
function onStartNoticeDistribute($notice)
{
$profile = $notice->getProfile();
$isRemote = !User::getKV('id', $profile->id);
if ($isRemote) {
/*
* Notices from remote users on other sites
* will normally not end up here unless they're
* specifically directed here, e.g.: via explicit
* post to a remote (to them) group. But remote
* notices can also be `pulled in' as a result of
* local users subscribing to the remote user;
* from the remote user's perspective, this results
* in group-forcing appearing effectively random.
* So let's be consistent, and just never force
* incoming remote notices into a ForceGroup:
*/
return true;
}
foreach ($this->post as $nickname) {
$group = User_group::getForNickname($nickname);
if ($group && $profile->isMember($group)) {
$notice->addToGroupInbox($group);
}
}
return true;
}
示例3: handle
/**
* Handle distribution of a notice after we've saved it:
* @li add to local recipient inboxes
* @li send email notifications to local @-reply targets
* @li run final EndNoticeSave plugin events
* @li put any remaining post-processing into the queues
*
* If this function indicates failure, a warning will be logged
* and the item is placed back in the queue to be re-run.
*
* @fixme addToInboxes is known to fail sometimes with large recipient sets
*
* @param Notice $notice
* @return boolean true on success, false on failure
*/
function handle($notice)
{
try {
$notice->addToInboxes();
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
$notice->sendReplyNotifications();
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
Event::handle('EndNoticeDistribute', array($notice));
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
Event::handle('EndNoticeSave', array($notice));
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
// Enqueue for other handlers
common_enqueue_notice($notice);
} catch (Exception $e) {
$this->logit($notice, $e);
}
return true;
}
示例4: getNoticeIds
function getNoticeIds($offset, $limit, $since_id, $max_id)
{
// XXX It would be nice to do this without a join
// (necessary to do it efficiently on accounts with long history)
$notice = new Notice();
$query = "select id from notice join notice_tag on id=notice_id where tag='" . $notice->escape($this->tag) . "' and profile_id=" . intval($this->profile->id);
$since = Notice::whereSinceId($since_id, 'id', 'notice.created');
if ($since) {
$query .= " and ({$since})";
}
$max = Notice::whereMaxId($max_id, 'id', 'notice.created');
if ($max) {
$query .= " and ({$max})";
}
$query .= ' order by notice.created DESC, id DESC';
if (!is_null($offset)) {
$query .= " LIMIT " . intval($limit) . " OFFSET " . intval($offset);
}
$notice->query($query);
$ids = array();
while ($notice->fetch()) {
$ids[] = $notice->id;
}
return $ids;
}
示例5: getStreamByIds
static function getStreamByIds($ids)
{
$cache = Cache::instance();
if (!empty($cache)) {
$notices = array();
foreach ($ids as $id) {
$n = Notice::staticGet('id', $id);
if (!empty($n)) {
$notices[] = $n;
}
}
return new ArrayWrapper($notices);
} else {
$notice = new Notice();
if (empty($ids)) {
//if no IDs requested, just return the notice object
return $notice;
}
$notice->whereAdd('id in (' . implode(', ', $ids) . ')');
$notice->find();
$temp = array();
while ($notice->fetch()) {
$temp[$notice->id] = clone $notice;
}
$wrapped = array();
foreach ($ids as $id) {
if (array_key_exists($id, $temp)) {
$wrapped[] = $temp[$id];
}
}
return new ArrayWrapper($wrapped);
}
}
示例6: getNoticeIds
function getNoticeIds($offset, $limit, $since_id = null, $max_id = null)
{
$notice = new Notice();
// SELECT
$notice->selectAdd();
$notice->selectAdd('id');
// WHERE
$notice->conversation = $this->id;
if (!empty($since_id)) {
$notice->whereAdd(sprintf('notice.id > %d', $since_id));
}
if (!empty($max_id)) {
$notice->whereAdd(sprintf('notice.id <= %d', $max_id));
}
if (!is_null($offset)) {
$notice->limit($offset, $limit);
}
if (!empty($this->selectVerbs)) {
$notice->whereAddIn('verb', $this->selectVerbs, $notice->columnType('verb'));
}
// ORDER BY
// currently imitates the previously used "_reverseChron" sorting
$notice->orderBy('notice.created DESC');
$notice->find();
return $notice->fetchAll('id');
}
示例7: getNoticeIds
function getNoticeIds($offset, $limit, $since_id, $max_id)
{
$notice = new Notice();
$qry = null;
$qry = 'SELECT notice.* FROM notice ';
$qry .= 'INNER JOIN happening ON happening.uri = notice.uri ';
$qry .= 'AND notice.is_local != ' . Notice::GATEWAY . ' ';
if ($since_id != 0) {
$qry .= 'AND notice.id > ' . $since_id . ' ';
}
if ($max_id != 0) {
$qry .= 'AND notice.id <= ' . $max_id . ' ';
}
// NOTE: we sort by event time, not by notice time!
$qry .= 'ORDER BY happening.created DESC ';
if (!is_null($offset)) {
$qry .= "LIMIT {$limit} OFFSET {$offset}";
}
$notice->query($qry);
$ids = array();
while ($notice->fetch()) {
$ids[] = $notice->id;
}
$notice->free();
unset($notice);
return $ids;
}
示例8: send
/**
* @param Notice $notice
* @return string
**/
public function send(Notice $notice)
{
$xml = $notice->toXml($this->configuration);
$opts = array('http' => array('method' => 'POST', 'header' => $this->headers, 'content' => $xml));
$context = stream_context_create($opts);
$result = file_get_contents($this->configuration->apiEndPoint, false, $context);
return $result;
}
示例9: getNextBatch
/**
* Fetch the next self::DELETION_WINDOW messages for this user.
* @return Notice
*/
protected function getNextBatch(User $user)
{
$notice = new Notice();
$notice->profile_id = $user->id;
$notice->limit(self::DELETION_WINDOW);
$notice->find();
return $notice;
}
示例10: locFromStored
static function locFromStored(Notice $stored)
{
$loc = new Notice_location();
$loc->notice_id = $stored->getID();
if (!$loc->find(true)) {
throw new NoResultException($loc);
}
return $loc->asLocation();
}
示例11: onEndShowThreadedNoticeTail
public function onEndShowThreadedNoticeTail(NoticeListItem $nli, Notice $notice, array $notices)
{
if ($this->prerender_replyforms) {
$nli->out->elementStart('li', array('class' => 'notice-reply', 'style' => 'display: none;'));
$replyForm = new NoticeForm($nli->out, array('inreplyto' => $notice->getID()));
$replyForm->show();
$nli->out->elementEnd('li');
}
return true;
}
示例12: onStartNoticeDistribute
/**
* If poster is in one of the forced groups, make sure their notice
* gets saved into that group even if not explicitly mentioned.
*
* @param Notice $notice
* @return boolean event hook return
*/
function onStartNoticeDistribute($notice)
{
$profile = $notice->getProfile();
foreach ($this->post as $nickname) {
$group = User_group::getForNickname($nickname);
if ($group && $profile->isMember($group)) {
$notice->addToGroupInbox($group);
}
}
return true;
}
示例13: approve
function approve($id)
{
if ($_POST) {
$notice = new Notice($id);
$_POST['approve_id'] = $this->session->userdata('id');
$notice->approve_date = date("Y-m-d H:i:s");
$notice->from_array($_POST);
$notice->save();
echo approve_comment($notice);
}
}
示例14: getUpdates
function getUpdates($seconds)
{
$notice = new Notice();
# XXX: cache this. Depends on how big this protocol becomes;
# Re-doing this query every 15 seconds isn't the end of the world.
$notice->query('SELECT profile_id, max(id) AS max_id ' . 'FROM notice ' . (common_config('db', 'type') == 'pgsql' ? 'WHERE extract(epoch from created) > (extract(epoch from now()) - ' . $seconds . ') ' : 'WHERE created > (now() - ' . $seconds . ') ') . 'GROUP BY profile_id');
$updates = array();
while ($notice->fetch()) {
$updates[] = array($notice->profile_id, $notice->max_id);
}
return $updates;
}
示例15: saveNew
public static function saveNew(Notice $notice, Profile $profile, $reason = null)
{
$att = new Attention();
$att->notice_id = $notice->getID();
$att->profile_id = $profile->getID();
$att->reason = $reason;
$att->created = common_sql_now();
$result = $att->insert();
if ($result === false) {
throw new Exception('Could not saveNew in Attention');
}
return $att;
}