From: Mikael Nordfeldth Date: Tue, 14 Jul 2015 14:52:20 +0000 (+0200) Subject: Removing MicroID as well as simplifying profileaction X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=01a4ab30dc1dfbf4d6ee6a42a7f8f45a1a42894d;p=quix0rs-gnu-social.git Removing MicroID as well as simplifying profileaction sorry, forgot to commit in between --- diff --git a/actions/emailsettings.php b/actions/emailsettings.php index a0f111c0d5..cffc5da247 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -231,12 +231,6 @@ class EmailsettingsAction extends SettingsAction _('Allow friends to nudge me and send me an email.'), $user->emailnotifynudge); $this->elementEnd('li'); - $this->elementStart('li'); - $this->checkbox('emailmicroid', - // TRANS: Checkbox label in e-mail preferences form. - _('Publish a MicroID for my email address.'), - $user->emailmicroid); - $this->elementEnd('li'); Event::handle('EndEmailFormData', array($this, $this->scoped)); } $this->elementEnd('ul'); @@ -320,7 +314,6 @@ class EmailsettingsAction extends SettingsAction $emailnotifymsg = $this->booleanintstring('emailnotifymsg'); $emailnotifynudge = $this->booleanintstring('emailnotifynudge'); $emailnotifyattn = $this->booleanintstring('emailnotifyattn'); - $emailmicroid = $this->booleanintstring('emailmicroid'); $emailpost = $this->booleanintstring('emailpost'); $user->query('BEGIN'); @@ -331,7 +324,6 @@ class EmailsettingsAction extends SettingsAction $user->emailnotifymsg = $emailnotifymsg; $user->emailnotifynudge = $emailnotifynudge; $user->emailnotifyattn = $emailnotifyattn; - $user->emailmicroid = $emailmicroid; $user->emailpost = $emailpost; $result = $user->update($original); diff --git a/actions/groupbyid.php b/actions/groupbyid.php index b82a861e97..8556675155 100644 --- a/actions/groupbyid.php +++ b/actions/groupbyid.php @@ -28,12 +28,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} - -require_once INSTALLDIR.'/lib/noticelist.php'; -require_once INSTALLDIR.'/lib/feedlist.php'; +if (!defined('GNUSOCIAL')) { exit(1); } /** * Permalink for a group diff --git a/actions/imsettings.php b/actions/imsettings.php index 92fff45a7d..feb5d32fc1 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -179,8 +179,6 @@ class ImsettingsAction extends SettingsAction // TRANS: Checkbox label in IM preferences form. array('name'=>'replies', 'description'=>_('Send me replies '. 'from people I\'m not subscribed to.')), - // TRANS: Checkbox label in IM preferences form. - array('name'=>'microid', 'description'=>_('Publish a MicroID')) ); foreach($preferences as $preference) { @@ -277,7 +275,7 @@ class ImsettingsAction extends SettingsAction $user_im_prefs->user_id = $user->id; if($user_im_prefs->find() && $user_im_prefs->fetch()) { - $preferences = array('notify', 'updatefrompresence', 'replies', 'microid'); + $preferences = array('notify', 'updatefrompresence', 'replies'); do { $original = clone($user_im_prefs); diff --git a/actions/shownotice.php b/actions/shownotice.php index 4a1adfd7de..23386868dd 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -222,25 +222,12 @@ class ShownoticeAction extends ManagedAction /** * Extra content * - * We show the microid(s) for the author, if any. + * Facebook OpenGraph metadata. * * @return void */ function extraHead() { - $user = User::getKV($this->profile->id); - - if (!$user instanceof User) { - return; - } - - if ($user->emailmicroid && $user->email && $this->notice->uri) { - $id = new Microid('mailto:'. $user->email, - $this->notice->uri); - $this->element('meta', array('name' => 'microid', - 'content' => $id->toString())); - } - // Extras to aid in sharing notices to Facebook $avatarUrl = $this->profile->avatarUrl(AVATAR_PROFILE_SIZE); $this->element('meta', array('property' => 'og:image', diff --git a/actions/showstream.php b/actions/showstream.php index 51384eb487..890c1e711b 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -47,38 +47,6 @@ if (!defined('GNUSOCIAL')) { exit(1); } */ class ShowstreamAction extends NoticestreamAction { - protected $target = null; - - protected function doPreparation() - { - // showstream requires a nickname - $nickname_arg = $this->trimmed('nickname'); - $nickname = common_canonical_nickname($nickname_arg); - - // Permanent redirect on non-canonical nickname - if ($nickname_arg != $nickname) { - $args = array('nickname' => $nickname); - if ($this->arg('page') && $this->arg('page') != 1) { - $args['page'] = $this->arg['page']; - } - common_redirect(common_local_url($this->getActionName(), $args), 301); - } - - try { - $user = User::getByNickname($nickname); - } catch (NoSuchUserException $e) { - $group = Local_group::getKV('nickname', $nickname); - if ($group instanceof Local_group) { - common_redirect($group->getProfile()->getUrl()); - } - - // No user nor group found, throw the NoSuchUserException again - throw $e; - } - - $this->target = $user->getProfile(); - } - public function getStream() { if (empty($this->tag)) { @@ -195,13 +163,6 @@ class ShowstreamAction extends NoticestreamAction 'content' => $this->target->getDescription())); } - if ($this->target->isLocal() && $this->target->getUser()->emailmicroid && $this->target->getUser()->email && $this->target->getUrl()) { - $id = new Microid('mailto:'.$this->target->getUser()->email, - $this->selfUrl()); - $this->element('meta', array('name' => 'microid', - 'content' => $id->toString())); - } - // See https://wiki.mozilla.org/Microsummaries $this->element('link', array('rel' => 'microsummary', diff --git a/classes/User.php b/classes/User.php index ec6ceccf12..e1ce33be18 100644 --- a/classes/User.php +++ b/classes/User.php @@ -42,7 +42,6 @@ class User extends Managed_DataObject public $emailnotifynudge; // tinyint(1) default_1 public $emailnotifymsg; // tinyint(1) default_1 public $emailnotifyattn; // tinyint(1) default_1 - public $emailmicroid; // tinyint(1) default_1 public $language; // varchar(50) public $timezone; // varchar(50) public $emailpost; // tinyint(1) default_1 @@ -77,7 +76,6 @@ class User extends Managed_DataObject 'emailnotifynudge' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of nudges'), 'emailnotifymsg' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of direct messages'), 'emailnotifyattn' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of @-replies'), - 'emailmicroid' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'whether to publish email microid'), 'language' => array('type' => 'varchar', 'length' => 50, 'description' => 'preferred language'), 'timezone' => array('type' => 'varchar', 'length' => 50, 'description' => 'timezone'), 'emailpost' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Post by email'), @@ -276,9 +274,7 @@ class User extends Managed_DataObject $user->emailnotifynudge = 1; $user->emailnotifymsg = 1; $user->emailnotifyattn = 1; - $user->emailmicroid = 1; $user->emailpost = 1; - $user->jabbermicroid = 1; $user->created = common_sql_now(); diff --git a/classes/User_im_prefs.php b/classes/User_im_prefs.php index 16fd030bb4..6a5fc7f3ab 100644 --- a/classes/User_im_prefs.php +++ b/classes/User_im_prefs.php @@ -40,7 +40,6 @@ class User_im_prefs extends Managed_DataObject public $transport; // varchar(191) not_null not 255 because utf8mb4 takes more space public $notify; // tinyint(1) public $replies; // tinyint(1) - public $microid; // tinyint(1) public $updatefrompresence; // tinyint(1) public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00 public $modified; // timestamp not_null default_CURRENT_TIMESTAMP @@ -57,7 +56,6 @@ class User_im_prefs extends Managed_DataObject 'transport' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'transport (ex xmpp, aim)'), 'notify' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Notify when a new notice is sent'), 'replies' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to'), - 'microid' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'Publish a MicroID'), 'updatefrompresence' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to.'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), diff --git a/lib/galleryaction.php b/lib/galleryaction.php index f87043ac06..5dd0cfcfa7 100644 --- a/lib/galleryaction.php +++ b/lib/galleryaction.php @@ -36,35 +36,6 @@ class GalleryAction extends ProfileAction parent::handle(); } - protected function doPreparation() - { - // showstream requires a nickname - $nickname_arg = $this->arg('nickname'); - $nickname = common_canonical_nickname($nickname_arg); - - // Permanent redirect on non-canonical nickname - - if ($nickname_arg != $nickname) { - $args = array('nickname' => $nickname); - if ($this->arg('page') && $this->arg('page') != 1) { - $args['page'] = $this->arg['page']; - } - common_redirect(common_local_url($this->getActionName(), $args), 301); - } - $this->user = User::getKV('nickname', $nickname); - - if (!$this->user) { - $group = Local_group::getKV('nickname', $nickname); - if ($group instanceof Local_group) { - common_redirect($group->getProfile()->getUrl()); - } - // TRANS: Client error displayed when calling a profile action without specifying a user. - $this->clientError(_('No such user.'), 404); - } - - $this->target = $this->user->getProfile(); - } - function showContent() { $this->showTagsDropdown(); diff --git a/lib/implugin.php b/lib/implugin.php index 87ca037160..6395ecbdb7 100644 --- a/lib/implugin.php +++ b/lib/implugin.php @@ -126,17 +126,6 @@ abstract class ImPlugin extends Plugin */ abstract function daemonScreenname(); - /** - * get the microid uri of a given screenname - * - * @param string $screenname screenname - * - * @return string microid uri - */ - function microiduri($screenname) - { - return $this->transport . ':' . $screenname; - } //========================UTILITY FUNCTIONS USEFUL TO IMPLEMENTATIONS - MISC ========================\ /** @@ -571,25 +560,12 @@ abstract class ImPlugin extends Plugin $user_im_prefs->user_id = $action->notice->getProfile()->getID(); $user_im_prefs->transport = $this->transport; - if ($user_im_prefs->find() && $user_im_prefs->fetch() && $user_im_prefs->microid && $action->notice->uri) { - $id = new Microid($this->microiduri($user_im_prefs->screenname), - $action->notice->uri); - $action->element('meta', array('name' => 'microid', - 'content' => $id->toString())); - } - } elseif ($action instanceof ShowstreamAction) { $user_im_prefs = new User_im_prefs(); $user_im_prefs->user_id = $action->getTarget()->getID(); $user_im_prefs->transport = $this->transport; - if ($user_im_prefs->find() && $user_im_prefs->fetch() && $user_im_prefs->microid && $action->getTarget()->getUrl()) { - $id = new Microid($this->microiduri($user_im_prefs->screenname), - $action->selfUrl()); - $action->element('meta', array('name' => 'microid', - 'content' => $id->toString())); - } } } diff --git a/lib/microid.php b/lib/microid.php deleted file mode 100644 index e2e7d7607f..0000000000 --- a/lib/microid.php +++ /dev/null @@ -1,97 +0,0 @@ -. - * - * @category ID - * @package StatusNet - * @author Evan Prodromou - * @copyright 2008 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} - -/** - * A class for microids - * - * @category ID - * @package StatusNet - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - * @see http://microid.org/ - */ - -class Microid -{ - /** Agent part of the ID. */ - - var $agent = null; - - /** Resource part of the ID. */ - - var $resource = null; - - /** - * Constructor - * - * @param string $agent Agent of the ID - * @param string $resource Resource part - */ - - function __construct($agent, $resource) - { - $this->agent = $agent; - $this->resource = $resource; - - } - - /** - * Generate a MicroID string - * - * @return string MicroID for agent and resource - */ - - function toString() - { - $agent_proto = $this->_getProto($this->agent); - $resource_proto = $this->_getProto($this->resource); - - return $agent_proto.'+'.$resource_proto.':sha1:'. - sha1(sha1($this->agent).sha1($this->resource)); - } - - /** - * Utility for getting the protocol part of a URI - * - * @param string $uri URI to parse - * - * @return string scheme part of the URI - */ - - function _getProto($uri) - { - $colon = strpos($uri, ':'); - return substr($uri, 0, $colon); - } -} diff --git a/lib/profileaction.php b/lib/profileaction.php index 5a5d526e42..3dc28a7cc4 100644 --- a/lib/profileaction.php +++ b/lib/profileaction.php @@ -48,6 +48,36 @@ abstract class ProfileAction extends ManagedAction protected $target = null; // Profile that we're showing + protected function doPreparation() + { + // showstream requires a nickname + $nickname_arg = $this->trimmed('nickname'); + $nickname = common_canonical_nickname($nickname_arg); + + // Permanent redirect on non-canonical nickname + if ($nickname_arg != $nickname) { + $args = array('nickname' => $nickname); + if ($this->arg('page') && $this->arg('page') != 1) { + $args['page'] = $this->arg['page']; + } + common_redirect(common_local_url($this->getActionName(), $args), 301); + } + + try { + $user = User::getByNickname($nickname); + } catch (NoSuchUserException $e) { + $group = Local_group::getKV('nickname', $nickname); + if ($group instanceof Local_group) { + common_redirect($group->getProfile()->getUrl()); + } + + // No user nor group found, throw the NoSuchUserException again + throw $e; + } + + $this->target = $user->getProfile(); + } + protected function prepare(array $args=array()) { // this will call ->doPreparation() which child classes use to set $this->target @@ -65,11 +95,6 @@ abstract class ProfileAction extends ManagedAction return true; } - protected function profileActionPreparation() - { - // Nothing to do by default. - } - public function getTarget() { if (!$this->target instanceof Profile) { diff --git a/plugins/Xmpp/XmppPlugin.php b/plugins/Xmpp/XmppPlugin.php index 0a70268735..04101a8e2b 100644 --- a/plugins/Xmpp/XmppPlugin.php +++ b/plugins/Xmpp/XmppPlugin.php @@ -308,11 +308,6 @@ class XmppPlugin extends ImPlugin return true; } - function microiduri($screenname) - { - return 'xmpp:' . $screenname; - } - function sendMessage($screenname, $body) { $this->queuedConnection()->message($screenname, $body, 'chat');