本文整理汇总了PHP中common_log_db_error函数的典型用法代码示例。如果您正苦于以下问题:PHP common_log_db_error函数的具体用法?PHP common_log_db_error怎么用?PHP common_log_db_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了common_log_db_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveNew
static function saveNew($from, $to, $content, $source)
{
$sender = Profile::staticGet('id', $from);
if (!$sender->hasRight(Right::NEWMESSAGE)) {
// TRANS: Client exception thrown when a user tries to send a direct message while being banned from sending them.
throw new ClientException(_('You are banned from sending direct messages.'));
}
$msg = new Message();
$msg->from_profile = $from;
$msg->to_profile = $to;
$msg->content = common_shorten_links($content);
$msg->rendered = common_render_text($content);
$msg->created = common_sql_now();
$msg->source = $source;
$result = $msg->insert();
if (!$result) {
common_log_db_error($msg, 'INSERT', __FILE__);
// TRANS: Message given when a message could not be stored on the server.
return _('Could not insert message.');
}
$orig = clone $msg;
$msg->uri = common_local_url('showmessage', array('message' => $msg->id));
$result = $msg->update($orig);
if (!$result) {
common_log_db_error($msg, 'UPDATE', __FILE__);
// TRANS: Message given when a message could not be updated on the server.
return _('Could not update message with new URI.');
}
return $msg;
}
示例2: update_location
function update_location($args, $apidata)
{
parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
$this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']);
return;
}
$location = trim($this->arg('location'));
if (!is_null($location) && mb_strlen($location) > 255) {
// XXX: But Twitter just truncates and runs with it. -- Zach
$this->clientError(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']);
return;
}
$user = $apidata['user'];
// Always the auth user
$profile = $user->getProfile();
$orig_profile = clone $profile;
$profile->location = $location;
$result = $profile->update($orig_profile);
if (empty($result)) {
common_log_db_error($profile, 'UPDATE', __FILE__);
$this->serverError(_('Couldn\'t save profile.'));
return;
}
common_broadcast_profile($profile);
$type = $apidata['content-type'];
$this->init_document($type);
$this->show_profile($profile, $type);
$this->end_document($type);
}
示例3: saveNew
static function saveNew($profile_id, $album_id, $thumb_uri, $uri, $source, $insert_now, $title = null, $photo_description = null)
{
$photo = new GNUsocialPhoto();
$photo->thumb_uri = $thumb_uri;
$photo->uri = $uri;
$photo->album_id = $album_id;
if (!empty($title)) {
$photo->title = $title;
}
if (!empty($photo_description)) {
$photo->photo_description = (string) $photo_description;
}
if ($insert_now) {
$notice = Notice::saveNew($profile_id, $uri, $source);
$photo->notice_id = $notice->id;
$photo_id = $photo->insert();
if (!$photo_id) {
common_log_db_error($photo, 'INSERT', __FILE__);
throw new ServerException(_m('Problem Saving Photo.'));
}
} else {
GNUsocialPhotoTemp::$tmp = $photo;
Notice::saveNew($profile_id, $uri, $source);
}
}
示例4: setTags
static function setTags($tagger, $tagged, $newtags)
{
$newtags = array_unique($newtags);
$oldtags = Profile_tag::getTags($tagger, $tagged);
# Delete stuff that's old that not in new
$to_delete = array_diff($oldtags, $newtags);
# Insert stuff that's in new and not in old
$to_insert = array_diff($newtags, $oldtags);
$profile_tag = new Profile_tag();
$profile_tag->tagger = $tagger;
$profile_tag->tagged = $tagged;
$profile_tag->query('BEGIN');
foreach ($to_delete as $deltag) {
$profile_tag->tag = $deltag;
$result = $profile_tag->delete();
if (!$result) {
common_log_db_error($profile_tag, 'DELETE', __FILE__);
return false;
}
}
foreach ($to_insert as $instag) {
$profile_tag->tag = $instag;
$result = $profile_tag->insert();
if (!$result) {
common_log_db_error($profile_tag, 'INSERT', __FILE__);
return false;
}
}
$profile_tag->query('COMMIT');
return true;
}
示例5: handle
/**
* Handler method
*
* @param array $args is ignored since it's now passed in in prepare()
*/
function handle($args)
{
parent::handle($args);
$data = $this->facebook->getSignedRequest();
if (isset($data['user_id'])) {
$fbuid = $data['user_id'];
$flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE);
$user = $flink->getUser();
// Remove the link to Facebook
$result = $flink->delete();
if (!$result) {
common_log_db_error($flink, 'DELETE', __FILE__);
common_log(LOG_WARNING, sprintf('Unable to delete Facebook foreign link ' . 'for %s (%d), fbuid %d', $user->nickname, $user->id, $fbuid), __FILE__);
return;
}
common_log(LOG_INFO, sprintf('Facebook callback: %s (%d), fbuid %d has deauthorized ' . 'the Facebook application.', $user->nickname, $user->id, $fbuid), __FILE__);
// Warn the user about being locked out of their account
// if we can.
if (empty($user->password) && !empty($user->email)) {
Facebookclient::emailWarn($user);
} else {
common_log(LOG_WARNING, sprintf('%s (%d), fbuid %d has deauthorized his/her Facebook ' . 'connection but hasn\'t set a password so s/he ' . 'is locked out.', $user->nickname, $user->id, $fbuid), __FILE__);
}
} else {
if (!empty($data)) {
common_log(LOG_WARNING, sprintf('Facebook called the deauthorize callback ' . ' but didn\'t provide a user ID.'), __FILE__);
} else {
// It probably wasn't Facebook that hit this action,
// so redirect to the public timeline
common_redirect(common_local_url('public'), 303);
}
}
}
示例6: handle
function handle($args)
{
parent::handle($args);
$secret = common_config('facebook', 'secret');
$sig = '';
ksort($_POST);
foreach ($_POST as $key => $val) {
if (substr($key, 0, 7) == 'fb_sig_') {
$sig .= substr($key, 7) . '=' . $val;
}
}
$sig .= $secret;
$verify = md5($sig);
if ($verify == $this->arg('fb_sig')) {
$flink = Foreign_link::getByForeignID($this->arg('fb_sig_user'), 2);
common_debug("Removing foreign link to Facebook - local user ID: {$flink->user_id}, Facebook ID: {$flink->foreign_id}");
$result = $flink->delete();
if (!$result) {
common_log_db_error($flink, 'DELETE', __FILE__);
$this->serverError(_('Couldn\'t remove Facebook user.'));
return;
}
} else {
# Someone bad tried to remove facebook link?
common_log(LOG_ERR, "Someone from {$_SERVER['REMOTE_ADDR']} " . 'unsuccessfully tried to remove a foreign link to Facebook!');
}
}
示例7: insert
public function insert()
{
if (parent::insert() === false) {
common_log_db_error($this, 'INSERT', __FILE__);
throw new ServerException(sprintf(_m('Could not store new object of type %s'), get_called_class()));
}
self::blowCacheForProfileId($this->user_id);
self::blowCacheForNoticeId($this->notice_id);
return $this;
}
示例8: run
function run()
{
if (!$this->start()) {
return false;
}
$this->log(LOG_INFO, 'checking for queued confirmations');
do {
$confirm = $this->next_confirm();
if ($confirm) {
$this->log(LOG_INFO, 'Sending confirmation for ' . $confirm->address);
$user = User::staticGet($confirm->user_id);
if (!$user) {
$this->log(LOG_WARNING, 'Confirmation for unknown user ' . $confirm->user_id);
continue;
}
$success = jabber_confirm_address($confirm->code, $user->nickname, $confirm->address);
if (!$success) {
$this->log(LOG_ERR, 'Confirmation failed for ' . $confirm->address);
# Just let the claim age out; hopefully things work then
continue;
} else {
$this->log(LOG_INFO, 'Confirmation sent for ' . $confirm->address);
# Mark confirmation sent; need a dupe so we don't have the WHERE clause
$dupe = Confirm_address::staticGet('code', $confirm->code);
if (!$dupe) {
common_log(LOG_WARNING, 'Could not refetch confirm', __FILE__);
continue;
}
$orig = clone $dupe;
$dupe->sent = $dupe->claimed;
$result = $dupe->update($orig);
if (!$result) {
common_log_db_error($dupe, 'UPDATE', __FILE__);
# Just let the claim age out; hopefully things work then
continue;
}
$dupe->free();
unset($dupe);
}
$user->free();
unset($user);
$confirm->free();
unset($confirm);
$this->idle(0);
} else {
# $this->clear_old_confirm_claims();
$this->idle(10);
}
} while (true);
if (!$this->finish()) {
return false;
}
return true;
}
示例9: addNew
static function addNew($user, $notice)
{
$fave = new Fave();
$fave->user_id = $user->id;
$fave->notice_id = $notice->id;
if (!$fave->insert()) {
common_log_db_error($fave, 'INSERT', __FILE__);
return false;
}
return $fave;
}
示例10: initialize
/**
* Create a new inbox from existing Notice_inbox stuff
*/
static function initialize($user_id)
{
$inbox = Inbox::fromNoticeInbox($user_id);
unset($inbox->fake);
$result = $inbox->insert();
if (!$result) {
common_log_db_error($inbox, 'INSERT', __FILE__);
return null;
}
return $inbox;
}
示例11: getImage
function getImage()
{
$user = $this->user;
$profile = $user->getProfile();
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
$this->serverError(_('User without matching profile.'));
return null;
}
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
return $avatar ? $avatar->url : null;
}
示例12: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return void
*/
function handle($args)
{
parent::handle($args);
if (!common_logged_in()) {
// TRANS: Client error displayed when trying to remove a favorite while not logged in.
$this->clientError(_('Not logged in.'));
return;
}
$user = common_current_user();
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)));
return;
}
$id = $this->trimmed('notice');
$notice = Notice::staticGet($id);
$token = $this->trimmed('token-' . $notice->id);
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
$fave = new Fave();
$fave->user_id = $user->id;
$fave->notice_id = $notice->id;
if (!$fave->find(true)) {
// TRANS: Client error displayed when trying to remove favorite status for a notice that is not a favorite.
$this->clientError(_('This notice is not a favorite!'));
return;
}
$result = $fave->delete();
if (!$result) {
common_log_db_error($fave, 'DELETE', __FILE__);
// TRANS: Server error displayed when removing a favorite from the database fails.
$this->serverError(_('Could not delete favorite.'));
return;
}
$user->blowFavesCache();
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
// TRANS: Title for page on which favorites can be added.
$this->element('title', null, _('Add to favorites'));
$this->elementEnd('head');
$this->elementStart('body');
$favor = new FavorForm($this, $notice);
$favor->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {
common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)), 303);
}
}
示例13: vincularGrupo
static function vincularGrupo($userid, $groupid)
{
// MAGICALLY put fields into current scope
$grGroup = new Gradesgroup();
$grGroup->userid = $userid;
$grGroup->groupid = $groupid;
$result = $grGroup->insert();
if (!$result) {
common_log_db_error($userid, 'INSERT', __FILE__);
return false;
}
return $grGroup;
}
示例14: newResponse
static function newResponse($extension_id, $profile_id, $value)
{
$response = new GNUsocialProfileExtensionResponse();
$response->extension_id = $extension_id;
$response->profile_id = $profile_id;
$response->value = $value;
$response->id = $response->insert();
if (!$response->id) {
common_log_db_error($response, 'INSERT', __FILE__);
throw new ServerException(_m('Error creating new response.'));
}
return $response;
}
示例15: onStartNoticeDistribute
function onStartNoticeDistribute($notice)
{
common_log(LOG_INFO, "event: StartNoticeDistribute");
if (GNUsocialPhotoTemp::$tmp) {
GNUsocialPhotoTemp::$tmp->notice_id = $notice->id;
$photo_id = GNUsocialPhotoTemp::$tmp->insert();
if (!$photo_id) {
common_log_db_error($photo, 'INSERT', __FILE__);
throw new ServerException(_m('Problem saving photo.'));
}
}
return true;
}