Ejemplo n.º 1
0
// 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    local_msaccount
 * @author Vinayak (Vin) Bhalerao (v-vibhal@microsoft.com)
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @copyright  Microsoft Open Technologies, Inc.
 */
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once dirname(__FILE__) . '/msaccount_client.php';
if (!msaccount_api::getinstance()->is_logged_in()) {
    // Upgrades token and then checks for success.
    throw new moodle_exception('Unable to log in to Microsoft Account.');
}
$strhttpsbug = get_string('cannotaccessparentwin', 'local_msaccount');
$strrefreshnonjs = get_string('refreshnonjsfilepicker', 'local_msaccount');
$js = <<<EOD
<html>
<head>
    <script type="text/javascript">
    if(window.opener){
        try {
            window.opener.M.core_filepicker.active_filepicker.list();
        } catch (ex) {
            alert("{$strhttpsbug}");
        }
Ejemplo n.º 2
0
 /**
  * Constructor.
  *
  * Initializes msaccount_api instance which is used to do moest of the underlying authentication and
  * REST API operations. This is a singleton class, do not use the constructor directly to create an instance.
  * Use the getinstance() method instead.
  */
 protected function __construct()
 {
     $this->msaccountapi = \msaccount_api::getinstance();
     $this->msaccountapi->is_logged_in();
 }
Ejemplo n.º 3
0
 /**
  * Get the instance of the msaccount_api object. Use this method to obtain an instance of the class rather than
  * the constructor. Also tries to ensure that the user is logged in.
  * @return null|static The instance.
  */
 public static function getinstance()
 {
     if (null === self::$instance) {
         self::$instance = new static();
     }
     self::$instance->msaccountclient->is_logged_in();
     return self::$instance;
 }