Browse code

Version 1.5 initial commit

Benjamin Roth authored on24/06/2024 12:06:17
Showing1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,134 +0,0 @@
1
-<?php
2
-
3
-declare(strict_types=1);
4
-
5
-/*
6
- * This file is part of Oveleon ContaoMemberExtension Bundle.
7
- *
8
- * @package     contao-member-extension-bundle
9
- * @license     MIT
10
- * @author      Sebastian Zoglowek     <https://github.com/zoglo>
11
- * @author      Daniele Sciannimanica  <https://github.com/doishub>
12
- * @author      Fabian Ekert           <https://github.com/eki89>
13
- * @copyright   Oveleon                <https://www.oveleon.de/>
14
- */
15
-
16
-namespace Oveleon\ContaoMemberExtensionBundle;
17
-
18
-use Contao\BackendTemplate;
19
-use Contao\Config;
20
-use Contao\FrontendUser;
21
-use Contao\Input;
22
-use Contao\MemberModel;
23
-use Contao\Module;
24
-use Contao\StringUtil;
25
-use Contao\System;
26
-
27
-/**
28
- * Class ModuleDeleteAvatar
29
- *
30
- * @author Sebastian Zoglowek <https://github.com/zoglo>
31
- */
32
-class ModuleDeleteAvatar extends Module
33
-{
34
-    /**
35
-     * Template.
36
-     *
37
-     * @var string
38
-     */
39
-    protected $strTemplate = 'memberExtension_deleteAvatar';
40
-
41
-    /**
42
-     * Display a wildcard in the back end
43
-     *
44
-     * @return string
45
-     */
46
-    public function generate()
47
-    {
48
-        $container = System::getContainer();
49
-        $request = System::getContainer()->get('request_stack')->getCurrentRequest();
50
-
51
-        if ($request && $container->get('contao.routing.scope_matcher')->isBackendRequest($request))
52
-        {
53
-            $objTemplate = new BackendTemplate('be_wildcard');
54
-            $objTemplate->wildcard = '### ' . $GLOBALS['TL_LANG']['FMD']['deleteAvatar'][0] . ' ###';
55
-            $objTemplate->title = $this->headline;
56
-            $objTemplate->id = $this->id;
57
-            $objTemplate->link = $this->name;
58
-            $objTemplate->href = StringUtil::specialcharsUrl(System::getContainer()->get('router')->generate('contao_backend', ['do'=>'themes', 'table'=>'tl_module', 'act'=>'edit', 'id'=>$this->id]));
59
-
60
-            return $objTemplate->parse();
61
-        }
62
-
63
-        // Set the item from the auto_item parameter
64
-        if (!isset($_GET['items']) && isset($_GET['auto_item']) && Config::get('useAutoItem'))
65
-        {
66
-            Input::setGet('items', Input::get('auto_item'));
67
-        }
68
-
69
-        // Return if there is no logged-in user
70
-        if (!$container->get('contao.security.token_checker')->hasFrontendUser())
71
-        {
72
-            return '';
73
-        }
74
-
75
-        $this->import(FrontendUser::class, 'User');
76
-        $objMember = MemberModel::findByPk($this->User->id);
77
-
78
-        if (null === $objMember)
79
-        {
80
-            return '';
81
-        }
82
-
83
-        // Confirmation message
84
-        $session = System::getContainer()->get('session');
85
-        $flashBag = $session->getFlashBag();
86
-
87
-        // Return if there is no flashbag message or an avatar
88
-        if (!($session->isStarted() && $flashBag->has('mod_avatar_deleted')) && !$objMember->avatar)
89
-        {
90
-            return '';
91
-        }
92
-
93
-        return parent::generate();
94
-    }
95
-
96
-    /**
97
-     * Generate the module
98
-     */
99
-    protected function compile()
100
-    {
101
-        $strFormId = 'deleteAvatar_' . $this->id;
102
-        $session = System::getContainer()->get('session');
103
-        $flashBag = $session->getFlashBag();
104
-
105
-        // Get form submit
106
-        if (Input::post('FORM_SUBMIT') == $strFormId)
107
-        {
108
-            $this->import(FrontendUser::class, 'User');
109
-            $objMember = MemberModel::findByPk($this->User->id);
110
-
111
-            // Delete avatar if it exists
112
-            if (!!$objMember->avatar)
113
-            {
114
-                Member::deleteAvatar($objMember);
115
-                // Unset avatar
116
-                $objMember->avatar = null;
117
-                $objMember->save();
118
-
119
-                // Set message for deletion feedback
120
-                $flashBag->set('mod_avatar_deleted', $GLOBALS['TL_LANG']['MSC']['avatarDeleted']);
121
-                $this->reload();
122
-            }
123
-        }
124
-
125
-        // Confirmation message
126
-        if ($session->isStarted() && $flashBag->has('mod_avatar_deleted')) {
127
-            $arrMessages = $flashBag->get('mod_avatar_deleted');
128
-            $this->Template->message = $arrMessages[0];
129
-        }
130
-
131
-        $this->Template->formId = $strFormId;
132
-        $this->Template->slabel = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['deleteAvatar']);
133
-    }
134
-}
Browse code

