Browse Source

Minor - Flint fixes

Angel Fernando Quiroz Campos 6 years ago
parent
commit
1ab450fda0
2 changed files with 60 additions and 60 deletions
  1. 9 9
      main/inc/lib/userportal.lib.php
  2. 51 51
      plugin/whispeakauth/WhispeakAuthPlugin.php

+ 9 - 9
main/inc/lib/userportal.lib.php

@@ -947,16 +947,16 @@ class IndexManager
         }
 
         if (true === api_get_configuration_value('whispeak_auth_enabled')) {
-//            if (!WhispeakAuthPlugin::checkUserIsEnrolled($userId)) {
-                $itemTitle = WhispeakAuthPlugin::create()->get_title();
+            //if (!WhispeakAuthPlugin::checkUserIsEnrolled($userId)) {
+            $itemTitle = WhispeakAuthPlugin::create()->get_title();
 
-                $items[] = [
-                    'class' => 'whispeak-enrollment',
-                    'icon' => Display::return_icon('addworkuser.png', $itemTitle),
-                    'link' => WhispeakAuthPlugin::getEnrollmentUrl(),
-                    'title' => $itemTitle,
-                ];
-//            }
+            $items[] = [
+                'class' => 'whispeak-enrollment',
+                'icon' => Display::return_icon('addworkuser.png', $itemTitle),
+                'link' => WhispeakAuthPlugin::getEnrollmentUrl(),
+                'title' => $itemTitle,
+            ];
+            //}
         }
 
         return $items;

+ 51 - 51
plugin/whispeakauth/WhispeakAuthPlugin.php

@@ -127,57 +127,6 @@ class WhispeakAuthPlugin extends Plugin
         return api_get_path(WEB_PLUGIN_PATH).'whispeakauth/enrollment.php';
     }
 
-    /**
-     * @return string
-     */
-    private function getApiUrl()
-    {
-        $url = $this->get(self::SETTING_API_URL);
-
-        return trim($url, " \t\n\r \v/");
-    }
-
-    /**
-     * @param string $endPoint
-     * @param array  $metadata
-     * @param User   $user
-     * @param string $filePath
-     *
-     * @return array
-     */
-    private function sendRequest($endPoint, array $metadata, User $user, $filePath)
-    {
-        $moderator = $user->getCreatorId() ?: $user->getId();
-        $apiUrl = $this->getApiUrl()."/$endPoint";
-        $headers = [
-            //"Content-Type: application/x-www-form-urlencoded",
-            "Authorization: Bearer ".$this->get(self::SETTING_TOKEN),
-        ];
-        $post = [
-            'metadata' => json_encode($metadata),
-            'moderator' => "moderator_$moderator",
-            'client' => base64_encode($user->getUserId()),
-            'voice' => new CURLFile($filePath),
-        ];
-
-        $ch = curl_init();
-        curl_setopt($ch, CURLOPT_URL, $apiUrl);
-        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
-        curl_setopt($ch, CURLOPT_POST, true);
-        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-        $result = curl_exec($ch);
-        curl_close($ch);
-
-        $result = json_decode($result, true);
-
-        if (!empty($result['error'])) {
-            return null;
-        }
-
-        return json_decode($result, true);
-    }
-
     /**
      * @param User   $user
      * @param string $filePath
@@ -286,4 +235,55 @@ class WhispeakAuthPlugin extends Plugin
 
         api_not_allowed($printHeaders);
     }
+
+    /**
+     * @return string
+     */
+    private function getApiUrl()
+    {
+        $url = $this->get(self::SETTING_API_URL);
+
+        return trim($url, " \t\n\r \v/");
+    }
+
+    /**
+     * @param string $endPoint
+     * @param array  $metadata
+     * @param User   $user
+     * @param string $filePath
+     *
+     * @return array
+     */
+    private function sendRequest($endPoint, array $metadata, User $user, $filePath)
+    {
+        $moderator = $user->getCreatorId() ?: $user->getId();
+        $apiUrl = $this->getApiUrl()."/$endPoint";
+        $headers = [
+            //"Content-Type: application/x-www-form-urlencoded",
+            "Authorization: Bearer ".$this->get(self::SETTING_TOKEN),
+        ];
+        $post = [
+            'metadata' => json_encode($metadata),
+            'moderator' => "moderator_$moderator",
+            'client' => base64_encode($user->getUserId()),
+            'voice' => new CURLFile($filePath),
+        ];
+
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $apiUrl);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+        curl_setopt($ch, CURLOPT_POST, true);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        $result = curl_exec($ch);
+        curl_close($ch);
+
+        $result = json_decode($result, true);
+
+        if (!empty($result['error'])) {
+            return null;
+        }
+
+        return json_decode($result, true);
+    }
 }