- Used instanceof to compare object instance with class (not the best, interfaces would be better)
- Improved some SQL queries by addding backticks
- Converted some double-quotes to single
Signed-off-by: Roland Haeder <roland@mxchange.org>
if (!$ptag) {
$user = User::getKV('id', $id);
- if ($user) {
+
+ if ($user instanceof User) {
$this->clientError(
// TRANS: Client error displayed when an unknown error occurs when adding a user to a list.
// TRANS: %s is a username.
function defaultReturnTo()
{
$user = common_current_user();
- if ($user) {
+
+ if ($user instanceof User) {
return common_local_url('subscribers',
array('nickname' => $user->nickname));
} else {
if (!$ptag) {
$user = User::getKV('id', $this->tagged->id);
- if ($user) {
+ if ($user instanceof User) {
$this->clientError(
// TRANS: Client error displayed when an unknown error occurs while delisting a user.
// TRANS: %s is a username.
$msg->from_profile = $from;
$msg->to_profile = $to;
- if ($user) {
+
+ if ($user instanceof User) {
// Use the sender's URL shortening options.
$msg->content = $user->shortenLinks($content);
} else {
$msg->content = common_shorten_links($content);
}
+
$msg->rendered = common_render_text($msg->content);
$msg->created = common_sql_now();
$msg->source = $source;
$this->out->elementEnd('div');
- if ($user) {
+ if ($user instanceof User) {
$this->out->elementStart('div', 'entity_actions');
$this->out->elementStart('ul');
$this->out->elementStart('li', 'entity_subscribe');
{
if (Event::handle('StartShowNoticeOptions', array($this))) {
$user = common_current_user();
- if ($user) {
+
+ if ($user instanceof User) {
$this->out->elementStart('div', 'notice-options');
if (Event::handle('StartShowNoticeOptionItems', array($this))) {
$this->showReplyLink();
}
$this->out->elementEnd('div');
}
+
Event::handle('EndShowNoticeOptions', array($this));
}
}
return false;
}
- if ($user) {
+ if ($user instanceof User) {
if (Event::handle('StartSetUser', array(&$user))) {
if (!empty($user)) {
if (!$user->hasRight(Right::WEBLOGIN)) {
if ($user === false) {
$user = common_current_user();
}
- if ($user) {
+ if ($user instanceof User) {
return crc32($user->id . ':' . $user->nickname);
} else {
return '0';
function showJoinButton()
{
$user = $this->owner;
- if ($user) {
+ if ($user instanceof User) {
$this->out->elementStart('li', 'entity_subscribe');
// XXX: special-case for user looking at own
// subscriptions page
function onEndShowAccountProfileBlock(HTMLOutputter $out, Profile $profile) {
$user = User::getKV('id', $profile->id);
- if ($user) {
+
+ if ($user instanceof User) {
$url = common_local_url('profiledetail', array('nickname' => $user->nickname));
// TRANS: Link text on user profile page leading to extended profile page.
$out->element('a', array('href' => $url, 'class' => 'profiledetail'), _m('More details...'));
{
if ($this->nickname) {
$user = User::getKV('nickname', $this->nickname);
- if ($user) {
+
+ if ($user instanceof User) {
return common_local_url('userbyid', array('id' => $user->id));
} else {
// TRANS: Client error.
if (preg_match('!/group/(\d+)/id!', $oprofile->getUri(), $matches)) {
$id = intval($matches[1]);
$group = Local_group::getKV('group_id', $id);
- if ($group) {
+ if ($group instanceof Local_group) {
$nick = $group->nickname;
} else {
$nick = '<deleted>';
} else if (preg_match('!/user/(\d+)!', $uri, $matches)) {
$id = intval($matches[1]);
$user = User::getKV('id', $id);
- if ($user) {
+
+ if ($user instanceof User) {
$nick = $user->nickname;
} else {
$nick = '<deleted>';
}
+
echo "user $id ($nick) hidden by $uri";
} else {
echo "$uri matched query, but we don't recognize it.\n";
$user = oid_get_user($canonical);
- if ($user) {
+ if ($user instanceof User) {
oid_set_last($display);
// XXX: commented out at @edd's request until better
// control over how data flows from OpenID provider.
// oid_update_user($user, $sreg);
common_set_user($user);
common_real_login(true);
+
if (isset($_SESSION['openid_rememberme']) && $_SESSION['openid_rememberme']) {
common_rememberme($user);
}
+
unset($_SESSION['openid_rememberme']);
$this->goHome($user->nickname);
} else {
$out->elementStart('div', array('class' => 'e-content poll-content'));
$poll = Poll::getByNotice($notice);
if ($poll) {
- if ($user) {
+ if ($user instanceof User) {
$profile = $user->getProfile();
$response = $poll->getResponse($profile);
if ($response) {
function onStartNoticeSearchShowResults($action, $q, $notice)
{
$user = common_current_user();
- if ($user) {
+
+ if ($user instanceof User) {
$search = $q;
$searchsub = SearchSub::pkeyGet(array('search' => $search,
'profile_id' => $user->id));
} else {
$form = new SearchSubForm($action, $search);
}
+
$action->elementStart('div', 'entity_actions');
$action->elementStart('ul');
$action->elementStart('li', 'entity_subscribe');
$action->elementEnd('ul');
$action->elementEnd('div');
}
+
return true;
}
$exclude = $this->nicknamesToIds($this->excludeUsers);
if (count($include) == 1) {
- return "profile_id = " . intval($include[0]);
+ return '`profile_id` = ' . intval($include[0]);
} else if (count($include) > 1) {
- return "profile_id IN (" . implode(',', $include) . ")";
+ return '`profile_id` IN (' . implode(',', $include) . ')';
} else if (count($exclude) == 1) {
- return "profile_id != " . intval($exclude[0]);
+ return '`profile_id` != ' . intval($exclude[0]);
} else if (count($exclude) > 1) {
- return "profile_id NOT IN (" . implode(',', $exclude) . ")";
+ return '`profile_id` NOT IN (' . implode(',', $exclude) . ')';
} else {
return false;
}
foreach ($nicks as $nick) {
// not the most efficient way for a big list!
$user = User::getKV('nickname', $nick);
- if ($user) {
+
+ if ($user instanceof User) {
$ids[] = intval($user->id);
}
}
function showFeedForm($mirror)
{
$profile = Profile::getKV('id', $mirror->subscribed);
- if ($profile) {
+
+ if ($profile instanceof Profile) {
$form = new EditMirrorForm($this, $profile);
$form->show();
}
function onStartTagShowContent(TagAction $action)
{
$user = common_current_user();
- if ($user) {
+
+ if ($user instanceof User) {
$tag = $action->trimmed('tag');
$tagsub = TagSub::pkeyGet(array('tag' => $tag,
'profile_id' => $user->id));
$action->elementEnd('ul');
$action->elementEnd('div');
}
+
return true;
}
return Profile::getKV('id', $profileId);
} else {
$user = User::getKV('nickname', $nickname);
- if ($user) {
+
+ if ($user instanceof User) {
common_log(LOG_WARNING, "Copying Yammer profile info onto existing user $nickname");
$profile = $user->getProfile();
$this->savePropertiesOn($profile, $data['options'],
$user = User::register($data['options']);
$profile = $user->getProfile();
}
+
if ($data['avatar']) {
try {
$this->saveAvatar($data['avatar'], $profile);
// Save "likes" as favorites...
foreach ($data['faves'] as $nickname) {
$user = User::getKV('nickname', $nickname);
- if ($user) {
+
+ if ($user instanceof User) {
Fave::addNew($user->getProfile(), $notice);
}
}
// @fixme if we see a group link inline, don't add this?
$group = User_group::getKV('id', $groupId);
- if ($group) {
+ if ($group instanceof User_group) {
$content .= ' !' . $group->nickname;
}
}
function setUp()
{
$user = User::getKV('nickname', 'userrightstestuser');
- if ($user) {
+
+ if ($user instanceof User) {
// Leftover from a broken test run?
$profile = $user->getProfile();
$user->delete();
$profile->delete();
}
+
$this->user = User::register(array('nickname' => 'userrightstestuser'));
+
if (!$this->user) {
throw new Exception("Couldn't register userrightstestuser");
}