[Change] Drop contao 4.9 support

Sebastian Zoglowek authored on15/01/2023 16:55:51
Showing1 changed files
... ...
@@ -39,24 +39,23 @@ class ModuleDeleteAvatar extends Module
39 39
     protected $strTemplate = 'memberExtension_deleteAvatar';
40 40
 
41 41
     /**
42
-     * Return a wildcard in the back end
42
+     * Display a wildcard in the back end
43 43
      *
44 44
      * @return string
45 45
      */
46 46
     public function generate()
47 47
     {
48 48
         $container = System::getContainer();
49
-
50 49
         $request = System::getContainer()->get('request_stack')->getCurrentRequest();
51 50
 
52
-        if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request))
51
+        if ($request && $container->get('contao.routing.scope_matcher')->isBackendRequest($request))
53 52
         {
54 53
             $objTemplate = new BackendTemplate('be_wildcard');
55
-            $objTemplate->wildcard = '### ' . mb_strtoupper($GLOBALS['TL_LANG']['FMD']['deleteAvatar'][0] ?? '', 'UTF-8') . ' ###';
54
+            $objTemplate->wildcard = '### ' . $GLOBALS['TL_LANG']['FMD']['deleteAvatar'][0] . ' ###';
56 55
             $objTemplate->title = $this->headline;
57 56
             $objTemplate->id = $this->id;
58 57
             $objTemplate->link = $this->name;
59
-            $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
58
+            $objTemplate->href = StringUtil::specialcharsUrl(System::getContainer()->get('router')->generate('contao_backend', ['do'=>'themes', 'table'=>'tl_module', 'act'=>'edit', 'id'=>$this->id]));
60 59
 
61 60
             return $objTemplate->parse();
62 61
         }
Sebastian Zoglowek authored on13/01/2023 19:37:52
Showing1 changed files
... ...
@@ -76,7 +76,7 @@ class ModuleDeleteAvatar extends Module
76 76
         $this->import(FrontendUser::class, 'User');
77 77
         $objMember = MemberModel::findByPk($this->User->id);
78 78
 
79
-        if(null === $objMember)
79
+        if (null === $objMember)
80 80
         {
81 81
             return '';
82 82
         }
... ...
@@ -110,7 +110,7 @@ class ModuleDeleteAvatar extends Module
110 110
             $objMember = MemberModel::findByPk($this->User->id);
111 111
 
112 112
             // Delete avatar if it exists
113
-            if(!!$objMember->avatar)
113
+            if (!!$objMember->avatar)
114 114
             {
115 115
                 Member::deleteAvatar($objMember);
116 116
                 // Unset avatar
... ...
@@ -124,7 +124,7 @@ class ModuleDeleteAvatar extends Module
124 124
         }
125 125
 
126 126
         // Confirmation message
