diff --git a/profiles/cmavatar.php b/profiles/cmavatar.php
deleted file mode 100755
index 7fc2634..0000000
--- a/profiles/cmavatar.php
+++ /dev/null
@@ -1,501 +0,0 @@
-isSite())
- {
- return true;
- }
-
- // Check we are manipulating a valid form.
- if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile')))
- {
- return true;
- }
-
- if (is_object($data))
- {
- $userId = isset($data->id) ? $data->id : 0;
-
- if (!isset($data->cmavatar['cmavatarcurrent']) and $userId > 0)
- {
- // Load the avatar's file name from the database.
- $currentAvatar = $this->getAvatar($userId);
-
- if (!empty($currentAvatar))
- {
- $folder = $this->params->get('folder', '');
- $avatarPath = $folder . '/' . $currentAvatar . '.' . $this->extension;
-
- $layout = JFactory::getApplication()->input->get('layout', 'default');
-
- if ($layout != 'default')
- {
- $data->cmavatar['cmavatar'] = $avatarPath;
- }
- else
- {
- $html = '
';
- $html .= '
';
- $html .= '
';
- $data->cmavatar['cmavatar'] = $html;
- }
- }
- else
- {
- $data->cmavatar['cmavatar'] = '';
- }
- }
- }
-
- return true;
- }
-
- /**
- * Add additional field to the user editing form
- *
- * @param JForm $form The form to be altered.
- * @param array $data The associated data for the form.
- *
- * @return boolean
- *
- * @since 1.0.0
- */
- public function onContentPrepareForm($form, $data)
- {
- if (!($form instanceof JForm))
- {
- throw new RuntimeException(JText::_('JERROR_NOT_A_FORM'));
-
- return false;
- }
-
- // Only run in front-end.
- if (!JFactory::getApplication()->isSite())
- {
- return true;
- }
-
- // Check we are manipulating a valid form.
- $name = $form->getName();
-
- if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration')))
- {
- return true;
- }
-
- $folder = $this->params->get('folder', '');
- $avatarFolder = JPATH_ROOT . '/' . $folder;
-
- // If the avatar folder doesn't exist, we don't display the fields.
- if (!JFolder::exists($avatarFolder))
- {
- return false;
- }
-
- $layout = JFactory::getApplication()->input->get('layout', 'default');
-
- if ($layout != 'default' || ($layout == 'default' && $this->params->get('display_avatar_in_profile', 0) == 1))
- {
- JForm::addFormPath(__DIR__ . '/profiles');
- $form->loadFile('profile', false);
- }
-
- return true;
- }
-
- /**
- * Save user profile data.
- *
- * @param array $data Entered user data
- * @param boolean $isNew True if this is a new user
- * @param boolean $result True if saving the user worked
- * @param string $error Error message
- *
- * @return boolean
- */
- public function onUserAfterSave($data, $isNew, $result, $error)
- {
- // Only run in front-end.
- if (!JFactory::getApplication()->isSite())
- {
- return true;
- }
-
- $userId = JArrayHelper::getValue($data, 'id', 0, 'int');
- $folder = $this->params->get('folder', '');
- $avatarFolder = JPATH_ROOT . '/' . $folder;
-
- // If the avatar folder doesn't exist, we don't do anything.
- if (!JFolder::exists($avatarFolder))
- {
- return false;
- }
-
- $jinput = JFactory::getApplication()->input;
- $delete = $jinput->get('delete-avatar', '', 'word');
-
- if ($delete == 'yes')
- {
- $this->deleteAvatar($userId);
-
- return true;
- }
-
- if ($result && $userId > 0)
- {
- $files = $jinput->files->get('jform', array(), 'array');
-
- if (!isset($files['cmavatar']['cmavatar']))
- {
- return false;
- }
-
- $file = $files['cmavatar']['cmavatar'];
-
- if (empty($file['name']))
- {
- throw new RuntimeException(JText::_('PLG_USER_CMAVATAR_ERROR_NO_INPUT'));
-
- return false;
- }
-
- $fileTypes = explode('.', $file['name']);
-
- if (count($fileTypes) < 2)
- {
- // There seems to be no extension.
- throw new RuntimeException(JText::_('PLG_USER_CMAVATAR_ERROR_FILE_TYPE'));
-
- return false;
- }
-
- array_shift($fileTypes);
-
- // Check if the file has an executable extension.
- $executable = array(
- 'php', 'js', 'exe', 'phtml', 'java', 'perl', 'py', 'asp','dll', 'go', 'ade', 'adp', 'bat', 'chm', 'cmd', 'com', 'cpl', 'hta', 'ins', 'isp',
- 'jse', 'lib', 'mde', 'msc', 'msp', 'mst', 'pif', 'scr', 'sct', 'shb', 'sys', 'vb', 'vbe', 'vbs', 'vxd', 'wsc', 'wsf', 'wsh'
- );
-
- $check = array_intersect($fileTypes, $executable);
-
- if (!empty($check))
- {
- throw new RuntimeException(JText::_('PLG_USER_CMAVATAR_ERROR_FILE_TYPE'));
-
- return false;
- }
-
- $fileType = array_pop($fileTypes);
- $allowable = array_map('trim', explode(',', $this->params->get('allowed_extensions')));
-
- if ($fileType == '' || $fileType == false || (!in_array($fileType, $allowable)))
- {
- throw new RuntimeException(JText::_('PLG_USER_CMAVATAR_ERROR_FILE_TYPE'));
-
- return false;
- }
-
- $uploadMaxSize = $this->params->get('max_size', 0) * 1024 * 1024;
- $uploadMaxFileSize = $this->toBytes(ini_get('upload_max_filesize'));
-
- if (($file['error'] == 1)
- || ($uploadMaxSize > 0 && $file['size'] > $uploadMaxSize)
- || ($uploadMaxFileSize > 0 && $file['size'] > $uploadMaxFileSize))
- {
- throw new RuntimeException(JText::_('PLG_USER_CMAVATAR_ERROR_FILE_TOO_LARGE'));
-
- return false;
- }
-
- // Make the file name unique.
- $md5String = $userId . $file['name'] . JFactory::getDate();
- $avatarFileName = JFile::makeSafe(md5($md5String));
-
- if (empty($avatarFileName))
- {
- // No file name after the name was cleaned by JFile::makeSafe.
- throw new RuntimeException(JText::_('PLG_USER_CMAVATAR_ERROR_NO_FILENAME'));
-
- return false;
- }
-
- $avatarPath = JPath::clean($avatarFolder . '/' . $avatarFileName . '.' . $this->extension);
-
- if (JFile::exists($avatarPath))
- {
- // A file with this name already exists. It is almost impossible.
- throw new RuntimeException(JText::_('PLG_USER_CMAVATAR_ERROR_FILE_EXISTS'));
-
- return false;
- }
-
- // Start resizing the file.
- $avatar = new JImage($file['tmp_name']);
- $originalWidth = $avatar->getWidth();
- $originalHeight = $avatar->getHeight();
- $ratio = $originalWidth / $originalHeight;
-
- $newWidth = (int) $this->params->get('width', 100);
-
- // Invalid value in the plugin configuration. Set avatar width to 100.
- if ($newWidth <= 0)
- {
- $newWidth = 100;
- }
-
- $newHeight = $newWidth / $ratio;
-
- $resizedAvatar = $avatar->resize($newWidth, $newHeight, true);
- $resizedAvatar->toFile($avatarPath);
-
- // Delete current avatar if exists.
- $this->deleteAvatar($userId);
-
- $db = JFactory::getDbo();
- $query = $db->getQuery(true);
-
- // Save avatar's file name to database.
- if (!empty($currentAvatar))
- {
- $query->update($db->qn('#__user_profiles'))
- ->set($db->qn('profile_value') . ' = ' . $db->q($avatarFileName))
- ->where($db->qn('user_id') . ' = ' . $db->q($userId))
- ->where($db->qn('profile_key') . ' = ' . $db->quote($this->profileKey));
- }
- else
- {
- $query->insert($db->qn('#__user_profiles'))
- ->columns(
- $db->qn(
- array(
- 'user_id',
- 'profile_key',
- 'profile_value',
- 'ordering'
- )
- )
- )
- ->values(
- $db->q($userId) . ', ' .
- $db->q($this->profileKey) . ', ' .
- $db->q($avatarFileName) . ', ' .
- $db->q('1')
- );
- }
-
- $db->setQuery($query)->execute();
-
- // Check for a database error.
- if ($error = $db->getErrorMsg())
- {
- throw new RuntimeException($error);
-
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Remove avatar for the given user ID.
- *
- * Method is called after user data is deleted from the database.
- *
- * @param array $user Holds the user data
- * @param boolean $success True if user was succesfully stored in the database
- * @param string $msg Message
- *
- * @return boolean
- */
- public function onUserAfterDelete($user, $success, $msg)
- {
- if (!$success)
- {
- return false;
- }
-
- $userId = JArrayHelper::getValue($user, 'id', 0, 'int');
-
- if ($userId)
- {
- $this->deleteAvatar($userId);
- }
-
- return true;
- }
-
- /**
- * Get current avatar.
- *
- * @param integer $userId The ID of the user.
- *
- * @return mixed
- *
- * @since 1.0.0
- */
- protected function getAvatar($userId)
- {
- $db = JFactory::getDbo();
- $query = $db->getQuery(true)
- ->select($db->qn('profile_value'))
- ->from($db->qn('#__user_profiles'))
- ->where($db->qn('user_id') . ' = ' . $db->q((int) $userId))
- ->where($db->qn('profile_key') . ' = ' . $db->quote($this->profileKey));
- $currentAvatar = $db->setQuery($query)->loadResult();
-
- // Check for a database error.
- if ($error = $db->getErrorMsg())
- {
- throw new RuntimeException($error);
-
- return false;
- }
-
- return $currentAvatar;
- }
-
- /**
- * Delete avatar.
- *
- * @param integer $userId The ID of the user.
- *
- * @return boolean
- *
- * @since 1.0.0
- */
- protected function deleteAvatar($userId)
- {
- $folder = $this->params->get('folder', '');
- $avatarFolder = JPATH_ROOT . '/' . $folder;
- $currentAvatar = $this->getAvatar($userId);
-
- if (!empty($currentAvatar))
- {
- $currentAvatarPath = JPath::clean($avatarFolder . '/' . $currentAvatar . '.' . $this->extension);
-
- if (JFile::exists($currentAvatarPath))
- {
- JFile::delete($currentAvatarPath);
- }
-
- $db = JFactory::getDbo();
- $query = $db->getQuery(true)
- ->delete($db->qn('#__user_profiles'))
- ->where($db->qn('user_id') . ' = ' . $db->q((int) $userId))
- ->where($db->qn('profile_key') . ' = ' . $db->quote($this->profileKey));
- $db->setQuery($query)->execute();
-
- // Check for a database error.
- if ($error = $db->getErrorMsg())
- {
- throw new RuntimeException($error);
-
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Small helper function that properly converts any
- * configuration options to their byte representation.
- * From libraries/cms/helper/media.php
- *
- * @param string|integer $val The value to be converted to bytes.
- *
- * @return integer The calculated bytes value from the input.
- *
- * @since 1.0.0
- */
- protected function toBytes($val)
- {
- switch ($val[strlen($val) - 1])
- {
- case 'M':
- case 'm':
- return (int) $val * 1048576;
- case 'K':
- case 'k':
- return (int) $val * 1024;
- case 'G':
- case 'g':
- return (int) $val * 1073741824;
- default:
- return $val;
- }
- }
-}
diff --git a/profiles/cmavatar.xml b/profiles/cmavatar.xml
deleted file mode 100755
index 8df1209..0000000
--- a/profiles/cmavatar.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
- PLG_USER_CMAVATAR
- 1.0.1
- (C) 2015 CMExtension team
- CMExtension team
- cmext.vn@gmail.com
- www.cmext.vn
- GNU General Public License version 2 or later
- May 3, 2015
- PLG_USER_CMAVATAR_XML_DESCRIPTION
-
-
- http://www.cmext.vn/joomla/extensions/update/plg_user_cmavatar.xml
-
-
-
- cmavatar.php
- helper.php
- fields
- language
- layouts
- profiles
-
-
-
-
-
-
-
-
diff --git a/profiles/fields/cmavatar.php b/profiles/fields/cmavatar.php
deleted file mode 100755
index f8583e7..0000000
--- a/profiles/fields/cmavatar.php
+++ /dev/null
@@ -1,69 +0,0 @@
-value))
- {
- $currentAvatar = JText::_('PLG_USER_CMAVATAR_NO_AVATAR');
- }
- else
- {
- $currentAvatar = '';
- }
-
- $uploadField = parent::getInput();
-
- if (empty($this->value))
- {
- $deleteField = '';
- }
- else
- {
- $deleteField = '';
- }
-
- $data = array(
- 'current_avatar' => $currentAvatar,
- 'upload_field' => $uploadField,
- 'delete_field' => $deleteField,
- );
-
- $layout = new JLayoutFile('default', $basePath = JPATH_PLUGINS . '/user/cmavatar/layouts');
- $html = $layout->render($data);
-
- return $html;
- }
-}
diff --git a/profiles/helper.php b/profiles/helper.php
deleted file mode 100755
index 90b62ef..0000000
--- a/profiles/helper.php
+++ /dev/null
@@ -1,59 +0,0 @@
-getQuery(true)
- ->select($db->qn('profile_value'))
- ->from($db->qn('#__user_profiles'))
- ->where($db->qn('user_id') . ' = ' . $db->q((int) $userId))
- ->where($db->qn('profile_key') . ' = ' . $db->quote($profileKey));
- $avatar = $db->setQuery($query)->loadResult();
-
- // Check for a database error.
- if ($error = $db->getErrorMsg())
- {
- throw new RuntimeException($error);
-
- return false;
- }
-
- if (!empty($avatar))
- {
- $extension = 'jpg';
- $plugin = JPluginHelper::getPlugin('user', 'cmavatar');
- $params = new JRegistry($plugin->params);
- $folder = $params->get('folder', '');
-
- $avatar = JPath::clean($folder . '/' . $avatar . '.' . $extension);
- }
-
- return $avatar;
- }
-}
diff --git a/profiles/language/en-GB/en-GB.plg_user_cmavatar.ini b/profiles/language/en-GB/en-GB.plg_user_cmavatar.ini
deleted file mode 100755
index 4a5c0e4..0000000
--- a/profiles/language/en-GB/en-GB.plg_user_cmavatar.ini
+++ /dev/null
@@ -1,21 +0,0 @@
-PLG_USER_CMAVATAR_FIELD_FOLDER_LABEL = "Avatar folder"
-PLG_USER_CMAVATAR_FIELD_FOLDER_DESC = "The path to the folder where user avatars are stored. This path is relative to the root of your webspace. Example: images/avatars. Note: Do not start the path with a slash!"
-PLG_USER_CMAVATAR_FIELD_ALLOWED_EXTENSIONS_LABEL = "Allowed image extensions"
-PLG_USER_CMAVATAR_FIELD_ALLOWED_EXTENSIONS_DESC = "Extensions (file types) which are allowed to upload, the extensions are separated by comma, for example: bmp,gif,jpg,png".
-PLG_USER_CMAVATAR_FIELD_WIDTH_LABEL = "Avatar's width (in pixel)"
-PLG_USER_CMAVATAR_FIELD_WIDTH_DESC = "The avatar file will be resized to this width. The height will be calculated and resized to keep the image's ratio."
-PLG_USER_CMAVATAR_FIELD_MAX_SIZE_LABEL = "Maximum size (in MB)"
-PLG_USER_CMAVATAR_FIELD_MAX_SIZE_DESC = "The maximum size of image which is allowed to upload. Note: your server also has its own maximum limit."
-PLG_USER_CMAVATAR_FIELD_DISPLAY_AVATAR_IN_PROFILE_LABEL = "Display avatar in profile"
-PLG_USER_CMAVATAR_FIELD_DISPLAY_AVATAR_IN_PROFILE_DESC = "Display the current avatar in profile view. By default this option is disabled because it is not possible to display an image in profile view. Please see the documentation for a solution."
-
-PLG_USER_CMAVATAR_SLIDER_LABEL = "Avatar"
-PLG_USER_CMAVATAR_FIELD_AVATAR_LABEL = "Avatar"
-PLG_USER_CMAVATAR_FIELD_AVATAR_DESC = "Your avatar."
-PLG_USER_CMAVATAR_DELETE_AVATAR = "Delete current avatar"
-PLG_USER_CMAVATAR_NO_AVATAR = "No avatar used."
-PLG_USER_CMAVATAR_ERROR_FILE_TOO_LARGE = "The avatar file is too large to upload."
-PLG_USER_CMAVATAR_ERROR_FILE_EXISTS = "There was an internal error while uploading your avatar, please try again."
-PLG_USER_CMAVATAR_ERROR_NO_FILENAME = "There was an internal error while uploading your avatar, please try again."
-PLG_USER_CMAVATAR_ERROR_NO_INPUT = "Unable to upload file."
-PLG_USER_CMAVATAR_ERROR_FILE_TYPE = "This file type is not supported."
\ No newline at end of file
diff --git a/profiles/language/en-GB/en-GB.plg_user_cmavatar.sys.ini b/profiles/language/en-GB/en-GB.plg_user_cmavatar.sys.ini
deleted file mode 100755
index 6b3ac77..0000000
--- a/profiles/language/en-GB/en-GB.plg_user_cmavatar.sys.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-PLG_USER_CMAVATAR = "User - CM Avatar"
-PLG_USER_CMAVATAR_XML_DESCRIPTION = "User profile plugin for supporting avatar field in Joomla! user profile."
diff --git a/profiles/layouts/default.php b/profiles/layouts/default.php
deleted file mode 100755
index d39f712..0000000
--- a/profiles/layouts/default.php
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file