Completed
Push — master ( c08111...74731f )
by Tim
15:33
created
Classes/Service/AccessService.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@
 block discarded – undo
136 136
     }
137 137
 
138 138
     /**
139
-     * @param $formProtectionId
139
+     * @param integer $formProtectionId
140 140
      *
141 141
      * @return bool
142 142
      */
Please login to merge, or discard this patch.
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -25,150 +25,150 @@
 block discarded – undo
25 25
 class AccessService extends AbstractService
26 26
 {
27 27
 
28
-    /**
29
-     * Session service
30
-     *
31
-     * @var \HVP\Html5videoplayerPowermail\Service\SessionService
32
-     * @inject
33
-     */
34
-    protected $sessionService;
35
-
36
-    /**
37
-     * Uri Builder
38
-     *
39
-     * @var \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
40
-     * @inject
41
-     */
42
-    protected $uriBuilder;
43
-
44
-    /**
45
-     * Flexform service
46
-     *
47
-     * @var \TYPO3\CMS\Extbase\Service\FlexFormService
48
-     * @inject
49
-     */
50
-    protected $flexFormService;
51
-
52
-    /**
53
-     * The session name
54
-     *
55
-     * @var string
56
-     */
57
-    protected $sessionName = 'submittedForms';
58
-
59
-    /**
60
-     * @param Video $video
61
-     */
62
-    public function checkVideoAccess(Video $video = null)
63
-    {
64
-        if ($video === null) {
65
-            return;
66
-        }
67
-
68
-        $formProtection = $this->getFormProtection($video);
69
-        if ($formProtection <= 0) {
70
-            return;
71
-        }
72
-
73
-        // disable the cache
74
-        $message = 'Do not cache video detail page, because every request is check via html5videoplayer_powermail';
75
-        GlobalUtility::getTypoScriptFrontendController($message)
76
-            ->set_no_cache();
77
-
78
-        if ($this->isAccessableByCurrentUser($formProtection)) {
79
-            return;
80
-        }
81
-
82
-        $formPage = $this->findFormPage($formProtection);
83
-        if ($formPage) {
84
-            $this->sessionService->set('videoReturnUrl', GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
85
-
86
-            $uri = $this->uriBuilder->setTargetPageUid($formPage)
87
-                ->build();
88
-            HttpUtility::redirect($uri, HttpUtility::HTTP_STATUS_403);
89
-        }
90
-    }
91
-
92
-    /**
93
-     * @param Form $form
94
-     */
95
-    public function triggerFormSubmit(Form $form)
96
-    {
97
-        if ($this->sessionService->has('videoReturnUrl') && $this->isProtectionForm($form)) {
98
-            $forms = $this->sessionService->has($this->sessionName) ? $this->sessionService->get($this->sessionName) : [];
99
-            $forms[] = $form->getUid();
100
-            $this->sessionService->set($this->sessionName, $forms);
101
-            HttpUtility::redirect($this->sessionService->get('videoReturnUrl'));
102
-        }
103
-    }
104
-
105
-    /**
106
-     * Find the given page UID of the form Protection ID
107
-     *
108
-     * @param int $formProtectionId
109
-     *
110
-     * @return int
111
-     */
112
-    protected function findFormPage($formProtectionId)
113
-    {
114
-        $pluings = $this->findPowermailPlugins();
115
-        foreach ($pluings as $plugin) {
116
-            $configuration = $this->flexFormService->convertFlexFormContentToArray($plugin['pi_flexform']);
117
-            if (isset($configuration['settings']['flexform']['main']['form'])) {
118
-                $formId = $configuration['settings']['flexform']['main']['form'];
119
-                if (MathUtility::canBeInterpretedAsInteger($formId) && (int)$formId == $formProtectionId) {
120
-                    return $plugin['pid'];
121
-                }
122
-            }
123
-        }
124
-        return 0;
125
-    }
126
-
127
-    /**
128
-     * Find all includes Powermail plugins
129
-     *
130
-     * @return array
131
-     */
132
-    protected function findPowermailPlugins()
133
-    {
134
-        $database = GlobalUtility::getDatabaseConnection();
135
-        $pageRepository = new PageRepository();
136
-        $where = 'CType="list" AND list_type="powermail_pi1"' . $pageRepository->enableFields('tt_content');
137
-        return $database->exec_SELECTgetRows('uid,pid,pi_flexform', 'tt_content', $where);
138
-    }
139
-
140
-    /**
141
-     * @param $formProtectionId
142
-     *
143
-     * @return bool
144
-     */
145
-    protected function isAccessableByCurrentUser($formProtectionId)
146
-    {
147
-        $forms = $this->sessionService->has($this->sessionName) ? $this->sessionService->get($this->sessionName) : [];
148
-        return in_array((int)$formProtectionId, $forms);
149
-    }
150
-
151
-    /**
152
-     * @param Form $form
153
-     *
154
-     * @return bool
155
-     */
156
-    protected function isProtectionForm(Form $form)
157
-    {
158
-        return (bool)GlobalUtility::getDatabaseConnection()
159
-            ->exec_SELECTcountRows('*', 'tx_html5videoplayer_domain_model_video', 'powermail_protection=' . $form->getUid());
160
-    }
161
-
162
-    /**
163
-     * Get the Form protection value
164
-     *
165
-     * @param Video $video
166
-     *
167
-     * @return int
168
-     */
169
-    protected function getFormProtection(Video $video)
170
-    {
171
-        $record = BackendUtility::getRecord('tx_html5videoplayer_domain_model_video', $video->getUid());
172
-        return (int)$record['powermail_protection'];
173
-    }
28
+	/**
29
+	 * Session service
30
+	 *
31
+	 * @var \HVP\Html5videoplayerPowermail\Service\SessionService
32
+	 * @inject
33
+	 */
34
+	protected $sessionService;
35
+
36
+	/**
37
+	 * Uri Builder
38
+	 *
39
+	 * @var \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
40
+	 * @inject
41
+	 */
42
+	protected $uriBuilder;
43
+
44
+	/**
45
+	 * Flexform service
46
+	 *
47
+	 * @var \TYPO3\CMS\Extbase\Service\FlexFormService
48
+	 * @inject
49
+	 */
50
+	protected $flexFormService;
51
+
52
+	/**
53
+	 * The session name
54
+	 *
55
+	 * @var string
56
+	 */
57
+	protected $sessionName = 'submittedForms';
58
+
59
+	/**
60
+	 * @param Video $video
61
+	 */
62
+	public function checkVideoAccess(Video $video = null)
63
+	{
64
+		if ($video === null) {
65
+			return;
66
+		}
67
+
68
+		$formProtection = $this->getFormProtection($video);
69
+		if ($formProtection <= 0) {
70
+			return;
71
+		}
72
+
73
+		// disable the cache
74
+		$message = 'Do not cache video detail page, because every request is check via html5videoplayer_powermail';
75
+		GlobalUtility::getTypoScriptFrontendController($message)
76
+			->set_no_cache();
77
+
78
+		if ($this->isAccessableByCurrentUser($formProtection)) {
79
+			return;
80
+		}
81
+
82
+		$formPage = $this->findFormPage($formProtection);
83
+		if ($formPage) {
84
+			$this->sessionService->set('videoReturnUrl', GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
85
+
86
+			$uri = $this->uriBuilder->setTargetPageUid($formPage)
87
+				->build();
88
+			HttpUtility::redirect($uri, HttpUtility::HTTP_STATUS_403);
89
+		}
90
+	}
91
+
92
+	/**
93
+	 * @param Form $form
94
+	 */
95
+	public function triggerFormSubmit(Form $form)
96
+	{
97
+		if ($this->sessionService->has('videoReturnUrl') && $this->isProtectionForm($form)) {
98
+			$forms = $this->sessionService->has($this->sessionName) ? $this->sessionService->get($this->sessionName) : [];
99
+			$forms[] = $form->getUid();
100
+			$this->sessionService->set($this->sessionName, $forms);
101
+			HttpUtility::redirect($this->sessionService->get('videoReturnUrl'));
102
+		}
103
+	}
104
+
105
+	/**
106
+	 * Find the given page UID of the form Protection ID
107
+	 *
108
+	 * @param int $formProtectionId
109
+	 *
110
+	 * @return int
111
+	 */
112
+	protected function findFormPage($formProtectionId)
113
+	{
114
+		$pluings = $this->findPowermailPlugins();
115
+		foreach ($pluings as $plugin) {
116
+			$configuration = $this->flexFormService->convertFlexFormContentToArray($plugin['pi_flexform']);
117
+			if (isset($configuration['settings']['flexform']['main']['form'])) {
118
+				$formId = $configuration['settings']['flexform']['main']['form'];
119
+				if (MathUtility::canBeInterpretedAsInteger($formId) && (int)$formId == $formProtectionId) {
120
+					return $plugin['pid'];
121
+				}
122
+			}
123
+		}
124
+		return 0;
125
+	}
126
+
127
+	/**
128
+	 * Find all includes Powermail plugins
129
+	 *
130
+	 * @return array
131
+	 */
132
+	protected function findPowermailPlugins()
133
+	{
134
+		$database = GlobalUtility::getDatabaseConnection();
135
+		$pageRepository = new PageRepository();
136
+		$where = 'CType="list" AND list_type="powermail_pi1"' . $pageRepository->enableFields('tt_content');
137
+		return $database->exec_SELECTgetRows('uid,pid,pi_flexform', 'tt_content', $where);
138
+	}
139
+
140
+	/**
141
+	 * @param $formProtectionId
142
+	 *
143
+	 * @return bool
144
+	 */
145
+	protected function isAccessableByCurrentUser($formProtectionId)
146
+	{
147
+		$forms = $this->sessionService->has($this->sessionName) ? $this->sessionService->get($this->sessionName) : [];
148
+		return in_array((int)$formProtectionId, $forms);
149
+	}
150
+
151
+	/**
152
+	 * @param Form $form
153
+	 *
154
+	 * @return bool
155
+	 */
156
+	protected function isProtectionForm(Form $form)
157
+	{
158
+		return (bool)GlobalUtility::getDatabaseConnection()
159
+			->exec_SELECTcountRows('*', 'tx_html5videoplayer_domain_model_video', 'powermail_protection=' . $form->getUid());
160
+	}
161
+
162
+	/**
163
+	 * Get the Form protection value
164
+	 *
165
+	 * @param Video $video
166
+	 *
167
+	 * @return int
168
+	 */
169
+	protected function getFormProtection(Video $video)
170
+	{
171
+		$record = BackendUtility::getRecord('tx_html5videoplayer_domain_model_video', $video->getUid());
172
+		return (int)$record['powermail_protection'];
173
+	}
174 174
 }
Please login to merge, or discard this patch.
Classes/Service/SessionService.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
      *
34 34
      * @param string $name
35 35
      *
36
-     * @return mixed|null
36
+     * @return string
37 37
      */
38 38
     public function get($name)
39 39
     {
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -16,46 +16,46 @@
 block discarded – undo
16 16
 class SessionService extends AbstractService
17 17
 {
18 18
 
19
-    /**
20
-     * Check if the value exists
21
-     *
22
-     * @param string $name
23
-     *
24
-     * @return boolean
25
-     */
26
-    public function has($name)
27
-    {
28
-        return isset($_COOKIE[$name]);
29
-    }
19
+	/**
20
+	 * Check if the value exists
21
+	 *
22
+	 * @param string $name
23
+	 *
24
+	 * @return boolean
25
+	 */
26
+	public function has($name)
27
+	{
28
+		return isset($_COOKIE[$name]);
29
+	}
30 30
 
31
-    /**
32
-     * Get a vaukue
33
-     *
34
-     * @param string $name
35
-     *
36
-     * @return mixed|null
37
-     */
38
-    public function get($name)
39
-    {
40
-        if (!$this->has($name)) {
41
-            return null;
42
-        }
43
-        return unserialize($_COOKIE[$name]);
31
+	/**
32
+	 * Get a vaukue
33
+	 *
34
+	 * @param string $name
35
+	 *
36
+	 * @return mixed|null
37
+	 */
38
+	public function get($name)
39
+	{
40
+		if (!$this->has($name)) {
41
+			return null;
42
+		}
43
+		return unserialize($_COOKIE[$name]);
44 44
 
45
-    }
45
+	}
46 46
 
47
-    /**
48
-     * Set a value
49
-     *
50
-     * @param string $name
51
-     * @param mixed  $value
52
-     *
53
-     * @return void
54
-     */
55
-    public function set($name, $value)
56
-    {
57
-        $setValue = serialize($value);
58
-        setcookie($name, $setValue, null, '/');
59
-        $_COOKIE[$name] = $setValue;
60
-    }
47
+	/**
48
+	 * Set a value
49
+	 *
50
+	 * @param string $name
51
+	 * @param mixed  $value
52
+	 *
53
+	 * @return void
54
+	 */
55
+	public function set($name, $value)
56
+	{
57
+		$setValue = serialize($value);
58
+		setcookie($name, $setValue, null, '/');
59
+		$_COOKIE[$name] = $setValue;
60
+	}
61 61
 }
Please login to merge, or discard this patch.
Classes/Utility/GlobalUtility.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,23 +19,23 @@
 block discarded – undo
19 19
 class GlobalUtility
20 20
 {
21 21
 
22
-    /**
23
-     * Get the TSFE
24
-     *
25
-     * @return TypoScriptFrontendController
26
-     */
27
-    public static function getTypoScriptFrontendController()
28
-    {
29
-        return $GLOBALS['TSFE'];
30
-    }
22
+	/**
23
+	 * Get the TSFE
24
+	 *
25
+	 * @return TypoScriptFrontendController
26
+	 */
27
+	public static function getTypoScriptFrontendController()
28
+	{
29
+		return $GLOBALS['TSFE'];
30
+	}
31 31
 
32
-    /**
33
-     * Get the database connection
34
-     *
35
-     * @return DatabaseConnection
36
-     */
37
-    public static function getDatabaseConnection()
38
-    {
39
-        return $GLOBALS['TYPO3_DB'];
40
-    }
32
+	/**
33
+	 * Get the database connection
34
+	 *
35
+	 * @return DatabaseConnection
36
+	 */
37
+	public static function getDatabaseConnection()
38
+	{
39
+		return $GLOBALS['TYPO3_DB'];
40
+	}
41 41
 }
Please login to merge, or discard this patch.
Classes/Slots/Videoplayer.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@
 block discarded – undo
16 16
 class Videoplayer extends AbstractSlot
17 17
 {
18 18
 
19
-    /**
20
-     * Slot for html5videoplayer
21
-     *
22
-     * @param $videos
23
-     * @param $video
24
-     *
25
-     * @return void
26
-     */
27
-    public function detailAction($videos, $video)
28
-    {
29
-        $this->getAccessService()
30
-            ->checkVideoAccess($video);
31
-    }
19
+	/**
20
+	 * Slot for html5videoplayer
21
+	 *
22
+	 * @param $videos
23
+	 * @param $video
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function detailAction($videos, $video)
28
+	{
29
+		$this->getAccessService()
30
+			->checkVideoAccess($video);
31
+	}
32 32
 }
Please login to merge, or discard this patch.
Classes/Slots/Form.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,16 +20,16 @@
 block discarded – undo
20 20
 class Form extends AbstractSlot
21 21
 {
22 22
 
23
-    /**
24
-     * Slot for powermail
25
-     *
26
-     * @param Mail           $mail
27
-     * @param string         $hash
28
-     * @param FormController $formController
29
-     */
30
-    public function createActionAfterSubmitView(Mail $mail, $hash, FormController $formController)
31
-    {
32
-        $this->getAccessService()
33
-            ->triggerFormSubmit($mail->getForm());
34
-    }
23
+	/**
24
+	 * Slot for powermail
25
+	 *
26
+	 * @param Mail           $mail
27
+	 * @param string         $hash
28
+	 * @param FormController $formController
29
+	 */
30
+	public function createActionAfterSubmitView(Mail $mail, $hash, FormController $formController)
31
+	{
32
+		$this->getAccessService()
33
+			->triggerFormSubmit($mail->getForm());
34
+	}
35 35
 }
Please login to merge, or discard this patch.
Classes/Slots/AbstractSlot.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,14 +19,14 @@
 block discarded – undo
19 19
 abstract class AbstractSlot
20 20
 {
21 21
 
22
-    /**
23
-     * Get the access service+
24
-     *
25
-     * @return AccessService
26
-     */
27
-    protected function getAccessService()
28
-    {
29
-        $objectManager = new ObjectManager();
30
-        return $objectManager->get(AccessService::class);
31
-    }
22
+	/**
23
+	 * Get the access service+
24
+	 *
25
+	 * @return AccessService
26
+	 */
27
+	protected function getAccessService()
28
+	{
29
+		$objectManager = new ObjectManager();
30
+		return $objectManager->get(AccessService::class);
31
+	}
32 32
 }
Please login to merge, or discard this patch.