diff --git a/controllers/IndexController.php b/controllers/IndexController.php
index 2eaa90a..cb58a70 100644
--- a/controllers/IndexController.php
+++ b/controllers/IndexController.php
@@ -11,7 +11,39 @@ class IndexController extends Controller
public function actionIndex()
{
+ $mod= Yii::$app->getModule('iframe');
+ $uid= Yii::$app->user->id;
+ $frame= Yii::$app->request->get('frame');
+ $top_data= $mod->getSetting('top_data', $frame);
+ $url= $mod->getSetting('url_reg', $frame);
+ if (empty($url) || Yii::$app->user->isGuest)
+ $url= $mod->getSetting('url', $frame);
+
+ if (Yii::$app->user->isGuest) {
+ $user= Yii::$app->request->userIP;
+ $email= '';
+ } else {
+ $user= Yii::$app->user->identity->username;
+ $email= Yii::$app->user->identity->email;
+ }
+
+ $ustr= $user.$email.$uid;
+ $color= '';
+ for ($x=0; $x<6; $x++) {
+ $c= ord(substr($ustr, $x, 1));
+ $color.= dechex($c & 0x0f);
+ }
+
+ $url= str_replace('@UID@', $uid, $url);
+ $url= str_replace('@USER@', urlencode($user), $url);
+ $url= str_replace('@EMAIL@', urlencode($email), $url);
+ $url= str_replace('@COLOR@', $color, $url);
+
return $this->render('index', [
+ 'mod'=> $mod,
+ 'frame'=> $frame,
+ 'url'=> $url,
+ 'top_data'=> $top_data,
]);
}
}
diff --git a/models/AdminForm.php b/models/AdminForm.php
index d3c4e09..65f1c14 100644
--- a/models/AdminForm.php
+++ b/models/AdminForm.php
@@ -16,8 +16,10 @@ class AdminForm extends \themroc\humhub\modules\modhelper\models\AdminForm
public $label;
public $sort;
public $size;
+ public $guest;
public $url;
public $url_reg;
+ public $top_data;
protected $vars= [
'label'=> [
@@ -34,12 +36,20 @@ class AdminForm extends \themroc\humhub\modules\modhelper\models\AdminForm
'hints'=> 'Determines topbar menu position',
],
'size'=> [
+ 'prefix'=> '',
'rules'=> ['in', 'range'=> [0, 1]],
'form'=> [
'type'=> 'radio',
'items'=> [self::class, 'sizeModes']
],
],
+ 'guest'=> [
+ 'label'=> 'Visible for guests',
+ 'rules'=> ['in', 'range'=> [0, 1]],
+ 'form'=> [
+ 'type'=> 'checkbox',
+ ],
+ ],
'url'=> [
'label'=> 'Page URL',
'hints'=> 'The webpage to be shown. @UID@, @USER@ and @EMAIL@ will be replaced by the respective values.',
@@ -48,6 +58,9 @@ class AdminForm extends \themroc\humhub\modules\modhelper\models\AdminForm
'label'=> 'Page URL for registered users',
'hints'=> 'If empty, the above will be used.',
],
+ 'top_data'=> [
+ 'label'=> 'HTML to add above the iframe',
+ ],
];
protected $mod= [
diff --git a/module.json b/module.json
index 69f21f6..5c9cf8a 100644
--- a/module.json
+++ b/module.json
@@ -4,7 +4,7 @@
"description": "(Nearly) fullscreen iframes",
"keywords": [
],
- "version": "0.2",
+ "version": "0.4.2",
"humhub": {
"minVersion": "1.2"
},
diff --git a/views/index/index.php b/views/index/index.php
index f5ef2e1..f2f67a0 100644
--- a/views/index/index.php
+++ b/views/index/index.php
@@ -4,36 +4,13 @@
themroc\humhub\modules\iframe\assets\Assets::register($this);
-$frame= Yii::$app->request->get('frame');
-$mod= Yii::$app->getModule('iframe');
-$url= $mod->getSetting('url_reg', $frame);
-if (empty($url) || Yii::$app->user->isGuest)
- $url= $mod->getSetting('url', $frame);
-if (Yii::$app->user->isGuest) {
- $uid= 0;
- $user= 'Guest-'.rand(10000000, 99999999);
- $email= '';
-} else {
- $uid= Yii::$app->user->id;
- $user= Yii::$app->user->getIdentity()->__get('username');
- $email= Yii::$app->user->getIdentity()->__get('email');
-}
-$ustr= $user.$email.$uid;
-$color= '';
-for ($x=0; $x<6; $x++) {
- $c= ord(substr($ustr, $x, 1));
- $color.= dechex($c & 0x0f);
-}
-$url= str_replace('@UID@', $uid, $url);
-$url= str_replace('@USER@', urlencode($user), $url);
-$url= str_replace('@EMAIL@', urlencode($email), $url);
-$url= str_replace('@COLOR@', $color, $url);
-
$js= [];
foreach ($mod->getFrames() as $f)
$js[urlencode($f)]= $mod->getSetting('size', $f);
$this->registerJsConfig(['iframe'=> $js]);
echo ''."\n";
+if (! empty($top_data))
+ echo $top_data."\n";
echo ''."\n";
echo '
'."\n";