Skip to content

Commit 2183ea0

Browse files
committed
Add some url-variables
1 parent bd92590 commit 2183ea0

2 files changed

Lines changed: 31 additions & 7 deletions

File tree

models/AdminForm.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,31 @@ class AdminForm extends \themroc\humhub\modules\modhelper\models\AdminForm
3535
],
3636
'size'=> [
3737
'rules'=> ['in', 'range'=> [0, 1]],
38-
'form'=> ['type'=> 'radio', 'items'=> [self::class, 'sizeModes']],
38+
'form'=> [
39+
'type'=> 'radio',
40+
'items'=> [self::class, 'sizeModes']
41+
],
3942
],
4043
'url'=> [
4144
'label'=> 'Page URL',
42-
'hints'=> 'The webpage to be shown',
45+
'hints'=> 'The webpage to be shown. @UID@, @USER@ and @EMAIL@ will be replaced by the respective values.',
4346
],
4447
'url_reg'=> [
4548
'label'=> 'Page URL for registered users',
46-
'hints'=> 'If empty, the above will be used',
49+
'hints'=> 'If empty, the above will be used.',
4750
],
4851
];
4952

5053
protected $mod= [
51-
'form'=> ['btn_post'=> [self::class, 'deleteButton']],
54+
'form'=> [
55+
'btn_post'=> [self::class, 'deleteButton']
56+
],
5257
];
5358

5459
/**
5560
* @inheritdoc
5661
*/
57-
public function save()
62+
public function save ()
5863
{
5964
$frame= strtolower($this->label);
6065
$this->mod['prefix']= $frame.'/';
@@ -73,7 +78,7 @@ public function save()
7378
return $this->loadSettings();
7479
}
7580

76-
public function deleteButton($model)
81+
public function deleteButton ($model)
7782
{
7883
return strlen($model->label)
7984
? "\t\t\t".Html::a(
@@ -83,7 +88,7 @@ public function deleteButton($model)
8388
: "";
8489
}
8590

86-
public function sizeModes()
91+
public function sizeModes ()
8792
{
8893
return [
8994
0=> Yii::t('IframeModule.base', 'Box'),

views/index/index.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@
99
$url= $mod->getSetting('url_reg', $frame);
1010
if (empty($url) || Yii::$app->user->isGuest)
1111
$url= $mod->getSetting('url', $frame);
12+
if (Yii::$app->user->isGuest) {
13+
$uid= 0;
14+
$user= 'Guest-'.rand(10000000, 99999999);
15+
$email= '';
16+
} else {
17+
$uid= Yii::$app->user->id;
18+
$user= Yii::$app->user->getIdentity()->__get('username');
19+
$email= Yii::$app->user->getIdentity()->__get('email');
20+
}
21+
$ustr= $user.$email.$uid;
22+
$color= '';
23+
for ($x=0; $x<6; $x++) {
24+
$c= ord(substr($ustr, $x, 1));
25+
$color.= dechex($c & 0x0f);
26+
}
27+
$url= str_replace('@UID@', $uid, $url);
28+
$url= str_replace('@USER@', urlencode($user), $url);
29+
$url= str_replace('@EMAIL@', urlencode($email), $url);
30+
$url= str_replace('@COLOR@', $color, $url);
1231

1332
$js= [];
1433
foreach ($mod->getFrames() as $f)

0 commit comments

Comments
 (0)