mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 00:10:57 +01:00
Profile image stuff
This commit is contained in:
parent
03fec6e911
commit
e28c2e8899
8 changed files with 56 additions and 6 deletions
|
@ -42,5 +42,7 @@ return array(
|
|||
'recaptcha.private-key' => null,
|
||||
|
||||
|
||||
'user.default-profile-image-phid' => 'PHID-FILE-f57aaefce707fc4060ef',
|
||||
|
||||
|
||||
);
|
||||
|
|
|
@ -131,6 +131,24 @@ class PhabricatorFacebookAuthController extends PhabricatorAuthController {
|
|||
return id(new AphrontRedirectResponse())
|
||||
->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();
|
||||
if ($current_user->getPHID()) {
|
||||
|
|
|
@ -85,6 +85,7 @@ class PhabricatorLoginController extends PhabricatorAuthController {
|
|||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader('Phabricator Login');
|
||||
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
||||
// $panel->setCreateButton('Register New Account', '/login/register/');
|
||||
$panel->appendChild($form);
|
||||
|
||||
$fbauth_enabled = PhabricatorEnv::getEnvConfig('facebook.auth-enabled');
|
||||
|
@ -117,7 +118,7 @@ class PhabricatorLoginController extends PhabricatorAuthController {
|
|||
id(new AphrontFormSubmitControl())
|
||||
->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);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,15 +50,15 @@ final class DifferentialRevisionCommentView extends AphrontView {
|
|||
|
||||
$date = date('F jS, Y g:i:s A', $comment->getDateCreated());
|
||||
|
||||
$author = $comment->getAuthorPHID();
|
||||
$author = $this->handles[$author]->renderLink();
|
||||
$author = $this->handles[$comment->getAuthorPHID()];
|
||||
$author_link = $author->renderLink();
|
||||
|
||||
$verb = DifferentialAction::getActionPastTenseVerb($comment->getAction());
|
||||
$verb = phutil_escape_html($verb);
|
||||
|
||||
$content = $comment->getContent();
|
||||
if (strlen(rtrim($content))) {
|
||||
$title = "{$author} {$verb} this revision:";
|
||||
$title = "{$author_link} {$verb} this revision:";
|
||||
$content =
|
||||
'<div class="phabricator-remarkup">'.
|
||||
$this->markupEngine->markupText($content).
|
||||
|
@ -67,9 +67,15 @@ final class DifferentialRevisionCommentView extends AphrontView {
|
|||
$title = null;
|
||||
$content =
|
||||
'<div class="differential-comment-nocontent">'.
|
||||
"<p>{$author} {$verb} this revision.</p>".
|
||||
"<p>{$author_link} {$verb} this revision.</p>".
|
||||
'</div>';
|
||||
}
|
||||
|
||||
$background = null;
|
||||
$uri = $author->getImageURI();
|
||||
if ($uri) {
|
||||
$background = "background-image: url('{$uri}');";
|
||||
}
|
||||
|
||||
return
|
||||
'<div class="differential-comment '.$action_class.'">'.
|
||||
|
@ -77,7 +83,7 @@ final class DifferentialRevisionCommentView extends AphrontView {
|
|||
'<div class="differential-comment-date">'.$date.'</div>'.
|
||||
'<div class="differential-comment-title">'.$title.'</div>'.
|
||||
'</div>'.
|
||||
'<div class="differential-comment-body">'.
|
||||
'<div class="differential-comment-body" style="'.$background.'">'.
|
||||
'<div class="differential-comment-core">'.
|
||||
'<div class="differential-comment-content">'.
|
||||
$content.
|
||||
|
|
|
@ -52,6 +52,7 @@ class PhabricatorFileViewController extends PhabricatorFileController {
|
|||
|
||||
$form = new AphrontFormView();
|
||||
$form->setAction('/file/view/'.$file->getPHID().'/');
|
||||
$form->setUser($this->getRequest()->getUser());
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormStaticControl())
|
||||
|
|
|
@ -30,6 +30,12 @@ class PhabricatorUser extends PhabricatorUserDAO {
|
|||
protected $profileImagePHID;
|
||||
|
||||
private $sessionKey;
|
||||
|
||||
public function getProfileImagePHID() {
|
||||
return nonempty(
|
||||
$this->profileImagePHID,
|
||||
PhabricatorEnv::getEnvConfig('user.default-profile-image-phid'));
|
||||
}
|
||||
|
||||
public function getConfiguration() {
|
||||
return array(
|
||||
|
|
|
@ -23,6 +23,7 @@ class PhabricatorObjectHandle {
|
|||
private $type;
|
||||
private $name;
|
||||
private $email;
|
||||
private $imageURI;
|
||||
|
||||
public function setURI($uri) {
|
||||
$this->uri = $uri;
|
||||
|
@ -68,6 +69,15 @@ class PhabricatorObjectHandle {
|
|||
public function getEmail() {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setImageURI($uri) {
|
||||
$this->imageURI = $uri;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getImageURI() {
|
||||
return $this->imageURI;
|
||||
}
|
||||
|
||||
public function renderLink() {
|
||||
return phutil_render_tag(
|
||||
|
|
|
@ -58,6 +58,12 @@ class PhabricatorObjectHandleData {
|
|||
$handle->setName($user->getUsername());
|
||||
$handle->setURI('/p/'.$user->getUsername().'/');
|
||||
$handle->setEmail($user->getEmail());
|
||||
|
||||
$img_phid = $user->getProfileImagePHID();
|
||||
if ($img_phid) {
|
||||
$handle->setImageURI(
|
||||
PhabricatorFileURI::getViewURIForPHID($img_phid));
|
||||
}
|
||||
}
|
||||
$handles[$phid] = $handle;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue