diff --git a/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/assets/css/oneallsociallogin.css b/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/assets/css/oneallsociallogin.css
old mode 100755
new mode 100644
diff --git a/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/assets/js/jquery.js b/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/assets/js/jquery.js
old mode 100755
new mode 100644
diff --git a/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/assets/js/oneallsociallogin.js b/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/assets/js/oneallsociallogin.js
old mode 100755
new mode 100644
diff --git a/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/install/install.mysql.utf8.sql b/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/install/install.mysql.utf8.sql
old mode 100755
new mode 100644
diff --git a/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/install/script.oneallsociallogin.php b/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/install/script.oneallsociallogin.php
new file mode 100644
index 00000000..646975d5
--- /dev/null
+++ b/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/install/script.oneallsociallogin.php
@@ -0,0 +1,532 @@
+ array(
+ 'site' => array(
+ 'oneallsociallogin' => array(
+ 'title' => 'Social Login',
+ 'position' => 'position-7',
+ 'order' => 8,
+ 'published' => 1,
+ 'language' => '*',
+ 'showtitle' => 0
+ )
+ )
+ ),
+ 'plugins' => array(
+ 'system' => array(
+ 'oneallsociallogin' => array(
+ 'published' => 1
+ )
+ )
+ )
+ );
+
+ /**
+ * Runs before install, update or discover_install
+ */
+ public function preflight ($type, $parent)
+ {
+ switch ($type)
+ {
+ case 'install' :
+ case 'discover_install' :
+ $this->bugfix_db_function_returned_no_error ();
+ break;
+
+ case 'update' :
+ $this->bugfix_cannot_build_admin_menus ();
+ break;
+ }
+
+ // Only allow to install on Joomla! 3 or later
+ return version_compare (JVERSION, '3', 'ge');
+ }
+
+ /**
+ * Runs after install, update or discover_update
+ */
+ public function postflight ($type, $parent)
+ {
+ // Install sub-extensions
+ $status = $this->install_sub_extensions ($parent);
+
+ // Show the post-installation page
+ $this->render_post_installation ($status, $parent);
+ }
+
+ /**
+ * Runs on uninstallation
+ */
+ public function uninstall ($parent)
+ {
+ // Uninstall subextensions
+ $status = $this->uninstall_sub_extensions ($parent);
+
+ // Show the post-uninstallation page
+ $this->render_post_uninstallation ($status, $parent);
+ }
+
+ /**
+ * Renders the post-installation message
+ */
+ private function render_post_installation ($status, $parent)
+ {
+ $message = '
Thank you very much for having installed Social Login!
';
+ $message .= 'Please open the Social Login Configuration to enable this component.
';
+ echo $message;
+ }
+
+ /**
+ * Renders the post-uninstallation message
+ */
+ private function render_post_uninstallation ($status, $parent)
+ {
+ $message = 'Social Login has been uninstalled successfully.';
+ echo $message;
+ }
+
+ /**
+ * Joomla! bugfix for "DB function returned no error"
+ */
+ private function bugfix_db_function_returned_no_error ()
+ {
+ $db = JFactory::getDbo ();
+
+ // Fix broken #__assets records
+ $query = $db->getQuery (true);
+ $query->select ('id')->from ('#__assets')->where ($db->qn ('name') . ' = ' . $db->q ($this->_oneallsociallogin_extension));
+ $db->setQuery ($query);
+ $ids = $db->loadColumn ();
+
+ if (is_array ($ids))
+ {
+ foreach ($ids as $id)
+ {
+ $query = $db->getQuery (true);
+ $query->delete ('#__assets')->where ($db->qn ('id') . ' = ' . $db->q ($id));
+ $db->setQuery ($query);
+ $db->query ();
+ }
+ }
+
+ // Fix broken #__extensions records
+ $query = $db->getQuery (true);
+ $query->select ('extension_id')->from ('#__extensions')->where ($db->qn ('element') . ' = ' . $db->q ($this->_oneallsociallogin_extension));
+ $db->setQuery ($query);
+ $ids = $db->loadColumn ();
+
+ if (is_array ($ids))
+ {
+ foreach ($ids as $id)
+ {
+ $query = $db->getQuery (true);
+ $query->delete ('#__extensions')->where ($db->qn ('extension_id') . ' = ' . $db->q ($id));
+ $db->setQuery ($query);
+ $db->query ();
+ }
+ }
+
+ // Fix broken #__menu records
+ $query = $db->getQuery (true);
+ $query->select ('id')->from ('#__menu')->where ($db->qn ('type') . ' = ' . $db->q ('component'))->where ($db->qn ('menutype') . ' = ' . $db->q ('main'))->where ($db->qn ('link') . ' LIKE ' . $db->q ('index.php?option=' . $this->_oneallsociallogin_extension));
+ $db->setQuery ($query);
+ $ids = $db->loadColumn ();
+
+ if (is_array ($ids))
+ {
+ foreach ($ids as $id)
+ {
+ $query = $db->getQuery (true);
+ $query->delete ('#__menu')->where ($db->qn ('id') . ' = ' . $db->q ($id));
+ $db->setQuery ($query);
+ $db->query ();
+ }
+ }
+ }
+
+ /**
+ * Joomla! bugfix for "Can not build admin menus"
+ */
+ private function bugfix_cannot_build_admin_menus ()
+ {
+ $db = JFactory::getDbo ();
+
+ // If there are multiple #__extensions record, keep one of them
+ $query = $db->getQuery (true);
+ $query->select ('extension_id')->from ('#__extensions')->where ($db->qn ('element') . ' = ' . $db->q ($this->_oneallsociallogin_extension));
+ $db->setQuery ($query);
+ $ids = $db->loadColumn ();
+ if (count ($ids) > 1)
+ {
+ asort ($ids);
+ $extension_id = array_shift ($ids); // Keep the oldest id
+
+ foreach ($ids as $id)
+ {
+ $query = $db->getQuery (true);
+ $query->delete ('#__extensions')->where ($db->qn ('extension_id') . ' = ' . $db->q ($id));
+ $db->setQuery ($query);
+ $db->query ();
+ }
+ }
+
+ // If there are multiple assets records, delete all except the oldest one
+ $query = $db->getQuery (true);
+ $query->select ('id')->from ('#__assets')->where ($db->qn ('name') . ' = ' . $db->q ($this->_oneallsociallogin_extension));
+ $db->setQuery ($query);
+ $ids = $db->loadObjectList ();
+ if (count ($ids) > 1)
+ {
+ asort ($ids);
+ $asset_id = array_shift ($ids); // Keep the oldest id
+
+ foreach ($ids as $id)
+ {
+ $query = $db->getQuery (true);
+ $query->delete ('#__assets')->where ($db->qn ('id') . ' = ' . $db->q ($id));
+ $db->setQuery ($query);
+ $db->query ();
+ }
+ }
+
+ // Remove #__menu records for good measure!
+ $query = $db->getQuery (true);
+ $query->select ('id')->from ('#__menu')->where ($db->qn ('type') . ' = ' . $db->q ('component'))->where ($db->qn ('menutype') . ' = ' . $db->q ('main'))->where ($db->qn ('link') . ' LIKE ' . $db->q ('index.php?option=' . $this->_oneallsociallogin_extension));
+ $db->setQuery ($query);
+ $ids1 = $db->loadColumn ();
+ if (empty ($ids1))
+ $ids1 = array();
+ $query = $db->getQuery (true);
+ $query->select ('id')->from ('#__menu')->where ($db->qn ('type') . ' = ' . $db->q ('component'))->where ($db->qn ('menutype') . ' = ' . $db->q ('main'))->where ($db->qn ('link') . ' LIKE ' . $db->q ('index.php?option=' . $this->_oneallsociallogin_extension . '&%'));
+ $db->setQuery ($query);
+ $ids2 = $db->loadColumn ();
+ if (empty ($ids2))
+ $ids2 = array();
+ $ids = array_merge ($ids1, $ids2);
+ if (!empty ($ids))
+ foreach ($ids as $id)
+ {
+ $query = $db->getQuery (true);
+ $query->delete ('#__menu')->where ($db->qn ('id') . ' = ' . $db->q ($id));
+ $db->setQuery ($query);
+ $db->query ();
+ }
+ }
+
+ /**
+ * Installs subextensions (modules, plugins) bundled with the main extension
+ */
+ private function install_sub_extensions ($parent)
+ {
+ $src = $parent->getParent ()->getPath ('source');
+
+ $db = JFactory::getDbo ();
+
+ // The subextension installation status
+ $status = new JObject ();
+ $status->modules = array();
+ $status->plugins = array();
+
+ // Modules installation
+ if (isset ($this->installation_queue ['modules']) and is_array ($this->installation_queue ['modules']))
+ {
+ foreach ($this->installation_queue ['modules'] as $folder => $modules)
+ {
+ if (is_array ($modules))
+ {
+ foreach ($modules as $module => $module_preferences)
+ {
+ // Look for the temporary installation folder
+ $path = $src . '/modules/' . $folder . '/' . $module;
+
+ if (!is_dir ($path))
+ {
+ $path = $src . '/modules/' . $folder . '/mod_' . $module;
+ }
+
+ if (!is_dir ($path))
+ {
+ $path = $src . '/modules/' . $module;
+ }
+
+ if (!is_dir ($path))
+ {
+ $path = $src . '/modules/mod_' . $module;
+ }
+
+ if (!is_dir ($path))
+ {
+ $path = $src . '/mod_' . $module;
+ }
+
+ if (!is_dir ($path))
+ {
+ continue;
+ }
+
+ // Was the module already installed?
+ $sql = $db->getQuery (true)->select ('COUNT(*)')->from ('#__modules')->where ($db->qn ('module') . ' = ' . $db->q ('mod_' . $module));
+ $db->setQuery ($sql);
+ $count = $db->loadResult ();
+
+ // Install
+ $installer = new JInstaller ();
+ $installer->setOverwrite (true);
+ $result = $installer->install ($path);
+
+ // Store status
+ $status->modules [] = array(
+ 'name' => 'mod_' . $module,
+ 'client' => $folder,
+ 'result' => $result
+ );
+
+ // Modify where it's published and its published state
+ if (!$count)
+ {
+ // Flags
+ $module_position = (isset ($module_preferences ['position']) ? $module_preferences ['position'] : 1);
+ $module_published = (!empty ($module_preferences ['published']));
+ $module_showtitle = (!empty ($module_preferences ['showtitle']));
+
+ // Position
+ $sql = $db->getQuery (true)->update ($db->qn ('#__modules'))->set ($db->qn ('position') . ' = ' . $db->q ($module_position))->where ($db->qn ('module') . ' = ' . $db->q ('mod_' . $module));
+
+ // Published
+ if ($module_published)
+ {
+ $sql->set ($db->qn ('published') . ' = ' . $db->q ('1'));
+ }
+
+ // Do not display the title?
+ if (!$module_showtitle)
+ {
+ $sql->set ($db->qn ('showtitle') . ' = ' . $db->q ('0'));
+ }
+
+ $db->setQuery ($sql);
+ $db->query ();
+
+ // Change the ordering of back-end modules to 1 + max ordering
+ if ($folder == 'admin')
+ {
+ $query = $db->getQuery (true);
+ $query->select ('MAX(' . $db->qn ('ordering') . ')')->from ($db->qn ('#__modules'))->where ($db->qn ('position') . '=' . $db->q ($module_position));
+ $db->setQuery ($query);
+ $position = $db->loadResult ();
+ $position ++;
+
+ $query = $db->getQuery (true);
+ $query->update ($db->qn ('#__modules'))->set ($db->qn ('ordering') . ' = ' . $db->q ($position))->where ($db->qn ('module') . ' = ' . $db->q ('mod_' . $module));
+ $db->setQuery ($query);
+ $db->query ();
+ }
+
+ // Link to all pages
+ $query = $db->getQuery (true);
+ $query->select ('id')->from ($db->qn ('#__modules'))->where ($db->qn ('module') . ' = ' . $db->q ('mod_' . $module));
+ $db->setQuery ($query);
+ $moduleid = $db->loadResult ();
+
+ $query = $db->getQuery (true);
+ $query->select ('*')->from ($db->qn ('#__modules_menu'))->where ($db->qn ('moduleid') . ' = ' . $db->q ($moduleid));
+ $db->setQuery ($query);
+ $assignments = $db->loadObjectList ();
+
+ $isAssigned = !empty ($assignments);
+ if (!$isAssigned)
+ {
+ $o = (object) array(
+ 'moduleid' => $moduleid,
+ 'menuid' => 0
+ );
+ $db->insertObject ('#__modules_menu', $o);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Plugins installation
+ if (isset ($this->installation_queue ['plugins']) and is_array ($this->installation_queue ['plugins']))
+ {
+ foreach ($this->installation_queue ['plugins'] as $folder => $plugins)
+ {
+ if (is_array ($plugins))
+ {
+ foreach ($plugins as $plugin => $plugin_preferences)
+ {
+ // Look for the temporary installation folder
+ $path = $src . '/plugins/' . $folder . '/$plugin';
+
+ if (!is_dir ($path))
+ {
+ $path = $src . '/plugins/' . $folder . '/plg_' . $plugin;
+ }
+
+ if (!is_dir ($path))
+ {
+ $path = $src . '/plugins/' . $plugin;
+ }
+
+ if (!is_dir ($path))
+ {
+ $path = $src . '/plugins/plg_' . $plugin;
+ }
+
+ if (!is_dir ($path))
+ {
+ $path = $src . '/plg_' . $plugin;
+ }
+
+ if (!is_dir ($path))
+ {
+ continue;
+ }
+
+ // Was the plugin already installed?
+ $query = $db->getQuery (true)->select ('COUNT(*)')->from ($db->qn ('#__extensions'))->where ($db->qn ('element') . ' = ' . $db->q ($plugin))->where ($db->qn ('folder') . ' = ' . $db->q ($folder));
+ $db->setQuery ($query);
+ $count = $db->loadResult ();
+
+ // Install
+ $installer = new JInstaller ();
+ $result = $installer->install ($path);
+
+ // Store status
+ $status->plugins [] = array(
+ 'name' => 'plg_' . $plugin,
+ 'group' => $folder,
+ 'result' => $result
+ );
+
+ // Publish plugin
+ if (!empty ($plugin_preferences ['published']) && !$count)
+ {
+ $query = $db->getQuery (true)->update ($db->qn ('#__extensions'))->set ($db->qn ('enabled') . ' = ' . $db->q ('1'))->where ($db->qn ('element') . ' = ' . $db->q ($plugin))->where ($db->qn ('folder') . ' = ' . $db->q ($folder));
+ $db->setQuery ($query);
+ $db->query ();
+ }
+ }
+ }
+ }
+ }
+
+ return $status;
+ }
+
+ /**
+ * Uninstalls subextensions (modules, plugins) bundled with the main extension
+ */
+ private function uninstall_sub_extensions ($parent)
+ {
+ jimport ('joomla.installer.installer');
+
+ // Database handler
+ $db = JFactory::getDBO ();
+
+ // Uninstall status
+ $status = new JObject ();
+ $status->modules = array();
+ $status->plugins = array();
+
+ // Modules uninstallation
+ if (isset ($this->installation_queue ['modules']) and is_array ($this->installation_queue ['modules']))
+ {
+ foreach ($this->installation_queue ['modules'] as $folder => $modules)
+ {
+ if (is_array ($modules))
+ {
+ foreach ($modules as $module => $module_preferences)
+ {
+ // Find the module ID
+ $sql = $db->getQuery (true)->select ($db->qn ('extension_id'))->from ($db->qn ('#__extensions'))->where ($db->qn ('element') . ' = ' . $db->q ('mod_' . $module))->where ($db->qn ('type') . ' = ' . $db->q ('module'));
+ $db->setQuery ($sql);
+ $id = $db->loadResult ();
+
+ // Uninstall the module
+ if ($id)
+ {
+ $installer = new JInstaller ();
+ $result = $installer->uninstall ('module', $id, 1);
+ $status->modules [] = array(
+ 'name' => 'mod_' . $module,
+ 'client' => $folder,
+ 'result' => $result
+ );
+ }
+ }
+ }
+ }
+ }
+
+ // Plugins uninstallation
+ if (isset ($this->installation_queue ['plugins']) and is_array ($this->installation_queue ['plugins']))
+ {
+ foreach ($this->installation_queue ['plugins'] as $folder => $plugins)
+ {
+ if (is_array ($plugins))
+ {
+ foreach ($plugins as $plugin => $plugin_preferences)
+ {
+ // Find the plugin ID
+ $sql = $db->getQuery (true)->select ($db->qn ('extension_id'))->from ($db->qn ('#__extensions'))->where ($db->qn ('type') . ' = ' . $db->q ('plugin'))->where ($db->qn ('element') . ' = ' . $db->q ($plugin))->where ($db->qn ('folder') . ' = ' . $db->q ($folder));
+ $db->setQuery ($sql);
+ $id = $db->loadResult ();
+
+ // Uninstall the plugin
+ if ($id)
+ {
+ $installer = new JInstaller ();
+ $result = $installer->uninstall ('plugin', $id, 1);
+ $status->plugins [] = array(
+ 'name' => 'plg_' . $plugin,
+ 'group' => $folder,
+ 'result' => $result
+ );
+ }
+ }
+ }
+ }
+ }
+ return $status;
+ }
+}
diff --git a/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/install/uninstall.mysql.utf8.sql b/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/install/uninstall.mysql.utf8.sql
old mode 100755
new mode 100644
diff --git a/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/manifest.xml b/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/manifest.xml
new file mode 100644
index 00000000..70744ab9
--- /dev/null
+++ b/packages/oneallsociallogin/administrator/components/com_oneallsociallogin/manifest.xml
@@ -0,0 +1,77 @@
+
+
+ OneAll Social Login
+ Open Source License, GPL v2 based
+ OneAll LLC
+ support@oneall.com
+ http://www.oneall.com
+ 2014-10-29
+ 2011 - Today, OneAll LLC
+ 5.5.0
+
+
+
+
+
+
+
+ install/install.mysql.utf8.sql
+
+
+
+
+
+
+ install/uninstall.mysql.utf8.sql
+
+
+ install/script.oneallsociallogin.php
+
+
+
+ index.html
+ oneallsociallogin.php
+
+
+
+
+
+
+ assets
+ install
+ models
+ views
+ index.html
+ controller.php
+ oneallsociallogin.php
+
+
+ en-GB.com_oneallsociallogin.sys.ini
+
+
+
+
+
+
+
+ classes
+ tmpl
+ index.html
+ mod_oneallsociallogin.php
+ mod_oneallsociallogin.xml
+
+
+
+
+
+
+
+
+ index.html
+ helper.php
+ oneallsociallogin.php
+ oneallsociallogin.xml
+
+
+
+
\ No newline at end of file
diff --git a/packages/oneallsociallogin/administrator/language/en-GB/en-GB.com_oneallsociallogin.sys.ini b/packages/oneallsociallogin/administrator/language/en-GB/en-GB.com_oneallsociallogin.sys.ini
old mode 100755
new mode 100644
diff --git a/packages/oneallsociallogin/modules/mod_oneallsociallogin/index.html b/packages/oneallsociallogin/modules/mod_oneallsociallogin/index.html
deleted file mode 100644
index 5d5190f8..00000000
--- a/packages/oneallsociallogin/modules/mod_oneallsociallogin/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/packages/oneallsociallogin/modules/mod_oneallsociallogin/mod_oneallsociallogin.xml b/packages/oneallsociallogin/modules/mod_oneallsociallogin/mod_oneallsociallogin.xml
old mode 100755
new mode 100644
diff --git a/packages/oneallsociallogin/modules/mod_oneallsociallogin/tmpl/default.php b/packages/oneallsociallogin/modules/mod_oneallsociallogin/tmpl/default.php
index ced5bf91..9592dec4 100644
--- a/packages/oneallsociallogin/modules/mod_oneallsociallogin/tmpl/default.php
+++ b/packages/oneallsociallogin/modules/mod_oneallsociallogin/tmpl/default.php
@@ -24,36 +24,39 @@
*/
defined ('_JEXEC') or die ('Direct Access to this location is not allowed.');
+$_GET["source"] = isset($_GET["source"]) ? $_GET["source"] : "";
+
+if($_GET["source"] != "blankframe") {
// User is logged in
if ($user_status == 'logout')
{
// Display a Logout button?
if (isset ($widget_settings ['show_logout_button']) and $widget_settings ['show_logout_button'] == '1')
{
- ?>
-
-
+ ?>
+
0)
{
- ?>
-
-
+ ?>
+
+
-
-
-
-
+ ?>
+
+
+
+
-
- [Social Login] Please select at least one Social Network (Admin: Components\OneAll Social Login)
-
+ ?>
+
+ [Social Login] Please select at least one Social Network (Admin: Components\OneAll Social Login)
+
-
- [Social Login] Please complete your API Settings (Admin: Components\OneAll Social Login)
-
+ ?>
+
+ [Social Login] Please complete your API Settings (Admin: Components\OneAll Social Login)
+
quote ($username);
- $db->setQuery ($sql);
- $user_id = $db->loadResult ();
-
- // Done
- return (!empty ($user_id) and is_numeric ($user_id));
- }
-
- /**
- * Check if the given email exists
- */
- public static function useremailExists ($email)
- {
- // Database handler
- $db = JFactory::getDBO ();
-
- // Get user for email
- $sql = "SELECT id FROM #__users WHERE email = " . $db->quote ($email);
- $db->setQuery ($sql);
- $user_id = $db->loadResult ();
-
- // Done
- return (!empty ($user_id) and is_numeric ($user_id));
- }
-
- /**
- * Create random email
- */
- public static function getRandomUseremail ()
- {
- // Create unique email
- do
- {
- $email = md5 (uniqid (rand (10000, 99000))) . "@example.com";
- }
- while ( self::useremailExists ($email) );
-
- // Done
- return $email;
- }
-
- /**
- * Link token to userid
- */
- public static function setUserIdForToken ($token, $user_id)
- {
- // Database handler
- $db = JFactory::getDBO ();
-
- // Remove
- $sql = "DELETE FROM #__oasl_user_mapping WHERE token = " . $db->quote ($token);
- $db->setQuery ($sql);
- if ($db->query ())
- {
- // Add
- $sql = "INSERT INTO #__oasl_user_mapping SET token = " . $db->quote ($token) . ", user_id = " . $db->Quote ($user_id);
- $db->setQuery ($sql);
- if ($db->query ())
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Check if we have a userid for the given token
- */
- public static function getUserIdForToken ($token)
- {
- // Database handler
- $db = JFactory::getDBO ();
-
- // Read user
- $sql = "SELECT u.ID FROM #__oasl_user_mapping AS um INNER JOIN #__users AS u ON (um.user_id=u.ID) WHERE um.token = " . $db->quote ($token);
- $db->setQuery ($sql);
- $user_id = $db->loadResult ();
- if ($user_id)
- {
- return $user_id;
- }
- return false;
- }
-
- /**
- * Get the userid for a given email
- */
- public static function getUserIdForEmail ($email)
- {
- // Database handler
- $db = JFactory::getDBO ();
-
- // Read user
- $sql = "SELECT id FROM #__users WHERE email = " . $db->quote ($email);
- $db->setQuery ($sql);
- $user_id = $db->loadResult ();
- if ($user_id)
- {
- return $user_id;
- }
- return false;
- }
-
- /**
- * Make an API Request to obtain the data for a given connection_token
- */
- public static function makeTokenLookup ($token)
- {
- // Read settings
- $settings = self::getSettings ();
-
- // API Settings
- $api_subdomain = (!empty ($settings ['api_subdomain']) ? trim ($settings ['api_subdomain']) : '');
- $api_key = (!empty ($settings ['api_key']) ? $settings ['api_key'] : '');
- $api_secret = (!empty ($settings ['api_secret']) ? $settings ['api_secret'] : '');
-
- // API Connection
- $api_connection_handler = ((!empty ($settings ['api_connection_handler']) and $settings ['api_connection_handler'] == 'fsockopen') ? 'fsockopen' : 'curl');
- $api_connection_port = ((!empty ($settings ['api_connection_port']) and $settings ['api_connection_port'] == 80) ? 80 : 443);
- $api_connection_secure = ($api_connection_port == 443);
-
- $api_resource = ($api_connection_secure ? 'https' : 'http') . '://' . $api_subdomain . '.api.oneall.com/connections/' . $token . '.json';
-
- // Send request to the API
- $result = self::makeHttpRequest ($api_connection_handler, $api_resource, array(
- 'api_key' => $api_key,
- 'api_secret' => $api_secret
- ));
-
- // Parse result
- if (is_object ($result) and property_exists ($result, 'http_data') and property_exists ($result, 'http_code') and $result->http_code == 200)
- {
- // Result
- $json = $result->http_data;
-
- // Decode
- $json_decoded = @json_decode ($json);
-
- // Check format
- if (is_object ($json_decoded) and !empty ($json_decoded->response->request->status->code) and $json_decoded->response->request->status->code == 200)
- {
- $social_data = $json_decoded;
- }
- }
-
- return ((isset ($social_data) and is_object ($social_data)) ? $social_data : null);
- }
-
- /**
- * Send a HTTP request by using the given handler
- */
- public static function makeHttpRequest ($handler, $url, $options = array (), $timeout = 15)
- {
- // FSOCKOPEN
- if ($handler == 'fsockopen')
- {
- return self::makeFsockopenRequest ($url, $options, $timeout);
- }
- // CURL
- else
- {
- return self::makeCurlRequest ($url, $options, $timeout);
- }
- }
-
- /**
- * Send a HTTP request by using CURL
- */
- public static function makeCurlRequest ($url, $options = array (), $timeout = 15)
- {
- // Store the result
- $result = new stdClass ();
-
- // Send request
- $curl = curl_init ();
- curl_setopt ($curl, CURLOPT_URL, $url);
- curl_setopt ($curl, CURLOPT_HEADER, 0);
- curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout);
- curl_setopt ($curl, CURLOPT_VERBOSE, 0);
- curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt ($curl, CURLOPT_USERAGENT, OA_USERAGENT);
-
- // BASIC AUTH?
- if (isset ($options ['api_key']) and isset ($options ['api_secret']))
- {
- curl_setopt ($curl, CURLOPT_USERPWD, $options ['api_key'] . ":" . $options ['api_secret']);
- }
-
- // Make request
- if (($http_data = curl_exec ($curl)) !== false)
- {
- $result->http_code = curl_getinfo ($curl, CURLINFO_HTTP_CODE);
- $result->http_data = $http_data;
- $result->http_error = null;
- }
- else
- {
- $result->http_code = -1;
- $result->http_data = null;
- $result->http_error = curl_error ($curl);
- }
-
- // Done
- return $result;
- }
-
- /**
- * Send a HTTP request by using FSOCKOPEN
- */
- public static function makeFsockopenRequest ($url, $options = array (), $timeout = 15)
- {
- // Store the result
- $result = new stdClass ();
-
- // Make that this is a valid URL
- if (($uri = parse_url ($url)) == false)
- {
- $result->http_code = -1;
- $result->http_data = null;
- $result->http_error = 'invalid_uri';
- return $result;
- }
-
- // Make sure we can handle the schema
- switch ($uri ['scheme'])
- {
- case 'http' :
- $port = (isset ($uri ['port']) ? $uri ['port'] : 80);
- $host = ($uri ['host'] . ($port != 80 ? ':' . $port : ''));
- $fp = @fsockopen ($uri ['host'], $port, $errno, $errstr, $timeout);
- break;
-
- case 'https' :
- $port = (isset ($uri ['port']) ? $uri ['port'] : 443);
- $host = ($uri ['host'] . ($port != 443 ? ':' . $port : ''));
- $fp = @fsockopen ('ssl://' . $uri ['host'], $port, $errno, $errstr, $timeout);
- break;
-
- default :
- $result->http_code = -1;
- $result->http_data = null;
- $result->http_error = 'invalid_schema';
- return $result;
- break;
- }
-
- // Make sure the socket opened properly
- if (!$fp)
- {
- $result->http_code = -$errno;
- $result->http_data = null;
- $result->http_error = trim ($errstr);
- return $result;
- }
-
- // Construct the path to act on
- $path = (isset ($uri ['path']) ? $uri ['path'] : '/');
- if (isset ($uri ['query']))
- {
- $path .= '?' . $uri ['query'];
- }
-
- // Create HTTP request
- $defaults = array(
- 'Host' => "Host: $host",
- 'User-Agent' => 'User-Agent: ' . OA_USERAGENT
- );
-
- // BASIC AUTH?
- if (isset ($options ['api_key']) and isset ($options ['api_secret']))
- {
- $defaults ['Authorization'] = 'Authorization: Basic ' . base64_encode ($options ['api_key'] . ":" . $options ['api_secret']);
- }
-
- // Build and send request
- $request = 'GET ' . $path . " HTTP/1.0\r\n";
- $request .= implode ("\r\n", $defaults);
- $request .= "\r\n\r\n";
- fwrite ($fp, $request);
-
- // Fetch response
- $response = '';
- while ( !feof ($fp) )
- {
- $response .= fread ($fp, 1024);
- }
-
- // Close connection
- fclose ($fp);
-
- // Parse response
- list ($response_header, $response_body) = explode ("\r\n\r\n", $response, 2);
-
- // Parse header
- $response_header = preg_split ("/\r\n|\n|\r/", $response_header);
- list ($header_protocol, $header_code, $header_status_message) = explode (' ', trim (array_shift ($response_header)), 3);
-
- // Build result
- $result->http_code = $header_code;
- $result->http_data = $response_body;
-
- // Done
- return $result;
- }
-
- /**
- * Get settings
- */
- public static function getSettings ()
- {
- // Container
- $settings = array();
-
- // Get database handle
- $db = JFactory::getDBO ();
-
- // Read settings
- $sql = "SELECT * FROM #__oasl_settings";
- $db->setQuery ($sql);
- $rows = $db->LoadAssocList ();
-
- if (is_array ($rows))
- {
- foreach ($rows as $key => $data)
- {
- if ($data ['setting'] == 'providers')
- {
- $tmp = @unserialize ($data ['value']);
- if ($tmp !== false and is_array ($tmp))
- {
- $settings [$data ['setting']] = $tmp;
- }
- else
- {
- $settings [$data ['setting']] = array();
- }
- }
- else
- {
- $settings [$data ['setting']] = $data ['value'];
- }
- }
- }
-
- return $settings;
- }
+quote ($username);
+ $db->setQuery ($sql);
+ $user_id = $db->loadResult ();
+
+ // Done
+ return (!empty ($user_id) and is_numeric ($user_id));
+ }
+
+ /**
+ * Check if the given email exists
+ */
+ public static function useremailExists ($email)
+ {
+ // Database handler
+ $db = JFactory::getDBO ();
+
+ // Get user for email
+ $sql = "SELECT id FROM #__users WHERE email = " . $db->quote ($email);
+ $db->setQuery ($sql);
+ $user_id = $db->loadResult ();
+
+ // Done
+ return (!empty ($user_id) and is_numeric ($user_id));
+ }
+
+ /**
+ * Create random email
+ */
+ public static function getRandomUseremail ()
+ {
+ // Create unique email
+ do
+ {
+ $email = md5 (uniqid (rand (10000, 99000))) . "@example.com";
+ }
+ while ( self::useremailExists ($email) );
+
+ // Done
+ return $email;
+ }
+
+ /**
+ * Link token to userid
+ */
+ public static function setUserIdForToken ($token, $user_id)
+ {
+ // Database handler
+ $db = JFactory::getDBO ();
+
+ // Remove
+ $sql = "DELETE FROM #__oasl_user_mapping WHERE token = " . $db->quote ($token);
+ $db->setQuery ($sql);
+ if ($db->query ())
+ {
+ // Add
+ $sql = "INSERT INTO #__oasl_user_mapping SET token = " . $db->quote ($token) . ", user_id = " . $db->Quote ($user_id);
+ $db->setQuery ($sql);
+ if ($db->query ())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check if we have a userid for the given token
+ */
+ public static function getUserIdForToken ($token)
+ {
+ // Database handler
+ $db = JFactory::getDBO ();
+
+ // Read user
+ $sql = "SELECT u.ID FROM #__oasl_user_mapping AS um INNER JOIN #__users AS u ON (um.user_id=u.ID) WHERE um.token = " . $db->quote ($token);
+ $db->setQuery ($sql);
+ $user_id = $db->loadResult ();
+ if ($user_id)
+ {
+ return $user_id;
+ }
+ return false;
+ }
+
+ /**
+ * Get the userid for a given email
+ */
+ public static function getUserIdForEmail ($email)
+ {
+ // Database handler
+ $db = JFactory::getDBO ();
+
+ // Read user
+ $sql = "SELECT id FROM #__users WHERE email = " . $db->quote ($email);
+ $db->setQuery ($sql);
+ $user_id = $db->loadResult ();
+ if ($user_id)
+ {
+ return $user_id;
+ }
+ return false;
+ }
+
+ /**
+ * Make an API Request to obtain the data for a given connection_token
+ */
+ public static function makeTokenLookup ($token)
+ {
+ // Read settings
+ $settings = self::getSettings ();
+
+ // API Settings
+ $api_subdomain = (!empty ($settings ['api_subdomain']) ? trim ($settings ['api_subdomain']) : '');
+ $api_key = (!empty ($settings ['api_key']) ? $settings ['api_key'] : '');
+ $api_secret = (!empty ($settings ['api_secret']) ? $settings ['api_secret'] : '');
+
+ // API Connection
+ $api_connection_handler = ((!empty ($settings ['api_connection_handler']) and $settings ['api_connection_handler'] == 'fsockopen') ? 'fsockopen' : 'curl');
+ $api_connection_port = ((!empty ($settings ['api_connection_port']) and $settings ['api_connection_port'] == 80) ? 80 : 443);
+ $api_connection_secure = ($api_connection_port == 443);
+
+ $api_resource = ($api_connection_secure ? 'https' : 'http') . '://' . $api_subdomain . '.api.oneall.com/connections/' . $token . '.json';
+
+ // Send request to the API
+ $result = self::makeHttpRequest ($api_connection_handler, $api_resource, array(
+ 'api_key' => $api_key,
+ 'api_secret' => $api_secret
+ ));
+
+ // Parse result
+ if (is_object ($result) and property_exists ($result, 'http_data') and property_exists ($result, 'http_code') and $result->http_code == 200)
+ {
+ // Result
+ $json = $result->http_data;
+
+ // Decode
+ $json_decoded = @json_decode ($json);
+
+ // Check format
+ if (is_object ($json_decoded) and !empty ($json_decoded->response->request->status->code) and $json_decoded->response->request->status->code == 200)
+ {
+ $social_data = $json_decoded;
+ }
+ }
+
+ return ((isset ($social_data) and is_object ($social_data)) ? $social_data : null);
+ }
+
+ /**
+ * Send a HTTP request by using the given handler
+ */
+ public static function makeHttpRequest ($handler, $url, $options = array (), $timeout = 15)
+ {
+ // FSOCKOPEN
+ if ($handler == 'fsockopen')
+ {
+ return self::makeFsockopenRequest ($url, $options, $timeout);
+ }
+ // CURL
+ else
+ {
+ return self::makeCurlRequest ($url, $options, $timeout);
+ }
+ }
+
+ /**
+ * Send a HTTP request by using CURL
+ */
+ public static function makeCurlRequest ($url, $options = array (), $timeout = 15)
+ {
+ // Store the result
+ $result = new stdClass ();
+
+ // Send request
+ $curl = curl_init ();
+ curl_setopt ($curl, CURLOPT_URL, $url);
+ curl_setopt ($curl, CURLOPT_HEADER, 0);
+ curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout);
+ curl_setopt ($curl, CURLOPT_VERBOSE, 0);
+ curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_setopt ($curl, CURLOPT_USERAGENT, OA_USERAGENT);
+
+ // BASIC AUTH?
+ if (isset ($options ['api_key']) and isset ($options ['api_secret']))
+ {
+ curl_setopt ($curl, CURLOPT_USERPWD, $options ['api_key'] . ":" . $options ['api_secret']);
+ }
+
+ // Make request
+ if (($http_data = curl_exec ($curl)) !== false)
+ {
+ $result->http_code = curl_getinfo ($curl, CURLINFO_HTTP_CODE);
+ $result->http_data = $http_data;
+ $result->http_error = null;
+ }
+ else
+ {
+ $result->http_code = -1;
+ $result->http_data = null;
+ $result->http_error = curl_error ($curl);
+ }
+
+ // Done
+ return $result;
+ }
+
+ /**
+ * Send a HTTP request by using FSOCKOPEN
+ */
+ public static function makeFsockopenRequest ($url, $options = array (), $timeout = 15)
+ {
+ // Store the result
+ $result = new stdClass ();
+
+ // Make that this is a valid URL
+ if (($uri = parse_url ($url)) == false)
+ {
+ $result->http_code = -1;
+ $result->http_data = null;
+ $result->http_error = 'invalid_uri';
+ return $result;
+ }
+
+ // Make sure we can handle the schema
+ switch ($uri ['scheme'])
+ {
+ case 'http' :
+ $port = (isset ($uri ['port']) ? $uri ['port'] : 80);
+ $host = ($uri ['host'] . ($port != 80 ? ':' . $port : ''));
+ $fp = @fsockopen ($uri ['host'], $port, $errno, $errstr, $timeout);
+ break;
+
+ case 'https' :
+ $port = (isset ($uri ['port']) ? $uri ['port'] : 443);
+ $host = ($uri ['host'] . ($port != 443 ? ':' . $port : ''));
+ $fp = @fsockopen ('ssl://' . $uri ['host'], $port, $errno, $errstr, $timeout);
+ break;
+
+ default :
+ $result->http_code = -1;
+ $result->http_data = null;
+ $result->http_error = 'invalid_schema';
+ return $result;
+ break;
+ }
+
+ // Make sure the socket opened properly
+ if (!$fp)
+ {
+ $result->http_code = -$errno;
+ $result->http_data = null;
+ $result->http_error = trim ($errstr);
+ return $result;
+ }
+
+ // Construct the path to act on
+ $path = (isset ($uri ['path']) ? $uri ['path'] : '/');
+ if (isset ($uri ['query']))
+ {
+ $path .= '?' . $uri ['query'];
+ }
+
+ // Create HTTP request
+ $defaults = array(
+ 'Host' => "Host: $host",
+ 'User-Agent' => 'User-Agent: ' . OA_USERAGENT
+ );
+
+ // BASIC AUTH?
+ if (isset ($options ['api_key']) and isset ($options ['api_secret']))
+ {
+ $defaults ['Authorization'] = 'Authorization: Basic ' . base64_encode ($options ['api_key'] . ":" . $options ['api_secret']);
+ }
+
+ // Build and send request
+ $request = 'GET ' . $path . " HTTP/1.0\r\n";
+ $request .= implode ("\r\n", $defaults);
+ $request .= "\r\n\r\n";
+ fwrite ($fp, $request);
+
+ // Fetch response
+ $response = '';
+ while ( !feof ($fp) )
+ {
+ $response .= fread ($fp, 1024);
+ }
+
+ // Close connection
+ fclose ($fp);
+
+ // Parse response
+ list ($response_header, $response_body) = explode ("\r\n\r\n", $response, 2);
+
+ // Parse header
+ $response_header = preg_split ("/\r\n|\n|\r/", $response_header);
+ list ($header_protocol, $header_code, $header_status_message) = explode (' ', trim (array_shift ($response_header)), 3);
+
+ // Build result
+ $result->http_code = $header_code;
+ $result->http_data = $response_body;
+
+ // Done
+ return $result;
+ }
+
+ /**
+ * Get settings
+ */
+ public static function getSettings ()
+ {
+ // Container
+ $settings = array();
+
+ // Get database handle
+ $db = JFactory::getDBO ();
+
+ // Read settings
+ $sql = "SELECT * FROM #__oasl_settings";
+ $db->setQuery ($sql);
+ $rows = $db->LoadAssocList ();
+
+ if (is_array ($rows))
+ {
+ foreach ($rows as $key => $data)
+ {
+ if ($data ['setting'] == 'providers')
+ {
+ $tmp = @unserialize ($data ['value']);
+ if ($tmp !== false and is_array ($tmp))
+ {
+ $settings [$data ['setting']] = $tmp;
+ }
+ else
+ {
+ $settings [$data ['setting']] = array();
+ }
+ }
+ else
+ {
+ $settings [$data ['setting']] = $data ['value'];
+ }
+ }
+ }
+
+ return $settings;
+ }
}
diff --git a/packages/oneallsociallogin/plugins/system/oneallsociallogin/oneallsociallogin.php b/packages/oneallsociallogin/plugins/system/oneallsociallogin/oneallsociallogin.php
index c986dc0d..9bb1c79e 100644
--- a/packages/oneallsociallogin/plugins/system/oneallsociallogin/oneallsociallogin.php
+++ b/packages/oneallsociallogin/plugins/system/oneallsociallogin/oneallsociallogin.php
@@ -1,4 +1,5 @@
response->result->data->user->identity;
$user_token = $social_data->response->result->data->user->user_token;
@@ -72,93 +69,66 @@ class plgSystemOneAllSocialLogin extends JPlugin
$user_identity_provider = $identity->source->name;
// ***** Firstname *****
- if (isset($identity->name->givenName) and !empty($identity->name->givenName))
- {
+ if (isset($identity->name->givenName) and !empty($identity->name->givenName)) {
$user_first_name = $identity->name->givenName;
- }
- elseif (isset($identity->preferredUsername))
- {
+ } elseif (isset($identity->preferredUsername)) {
$user_first_name = $identity->preferredUsername;
- }
- else
- {
+ } else {
$user_first_name = 'noname';
}
// ***** Lastname *****
- if (isset($identity->name->familyName) and !empty($identity->name->familyName))
- {
+ if (isset($identity->name->familyName) and !empty($identity->name->familyName)) {
$user_last_name = $identity->name->familyName;
- }
- else
- {
+ } else {
$user_last_name = '';
}
// ***** Fullname *****
- if (!empty($identity->name->formatted))
- {
+ if (!empty($identity->name->formatted)) {
$user_full_name = $identity->name->formatted;
- }
- elseif (!empty($identity->name->displayName))
- {
+ } elseif (!empty($identity->name->displayName)) {
$user_full_name = $identity->name->displayName;
- }
- else
- {
- $user_full_name = trim($user_first_name . ' ' . $user_last_name);
+ } else {
+ if ($_SERVER['HTTP_HOST'] == "www.archlinexp.com")
+ $user_full_name = trim($user_first_name . ' ' . $user_last_name);
+ else
+ $user_full_name = trim($user_last_name . ' ' . $user_first_name);
}
// ***** Email *****
$user_email = '';
- if (property_exists($identity, 'emails') and is_array($identity->emails))
- {
- foreach ($identity->emails as $email)
- {
+ if (property_exists($identity, 'emails') and is_array($identity->emails)) {
+ foreach ($identity->emails as $email) {
$user_email = $email->value;
$user_email_is_verified = ($email->is_verified == '1');
}
}
// ***** Thumbnail *****
- if (property_exists($identity, 'thumbnailUrl') and !empty($identity->thumbnailUrl))
- {
+ if (property_exists($identity, 'thumbnailUrl') and !empty($identity->thumbnailUrl)) {
$user_thumbnail = trim($identity->thumbnailUrl);
- }
- else
- {
+ } else {
$user_thumbnail = '';
}
// ***** User Website *****
- if (property_exists($identity, 'profileUrl') and !empty($identity->profileUrl))
- {
+ if (property_exists($identity, 'profileUrl') and !empty($identity->profileUrl)) {
$user_website = $identity->profileUrl;
- }
- elseif (property_exists($identity, 'urls') and !empty($identity->urls[0]->value))
- {
+ } elseif (property_exists($identity, 'urls') and !empty($identity->urls[0]->value)) {
$user_website = $identity->urls[0]->value;
- }
- else
- {
+ } else {
$user_website = '';
}
// ***** Preferred Username *****
- if (!empty($identity->preferredUsername))
- {
+ if (!empty($identity->preferredUsername)) {
$user_login = $identity->preferredUsername;
- }
- elseif (!empty($identity->displayName))
- {
+ } elseif (!empty($identity->displayName)) {
$user_login = $identity->displayName;
- }
- elseif (!empty($identity->name->formatted))
- {
+ } elseif (!empty($identity->name->formatted)) {
$user_login = $identity->name->formatted;
- }
- else
- {
+ } else {
$user_login = '';
}
@@ -166,22 +136,16 @@ class plgSystemOneAllSocialLogin extends JPlugin
$user_id = plgSystemOneAllSocialLoginHelper::getUserIdForToken($user_token);
// Not linked, try to link to existing account
- if (!is_numeric($user_id))
- {
+ if (!is_numeric($user_id)) {
// Linking enabled?
- if (!empty($settings['link_verified_accounts']))
- {
+ if (!empty($settings['link_verified_accounts'])) {
// Only of email is verified
- if (!empty($user_email) and $user_email_is_verified === true)
- {
+ if (!empty($user_email) and $user_email_is_verified === true) {
// Read existing user
- if (($user_id_tmp = plgSystemOneAllSocialLoginHelper::getUserIdForEmail($user_email)) !== false)
- {
+ if (($user_id_tmp = plgSystemOneAllSocialLoginHelper::getUserIdForEmail($user_email)) !== false) {
// Link user to token
- if (is_numeric($user_id_tmp))
- {
- if (plgSystemOneAllSocialLoginHelper::setUserIdForToken($user_token, $user_id_tmp))
- {
+ if (is_numeric($user_id_tmp)) {
+ if (plgSystemOneAllSocialLoginHelper::setUserIdForToken($user_token, $user_id_tmp)) {
$user_id = $user_id_tmp;
}
}
@@ -191,8 +155,7 @@ class plgSystemOneAllSocialLogin extends JPlugin
}
// ***** New User *****
- if (!is_numeric($user_id))
- {
+ if (!is_numeric($user_id)) {
// Import libraries
jimport('joomla.user.helper');
jimport('joomla.application.component.helper');
@@ -204,8 +167,7 @@ class plgSystemOneAllSocialLogin extends JPlugin
$usersParams = JComponentHelper::getParams('com_users');
// Make sure user registration is allowed.
- if ($usersParams->get('allowUserRegistration') == '0' && !$usersParams->get('override_allow_user_registration', 0))
- {
+ if ($usersParams->get('allowUserRegistration') == '0' && !$usersParams->get('override_allow_user_registration', 0)) {
JFactory::getApplication()->enqueueMessage(JText::_('Sorry, but your account could not be created as the registration of new users has been disabled by the administrator of this website.'), 'error');
return false;
@@ -217,18 +179,15 @@ class plgSystemOneAllSocialLogin extends JPlugin
$user_login = trim(trim($user_login), '.');
// Username must be at least 2 characters long
- if (strlen($user_login) < 2)
- {
+ if (strlen($user_login) < 2) {
$user_login = $user_identity_provider . 'User';
}
// Username must be unique
- if (plgSystemOneAllSocialLoginHelper::usernameExists($user_login))
- {
+ if (plgSystemOneAllSocialLoginHelper::usernameExists($user_login)) {
$i = 1;
$user_login_tmp = $user_login;
- do
- {
+ do {
$user_login_tmp = $user_login . ($i++);
} while (plgSystemOneAllSocialLoginHelper::usernameExists($user_login_tmp));
@@ -237,8 +196,7 @@ class plgSystemOneAllSocialLogin extends JPlugin
}
// Email must be unique
- if (empty($user_email) or plgSystemOneAllSocialLoginHelper::useremailExists($user_email))
- {
+ if (empty($user_email) or plgSystemOneAllSocialLoginHelper::useremailExists($user_email)) {
$user_email = plgSystemOneAllSocialLoginHelper::getRandomUseremail();
}
@@ -253,8 +211,7 @@ class plgSystemOneAllSocialLogin extends JPlugin
// Get the default usertype
$defaultUserGroups = $usersParams->get('new_usertype', 2);
- if (!$defaultUserGroups)
- {
+ if (!$defaultUserGroups) {
$defaultUserGroups = 'Registered';
}
@@ -274,16 +231,14 @@ class plgSystemOneAllSocialLogin extends JPlugin
$data['block'] = 0;
// Bind the data to the JUser Object
- if (!$user->bind($data))
- {
+ if (!$user->bind($data)) {
JError::raiseWarning('', JText::_('Could not bind data to user') . ': ' . JText::_($user->getError()));
return false;
}
// Save the user
- if (!$user->save())
- {
+ if (!$user->save()) {
JError::raiseWarning('', JText::_('Could not create user') . ': ' . JText::_($user->getError()));
return false;
@@ -292,22 +247,81 @@ class plgSystemOneAllSocialLogin extends JPlugin
// Store userid
$user_id = $user->get('id');
+ if ($_SERVER['HTTP_HOST'] == "www.archlinexp.com") {
+ $old_db = "clusers_eng";
+ $info = "Web registration";
+ $topic = 219;
+ } else {
+ $old_db = "clusers";
+ $info = "Weben regisztrált";
+ $topic = 362;
+ }
+
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true);
+ $query->select('nUserID')->from('cl_hlusers.u_emails')->where('email = "' . $data['email'] . '"');
+ $db->setQuery($query);
+ $existedEmail = $db->loadObject();
+
+ if (empty($existedEmail)) {
+ $query = $db->getQuery(true);
+ $query->select('ctrID')->from('cl_hlusers.countries')->where('ctrNameEng = "' . $identity->loginLocation->country->long . '"');
+ $db->setQuery($query);
+ $result = $db->loadObject();
+
+ $query = $db->getQuery(false);
+ $query = "INSERT INTO cl_hlusers.users(strName, strEmail, dateInsert, old_db, nCtrID)
+ VALUES('" . $data['name'] . "', '" . $data['email'] . "', '" . time() . "', '" . $old_db . "'," . $result->ctrID . ")";
+ $db->setQuery($query);
+ $db->execute();
+ $nUserID = $db->insertid();
+
+ $query = "INSERT INTO cl_hlusers.u_emails(email, nUserID)
+ VALUES('" . $data['email'] . "', '" . $nUserID . "')";
+ $db->setQuery($query);
+ $db->execute();
+
+ $query = $db->getQuery(true);
+ $query->update("cl_hlusers.u_emails");
+ $query->set('u_emails.default = 1');
+ $query->where('nUserID = ' . $nUserID);
+ $db->setQuery($query);
+ $db->execute();
+
+ $query = $db->getQuery(false);
+ $query = "INSERT INTO cl_hlusers.u_history(nUserID, nTopicID, dateEvent, strPlace, strInfo, nManagerID, insertDate)
+ VALUES(" . $nUserID . ", " . $topic . ", '" . date("Y-m-d", time()) . "', 'web', '" . $info . "', 36, '" . date("Y-m-d H:i:s", time()) . "')";
+ $db->setQuery($query);
+ $db->execute();
+ } else {
+ $nUserID = $existedEmail->nUserID;
+ }
+
+ $query = $db->getQuery(true);
+ $query->update("jml_users");
+ $query->set('nUserID = ' . $nUserID);
+ $query->where('id = ' . $user_id);
+ $db->setQuery($query);
+ $db->execute();
+
// Link to token
plgSystemOneAllSocialLoginHelper::setUserIdForToken($user_token, $user_id);
+
+ $query = $db->getQuery(false);
+ $query = "UPDATE www_archline_hu.jml_users SET username = '" . $data['email'] . "' WHERE id = " . $user_id;
+ $db->setQuery($query);
+ $db->execute();
}
// Returning user
- else
- {
+ else {
$new_user = false;
}
// Sucess
- if (isset($user_id) and is_numeric($user_id) and !empty($user_id))
- {
+ if (isset($user_id) and is_numeric($user_id) and !empty($user_id)) {
// User exists
$user = JFactory::getUser($user_id);
- if (is_object($user))
- {
+ if (is_object($user)) {
// Get the application object.
$app = JFactory::getApplication();
$db = JFactory::getDBO();
@@ -316,8 +330,7 @@ class plgSystemOneAllSocialLogin extends JPlugin
$result = $db->loadObject();
// Login user
- if ($result and !empty($result->username))
- {
+ if ($result and !empty($result->username)) {
JPluginHelper::importPlugin('user');
// Setup options
@@ -340,19 +353,15 @@ class plgSystemOneAllSocialLogin extends JPlugin
*/
// Setup return url for new users
- if ($new_user === true)
- {
- if (isset($settings['redirect_register_url']) and strlen(trim($settings['redirect_register_url'])) > 0)
- {
+ if ($new_user === true) {
+ if (isset($settings['redirect_register_url']) and strlen(trim($settings['redirect_register_url'])) > 0) {
$session = JFactory::getSession();
$session->set('redirect_url', trim($settings['redirect_register_url']), 'plg_oneallsociallogin');
}
}
// Setup return url for returning users
- elseif ($new_user === false)
- {
- if (isset($settings['redirect_login_url']) and strlen(trim($settings['redirect_login_url'])) > 0)
- {
+ elseif ($new_user === false) {
+ if (isset($settings['redirect_login_url']) and strlen(trim($settings['redirect_login_url'])) > 0) {
$session = JFactory::getSession();
$session->set('redirect_url', trim($settings['redirect_login_url']), 'plg_oneallsociallogin');
}
@@ -368,8 +377,7 @@ class plgSystemOneAllSocialLogin extends JPlugin
$loginResult = $app->triggerEvent('onUserLogin', array((array) $response, $options));
$user = \JFactory::getUser();
- if (in_array(false, $loginResult, true) == false)
- {
+ if (in_array(false, $loginResult, true) == false) {
$options['user'] = $user;
$options['responseType'] = $response->type;
@@ -378,6 +386,7 @@ class plgSystemOneAllSocialLogin extends JPlugin
}
//Done
+ header("Refresh:0");
return true;
}
@@ -392,8 +401,7 @@ class plgSystemOneAllSocialLogin extends JPlugin
public function onAfterInitialise()
{
// Check if we have a connection token
- if (isset($_POST) and !empty($_POST['oa_action']) and $_POST['oa_action'] == 'social_login' and !empty($_POST['connection_token']))
- {
+ if (isset($_POST) and !empty($_POST['oa_action']) and $_POST['oa_action'] == 'social_login' and !empty($_POST['connection_token'])) {
$this->doAuth($_POST['connection_token']);
}
}
@@ -408,8 +416,7 @@ class plgSystemOneAllSocialLogin extends JPlugin
// Check for uri
$redirect_url = $session->get('redirect_url', null, 'plg_oneallsociallogin');
- if (!empty($redirect_url))
- {
+ if (!empty($redirect_url)) {
// Clear uri
$session->clear('redirect_url', 'plg_oneallsociallogin');
diff --git a/packages/oneallsociallogin/plugins/system/oneallsociallogin/oneallsociallogin.xml b/packages/oneallsociallogin/plugins/system/oneallsociallogin/oneallsociallogin.xml
old mode 100755
new mode 100644