127
-        if($session->isStarted() && $flashBag->has('mod_avatar_deleted')) {
127
+        if ($session->isStarted() && $flashBag->has('mod_avatar_deleted')) {
128 128
             $arrMessages = $flashBag->get('mod_avatar_deleted');
129 129
             $this->Template->message = $arrMessages[0];
130 130
         }
Browse code

Update comments

Sebastian Zoglowek authored on14/08/2022 16:18:52
Showing1 changed files
... ...
@@ -7,10 +7,10 @@ declare(strict_types=1);
7 7
  *
8 8
  * @package     contao-member-extension-bundle
9 9
  * @license     MIT
10
- * @author      Daniele Sciannimanica   <https://github.com/doishub>
11
- * @author      Fabian Ekert            <https://github.com/eki89>
12
- * @author      Sebastian Zoglowek      <https://github.com/zoglo>
13
- * @copyright   Oveleon                 <https://www.oveleon.de/>
10
+ * @author      Sebastian Zoglowek     <https://github.com/zoglo>
11
+ * @author      Daniele Sciannimanica  <https://github.com/doishub>
12
+ * @author      Fabian Ekert           <https://github.com/eki89>
13
+ * @copyright   Oveleon                <https://www.oveleon.de/>
14 14
  */
15 15
 
16 16
 namespace Oveleon\ContaoMemberExtensionBundle;
Browse code

Change bundle structure

Sebastian Zoglowek authored on14/08/2022 15:51:15
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,135 @@
1
+<?php
2
+
3
+declare(strict_types=1);
4
+
5
+/*
6
+ * This file is part of Oveleon ContaoMemberExtension Bundle.
7
+ *
8
+ * @package     contao-member-extension-bundle
9
+ * @license     MIT
10
+ * @author      Daniele Sciannimanica   <https://github.com/doishub>
11
+ * @author      Fabian Ekert            <https://github.com/eki89>
12
+ * @author      Sebastian Zoglowek      <https://github.com/zoglo>
13
+ * @copyright   Oveleon                 <https://www.oveleon.de/>
14
+ */
15
+
16
+namespace Oveleon\ContaoMemberExtensionBundle;
17
+
18
+use Contao\BackendTemplate;
19
+use Contao\Config;
20
+use Contao\FrontendUser;
21
+use Contao\Input;
22
+use Contao\MemberModel;
23
+use Contao\Module;
24
+use Contao\StringUtil;
25
+use Contao\System;
26
+
27
+/**
28
+ * Class ModuleDeleteAvatar
29
+ *
30
+ * @author Sebastian Zoglowek <https://github.com/zoglo>
31
+ */
32
+class ModuleDeleteAvatar extends Module
33
+{
34
+    /**
35
+     * Template.
36
+     *
37
+     * @var string
38
+     */
39
+    protected $strTemplate = 'memberExtension_deleteAvatar';
40
+
41
+    /**
42
+     * Return a wildcard in the back end
43
+     *
44
+     * @return string
45
+     */
46
+    public function generate()
47
+    {
48
+        $container = System::getContainer();
49
+
50
+        $request = System::getContainer()->get('request_stack')->getCurrentRequest();
51
+
52
+        if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request))
53
+        {
54
+            $objTemplate = new BackendTemplate('be_wildcard');
55
+            $objTemplate->wildcard = '### ' . mb_strtoupper($GLOBALS['TL_LANG']['FMD']['deleteAvatar'][0] ?? '', 'UTF-8') . ' ###';
56
+            $objTemplate->title = $this->headline;
57
+            $objTemplate->id = $this->id;
58
+            $objTemplate->link = $this->name;
59
+            $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
60
+
61
+            return $objTemplate->parse();
62
+        }
63
+
64
+        // Set the item from the auto_item parameter
65
+        if (!isset($_GET['items']) && isset($_GET['auto_item']) && Config::get('useAutoItem'))
66
+        {
67
+            Input::setGet('items', Input::get('auto_item'));
68
+        }
69
+
70
+        // Return if there is no logged-in user
71
+        if (!$container->get('contao.security.token_checker')->hasFrontendUser())
72
+        {
73
+            return '';
74
+        }
75
+
76
+        $this->import(FrontendUser::class, 'User');
77
+        $objMember = MemberModel::findByPk($this->User->id);
78
+
79
+        if(null === $objMember)
80
+        {
81
+            return '';
82
+        }
83
+
84
+        // Confirmation message
85
+        $session = System::getContainer()->get('session');
86
+        $flashBag = $session->getFlashBag();
87
+
88
+        // Return if there is no flashbag message or an avatar
89
+        if (!($session->isStarted() && $flashBag->has('mod_avatar_deleted')) && !$objMember->avatar)
90
+        {
91
+            return '';
92
+        }
93
+
94
+        return parent::generate();
95
+    }
96
+
97
+    /**
98
+     * Generate the module
99
+     */
100
+    protected function compile()
101
+    {
102
+        $strFormId = 'deleteAvatar_' . $this->id;
103
+        $session = System::getContainer()->get('session');
104
+        $flashBag = $session->getFlashBag();
105
+
106
+        // Get form submit
107
+        if (Input::post('FORM_SUBMIT') == $strFormId)
108
+        {
109
+            $this->import(FrontendUser::class, 'User');
110
+            $objMember = MemberModel::findByPk($this->User->id);
111
+
112
+            // Delete avatar if it exists
113
+            if(!!$objMember->avatar)
114
+            {
115
+                Member::deleteAvatar($objMember);
116
+                // Unset avatar
117
+                $objMember->avatar = null;
118
+                $objMember->save();
119
+
120
+                // Set message for deletion feedback
121
+                $flashBag->set('mod_avatar_deleted', $GLOBALS['TL_LANG']['MSC']['avatarDeleted']);
122
+                $this->reload();
123
+            }
124
+        }
125
+
126
+        // Confirmation message
127
+        if($session->isStarted() && $flashBag->has('mod_avatar_deleted')) {
128
+            $arrMessages = $flashBag->get('mod_avatar_deleted');
129
+            $this->Template->message = $arrMessages[0];
130
+        }
131
+
132
+        $this->Template->formId = $strFormId;
133
+        $this->Template->slabel = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['deleteAvatar']);
134
+    }
135
+}