1<?php 2if (!defined('DOKU_INC')) die(); 3 4define('SKAUTIS_LIBS_DIR', dirname(__FILE__).'/libs/'); 5require_once SKAUTIS_LIBS_DIR. 'skautis-minify.php'; 6 7 8class action_plugin_authskautis extends DokuWiki_Action_Plugin { 9 10 protected $url; 11 protected $testUrl; 12 13 /** 14 * Registers the event handlers. 15 */ 16 function register(Doku_Event_Handler $controller) 17 { 18 $controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'hook_html_loginform_output', array()); 19 $controller->register_hook('HTML_UPDATEPROFILEFORM_OUTPUT', 'BEFORE', $this, 'hook_updateprofileform_output', array()); 20 } 21 22 function hook_updateprofileform_output(&$event, $param) { 23 global $USERINFO; 24 25 if ($USERINFO['is_skautis']) { 26 $elem = $event->data->getElementAt(2); 27 $elem['disabled'] = 'disabled'; 28 $event->data->replaceElement(2, $elem); 29 30 $elem = $event->data->getElementAt(3); 31 $elem['disabled'] = 'disabled'; 32 $event->data->replaceElement(3, $elem); 33 34 $event->data->replaceElement(10, null); 35 $event->data->replaceElement(9, null); 36 $event->data->replaceElement(8, null); 37 $event->data->replaceElement(7, null); 38 $event->data->replaceElement(6, null); 39 $event->data->replaceElement(5, null); 40 $event->data->replaceElement(4, null); 41 } 42 } 43 44 45 /** 46 * Handles the login form rendering. 47 */ 48 function hook_html_loginform_output(&$event, $param) { 49 50 $this->url = Skautis\Config::URL_PRODUCTION . 'Login/?appid='; 51 $this->testUrl = Skautis\Config::URL_TEST . 'Login/?appid='; 52 53 $skautisAppId = $this->getConf('skautis_app_id'); 54 if($skautisAppId!=''){ 55 $skautIsTestmode = $this->getConf('skautis_test_mode'); 56 if ($skautIsTestmode){ 57 $auth_url = $this->testUrl.$skautisAppId; 58 } else { 59 $auth_url = $this->url.$skautIsTestmode; 60 } 61 62 63 $a_style = "width: 200px;margin:0 auto;color: #666666;cursor: pointer;text-decoration: none !important;display: block;padding-bottom:1.4em;";//-moz-linear-gradient(center top , #F8F8F8, #ECECEC) 64 $div_style = "float:left;line-height: 30px;background-color: #F8F8F8;border: 1px solid #C6C6C6;border-radius: 2px 2px 2px 2px;padding: 0px 5px 0px 5px;position: relative;"; 65 echo "<a href='$auth_url' style='$a_style' title='".$this->getLang('enter_skautis')."'><div style=\"$div_style\">".$this->getLang('enter_skautis')."</div>"; 66 echo "<div style='clear: both;'></div></a>"; 67 } 68 } 69} 70 71?>