Loading modules/o365_onedrive/src/Plugin/Block/RecentFilesBlock.php +55 −1 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\o365\Block\O365UncachedBlockBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\o365_onedrive\GetFilesAndFoldersServiceInterface; use Drupal\Core\Form\FormStateInterface; /** * Provides a 'Recent Files' block. Loading Loading @@ -57,7 +58,60 @@ class RecentFilesBlock extends O365UncachedBlockBase implements ContainerFactory * @throws \Microsoft\Graph\Exception\GraphException */ public function build() { return $this->getFilesAndFoldersService->listSpecialFilesAndFolders('recent'); $blockData = $this->getFilesAndFoldersService->listSpecialFilesAndFolders('recent'); if (!empty($blockData)) { return $blockData; } $config = $this->getConfiguration(); if ($config['show_recent_files_block']) { return [ '#theme' => 'o365_onedrive_results', '#results' => $config['recent_files_block_text'], ]; } return []; } /** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $form['show_recent_files_block'] = [ '#type' => 'checkbox', '#title' => $this->t('Show latest unread mail\'s when there is no data'), ]; $form['recent_files_block_text'] = [ '#type' => 'textarea', '#title' => t('Mail block text'), '#description' => t('Enter the text you would like to show'), '#default_value' => t('Enter the text you would like to show'), '#states' => [ 'visible' => [ 'input[name="show_recent_files_block"]' => [ 'checked' => TRUE, ], ], ], ]; return $form; } /** * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state) { $values = $form_state->getValues(); $this->configuration['show_recent_files_block'] = $values['show_recent_files_block']; $this->configuration['recent_files_block_text'] = $values['recent_files_block_text']; } } modules/o365_onedrive/src/Plugin/Block/SharedFilesBlock.php +53 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\o365_onedrive\Plugin\Block; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\o365\Block\O365UncachedBlockBase; use Symfony\Component\DependencyInjection\ContainerInterface; Loading Loading @@ -57,7 +58,58 @@ class SharedFilesBlock extends O365UncachedBlockBase implements ContainerFactory * @throws \Microsoft\Graph\Exception\GraphException */ public function build() { return $this->getFilesAndFoldersService->listSharedFilesAndFolders(); $blockData = $this->getFilesAndFoldersService->listSharedFilesAndFolders(); if (!empty($blockData)) { return $blockData; } $config = $this->getConfiguration(); if ($config['show_recent_files_block']) { return [ '#theme' => 'o365_onedrive_results', '#results' => $config['recent_files_block_text'], ]; } return []; } /** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $form['show_shared_files_block'] = [ '#type' => 'checkbox', '#title' => $this->t('Show latest unread mail\'s when there is no data'), ]; $form['shared_files_block_text'] = [ '#type' => 'textarea', '#title' => t('Mail block text'), '#description' => t('Enter the text you would like to show'), '#default_value' => t('Enter the text you would like to show'), '#states' => [ 'visible' => [ 'input[name="show_shared_files_block"]' => [ 'checked' => TRUE, ], ], ], ]; return $form; } /** * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state) { $values = $form_state->getValues(); $this->configuration['show_shared_files_block'] = $values['show_shared_files_block']; $this->configuration['shared_files_block_text'] = $values['shared_files_block_text']; } } modules/o365_outlook_mail/o365_outlook_mail.module 100755 → 100644 +0 −35 Original line number Diff line number Diff line Loading @@ -5,8 +5,6 @@ * Implemented hooks for the o365_outlook_mail module. */ use Drupal\Core\Form\FormStateInterface; /** * Implements hook_o365_auth_scopes(). */ Loading Loading @@ -48,36 +46,3 @@ function o365_outlook_mail_theme($existing, $type, $theme, $path) { ], ]; } function o365_outlook_mail_form_alter(&$form, FormStateInterface $form_state, $form_id) { $config = \Drupal::config('o365.block_settings'); if ($form_id == 'block_settings_form') { // $form['value']['onedrive_block'] = [ $form['block_mail'] = [ '#type' => 'textarea', '#title' => t('Mail block text'), '#description' => t('Enter the text you would like to show'), '#default_value' => $config->get('block_mail'), '#states' => [ 'visible' => [ ':input[name="show_block"]' => ['checked' => TRUE], ], ], ]; } } ///** // * Implements hook_preprocess(). // */ //function o365_outlook_mail_preprocess_page(&$variables) { // // if (\Drupal::config('o365.block_settings')->get('show_block') == TRUE) { // $variables['block_mail'] = \Drupal::config('o365.block_settings') // ->get('block_mail'); // } // //} modules/o365_outlook_mail/src/Plugin/Block/LatestMailBlock.php +54 −1 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\o365\Block\O365UncachedBlockBase; use Drupal\o365_outlook_mail\GetMailServiceInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Form\FormStateInterface; /** * Provides a 'Latest Mail' block. Loading Loading @@ -57,7 +58,22 @@ class LatestMailBlock extends O365UncachedBlockBase implements ContainerFactoryP * @throws \Microsoft\Graph\Exception\GraphException */ public function build() { return $this->getMails(); $mails = $this->getMails(); if (!empty($mails)) { return $mails; } $config = $this->getConfiguration(); if ($config['show_latest_mail_block']) { return [ '#theme' => 'o365_outlook_mail_list_block', '#readmore_class' => 'button--primary button', '#list' => $config['latest_mail_block_text'], ]; } return []; } /** Loading Loading @@ -90,4 +106,41 @@ class LatestMailBlock extends O365UncachedBlockBase implements ContainerFactoryP return []; } /** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $form['show_latest_mail_block'] = [ '#type' => 'checkbox', '#title' => $this->t('Show latest unread mail\'s when there is no data'), ]; $form['latest_mail_block_text'] = [ '#type' => 'textarea', '#title' => t('Mail block text'), '#description' => t('Enter the text you would like to show'), '#default_value' => t('Enter the text you would like to show'), '#states' => [ 'visible' => [ 'input[name="show_latest_mail_block"]' => [ 'checked' => TRUE, ], ], ], ]; return $form; } /** * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state) { $values = $form_state->getValues(); $this->configuration['show_latest_mail_block'] = $values['show_latest_mail_block']; $this->configuration['latest_mail_block_text'] = $values['latest_mail_block_text']; } } modules/o365_outlook_mail/src/Plugin/Block/LatestUnreadMailBlock.php +53 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\o365_outlook_mail\Plugin\Block; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\o365\Block\O365UncachedBlockBase; use Drupal\o365_outlook_mail\GetMailServiceInterface; Loading Loading @@ -57,7 +58,21 @@ class LatestUnreadMailBlock extends O365UncachedBlockBase implements ContainerFa * @throws \Microsoft\Graph\Exception\GraphException */ public function build() { return $this->getMails(); $mails = $this->getMails(); if (!empty($mails)) { return $mails; } $config = $this->getConfiguration(); if ($config['show_latest_unread_mail_block']) { return [ '#theme' => 'o365_outlook_mail_list_block', '#readmore_class' => 'button--primary button', '#list' => $config['latest_unread_mail_block_text'], ]; } return []; } /** Loading Loading @@ -90,4 +105,41 @@ class LatestUnreadMailBlock extends O365UncachedBlockBase implements ContainerFa return []; } /** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $form['show_latest_unread_mail_block'] = [ '#type' => 'checkbox', '#title' => $this->t('Show latest unread mail\'s when there is no data'), ]; $form['latest_unread_mail_block_text'] = [ '#type' => 'textarea', '#title' => t('Mail block text'), '#description' => t('Enter the text you would like to show'), '#default_value' => t('Enter the text you would like to show'), '#states' => [ 'visible' => [ 'input[name="show_latest_unread_mail_block"]' => [ 'checked' => TRUE, ], ], ], ]; return $form; } /** * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state) { $values = $form_state->getValues(); $this->configuration['show_latest_unread_mail_block'] = $values['show_latest_unread_mail_block']; $this->configuration['latest_unread_mail_block_text'] = $values['latest_unread_mail_block_text']; } } Loading
modules/o365_onedrive/src/Plugin/Block/RecentFilesBlock.php +55 −1 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\o365\Block\O365UncachedBlockBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\o365_onedrive\GetFilesAndFoldersServiceInterface; use Drupal\Core\Form\FormStateInterface; /** * Provides a 'Recent Files' block. Loading Loading @@ -57,7 +58,60 @@ class RecentFilesBlock extends O365UncachedBlockBase implements ContainerFactory * @throws \Microsoft\Graph\Exception\GraphException */ public function build() { return $this->getFilesAndFoldersService->listSpecialFilesAndFolders('recent'); $blockData = $this->getFilesAndFoldersService->listSpecialFilesAndFolders('recent'); if (!empty($blockData)) { return $blockData; } $config = $this->getConfiguration(); if ($config['show_recent_files_block']) { return [ '#theme' => 'o365_onedrive_results', '#results' => $config['recent_files_block_text'], ]; } return []; } /** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $form['show_recent_files_block'] = [ '#type' => 'checkbox', '#title' => $this->t('Show latest unread mail\'s when there is no data'), ]; $form['recent_files_block_text'] = [ '#type' => 'textarea', '#title' => t('Mail block text'), '#description' => t('Enter the text you would like to show'), '#default_value' => t('Enter the text you would like to show'), '#states' => [ 'visible' => [ 'input[name="show_recent_files_block"]' => [ 'checked' => TRUE, ], ], ], ]; return $form; } /** * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state) { $values = $form_state->getValues(); $this->configuration['show_recent_files_block'] = $values['show_recent_files_block']; $this->configuration['recent_files_block_text'] = $values['recent_files_block_text']; } }
modules/o365_onedrive/src/Plugin/Block/SharedFilesBlock.php +53 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\o365_onedrive\Plugin\Block; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\o365\Block\O365UncachedBlockBase; use Symfony\Component\DependencyInjection\ContainerInterface; Loading Loading @@ -57,7 +58,58 @@ class SharedFilesBlock extends O365UncachedBlockBase implements ContainerFactory * @throws \Microsoft\Graph\Exception\GraphException */ public function build() { return $this->getFilesAndFoldersService->listSharedFilesAndFolders(); $blockData = $this->getFilesAndFoldersService->listSharedFilesAndFolders(); if (!empty($blockData)) { return $blockData; } $config = $this->getConfiguration(); if ($config['show_recent_files_block']) { return [ '#theme' => 'o365_onedrive_results', '#results' => $config['recent_files_block_text'], ]; } return []; } /** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $form['show_shared_files_block'] = [ '#type' => 'checkbox', '#title' => $this->t('Show latest unread mail\'s when there is no data'), ]; $form['shared_files_block_text'] = [ '#type' => 'textarea', '#title' => t('Mail block text'), '#description' => t('Enter the text you would like to show'), '#default_value' => t('Enter the text you would like to show'), '#states' => [ 'visible' => [ 'input[name="show_shared_files_block"]' => [ 'checked' => TRUE, ], ], ], ]; return $form; } /** * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state) { $values = $form_state->getValues(); $this->configuration['show_shared_files_block'] = $values['show_shared_files_block']; $this->configuration['shared_files_block_text'] = $values['shared_files_block_text']; } }
modules/o365_outlook_mail/o365_outlook_mail.module 100755 → 100644 +0 −35 Original line number Diff line number Diff line Loading @@ -5,8 +5,6 @@ * Implemented hooks for the o365_outlook_mail module. */ use Drupal\Core\Form\FormStateInterface; /** * Implements hook_o365_auth_scopes(). */ Loading Loading @@ -48,36 +46,3 @@ function o365_outlook_mail_theme($existing, $type, $theme, $path) { ], ]; } function o365_outlook_mail_form_alter(&$form, FormStateInterface $form_state, $form_id) { $config = \Drupal::config('o365.block_settings'); if ($form_id == 'block_settings_form') { // $form['value']['onedrive_block'] = [ $form['block_mail'] = [ '#type' => 'textarea', '#title' => t('Mail block text'), '#description' => t('Enter the text you would like to show'), '#default_value' => $config->get('block_mail'), '#states' => [ 'visible' => [ ':input[name="show_block"]' => ['checked' => TRUE], ], ], ]; } } ///** // * Implements hook_preprocess(). // */ //function o365_outlook_mail_preprocess_page(&$variables) { // // if (\Drupal::config('o365.block_settings')->get('show_block') == TRUE) { // $variables['block_mail'] = \Drupal::config('o365.block_settings') // ->get('block_mail'); // } // //}
modules/o365_outlook_mail/src/Plugin/Block/LatestMailBlock.php +54 −1 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\o365\Block\O365UncachedBlockBase; use Drupal\o365_outlook_mail\GetMailServiceInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Form\FormStateInterface; /** * Provides a 'Latest Mail' block. Loading Loading @@ -57,7 +58,22 @@ class LatestMailBlock extends O365UncachedBlockBase implements ContainerFactoryP * @throws \Microsoft\Graph\Exception\GraphException */ public function build() { return $this->getMails(); $mails = $this->getMails(); if (!empty($mails)) { return $mails; } $config = $this->getConfiguration(); if ($config['show_latest_mail_block']) { return [ '#theme' => 'o365_outlook_mail_list_block', '#readmore_class' => 'button--primary button', '#list' => $config['latest_mail_block_text'], ]; } return []; } /** Loading Loading @@ -90,4 +106,41 @@ class LatestMailBlock extends O365UncachedBlockBase implements ContainerFactoryP return []; } /** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $form['show_latest_mail_block'] = [ '#type' => 'checkbox', '#title' => $this->t('Show latest unread mail\'s when there is no data'), ]; $form['latest_mail_block_text'] = [ '#type' => 'textarea', '#title' => t('Mail block text'), '#description' => t('Enter the text you would like to show'), '#default_value' => t('Enter the text you would like to show'), '#states' => [ 'visible' => [ 'input[name="show_latest_mail_block"]' => [ 'checked' => TRUE, ], ], ], ]; return $form; } /** * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state) { $values = $form_state->getValues(); $this->configuration['show_latest_mail_block'] = $values['show_latest_mail_block']; $this->configuration['latest_mail_block_text'] = $values['latest_mail_block_text']; } }
modules/o365_outlook_mail/src/Plugin/Block/LatestUnreadMailBlock.php +53 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\o365_outlook_mail\Plugin\Block; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\o365\Block\O365UncachedBlockBase; use Drupal\o365_outlook_mail\GetMailServiceInterface; Loading Loading @@ -57,7 +58,21 @@ class LatestUnreadMailBlock extends O365UncachedBlockBase implements ContainerFa * @throws \Microsoft\Graph\Exception\GraphException */ public function build() { return $this->getMails(); $mails = $this->getMails(); if (!empty($mails)) { return $mails; } $config = $this->getConfiguration(); if ($config['show_latest_unread_mail_block']) { return [ '#theme' => 'o365_outlook_mail_list_block', '#readmore_class' => 'button--primary button', '#list' => $config['latest_unread_mail_block_text'], ]; } return []; } /** Loading Loading @@ -90,4 +105,41 @@ class LatestUnreadMailBlock extends O365UncachedBlockBase implements ContainerFa return []; } /** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $form['show_latest_unread_mail_block'] = [ '#type' => 'checkbox', '#title' => $this->t('Show latest unread mail\'s when there is no data'), ]; $form['latest_unread_mail_block_text'] = [ '#type' => 'textarea', '#title' => t('Mail block text'), '#description' => t('Enter the text you would like to show'), '#default_value' => t('Enter the text you would like to show'), '#states' => [ 'visible' => [ 'input[name="show_latest_unread_mail_block"]' => [ 'checked' => TRUE, ], ], ], ]; return $form; } /** * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state) { $values = $form_state->getValues(); $this->configuration['show_latest_unread_mail_block'] = $values['show_latest_unread_mail_block']; $this->configuration['latest_unread_mail_block_text'] = $values['latest_unread_mail_block_text']; } }