This repository has been archived by the owner on Jul 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MSFTMPP-613: Moved skype block to block_skypeweb
- Loading branch information
0 parents
commit 48a2b40
Showing
28 changed files
with
4,889 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# Moodle Plugins for Microsoft Services | ||
*including* **Office 365** *and other Microsoft services* | ||
|
||
## Microsoft Skype Web block | ||
|
||
This plugin provides easy access to all Microsoft Account and Office 365 services for Moodle. | ||
|
||
This is part of the suite of Office 365 plugins for Moodle. | ||
|
||
This repository is updated with stable releases. To follow active development, see: https://github.com/Microsoft/o365-moodle | ||
|
||
## Installation | ||
|
||
1. Unpack the plugin into /blocks/skypeweb within your Moodle install. | ||
2. From the Moodle Administration block, expand Site Administration and click "Notifications". | ||
3. Follow the on-screen instructions to install the plugin. | ||
4. Add the block to any page you want it displayed. | ||
|
||
For more documentation, visit https://docs.moodle.org/30/en/Office365 | ||
|
||
## Configuration | ||
|
||
### Prepare your Office 365 account for single sign-on with your Moodle installation | ||
|
||
You will need an Azure subscription. If you do not have one, you can create one by visiting [http://azure.microsoft.com/en-us/pricing/free-trial/ Microsoft Azure Sign Up](http://azure.microsoft.com/en-us/pricing/free-trial/ Microsoft Azure Sign Up "wikilink") | ||
|
||
To use Moodle with Office 365 for SSO, you must [configure Microsoft Azure](https://manage.windowsazure.com) to manage your Office 365 Microsoft Azure Active Directory: | ||
|
||
1. Create a new Active Directory. | ||
2. Select Use existing directory. | ||
|
||
 | ||
|
||
3. Select **I am ready to be signed out now** and click the check mark. | ||
|
||
 | ||
|
||
4. Sign in with your Office 365 subscription credentials. | ||
5. Click **Continue**. | ||
6. Log out and sign back in to your Azure account. | ||
|
||
**Note**: In order to sign-up for an Azure subscription, you are required to enter a credit card and phone number. If only use the subscription to access the Azure Active Directory associated with your Office 365 subscription and enable no other paid services such as Virtual Machines, you will not be charged for the subscription. | ||
|
||
### Register your Moodle instance as an Application in Azure Active Directory | ||
|
||
1. Sign in to the [Microsoft Azure Management Portal](https://manage.windowsazure.com). | ||
2. Click on the **Active Directory** icon on the left menu, and then click on the desired Office 365 connected Azure AD. | ||
3. On the top menu, click **Applications**. If no apps have been added to your directory, this page will only show the **Add an App** link. Click on the link, or alternatively you can click on the **Add** button on the command bar. | ||
4. On the **What do you want to do** page, click on the link to **Add an application my organization is developing**. | ||
5. On the **Tell us about your application** page, you must specify a name for your application and indicate the type of application you are registering with Azure AD. Click **web application and/or web API** (default) and then click the arrow icon on the bottom-right corner of the page. | ||
6. On the App properties page, provide the **Sign-on URL** and **App ID URI** for your Moodle instance. | ||
1. The Sign-on URI is the main URI of the Moodle instance + '/blocks/skypeweb/skypeloginreturn.php'. | ||
2. The APP ID URI is the main URI of the Moodle instance. | ||
|
||
7. Click the checkbox in the bottom-right hand corner of the page and then click Ok to add your app to Azure Active Directory. | ||
8. There are a couple more values and changes you need to make and write down some values which you will need in the next section. | ||
|
||
### Configure your Azure Active Directory Application | ||
|
||
1. In Azure, click on the **Active Directory** icon on the left menu, and then click on the desired Azure AD. | ||
2. Click the Applications tab at the top of the screen. | ||
3. Locate the application you created and click it's name in the list. | ||
4. Click Configure at the top of the screen. | ||
5. Locate the **Client ID**, note this value (write it down or copy it somewhere), and set it aside. You'll need it later. | ||
6. Click on **MANAGE MANIFEST** and then Download Manifest. | ||
7. On the **Download Manifest** page, click on the link to **Download manifest**. | ||
8. Open the downloaded manifest file in any editor and update the value of **oauth2AllowImplicitFlow** to **true**. | ||
9. In Azure, click on **MANAGE MANIFEST** and then Upload Manifest. | ||
10. On the **Upload Manifest** page, browse the same updated manifest file. | ||
11. Click the check mark at the bottom right of the dialog. | ||
12. Locate the **Permissions to other applications** section. | ||
13. Click **Add application** click the plus sign to the right of **Skype for Business Online**. Note, the plus will appear when you hover over each of the items. | ||
14. Click the check mark at the bottom right of the dialog. | ||
15. In the Delegated Permissions dropdown for Skype for Business Online select the following permissions: | ||
1. Read/write Skype user contacts and groups. | ||
2. Receive conversation invites (preview). | ||
3. Read/write Skype user information (preview). | ||
4. Create Skype Meetings. | ||
5. Initiate conversations and join meetings. | ||
|
||
16. Click save at the bottom of the screen. | ||
|
||
### Configure the Setting page in the Skype Web Block plugin | ||
|
||
Navigate to **Site Administration \> Plugins \> Blocks**. Click **Skype Web**. Complete the following steps: | ||
|
||
1. Register Moodle with Azure AD (process outlined above). | ||
1. Copy the client ID you noted earlier from Azure AD into the appropriate fields in step 1. | ||
2. Click save changes at the bottom of the page. | ||
|
||
## Skype Web Block | ||
|
||
The Skype Web block provides the ability for users to quickly link off to Skype for Business services. | ||
- Shows self details | ||
- Shows contacts | ||
- Shows groups | ||
- Allow chat service | ||
|
||
## Support | ||
|
||
If you are experiencing problems, have a feature request, or have a question, please open an issue on Github at https://github.com/Microsoft/o365-moodle. | ||
|
||
To help developers debug problems, please include the following in all issues: | ||
- Plugin versions. | ||
- Moodle version. | ||
- Detailed instructions of what went wrong and how to reproduce the problem. | ||
- Any error messages encountered. | ||
- PHP version. | ||
- Database software and versions. | ||
- Any other environmental information available. | ||
|
||
Note that developers will triage issues and deal with more serious problems first. All issues will be addressed but some may not be addressed immediately. | ||
|
||
## Contributing | ||
|
||
We're looking for community contributions! Feel free to submit pull requests, but please do so against the development repository at https://github.com/Microsoft/o365-moodle. Pull requests submitted to individual plugin repositories cannot be accepted. | ||
|
||
### Needed Contributions | ||
Smaller issues that developers cannot address right away will be labeled with "Help Wanted" in the issue tracker in the development repository at https://github.com/Microsoft/o365-moodle/issues. These are only suggestions - we can also accept pull requests fixing other bugs, or even adding new features. | ||
|
||
Pull requests adding new features are much appreciated but note that they may be rejected (even if technically sound) if they do not match the direction of the project. If you want to add a new feature, it's best to open an issue outlining your idea first, and get feedback from the maintainers. | ||
|
||
Contributions to our documentation are especially appreciated! All documentation lives in the /local/o365docs folder of the development repository (https://github.com/Microsoft/o365-moodle). Updates to this documentation can be sent via pull request like any other contributions. | ||
|
||
### Code Review | ||
All pull requests go through a thorough examination from developers before they are merged. Please read our [code review process](https://github.com/Microsoft/o365-moodle/tree/master/local/o365docs/codereview.md) and ensure your code is consistent before submitting. A developer may respond with changes that are needed before a pull request can be accepted and it is up to the submitter to make those changes. If accepted, your commit will remain as-is to ensure you get credit, but developers may modify solutions slightly in subsequent commits. | ||
|
||
### CLA | ||
Finally, before we can accept your pull request, you'll need to electronically complete Microsoft's [Contributor License Agreement](https://cla.microsoft.com/). If you've done this for other Microsoft projects, then you're already covered. | ||
|
||
[Why a CLA?](https://www.gnu.org/licenses/why-assign.html) (from the FSF) | ||
|
||
## Copyright | ||
|
||
© Microsoft, Inc. Code for this plugin is licensed under the GPLv3 license. | ||
|
||
Any Microsoft trademarks and logos included in these plugins are property of Microsoft and should not be reused, redistributed, modified, repurposed, or otherwise altered or used outside of this plugin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* @package block_skypeweb | ||
* @author Aashay Zajriya <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) | ||
*/ | ||
defined('MOODLE_INTERNAL') || die(); | ||
// Checks weather Mustache_Engine is already defined or not as | ||
// Moodle 2.9 onwards Mustache_Engine is already included in Moodle core. | ||
if (!class_exists('Mustache_Engine')) { | ||
require_once(__DIR__.'/mustache.php'); | ||
} | ||
|
||
/** | ||
* Skype Block. | ||
*/ | ||
class block_skypeweb extends block_base { | ||
|
||
/** | ||
* Initialize plugin. | ||
*/ | ||
public function init() { | ||
|
||
global $PAGE; | ||
// Adding Skype SDK in the $PAGE. | ||
$skypesdkurl = new moodle_url(get_string('skypesdkurl', 'block_skypeweb')); | ||
$PAGE->requires->js($skypesdkurl, true); | ||
$this->title = get_string('skypeweb', 'block_skypeweb'); | ||
} | ||
|
||
/** | ||
* Whether the block has settings. | ||
* | ||
* @return bool Has settings or not. | ||
*/ | ||
public function has_config() { | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the content of the block. | ||
* | ||
* @return stdObject | ||
*/ | ||
public function get_content() { | ||
|
||
global $PAGE, $CFG, $USER, $SESSION; | ||
|
||
if (empty($USER->id)) { | ||
return ''; | ||
} | ||
|
||
// To avoid duplication of block code and JavaScript inclusion. | ||
// Ref: https://moodle.org/mod/forum/discuss.php?d=170193. | ||
if ($this->content != null) { | ||
return $this->content; | ||
} | ||
|
||
// Adding jquery, jquery-ui, jquery-ui-css in the $PAGE. | ||
$PAGE->requires->jquery(); | ||
$PAGE->requires->jquery_plugin('ui'); | ||
$PAGE->requires->jquery_plugin('ui-css'); | ||
|
||
// Getting the client ID from OpenID authentication plugin. | ||
$clientid = get_config('auth_oidc', 'clientid'); | ||
$config = array('client_id' => $clientid, | ||
'wwwroot' => $CFG->wwwroot, | ||
'errormessage' => get_string('signinerror', 'block_skypeweb')); | ||
|
||
$this->content = new stdClass; | ||
$this->content->text = ''; | ||
if ($USER->auth == 'oidc' || !empty($SESSION->skype_login)) { | ||
// Added required Skype SDK's YUI module in the $PAGE. | ||
$PAGE->requires->yui_module('moodle-block_skypeweb-groups', 'M.block_skypeweb.groups.init', array($config)); | ||
$PAGE->requires->yui_module('moodle-block_skypeweb-signin', 'M.block_skypeweb.signin.init', array($config)); | ||
$PAGE->requires->yui_module('moodle-block_skypeweb-contact', 'M.block_skypeweb.contact.init', array($config)); | ||
$PAGE->requires->yui_module('moodle-block_skypeweb-self', 'M.block_skypeweb.self.init', array($config)); | ||
$this->content->text .= $this->get_template($CFG->dirroot . '/blocks/skypeweb/html_templates/skype_block.html'); | ||
} else { | ||
// Added required Skype SDK's authentication module in the $PAGE. | ||
$PAGE->requires->yui_module('moodle-block_skypeweb-login', 'M.block_skypeweb.login.init', array($config)); | ||
$this->content->text .= $this->get_template($CFG->dirroot . '/blocks/skypeweb/html_templates/skype_login.html'); | ||
} | ||
|
||
$this->content->text = str_replace("@@wwwroot@@", $CFG->wwwroot, $this->content->text); | ||
$this->content->footer = ''; | ||
return $this->content; | ||
} | ||
|
||
/** | ||
* Get block content's tamplate according to the user's login status. | ||
* | ||
* @param string $templatepath The HTML template path that we are using. | ||
* @return string Block content. | ||
*/ | ||
private function get_template($templatepath) { | ||
$templateengine = new Mustache_Engine(); | ||
$templatecontents = file_get_contents($templatepath); | ||
$templateopts = [ | ||
'get_string' => function($stringtolocalize) { | ||
return get_string($stringtolocalize, 'block_skypeweb'); | ||
} | ||
]; | ||
return $templateengine->render($templatecontents, $templateopts); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* @package block_skypeweb | ||
* @author Aashay Zajriya <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) | ||
*/ | ||
|
||
$capabilities = [ | ||
'block/skypeweb:myaddinstance' => [ | ||
'captype' => 'write', | ||
'contextlevel' => CONTEXT_SYSTEM, | ||
'archetypes' => [ | ||
'user' => CAP_ALLOW | ||
], | ||
'clonepermissionsfrom' => 'moodle/my:manageblocks' | ||
], | ||
'block/skypeweb:addinstance' => [ | ||
'riskbitmask' => RISK_SPAM | RISK_XSS, | ||
'captype' => 'write', | ||
'contextlevel' => CONTEXT_BLOCK, | ||
'archetypes' => [ | ||
'editingteacher' => CAP_ALLOW, | ||
'manager' => CAP_ALLOW | ||
], | ||
'clonepermissionsfrom' => 'moodle/site:manageblocks' | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<div class="wrappingdiv"> | ||
<h2>{{# get_string}}lbl_self{{/ get_string}}</h2> | ||
<div class="self"> | ||
<div class="need-to-add"> | ||
<p>{{# get_string}}lbl_title{{/ get_string}}: <span id="self-title"></span></p> | ||
<p>{{# get_string}}lbl_email{{/ get_string}}: <span id="self-email"></span></p> | ||
</div> | ||
<div class="persona persona-xl self"> | ||
<div class="note-c"> | ||
<div id="txt-note" class="editable" contenteditable="true" | ||
placeholder="{{# get_string}}status_placeholder{{/ get_string}}"></div> | ||
<div class="tick"></div> | ||
</div> | ||
<div class="photo-c"> | ||
<img src="@@wwwroot@@/blocks/skypeweb/pix/default.png" height="48" width="48" /> | ||
<div class="photo-presence"></div> | ||
</div> | ||
<div class="detail"> | ||
<div id="self-name" class="primary"></div> | ||
<select id="sel-presence" class="secondary"> | ||
<option value="Online">{{# get_string}}option_available{{/ get_string}}</option> | ||
<option value="Busy">{{# get_string}}option_busy{{/ get_string}}</option> | ||
<option value="DoNotDisturb">{{# get_string}}option_disturb{{/ get_string}}</option> | ||
<option value="BeRightBack">{{# get_string}}option_back{{/ get_string}}</option> | ||
<option value="Away">{{# get_string}}option_away{{/ get_string}}</option> | ||
</select> | ||
<div id="self-location" class="editable tertiary" contenteditable="true" | ||
placeholder="{{# get_string}}location_placeholder{{/ get_string}}"></div> | ||
</div> | ||
</div> | ||
</div> | ||
<h2>{{# get_string}}lbl_contact{{/ get_string}}</h2> | ||
<div class="contact"> | ||
<div> | ||
<input type="text" id="useruri" placeholder="{{# get_string}}email_placeholder{{/ get_string}}" /> | ||
<span id="btn-get-contact">{{# get_string}}lbl_contact{{/ get_string}}</span> | ||
</div> | ||
<div id="status"></div> | ||
<div id="result"></div> | ||
</div> | ||
<h2>{{# get_string}}lbl_group{{/ get_string}}</h2> | ||
<div class="groups"> | ||
<div id="results"></div> | ||
</div> | ||
<h2>{{# get_string}}lbl_chat{{/ get_string}}</h2> | ||
<button id='btnOpenChat' class='btn btn-success'>{{# get_string}}lbl_button{{/ get_string}}</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div class="wrappingdiv"> | ||
<form id='frmLoginToSkype' method='get' action='https://login.microsoftonline.com/common/oauth2/authorize'> | ||
<input type='hidden' name='response_type' value='token' /> | ||
<input type='hidden' name='client_id' value='' /> | ||
<input type='hidden' name='redirect_uri' value='@@wwwroot@@/blocks/skypeweb/skypeloginreturn.php' /> | ||
<input type='hidden' name='resource' value='https://webdirin1.online.lync.com' /> | ||
<input type='hidden' name='state' value='' /> | ||
<button id='btnSkypeLogin' class='btn btn-success'>{{# get_string}}skypelogin_button{{/ get_string}}</button> | ||
</form> | ||
</div> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.