'.JText::_('COM_MEMBERSMANAGER_ALL_THE_USERS_FOUND_IN_JOOMLA_WERE_SUCCESSFULLY_IMPORTED_INTO_RELATED_MEMBER_TYPE_RELATIONSHIPS').'
'; + $this->setRedirect($redirect_url, $message); + return true; + } + } + else + { + JFactory::getApplication()->enqueueMessage(JText::_('COM_MEMBERSMANAGER_YOU_DO_NOT_HAVE_PERMISSION_TO_CREATE_MEMBERS'), 'error'); + } + $this->setRedirect($redirect_url); + return false; } } diff --git a/admin/controllers/types.php b/admin/controllers/types.php index 542efe2..53fe5dd 100644 --- a/admin/controllers/types.php +++ b/admin/controllers/types.php @@ -102,5 +102,35 @@ class MembersmanagerControllerTypes extends JControllerAdmin $message = JText::_('COM_MEMBERSMANAGER_IMPORT_FAILED'); $this->setRedirect(JRoute::_('index.php?option=com_membersmanager&view=types', false), $message, 'error'); return; + } + + public function updateTypes() + { + // Check for request forgeries + JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); + // check if user has the right + $user = JFactory::getUser(); + // set redirect + $redirect_url = JRoute::_('index.php?option=com_membersmanager&view=types', false); + if($user->authorise('core.create', 'com_membersmanager')) + { + // get the model + $model = $this->getModel('types'); + if ($model->updateTypes()) + { + // set success message + $message = ''.JText::_('COM_MEMBERSMANAGER_ALL_THE_MEMBERS_FOUND_WERE_SUCCESSFULLY_MAPPED_WITH_THE_TYPES_SELECTED').'
'; + $this->setRedirect($redirect_url, $message); + return true; + } + } + else + { + JFactory::getApplication()->enqueueMessage(JText::_('COM_MEMBERSMANAGER_YOU_DO_NOT_HAVE_PERMISSION_TO_UPDATE_MEMBERS_TYPES'), 'error'); + } + $this->setRedirect($redirect_url); + return false; } + } diff --git a/admin/helpers/membersmanager.php b/admin/helpers/membersmanager.php index fce0fe8..b98e1b4 100644 --- a/admin/helpers/membersmanager.php +++ b/admin/helpers/membersmanager.php @@ -27,6 +27,7 @@ abstract class MembersmanagerHelper self::loadSession(); } + /** * the params **/ @@ -161,7 +162,7 @@ abstract class MembersmanagerHelper // set edit link $selection['setMemberEditURL:id|created_by'] = $f . 'edit_url' . $b; // Get the medium encryption. - $mediumkey = MembersmanagerHelper::getCryptKey('medium'); + $mediumkey = self::getCryptKey('medium'); if ($mediumkey) { // Get the encryption object. @@ -221,7 +222,17 @@ abstract class MembersmanagerHelper **/ protected static function setProfileLink($object) { - return JRoute::_('index.php?option=com_membersmanager&view=profile&id='. $object->get('id') . ':' . $object->get('token') . '&return=' . self::$return_here); + // get the global settings + if (!self::checkObject(self::$params)) + { + self::$params = JComponentHelper::getParams('com_membersmanager'); + } + // only load link if open to public or is logged in + if (2 == self::$params->get('login_required', 1) || JFactory::getUser()->id > 0) + { + return JRoute::_('index.php?option=com_membersmanager&view=profile&id='. $object->get('id') . ':' . $object->get('token') . '&return=' . self::$return_here); + } + return ''; } /** @@ -290,9 +301,24 @@ abstract class MembersmanagerHelper $_return = urlencode(base64_encode((string) JUri::getInstance())); if ($return) { - return self::getCreateURL('message', 'message', $return . '&return=' . $_return, 'com_communicate'); + return self::getCreateURL('compose', 'compose', $return . '&return=' . $_return, 'com_communicate'); } - return self::getCreateURL('message', 'message', '&return=' . $_return, 'com_communicate'); + return self::getCreateURL('compose', 'compose', '&return=' . $_return, 'com_communicate'); + } + elseif ($key && 'message_number' === $key && is_numeric($return) && $return > 0) + { + // get the messages numbers + if (($messages = self::getMessages($return)) !== false) + { + // return result + return count( (array) $messages); + } + return 0; + } + elseif ($key && 'list_messages' === $key && is_numeric($default) && $default > 0) + { + // return result + return self::getListMessages($default, $return); } // get the global settings of com_communicate (singleton) $params = JComponentHelper::getParams('com_communicate'); @@ -306,6 +332,103 @@ abstract class MembersmanagerHelper return $default; } + /** + * return a list of messages + **/ + protected static function getListMessages(&$id, &$return) + { + // get the messages + if (($messages = self::getMessages($id)) !== false) + { + // set the return value + $_return = ''; + if (self::checkString($return)) + { + $_return = '&return=' . $return; + } + // now build the html + $bucket = array('received' => array(), 'send' => array()); + foreach($messages as $message) + { + // get time stamp + $timestamp = strtotime($message->created); + $date = self::fancyDynamicDate($timestamp); + // get key + $key = '&key=' . self::lock($message->id); // to insure that the access is only given by the sytem + // build link + $link = JRoute::_('index.php?option=com_communicate&view=message&id=' . $message->id . $_return . $key); + // set read status + $b = ''; + $_b = ''; + if ($message->hits == 0) + { + $b = '★ '; + } + // build the bucket of messages + if ($id == $message->recipient) + { + $bucket['received'][] = $b . $message->subject . '' .
implode('
', $placeholders) .
diff --git a/admin/models/member.php b/admin/models/member.php
index ef1eff6..5218f8d 100644
--- a/admin/models/member.php
+++ b/admin/models/member.php
@@ -113,7 +113,7 @@ class MembersmanagerModelMember extends JModelAdmin
else
{
$id = $item->id;
- }
+ }
// set the id and view name to session
if ($vdm = MembersmanagerHelper::get('member__'.$id))
{
@@ -1584,7 +1584,7 @@ class MembersmanagerModelMember extends JModelAdmin
// start message bucket
$message = array();
// check if user already linked
- if (isset($data['user']) && $data['user'] > 0)
+ if (isset($data['user']) && is_numeric($data['user']) && $data['user'] > 0)
{
// set user ID
$bucket['id'] = $data['user'];
@@ -1636,32 +1636,33 @@ class MembersmanagerModelMember extends JModelAdmin
{
// make sure to set the user value
$data['user'] = $done;
+ $app->enqueueMessage(JText::_('COM_MEMBERSMANAGER_MEMBER_WAS_CREATED_SUCCESSFULLY_AND_THE_LOGIN_DETAILS_WAS_EMAILED_TO_THE_MEMBER'), 'Success');
+ }
+ else
+ {
+ // set the error
+ $app->enqueueMessage($done, 'Error');
+ // we still check if user was created.... (TODO)
+ if (($didCreate = JUserHelper::getUserId($bucket['username'])))
+ {
+ $data['user'] = $didCreate;
+ }
+ }
+ // once we are sure we have an user ID
+ if (isset($data['user']) && is_numeric($data['user']) && $data['user'] > 0)
+ {
// check if we have groups
if (($typeGroups = MembersmanagerHelper::getMemberGroupsByType($data['type'])) !== false)
{
// update the user groups
- JUserHelper::setUserGroups((int) $done, (array) $typeGroups);
+ JUserHelper::setUserGroups((int) $data['user'], (array) $typeGroups);
}
else
{
// notice that the group was not set for this user
$app->enqueueMessage(JText::_('COM_MEMBERSMANAGER_MEMBER_WAS_NOT_ADDED_TO_ANY_GROUPS_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR'), 'Error');
}
- $app->enqueueMessage(JText::_('COM_MEMBERSMANAGER_MEMBER_WAS_CREATED_SUCCESSFULLY_AND_THE_LOGIN_DETAILS_WAS_EMAILED_TO_THE_MEMBER'), 'Success');
}
- else
- {
- $app->enqueueMessage($done, 'Error');
- }
- // we still check if user was created.... (TODO)
- if (!is_numeric($done) && ($didCreate = JUserHelper::getUserId($bucket['username'])))
- {
- $data['user'] = $didCreate;
- }
- }
- // check if the user was set
- if (isset($data['user']) && $data['user'] > 0)
- {
// the login member must always own it self for edit permissions
$data['created_by'] = $data['user'];
}
diff --git a/admin/models/members.php b/admin/models/members.php
index 13ab7db..d129c18 100644
--- a/admin/models/members.php
+++ b/admin/models/members.php
@@ -27,13 +27,206 @@ class MembersmanagerModelMembers extends JModelList
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
- 'a.account','account',
- 'a.main_member','main_member'
+ 'a.account','account'
);
}
parent::__construct($config);
+ }
+
+ /**
+ * Load all the users found in Joomla into membersmanager
+ *
+ * @since 2.7.5
+ *
+ * @return bool true on success
+ */
+ public function importJoomlaUsers()
+ {
+ if (($types = $this->getMemberTypes()) !== false)
+ {
+ // get all already set users
+ $active_users = (($users = MembersmanagerHelper::getVars('member', 1, 'published', 'user')) !== false) ? $users : array();
+ // set so defaults
+ $userBucket = array();
+ $trigger = false;
+ foreach ($types as $type => $groups)
+ {
+ $this->loadMembers($userBucket, $type, $groups, $active_users, $trigger);
+ // trigger message to run import again
+ if ($trigger)
+ {
+ JFactory::getApplication()->enqueueMessage(JText::_('COM_MEMBERSMANAGER_ONLY_ONE_THOUSAND_MEMBERS_CAN_BE_IMPORTED_AT_A_TIME_SINCE_YOU_HAVE_MORE_THEN_ONE_THOUSAND_USERS_YOU_WILL_NEED_TO_RUN_THE_IMPORT_AGAIN_UNTIL_YOU_SEE_A_GREEN_SUCCESS_MESSAGE'), 'warning');
+ return false;
+ }
+ }
+ // now insert the members in table
+ if ($this->insertMembers($userBucket, $active_users) || !$trigger)
+ {
+ return true;
+ }
+ JFactory::getApplication()->enqueueMessage(JText::_('COM_MEMBERSMANAGER_NO_USERS_WERE_FOUND_THAT_MATCH_THE_TARGET_GROUPS_SET_IN_THE_MEMBER_TYPES'), 'warning');
+ return false;
+ }
+ JFactory::getApplication()->enqueueMessage(JText::_('COM_MEMBERSMANAGER_NO_MEMBER_TYPES_ARE_SET_PLEASE_SET_SOME_AND_TRY_AGAIN'), 'warning');
+ return false;
}
+
+ /**
+ * Gets an array of objects of types of members.
+ *
+ * @return object[] An array of results.
+ *
+ */
+ protected function getMemberTypes()
+ {
+ // get types that allow relationships
+ $query = $this->_db->getQuery(true);
+ $query->select(array('a.id', 'a.groups_target'));
+ $query->from('#__membersmanager_type AS a');
+ $query->where($this->_db->quoteName('a.published') . ' >= 1');
+ $this->_db->setQuery($query);
+ $this->_db->execute();
+ // only continue if we have member types and all relationship types
+ if (($types = $this->_db->loadAssocList('id', 'groups_target')) !== false && MembersmanagerHelper::checkArray($types))
+ {
+ return $types;
+ }
+ return false;
+ }
+
+ /**
+ * Load members
+ *
+ * @return void
+ *
+ */
+ protected function loadMembers(&$userBucket, &$type, &$groups, &$active_users, &$trigger)
+ {
+ if (!$trigger && MembersmanagerHelper::checkJson($groups))
+ {
+ $groups = (array) json_decode($groups, true);
+ if (MembersmanagerHelper::checkArray($groups))
+ {
+ foreach ($groups as $group_id)
+ {
+ if (($users = JAccess::getUsersByGroup($group_id)) !== false && MembersmanagerHelper::checkArray($users))
+ {
+ foreach ($users as $user_id)
+ {
+ // make sure this user is not already set
+ if (!in_array($user_id, $active_users))
+ {
+ if (!isset($userBucket[$user_id]))
+ {
+ $userBucket[$user_id] = array($type);
+ }
+ else
+ {
+ $userBucket[$user_id][] = $type;
+ }
+ }
+ else
+ {
+ // we need to do something here (TODO)
+ }
+ // if at any time we hit the 1000 mark we must reset
+ if (count($userBucket) >= 1000)
+ {
+ $trigger = true;
+ return $this->insertMembers($userBucket, $active_users);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Insert the members into the members table
+ *
+ * @return void
+ *
+ */
+ protected function insertMembers(&$userBucket, $users)
+ {
+ // check if we found users
+ if (MembersmanagerHelper::checkArray($userBucket))
+ {
+ // Get a db connection.
+ $db = JFactory::getDbo();
+ $todayDate = JFactory::getDate()->toSql();
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ // Insert columns.
+ $columns = array('user', 'token', 'name', 'username', 'useremail', 'account', 'type', 'created_by', 'created', 'published', 'access', 'version');
+ // Prepare the insert query.
+ $query->insert($db->quoteName('#__membersmanager_member'))->columns($db->quoteName($columns));
+ // limiting counter
+ $limiter = 0;
+ foreach ($userBucket as $user_id => $values)
+ {
+ // set the type
+ $type = new JRegistry;
+ $type->loadArray($values);
+ // get user
+ $member = JFactory::getUser($user_id);
+ // build unique token
+ $token = MembersmanagerHelper::safeString($member->name, 'L', '-', false, false);
+ while (!MembersmanagerHelper::checkUnique(0, 'token', $token, 'member'))
+ {
+ $token = JString::increment($token, 'dash');
+ }
+ // build member
+ $values = array();
+ $values[] = (int) $user_id;
+ $values[] = $db->quote($token);
+ $values[] = $db->quote($member->name);
+ $values[] = $db->quote($member->username);
+ $values[] = $db->quote($member->email);
+ $values[] = 1;
+ $values[] = $db->quote((string) $type);
+ $values[] = (int) $user_id;
+ $values[] = $db->quote($todayDate);
+ $values[] = 1;
+ $values[] = 1;
+ $values[] = 1;
+
+ // load values
+ $query->values(implode(',', $values));
+ // clear memory
+ unset($userBucket[$user_id]);
+ $limiter++;
+ // check if we have 100 rows, the insert and start new
+ if ($limiter >= 100)
+ {
+ // reset counter
+ $limiter = 0;
+ // run query
+ $db->setQuery($query);
+ $db->execute();
+ // reset query
+ $query = $db->getQuery(true);
+ // Prepare the new insert query.
+ $query->insert($db->quoteName('#__membersmanager_member'))->columns($db->quoteName($columns));
+ }
+ // make sure to update the user array that are active
+ $users[] = $user_id;
+ }
+ // reset the bucket
+ $userBucket = array();
+ // only run if queries remain
+ if ($limiter > 0)
+ {
+ $db->setQuery($query);
+ $db->execute();
+ }
+ return true;
+ }
+ return false;
+ }
+
/**
* Method to auto-populate the model state.
@@ -50,10 +243,7 @@ class MembersmanagerModelMembers extends JModelList
$this->context .= '.' . $layout;
}
$account = $this->getUserStateFromRequest($this->context . '.filter.account', 'filter_account');
- $this->setState('filter.account', $account);
-
- $main_member = $this->getUserStateFromRequest($this->context . '.filter.main_member', 'filter_main_member');
- $this->setState('filter.main_member', $main_member);
+ $this->setState('filter.account', $account);
$sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int');
$this->setState('filter.sorting', $sorting);
@@ -245,11 +435,6 @@ class MembersmanagerModelMembers extends JModelList
{
$query->where('a.account = ' . $db->quote($db->escape($account)));
}
- // Filter by main_member.
- if ($main_member = $this->getState('filter.main_member'))
- {
- $query->where('a.main_member = ' . $db->quote($db->escape($main_member)));
- }
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering', 'a.id');
@@ -407,8 +592,7 @@ class MembersmanagerModelMembers extends JModelList
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' . $this->getState('filter.modified_by');
- $id .= ':' . $this->getState('filter.account');
- $id .= ':' . $this->getState('filter.main_member');
+ $id .= ':' . $this->getState('filter.account');
return parent::getStoreId($id);
}
diff --git a/admin/models/types.php b/admin/models/types.php
index 7ab44da..ccb5289 100644
--- a/admin/models/types.php
+++ b/admin/models/types.php
@@ -33,7 +33,53 @@ class MembersmanagerModelTypes extends JModelList
}
parent::__construct($config);
+ }
+
+ /**
+ * update/sync all the member types
+ *
+ * @return bool true on success
+ */
+ public function updateTypes()
+ {
+ if (($members = $this->getMembers()) !== false)
+ {
+ // set so defaults
+ $bucket = array();
+ $trigger = false;
+ foreach ($members as $id => $types)
+ {
+ MembersmanagerHelper::updateTypes($id, $types);
+ }
+ return true;
+ }
+ JFactory::getApplication()->enqueueMessage(JText::_('COM_MEMBERSMANAGER_NO_MEMBERS_ARE_SET_PLEASE_SET_SOME_AND_TRY_AGAIN'), 'warning');
+ return false;
}
+
+ /**
+ * Gets an array of members.
+ *
+ * @return array An array of members.
+ *
+ */
+ protected function getMembers()
+ {
+ // get types that allow relationships
+ $query = $this->_db->getQuery(true);
+ $query->select(array('a.id', 'a.type'));
+ $query->from('#__membersmanager_member AS a');
+ $query->where($this->_db->quoteName('a.published') . ' >= 1');
+ $this->_db->setQuery($query);
+ $this->_db->execute();
+ // only continue if we have member types and all relationship types
+ if (($members = $this->_db->loadAssocList('id', 'type')) !== false && MembersmanagerHelper::checkArray($members))
+ {
+ return $members;
+ }
+ return false;
+ }
+
/**
* Method to auto-populate the model state.
diff --git a/admin/sql/install.mysql.utf8.sql b/admin/sql/install.mysql.utf8.sql
index bc9db0c..0bec818 100644
--- a/admin/sql/install.mysql.utf8.sql
+++ b/admin/sql/install.mysql.utf8.sql
@@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS `#__membersmanager_member` (
`user` INT(11) NOT NULL DEFAULT 0,
`useremail` VARCHAR(255) NOT NULL DEFAULT '',
`username` VARCHAR(255) NOT NULL DEFAULT '',
- `params` text NOT NULL DEFAULT '',
+ `params` text NOT NULL,
`published` TINYINT(3) NOT NULL DEFAULT 1,
`created_by` INT(10) unsigned NOT NULL DEFAULT 0,
`modified_by` INT(10) unsigned NOT NULL DEFAULT 0,
@@ -52,7 +52,7 @@ CREATE TABLE IF NOT EXISTS `#__membersmanager_type` (
`name` VARCHAR(255) NOT NULL DEFAULT '',
`type` TEXT NOT NULL,
`view_relationship` TEXT NOT NULL,
- `params` text NOT NULL DEFAULT '',
+ `params` text NOT NULL,
`published` TINYINT(3) NOT NULL DEFAULT 1,
`created_by` INT(10) unsigned NOT NULL DEFAULT 0,
`modified_by` INT(10) unsigned NOT NULL DEFAULT 0,
diff --git a/admin/views/member/submitbutton.js b/admin/views/member/submitbutton.js
index 0e6cf69..942dda3 100644
--- a/admin/views/member/submitbutton.js
+++ b/admin/views/member/submitbutton.js
@@ -13,19 +13,9 @@ Joomla.submitbutton = function(task)
if (task == ''){
return false;
} else {
- var isValid=true;
var action = task.split('.');
- if (action[1] != 'cancel' && action[1] != 'close'){
- var forms = $$('form.form-validate');
- for (var i=0;iuser->authorise('member.import_joomla_users', 'com_membersmanager'))
+ {
+ // add Import Joomla Users button.
+ JToolBarHelper::custom('members.importJoomlaUsers', 'joomla', '', 'COM_MEMBERSMANAGER_IMPORT_JOOMLA_USERS', false);
+ }
if ($this->canDo->get('core.import') && $this->canDo->get('member.import'))
{
@@ -206,28 +211,6 @@ class MembersmanagerViewMembers extends JViewLegacy
JHtml::_('select.options', $this->accountOptions, 'value', 'text')
);
}
- }
-
- // Set Main Member User Selection
- $this->main_memberUserOptions = JFormHelper::loadFieldType('Mainmembers')->options;
- if ($this->main_memberUserOptions)
- {
- // Main Member User Filter
- JHtmlSidebar::addFilter(
- '- Select '.JText::_('COM_MEMBERSMANAGER_MEMBER_MAIN_MEMBER_LABEL').' -',
- 'filter_main_member',
- JHtml::_('select.options', $this->main_memberUserOptions, 'value', 'text', $this->state->get('filter.main_member'))
- );
-
- if ($this->canBatch && $this->canCreate && $this->canEdit)
- {
- // Main Member User Batch Selection
- JHtmlBatch_::addListSelection(
- '- Keep Original '.JText::_('COM_MEMBERSMANAGER_MEMBER_MAIN_MEMBER_LABEL').' -',
- 'batch[main_member]',
- JHtml::_('select.options', $this->main_memberUserOptions, 'value', 'text')
- );
- }
}
}
diff --git a/admin/views/type/submitbutton.js b/admin/views/type/submitbutton.js
index 63a42d6..aced204 100644
--- a/admin/views/type/submitbutton.js
+++ b/admin/views/type/submitbutton.js
@@ -13,19 +13,9 @@ Joomla.submitbutton = function(task)
if (task == ''){
return false;
} else {
- var isValid=true;
var action = task.split('.');
- if (action[1] != 'cancel' && action[1] != 'close'){
- var forms = $$('form.form-validate');
- for (var i=0;iuser->authorise('type.update_types', 'com_membersmanager'))
+ {
+ // add Update Types button.
+ JToolBarHelper::custom('types.updateTypes', 'wrench', '', 'COM_MEMBERSMANAGER_UPDATE_TYPES', false);
+ }
if ($this->canDo->get('core.import') && $this->canDo->get('type.import'))
{
diff --git a/membersmanager.xml b/membersmanager.xml
index 4e58325..b8c7693 100644
--- a/membersmanager.xml
+++ b/membersmanager.xml
@@ -1,7 +1,7 @@
COM_MEMBERSMANAGER
- 27th December, 2018
+ 4th April, 2019
Llewellyn van der Merwe
llewellyn@joomlacomponentbuilder.com
https://www.joomlacomponentbuilder.com/
diff --git a/script.php b/script.php
index eaaddb8..5e5d13a 100644
--- a/script.php
+++ b/script.php
@@ -503,7 +503,7 @@ class com_membersmanagerInstallerScript
$query = $db->getQuery(true);
// Field to update.
$fields = array(
- $db->quoteName('params') . ' = ' . $db->quote('{"autorName":"Llewellyn van der Merwe","autorEmail":"llewellyn@joomlacomponentbuilder.com","placeholder_prefix":"member","members_display_type":"1","many_components":"0","crop_profile":"1","profile_height":"300","profile_width":"200","dynamic_salt":"1->!,3->E,4->A,6->b,9->d","country":"Namibia","check_in":"-1 day","save_history":"1","history_limit":"10","uikit_version":"2","uikit_load":"1","uikit_min":"","uikit_style":""}'),
+ $db->quoteName('params') . ' = ' . $db->quote('{"autorName":"Llewellyn van der Merwe","autorEmail":"llewellyn@joomlacomponentbuilder.com","default_accesslevel":"1","placeholder_prefix":"member","members_display_type":"1","many_components":"0","login_required":"1","crop_profile":"1","profile_height":"300","profile_width":"200","dynamic_salt":"1->!,3->E,4->A,6->b,9->d","country":"Namibia","check_in":"-1 day","save_history":"1","history_limit":"10","uikit_version":"2","uikit_load":"1","uikit_min":"","uikit_style":""}'),
);
// Condition.
$conditions = array(
diff --git a/site/assets/css/member.css b/site/assets/css/member.css
index 095d0de..6a21998 100644
--- a/site/assets/css/member.css
+++ b/site/assets/css/member.css
@@ -13,4 +13,14 @@
#jform_main_member_chzn {
width: 100% !important;
+}
+.btn-toolbar .btn-wrapper {
+ display: inline-block;
+ margin: 0 0 8px 5px;
+}
+.form-inline, .form-inline-header {
+ display: inline-block;
+}
+.form-inline-header .control-group, .form-inline-header .control-label, .form-inline-header .controls {
+ display: inline-block;
}
diff --git a/site/assets/js/profile.js b/site/assets/js/profile.js
index 2032c92..429ec3a 100644
--- a/site/assets/js/profile.js
+++ b/site/assets/js/profile.js
@@ -11,16 +11,16 @@
/* JS Document */
// Get report based on id & element from Server
function getReport_server(report_key){
- var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.getReport&format=json");
+ var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.getReport&raw=true&format=json&vdm="+vastDevMod);
if(token.length > 0 && report_key.length > 0){
var request = 'token='+token+'&key='+report_key;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
- dataType: 'jsonp',
+ dataType: 'json',
data: request,
- jsonp: 'callback'
+ jsonp: false
});
}
// get report to display
@@ -73,4 +73,44 @@ function loadTheChartInModal(callback, targetDivID){
// run call back
callback();
}, 800);
-}
\ No newline at end of file
+}
+
+// Get messages based on id & element from Server
+function getListMessages_server(messages_key){
+ var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.getListMessages&raw=true&format=json&vdm="+vastDevMod);
+ if(token.length > 0 && messages_key.length > 0){
+ var request = 'token='+token+'&key='+messages_key;
+ }
+ return jQuery.ajax({
+ type: 'POST',
+ url: getUrl,
+ dataType: 'json',
+ data: request,
+ jsonp: false
+ });
+}
+// get messages to display
+function getListMessages(messages_key){
+ // remove old data and add spinner
+ jQuery('.setlistmessages').html('');
+ jQuery('.listmessages-spinner').show();
+ // first we see if we have local storage of this data
+ getListMessages_server(messages_key).done(function(result) {
+ if(result.html){
+ setListMessages(result.html);
+ } else if(result.error){
+ // set an error if item date could not return
+ setListMessages(result.error);
+ } else {
+ // set an error if item date could not return
+ setListMessages(''+Joomla.JText._('COM_MEMBERSMANAGER_THERE_WAS_NO_MESSAGES_FOUND')+' ');
+ }
+ });
+}
+// set the Messages
+function setListMessages(data) {
+ // show data
+ jQuery('.setlistmessages').html(data);
+ // hide spinner
+ jQuery('.listmessages-spinner').hide();
+}
\ No newline at end of file
diff --git a/site/controller.php b/site/controller.php
index 3525ae9..0b01417 100644
--- a/site/controller.php
+++ b/site/controller.php
@@ -29,7 +29,7 @@ class MembersmanagerController extends JControllerLegacy
function display($cachable = false, $urlparams = false)
{
// set default view if not set
- $view = $this->input->getCmd('view', 'members');
+ $view = $this->input->getCmd('view', 'cpanel');
$this->input->set('view', $view);
$isEdit = $this->checkEditView($view);
$layout = $this->input->get('layout', null, 'WORD');
@@ -68,7 +68,7 @@ class MembersmanagerController extends JControllerLegacy
else
{
// normal redirect back to the list default site view
- $this->setRedirect(JRoute::_('index.php?option=com_membersmanager&view=members', false));
+ $this->setRedirect(JRoute::_('index.php?option=com_membersmanager&view=cpanel', false));
}
return false;
}
diff --git a/site/controllers/ajax.json.php b/site/controllers/ajax.json.php
index dbfdad3..64bb0ac 100644
--- a/site/controllers/ajax.json.php
+++ b/site/controllers/ajax.json.php
@@ -33,7 +33,8 @@ class MembersmanagerControllerAjax extends JControllerLegacy
$this->registerTask('getUserDetails', 'ajax');
$this->registerTask('getChartImageLink', 'ajax');
$this->registerTask('searchMembers', 'ajax');
- $this->registerTask('getReport', 'ajax');
+ $this->registerTask('getReport', 'ajax');
+ $this->registerTask('getListMessages', 'ajax');
}
public function ajax()
@@ -394,6 +395,44 @@ class MembersmanagerControllerAjax extends JControllerLegacy
echo "(".json_encode($e).");";
}
}
+ break;
+ case 'getListMessages':
+ try
+ {
+ $returnRaw = $jinput->get('raw', false, 'BOOLEAN');
+ $keyValue = $jinput->get('key', NULL, 'STRING');
+ if($keyValue && $user->id != 0)
+ {
+ $result = $this->getModel('ajax')->getListMessages($keyValue);
+ }
+ else
+ {
+ $result = false;
+ }
+ if($callback = $jinput->get('callback', null, 'CMD'))
+ {
+ echo $callback . "(".json_encode($result).");";
+ }
+ elseif($returnRaw)
+ {
+ echo json_encode($result);
+ }
+ else
+ {
+ echo "(".json_encode($result).");";
+ }
+ }
+ catch(Exception $e)
+ {
+ if($callback = $jinput->get('callback', null, 'CMD'))
+ {
+ echo $callback."(".json_encode($e).");";
+ }
+ else
+ {
+ echo "(".json_encode($e).");";
+ }
+ }
break;
}
}
diff --git a/site/controllers/member.php b/site/controllers/member.php
index bb5d6b2..8cc4dd6 100644
--- a/site/controllers/member.php
+++ b/site/controllers/member.php
@@ -35,7 +35,7 @@ class MembersmanagerControllerMember extends JControllerForm
*/
public function __construct($config = array())
{
- $this->view_list = 'members'; // safeguard for setting the return view listing to the default site view.
+ $this->view_list = 'cpanel'; // safeguard for setting the return view listing to the default site view.
parent::__construct($config);
}
diff --git a/site/helpers/membersmanager.php b/site/helpers/membersmanager.php
index 9e41834..70de095 100644
--- a/site/helpers/membersmanager.php
+++ b/site/helpers/membersmanager.php
@@ -27,6 +27,7 @@ abstract class MembersmanagerHelper
self::loadSession();
}
+
/**
* the params
**/
@@ -161,7 +162,7 @@ abstract class MembersmanagerHelper
// set edit link
$selection['setMemberEditURL:id|created_by'] = $f . 'edit_url' . $b;
// Get the medium encryption.
- $mediumkey = MembersmanagerHelper::getCryptKey('medium');
+ $mediumkey = self::getCryptKey('medium');
if ($mediumkey)
{
// Get the encryption object.
@@ -221,7 +222,17 @@ abstract class MembersmanagerHelper
**/
protected static function setProfileLink($object)
{
- return JRoute::_('index.php?option=com_membersmanager&view=profile&id='. $object->get('id') . ':' . $object->get('token') . '&return=' . self::$return_here);
+ // get the global settings
+ if (!self::checkObject(self::$params))
+ {
+ self::$params = JComponentHelper::getParams('com_membersmanager');
+ }
+ // only load link if open to public or is logged in
+ if (2 == self::$params->get('login_required', 1) || JFactory::getUser()->id > 0)
+ {
+ return JRoute::_('index.php?option=com_membersmanager&view=profile&id='. $object->get('id') . ':' . $object->get('token') . '&return=' . self::$return_here);
+ }
+ return '';
}
/**
@@ -290,9 +301,24 @@ abstract class MembersmanagerHelper
$_return = urlencode(base64_encode((string) JUri::getInstance()));
if ($return)
{
- return self::getCreateURL('message', 'message', $return . '&return=' . $_return, 'com_communicate');
+ return self::getCreateURL('compose', 'compose', $return . '&return=' . $_return, 'com_communicate');
}
- return self::getCreateURL('message', 'message', '&return=' . $_return, 'com_communicate');
+ return self::getCreateURL('compose', 'compose', '&return=' . $_return, 'com_communicate');
+ }
+ elseif ($key && 'message_number' === $key && is_numeric($return) && $return > 0)
+ {
+ // get the messages numbers
+ if (($messages = self::getMessages($return)) !== false)
+ {
+ // return result
+ return count( (array) $messages);
+ }
+ return 0;
+ }
+ elseif ($key && 'list_messages' === $key && is_numeric($default) && $default > 0)
+ {
+ // return result
+ return self::getListMessages($default, $return);
}
// get the global settings of com_communicate (singleton)
$params = JComponentHelper::getParams('com_communicate');
@@ -306,6 +332,103 @@ abstract class MembersmanagerHelper
return $default;
}
+ /**
+ * return a list of messages
+ **/
+ protected static function getListMessages(&$id, &$return)
+ {
+ // get the messages
+ if (($messages = self::getMessages($id)) !== false)
+ {
+ // set the return value
+ $_return = '';
+ if (self::checkString($return))
+ {
+ $_return = '&return=' . $return;
+ }
+ // now build the html
+ $bucket = array('received' => array(), 'send' => array());
+ foreach($messages as $message)
+ {
+ // get time stamp
+ $timestamp = strtotime($message->created);
+ $date = self::fancyDynamicDate($timestamp);
+ // get key
+ $key = '&key=' . self::lock($message->id); // to insure that the access is only given by the sytem
+ // build link
+ $link = JRoute::_('index.php?option=com_communicate&view=message&id=' . $message->id . $_return . $key);
+ // set read status
+ $b = '';
+ $_b = '';
+ if ($message->hits == 0)
+ {
+ $b = '★ ';
+ }
+ // build the bucket of messages
+ if ($id == $message->recipient)
+ {
+ $bucket['received'][] = $b . $message->subject . '
→ ' . $date . '' . $_b;
+ }
+ else
+ {
+ if (($name = self::getMemberName($message->recipient, null, null, null, false)) === false)
+ {
+ $name = $message->email;
+ }
+ $bucket['send'][] = $b . $name . '
' . $message->subject . '
← ' . $date . '' . $_b;
+ }
+ }
+ // now build the actual list
+ $html = array();
+ foreach ($bucket as $_name => $_messages)
+ {
+ if (self::checkArray($_messages))
+ {
+ $html[] = '' . $_name . ' ';
+ $html[] = '' . implode(' ', $_messages) . ' ';
+ }
+ }
+ // make sure we have messages
+ if (self::checkArray($html))
+ {
+ return implode("", $html);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * get messages
+ **/
+ public static function getMessages(&$id)
+ {
+ // Get the user object.
+ $user = JFactory::getUser();
+ // get database object
+ $db = JFactory::getDBO();
+ $query = $db->getQuery(true);
+ $query->select(array('a.id', 'a.member','a.recipient','a.created','a.subject','a.kind','a.email','a.hits'));
+ $query->from('#__communicate_message AS a');
+ $query->where('(a.recipient = ' . (int) $id . ' OR a.member = ' . (int) $id . ')');
+ $query->where('a.published = 1');
+ // Implement View Level Access
+ if (!$user->authorise('core.options', 'com_communicate'))
+ {
+ $groups = implode(',', $user->getAuthorisedViewLevels());
+ $query->where('a.access IN (' . $groups . ')');
+ }
+ $query->order('a.created desc');
+ $db->setQuery($query);
+ $db->execute();
+ // check if we have found any
+ if ($db->getNumRows())
+ {
+ // get all messages
+ return $db->loadObjectList();
+ }
+ return false;
+ }
+
/**
* remove all groups that are part of target groups in the member types
**/
@@ -342,7 +465,7 @@ abstract class MembersmanagerHelper
public static function getAnyPlaceHolders($_component, $type = 'report', $addCompany = false)
{
// check if we are in the correct class
- if ('com_membersmanager' !== $_component)
+ if ('com_membersmanager' !== $_component && 'com_corecomponent' !== $_component)
{
// check if the class and method exist
if (($helperClass = self::getHelperClass($_component)) !== false && method_exists($helperClass, 'getPlaceHolders'))
@@ -681,9 +804,57 @@ abstract class MembersmanagerHelper
// check if access is needed
if (!$user->authorise('core.options', 'com_membersmanager'))
{
- if (($userID = $user->get('id', false)) !== false && $userID > 0 && ($types = self::getVar('member', $userID, 'user', 'type')) !== false)
+ // get all types in system
+ $query = $db->getQuery(true);
+ $query->select(array('a.groups_access', 'a.groups_target'));
+ $query->from('#__membersmanager_type AS a');
+ $query->where($db->quoteName('a.published') . ' >= 1');
+ // also filter by access (will keep an eye on this)
+ $groups = implode(',', $user->getAuthorisedViewLevels());
+ $query->where('a.access IN (' . $groups . ')');
+ $db->setQuery($query);
+ $db->execute();
+ // get all types
+ $types = $db->loadAssocList();
+ // make sure we have types, and user access groups
+ if (self::checkArray($types) && ($userID = $user->get('id', false)) !== false && $userID > 0 && ($member_type = self::getVar('member', $userID, 'user', 'type')) !== false)
{
- return self::getMemberGroupsByType($types, 'groups_access');
+ // get the groups this member belong to
+ $member_access = self::getMemberGroupsByType($member_type);
+ // function to setup the group array
+ $setGroups = function ($groups) {
+ // convert to array
+ if (self::checkJson($groups))
+ {
+ return (array) json_decode($groups, true);
+ }
+ elseif (is_numeric($groups))
+ {
+ return array($groups);
+ }
+ return false;
+ };
+ // our little function to check if two arrays intersect on values
+ $intersect = function ($a, $b) { $b = array_flip($b); foreach ($a as $v) { if (isset($b[$v])) return true; } return false; };
+ // type bucket
+ $bucketTypes = array();
+ foreach ($types as $groups)
+ {
+ $groups_access = $setGroups($groups['groups_access']);
+ if (self::checkArray($groups_target) && $intersect($groups_access, $member_access))
+ {
+ $groups_target = $setGroups($groups['groups_target']);
+ foreach ($groups_target as $group_target)
+ {
+ $bucketTypes[$group_target] = $group_target;
+ }
+ }
+ }
+ // check if we found any
+ if (self::checkArray($bucketTypes))
+ {
+ return $bucketTypes;
+ }
}
return false;
}
@@ -712,7 +883,7 @@ abstract class MembersmanagerHelper
{
// get all types in system
$query = $db->getQuery(true);
- $query->select(array('a.id', 'a.groups_target')); // groups_target = type_link
+ $query->select(array('a.id', 'a.groups_access'));
$query->from('#__membersmanager_type AS a');
$query->where($db->quoteName('a.published') . ' >= 1');
// also filter by access (will keep an eye on this)
@@ -721,10 +892,12 @@ abstract class MembersmanagerHelper
$db->setQuery($query);
$db->execute();
// get all types
- $types = $db->loadAssocList('id', 'groups_target');
+ $types = $db->loadAssocList('id', 'groups_access');
// make sure we have types, and user access groups
- if (self::checkArray($types) && ($groups_access = self::getAccessGroups($user, $db)) !== false)
+ if (self::checkArray($types) && ($userID = $user->get('id', false)) !== false && $userID > 0 && ($member_type = self::getVar('member', $userID, 'user', 'type')) !== false)
{
+ // get the access groups
+ $groups_access = self::getMemberGroupsByType($member_type);
// function to setup the group array
$setGroups = function ($groups) {
// convert to array
@@ -835,6 +1008,32 @@ abstract class MembersmanagerHelper
return date('jS \o\f F Y',$date);
}
+ /**
+ * get date based in period past
+ */
+ public static function fancyDynamicDate($date)
+ {
+ if (!self::isValidTimeStamp($date))
+ {
+ $date = strtotime($date);
+ }
+ // older then year
+ $lastyear = date("Y", strtotime("-1 year"));
+ $tragetyear = date("Y", $date);
+ if ($tragetyear <= $lastyear)
+ {
+ return date('m/d/y', $date);
+ }
+ // same day
+ $yesterday = strtotime("-1 day");
+ if ($date > $yesterday)
+ {
+ return date('g:i A', $date);
+ }
+ // just month day
+ return date('M j', $date);
+ }
+
/**
* Change to nice fancy day time and date
*/
@@ -1992,6 +2191,10 @@ abstract class MembersmanagerHelper
{
$checked_out = (int) $item->checked_out;
}
+ else
+ {
+ $checked_out = self::getVar($view, $item->id, 'id', 'checked_out', '=', str_replace('com_', '', $component));
+ }
}
elseif (self::checkArray($item) && isset($item['id']))
{
@@ -2000,6 +2203,14 @@ abstract class MembersmanagerHelper
{
$checked_out = (int) $item['checked_out'];
}
+ else
+ {
+ $checked_out = self::getVar($view, $item['id'], 'id', 'checked_out', '=', str_replace('com_', '', $component));
+ }
+ }
+ elseif (is_numeric($item) && $item > 0)
+ {
+ $checked_out = self::getVar($view, $item, 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
// set the link title
$title = self::safeString(JText::_('COM_MEMBERSMANAGER_EDIT') . ' ' . $view, 'W');
@@ -2051,6 +2262,118 @@ abstract class MembersmanagerHelper
return '';
}
+ /**
+ * Get an edit text button
+ *
+ * @param string $text The button text
+ * @param int $item The item to edit
+ * @param string $view The type of item to edit
+ * @param string $views The list view controller name
+ * @param string $ref The return path
+ * @param string $component The component these views belong to
+ * @param string $headsup The message to show on click of button
+ *
+ * @return string On success the full html link
+ *
+ */
+ public static function getEditTextButton($text, &$item, $view, $views, $ref = '', $component = 'com_membersmanager', $jRoute = true, $class = 'uk-button', $headsup = 'COM_MEMBERSMANAGER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE')
+ {
+ // make sure we have text
+ if (!self::checkString($text))
+ {
+ return self::getEditButton($item, $view, $views, $ref, $component, $headsup);
+ }
+ // get URL
+ $url = self::getEditURL($item, $view, $views, $ref, $component, $jRoute);
+ // check if we found any
+ if (self::checkString($url))
+ {
+ // get the global settings
+ if (!self::checkObject(self::$params))
+ {
+ self::$params = JComponentHelper::getParams('com_membersmanager');
+ }
+ // get UIKIT version
+ $uikit = self::$params->get('uikit_version', 2);
+ // check that we have the ID
+ if (self::checkObject($item) && isset($item->id))
+ {
+ // check if the checked_out is available
+ if (isset($item->checked_out))
+ {
+ $checked_out = (int) $item->checked_out;
+ }
+ else
+ {
+ $checked_out = self::getVar($view, $item->id, 'id', 'checked_out', '=', str_replace('com_', '', $component));
+ }
+ }
+ elseif (self::checkArray($item) && isset($item['id']))
+ {
+ // check if the checked_out is available
+ if (isset($item['checked_out']))
+ {
+ $checked_out = (int) $item['checked_out'];
+ }
+ else
+ {
+ $checked_out = self::getVar($view, $item['id'], 'id', 'checked_out', '=', str_replace('com_', '', $component));
+ }
+ }
+ elseif (is_numeric($item) && $item > 0)
+ {
+ $checked_out = self::getVar($view, $item, 'id', 'checked_out', '=', str_replace('com_', '', $component));
+ }
+ // set the link title
+ $title = self::safeString(JText::_('COM_MEMBERSMANAGER_EDIT') . ' ' . $view, 'W');
+ // check that there is a check message
+ if (self::checkString($headsup))
+ {
+ if (3 == $uikit)
+ {
+ $href = 'onclick="UIkit.modal.confirm(\''.JText::_($headsup).'\').then( function(){ window.location.href = \'' . $url . '\' } )" href="javascript:void(0)"';
+ }
+ else
+ {
+ $href = 'onclick="UIkit2.modal.confirm(\''.JText::_($headsup).'\', function(){ window.location.href = \'' . $url . '\' })" href="javascript:void(0)"';
+ }
+ }
+ else
+ {
+ $href = 'href="' . $url . '"';
+ }
+ // return UIKIT version 3
+ if (3 == $uikit)
+ {
+ // check if it is checked out
+ if (isset($checked_out) && $checked_out > 0)
+ {
+ // is this user the one who checked it out
+ if ($checked_out == JFactory::getUser()->id)
+ {
+ return ' ' . $text . '';
+ }
+ return ' ' . $text . '';
+ }
+ // return normal edit link
+ return ' ' . $text . '';
+ }
+ // check if it is checked out (return UIKIT version 2)
+ if (isset($checked_out) && $checked_out > 0)
+ {
+ // is this user the one who checked it out
+ if ($checked_out == JFactory::getUser()->id)
+ {
+ return ' ' . $text . '';
+ }
+ return ' ' . $text . '';
+ }
+ // return normal edit link
+ return ' ' . $text . '';
+ }
+ return '';
+ }
+
/**
* Get the edit URL
*
@@ -2064,8 +2387,13 @@ abstract class MembersmanagerHelper
* @return string On success the edit url
*
*/
- public static function getEditURL(&$item, $view, $views, $ref = '', $component = 'com_membersmanager', $jRoute = true)
+ public static function getEditURL(&$item, $view, $views, $ref = '', $component = 'com_membersmanager', $jRoute = true)
{
+ // make sure the user has access to view
+ if (!JFactory::getUser()->authorise($view. '.access', $component))
+ {
+ return false;
+ }
// build record
$record = new stdClass();
// check that we have the ID
@@ -2182,7 +2510,7 @@ abstract class MembersmanagerHelper
public static function getCreateURL($view, $views, $ref = '', $component = 'com_membersmanager', $jRoute = true)
{
// can create
- if (JFactory::getUser()->authorise($view . '.create', $component))
+ if (JFactory::getUser()->authorise($view. '.access', $component) && JFactory::getUser()->authorise($view . '.create', $component))
{
// set create task
$create = "&task=" . $view . ".edit";
@@ -2348,9 +2676,36 @@ abstract class MembersmanagerHelper
// add and update the header footer and header if setDynamicData is found on placeholder request
if (method_exists(__CLASS__, 'setDynamicData') && 'placeholder' == $method)
{
+ // get the placeholder prefix
+ $prefix = self::$params->get('placeholder_prefix', 'member');
+ // member array keeper
+ $member_keeper = array('[IF ' . $prefix . '_' => '|!f r3c1p13nt_', '[' . $prefix . '_' => '|r3c1p13nt_');
+ // get the global templates
+ $doc_header = self::$params->get('doc_header', '');
+ if (self::checkString($doc_header))
+ {
+ // preserve any possible member placeholders
+ $doc_header = str_replace(array_keys($member_keeper), array_values($member_keeper), $doc_header);
+ // update document header with company details
+ $doc_header = self::setDynamicData($doc_header, self::$companyDetails[$method]);
+ // reverse the preservation of member placeholders
+ $doc_header = str_replace(array_values($member_keeper), array_keys($member_keeper), $doc_header);
+ }
+ // get the global templates
+ $doc_footer = self::$params->get('doc_footer', '');
+ if (self::checkString($doc_footer))
+ {
+ // preserve any possible member placeholders
+ $doc_footer = str_replace(array_keys($member_keeper), array_values($member_keeper), $doc_footer);
+ // update document footer with company details
+ $doc_footer = self::setDynamicData($doc_footer, self::$companyDetails[$method]);
+ // reverse the preservation of member placeholders
+ $doc_footer = str_replace(array_values($member_keeper), array_keys($member_keeper), $doc_footer);
+ }
+
// add document header and footer
- self::$companyDetails[$method][$f.'company_doc_header'.$b] = self::setDynamicData(self::$params->get('doc_header', ''), self::$companyDetails[$method]);
- self::$companyDetails[$method][$f.'company_doc_footer'.$b] = self::setDynamicData(self::$params->get('doc_footer', ''), self::$companyDetails[$method]);
+ self::$companyDetails[$method][$f.'company_doc_header'.$b] = $doc_header;
+ self::$companyDetails[$method][$f.'company_doc_footer'.$b] = $doc_footer;
}
// if object is called for
if ('object' == $method)
@@ -2872,11 +3227,11 @@ abstract class MembersmanagerHelper
self::joinMemberDetails($query, $filter, $db);
}
// Implement View Level Access (if set in table)
- if (!$user->authorise('core.options', '[[[com_component]]]') && isset($columns['access']))
+ if (!$user->authorise('core.options', 'com_membersmanager') && isset($columns['access']))
{
// ensure to always filter by access
- $accessGroups = implode(',', $user->getAuthorisedViewLevels());
- $query->where('a.access IN (' . $accessGroups . ')');
+ // $accessGroups = implode(',', $user->getAuthorisedViewLevels()); TODO first fix save to correct access groups
+ // $query->where('a.access IN (' . $accessGroups . ')');
}
// check if we have more get where details
if (method_exists(__CLASS__, "whereMemberDetails"))
@@ -3827,6 +4182,8 @@ abstract class MembersmanagerHelper
*/
protected static function setInfoComponents()
{
+ // filter per user access
+ $user = JFactory::getUser();
$db = JFactory::getDBO();
// get components
$query = $db->getQuery(true);
@@ -3843,8 +4200,9 @@ abstract class MembersmanagerHelper
// filter out the components we need
$listComponents = array_filter(
$listComponents,
- function ($component) {
- if (self::checkJson($component->params) && strpos($component->params, 'activate_membersmanager_info') !== false)
+ function ($component) use($user) {
+ if (self::checkJson($component->params) && strpos($component->params, 'activate_membersmanager_info') !== false
+ && $user->authorise('form.access', $component->element))
{
// check if this component is active
$component->params = json_decode($component->params);
@@ -4078,6 +4436,8 @@ abstract class MembersmanagerHelper
*/
protected static function setAssessmentComponents()
{
+ // filter per user access
+ $user = JFactory::getUser();
$db = JFactory::getDBO();
// get components
$query = $db->getQuery(true);
@@ -4094,8 +4454,9 @@ abstract class MembersmanagerHelper
// filter out the components we need
$listComponents = array_filter(
$listComponents,
- function ($component) {
- if (self::checkJson($component->params) && strpos($component->params, 'activate_membersmanager_assessment') !== false)
+ function ($component) use($user) {
+ if (self::checkJson($component->params) && strpos($component->params, 'activate_membersmanager_assessment') !== false
+ && $user->authorise('form.access', $component->element))
{
// check if this component is active
$component->params = json_decode($component->params);
@@ -4167,6 +4528,8 @@ abstract class MembersmanagerHelper
return false;
}
);
+ // get user object
+ $user = JFactory::getUser();
// get the database object
$db = JFactory::getDBO();
// set the tabs
@@ -4190,14 +4553,18 @@ abstract class MembersmanagerHelper
$tables = array();
foreach ($component as $_nr => $comp)
{
- if (($ids = self::getVars('form', $item->id, $view, 'id', 'IN', str_replace('com_', '', $comp->element))) !== false && self::checkArray($ids))
+ // first check access
+ if ($user->authorise('form.edit', $comp->element))
{
- // load the table
- $tables[] = self::getTabLinksTable($ids, $item, $comp, $view, $return, $db);
- }
- elseif (($tmp = self::getTabLinksTable(null, $item, $comp, $view, $return, $db)) !== false)
- {
- $tables[] = $tmp;
+ if (($ids = self::getVars('form', $item->id, $view, 'id', 'IN', str_replace('com_', '', $comp->element))) !== false && self::checkArray($ids))
+ {
+ // load the table
+ $tables[] = self::getTabLinksTable($ids, $item, $comp, $view, $return, $db);
+ }
+ elseif (($tmp = self::getTabLinksTable(null, $item, $comp, $view, $return, $db)) !== false)
+ {
+ $tables[] = $tmp;
+ }
}
}
// load the tables to the layout
@@ -4225,7 +4592,7 @@ abstract class MembersmanagerHelper
$layout = array();
}
}
- elseif (self::checkObject($component) && isset($component->element))
+ elseif (self::checkObject($component) && isset($component->element) && $user->authorise('form.edit', $component->element))
{
if (($id = self::getVar('form', $item->id, $view, 'id', '=', str_replace('com_', '', $component->element))) === false) // get item ID
{
@@ -4398,6 +4765,7 @@ abstract class MembersmanagerHelper
* @param int $id The item id
* @param object $component The target component details
* @param array $document The document array to load script
+ * @param array $footer The document footer array to load scripts
*
* @return string
*
@@ -4439,6 +4807,7 @@ abstract class MembersmanagerHelper
*
* @param object $component The target component
* @param array $document The document array to load script
+ * @param array $footer The document footer array to load scripts
*
* @return string
*
@@ -4688,9 +5057,24 @@ abstract class MembersmanagerHelper
return false;
}
);
+ // set type if not set
+ if (!isset($data['type']) && $view == 'member')
+ {
+ $data['type'] = self::getVar($view, $data['id'], 'id', 'type');
+ }
+ // set account if not set
+ if (!isset($data['account']) && $view == 'member')
+ {
+ $data['account'] = self::getVar($view, $data['id'], 'id', 'account');
+ }
// check if we have methods
if (self::checkArray($methods) && isset($data['type'], $data['account']))
{
+ // get the global settings
+ if (!self::checkObject(self::$params))
+ {
+ self::$params = JComponentHelper::getParams('com_membersmanager');
+ }
// get the app object
$app = JFactory::getApplication();
// get the post object
@@ -4699,7 +5083,7 @@ abstract class MembersmanagerHelper
$user = JFactory::getUser();
// get the database object
$db = JFactory::getDBO();
- // start looping the metods
+ // start looping the methods
foreach ($methods as $method)
{
// get components
@@ -4722,10 +5106,15 @@ abstract class MembersmanagerHelper
// check if user are allowed to edit form values or create form values
if (self::checkArray($_data))
{
+ // get the local params
+ $params = JComponentHelper::getParams($_component);
// make sure the ID is set
- if (!isset($_data['id']) || !is_numeric($_data['id']))
+ if (!isset($_data['id']) || !is_numeric($_data['id']) || $_data['id'] == 0)
{
+ // set id to zero as this will cause new item to be created
$_data['id'] = 0;
+ // set default access
+ $_data['access'] = $params->get('default_accesslevel', self::$params->get('default_accesslevel', 1));
}
// check if user may edit
if ($_data['id'] > 0 && !$user->authorise('form.edit', $_component . '.form.' . (int) $_data['id']))
@@ -4794,7 +5183,7 @@ abstract class MembersmanagerHelper
continue;
}
// remove all fields not part of the allowed edit fields
- if (($fields = JComponentHelper::getParams($_component)->get('edit_fields', false)) !== false && self::checkObject($fields))
+ if (($fields = $params->get('edit_fields', false)) !== false && self::checkObject($fields))
{
// build a fields array bucket
$fieldActive = array();
@@ -4810,6 +5199,7 @@ abstract class MembersmanagerHelper
$fieldActive['created_by'] = 'created_by';
$fieldActive['modified'] = 'modified';
$fieldActive['modified_by'] = 'modified_by';
+ $fieldActive['access'] = 'access';
$fieldActive['version'] = 'version';
$fieldActive['rules'] = 'rules';
// get the database columns of this table
@@ -5108,6 +5498,95 @@ abstract class MembersmanagerHelper
return $none;
}
+
+ /**
+ * bc math wrapper (very basic not for accounting)
+ *
+ * @param string $type The type bc math
+ * @param int $val1 The first value
+ * @param int $val2 The second value
+ * @param int $scale The scale value
+ *
+ * @return int
+ *
+ */
+ public static function bcmath($type, $val1, $val2, $scale = 0)
+ {
+ // build function name
+ $function = 'bc' . $type;
+ // use the bcmath function if available
+ if (function_exists($function))
+ {
+ return $function($val1, $val2, $scale);
+ }
+ // if function does not exist we use +-*/ operators (fallback - not ideal)
+ switch ($type)
+ {
+ // Multiply two numbers
+ case 'mul':
+ return (string) round($val1 * $val2, $scale);
+ break;
+ // Divide of two numbers
+ case 'div':
+ return (string) round($val1 / $val2, $scale);
+ break;
+ // Adding two numbers
+ case 'add':
+ return (string) round($val1 + $val2, $scale);
+ break;
+ // Subtract one number from the other
+ case 'sub':
+ return (string) round($val1 - $val2, $scale);
+ break;
+ // Raise an arbitrary precision number to another
+ case 'pow':
+ return (string) round(pow($val1, $val2), $scale);
+ break;
+ // Compare two arbitrary precision numbers
+ case 'comp':
+ return (round($val1,2) == round($val2,2));
+ break;
+ }
+ return false;
+ }
+
+ /**
+ * Basic sum of an array with more precision
+ *
+ * @param array $array The values to sum
+ * @param int $scale The scale value
+ *
+ * @return float
+ *
+ */
+ public static function bcsum($array, $scale = 4)
+ {
+ // use the bcadd function if available
+ if (function_exists('bcadd'))
+ {
+ // set the start value
+ $value = 0.0;
+ // loop the values and run bcadd
+ foreach($array as $val)
+ {
+ $value = bcadd($value, $val, $scale);
+ }
+ return $value;
+ }
+ // fall back on array sum
+ return array_sum($array);
+ }
+
+ /**
+ * get Core Name
+ *
+ * @return string the core component name
+ *
+ */
+ public static function getCoreName()
+ {
+ return 'membersmanager';
+ }
public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
{
diff --git a/site/language/en-GB/en-GB.com_membersmanager.ini b/site/language/en-GB/en-GB.com_membersmanager.ini
index d97ea68..329e728 100644
--- a/site/language/en-GB/en-GB.com_membersmanager.ini
+++ b/site/language/en-GB/en-GB.com_membersmanager.ini
@@ -5,11 +5,12 @@ COM_MEMBERSMANAGER_ACCESS_S_S="Access %s %s"
COM_MEMBERSMANAGER_ADD="Add"
COM_MEMBERSMANAGER_ADD_ONE_OF_THESE_PLACEHOLDERS_IN_TEXT_FOR_CUSTOM_DOWNLOAD_PLACEMENT="Add one of these placeholders in text for custom download placement"
COM_MEMBERSMANAGER_ALLOWED_IMAGE_FORMATS_ARE_NOT_SET_IN_THE_GLOBAL_SETTINGS_PLEASE_NOTIFY_YOUR_SYSTEM_ADMINISTRATOR="Allowed image formats are not set in the global settings, please notify your system administrator."
+COM_MEMBERSMANAGER_ALL_THE_USERS_FOUND_IN_JOOMLA_WERE_SUCCESSFULLY_IMPORTED_INTO_RELATED_MEMBER_TYPE_RELATIONSHIPS="All the users found in Joomla were successfully imported into related member type relationships."
COM_MEMBERSMANAGER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE="All unsaved work on this page will be lost, are you sure you want to continue?"
COM_MEMBERSMANAGER_BACK="Back"
-COM_MEMBERSMANAGER_BACK_TO_CPANEL="Back to cPanel"
COM_MEMBERSMANAGER_BSB_IS_ALREADY_IN_USE_PLEASE_TRY_ANOTHER="%s is already in use, please try another!"
COM_MEMBERSMANAGER_CLOSE="Close"
+COM_MEMBERSMANAGER_CORE_PLACEHOLDERS="Core Placeholders"
COM_MEMBERSMANAGER_COULD_NOT_UPLOAD_THE_FILE="Could not upload the file!"
COM_MEMBERSMANAGER_CPANEL="cPanel"
COM_MEMBERSMANAGER_CPANEL_DESC="Control Panel for Members"
@@ -24,6 +25,8 @@ COM_MEMBERSMANAGER_GO_BACK="go Back"
COM_MEMBERSMANAGER_GREAT_SS_IS_AVAILABLE="Great, %s(%s) is available!"
COM_MEMBERSMANAGER_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BMEMBERSMANAGERB_WILL_NOT_FUNCTION_CORRECTLYP="Curl Not Found!
Please setup curl on your system, or membersmanager will not function correctly!
"
COM_MEMBERSMANAGER_IMAGE="Image"
+COM_MEMBERSMANAGER_IMPORT_JOOMLA_USERS="Import Joomla Users"
+COM_MEMBERSMANAGER_IMPORT_SUCCESS="Import Success!"
COM_MEMBERSMANAGER_LOADING="Loading"
COM_MEMBERSMANAGER_LOGIN_MODULE_POSITION="Login Module Position"
COM_MEMBERSMANAGER_MAIN_MEMBER="Main Member"
@@ -149,6 +152,8 @@ COM_MEMBERSMANAGER_MEMBER_VERSION_DESC="A count of the number of times this Memb
COM_MEMBERSMANAGER_MEMBER_VERSION_LABEL="Revision"
COM_MEMBERSMANAGER_MEMBER_WAS_CREATED_SUCCESSFULLY_AND_THE_LOGIN_DETAILS_WAS_EMAILED_TO_THE_MEMBER="Member was created successfully, and the login details was emailed to the member."
COM_MEMBERSMANAGER_MEMBER_WAS_NOT_ADDED_TO_ANY_GROUPS_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR="Member was not added to any groups. Please inform your system administrator."
+COM_MEMBERSMANAGER_MESSAGE="Message"
+COM_MEMBERSMANAGER_MESSAGES="Messages"
COM_MEMBERSMANAGER_NEW="New"
COM_MEMBERSMANAGER_NOT_AUTHORISED_TO_VIEW_CPANEL="Not authorised to view cpanel!"
COM_MEMBERSMANAGER_NOT_AUTHORISED_TO_VIEW_MEMBERS="Not authorised to view members!"
@@ -156,14 +161,20 @@ COM_MEMBERSMANAGER_NOT_AUTHORISED_TO_VIEW_PROFILE="Not authorised to view profil
COM_MEMBERSMANAGER_NOT_ENOUGH_DATA="Not enough data"
COM_MEMBERSMANAGER_NOT_FOUND_OR_ACCESS_DENIED="Not found or access denied!"
COM_MEMBERSMANAGER_NO_ACCESS_GRANTED="No Access Granted!"
+COM_MEMBERSMANAGER_NO_ACCESS_TO_VIEW_DETAILS="No Access to View Details"
COM_MEMBERSMANAGER_NO_DETAILS_FOUND="No Details Found"
+COM_MEMBERSMANAGER_NO_FORMS_FOUND="No Forms Found"
COM_MEMBERSMANAGER_NO_IMPORT_FILE_SELECTED="No import file selected."
+COM_MEMBERSMANAGER_NO_MEMBER_TYPES_ARE_SET_PLEASE_SET_SOME_AND_TRY_AGAIN="No member types are set, please set some and try again."
COM_MEMBERSMANAGER_NO_MEMBER_WAS_FOUND="No member was found"
+COM_MEMBERSMANAGER_NO_MESSAGES="No messages"
COM_MEMBERSMANAGER_NO_PROFILE_FOUND="No Profile Found"
COM_MEMBERSMANAGER_NO_REPORTS_FOUND="No reports found"
COM_MEMBERSMANAGER_NO_S_FOUND="No %s found"
COM_MEMBERSMANAGER_NO_S_FOUND_IN_S="No %s found in %s"
COM_MEMBERSMANAGER_NO_TEMPLATE_FOR_BSB_WERE_FOUND="No template for %s were found"
+COM_MEMBERSMANAGER_NO_USERS_WERE_FOUND_THAT_MATCH_THE_TARGET_GROUPS_SET_IN_THE_MEMBER_TYPES="No users were found that match the target groups set in the member types."
+COM_MEMBERSMANAGER_ONLY_ONE_THOUSAND_MEMBERS_CAN_BE_IMPORTED_AT_A_TIME_SINCE_YOU_HAVE_MORE_THEN_ONE_THOUSAND_USERS_YOU_WILL_NEED_TO_RUN_THE_IMPORT_AGAIN_UNTIL_YOU_SEE_A_GREEN_SUCCESS_MESSAGE="Only 1000 members can be imported at a time. Since you have more then 1000 users, you will need to run the import again until you see a green success message!"
COM_MEMBERSMANAGER_OPEN="Open"
COM_MEMBERSMANAGER_OPEN_CPANEL="Open cPanel"
COM_MEMBERSMANAGER_OPEN_MAIN_MEMBER_PROFILE="Open Main Member Profile"
@@ -187,6 +198,7 @@ COM_MEMBERSMANAGER_S_DATA_COULD_NOT_BE_SAVED="%s data could not be saved"
COM_MEMBERSMANAGER_S_OPTIONS="%s Options"
COM_MEMBERSMANAGER_THERE_HAS_BEEN_AN_ERROR="There has been an error."
COM_MEMBERSMANAGER_THERE_WAS_AN_ERROR_PLEASE_TRY_AGAIN_LATER_IF_THIS_ERROR_CONTINUES_CONTACT_YOUR_SYSTEM_ADMINISTRATOR="There was an error, please try again later. If this error continues, contact your system administrator."
+COM_MEMBERSMANAGER_THERE_WAS_NO_MESSAGES_FOUND="There was no messages found!"
COM_MEMBERSMANAGER_THERE_WAS_NO_REPORT_FOUND="There was no report found!"
COM_MEMBERSMANAGER_THE_PROFILE_WILL_BE_CROPPED_TO_THIS_SIZE="The profile will be cropped to this size"
COM_MEMBERSMANAGER_TIME_STAMP="Time Stamp"
@@ -195,6 +207,7 @@ COM_MEMBERSMANAGER_WARNING_IMPORT_FILE_ERROR="Warning, import file error."
COM_MEMBERSMANAGER_WARNING_IMPORT_UPLOAD_ERROR="Warning, import upload error."
COM_MEMBERSMANAGER_YOU_CAN_NOT_DELETE_BSB_FIRST_MOVE_ALL_SUB_ACCOUNTS_TO_NEW_MAIN_MEMBER="You can not delete %s, first move all sub account/s to new main member."
COM_MEMBERSMANAGER_YOU_DO_NOT_HAVE_PERMISSION_TO_ADD_DATA_TO_S_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR="You do not have permission to add data to %s, please contact your system administrator."
+COM_MEMBERSMANAGER_YOU_DO_NOT_HAVE_PERMISSION_TO_CREATE_MEMBERS="You do not have permission to create members."
COM_MEMBERSMANAGER_YOU_DO_NOT_HAVE_PERMISSION_TO_EDIT_S_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR="You do not have permission to edit %s, please contact your system administrator."
COM_MEMBERSMANAGER_YOU_DO_NOT_HAVE_PERMISSION_TO_EDIT_THIS_MEMBER_RELATIONSHIPS_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR="You do not have permission to edit this member relationships, please contact your system administrator."
COM_MEMBERSMANAGER_YOU_DO_NOT_HAVE_PERMISSION_TO_EDIT_THIS_MEMBER_TYPE_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR="You do not have permission to edit this member type, please contact your system administrator."
diff --git a/site/layouts/cpanel_search_form.php b/site/layouts/cpanel_search_form.php
new file mode 100644
index 0000000..50fdb95
--- /dev/null
+++ b/site/layouts/cpanel_search_form.php
@@ -0,0 +1,29 @@
+
+ * @github Joomla Members Manager
+ * @copyright Copyright (C) 2015. All Rights Reserved
+ * @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ */
+
+// No direct access to this file
+defined('JPATH_BASE') or die('Restricted access');
+
+
+
+?>
+
+ input;?>
+
+
+
diff --git a/site/layouts/cpanel_uikit_three_buttons.php b/site/layouts/cpanel_uikit_three_buttons.php
new file mode 100644
index 0000000..0725e5b
--- /dev/null
+++ b/site/layouts/cpanel_uikit_three_buttons.php
@@ -0,0 +1,20 @@
+
+ * @github Joomla Members Manager
+ * @copyright Copyright (C) 2015. All Rights Reserved
+ * @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ */
+
+// No direct access to this file
+defined('JPATH_BASE') or die('Restricted access');
+
+
+
+?>
+
+
+
diff --git a/site/layouts/cpanel_uikit_two_buttons.php b/site/layouts/cpanel_uikit_two_buttons.php
new file mode 100644
index 0000000..8db0c4a
--- /dev/null
+++ b/site/layouts/cpanel_uikit_two_buttons.php
@@ -0,0 +1,20 @@
+
+ * @github Joomla Members Manager
+ * @copyright Copyright (C) 2015. All Rights Reserved
+ * @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ */
+
+// No direct access to this file
+defined('JPATH_BASE') or die('Restricted access');
+
+
+
+?>
+
+
+
diff --git a/site/layouts/list_name_value.php b/site/layouts/list_name_value.php
index b7f0d27..7262193 100644
--- a/site/layouts/list_name_value.php
+++ b/site/layouts/list_name_value.php
@@ -28,9 +28,10 @@ else
{
$updated = false;
}
+$tracker = 0;
?>
-
+
$value): ?>
authorise('form.view.' . $name, $displayData['com'] . '.form.' . (int) $displayData['data']['id'])): ?>
@@ -44,13 +45,16 @@ else
}
?>
- :
+
+ 0 && $tracker > 0): ?>
+
+ :
+
+ ...
+
...
- 0) :?>
-
- :
-
diff --git a/site/layouts/member/membership_above.php b/site/layouts/member/membership_above.php
index 465b5d4..5156eff 100644
--- a/site/layouts/member/membership_above.php
+++ b/site/layouts/member/membership_above.php
@@ -14,14 +14,20 @@ defined('_JEXEC') or die('Restricted access');
$form = $displayData->getForm();
-$fields = array(
+$fields = $displayData->get('fields') ?: array(
'token',
- 'account'
+ 'account',
+ 'user'
);
+$hiddenFields = $displayData->get('hidden_fields') ?: array();
+
?>
- renderField($field);
- } ?>
+
+
+ setFieldAttribute($field, 'type', 'hidden'); ?>
+
+ renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
+
diff --git a/site/layouts/member/membership_left.php b/site/layouts/member/membership_left.php
index 6da2add..fbaa43f 100644
--- a/site/layouts/member/membership_left.php
+++ b/site/layouts/member/membership_left.php
@@ -30,20 +30,10 @@ $fields = $displayData->get('fields') ?: array(
$hiddenFields = $displayData->get('hidden_fields') ?: array();
-foreach ($fields as $field)
-{
- $field = is_array($field) ? $field : array($field);
- foreach ($field as $f)
- {
- if ($form->getField($f))
- {
- if (in_array($f, $hiddenFields))
- {
- $form->setFieldAttribute($f, 'type', 'hidden');
- }
-
- echo $form->renderField($f);
- break;
- }
- }
-}
+?>
+
+
+ setFieldAttribute($field, 'type', 'hidden'); ?>
+
+ renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
+
diff --git a/site/layouts/member/membership_right.php b/site/layouts/member/membership_right.php
index 06ff934..888b87a 100644
--- a/site/layouts/member/membership_right.php
+++ b/site/layouts/member/membership_right.php
@@ -20,20 +20,10 @@ $fields = $displayData->get('fields') ?: array(
$hiddenFields = $displayData->get('hidden_fields') ?: array();
-foreach ($fields as $field)
-{
- $field = is_array($field) ? $field : array($field);
- foreach ($field as $f)
- {
- if ($form->getField($f))
- {
- if (in_array($f, $hiddenFields))
- {
- $form->setFieldAttribute($f, 'type', 'hidden');
- }
-
- echo $form->renderField($f);
- break;
- }
- }
-}
+?>
+
+
+ setFieldAttribute($field, 'type', 'hidden'); ?>
+
+ renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
+
diff --git a/site/layouts/member/publishing.php b/site/layouts/member/publishing.php
index 2778547..3e59c77 100644
--- a/site/layouts/member/publishing.php
+++ b/site/layouts/member/publishing.php
@@ -12,11 +12,9 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
-$app = JFactory::getApplication();
$form = $displayData->getForm();
$fields = $displayData->get('fields') ?: array(
- 'user',
'created',
'created_by',
'modified',
@@ -25,20 +23,10 @@ $fields = $displayData->get('fields') ?: array(
$hiddenFields = $displayData->get('hidden_fields') ?: array();
-foreach ($fields as $field)
-{
- $field = is_array($field) ? $field : array($field);
- foreach ($field as $f)
- {
- if ($form->getField($f))
- {
- if (in_array($f, $hiddenFields))
- {
- $form->setFieldAttribute($f, 'type', 'hidden');
- }
-
- echo $form->renderField($f);
- break;
- }
- }
-}
+?>
+
+
+ setFieldAttribute($field, 'type', 'hidden'); ?>
+
+ renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
+
diff --git a/site/layouts/member/publlshing.php b/site/layouts/member/publlshing.php
index 7a32c45..bf34d22 100644
--- a/site/layouts/member/publlshing.php
+++ b/site/layouts/member/publlshing.php
@@ -12,7 +12,6 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
-$app = JFactory::getApplication();
$form = $displayData->getForm();
$fields = $displayData->get('fields') ?: array(
@@ -26,20 +25,10 @@ $fields = $displayData->get('fields') ?: array(
$hiddenFields = $displayData->get('hidden_fields') ?: array();
-foreach ($fields as $field)
-{
- $field = is_array($field) ? $field : array($field);
- foreach ($field as $f)
- {
- if ($form->getField($f))
- {
- if (in_array($f, $hiddenFields))
- {
- $form->setFieldAttribute($f, 'type', 'hidden');
- }
-
- echo $form->renderField($f);
- break;
- }
- }
-}
+?>
+
+
+ setFieldAttribute($field, 'type', 'hidden'); ?>
+
+ renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
+
diff --git a/site/layouts/profileassessment_uikit_three.php b/site/layouts/profileassessment_uikit_three.php
index bc27e3f..57ba04c 100644
--- a/site/layouts/profileassessment_uikit_three.php
+++ b/site/layouts/profileassessment_uikit_three.php
@@ -28,35 +28,38 @@ if ($displayData->setAssessment)
$displayData->assessments[$_name] = array();
foreach ($assessment as $_nr => $assess)
{
- $displayData->assessments[$_name][$_nr] = MembersmanagerHelper::getAnyFormDetails($displayData->id, 'member', $assess->element, 'object', 'profile');
- if (MembersmanagerHelper::checkArray($displayData->assessments[$_name][$_nr]))
+ if ($displayData->_USER->authorise('form.report.viewtab', $assess->element))
{
- foreach ($displayData->assessments[$_name][$_nr] as $_pointer => &$value)
+ $displayData->assessments[$_name][$_nr] = MembersmanagerHelper::getAnyFormDetails($displayData->id, 'member', $assess->element, 'object', 'profile');
+ if (MembersmanagerHelper::checkArray($displayData->assessments[$_name][$_nr]))
{
- if (isset($value->name) && MembersmanagerHelper::checkString($value->name))
+ foreach ($displayData->assessments[$_name][$_nr] as $_pointer => &$value)
{
- $value->name = $assess->name . ' - ' . $value->name;
+ if (isset($value->name) && MembersmanagerHelper::checkString($value->name))
+ {
+ $value->name = $assess->name . ' - ' . $value->name;
+ }
+ else
+ {
+ $value->name = $assess->name;
+ }
+ }
+ }
+ elseif (MembersmanagerHelper::checkObject($displayData->assessments[$_name][$_nr]))
+ {
+ if (isset($displayData->assessments[$_name][$_nr]->name) && MembersmanagerHelper::checkString($displayData->assessments[$_name][$_nr]->name))
+ {
+ $displayData->assessments[$_name][$_nr]->name = $assess->name . ' - ' . $displayData->assessments[$_name][$_nr]->name;
}
else
{
- $value->name = $assess->name;
+ $displayData->assessments[$_name][$_nr]->name = $assess->name;
}
}
}
- elseif (MembersmanagerHelper::checkObject($displayData->assessments[$_name][$_nr]))
- {
- if (isset($displayData->assessments[$_name][$_nr]->name) && MembersmanagerHelper::checkString($displayData->assessments[$_name][$_nr]->name))
- {
- $displayData->assessments[$_name][$_nr]->name = $assess->name . ' - ' . $displayData->assessments[$_name][$_nr]->name;
- }
- else
- {
- $displayData->assessments[$_name][$_nr]->name = $assess->name;
- }
- }
}
}
- elseif (MembersmanagerHelper::checkObject($assessment) && isset($assessment->element))
+ elseif ($displayData->_USER->authorise('form.report.viewtab', $assessment->element) && MembersmanagerHelper::checkObject($assessment) && isset($assessment->element))
{
$displayData->assessments[$_name] = MembersmanagerHelper::getAnyFormDetails($displayData->id, 'member', $assessment->element, 'object', 'profile');
if (MembersmanagerHelper::checkObject($displayData->assessments[$_name]))
@@ -76,13 +79,15 @@ if ($displayData->setAssessment)
?>
setAssessment) : ?>
- type_name) && $displayData->_USER->authorise('member.view.type', 'com_membersmanager.member.' . (int) $displayData->id)) : ?>
+ type_name) && MembersmanagerHelper::checkString($displayData->type_name) && $displayData->_USER->authorise('member.view.type', 'com_membersmanager.member.' . (int) $displayData->id)) : ?>
type_name, 'W'), implode(', ', (array) array_keys($displayData->assessmentAvailable))); ?>
assessmentAvailable))); ?>
-
-
+ _USER->id > 0): ?>
+
+
+
diff --git a/site/layouts/profileassessment_uikit_two.php b/site/layouts/profileassessment_uikit_two.php
index ac15b5d..fb44759 100644
--- a/site/layouts/profileassessment_uikit_two.php
+++ b/site/layouts/profileassessment_uikit_two.php
@@ -28,35 +28,38 @@ if ($displayData->setAssessment)
$displayData->assessments[$_name] = array();
foreach ($assessment as $_nr => $assess)
{
- $displayData->assessments[$_name][$_nr] = MembersmanagerHelper::getAnyFormDetails($displayData->id, 'member', $assess->element, 'object', 'profile');
- if (MembersmanagerHelper::checkArray($displayData->assessments[$_name][$_nr]))
+ if ($displayData->_USER->authorise('form.report.viewtab', $assess->element))
{
- foreach ($displayData->assessments[$_name][$_nr] as $_pointer => &$value)
+ $displayData->assessments[$_name][$_nr] = MembersmanagerHelper::getAnyFormDetails($displayData->id, 'member', $assess->element, 'object', 'profile');
+ if (MembersmanagerHelper::checkArray($displayData->assessments[$_name][$_nr]))
{
- if (isset($value->name) && MembersmanagerHelper::checkString($value->name))
+ foreach ($displayData->assessments[$_name][$_nr] as $_pointer => &$value)
{
- $value->name = $assess->name . ' - ' . $value->name;
+ if (isset($value->name) && MembersmanagerHelper::checkString($value->name))
+ {
+ $value->name = $assess->name . ' - ' . $value->name;
+ }
+ else
+ {
+ $value->name = $assess->name;
+ }
+ }
+ }
+ elseif (MembersmanagerHelper::checkObject($displayData->assessments[$_name][$_nr]))
+ {
+ if (isset($displayData->assessments[$_name][$_nr]->name) && MembersmanagerHelper::checkString($displayData->assessments[$_name][$_nr]->name))
+ {
+ $displayData->assessments[$_name][$_nr]->name = $assess->name . ' - ' . $displayData->assessments[$_name][$_nr]->name;
}
else
{
- $value->name = $assess->name;
+ $displayData->assessments[$_name][$_nr]->name = $assess->name;
}
}
}
- elseif (MembersmanagerHelper::checkObject($displayData->assessments[$_name][$_nr]))
- {
- if (isset($displayData->assessments[$_name][$_nr]->name) && MembersmanagerHelper::checkString($displayData->assessments[$_name][$_nr]->name))
- {
- $displayData->assessments[$_name][$_nr]->name = $assess->name . ' - ' . $displayData->assessments[$_name][$_nr]->name;
- }
- else
- {
- $displayData->assessments[$_name][$_nr]->name = $assess->name;
- }
- }
}
}
- elseif (MembersmanagerHelper::checkObject($assessment) && isset($assessment->element))
+ elseif ($displayData->_USER->authorise('form.report.viewtab', $assessment->element) && MembersmanagerHelper::checkObject($assessment) && isset($assessment->element))
{
$displayData->assessments[$_name] = MembersmanagerHelper::getAnyFormDetails($displayData->id, 'member', $assessment->element, 'object', 'profile');
if (MembersmanagerHelper::checkObject($displayData->assessments[$_name]))
@@ -76,13 +79,15 @@ if ($displayData->setAssessment)
?>
setAssessment) : ?>
- type_name) && $displayData->_USER->authorise('member.view.type', 'com_membersmanager.member.' . (int) $displayData->id)) : ?>
+ type_name) && MembersmanagerHelper::checkString($displayData->type_name) && $displayData->_USER->authorise('member.view.type', 'com_membersmanager.member.' . (int) $displayData->id)) : ?>
type_name, 'W'), implode(', ', (array) array_keys($displayData->assessmentAvailable))); ?>
assessmentAvailable))); ?>
-
-
+ _USER->id > 0): ?>
+
+
+
diff --git a/site/layouts/profileassessmentselection_uikit_three.php b/site/layouts/profileassessmentselection_uikit_three.php
index 7969bcc..ea19cd1 100644
--- a/site/layouts/profileassessmentselection_uikit_three.php
+++ b/site/layouts/profileassessmentselection_uikit_three.php
@@ -15,23 +15,38 @@ defined('JPATH_BASE') or die('Restricted access');
?>
-
+