Move all files to 2017/
This commit is contained in:
parent
ac7370f67f
commit
2875863330
15717 changed files with 0 additions and 0 deletions
20
2017/web/core/modules/tracker/src/Controller/TrackerPage.php
Normal file
20
2017/web/core/modules/tracker/src/Controller/TrackerPage.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\tracker\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
|
||||
/**
|
||||
* Controller for tracker.page route.
|
||||
*/
|
||||
class TrackerPage extends ControllerBase {
|
||||
|
||||
/**
|
||||
* Content callback for the tracker.page route.
|
||||
*/
|
||||
public function getContent() {
|
||||
module_load_include('inc', 'tracker', 'tracker.pages');
|
||||
return tracker_page();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\tracker\Controller;
|
||||
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\user\UserInterface;
|
||||
|
||||
/**
|
||||
* Controller for tracker.users_recent_content route.
|
||||
*/
|
||||
class TrackerUserRecent extends ControllerBase {
|
||||
|
||||
/**
|
||||
* Content callback for the tracker.users_recent_content route.
|
||||
*/
|
||||
public function getContent(UserInterface $user) {
|
||||
module_load_include('inc', 'tracker', 'tracker.pages');
|
||||
return tracker_page($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks access for the users recent content tracker page.
|
||||
*
|
||||
* @param \Drupal\user\UserInterface $user
|
||||
* The user being viewed.
|
||||
* @param \Drupal\Core\Session\AccountInterface $account
|
||||
* The account viewing the page.
|
||||
*
|
||||
* @return \Drupal\Core\Access\AccessResult
|
||||
* The access result.
|
||||
*/
|
||||
public function checkAccess(UserInterface $user, AccountInterface $account) {
|
||||
return AccessResult::allowedIf($account->isAuthenticated() && $user->id() == $account->id())
|
||||
->cachePerUser();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\tracker\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\user\UserInterface;
|
||||
|
||||
/**
|
||||
* Controller for tracker.user_tab route.
|
||||
*/
|
||||
class TrackerUserTab extends ControllerBase {
|
||||
|
||||
/**
|
||||
* Content callback for the tracker.user_tab route.
|
||||
*/
|
||||
public function getContent(UserInterface $user) {
|
||||
module_load_include('inc', 'tracker', 'tracker.pages');
|
||||
return tracker_page($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Title callback for the tracker.user_tab route.
|
||||
*/
|
||||
public function getTitle(UserInterface $user) {
|
||||
return $user->getUsername();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\tracker\Plugin\Menu;
|
||||
|
||||
use Drupal\Core\Menu\LocalTaskDefault;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
|
||||
/**
|
||||
* Provides route parameters needed to link to the current user tracker tab.
|
||||
*/
|
||||
class UserTrackerTab extends LocalTaskDefault {
|
||||
|
||||
/**
|
||||
* Current user object.
|
||||
*
|
||||
* @var \Drupal\Core\Session\AccountInterface
|
||||
*/
|
||||
protected $currentUser;
|
||||
|
||||
/**
|
||||
* Gets the current active user.
|
||||
*
|
||||
* @todo: https://www.drupal.org/node/2105123 put this method in
|
||||
* \Drupal\Core\Plugin\PluginBase instead.
|
||||
*
|
||||
* @return \Drupal\Core\Session\AccountInterface
|
||||
*/
|
||||
protected function currentUser() {
|
||||
if (!$this->currentUser) {
|
||||
$this->currentUser = \Drupal::currentUser();
|
||||
}
|
||||
return $this->currentUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteParameters(RouteMatchInterface $route_match) {
|
||||
return ['user' => $this->currentUser()->Id()];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\tracker\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 7 tracker node source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_tracker_node",
|
||||
* source_module = "tracker"
|
||||
* )
|
||||
*/
|
||||
class TrackerNode extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('tracker_node', 'tn')->fields('tn');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'nid' => $this->t('The {node}.nid this record tracks.'),
|
||||
'published' => $this->t('Boolean indicating whether the node is published.'),
|
||||
'changed' => $this->t('The Unix timestamp when the node was most recently saved or commented on.'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['nid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\tracker\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 7 tracker user source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_tracker_user",
|
||||
* source_module = "tracker"
|
||||
* )
|
||||
*/
|
||||
class TrackerUser extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('tracker_user', 'tu')->fields('tu');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'nid' => $this->t('The {user}.nid this record tracks.'),
|
||||
'uid' => $this->t('The {users}.uid of the node author or commenter.'),
|
||||
'published' => $this->t('Boolean indicating whether the node is published.'),
|
||||
'changed' => $this->t('The Unix timestamp when the user was most recently saved or commented on.'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['nid']['type'] = 'integer';
|
||||
$ids['uid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\tracker\Plugin\views\argument;
|
||||
|
||||
use Drupal\comment\Plugin\views\argument\UserUid as CommentUserUid;
|
||||
|
||||
/**
|
||||
* UID argument to check for nodes that user posted or commented on.
|
||||
*
|
||||
* @ingroup views_argument_handlers
|
||||
*
|
||||
* @ViewsArgument("tracker_user_uid")
|
||||
*/
|
||||
class UserUid extends CommentUserUid {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query($group_by = FALSE) {
|
||||
// Because this handler thinks it's an argument for a field on the {node}
|
||||
// table, we need to make sure {tracker_user} is JOINed and use its alias
|
||||
// for the WHERE clause.
|
||||
$tracker_user_alias = $this->query->ensureTable('tracker_user');
|
||||
$this->query->addWhere(0, "$tracker_user_alias.uid", $this->argument);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\tracker\Plugin\views\filter;
|
||||
|
||||
use Drupal\user\Plugin\views\filter\Name;
|
||||
|
||||
/**
|
||||
* UID filter to check for nodes that a user posted or commented on.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*
|
||||
* @ViewsFilter("tracker_user_uid")
|
||||
*/
|
||||
class UserUid extends Name {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Because this handler thinks it's an argument for a field on the {node}
|
||||
// table, we need to make sure {tracker_user} is JOINed and use its alias
|
||||
// for the WHERE clause.
|
||||
$tracker_user_alias = $this->query->ensureTable('tracker_user');
|
||||
// Cast scalars to array so we can consistently use an IN condition.
|
||||
$this->query->addWhere(0, "$tracker_user_alias.uid", (array) $this->value, 'IN');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\tracker\Tests\Views;
|
||||
|
||||
@trigger_error(__NAMESPACE__ . '\TrackerTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\tracker\Functional\Views\TrackerTestBase', E_USER_DEPRECATED);
|
||||
|
||||
use Drupal\comment\Tests\CommentTestTrait;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
|
||||
/**
|
||||
* Base class for all tracker tests.
|
||||
*
|
||||
* @deprecated Scheduled for removal in Drupal 9.0.0.
|
||||
* Use \Drupal\Tests\tracker\Functional\Views\TrackerTestBase instead.
|
||||
*/
|
||||
abstract class TrackerTestBase extends ViewTestBase {
|
||||
|
||||
use CommentTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['comment', 'tracker', 'tracker_test_views'];
|
||||
|
||||
/**
|
||||
* The node used for testing.
|
||||
*
|
||||
* @var \Drupal\node\NodeInterface
|
||||
*/
|
||||
protected $node;
|
||||
|
||||
/**
|
||||
* The comment used for testing.
|
||||
*
|
||||
* @var \Drupal\comment\CommentInterface
|
||||
*/
|
||||
protected $comment;
|
||||
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), ['tracker_test_views']);
|
||||
|
||||
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
|
||||
// Add a comment field.
|
||||
$this->addDefaultCommentField('node', 'page');
|
||||
|
||||
$permissions = ['access comments', 'create page content', 'post comments', 'skip comment approval'];
|
||||
$account = $this->drupalCreateUser($permissions);
|
||||
|
||||
$this->drupalLogin($account);
|
||||
|
||||
$this->node = $this->drupalCreateNode([
|
||||
'title' => $this->randomMachineName(8),
|
||||
'uid' => $account->id(),
|
||||
'status' => 1,
|
||||
]);
|
||||
|
||||
$this->comment = Comment::create([
|
||||
'entity_id' => $this->node->id(),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'comment',
|
||||
'subject' => $this->randomMachineName(),
|
||||
'comment_body[' . LanguageInterface::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomMachineName(20),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue