1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00

Profile image stuff

This commit is contained in:
epriestley 2011-01-31 16:00:42 -08:00
parent 03fec6e911
commit e28c2e8899
8 changed files with 56 additions and 6 deletions

View file

@ -42,5 +42,7 @@ return array(
'recaptcha.private-key' => null, 'recaptcha.private-key' => null,
'user.default-profile-image-phid' => 'PHID-FILE-f57aaefce707fc4060ef',
); );

View file

@ -132,6 +132,24 @@ class PhabricatorFacebookAuthController extends PhabricatorAuthController {
->setURI('/'); ->setURI('/');
} }
$known_email = id(new PhabricatorUser())
->loadOneWhere('email = %s', $user_data['email']);
if ($known_email) {
if ($known_email->getFacebookUID()) {
throw new Exception(
"The email associated with the Facebook account you just logged in ".
"with is already associated with another Phabricator account which ".
"is, in turn, associated with a Facebook account different from ".
"the one you just logged in with.");
}
$known_email->setFacebookUID($user_id);
$session_key = $known_email->establishSession('web');
$request->setCookie('phusr', $known_email->getUsername());
$request->setCookie('phsid', $session_key);
return id(new AphrontRedirectResponse())
->setURI('/');
}
$current_user = $this->getRequest()->getUser(); $current_user = $this->getRequest()->getUser();
if ($current_user->getPHID()) { if ($current_user->getPHID()) {
if ($current_user->getFacebookUID() && if ($current_user->getFacebookUID() &&

View file

@ -85,6 +85,7 @@ class PhabricatorLoginController extends PhabricatorAuthController {
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->setHeader('Phabricator Login'); $panel->setHeader('Phabricator Login');
$panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->setWidth(AphrontPanelView::WIDTH_FORM);
// $panel->setCreateButton('Register New Account', '/login/register/');
$panel->appendChild($form); $panel->appendChild($form);
$fbauth_enabled = PhabricatorEnv::getEnvConfig('facebook.auth-enabled'); $fbauth_enabled = PhabricatorEnv::getEnvConfig('facebook.auth-enabled');
@ -117,7 +118,7 @@ class PhabricatorLoginController extends PhabricatorAuthController {
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue("Login with Facebook \xC2\xBB")); ->setValue("Login with Facebook \xC2\xBB"));
$panel->appendChild('<br /><h1>Login with Facebook</h1>'); $panel->appendChild('<br /><h1>Login or Register with Facebook</h1>');
$panel->appendChild($facebook_auth); $panel->appendChild($facebook_auth);
} }

View file

@ -50,15 +50,15 @@ final class DifferentialRevisionCommentView extends AphrontView {
$date = date('F jS, Y g:i:s A', $comment->getDateCreated()); $date = date('F jS, Y g:i:s A', $comment->getDateCreated());
$author = $comment->getAuthorPHID(); $author = $this->handles[$comment->getAuthorPHID()];
$author = $this->handles[$author]->renderLink(); $author_link = $author->renderLink();
$verb = DifferentialAction::getActionPastTenseVerb($comment->getAction()); $verb = DifferentialAction::getActionPastTenseVerb($comment->getAction());
$verb = phutil_escape_html($verb); $verb = phutil_escape_html($verb);
$content = $comment->getContent(); $content = $comment->getContent();
if (strlen(rtrim($content))) { if (strlen(rtrim($content))) {
$title = "{$author} {$verb} this revision:"; $title = "{$author_link} {$verb} this revision:";
$content = $content =
'<div class="phabricator-remarkup">'. '<div class="phabricator-remarkup">'.
$this->markupEngine->markupText($content). $this->markupEngine->markupText($content).
@ -67,17 +67,23 @@ final class DifferentialRevisionCommentView extends AphrontView {
$title = null; $title = null;
$content = $content =
'<div class="differential-comment-nocontent">'. '<div class="differential-comment-nocontent">'.
"<p>{$author} {$verb} this revision.</p>". "<p>{$author_link} {$verb} this revision.</p>".
'</div>'; '</div>';
} }
$background = null;
$uri = $author->getImageURI();
if ($uri) {
$background = "background-image: url('{$uri}');";
}
return return
'<div class="differential-comment '.$action_class.'">'. '<div class="differential-comment '.$action_class.'">'.
'<div class="differential-comment-head">'. '<div class="differential-comment-head">'.
'<div class="differential-comment-date">'.$date.'</div>'. '<div class="differential-comment-date">'.$date.'</div>'.
'<div class="differential-comment-title">'.$title.'</div>'. '<div class="differential-comment-title">'.$title.'</div>'.
'</div>'. '</div>'.
'<div class="differential-comment-body">'. '<div class="differential-comment-body" style="'.$background.'">'.
'<div class="differential-comment-core">'. '<div class="differential-comment-core">'.
'<div class="differential-comment-content">'. '<div class="differential-comment-content">'.
$content. $content.

View file

@ -52,6 +52,7 @@ class PhabricatorFileViewController extends PhabricatorFileController {
$form = new AphrontFormView(); $form = new AphrontFormView();
$form->setAction('/file/view/'.$file->getPHID().'/'); $form->setAction('/file/view/'.$file->getPHID().'/');
$form->setUser($this->getRequest()->getUser());
$form $form
->appendChild( ->appendChild(
id(new AphrontFormStaticControl()) id(new AphrontFormStaticControl())

View file

@ -31,6 +31,12 @@ class PhabricatorUser extends PhabricatorUserDAO {
private $sessionKey; private $sessionKey;
public function getProfileImagePHID() {
return nonempty(
$this->profileImagePHID,
PhabricatorEnv::getEnvConfig('user.default-profile-image-phid'));
}
public function getConfiguration() { public function getConfiguration() {
return array( return array(
self::CONFIG_AUX_PHID => true, self::CONFIG_AUX_PHID => true,

View file

@ -23,6 +23,7 @@ class PhabricatorObjectHandle {
private $type; private $type;
private $name; private $name;
private $email; private $email;
private $imageURI;
public function setURI($uri) { public function setURI($uri) {
$this->uri = $uri; $this->uri = $uri;
@ -69,6 +70,15 @@ class PhabricatorObjectHandle {
return $this->email; return $this->email;
} }
public function setImageURI($uri) {
$this->imageURI = $uri;
return $this;
}
public function getImageURI() {
return $this->imageURI;
}
public function renderLink() { public function renderLink() {
return phutil_render_tag( return phutil_render_tag(
'a', 'a',

View file

@ -58,6 +58,12 @@ class PhabricatorObjectHandleData {
$handle->setName($user->getUsername()); $handle->setName($user->getUsername());
$handle->setURI('/p/'.$user->getUsername().'/'); $handle->setURI('/p/'.$user->getUsername().'/');
$handle->setEmail($user->getEmail()); $handle->setEmail($user->getEmail());
$img_phid = $user->getProfileImagePHID();
if ($img_phid) {
$handle->setImageURI(
PhabricatorFileURI::getViewURIForPHID($img_phid));
}
} }
$handles[$phid] = $handle; $handles[$phid] = $handle;
} }