* @copyright Copyright (C) 2015. All Rights Reserved
@@ -88,11 +88,7 @@ $edit = "index.php?option=com_membersmanager&view=members&task=member.edit";
- user->authorise('type.edit', 'com_membersmanager.type.' . (int)$item->type)): ?>
- escape($item->type_name); ?>
-
- escape($item->type_name); ?>
- :
+ escape($item->type); ?>:
account); ?>
escape($item->token); ?>
diff --git a/admin/views/members/tmpl/default_foot.php b/admin/views/members/tmpl/default_foot.php
index 0a533c0..a34998a 100644
--- a/admin/views/members/tmpl/default_foot.php
+++ b/admin/views/members/tmpl/default_foot.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/admin/views/members/tmpl/default_head.php b/admin/views/members/tmpl/default_head.php
index 824acd9..e02a54c 100644
--- a/admin/views/members/tmpl/default_head.php
+++ b/admin/views/members/tmpl/default_head.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/admin/views/members/tmpl/default_toolbar.php b/admin/views/members/tmpl/default_toolbar.php
index 5da5987..77c3fd5 100644
--- a/admin/views/members/tmpl/default_toolbar.php
+++ b/admin/views/members/tmpl/default_toolbar.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/admin/views/members/view.html.php b/admin/views/members/view.html.php
index 819378c..4a40494 100644
--- a/admin/views/members/view.html.php
+++ b/admin/views/members/view.html.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -37,6 +37,8 @@ class MembersmanagerViewMembers extends JViewLegacy
$this->listOrder = $this->escape($this->state->get('list.ordering'));
$this->listDirn = $this->escape($this->state->get('list.direction'));
$this->saveOrder = $this->listOrder == 'ordering';
+ // set the return here value
+ $this->return_here = urlencode(base64_encode((string) JUri::getInstance()));
// get global action permissions
$this->canDo = MembersmanagerHelper::getActions('member');
$this->canEdit = $this->canDo->get('member.edit');
@@ -226,28 +228,6 @@ class MembersmanagerViewMembers extends JViewLegacy
JHtml::_('select.options', $this->main_memberUserOptions, 'value', 'text')
);
}
- }
-
- // Set Type Name Selection
- $this->typeNameOptions = JFormHelper::loadFieldType('Types')->options;
- if ($this->typeNameOptions)
- {
- // Type Name Filter
- JHtmlSidebar::addFilter(
- '- Select '.JText::_('COM_MEMBERSMANAGER_MEMBER_TYPE_LABEL').' -',
- 'filter_type',
- JHtml::_('select.options', $this->typeNameOptions, 'value', 'text', $this->state->get('filter.type'))
- );
-
- if ($this->canBatch && $this->canCreate && $this->canEdit)
- {
- // Type Name Batch Selection
- JHtmlBatch_::addListSelection(
- '- Keep Original '.JText::_('COM_MEMBERSMANAGER_MEMBER_TYPE_LABEL').' -',
- 'batch[type]',
- JHtml::_('select.options', $this->typeNameOptions, 'value', 'text')
- );
- }
}
}
diff --git a/admin/views/type/submitbutton.js b/admin/views/type/submitbutton.js
index 79b56b9..63a42d6 100644
--- a/admin/views/type/submitbutton.js
+++ b/admin/views/type/submitbutton.js
@@ -1,7 +1,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/admin/views/type/tmpl/edit.php b/admin/views/type/tmpl/edit.php
index 4578833..e8337f9 100644
--- a/admin/views/type/tmpl/edit.php
+++ b/admin/views/type/tmpl/edit.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -65,6 +65,17 @@ $componentParams = $this->params; // will be removed just use $this->params inst
+
+
+
+
ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?>
tab_name = 'typeTab'; ?>
@@ -110,4 +121,23 @@ $componentParams = $this->params; // will be removed just use $this->params inst
-
+
+
+
diff --git a/admin/views/type/view.html.php b/admin/views/type/view.html.php
index 37a16a6..2a29062 100644
--- a/admin/views/type/view.html.php
+++ b/admin/views/type/view.html.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/admin/views/types/tmpl/default.php b/admin/views/types/tmpl/default.php
index 5c52eea..3d644a7 100644
--- a/admin/views/types/tmpl/default.php
+++ b/admin/views/types/tmpl/default.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/admin/views/types/tmpl/default_batch_body.php b/admin/views/types/tmpl/default_batch_body.php
index 77b766e..f0e6e8b 100644
--- a/admin/views/types/tmpl/default_batch_body.php
+++ b/admin/views/types/tmpl/default_batch_body.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/admin/views/types/tmpl/default_batch_footer.php b/admin/views/types/tmpl/default_batch_footer.php
index e78db42..31967c5 100644
--- a/admin/views/types/tmpl/default_batch_footer.php
+++ b/admin/views/types/tmpl/default_batch_footer.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/admin/views/types/tmpl/default_body.php b/admin/views/types/tmpl/default_body.php
index 946042f..e8dad55 100644
--- a/admin/views/types/tmpl/default_body.php
+++ b/admin/views/types/tmpl/default_body.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -81,6 +81,9 @@ $edit = "index.php?option=com_membersmanager&view=types&task=type.edit";
escape($item->groups_access); ?>
|
+
+ add_relationship); ?>
+ |
get('type.edit.state')) : ?>
checked_out) : ?>
diff --git a/admin/views/types/tmpl/default_foot.php b/admin/views/types/tmpl/default_foot.php
index 64b8d57..a71c163 100644
--- a/admin/views/types/tmpl/default_foot.php
+++ b/admin/views/types/tmpl/default_foot.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -14,5 +14,5 @@ defined('_JEXEC') or die('Restricted access');
?>
- pagination->getListFooter(); ?> |
+ pagination->getListFooter(); ?> |
\ No newline at end of file
diff --git a/admin/views/types/tmpl/default_head.php b/admin/views/types/tmpl/default_head.php
index 5dd11da..c40e3dd 100644
--- a/admin/views/types/tmpl/default_head.php
+++ b/admin/views/types/tmpl/default_head.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -41,6 +41,9 @@ defined('_JEXEC') or die('Restricted access');
|
+
+
+ |
canState): ?>
listDirn, $this->listOrder); ?>
diff --git a/admin/views/types/tmpl/default_toolbar.php b/admin/views/types/tmpl/default_toolbar.php
index 7adbd82..20a8f10 100644
--- a/admin/views/types/tmpl/default_toolbar.php
+++ b/admin/views/types/tmpl/default_toolbar.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/admin/views/types/view.html.php b/admin/views/types/view.html.php
index 6e647c6..31f79a0 100644
--- a/admin/views/types/view.html.php
+++ b/admin/views/types/view.html.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -37,6 +37,8 @@ class MembersmanagerViewTypes extends JViewLegacy
$this->listOrder = $this->escape($this->state->get('list.ordering'));
$this->listDirn = $this->escape($this->state->get('list.direction'));
$this->saveOrder = $this->listOrder == 'ordering';
+ // set the return here value
+ $this->return_here = urlencode(base64_encode((string) JUri::getInstance()));
// get global action permissions
$this->canDo = MembersmanagerHelper::getActions('type');
$this->canEdit = $this->canDo->get('type.edit');
@@ -182,6 +184,28 @@ class MembersmanagerViewTypes extends JViewLegacy
'batch[access]',
JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text')
);
+ }
+
+ // Set Add Relationship Selection
+ $this->add_relationshipOptions = $this->getTheAdd_relationshipSelections();
+ if ($this->add_relationshipOptions)
+ {
+ // Add Relationship Filter
+ JHtmlSidebar::addFilter(
+ '- Select '.JText::_('COM_MEMBERSMANAGER_TYPE_ADD_RELATIONSHIP_LABEL').' -',
+ 'filter_add_relationship',
+ JHtml::_('select.options', $this->add_relationshipOptions, 'value', 'text', $this->state->get('filter.add_relationship'))
+ );
+
+ if ($this->canBatch && $this->canCreate && $this->canEdit)
+ {
+ // Add Relationship Batch Selection
+ JHtmlBatch_::addListSelection(
+ '- Keep Original '.JText::_('COM_MEMBERSMANAGER_TYPE_ADD_RELATIONSHIP_LABEL').' -',
+ 'batch[add_relationship]',
+ JHtml::_('select.options', $this->add_relationshipOptions, 'value', 'text')
+ );
+ }
}
}
@@ -231,5 +255,41 @@ class MembersmanagerViewTypes extends JViewLegacy
'a.name' => JText::_('COM_MEMBERSMANAGER_TYPE_NAME_LABEL'),
'a.id' => JText::_('JGRID_HEADING_ID')
);
+ }
+
+ protected function getTheAdd_relationshipSelections()
+ {
+ // Get a db connection.
+ $db = JFactory::getDbo();
+
+ // Create a new query object.
+ $query = $db->getQuery(true);
+
+ // Select the text.
+ $query->select($db->quoteName('add_relationship'));
+ $query->from($db->quoteName('#__membersmanager_type'));
+ $query->order($db->quoteName('add_relationship') . ' ASC');
+
+ // Reset the query using our newly populated query object.
+ $db->setQuery($query);
+
+ $results = $db->loadColumn();
+
+ if ($results)
+ {
+ // get model
+ $model = $this->getModel();
+ $results = array_unique($results);
+ $_filter = array();
+ foreach ($results as $add_relationship)
+ {
+ // Translate the add_relationship selection
+ $text = $model->selectionTranslation($add_relationship,'add_relationship');
+ // Now add the add_relationship and its text to the options array
+ $_filter[] = JHtml::_('select.option', $add_relationship, JText::_($text));
+ }
+ return $_filter;
+ }
+ return false;
}
}
diff --git a/media/css/A4.print.css b/media/css/A4.print.css
index bf59d62..9c7a6e2 100644
--- a/media/css/A4.print.css
+++ b/media/css/A4.print.css
@@ -1,7 +1,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/membersmanager.xml b/membersmanager.xml
index 5d5c218..4e58325 100644
--- a/membersmanager.xml
+++ b/membersmanager.xml
@@ -1,20 +1,20 @@
COM_MEMBERSMANAGER
- 26th September, 2018
+ 27th December, 2018
Llewellyn van der Merwe
llewellyn@joomlacomponentbuilder.com
https://www.joomlacomponentbuilder.com/
Copyright (C) 2015. All Rights Reserved
GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
- 2.0.1
+ 2.0.6
Members Manager (v.2.0.1)
+ Members Manager (v.2.0.6)
A [Members manager](https://github.com/vdm-io/Joomla-Members-Manager) to use as a base for any kind of project that needs user integration. You can with much ease adapt it using the [JCB package](https://github.com/vdm-io/JCB-Community-Packages/raw/master/JCB_membersManager.zip).
Watch this [tutorial](https://youtu.be/lkE0ZiSWufg) to see how.
- Created by Llewellyn van der Merwe Development started 6th September, 2015
+ Created by Llewellyn van der Merwe Development started 6th July, 2018
]]>
diff --git a/membersmanager_server.xml b/membersmanager_server.xml
index f4b87de..4e25eac 100644
--- a/membersmanager_server.xml
+++ b/membersmanager_server.xml
@@ -152,4 +152,89 @@
https://www.joomlacomponentbuilder.com/
+
+ Members Manager
+ Members Manager
+ com_membersmanager
+ component
+ 2.0.2
+ https://www.joomlacomponentbuilder.com/
+
+ https://github.com/vdm-io/Joomla-Members-Manager/releases/download/v2.0.6/JMM_v2.0.6.zip
+
+
+ stable
+
+ Llewellyn van der Merwe
+ https://www.joomlacomponentbuilder.com/
+
+
+
+ Members Manager
+ Members Manager
+ com_membersmanager
+ component
+ 2.0.3
+ https://www.joomlacomponentbuilder.com/
+
+ https://github.com/vdm-io/Joomla-Members-Manager/releases/download/v2.0.6/JMM_v2.0.6.zip
+
+
+ stable
+
+ Llewellyn van der Merwe
+ https://www.joomlacomponentbuilder.com/
+
+
+
+ Members Manager
+ Members Manager
+ com_membersmanager
+ component
+ 2.0.4
+ https://www.joomlacomponentbuilder.com/
+
+ https://github.com/vdm-io/Joomla-Members-Manager/releases/download/v2.0.6/JMM_v2.0.6.zip
+
+
+ stable
+
+ Llewellyn van der Merwe
+ https://www.joomlacomponentbuilder.com/
+
+
+
+ Members Manager
+ Members Manager
+ com_membersmanager
+ component
+ 2.0.5
+ https://www.joomlacomponentbuilder.com/
+
+ https://github.com/vdm-io/Joomla-Members-Manager/releases/download/v2.0.6/JMM_v2.0.6.zip
+
+
+ stable
+
+ Llewellyn van der Merwe
+ https://www.joomlacomponentbuilder.com/
+
+
+
+ Members Manager
+ Members Manager
+ com_membersmanager
+ component
+ 2.0.6
+ https://www.joomlacomponentbuilder.com/
+
+ https://github.com/vdm-io/Joomla-Members-Manager/releases/download/v2.0.6/JMM_v2.0.6.zip
+
+
+ stable
+
+ Llewellyn van der Merwe
+ https://www.joomlacomponentbuilder.com/
+
+
\ No newline at end of file
diff --git a/script.php b/script.php
index ded601f..eaaddb8 100644
--- a/script.php
+++ b/script.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -42,6 +42,168 @@ class com_membersmanagerInstallerScript
// Get The Database object
$db = JFactory::getDbo();
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ // Select ids from fields
+ $query->select($db->quoteName('id'));
+ $query->from($db->quoteName('#__fields'));
+ // Where member context is found
+ $query->where( $db->quoteName('context') . ' = '. $db->quote('com_membersmanager.member') );
+ $db->setQuery($query);
+ // Execute query to see if context is found
+ $db->execute();
+ $member_found = $db->getNumRows();
+ // Now check if there were any rows
+ if ($member_found)
+ {
+ // Since there are load the needed member field ids
+ $member_field_ids = $db->loadColumn();
+ // Remove member from the field table
+ $member_condition = array( $db->quoteName('context') . ' = '. $db->quote('com_membersmanager.member') );
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ $query->delete($db->quoteName('#__fields'));
+ $query->where($member_condition);
+ $db->setQuery($query);
+ // Execute the query to remove member items
+ $member_done = $db->execute();
+ if ($member_done)
+ {
+ // If succesfully remove member add queued success message.
+ $app->enqueueMessage(JText::_('The fields with type (com_membersmanager.member) context was removed from the #__fields table'));
+ }
+ // Also Remove member field values
+ $member_condition = array( $db->quoteName('field_id') . ' IN ('. implode(',', $member_field_ids) .')');
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ $query->delete($db->quoteName('#__fields_values'));
+ $query->where($member_condition);
+ $db->setQuery($query);
+ // Execute the query to remove member field values
+ $member_done = $db->execute();
+ if ($member_done)
+ {
+ // If succesfully remove member add queued success message.
+ $app->enqueueMessage(JText::_('The fields values for member was removed from the #__fields_values table'));
+ }
+ }
+
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ // Select ids from field groups
+ $query->select($db->quoteName('id'));
+ $query->from($db->quoteName('#__fields_groups'));
+ // Where member context is found
+ $query->where( $db->quoteName('context') . ' = '. $db->quote('com_membersmanager.member') );
+ $db->setQuery($query);
+ // Execute query to see if context is found
+ $db->execute();
+ $member_found = $db->getNumRows();
+ // Now check if there were any rows
+ if ($member_found)
+ {
+ // Remove member from the field groups table
+ $member_condition = array( $db->quoteName('context') . ' = '. $db->quote('com_membersmanager.member') );
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ $query->delete($db->quoteName('#__fields_groups'));
+ $query->where($member_condition);
+ $db->setQuery($query);
+ // Execute the query to remove member items
+ $member_done = $db->execute();
+ if ($member_done)
+ {
+ // If succesfully remove member add queued success message.
+ $app->enqueueMessage(JText::_('The field groups with type (com_membersmanager.member) context was removed from the #__fields_groups table'));
+ }
+ }
+
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ // Select id from content type table
+ $query->select($db->quoteName('type_id'));
+ $query->from($db->quoteName('#__content_types'));
+ // Where member alias is found
+ $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_membersmanager.member') );
+ $db->setQuery($query);
+ // Execute query to see if alias is found
+ $db->execute();
+ $member_found = $db->getNumRows();
+ // Now check if there were any rows
+ if ($member_found)
+ {
+ // Since there are load the needed member type ids
+ $member_ids = $db->loadColumn();
+ // Remove member from the content type table
+ $member_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_membersmanager.member') );
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ $query->delete($db->quoteName('#__content_types'));
+ $query->where($member_condition);
+ $db->setQuery($query);
+ // Execute the query to remove member items
+ $member_done = $db->execute();
+ if ($member_done)
+ {
+ // If succesfully remove member add queued success message.
+ $app->enqueueMessage(JText::_('The (com_membersmanager.member) type alias was removed from the #__content_type table'));
+ }
+
+ // Remove member items from the contentitem tag map table
+ $member_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_membersmanager.member') );
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ $query->delete($db->quoteName('#__contentitem_tag_map'));
+ $query->where($member_condition);
+ $db->setQuery($query);
+ // Execute the query to remove member items
+ $member_done = $db->execute();
+ if ($member_done)
+ {
+ // If succesfully remove member add queued success message.
+ $app->enqueueMessage(JText::_('The (com_membersmanager.member) type alias was removed from the #__contentitem_tag_map table'));
+ }
+
+ // Remove member items from the ucm content table
+ $member_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_membersmanager.member') );
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ $query->delete($db->quoteName('#__ucm_content'));
+ $query->where($member_condition);
+ $db->setQuery($query);
+ // Execute the query to remove member items
+ $member_done = $db->execute();
+ if ($member_done)
+ {
+ // If succesfully remove member add queued success message.
+ $app->enqueueMessage(JText::_('The (com_membersmanager.member) type alias was removed from the #__ucm_content table'));
+ }
+
+ // Make sure that all the member items are cleared from DB
+ foreach ($member_ids as $member_id)
+ {
+ // Remove member items from the ucm base table
+ $member_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $member_id);
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ $query->delete($db->quoteName('#__ucm_base'));
+ $query->where($member_condition);
+ $db->setQuery($query);
+ // Execute the query to remove member items
+ $db->execute();
+
+ // Remove member items from the ucm history table
+ $member_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $member_id);
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ $query->delete($db->quoteName('#__ucm_history'));
+ $query->where($member_condition);
+ $db->setQuery($query);
+ // Execute the query to remove member items
+ $db->execute();
+ }
+ }
+
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
@@ -305,7 +467,7 @@ class com_membersmanagerInstallerScript
$member->table = '{"special": {"dbtable": "#__membersmanager_member","key": "id","type": "Member","prefix": "membersmanagerTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$member->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","email":"email","account":"account","user":"user","token":"token","profile_image":"profile_image","not_required":"not_required","main_member":"main_member","password_check":"password_check","password":"password","useremail":"useremail","username":"username","surname":"surname","type":"type"}}';
$member->router = 'MembersmanagerHelperRoute::getMemberRoute';
- $member->content_history_options = '{"formFile": "administrator/components/com_membersmanager/models/forms/member.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","profile_image","not_required"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","account","user","main_member","type"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "user","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "main_member","targetTable": "#__membersmanager_member","targetColumn": "id","displayColumn": "user"},{"sourceColumn": "type","targetTable": "#__membersmanager_type","targetColumn": "id","displayColumn": "name"}]}';
+ $member->content_history_options = '{"formFile": "administrator/components/com_membersmanager/models/forms/member.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","profile_image","not_required"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","account","user","main_member"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "user","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "main_member","targetTable": "#__membersmanager_member","targetColumn": "id","displayColumn": "user"},{"sourceColumn": "type","targetTable": "#__membersmanager_type","targetColumn": "id","displayColumn": "name"}]}';
// Set the object into the content types table.
$member_Inserted = $db->insertObject('#__content_types', $member);
@@ -315,9 +477,9 @@ class com_membersmanagerInstallerScript
$type->type_title = 'Membersmanager Type';
$type->type_alias = 'com_membersmanager.type';
$type->table = '{"special": {"dbtable": "#__membersmanager_type","key": "id","type": "Type","prefix": "membersmanagerTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
- $type->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","groups_target":"groups_target","groups_access":"groups_access","alias":"alias"}}';
+ $type->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","groups_target":"groups_target","groups_access":"groups_access","add_relationship":"add_relationship","field_type":"field_type","communicate":"communicate","view_relationship":"view_relationship","edit_relationship":"edit_relationship","type":"type","alias":"alias"}}';
$type->router = 'MembersmanagerHelperRoute::getTypeRoute';
- $type->content_history_options = '{"formFile": "administrator/components/com_membersmanager/models/forms/type.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
+ $type->content_history_options = '{"formFile": "administrator/components/com_membersmanager/models/forms/type.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","add_relationship","field_type","communicate"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "view_relationship","targetTable": "#__membersmanager_type","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "edit_relationship","targetTable": "#__membersmanager_type","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "type","targetTable": "#__membersmanager_type","targetColumn": "id","displayColumn": "name"}]}';
// Set the object into the content types table.
$type_Inserted = $db->insertObject('#__content_types', $type);
@@ -327,7 +489,7 @@ class com_membersmanagerInstallerScript
$query = $db->getQuery(true);
// Field to update.
$fields = array(
- $db->quoteName('rules') . ' = ' . $db->quote('{"site.cpanel.access":{"1":1}}'),
+ $db->quoteName('rules') . ' = ' . $db->quote('{"site.members.access":{"1":1}}'),
);
// Condition.
$conditions = array(
@@ -341,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","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","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":""}'),
);
// Condition.
$conditions = array(
@@ -369,7 +531,7 @@ class com_membersmanagerInstallerScript
$member->table = '{"special": {"dbtable": "#__membersmanager_member","key": "id","type": "Member","prefix": "membersmanagerTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$member->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","email":"email","account":"account","user":"user","token":"token","profile_image":"profile_image","not_required":"not_required","main_member":"main_member","password_check":"password_check","password":"password","useremail":"useremail","username":"username","surname":"surname","type":"type"}}';
$member->router = 'MembersmanagerHelperRoute::getMemberRoute';
- $member->content_history_options = '{"formFile": "administrator/components/com_membersmanager/models/forms/member.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","profile_image","not_required"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","account","user","main_member","type"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "user","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "main_member","targetTable": "#__membersmanager_member","targetColumn": "id","displayColumn": "user"},{"sourceColumn": "type","targetTable": "#__membersmanager_type","targetColumn": "id","displayColumn": "name"}]}';
+ $member->content_history_options = '{"formFile": "administrator/components/com_membersmanager/models/forms/member.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","profile_image","not_required"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","account","user","main_member"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "user","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "main_member","targetTable": "#__membersmanager_member","targetColumn": "id","displayColumn": "user"},{"sourceColumn": "type","targetTable": "#__membersmanager_type","targetColumn": "id","displayColumn": "name"}]}';
// Check if member type is already in content_type DB.
$member_id = null;
@@ -396,9 +558,9 @@ class com_membersmanagerInstallerScript
$type->type_title = 'Membersmanager Type';
$type->type_alias = 'com_membersmanager.type';
$type->table = '{"special": {"dbtable": "#__membersmanager_type","key": "id","type": "Type","prefix": "membersmanagerTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
- $type->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","groups_target":"groups_target","groups_access":"groups_access","alias":"alias"}}';
+ $type->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","groups_target":"groups_target","groups_access":"groups_access","add_relationship":"add_relationship","field_type":"field_type","communicate":"communicate","view_relationship":"view_relationship","edit_relationship":"edit_relationship","type":"type","alias":"alias"}}';
$type->router = 'MembersmanagerHelperRoute::getTypeRoute';
- $type->content_history_options = '{"formFile": "administrator/components/com_membersmanager/models/forms/type.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
+ $type->content_history_options = '{"formFile": "administrator/components/com_membersmanager/models/forms/type.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","add_relationship","field_type","communicate"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "view_relationship","targetTable": "#__membersmanager_type","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "edit_relationship","targetTable": "#__membersmanager_type","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "type","targetTable": "#__membersmanager_type","targetColumn": "id","displayColumn": "name"}]}';
// Check if type type is already in content_type DB.
$type_id = null;
@@ -424,7 +586,7 @@ class com_membersmanagerInstallerScript
echo '
- Upgrade to Version 2.0.1 Was Successful! Let us know if anything is not working as expected.';
+ Upgrade to Version 2.0.6 Was Successful! Let us know if anything is not working as expected.';
}
}
}
diff --git a/site/assets/css/cpanel.css b/site/assets/css/cpanel.css
index 026520f..3a84864 100644
--- a/site/assets/css/cpanel.css
+++ b/site/assets/css/cpanel.css
@@ -1,7 +1,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/assets/css/member.css b/site/assets/css/member.css
index 58d7189..095d0de 100644
--- a/site/assets/css/member.css
+++ b/site/assets/css/member.css
@@ -1,7 +1,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/assets/css/members.css b/site/assets/css/members.css
new file mode 100644
index 0000000..3a84864
--- /dev/null
+++ b/site/assets/css/members.css
@@ -0,0 +1,13 @@
+/**
+ * @package Joomla.Members.Manager
+ *
+ * @created 6th July, 2018
+ * @author Llewellyn van der Merwe
+ * @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
+ */
+
+/* CSS Document */
+
+
diff --git a/site/assets/css/profile.css b/site/assets/css/profile.css
index 026520f..3a84864 100644
--- a/site/assets/css/profile.css
+++ b/site/assets/css/profile.css
@@ -1,7 +1,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/assets/css/site.css b/site/assets/css/site.css
index 7a19d60..f293af0 100644
--- a/site/assets/css/site.css
+++ b/site/assets/css/site.css
@@ -1,7 +1,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/assets/js/cpanel.js b/site/assets/js/cpanel.js
index e365442..1e27599 100644
--- a/site/assets/js/cpanel.js
+++ b/site/assets/js/cpanel.js
@@ -1,7 +1,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/assets/js/profile.js b/site/assets/js/profile.js
index 3d4cff9..2032c92 100644
--- a/site/assets/js/profile.js
+++ b/site/assets/js/profile.js
@@ -1,7 +1,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -58,4 +58,19 @@ function setReport(data) {
jQuery('.setreport').html(data);
// hide spinner
jQuery('.report-spinner').hide();
-}
\ No newline at end of file
+}
+// load chart in modal
+function loadTheChartInModal(callback, targetDivID){
+ // remove old data and add spinner
+ jQuery('.setreport').html('');
+ jQuery('.report-spinner').show();
+ // add new div
+ jQuery('.setreport').html('Print ');
+ // allow modal to open
+ setTimeout(function() {
+ // hide spinner
+ jQuery('.report-spinner').hide();
+ // run call back
+ callback();
+ }, 800);
+}
\ No newline at end of file
diff --git a/site/assets/js/site.js b/site/assets/js/site.js
index f6daf95..16c13ac 100644
--- a/site/assets/js/site.js
+++ b/site/assets/js/site.js
@@ -1,7 +1,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/controller.php b/site/controller.php
index 9759f9e..3525ae9 100644
--- a/site/controller.php
+++ b/site/controller.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -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', 'cpanel');
+ $view = $this->input->getCmd('view', 'members');
$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=cpanel', false));
+ $this->setRedirect(JRoute::_('index.php?option=com_membersmanager&view=members', false));
}
return false;
}
diff --git a/site/controllers/ajax.json.php b/site/controllers/ajax.json.php
index 5e92ef9..dbfdad3 100644
--- a/site/controllers/ajax.json.php
+++ b/site/controllers/ajax.json.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -27,9 +27,11 @@ class MembersmanagerControllerAjax extends JControllerLegacy
// load the tasks
$this->registerTask('checkUnique', 'ajax');
$this->registerTask('getPlaceHolders', 'ajax');
+ $this->registerTask('getAnyPlaceHolders', 'ajax');
$this->registerTask('uploadfile', 'ajax');
$this->registerTask('removeFile', 'ajax');
$this->registerTask('getUserDetails', 'ajax');
+ $this->registerTask('getChartImageLink', 'ajax');
$this->registerTask('searchMembers', 'ajax');
$this->registerTask('getReport', 'ajax');
}
@@ -123,6 +125,44 @@ class MembersmanagerControllerAjax extends JControllerLegacy
}
}
break;
+ case 'getAnyPlaceHolders':
+ try
+ {
+ $returnRaw = $jinput->get('raw', false, 'BOOLEAN');
+ $getTypeValue = $jinput->get('getType', NULL, 'WORD');
+ if($getTypeValue && $user->id != 0)
+ {
+ $result = $this->getModel('ajax')->getAnyPlaceHolders($getTypeValue);
+ }
+ 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;
case 'uploadfile':
try
{
@@ -241,6 +281,44 @@ class MembersmanagerControllerAjax extends JControllerLegacy
}
}
break;
+ case 'getChartImageLink':
+ try
+ {
+ $returnRaw = $jinput->get('raw', false, 'BOOLEAN');
+ $imageValue = $jinput->get('image', NULL, 'STRING');
+ if($imageValue && $user->id != 0)
+ {
+ $result = $this->getModel('ajax')->getChartImageLink($imageValue);
+ }
+ 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;
case 'searchMembers':
try
{
diff --git a/site/controllers/member.php b/site/controllers/member.php
index 63ce8a6..bb5d6b2 100644
--- a/site/controllers/member.php
+++ b/site/controllers/member.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -35,7 +35,7 @@ class MembersmanagerControllerMember extends JControllerForm
*/
public function __construct($config = array())
{
- $this->view_list = 'cpanel'; // safeguard for setting the return view listing to the default site view.
+ $this->view_list = 'members'; // safeguard for setting the return view listing to the default site view.
parent::__construct($config);
}
@@ -316,7 +316,17 @@ class MembersmanagerControllerMember extends JControllerForm
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
// safe all dynamic values (that has been posted)
- MembersmanagerHelper::saveDynamicValues($validData, 'member');
+ if (isset($validData['id']))
+ {
+ MembersmanagerHelper::saveDynamicValues($validData, 'member');
+ // always sync the type with the type_map
+ if (isset($validData['type']))
+ {
+ MembersmanagerHelper::updateTypes($validData['id'], $validData['type']);
+ }
+ // safe all set relationships
+ MembersmanagerHelper::saveRelationships($validData);
+ }
return;
}
diff --git a/site/helpers/category.php b/site/helpers/category.php
index 2dcbbf1..c3f7bd4 100644
--- a/site/helpers/category.php
+++ b/site/helpers/category.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/helpers/headercheck.php b/site/helpers/headercheck.php
index 4c1d712..b380a0d 100644
--- a/site/helpers/headercheck.php
+++ b/site/helpers/headercheck.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/helpers/membersmanager.php b/site/helpers/membersmanager.php
index 71076c2..9e41834 100644
--- a/site/helpers/membersmanager.php
+++ b/site/helpers/membersmanager.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -33,57 +33,19 @@ abstract class MembersmanagerHelper
protected static $params;
/**
- * Get placeholders
- *
- * @param string $type The type of placeholders to return
- *
- * @return array
- *
- */
- public static function getPlaceHolders($type)
- {
- if ('document' === $type)
- {
- // get company placeholders
- if (($company = self::getCompanyDetails('placeholder')) !== false && self::checkArray($company))
- {
- // just remove the footer and header placeholders
- unset($company['[company_doc_header]']);
- unset($company['[company_doc_footer]']);
- $placeholders = array_keys($company);
- return $placeholders;
- }
- }
- return false;
- }
+ * the button names
+ **/
+ protected static $buttonNames = array();
/**
- * Add Join Tables based on filter
- *
- * @param object $query The database query object
- * @param string $filter The target area that made the request
- *
- * @return array
- *
- */
- protected static function joinMemberDetails(&$query, $filter = 'none', $db = null)
- {
- // check if we have the DB object
- if (!self::checkObject($db))
- {
- // get the database object
- $db = JFactory::getDBO();
- }
- if ('none' === $filter)
- {
- // From the users table.
- $query->join('LEFT', $db->quoteName('#__users', 'u') . ' ON (' . $db->quoteName('a.user') . ' = ' . $db->quoteName('u.id') . ')');
- // From the membersmanager_member table.
- $query->join('LEFT', $db->quoteName('#__membersmanager_member', 'm') . ' ON (' . $db->quoteName('a.main_member') . ' = ' . $db->quoteName('m.id') . ')');
- // From the membersmanager_type table.
- $query->join('LEFT', $db->quoteName('#__membersmanager_type', 't') . ' ON (' . $db->quoteName('a.type') . ' = ' . $db->quoteName('t.id') . ')');
- }
- }
+ * the opener
+ **/
+ protected static $opener;
+
+ /**
+ * the return here path
+ **/
+ protected static $return_here;
/**
* Get selection based on type
@@ -98,16 +60,47 @@ abstract class MembersmanagerHelper
*/
protected static function getSelection($table = 'member', $method = 'placeholder', $filter = 'none', $db = null)
{
+ // get the global settings
+ if (!self::checkObject(self::$params))
+ {
+ self::$params = JComponentHelper::getParams('com_membersmanager');
+ }
// prep for placeholders
$f = '';
$b = '';
if ('placeholder' === $method)
{
- $f = '[member_';
+ // get the placeholder prefix
+ $prefix = self::$params->get('placeholder_prefix', 'membersmanager');
+ $f = '[' . $prefix . '_';
$b = ']';
}
+ // get charts
+ if ('chart' !== $filter && 'field' !== $filter && method_exists(__CLASS__, 'getAnyAvailableCharts') && method_exists(__CLASS__, 'getAllComponents'))
+ {
+ if (($components = self::getAllComponents(null, array('Assessment'))) !== false && self::checkArray($components))
+ {
+ // Chart Target Types
+ $targets = array(2,3);
+ // load per component
+ foreach ($targets as $target)
+ {
+ foreach ($components as $component)
+ {
+ if (($data = self::getAnyAvailableCharts(null, $target, $component->element)) !== false && self::checkArray($data))
+ {
+ $com = str_replace('com_', '', $component->element);
+ foreach ($data as $key => $chartData)
+ {
+ $charts[$key . '\^/' . $component->element . '\^/' . $target] = $com . '_' . $key;
+ }
+ }
+ }
+ }
+ }
+ }
// only get what we need
- if ('none' === $filter)
+ if ('email' === $filter || 'report' === $filter)
{
// check if we have the DB object
if (!self::checkObject($db))
@@ -127,27 +120,505 @@ abstract class MembersmanagerHelper
// prep the columns
$columns = array_keys($columns);
}
- // convert the columns for query selection
- $selection = array();
- foreach ($columns as $column)
+ // check if we have columns
+ if (isset($columns) && self::checkArray($columns))
{
- $selection['a.' . $column] = $f . $column . $b;
+ // convert the columns for query selection
+ $selection = array();
+ foreach ($columns as $column)
+ {
+ $selection['a.' . $column] = $f . $column . $b;
+ // we must add the params
+ if ('profile' !== $filter && 'field' !== $filter)
+ {
+ // set the label for these fields
+ $selection['setLabel->' . $column] = $f . 'label_' . $column . $b;
+ }
+ }
+ // needed values
+ if ('member' === $table)
+ {
+ // set names and emails
+ $selection['setMemberName:id|user|name|surname'] = $f . 'name' . $b;
+ $selection['setMemberEmail:id|user|email'] = $f . 'email' . $b;
+ $selection['setMemberName:created_by|user'] = $f . 'created_name' . $b;
+ $selection['setMemberEmail:created_by|user'] = $f . 'created_email' . $b;
+ $selection['setMemberName:modified_by|user'] = $f . 'modified_name' . $b;
+ $selection['setMemberEmail:modified_by|user'] = $f . 'modified_email' . $b;
+ // get name and email
+ $selection['getMemberName:main_member'] = $f . 'main_name' . $b;
+ $selection['getMemberEmail:main_member'] = $f . 'main_email' . $b;
+ // set fancy dates
+ $selection['fancyDate:created'] = $f . 'created' . $b;
+ $selection['fancyDate:modified'] = $f . 'modified' . $b;
+ // set profile image
+ $selection['setImageLink:profile_image|name'] = $f . 'profile_image_url' . $b;
+ $selection['setImageHTML:profile_image_url|name'] = $f . 'profile_image_html' . $b;
+ // set profile
+ $selection['setProfileLink:id|token'] = $f . 'profile_link_url' . $b;
+ // set the return value
+ self::$return_here = urlencode(base64_encode((string) JUri::getInstance()));
+ // set edit link
+ $selection['setMemberEditURL:id|created_by'] = $f . 'edit_url' . $b;
+ // Get the medium encryption.
+ $mediumkey = MembersmanagerHelper::getCryptKey('medium');
+ if ($mediumkey)
+ {
+ // Get the encryption object.
+ self::$opener = new FOFEncryptAes($mediumkey);
+ }
+ }
+ // add the chart div and JS code (only if filter is not chart)
+ if ('chart' !== $filter && 'field' !== $filter && isset($charts) && self::checkArray($charts))
+ {
+ foreach ($charts as $chart => $value)
+ {
+ // make sure the chart name is save
+ $selection['setMultiChart->' . $chart] = $f . $value . $b;
+ }
+ }
+ return $selection;
}
- // add joined values if needed (based on filter)
- if ('member' === $table && 'none' === $filter)
- {
- $selection['u.name'] = $f . 'user_name' . $b;
- $selection['u.email'] = $f . 'user_email' . $b;
- $selection['t.name'] = $f . 'type_name' . $b;
- $selection['m.user'] = $f . 'main_user' . $b;
- $selection['m.name'] = $f . 'main_name' . $b;
- $selection['m.email'] = $f . 'main_email' . $b;
- }
- return $selection;
+ return false;
}
/**
- * Get a user Access Types
+ * set image HTML
+ **/
+ protected static function setImageHTML($object)
+ {
+ return '';
+ }
+
+ /**
+ * set image link
+ **/
+ protected static function setImageLink($item)
+ {
+ if (self::checkObject(self::$opener) && ($image = $item->get('profile_image', false)) !== false && !is_numeric($image) && $image === base64_encode(base64_decode($image, true)))
+ {
+ // now unlock
+ $item->set('profile_image', rtrim(self::$opener->decryptString($image), "\0"));
+ }
+ // get link
+ return self::getImageLink($item, 'profile_image', 'name', null, false);
+ }
+
+ /**
+ * set member edit url
+ **/
+ protected static function setMemberEditURL($item)
+ {
+ if (($url = self::getEditURL($item, 'member', 'members', '&return=' . self::$return_here)) !== false)
+ {
+ return $url;
+ }
+ return '';
+ }
+
+ /**
+ * set profile link
+ **/
+ 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);
+ }
+
+ /**
+ * set member name
+ **/
+ protected static function setMemberName($object)
+ {
+ // check if this is a created by or modified by
+ if (($user = $object->get('created_by', false)) !== false || ($user = $object->get('modified_by', false)) !== false )
+ {
+ $object->set('user', $user);
+ }
+ return self::getMemberName($object->get('id', null), $object->get('user', null), $object->get('name', null), $object->get('surname', null));
+ }
+
+ /**
+ * set member email
+ **/
+ protected static function setMemberEmail($object)
+ {
+ // check if this is a created by or modified by
+ if (($user = $object->get('created_by', false)) !== false || ($user = $object->get('modified_by', false)) !== false )
+ {
+ $object->set('user', $user);
+ }
+ return self::getMemberEmail($object->get('id', null), $object->get('user', null), $object->get('email', null));
+ }
+
+ /**
+ * set the session defaults if not set
+ **/
+ protected static function setSessionDefaults()
+ {
+ // noting for now
+ return true;
+ }
+
+ /**
+ * get button name
+ **/
+ public static function getButtonName($type, $default)
+ {
+ if (!isset(self::$buttonNames[$type]))
+ {
+ // get the global settings
+ if (!self::checkObject(self::$params))
+ {
+ self::$params = JComponentHelper::getParams('com_membersmanager');
+ }
+ // get the button name
+ self::$buttonNames[$type] = self::$params->get('button_'. $type . '_name', $default);
+ }
+ return self::$buttonNames[$type];
+ }
+
+ /**
+ * check if the communication component is set (and get key value)
+ **/
+ public static function communicate($key = null, $default = false, $return = null)
+ {
+ if (JComponentHelper::isInstalled('com_communicate') && JComponentHelper::isEnabled('com_communicate'))
+ {
+ // check if looking for create_url
+ if ($key && 'create_url' === $key)
+ {
+ $_return = urlencode(base64_encode((string) JUri::getInstance()));
+ if ($return)
+ {
+ return self::getCreateURL('message', 'message', $return . '&return=' . $_return, 'com_communicate');
+ }
+ return self::getCreateURL('message', 'message', '&return=' . $_return, 'com_communicate');
+ }
+ // get the global settings of com_communicate (singleton)
+ $params = JComponentHelper::getParams('com_communicate');
+ // return the key value
+ if ($key)
+ {
+ return $params->get($key, $default);
+ }
+ return $params;
+ }
+ return $default;
+ }
+
+ /**
+ * remove all groups that are part of target groups in the member types
+ **/
+ public static function removeMemberGroups(&$groups)
+ {
+ if (self::checkArray($groups))
+ {
+ // get database object
+ $db = JFactory::getDBO();
+ $query = $db->getQuery(true);
+ $query->select(array('a.id'));
+ $query->from('#__membersmanager_type AS a');
+ $db->setQuery($query);
+ $db->execute();
+ // get all types
+ $types = $db->loadColumn();
+ // now get all target groups
+ $groups_target = self::getMemberGroupsByType($types, 'groups_target');
+ // now update the groups
+ $groups = array_diff($groups, $groups_target);
+ }
+ }
+
+ /**
+ * Get any placeholders
+ *
+ * @param string $component The component placeholders to return
+ * @param string $type The type of placeholders to return
+ * @param bool $addCompany The switch to add the company
+ *
+ * @return array
+ *
+ */
+ public static function getAnyPlaceHolders($_component, $type = 'report', $addCompany = false)
+ {
+ // check if we are in the correct class
+ if ('com_membersmanager' !== $_component)
+ {
+ // check if the class and method exist
+ if (($helperClass = self::getHelperClass($_component)) !== false && method_exists($helperClass, 'getPlaceHolders'))
+ {
+ return $helperClass::getPlaceHolders($type, $addCompany);
+ }
+ }
+ // check if the class and method exist
+ elseif (method_exists(__CLASS__, 'getPlaceHolders'))
+ {
+ return self::getPlaceHolders($type, $addCompany, 'member');
+ }
+ return false;
+ }
+
+
+ /**
+ * Get placeholders
+ *
+ * @param string $type The type of placeholders to return
+ * @param bool $addCompany The switch to add the company
+ * @param string $table The table being targeted
+ *
+ * @return array
+ *
+ */
+ public static function getPlaceHolders($type = 'report', $addCompany = false, $table = 'form')
+ {
+ // start loading the placeholders
+ $placeholders = array();
+ if (method_exists(__CLASS__, 'getSelection'))
+ {
+ // get form placeholders
+ if (('report' === $type || 'chart' === $type) && ($form = self::getSelection($table, 'placeholder', $type)) !== false && self::checkArray($form))
+ {
+ // always remove params, since it should never be used in placeholders
+ unset($form['a.params']);
+ // be sure to sort the array
+ sort($form);
+ // and remove duplicates
+ $form = array_unique(array_values($form));
+ // check if company should be added
+ if ($addCompany)
+ {
+ $placeholders[] = $form;
+ }
+ else
+ {
+ return $form;
+ }
+ }
+ }
+ // get company placeholders
+ if (('document' === $type || $addCompany) && method_exists(__CLASS__, 'getAnyCompanyDetails') && ($company = self::getAnyCompanyDetails('com_membersmanager', 'placeholder')) !== false && self::checkArray($company))
+ {
+ if ('document' === $type)
+ {
+ // just remove the footer and header placeholders
+ unset($company['[company_doc_header]']);
+ unset($company['[company_doc_footer]']);
+ }
+ $placeholders[] = array_keys($company);
+ }
+ // check that we have placeholders
+ if (self::checkArray($placeholders))
+ {
+ return self::mergeArrays($placeholders);
+ }
+ return false;
+ }
+
+
+ /**
+ * The Type Members Memory
+ *
+ * @var array
+ */
+ protected static $typeMembers = array();
+
+ /**
+ * get members by type
+ *
+ * @param int/array $id The Type ID
+ * @param object $db Database object
+ *
+ * @return array of member IDs
+ *
+ */
+ public static function getMembersByType(&$id, $db)
+ {
+ // if the id is an array
+ if (self::checkArray($id))
+ {
+ $members = array();
+ foreach ($id as $_id)
+ {
+ if (($_members = self::getMembersByType($_id, $db)) !== false)
+ {
+ $members[] = $_members;
+ }
+ }
+ return self::mergeArrays($members);
+ }
+ // check if we already have the members set by type
+ if (!self::checkArray(self::$typeMembers) || !isset(self::$typeMembers[$id]) || !self::checkArray(self::$typeMembers[$id]))
+ {
+ // check that we have the database object
+ if (!$db)
+ {
+ // get DB
+ $db = JFactory::getDBO();
+ }
+ // get types that allow relationships
+ $query = $db->getQuery(true);
+ $query->select('a.member');
+ $query->from('#__membersmanager_type_map AS a');
+ $query->where('a.type = ' . (int) $id);
+ $query->where('a.member > 0');
+ $db->setQuery($query);
+ $db->execute();
+ // only continue if we have member types
+ if (($members = $db->loadColumn()) !== false && self::checkArray($members))
+ {
+ self::$typeMembers[$id] = $members;
+ }
+ }
+ // check if we found member types
+ if (self::checkArray(self::$typeMembers) && isset(self::$typeMembers[$id]) && self::checkArray(self::$typeMembers[$id]))
+ {
+ return self::$typeMembers[$id];
+ }
+ return false;
+ }
+
+
+ /**
+ * get the relationships by types
+ *
+ * @param object $member_types Member Types
+ * @param object $db Database object
+ * @param bool $filter_edit Switch to filter by edit relationship
+ * @param bool $filter_view Switch to filter by view relationship
+ * @param bool $load_members Switch to load the members of the types
+ *
+ * @return array
+ *
+ */
+ public static function getRelationshipsByTypes(&$member_types, $db, $filter_edit = false, $filter_view = true, $load_members = true)
+ {
+ // little function to get types
+ $getTypes = function($type) { return (isset($type)) ? ((self::checkJson($type)) ? json_decode($type, true) : ((self::checkArray($type)) ? $type : false)) : false; };
+ // get this member types
+ if (($member_types = $getTypes($member_types)) === false || (($user_types = $getTypes(self::getVar('member', JFactory::getUser()->id, 'user', 'type'))) === false || !self::checkArray($user_types) && ($filter_edit || $filter_view)))
+ {
+ return false;
+ }
+ // check that we have the database object
+ if (!$db)
+ {
+ // get DB
+ $db = JFactory::getDBO();
+ }
+ // get types that allow relationships
+ $query = $db->getQuery(true);
+ $query->select(array('a.id', 'a.name', 'a.description', 'a.type', 'a.edit_relationship', 'a.view_relationship', 'a.field_type', 'a.communicate'));
+ $query->from('#__membersmanager_type AS a');
+ $query->where($db->quoteName('a.published') . ' >= 1');
+ $query->where($db->quoteName('a.add_relationship') . ' = 1');
+ $db->setQuery($query);
+ $db->execute();
+ // only continue if we have member types and all relationship types
+ if (($types = $db->loadObjectList('id')) !== false && self::checkArray($types))
+ {
+ // 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; };
+ // the bucket
+ $bucket = array();
+ // get all types related to this member
+ foreach($types as $id => $value)
+ {
+ if (($value->type = $getTypes($value->type)) !== false && $intersect($member_types, $value->type)
+ && (($value->view_relationship = $getTypes($value->view_relationship)) !== false && $intersect($user_types, $value->view_relationship) || !$filter_view)
+ && (($value->edit_relationship = $getTypes($value->edit_relationship)) !== false && $intersect($user_types, $value->edit_relationship) || !$filter_edit))
+ {
+ // set the type
+ $bucket[$id] = $value;
+ if ($load_members)
+ {
+ // now get all members that belong to this type
+ $bucket[$id]->members = self::getMembersByType($id, $db);
+ }
+ }
+ }
+ // return if we found any
+ if (self::checkArray($bucket))
+ {
+ return $bucket;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * get the relationships by member
+ *
+ * @param object $member Member ID
+ * @param object $db Database object
+ * @param string $direction The relationship direction
+ *
+ * @return array
+ *
+ */
+ public static function getRelationshipsByMember(&$member, $db, $direction = 'member')
+ {
+ // always check that we have an ID
+ if (!is_numeric($member) || $member == 0)
+ {
+ return false;
+ }
+ // check that we have the database object
+ if (!$db)
+ {
+ // get DB
+ $db = JFactory::getDBO();
+ }
+ // set the direction relationship
+ $_direction = 'relation';
+ if ('relation' === $direction)
+ {
+ $_direction = 'member';
+ }
+ // get types that allow relationships
+ $query = $db->getQuery(true);
+ $query->select(array('a.' . $_direction, 'a.type'));
+ $query->from('#__membersmanager_relation_map AS a');
+ $query->where($db->quoteName('a.' . $direction) . ' = ' . (int) $member);
+ $db->setQuery($query);
+ $db->execute();
+ // only continue if we have member relationships
+ if (($relationships = $db->loadObjectList()) !== false && self::checkArray($relationships))
+ {
+ // the bucket
+ $bucket = array();
+ // sort by types
+ foreach($relationships as $relationship)
+ {
+ if (!isset($bucket[$relationship->type]))
+ {
+ $bucket[$relationship->type] = array();
+ }
+ // set the type
+ $bucket[$relationship->type][$relationship->{$_direction}] = $relationship->{$_direction};
+ }
+ return $bucket;
+ }
+ return false;
+ }
+
+
+ /**
+ * The Access Memory
+ *
+ * @var array
+ */
+ protected static $accessMemory = array();
+
+ /**
+ * The Key to Access Memory
+ *
+ * @var string
+ */
+ protected static $acK3y;
+
+ /**
+ * Get a user Access Types/Groups
*
* @param mix $id The the user ID/object
* @param int $type The type of access to return (1 = type, 2 = groups)
@@ -158,11 +629,6 @@ abstract class MembersmanagerHelper
*/
public static function getAccess($user = null, $type = 1, $db = null)
{
- // get DB
- if (!$db)
- {
- $db = JFactory::getDBO();
- }
// get user
if (!self::checkObject($user))
{
@@ -175,113 +641,51 @@ abstract class MembersmanagerHelper
$user = JFactory::getUser();
}
}
- // function to setup the group array
- $getGroups = function ($groups) {
- // convert to array
- if (self::checkJson($groups))
+ // check memory first
+ self::$acK3y = md5($user->get('id', 'not_set') . '_' . $type);
+ if (isset(self::$accessMemory[self::$acK3y]))
+ {
+ return self::$accessMemory[self::$acK3y];
+ }
+ // fallback to false
+ self::$accessMemory[self::$acK3y] = false;
+ // get DB
+ if (!$db)
+ {
+ $db = JFactory::getDBO();
+ }
+ // get user Access groups
+ if (2 == $type)
+ {
+ self::$accessMemory[self::$acK3y] = self::getAccessGroups($user, $db);
+ }
+ elseif (1 == $type)
+ {
+ // return access types
+ self::$accessMemory[self::$acK3y] = self::getAccessTypes($user, $db);
+ }
+ return self::$accessMemory[self::$acK3y];
+ }
+
+ /**
+ * Get a user Access Groups
+ *
+ * @param object $user The user object
+ * @param object $db The database object
+ *
+ * @return mix array
+ *
+ */
+ protected static function getAccessGroups(&$user, &$db)
+ {
+ // 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)
{
- return (array) json_decode($groups, true);
- }
- elseif (is_numeric($groups))
- {
- return array($groups);
+ return self::getMemberGroupsByType($types, 'groups_access');
}
return false;
- };
- // merge groups
- $mergeGroups = function ($types) use($getGroups){
- $bucket = array();
- foreach ($types as $id => $groups)
- {
- $groups = $getGroups($groups);
- if (self::checkArray($groups))
- {
- foreach ($groups as $group)
- {
- $bucket[$group] = $group;
- }
- }
- }
- return $bucket;
- };
- // check if access it needed
- if (!$user->authorise('core.admin'))
- {
- // get all types
- $query = $db->getQuery(true);
- $query->select(array('a.id', 'a.groups_access'));
- $query->from('#__membersmanager_type AS a');
- $db->setQuery($query);
- $db->execute();
- // get all types
- $types = $db->loadAssocList('id', 'groups_access');
- if (self::checkArray($types))
- {
- $bucket = array();
- foreach ($types as $id => $groups_access)
- {
- $groups_access = $getGroups($groups_access);
- if (self::checkArray($groups_access) && array_intersect($groups_access, $user->groups))
- {
- $bucket[$id] = $id;
- }
- }
- // return types that this member can access
- if (1 == $type && self::checkArray($bucket))
- {
- return $bucket;
- }
- elseif (self::checkArray($bucket))
- {
- // get the targeted groups
- $query = $db->getQuery(true);
- $query->select(array('a.id', 'a.groups_target'));
- $query->from('#__membersmanager_type AS a');
- $query->where('a.id IN ('. implode(',', $bucket) . ')');
- $db->setQuery($query);
- $db->execute();
- // get all types
- $targettypes = $db->loadAssocList('id', 'groups_target');
- if (self::checkArray($targettypes))
- {
- $targetbucket = $mergeGroups($targettypes);
- // return types that this member can access
- if (self::checkArray($targetbucket))
- {
- return $targetbucket;
- }
- }
- }
- }
- return false;
- }
- // return all types/groups
- $query = $db->getQuery(true);
- if (1 == $type)
- {
- $query->select(array('a.id'));
- }
- else
- {
- $query->select(array('a.id', 'a.groups_target'));
- }
- $query->from('#__membersmanager_type AS a');
- $db->setQuery($query);
- $db->execute();
- if (1 == $type)
- {
- return $db->loadColumn();
- }
- // get all types with group target
- $types = $db->loadAssocList('id', 'groups_target');
- if (self::checkArray($types))
- {
- $bucket = $mergeGroups($types);
- // return types that this member can access
- if (self::checkArray($bucket))
- {
- return $bucket;
- }
}
// return all groups
$query = $db->getQuery(true);
@@ -293,13 +697,131 @@ abstract class MembersmanagerHelper
}
/**
- * set the session defaults if not set
- **/
- protected static function setSessionDefaults()
+ * Get a user Access Types
+ *
+ * @param object $user The user object
+ * @param object $db The database object
+ *
+ * @return mix array
+ *
+ */
+ protected static function getAccessTypes(&$user, &$db)
{
- // noting for now
- return true;
+ // check if access is needed
+ if (!$user->authorise('core.options', 'com_membersmanager'))
+ {
+ // get all types in system
+ $query = $db->getQuery(true);
+ $query->select(array('a.id', 'a.groups_target')); // groups_target = type_link
+ $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('id', 'groups_target');
+ // make sure we have types, and user access groups
+ if (self::checkArray($types) && ($groups_access = self::getAccessGroups($user, $db)) !== false)
+ {
+ // 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 $id => $groups_target)
+ {
+ $groups_target = $setGroups($groups_target);
+ if (self::checkArray($groups_target) && $intersect($groups_target, $groups_access))
+ {
+ $bucketTypes[$id] = $id;
+ }
+ }
+ // check if we found any
+ if (self::checkArray($bucketTypes))
+ {
+ return $bucketTypes;
+ }
+ }
+ return false;
+ }
+ // return all types
+ $query = $db->getQuery(true);
+ $query->select(array('a.id'));
+ $query->from('#__membersmanager_type AS a');
+ $query->where($db->quoteName('a.published') . ' >= 1');
+ $db->setQuery($query);
+ $db->execute();
+ return $db->loadColumn();
}
+
+ /**
+ * Get a user Access Types/Groups
+ *
+ * @param mix $types The member types
+ * @param string $groupType The type of groups
+ *
+ * @return mix array
+ *
+ */
+ public static function getMemberGroupsByType($types, $groupType = 'groups_target')
+ {
+ // convert type json to array
+ if (self::checkJson($types))
+ {
+ $types = json_decode($types, true);
+ }
+ // convert type int to array
+ if (is_numeric($types) && $types > 0)
+ {
+ $types = array($types);
+ }
+ // make sure we have an array
+ if (self::checkArray($types))
+ {
+ $groups = array();
+ foreach ($types as $type)
+ {
+ // get the target groups
+ $groups_target = self::getVar('type', $type, 'id', $groupType);
+ // convert to array
+ if (self::checkJson($groups_target))
+ {
+ $groups_target = (array) json_decode($groups_target, true);
+ }
+ // convert type int to array
+ if (is_numeric($groups_target))
+ {
+ $groups_target = array((int) $groups_target);
+ }
+ // make sure we have an array
+ if (self::checkArray($groups_target))
+ {
+ $groups[] = $groups_target;
+ }
+ }
+ // make sure we have an array
+ if (self::checkArray($groups))
+ {
+ return self::mergeArrays($groups);
+ }
+ }
+ return false;
+ }
+
/**
* Change to nice fancy date
@@ -349,6 +871,30 @@ abstract class MembersmanagerHelper
return date('G:i',$time);
}
+ /**
+ * set the date as 2004/05 (for charts)
+ */
+ public static function setYearMonth($date)
+ {
+ if (!self::isValidTimeStamp($date))
+ {
+ $date = strtotime($date);
+ }
+ return date('Y/m', $date);
+ }
+
+ /**
+ * set the date as 2004/05/03 (for charts)
+ */
+ public static function setYearMonthDay($date)
+ {
+ if (!self::isValidTimeStamp($date))
+ {
+ $date = strtotime($date);
+ }
+ return date('Y/m/d', $date);
+ }
+
/**
* Check if string is a valid time stamp
*/
@@ -358,7 +904,71 @@ abstract class MembersmanagerHelper
&& ($timestamp <= PHP_INT_MAX)
&& ($timestamp >= ~PHP_INT_MAX);
}
-
+
+
+ /**
+ * get between
+ *
+ * @param string $content The content to search
+ * @param string $start The starting value
+ * @param string $end The ending value
+ * @param string $default The default value if none found
+ *
+ * @return string On success / empty string on failure
+ *
+ */
+ public static function getBetween($content, $start, $end, $default = '')
+ {
+ $r = explode($start, $content);
+ if (isset($r[1]))
+ {
+ $r = explode($end, $r[1]);
+ return $r[0];
+ }
+ return $default;
+ }
+
+ /**
+ * get all between
+ *
+ * @param string $content The content to search
+ * @param string $start The starting value
+ * @param string $end The ending value
+ *
+ * @return array On success
+ *
+ */
+ public static function getAllBetween($content, $start, $end)
+ {
+ // reset bucket
+ $bucket = array();
+ for ($i = 0; ; $i++)
+ {
+ // search for string
+ $found = self::getBetween($content,$start,$end);
+ if (self::checkString($found))
+ {
+ // add to bucket
+ $bucket[] = $found;
+ // build removal string
+ $remove = $start.$found.$end;
+ // remove from content
+ $content = str_replace($remove,'',$content);
+ }
+ else
+ {
+ break;
+ }
+ // safety catch
+ if ($i == 500)
+ {
+ break;
+ }
+ }
+ // only return unique array of values
+ return array_unique($bucket);
+ }
+
/**
* the Butler
@@ -388,6 +998,10 @@ abstract class MembersmanagerHelper
**/
public static function set($key, $value)
{
+ if (!isset(self::$session) || !self::checkObject(self::$session))
+ {
+ self::$session = JFactory::getSession();
+ }
// set to local memory to speed up program
self::$localSession[$key] = $value;
// load to session for later use
@@ -399,6 +1013,10 @@ abstract class MembersmanagerHelper
**/
public static function get($key, $default = null)
{
+ if (!isset(self::$session) || !self::checkObject(self::$session))
+ {
+ self::$session = JFactory::getSession();
+ }
// check if in local memory
if (!isset(self::$localSession[$key]))
{
@@ -435,6 +1053,44 @@ abstract class MembersmanagerHelper
}
+ /**
+ * open base64 string if stored as base64
+ *
+ * @param string $data The base64 string
+ * @param string $key We store the string with that suffix :)
+ * @param string $default The default switch
+ *
+ * @return string The opened string
+ *
+ */
+ public static function openValidBase64($data, $key = '__.o0=base64=Oo.__', $default = 'string')
+ {
+ // check that we have a string
+ if (self::checkString($data))
+ {
+ // check if we have a key
+ if (self::checkString($key))
+ {
+ if (strpos($data, $key) !== false)
+ {
+ return base64_decode(str_replace($key, '', $data));
+ }
+ }
+ // fallback to this, not perfect method
+ if (base64_encode(base64_decode($data, true)) === $data)
+ {
+ return base64_decode($data);
+ }
+ }
+ // check if we should just return the string
+ if ('string' === $default)
+ {
+ return $data;
+ }
+ return $default;
+ }
+
+
/**
* the locker
*
@@ -779,26 +1435,53 @@ abstract class MembersmanagerHelper
return $open;
}
+ /**
+ * The Dynamic Data Array
+ *
+ * @var array
+ */
protected static $dynamicData = array();
+ /**
+ * Set the Dynamic Data
+ *
+ * @param string $data The data to update
+ * @param array $placeholders The placeholders to use to update data
+ *
+ * @return string of updated data
+ *
+ */
public static function setDynamicData($data, $placeholders)
{
- $keyMD5 = md5($data.json_encode($placeholders));
- if (!isset(self::$dynamicData[$keyMD5]))
+ // make sure data is a string & placeholders is an array
+ if (self::checkString($data) && self::checkArray($placeholders))
{
- if (self::checkArray($placeholders))
+ // store in memory in case it is build multiple times
+ $keyMD5 = md5($data.json_encode($placeholders));
+ if (!isset(self::$dynamicData[$keyMD5]))
{
+ // remove all values that are not strings (just to be safe)
+ $placeholders = array_filter($placeholders, function ($val){ if (self::checkArray($val) || self::checkObject($val)) { return false; } return true; });
+ // model (basic) based on logic
self::setTheIF($data, $placeholders);
+ // update the string and store in memory
self::$dynamicData[$keyMD5] = str_replace(array_keys($placeholders), array_values($placeholders), $data);
}
- else
- {
- self::$dynamicData[$keyMD5] = $data;
- }
+ // return updated string
+ return self::$dynamicData[$keyMD5];
}
- return self::$dynamicData[$keyMD5];
+ return $data;
}
+ /**
+ * Set the IF statements
+ *
+ * @param string $string The string to update
+ * @param array $placeholders The placeholders to use to update string
+ *
+ * @return void
+ *
+ */
protected static function setTheIF(&$string, $placeholders)
{
// only normal if endif
@@ -843,6 +1526,15 @@ abstract class MembersmanagerHelper
}
}
+ /**
+ * Set the remainder IF
+ *
+ * @param array $match The match search
+ * @param array $placeholders The placeholders to use to match
+ *
+ * @return string of remainder
+ *
+ */
protected static function remainderIF(&$match, &$placeholders)
{
// default we keep nothing
@@ -873,7 +1565,7 @@ abstract class MembersmanagerHelper
{
$keep = addcslashes($match[$length - 1], '$');
}
- return $keep;
+ return $keep;
}
@@ -1148,6 +1840,39 @@ abstract class MembersmanagerHelper
}
+ /**
+ * Write a file to the server
+ *
+ * @param string $path The path and file name where to safe the data
+ * @param string $data The data to safe
+ *
+ * @return bool true On success
+ *
+ */
+ public static function writeFile($path, $data)
+ {
+ $klaar = false;
+ if (self::checkString($data))
+ {
+ // open the file
+ $fh = fopen($path, "w");
+ if (!is_resource($fh))
+ {
+ return $klaar;
+ }
+ // write to the file
+ if (fwrite($fh, $data))
+ {
+ // has been done
+ $klaar = true;
+ }
+ // close file.
+ fclose($fh);
+ }
+ return $klaar;
+ }
+
+
/**
* @return array of link options
*/
@@ -1641,6 +2366,69 @@ abstract class MembersmanagerHelper
return self::$companyDetails[$method];
}
+ /**
+ * Get/load the component helper class if not already loaded
+ *
+ * @param string $_component The component element name
+ *
+ * @return string The helper class name
+ *
+ */
+ public static function getHelperClass($_component)
+ {
+ // make sure we have com_
+ if (strpos($_component, 'com_') !== false)
+ {
+ // get component name
+ $component = str_replace('com_', '', $_component);
+ }
+ else
+ {
+ // get the component name
+ $component = $_component;
+ // set the element name
+ $_component = 'com_' . $component;
+ }
+ // build component helper name
+ $componentHelper = self::safeString($component, 'F') . 'Helper';
+ // check if it is already set
+ if (!class_exists($componentHelper))
+ {
+ // set the correct path focus
+ $focus = JPATH_ADMINISTRATOR;
+ // check if we are in the site area
+ if (JFactory::getApplication()->isSite())
+ {
+ // set admin path
+ $adminPath = $focus . '/components/' . $_component . '/helpers/' . $component . '.php';
+ // change the focus
+ $focus = JPATH_ROOT;
+ }
+ // set path based on focus
+ $path = $focus . '/components/' . $_component . '/helpers/' . $component . '.php';
+ // check if file exist, if not try admin again.
+ if (file_exists($path))
+ {
+ // make sure to load the helper
+ JLoader::register($componentHelper, $path);
+ }
+ // fallback option
+ elseif (isset($adminPath) && file_exists($adminPath))
+ {
+ // make sure to load the helper
+ JLoader::register($componentHelper, $adminPath);
+ }
+ else
+ {
+ // could not find this
+ return false;
+ }
+ }
+ // success
+ return $componentHelper;
+ }
+
+
/**
* get a report
*
@@ -1679,6 +2467,23 @@ abstract class MembersmanagerHelper
$placeholders = self::mergeArrays($placeholders);
// get the ID
$divID = self::randomkey(10);
+ // update the template with placeholders
+ $data = self::setDynamicData($template, $placeholders);
+ // make sure all placeholders are removed
+ if (strpos($data, '[') !== false && strpos($data, ']') !== false)
+ {
+ // get the prefix
+ $prefix = JComponentHelper::getParams($_component)->get('placeholder_prefix', str_replace('com_', '', $_component));
+ // get the left over placeholders
+ $left = self::getAllBetween($data, '[' . $prefix, ']');
+ if (self::checkArray($left))
+ {
+ foreach ($left as $remove)
+ {
+ $data = str_replace('[' . $prefix . $remove . ']', '', $data);
+ }
+ }
+ }
// get the global settings
if (!self::checkObject(self::$params))
{
@@ -1688,14 +2493,10 @@ abstract class MembersmanagerHelper
$uikitVersion = self::$params->get('uikit_version', 2);
if (3 == $uikitVersion)
{
- return '' . JText::_('COM_MEMBERSMANAGER_PRINT') . '
' .
- self::setDynamicData($template, $placeholders) .
- ' ';
+ return '' . JText::_('COM_MEMBERSMANAGER_PRINT') . '
' . $data . ' ';
}
// return html
- return '
' .
- self::setDynamicData($template, $placeholders) .
- ' ';
+ return '
' . $data . ' ';
}
}
return false;
@@ -1718,40 +2519,10 @@ abstract class MembersmanagerHelper
// check if we are in the correct class
if ('com_membersmanager' !== $_component)
{
- // get component name
- $component = str_replace('com_', '', $_component);
- // build component helper name
- $componentHelper = self::safeString($component, 'F') . 'Helper';
- // check if it is already set
- if (!class_exists($componentHelper, FALSE))
- {
- // set the correct path focus
- $focus = JPATH_ADMINISTRATOR;
- if (JFactory::getApplication()->isSite())
- {
- // set admin path
- $adminPath = $focus . '/components/' . $_component . '/helpers/' . $component . '.php';
- // change the focus
- $focus = JPATH_ROOT;
- }
- // set path based on focus
- $path = $focus . '/components/' . $_component . '/helpers/' . $component . '.php';
- // check if file exist, if not try admin again.
- if (file_exists($path))
- {
- // make sure to load the helper
- JLoader::register($componentHelper, $path);
- }
- elseif (isset($adminPath) && file_exists($adminPath)) // fallback option
- {
- // make sure to load the helper
- JLoader::register($componentHelper, $adminPath);
- }
- }
// check if the class and method exist
- if (class_exists($componentHelper) && method_exists($componentHelper, 'getTemplate'))
+ if (($helperClass = self::getHelperClass($_component)) !== false && method_exists($helperClass, 'getTemplate'))
{
- return $componentHelper::getTemplate($type, $default, $target);
+ return $helperClass::getTemplate($type, $default, $target);
}
return false;
}
@@ -1773,56 +2544,29 @@ abstract class MembersmanagerHelper
* @param string $method The type of values to return
* @param string $filter The kind of filter (to return only values required)
* @param string $masterkey The master key
+ * @param string $table The target form table
+ * @param int $qty The qty items to return
*
* @return array/object based on $method
*
*/
- public static function getAnyFormDetails($memberID, $type = 'member', $_component = 'com_membersmanager', $method = 'array', $filter = 'none', $masterkey = 'member')
+ public static function getAnyFormDetails($memberID, $type = 'member', $_component = 'com_membersmanager', $method = 'array', $filter = 'none', $masterkey = 'member', $table = 'form', $qty = 0)
{
+ // set class name
+ $class = self::safeString($table, 'W');
// check if we are in the correct class
if ('com_membersmanager' !== $_component)
{
- // get component name
- $component = str_replace('com_', '', $_component);
- // build component helper name
- $componentHelper = self::safeString($component, 'F') . 'Helper';
- // check if it is already set
- if (!class_exists($componentHelper, FALSE))
- {
- // set the correct path focus
- $focus = JPATH_ADMINISTRATOR;
- if (JFactory::getApplication()->isSite())
- {
- // set admin path
- $adminPath = $focus . '/components/' . $_component . '/helpers/' . $component . '.php';
- // change the focus
- $focus = JPATH_ROOT;
- }
- // set path based on focus
- $path = $focus . '/components/' . $_component . '/helpers/' . $component . '.php';
- // check if file exist, if not try admin again.
- if (file_exists($path))
- {
- // make sure to load the helper
- JLoader::register($componentHelper, $path);
- }
- elseif (isset($adminPath) && file_exists($adminPath))
- {
- // make sure to load the helper
- JLoader::register($componentHelper, $adminPath);
- }
- }
// check if the class and method exist
- if (class_exists($componentHelper) && method_exists($componentHelper, 'getFormDetails'))
+ if (($helperClass = self::getHelperClass($_component)) !== false && method_exists($helperClass, 'get' . $class . 'Details'))
{
- return $componentHelper::getFormDetails($memberID, $type, 'form', $method, $filter, $masterkey);
+ return $helperClass::{'get' . $class . 'Details'}($memberID, $type, $table, $method, $filter, $masterkey, $qty);
}
- return false;
}
// check if the class and method exist
- elseif (method_exists(__CLASS__, 'getFormDetails'))
+ elseif (method_exists(__CLASS__, 'get' . $class . 'Details'))
{
- return self::getFormDetails($memberID, $type, 'form', $method, $filter, $masterkey);
+ return self::{'get' . $class . 'Details'}($memberID, $type, $table, $method, $filter, $masterkey, $qty);
}
return false;
}
@@ -1843,42 +2587,11 @@ abstract class MembersmanagerHelper
// check if we are in the correct class
if ('com_membersmanager' !== $_component)
{
- // get component name
- $component = str_replace('com_', '', $_component);
- // build component helper name
- $componentHelper = self::safeString($component, 'F') . 'Helper';
- // check if it is already set
- if (!class_exists($componentHelper, FALSE))
- {
- // set the correct path focus
- $focus = JPATH_ADMINISTRATOR;
- if (JFactory::getApplication()->isSite())
- {
- // set admin path
- $adminPath = $focus . '/components/' . $_component . '/helpers/' . $component . '.php';
- // change the focus
- $focus = JPATH_ROOT;
- }
- // set path based on focus
- $path = $focus . '/components/' . $_component . '/helpers/' . $component . '.php';
- // check if file exist, if not try admin again.
- if (file_exists($path))
- {
- // make sure to load the helper
- JLoader::register($componentHelper, $path);
- }
- elseif (isset($adminPath) && file_exists($adminPath)) // fallback option
- {
- // make sure to load the helper
- JLoader::register($componentHelper, $adminPath);
- }
- }
// check if the class and method exist
- if (class_exists($componentHelper) && method_exists($componentHelper, 'getCompanyDetails'))
+ if (($helperClass = self::getHelperClass($_component)) !== false && method_exists($helperClass, 'getCompanyDetails'))
{
- return $componentHelper::getCompanyDetails($method, $filter);
+ return $helperClass::getCompanyDetails($method, $filter);
}
- return false;
}
// check if the class and method exist
elseif (method_exists(__CLASS__, 'getCompanyDetails'))
@@ -1889,6 +2602,102 @@ abstract class MembersmanagerHelper
}
+ /**
+ * Get Any chart code
+ *
+ * @param string $key The unique key/id_name
+ * @param string $dataTable The data table for the chart
+ * @param string $dataTable The details for the chart
+ * @param string $filter The kind of filter (to return only values required)
+ * @param string $_component The component element name
+ *
+ * @return string The dataTable
+ *
+ */
+ public static function getAnyChartCode($key, $dataTable, $chartDetails, $filter = 'null', $_component = 'com_membersmanager')
+ {
+ // check if we are in the correct class
+ if ('com_membersmanager' !== $_component)
+ {
+ // check if the class and method exist
+ if (($helperClass = self::getHelperClass($_component)) !== false && method_exists($helperClass, 'getChartCode'))
+ {
+ return $helperClass::getChartCode($key, $dataTable, $chartDetails, $filter);
+ }
+ }
+ // check if the class and method exist
+ elseif (method_exists(__CLASS__, 'getChartCode'))
+ {
+ return self::getChartCode($key, $dataTable, $chartDetails, $filter);
+ }
+ return false;
+ }
+
+
+ /**
+ * Get Any Multi Chart dataTable
+ *
+ * @param int $memberId The member ID
+ * @param int $target The type of chart retrieval behavior
+ * @param string $key The chart key
+ * @param string $_component The component element name
+ * @param array $args Options to override chart details
+ * 'dataTable' => $template
+ * 'number' => $number
+ *
+ * @return string The dataTable
+ *
+ */
+ public static function getAnyMultiChartDataTable($memberID, $target, $key = null, $_component = 'com_membersmanager', $args = null)
+ {
+ // check if we are in the correct class
+ if ('com_membersmanager' !== $_component)
+ {
+ // check if the class and method exist
+ if (($helperClass = self::getHelperClass($_component)) !== false && method_exists($helperClass, 'getMultiChartDataTable'))
+ {
+ return $helperClass::getMultiChartDataTable($memberID, $target, $key, $args);
+ }
+ }
+ // check if the class and method exist
+ elseif (method_exists(__CLASS__, 'getMultiChartDataTable'))
+ {
+ return self::getMultiChartDataTable($memberID, $target, $key, $args);
+ }
+ return false;
+ }
+
+
+ /**
+ * Get Any Available Charts
+ *
+ * @param string $key The chart key
+ * @param int $target The type of chart retrieval behavior
+ * @param string $_component The component element name
+ *
+ * @return array
+ *
+ */
+ public static function getAnyAvailableCharts($key = null, $target = 1, $_component = 'com_membersmanager')
+ {
+ // check if we are in the correct class
+ if ('com_membersmanager' !== $_component)
+ {
+ // check if the class and method exist
+ if (($helperClass = self::getHelperClass($_component)) !== false && method_exists($helperClass, 'getAvailableCharts'))
+ {
+ return $helperClass::getAvailableCharts($key, $target);
+ }
+ }
+ // check if the class and method exist
+ elseif (method_exists(__CLASS__, 'getAvailableCharts'))
+ {
+ return self::getAvailableCharts($key, $target);
+ }
+ return false;
+ }
+
+
/**
* Get Member forms
*
@@ -1952,6 +2761,13 @@ abstract class MembersmanagerHelper
*/
protected static $memberDetails = array();
+ /**
+ * The current return number
+ *
+ * @var int
+ */
+ public static $returnNumber;
+
/**
* The global details key (set per/query)
*
@@ -1968,11 +2784,12 @@ abstract class MembersmanagerHelper
* @param string $method The type of values to return
* @param string $filter The kind of filter (to return only values required)
* @param string $masterkey The master key for many values in the member table
+ * @param int $qty The qty items to return
*
* @return array/object based on $method
*
*/
- public static function getMemberDetails($id, $type = 'id', $table = 'member', $method = 'array', $filter = 'none', $masterkey = 'member')
+ public static function getMemberDetails($id, $type = 'id', $table = 'member', $method = 'array', $filter = 'none', $masterkey = 'member', $qty = 0)
{
// always make sure that we have a member column
if ($table !== 'member' && $type !== $masterkey)
@@ -1985,13 +2802,15 @@ abstract class MembersmanagerHelper
$type = $masterkey;
$table = 'member';
}
+ // get the user object
+ $user = JFactory::getUser();
// get database object
$db = JFactory::getDbo();
+ // get the database columns of this table
+ $columns = $db->getTableColumns("#__membersmanager_member", false);
// if not id validate column
if ($type !== 'id' && $type !== $masterkey)
{
- // get the database columns of this table
- $columns = $db->getTableColumns("#__membersmanager_member", false);
// check if the type is found
if (!isset($columns[$type]))
{
@@ -2017,7 +2836,7 @@ abstract class MembersmanagerHelper
$type = $masterkey;
}
// set the global key
- self::$k3y = $id.$method.$filter;
+ self::$k3y = $id.$method.$filter.$qty; // we will check this (qty) it may not be ideal (TODO)
// check if we have the member details in memory
if (is_numeric($id) && $id > 0 && !isset(self::$memberDetails[self::$k3y]))
{
@@ -2042,6 +2861,7 @@ abstract class MembersmanagerHelper
// check if we have a selection
if (isset($selection) && self::checkArray($selection))
{
+ // do permission view purge (TODO)
// set the selection
$query->select($db->quoteName(array_keys($selection), array_values($selection)));
// From the membersmanager_member table
@@ -2051,24 +2871,48 @@ 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']))
+ {
+ // ensure to always filter by access
+ $accessGroups = implode(',', $user->getAuthorisedViewLevels());
+ $query->where('a.access IN (' . $accessGroups . ')');
+ }
// check if we have more get where details
if (method_exists(__CLASS__, "whereMemberDetails"))
{
self::whereMemberDetails($query, $filter, $db);
}
+ // check if we have more order details
+ if (method_exists(__CLASS__, "orderMemberDetails"))
+ {
+ self::orderMemberDetails($query, $filter, $db);
+ }
+ // always order so to insure last added is first by default
+ else
+ {
+ $query->order('a.id ASC');
+ }
+ // limit the return
+ if($qty > 1)
+ {
+ $query->setLimit($qty);
+ }
// get by type ID
$query->where('a.' . $type . ' = ' . (int) $id);
$db->setQuery($query);
$db->execute();
- $numberRows = $db->getNumRows();
- if ($numberRows)
+ self::$returnNumber = $db->getNumRows();
+ if (self::$returnNumber)
{
if ('object' == $method)
{
// if one to one
- if ($relations == 1 || $numberRows == 1)
+ if ($qty == 1 || $relations == 1 || self::$returnNumber == 1)
{
self::$memberDetails[self::$k3y] = $db->loadObject();
+ // we retrieved only 1
+ self::$returnNumber = 1;
}
// if one to many (so we must return many)
else
@@ -2079,9 +2923,11 @@ abstract class MembersmanagerHelper
else
{
// if one to one
- if ($relations == 1 || $numberRows == 1)
+ if ($qty == 1 || $relations == 1 || self::$returnNumber == 1)
{
self::$memberDetails[self::$k3y] = $db->loadAssoc();
+ // we retrieved only 1
+ self::$returnNumber = 1;
}
// if one to many (so we must return many)
else
@@ -2098,11 +2944,11 @@ abstract class MembersmanagerHelper
// check if we must model the details
elseif (method_exists(__CLASS__, "modelMemberDetails"))
{
- self::modelMemberDetails($id, $method, $filter, $numberRows, $db);
+ self::modelMemberDetails($id, $method, $filter, $db);
// check if we must remove some details after modeling
if (method_exists(__CLASS__, "removeMemberDetails"))
{
- self::removeMemberDetails($id, $method, $filter, $numberRows, $db);
+ self::removeMemberDetails($id, $method, $filter, $db);
}
}
}
@@ -2115,19 +2961,26 @@ abstract class MembersmanagerHelper
}
+ /**
+ * the global chart array
+ *
+ * @var array
+ *
+ */
+ public static $globalMemberChartArray = array();
+
/**
* Model the member details/values
*
* @param object $id The the member ID
* @param string $method The type of values to return
* @param string $filter The kind of filter (to return only values required)
- * @param int $numberRows The number of rows
* @param object $db The database object
*
* @return void
*
*/
- protected static function modelMemberDetails($id, $method, $filter, $numberRows, $db = null)
+ protected static function modelMemberDetails($id, $method, $filter, $db = null)
{
// check that we have values
if (method_exists(__CLASS__, 'getSelection') && isset(self::$memberDetails[self::$k3y]) && self::$memberDetails[self::$k3y])
@@ -2141,7 +2994,12 @@ abstract class MembersmanagerHelper
// check if we have params to model
if (method_exists(__CLASS__, "paramsModelMemberDetails"))
{
- self::paramsModelMemberDetails($_builder, $method, $numberRows);
+ self::paramsModelMemberDetails($_builder, $method);
+ }
+ // check if we have subforms to model
+ if (method_exists(__CLASS__, "subformModelMemberDetails"))
+ {
+ self::subformModelMemberDetails($_builder, $method);
}
// get values that must be set (not SQL values)
$builder = array_filter(
@@ -2181,7 +3039,7 @@ abstract class MembersmanagerHelper
if (self::checkArray($valueKeys))
{
// start the modeling
- if ($numberRows == 1)
+ if (self::$returnNumber == 1)
{
$object = new JObject;
foreach ($valueKeys as $valueKey)
@@ -2292,7 +3150,7 @@ abstract class MembersmanagerHelper
}
else
{
- if ($numberRows == 1)
+ if (self::$returnNumber == 1)
{
// work with object
if ('object' === $method && isset(self::$memberDetails[self::$k3y]->{$_build[1]}))
@@ -2372,19 +3230,245 @@ abstract class MembersmanagerHelper
}
}
// check if we have labels to model
- if (method_exists(__CLASS__, "labelModelMemberDetails") && property_exists(__CLASS__, 'memberParams'))
+ if (method_exists(__CLASS__, "labelModelMemberDetails"))
{
- self::labelModelMemberDetails($_builder, $method, $numberRows);
+ self::labelModelMemberDetails($_builder, $method);
}
// check if we have templates to model
if (method_exists(__CLASS__, "templateModelMemberDetails") && property_exists(__CLASS__, 'memberParams'))
{
- self::templateModelMemberDetails($_builder, $method, $numberRows);
+ self::templateModelMemberDetails($_builder, $method);
+ }
+ // check if we have charts to model (must be last after all data is set)
+ if (method_exists(__CLASS__, "chartModelMemberDetails"))
+ {
+ self::chartModelMemberDetails($_builder, $method, $filter);
+ }
+ elseif (method_exists(__CLASS__, "multiChartModelMemberDetails"))
+ {
+ self::multiChartModelMemberDetails($_builder, $method, $filter);
}
}
}
+ /**
+ * Label Model the member details/values
+ *
+ * @param array $builder The selection array
+ * @param string $method The type of values to return
+ *
+ * @return void
+ *
+ */
+ protected static function labelModelMemberDetails($builder, $method)
+ {
+ // get values that must be set (not SQL values)
+ $builder = array_filter(
+ $builder,
+ function ($key) {
+ return strpos($key, 'Label->');
+ },
+ ARRAY_FILTER_USE_KEY
+ );
+ // start the builder
+ if (self::checkArray($builder))
+ {
+ // prep for placeholders
+ $f = '';
+ $b = '';
+ if ('placeholder' === $method)
+ {
+ // get the placeholder prefix
+ $prefix = self::$params->get('placeholder_prefix', 'membersmanager');
+ $f = '[' . $prefix . '_';
+ $b = ']';
+ }
+ // loop builder
+ foreach ($builder as $build => $set)
+ {
+ // get the label key
+ $build = str_replace('setLabel->', '', $build);
+ // check if this is a single or multi array
+ if (self::$returnNumber == 1)
+ {
+ // work with object
+ if ('object' === $method)
+ {
+ self::$memberDetails[self::$k3y]->{$set} = self::setLabelModelMemberDetails($build);
+ }
+ // work with array
+ elseif (self::checkArray(self::$memberDetails[self::$k3y]) && isset(self::$memberDetails[self::$k3y][$f.$build.$b]))
+ {
+ self::$memberDetails[self::$k3y][$set] = self::setLabelModelMemberDetails($build);
+ }
+ }
+ elseif (self::checkArray(self::$memberDetails[self::$k3y]))
+ {
+ foreach (self::$memberDetails[self::$k3y] as $_nr => $details)
+ {
+ // work with object
+ if ('object' === $method && isset(self::$memberDetails[self::$k3y][$_nr]->{$build}))
+ {
+ self::$memberDetails[self::$k3y][$_nr]->{$set} = self::setLabelModelMemberDetails($build);
+ }
+ // work with array
+ elseif (self::checkArray(self::$memberDetails[self::$k3y][$_nr]) && isset(self::$memberDetails[self::$k3y][$_nr][$f.$build.$b]))
+ {
+ self::$memberDetails[self::$k3y][$_nr][$set] = self::setLabelModelMemberDetails($build);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Set the Label to the member details/values
+ *
+ * @param string $key The key of the setting label
+ *
+ * @return mix
+ *
+ */
+ protected static function setLabelModelMemberDetails($key)
+ {
+ // make sure we have the template
+ if (property_exists(__CLASS__, 'formParams') && isset(self::$formParams[$key]) && isset(self::$memberParams[$key]['label']) && self::checkString(self::$memberParams[$key]['label']))
+ {
+ return JText::_(self::$memberParams[$key]['label']);
+ }
+ // check if this value is part of the admin form
+ $LABLE = 'COM_MEMBERSMANAGER_FORM_' . self::safeString($key, 'U') . '_LABEL';
+ $label = JText::_($LABLE);
+ // little workaround for now
+ if ($LABLE === $label)
+ {
+ return self::safeString($key, 'Ww');
+ }
+ return $label;
+ }
+
+
+ /**
+ * Multi Chart Model the member details/values
+ *
+ * @param array $builder The selection array
+ * @param string $method The type of values to return
+ * @param string $filter The kind of filter (to return only values required)
+ *
+ * @return void
+ *
+ */
+ protected static function multiChartModelMemberDetails($builder, $method, $filter)
+ {
+ // get values that must be set (not SQL values)
+ $builder = array_filter(
+ $builder,
+ function ($key) {
+ return strpos($key, 'MultiChart->');
+ },
+ ARRAY_FILTER_USE_KEY
+ );
+ // start the builder
+ if (self::checkArray($builder))
+ {
+ // prep for placeholders
+ $f = '';
+ $b = '';
+ if ('placeholder' === $method)
+ {
+ // get the placeholder prefix
+ $prefix = self::$params->get('placeholder_prefix', 'membersmanager');
+ $f = '[' . $prefix . '_';
+ $b = ']';
+ }
+ // set params key
+ // loop builder
+ foreach ($builder as $build => $set)
+ {
+ // get the chart key
+ $build = str_replace('setMultiChart->', '', $build);
+ // check if this is a single or multi array
+ if (self::$returnNumber == 1)
+ {
+ // work with object
+ if ('object' === $method)
+ {
+ self::$memberDetails[self::$k3y]->{$set} = self::setMultiChartModelMemberDetails(self::$memberDetails[self::$k3y]->{$f . 'id' . $b}, $build, $filter);
+ }
+ // work with array
+ elseif (self::checkArray(self::$memberDetails[self::$k3y]))
+ {
+ self::$memberDetails[self::$k3y][$set] = self::setMultiChartModelMemberDetails(self::$memberDetails[self::$k3y][$f . 'id' . $b], $build, $filter);
+ }
+ }
+ elseif (self::checkArray(self::$memberDetails[self::$k3y]))
+ {
+ foreach (self::$memberDetails[self::$k3y] as $_nr => $details)
+ {
+ // work with object
+ if ('object' === $method)
+ {
+ self::$memberDetails[self::$k3y][$_nr]->{$set} = self::setMultiChartModelMemberDetails(self::$memberDetails[self::$k3y][$_nr]->{$f . 'id' . $b}, $build, $filter);
+ }
+ // work with array
+ elseif (self::checkArray(self::$memberDetails[self::$k3y][$_nr]))
+ {
+ self::$memberDetails[self::$k3y][$_nr][$set] = self::setMultiChartModelMemberDetails(self::$memberDetails[self::$k3y][$_nr][$f . 'id' . $b], $build, $filter);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Set the multi chart to the member details/values
+ *
+ * @param object/array $placeholders The placeholders
+ * @param string $key The key of the setting chart
+ * @param string $filter The kind of filter (to return only values required)
+ *
+ * @return string
+ *
+ */
+ protected static function setMultiChartModelMemberDetails($id, $keyString, &$filter)
+ {
+ // get the key array
+ $keyArray = explode('\^/', $keyString);
+ // get the chart, the data table and the code
+ if (($cart = self::getAnyAvailableCharts($keyArray[0], $keyArray[2], $keyArray[1])) !== false &&
+ ($dataTable = self::getAnyMultiChartDataTable($id, $keyArray[2], $keyArray[0], $keyArray[1])) !== '' &&
+ ($code = self::getAnyChartCode($keyArray[0] . self::safeString($id), $dataTable, $cart['details'], $filter, $keyArray[1])) !== false)
+ {
+ if ('email' === $filter && isset($code['span']))
+ {
+ // set to global chart array
+ self::$globalMemberChartArray[$code['id_name']] = $code;
+ // return placeholder
+ return $code['span'];
+ }
+ // build html
+ $html = array();
+ $html[] = $code['div'];
+ $html[] = '';
+ // return the chart code/html
+ return implode("\n", $html);
+ }
+ return '';
+ }
+
+
+ /**
+ * The Member Name Memory
+ *
+ * @var array
+ */
+ protected static $memberNames = array();
+
/**
* Get the members name
*
@@ -2392,12 +3476,36 @@ abstract class MembersmanagerHelper
* @param int $user The user ID
* @param string $name The name
* @param string $surname The surname
+ * @param string $default The default
*
* @return string the members name
*
*/
- public static function getMemberName($id, $user = null, $name = null, $surname = null)
+ public static function getMemberName($id = null, $user = null, $name = null, $surname = null, $default = 'No Name')
{
+ // check if member ID is null, then get member ID
+ if (!$id || !is_numeric($id))
+ {
+ if (!$user || !is_numeric($user) || ($id = self::getVar('member', $user, 'user', 'id', '=', 'membersmanager')) === false || !is_numeric($id) || $id == 0)
+ {
+ // check if a was name given
+ if (self::checkstring($name))
+ {
+ $default = $name;
+ }
+ // always set surname if given
+ if (self::checkString($surname))
+ {
+ $default += ' ' . $surname;
+ }
+ return $default;
+ }
+ }
+ // check if name in memory
+ if (isset(self::$memberNames[$id]))
+ {
+ return self::$memberNames[$id];
+ }
// always get surname
if (!self::checkString($surname))
{
@@ -2409,19 +3517,125 @@ abstract class MembersmanagerHelper
// check name given
if (self::checkstring($name))
{
- return $name . ' ' . $surname;
+ $memberName = $name . ' ' . $surname;
}
// check user given
- elseif ((is_numeric($user) && $user > 0) || (is_numeric($id) && $id > 0 && ($user = self::getVar('member', $id, 'id', 'user', '=', 'membersmanager')) !== false && $user > 0))
+ elseif ((is_numeric($user) && $user > 0) || (($user = self::getVar('member', $id, 'id', 'user', '=', 'membersmanager')) !== false && $user > 0))
{
- return JFactory::getUser($user)->name . ' ' . $surname;
+ $memberName = JFactory::getUser($user)->name . ' ' . $surname;
}
// get the name
- elseif (is_numeric($id) && $id > 0 && ($name = self::getVar('member', $id, 'id', 'name', '=', 'membersmanager')) !== false && self::checkstring($name))
+ elseif (($name = self::getVar('member', $id, 'id', 'name', '=', 'membersmanager')) !== false && self::checkstring($name))
{
- return $name . ' ' . $surname;
+ $memberName = $name . ' ' . $surname;
}
- return JText::_('COM_MEMBERSMANAGER_NO_NAME');
+ // load to memory
+ if (isset($memberName))
+ {
+ self::$memberNames[$id] = $memberName;
+ // return member name
+ return $memberName;
+ }
+ return $default;
+ }
+
+ /**
+ * The Member Email Memory
+ *
+ * @var array
+ */
+ protected static $memberEmails = array();
+
+ /**
+ * Get the members email
+ *
+ * @param int $id The member ID
+ * @param int $user The user ID
+ * @param string $default The default
+ *
+ * @return string the members email
+ *
+ */
+ public static function getMemberEmail($id = null, $user = null, $default = '')
+ {
+ // check if member ID is null, then get member ID
+ if (!$id || !is_numeric($id))
+ {
+ if (!$user || !is_numeric($user) || ($id = self::getVar('member', $user, 'user', 'id')) === false)
+ {
+ return $default;
+ }
+ }
+ // check if email in memory
+ if (isset(self::$memberEmails[$id]))
+ {
+ return self::$memberEmails[$id];
+ }
+ // check user given
+ if ((is_numeric($user) && $user > 0) || (is_numeric($id) && $id > 0 && ($user = self::getVar('member', $id, 'id', 'user', '=', 'membersmanager')) !== false && $user > 0))
+ {
+ $memberEmail = JFactory::getUser($user)->email;
+ }
+ // get the email
+ elseif (($email = self::getVar('member', $id, 'id', 'email', '=', 'membersmanager')) !== false && self::checkstring($email))
+ {
+ $memberEmail = $email;
+ }
+ // load to memory
+ if (isset($memberEmail))
+ {
+ self::$memberEmails[$id] = $memberEmail;
+ // return found email
+ return $memberEmail;
+ }
+ return $default;
+ }
+
+
+ /**
+ * get all components linked
+ *
+ * @return array of all components
+ *
+ */
+ public static function getAllComponents($relation = null, $types = array('Info','Assessment'))
+ {
+ // build components array
+ $components = array();
+ // search if the types are set and active
+ foreach ($types as $type)
+ {
+ if (method_exists(__CLASS__, 'get' . $type. 'Components') && ($_components = self::{'get' . $type. 'Components'}(null, null, $relation)) !== false && self::checkArray($_components))
+ {
+ $components = self::mergeArrays(array($components, $_components));
+ }
+ }
+ // if we found components return
+ if (self::checkArray($components))
+ {
+ return $components;
+ }
+ return false;
+ }
+
+
+ /**
+ * get active component name
+ *
+ * @return string of component name
+ *
+ */
+ public static function getComponentName($_component, $types = array('Info','Assessment'))
+ {
+ // search if the types are set and active
+ foreach ($types as $type)
+ {
+ if (method_exists(__CLASS__, 'get' . $type. 'ComponentName') && ($name = self::{'get' . $type. 'ComponentName'}($_component)) !== false)
+ {
+ return $name;
+ }
+ }
+ return false;
}
@@ -2433,9 +3647,9 @@ abstract class MembersmanagerHelper
/**
* Get available infos based on type
*/
- public static function getInfoAvaillable($type, $account, $multiDimensionalAllowed = true)
+ public static function getInfoAvaillable($types, $account, $multiDimensionalAllowed = true)
{
- $infos = self::getInfoComponents($type, $account);
+ $infos = self::getInfoComponents($types, $account);
// check if we found components
if (self::checkArray($infos))
{
@@ -2463,9 +3677,31 @@ abstract class MembersmanagerHelper
if (!isset($bucketInfos[$infoTypeName]))
{
$bucketInfos[$infoTypeName] = array();
+ $bucketInfos[$infoTypeName][] = $component;
+ }
+ // check if this is an array set
+ elseif (self::checkArray($bucketInfos[$infoTypeName]))
+ {
+ // set data (one to many)
+ $bucketInfos[$infoTypeName][] = $component;
+ }
+ // check if this is an array set
+ elseif (self::checkObject($bucketInfos[$infoTypeName]))
+ {
+ $bucket_key = $infoTypeName . ' *';
+ // start array if not already set
+ if (!isset($bucketInfos[$bucket_key]))
+ {
+ $bucketInfos[$bucket_key] = array();
+ $bucketInfos[$bucket_key][] = $component;
+ }
+ // check if this is an array set
+ elseif (self::checkArray($bucketInfos[$bucket_key]))
+ {
+ // set data (one to many)
+ $bucketInfos[$bucket_key][] = $component;
+ }
}
- // set data (one to many)
- $bucketInfos[$infoTypeName][] = $component;
}
}
// return the info bucket
@@ -2474,12 +3710,37 @@ abstract class MembersmanagerHelper
return false;
}
+ /**
+ * Get type info component name
+ */
+ public static function getInfoComponentName($_component)
+ {
+ // see if we have components in memory
+ if (!self::checkArray(self::$infoComponents))
+ {
+ // get list of components
+ self::$infoComponents = self::setInfoComponents();
+ }
+ // make sure we have components
+ if (self::checkArray(self::$infoComponents))
+ {
+ foreach (self::$infoComponents as $component)
+ {
+ if ($component->element === $_component)
+ {
+ return $component->name;
+ }
+ }
+ }
+ return false;
+ }
+
/**
* Get type info names
*/
- public static function getTypeInfosNames($type, $account, $as = 'string')
+ public static function getTypeInfosNames($types, $account, $as = 'string')
{
- $infos = self::getInfoAvaillable($type, $account);
+ $infos = self::getInfoAvaillable($types, $account);
$names = array();
if (self::checkArray($infos))
{
@@ -2508,27 +3769,57 @@ abstract class MembersmanagerHelper
/**
* Get info components
*/
- public static function getInfoComponents($type = null, $account = null)
+ public static function getInfoComponents($types = null, $account = null, $relation = null)
{
+ // see if we have components in memory
if (!self::checkArray(self::$infoComponents))
{
- // get list of Extensions
+ // get list of components
self::$infoComponents = self::setInfoComponents();
}
- // filter by type & account
- if ($type && $account && self::checkArray(self::$infoComponents))
+ // make sure we have components
+ if (self::checkArray(self::$infoComponents))
{
- // filter out the components we need
- return array_filter(
- self::$infoComponents,
- function ($component) use ($type, $account) {
- // check if the component is available to this type of member
- return ((isset($component->params->membersmanager_target_type) && in_array($type, (array) $component->params->membersmanager_target_type)) &&
- (isset($component->params->membersmanager_target_account) && in_array($account, (array) $component->params->membersmanager_target_account)));
- }
- );
+ // convert type json to array
+ if ($types && self::checkJson($types))
+ {
+ $types = json_decode($types, true);
+ }
+ // convert type int to array
+ if ($types && is_numeric($types) && $types > 0)
+ {
+ $types = array($types);
+ }
+ // filter by type & account
+ if ($types && self::checkArray($types) && $account)
+ {
+ // 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; };
+ // filter out the components we need
+ return array_filter(
+ self::$infoComponents,
+ function ($component) use ($types, $account, $relation, $intersect) {
+ // check if the component is available to this type of member
+ return ((isset($component->params->membersmanager_target_type) && $intersect($types, (array) $component->params->membersmanager_target_type)) &&
+ (isset($component->params->membersmanager_target_account) && in_array($account, (array) $component->params->membersmanager_target_account)) &&
+ (!$relation || (is_int($relation) && $relation == $component->params->membersmanager_relation_type)));
+ }
+ );
+ }
+ elseif (is_int($relation))
+ {
+ // filter out the components we need
+ return array_filter(
+ self::$infoComponents,
+ function ($component) use ($relation) {
+ // check if the component is available to this relation
+ return ($relation == $component->params->membersmanager_relation_type);
+ }
+ );
+ }
+ return self::$infoComponents;
}
- return self::$infoComponents;
+ return false;
}
/**
@@ -2553,10 +3844,11 @@ abstract class MembersmanagerHelper
$listComponents = array_filter(
$listComponents,
function ($component) {
- if (strpos($component->params, 'activate_membersmanager_info') !== false)
+ if (self::checkJson($component->params) && strpos($component->params, 'activate_membersmanager_info') !== false)
{
// check if this component is active
- return json_decode($component->params)->activate_membersmanager_info;
+ $component->params = json_decode($component->params);
+ return $component->params->activate_membersmanager_info;
}
return false;
}
@@ -2568,16 +3860,27 @@ abstract class MembersmanagerHelper
$lang = JFactory::getLanguage();
foreach ($listComponents as $listComponent)
{
- // lets do a quick params setup (to objects)
- $listComponent->params = json_decode($listComponent->params);
- // try to load the translation
- $lang->load($listComponent->element, JPATH_ADMINISTRATOR, null, false, true);
- // translate the extension name if possible
- $listComponent->name = JText::_($listComponent->name);
- // translate the info type name
- if (isset($listComponent->params->info_type_name))
+ if (isset($listComponent->params))
{
- $listComponent->params->info_type_name = JText::_(strtoupper($listComponent->element) . '_CONFIG_' . $listComponent->params->info_type_name);
+ // convert params to object
+ if (self::checkJson($listComponent->params))
+ {
+ // lets do a quick params setup (to objects)
+ $listComponent->params = json_decode($listComponent->params);
+ }
+ // check that we have an object
+ if (self::checkObject($listComponent->params))
+ {
+ // try to load the translation
+ $lang->load($listComponent->element, JPATH_ADMINISTRATOR, null, false, true);
+ // translate the extension name if possible
+ $listComponent->name = JText::_($listComponent->name);
+ // translate the info type name
+ if (isset($listComponent->params->info_type_name))
+ {
+ $listComponent->params->info_type_name = JText::_(strtoupper($listComponent->element) . '_CONFIG_' . $listComponent->params->info_type_name);
+ }
+ }
}
}
return $listComponents;
@@ -2595,9 +3898,9 @@ abstract class MembersmanagerHelper
/**
* Get available assessments based on type
*/
- public static function getAssessmentAvaillable($type, $account, $multiDimensionalAllowed = true)
+ public static function getAssessmentAvaillable($types, $account, $multiDimensionalAllowed = true)
{
- $assessments = self::getAssessmentComponents($type, $account);
+ $assessments = self::getAssessmentComponents($types, $account);
// check if we found components
if (self::checkArray($assessments))
{
@@ -2625,9 +3928,31 @@ abstract class MembersmanagerHelper
if (!isset($bucketAssessments[$assessmentTypeName]))
{
$bucketAssessments[$assessmentTypeName] = array();
+ $bucketAssessments[$assessmentTypeName][] = $component;
+ }
+ // check if this is an array set
+ elseif (self::checkArray($bucketAssessments[$assessmentTypeName]))
+ {
+ // set data (one to many)
+ $bucketAssessments[$assessmentTypeName][] = $component;
+ }
+ // check if this is an array set
+ elseif (self::checkObject($bucketAssessments[$assessmentTypeName]))
+ {
+ $bucket_key = $assessmentTypeName . ' *';
+ // start array if not already set
+ if (!isset($bucketAssessments[$bucket_key]))
+ {
+ $bucketAssessments[$bucket_key] = array();
+ $bucketAssessments[$bucket_key][] = $component;
+ }
+ // check if this is an array set
+ elseif (self::checkArray($bucketAssessments[$bucket_key]))
+ {
+ // set data (one to many)
+ $bucketAssessments[$bucket_key][] = $component;
+ }
}
- // set data (one to many)
- $bucketAssessments[$assessmentTypeName][] = $component;
}
}
// return the assessment bucket
@@ -2636,12 +3961,37 @@ abstract class MembersmanagerHelper
return false;
}
+ /**
+ * Get type assessment component name
+ */
+ public static function getAssessmentComponentName($_component)
+ {
+ // see if we have components in memory
+ if (!self::checkArray(self::$assessmentComponents))
+ {
+ // get list of components
+ self::$assessmentComponents = self::setAssessmentComponents();
+ }
+ // make sure we have components
+ if (self::checkArray(self::$assessmentComponents))
+ {
+ foreach (self::$assessmentComponents as $component)
+ {
+ if ($component->element === $_component)
+ {
+ return $component->name;
+ }
+ }
+ }
+ return false;
+ }
+
/**
* Get type assessment names
*/
- public static function getTypeAssessmentsNames($type, $account, $as = 'string')
+ public static function getTypeAssessmentsNames($types, $account, $as = 'string')
{
- $assessments = self::getAssessmentAvaillable($type, $account);
+ $assessments = self::getAssessmentAvaillable($types, $account);
$names = array();
if (self::checkArray($assessments))
{
@@ -2670,27 +4020,57 @@ abstract class MembersmanagerHelper
/**
* Get assessment components
*/
- public static function getAssessmentComponents($type = null, $account = null)
+ public static function getAssessmentComponents($types = null, $account = null, $relation = null)
{
+ // see if we have components in memory
if (!self::checkArray(self::$assessmentComponents))
{
- // get list of Extensions
+ // get list of components
self::$assessmentComponents = self::setAssessmentComponents();
}
- // filter by type & account
- if ($type && $account && self::checkArray(self::$assessmentComponents))
+ // make sure we have components
+ if (self::checkArray(self::$assessmentComponents))
{
- // filter out the components we need
- return array_filter(
- self::$assessmentComponents,
- function ($component) use ($type, $account) {
- // check if the component is available to this type of member
- return ((isset($component->params->membersmanager_target_type) && in_array($type, (array) $component->params->membersmanager_target_type)) &&
- (isset($component->params->membersmanager_target_account) && in_array($account, (array) $component->params->membersmanager_target_account)));
- }
- );
+ // convert type json to array
+ if ($types && self::checkJson($types))
+ {
+ $types = json_decode($types, true);
+ }
+ // convert type int to array
+ if ($types && is_numeric($types) && $types > 0)
+ {
+ $types = array($types);
+ }
+ // filter by type & account
+ if ($types && self::checkArray($types) && $account)
+ {
+ // 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; };
+ // filter out the components we need
+ return array_filter(
+ self::$assessmentComponents,
+ function ($component) use ($types, $account, $relation, $intersect) {
+ // check if the component is available to this type of member
+ return ((isset($component->params->membersmanager_target_type) && $intersect($types, (array) $component->params->membersmanager_target_type)) &&
+ (isset($component->params->membersmanager_target_account) && in_array($account, (array) $component->params->membersmanager_target_account)) &&
+ (!$relation || (is_int($relation) && $relation == $component->params->membersmanager_relation_type)));
+ }
+ );
+ }
+ elseif (is_int($relation))
+ {
+ // filter out the components we need
+ return array_filter(
+ self::$assessmentComponents,
+ function ($component) use ($relation) {
+ // check if the component is available to this relation
+ return ($relation == $component->params->membersmanager_relation_type);
+ }
+ );
+ }
+ return self::$assessmentComponents;
}
- return self::$assessmentComponents;
+ return false;
}
/**
@@ -2715,10 +4095,11 @@ abstract class MembersmanagerHelper
$listComponents = array_filter(
$listComponents,
function ($component) {
- if (strpos($component->params, 'activate_membersmanager_assessment') !== false)
+ if (self::checkJson($component->params) && strpos($component->params, 'activate_membersmanager_assessment') !== false)
{
// check if this component is active
- return json_decode($component->params)->activate_membersmanager_assessment;
+ $component->params = json_decode($component->params);
+ return $component->params->activate_membersmanager_assessment;
}
return false;
}
@@ -2730,16 +4111,27 @@ abstract class MembersmanagerHelper
$lang = JFactory::getLanguage();
foreach ($listComponents as $listComponent)
{
- // lets do a quick params setup (to objects)
- $listComponent->params = json_decode($listComponent->params);
- // try to load the translation
- $lang->load($listComponent->element, JPATH_ADMINISTRATOR, null, false, true);
- // translate the extension name if possible
- $listComponent->name = JText::_($listComponent->name);
- // translate the assessment type name
- if (isset($listComponent->params->assessment_type_name))
+ if (isset($listComponent->params))
{
- $listComponent->params->assessment_type_name = JText::_(strtoupper($listComponent->element) . '_CONFIG_' . $listComponent->params->assessment_type_name);
+ // convert params to object
+ if (self::checkJson($listComponent->params))
+ {
+ // lets do a quick params setup (to objects)
+ $listComponent->params = json_decode($listComponent->params);
+ }
+ // check that we have an object
+ if (self::checkObject($listComponent->params))
+ {
+ // try to load the translation
+ $lang->load($listComponent->element, JPATH_ADMINISTRATOR, null, false, true);
+ // translate the extension name if possible
+ $listComponent->name = JText::_($listComponent->name);
+ // translate the assessment type name
+ if (isset($listComponent->params->assessment_type_name))
+ {
+ $listComponent->params->assessment_type_name = JText::_(strtoupper($listComponent->element) . '_CONFIG_' . $listComponent->params->assessment_type_name);
+ }
+ }
}
}
return $listComponents;
@@ -2762,7 +4154,7 @@ abstract class MembersmanagerHelper
public static function loadDynamicTabs(&$item, $view = 'member', $return = '')
{
// only loads if type and account is set
- if (is_numeric($item->type) && $item->type > 0 && is_numeric($item->account) && $item->account > 0)
+ if (isset($item->type) && (self::checkJson($item->type) || (is_numeric($item->type) && $item->type > 0) || self::checkArray($item->type)) && is_numeric($item->account) && $item->account > 0)
{
// get all the available component calling metods
$class = new ReflectionClass('MembersmanagerHelper');
@@ -2775,9 +4167,12 @@ abstract class MembersmanagerHelper
return false;
}
);
+ // get the database object
+ $db = JFactory::getDBO();
// set the tabs
$tabs = array();
$layout = array();
+ $script = array();
if (self::checkArray($methods))
{
foreach ($methods as $method)
@@ -2797,7 +4192,12 @@ abstract class MembersmanagerHelper
{
if (($ids = self::getVars('form', $item->id, $view, 'id', 'IN', str_replace('com_', '', $comp->element))) !== false && self::checkArray($ids))
{
- $tables[] = self::getTabLinksTable($ids, $item, $comp, $view, $return);
+ // 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
@@ -2835,10 +4235,11 @@ abstract class MembersmanagerHelper
// check if user are allowed to edit form values or create form values
if (($id > 0 && JFactory::getUser()->authorise('form.edit', $component->element . '.form.' . (int) $id)) || ($id == 0 && JFactory::getUser()->authorise('form.create', $component->element)))
{
- $fields = self::getTabFields($id, $component);
+ $fields = self::getTabFields($id, $component, $script);
// load the fields to the layout
if (self::checkString($fields))
{
+ // add fields
$layout[$_name] = $fields;
}
// add layout to tabs
@@ -2853,14 +4254,22 @@ abstract class MembersmanagerHelper
}
}
}
- // add layout to tabs
+ // add remainder layout to tabs
if (self::checkArray($layout))
{
$tabs[] = self::setTab($layout, $view);
}
+ // add the Relationship tab
+ self::setRelationshipTab($item, $view, $return, $tabs);
// check if we have tabs
if (self::checkArray($tabs))
{
+ // load the script if found
+ if (self::checkArray($script))
+ {
+ $document = JFactory::getDocument();
+ $document->addScriptDeclaration(implode("\n", $script));
+ }
return implode("\n", $tabs);
}
}
@@ -2868,15 +4277,132 @@ abstract class MembersmanagerHelper
}
/**
- * get the tabe fields
+ * set the relationship tab
*
- * @param int $id The item id
- * @param object $component The target component details
+ * @param object $item Data for the form
+ * @param string $view The view name
+ * @param string $return The return value if found
+ * @param array $tabs The exiting tabs array
+ *
+ * @return void
+ *
+ */
+ protected static function setRelationshipTab(&$item, &$view, &$return, &$tabs)
+ {
+ // get DB
+ $db = JFactory::getDBO();
+ // check if there is relationships and members in those relationships
+ if (self::checkObject($item) && isset($item->type) && ($relation_types = self::getRelationshipsByTypes($item->type, $db)) !== false)
+ {
+ // get the members already selected relationships
+ $relation_selected = (isset($item->id) && $item->id > 0) ? self::getRelationshipsByMember($item->id, $db) : false;
+ // build the fields
+ $null = null;
+ $headers = array();
+ $form = array();
+ foreach ($relation_types as $id => $type)
+ {
+ // get the field selection
+ $selected = ($relation_selected && isset($relation_selected[$id])) ? $relation_selected[$id] : '';
+ // set the field note headers
+ $headers[$id] = self::getRelationshipField($type->name, $type->description, $selected, $null);
+ // set the field
+ $form[$id] = self::getRelationshipField($type->name, $type->field_type, $selected, $type->members);
+ }
+ // divide the fields in two
+ $form = self::array_partition($form, 2, true);
+ // load the field layouts
+ foreach($form as $key => $fields)
+ {
+ $layout[$key] = '';
+ foreach ($fields as $pointer => $field)
+ {
+ // first set the header
+ $layout[$key] .= (isset($headers[$pointer])) ? '' . $headers[$pointer]->label . ' ': '';
+ // first set the header
+ $layout[$key] .= '';
+ $layout[$key] .= ' ' . $field->label . ' ';
+ $layout[$key] .= ' ' . $field->input . ' ';
+ $layout[$key] .= ' ';
+ }
+ }
+ // update tabs
+ $tabs[] = self::setTab($layout, $view, JText::_('COM_MEMBERSMANAGER_RELATIONSHIPS'), 6, false);
+ }
+ }
+
+ /**
+ * get the relationship field
+ *
+ * @param string $name The field name
+ * @param int/string $type The type if int or description if string
+ * @param array $selected The selected values
*
* @return string
*
*/
- protected static function getTabFields($id, &$component)
+ protected static function getRelationshipField(&$name, &$type, &$selected, &$values)
+ {
+ switch ($type)
+ {
+ case 1:
+ // build checkboxes
+ $attributes = array(
+ 'type' => 'checkboxes',
+ 'name' => 'relationship_mapping_' . self::safeString($name),
+ 'label' => $name,
+ 'class' => 'list_class',
+ 'description' => 'COM_MEMBERSMANAGER_MAKE_A_SELECTION_TO_CREATE_A_RELATIONSHIP');
+ break;
+ case 2:
+ // build list
+ $attributes = array(
+ 'type' => 'list',
+ 'name' => 'relationship_mapping_' . self::safeString($name),
+ 'label' => $name,
+ 'multiple' => true,
+ 'class' => 'list_class',
+ 'description' => 'COM_MEMBERSMANAGER_MAKE_A_SELECTION_TO_CREATE_A_RELATIONSHIP');
+ break;
+ default:
+ // build a note
+ $attributes = array(
+ 'type' => 'note',
+ 'name' => 'relationship_mapping_note_' . self::safeString($name),
+ 'label' => $name,
+ 'class' => 'alert');
+ if (self::checkString($type))
+ {
+ $attributes['description'] = $type;
+ }
+ break;
+ }
+ // set options
+ $options = null;
+ if (self::checkArray($values))
+ {
+ // start the building the options
+ $options = array();
+ // load relationship options from array
+ foreach($values as $value)
+ {
+ $options[(int) $value] = self::getMemberName($value);
+ }
+ }
+ return self::getFieldObject($attributes, $selected, $options);
+ }
+
+ /**
+ * get the tab fields
+ *
+ * @param int $id The item id
+ * @param object $component The target component details
+ * @param array $document The document array to load script
+ *
+ * @return string
+ *
+ */
+ protected static function getTabFields($id, &$component, &$document)
{
// build the rows
$rows = '';
@@ -2886,6 +4412,8 @@ abstract class MembersmanagerHelper
// get the fields for this form
if (($fields = JComponentHelper::getParams($component->element)->get('edit_fields', false)) !== false && self::checkObject($fields))
{
+ // load the fields script
+ self::getTabFieldsScript($component->element, $document);
// add the id field if the id was found (but hidden)
if ($id > 0)
{
@@ -2905,6 +4433,57 @@ abstract class MembersmanagerHelper
return $rows;
}
+
+ /**
+ * get the tab fields script
+ *
+ * @param object $component The target component
+ * @param array $document The document array to load script
+ *
+ * @return string
+ *
+ */
+ protected static function getTabFieldsScript(&$_component, &$document)
+ {
+ // get component name
+ $component = str_replace('com_', '', $_component);
+ // values to change in script
+ $replace = array(
+ 'jform_' => $component . '_',
+ 'updateFieldRequired' => $component . 'updateFieldRequired',
+ 'isSet' => $component . 'isSet',
+ 'vvvvv' => $component . 'uuuu'
+ );
+ // normal path to view javascript file
+ $script_path = JPATH_ADMINISTRATOR . '/components/' . $_component . '/models/forms/form.js';
+ // load the javascript for this view
+ if (file_exists($script_path) && ($script = self::getFileContents($script_path, false)) !== false)
+ {
+ // now update the script and add to document
+ $document[] = str_replace(array_keys($replace), array_values($replace), $script);
+ }
+ // normal path to view file
+ $view_path = JPATH_ADMINISTRATOR . '/components/' . $_component . '/views/form/tmpl/edit.php';
+ // load the javascript form this view
+ if (file_exists($view_path) && ($w_script = self::getFileContents($view_path, false)) !== false)
+ {
+ // get all script from view
+ $a_script = self::getAllBetween($w_script, '');
+ // check if we found any
+ if (self::checkArray($a_script))
+ {
+ foreach ($a_script as $_script)
+ {
+ if (strpos($_script, '// waiting spinner') === false && strpos($_script, '') === false)
+ {
+ // now update the script and add to document
+ $document[] = str_replace(array_keys($replace), array_values($replace), $_script);
+ }
+ }
+ }
+ }
+ }
+
/**
* get the tab table of links
*
@@ -2917,8 +4496,12 @@ abstract class MembersmanagerHelper
* @return string
*
*/
- protected static function getTabLinksTable($ids, &$item, &$comp, &$view, &$return)
+ protected static function getTabLinksTable($ids, &$item, &$comp, &$view, &$return, &$db)
{
+ // get component name
+ $component = str_replace('com_', '', $comp->element);
+ // get the database columns of this table
+ $columns = $db->getTableColumns("#__" . $component . "_form", false);
// get the global settings
$params = JComponentHelper::getParams($comp->element);
// get the profile fields
@@ -2931,40 +4514,63 @@ abstract class MembersmanagerHelper
{
$rows[] = '' . $create_button . ' | ';
}
- // build the links
- foreach ($ids as $id)
+ // see if id's are found
+ if (self::checkArray($ids))
{
- if (self::checkObject($profile_fields))
+ // build the links
+ foreach ($ids as $id)
{
- // the bucket
- $bucket = array();
- foreach ($profile_fields as $profile)
+ if (self::checkObject($profile_fields))
{
- $bucket[$profile->field] = self::getVar('form', $id, 'id', $profile->field, '=', str_replace('com_', '', $comp->element));
+ // the bucket
+ $bucket = array();
+ foreach ($profile_fields as $profile)
+ {
+ $bucket[$profile->field] = self::getVar('form', $id, 'id', $profile->field, '=', $component);
+ }
+ $rows[] = '' . implode(', ', $bucket) . self::getEditButton($id, 'form', 'forms', $_return, $comp->element) . ' | ';
+ }
+ else
+ {
+ // get creating date
+ $created = self::getVar('form', $id, 'id', 'created', '=', $component);
+ // set name
+ $name = self::fancyDayTimeDate($created);
+ // check if there is a name in table
+ if (isset($columns['name']))
+ {
+ // get name
+ $name = self::getVar('form', $id, 'id', 'name', '=', $component) . ' (' . $name . ')';
+ }
+ elseif (isset($columns['title']))
+ {
+ // get name
+ $name = self::getVar('form', $id, 'id', 'title', '=', $component) . ' (' . $name . ')';
+ }
+ $rows[] = '' . $name . self::getEditButton($id, 'form', 'forms', $_return, $comp->element) . ' | ';
}
- $rows[] = '' . implode(', ', $bucket) . self::getEditButton($id, 'form', 'forms', $_return, $comp->element) . ' | ';
- }
- else
- {
- $created = self::getVar('form', $id, 'id', 'created', '=', str_replace('com_', '', $comp->element));
- $rows[] = '' . self::fancyDayTimeDate($created) . self::getEditButton($id, 'form', 'forms', $_return, $comp->element) . ' | ';
}
}
- // set the header
- $head = array($comp->name);
- // return the table
- return self::setSubformTable($head, $rows, $view . '_' . $comp->name);
+ // check if we have rows
+ if (self::checkArray($rows))
+ {
+ // set the header
+ $head = array($comp->name);
+ // return the table
+ return self::setSubformTable($head, $rows, $view . '_' . $comp->name);
+ }
+ return false;
}
/**
* get the form fields
*
- * @param string $layout The layout array
- * @param string $code The tab/view code name
- * @param string $name The tab name
- * @param int $span The span trigger
- * @param bool $alert Show the alert
+ * @param string $layout The layout array
+ * @param string $code The tab/view code name
+ * @param string $name The tab name
+ * @param int $span The span trigger
+ * @param bool $alert Show the alert
*
* @return string
*
@@ -2976,7 +4582,7 @@ abstract class MembersmanagerHelper
{
$name = implode(' & ', array_keys($layout));
}
-$tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
+ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
$tmp .= PHP_EOL . '';
if (count((array) $layout) == 1)
{
@@ -3066,7 +4672,7 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
* @param object $date The main Data
* @param string $view The view name
*
- * @return string
+ * @return void
*
*/
public static function saveDynamicValues(&$data, $view = 'member')
@@ -3083,7 +4689,7 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
);
// check if we have methods
- if (self::checkArray($methods))
+ if (self::checkArray($methods) && isset($data['type'], $data['account']))
{
// get the app object
$app = JFactory::getApplication();
@@ -3208,7 +4814,7 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
$fieldActive['rules'] = 'rules';
// get the database columns of this table
$columns = $db->getTableColumns("#__" . $component . "_form", false);
- // no make sure the fields that are not editable are removed (so can't be updated via this form)
+ // now make sure the fields that are not editable are removed (so can't be updated via this form)
foreach(array_keys($columns) as $field)
{
if (!isset($fieldActive[$field]))
@@ -3259,6 +4865,249 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
}
+
+ /**
+ * save the relationships
+ *
+ * @param object $date The main Data
+ *
+ * @return void
+ *
+ */
+ public static function saveRelationships(&$data)
+ {
+ // get the app object
+ $app = JFactory::getApplication();
+ // get the user object
+ $user = JFactory::getUser();
+ // check if user may edit
+ if (0) // !$user->authorise('member.edit.type', 'com_membersmanager.member.' . (int) $data['id'])) (TODO)
+ {
+ $app->enqueueMessage(JText::_('COM_MEMBERSMANAGER_YOU_DO_NOT_HAVE_PERMISSION_TO_EDIT_THIS_MEMBER_RELATIONSHIPS_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR'), 'warning');
+ return;
+ }
+ // check if there is relationships and members in those relationships
+ if (self::checkArray($data) && isset($data['id']) && is_numeric($data['id']) && $data['id'] > 0 && isset($data['type'])
+ && ($relation_types = self::getRelationshipsByTypes($data['type'], $db, true)) !== false)
+ {
+ // get database object
+ $db = JFactory::getDbo();
+ // get the post object
+ $post = JFactory::getApplication()->input->post;
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ // build insert query
+ $query->insert($db->quoteName('#__membersmanager_relation_map'));
+ // Insert columns.
+ $columns = array('relation', 'member', 'type');
+ $query->columns($db->quoteName($columns));
+ // found values
+ $found = false;
+ // start looping the methods
+ foreach ($relation_types as $type)
+ {
+ // delete all previous set relationships of this member and type
+ self::deleteRelationship($data['id'], $type->id, $db);
+ // get components
+ $get = 'relationship_mapping_' . self::safeString($type->name);
+ // get the posted date if there were any
+ $_values = $post->get($get, array(), 'array');
+ // check if we found relationships
+ if (self::checkArray($_values))
+ {
+ // build the values
+ foreach ($_values as $_value)
+ {
+ if (is_numeric($_value) && $_value > 0)
+ {
+ $query->values((int) $_value . ',' . (int) $data['id'] . ',' . (int) $type->id);
+ }
+ }
+ $found = true;
+ }
+ }
+ // save relationship if found
+ if ($found)
+ {
+ // Set the query using our newly populated query object and execute it.
+ $db->setQuery($query);
+ $db->execute();
+ }
+ }
+ }
+
+ /**
+ * delete the relationships
+ *
+ * @param int $member The member ID
+ * @param int $type The type ID
+ *
+ * @return void
+ *
+ */
+ public static function deleteRelationship(&$member, &$type, &$db)
+ {
+ $query = $db->getQuery(true);
+ // delete all types the are linked to this member
+ $conditions = array(
+ $db->quoteName('member') . ' = ' . (int) $member,
+ $db->quoteName('type') . ' = ' . (int) $type
+ );
+ $query->delete($db->quoteName('#__membersmanager_relation_map'));
+ $query->where($conditions);
+ $db->setQuery($query);
+ $db->execute();
+ }
+
+
+ /**
+ * update the type map, for quick search
+ *
+ * @param int $member The member ID
+ * @param string/array $types The types
+ *
+ * @return void
+ *
+ */
+ public static function updateTypes(&$member, $types = null)
+ {
+ // get the app object
+ $app = JFactory::getApplication();
+ // get the user object
+ $user = JFactory::getUser();
+ // check if user may edit
+ if (!$user->authorise('member.edit.type', 'com_membersmanager.member.' . (int) $member))
+ {
+ $app->enqueueMessage(JText::_('COM_MEMBERSMANAGER_YOU_DO_NOT_HAVE_PERMISSION_TO_EDIT_THIS_MEMBER_TYPE_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR'), 'warning');
+ return;
+ }
+ // get database object
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true);
+ // delete all types the are linked to this member
+ $conditions = array(
+ $db->quoteName('member') . ' = ' . (int) $member
+ );
+ $query->delete($db->quoteName('#__membersmanager_type_map'));
+ $query->where($conditions);
+ $db->setQuery($query);
+ $db->execute();
+ // now set the new values
+ if (self::checkArray($types))
+ {
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ // Insert columns.
+ $columns = array('member', 'type');
+ // build insert query
+ $query->insert($db->quoteName('#__membersmanager_type_map'));
+ $query->columns($db->quoteName($columns));
+ // build the values
+ foreach ($types as $type)
+ {
+ $query->values((int) $member . ',' . (int) $type);
+ }
+ // Set the query using our newly populated query object and execute it.
+ $db->setQuery($query);
+ $db->execute();
+ }
+ }
+
+
+ /**
+ * Array Partitioning Function
+ *
+ * @link http://php.net/manual/en/function.array-chunk.php#75022
+ * Thanks to azspot at gmail dot com
+ *
+ * @param array $array
+ * The array to work on
+ *
+ * @param int $size
+ * The size of each chunk
+ *
+ * @param bool $preserve_keys [optional]
+ * When set to TRUE keys will be preserved.
+ * Default is FALSE which will reindex the chunk numerically
+ *
+ *
+ * @return array a multidimensional numerically indexed array, starting with zero,
+ * with each dimension containing size elements.
+ */
+ public static function array_partition($array, $size, $preserve_keys = FALSE)
+ {
+ // set some key values
+ $arraylen = count((array) $array );
+ $partlen = floor( $arraylen / $size );
+ $partrem = $arraylen % $size;
+ // start the partition builder
+ $partition = array();
+ $offset = 0;
+ for ($sizex = 0; $sizex < $size; $sizex++)
+ {
+ // get the partition length
+ $length = ($sizex < $partrem) ? $partlen + 1 : $partlen;
+ // set the partition values
+ $partition[$sizex] = array_slice($array, $offset, $length, $preserve_keys);
+ // update the offset
+ $offset += $length;
+ }
+ return $partition;
+ }
+
+
+ /**
+ * get the content of a file
+ *
+ * @param string $path The path to the file
+ * @param string/bool $none The return value if no content was found
+ *
+ * @return string On success
+ *
+ */
+ public static function getFileContents($path, $none = '')
+ {
+ if (self::checkString($path))
+ {
+ // use basic file get content for now
+ if (($content = @file_get_contents($path)) !== FALSE)
+ {
+ return $content;
+ }
+ // use curl if available
+ elseif (function_exists('curl_version'))
+ {
+ // start curl
+ $ch = curl_init();
+ // set the options
+ $options = array();
+ $options[CURLOPT_URL] = $path;
+ $options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12';
+ $options[CURLOPT_RETURNTRANSFER] = TRUE;
+ $options[CURLOPT_SSL_VERIFYPEER] = FALSE;
+ // load the options
+ curl_setopt_array($ch, $options);
+ // get the content
+ $content = curl_exec($ch);
+ // close the connection
+ curl_close($ch);
+ // return if found
+ if (self::checkString($content))
+ {
+ return $content;
+ }
+ }
+ elseif (property_exists('MembersmanagerHelper', 'curlErrorLoaded') && !self::$curlErrorLoaded)
+ {
+ // set the notice
+ JFactory::getApplication()->enqueueMessage(JText::_('COM_MEMBERSMANAGER_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BMEMBERSMANAGERB_WILL_NOT_FUNCTION_CORRECTLYP'), 'Error');
+ // load this notice only once
+ self::$curlErrorLoaded = true;
+ }
+ }
+ return $none;
+ }
+
public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
{
@@ -3309,7 +5158,7 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Load the Component xml manifest.
+ * Load the Component xml manifest.
**/
public static function manifest()
{
@@ -3318,12 +5167,12 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Joomla version object
+ * Joomla version object
**/
protected static $JVersion;
/**
- * set/get Joomla version
+ * set/get Joomla version
**/
public static function jVersion()
{
@@ -3336,7 +5185,7 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Load the Contributors details.
+ * Load the Contributors details.
**/
public static function getContributors()
{
@@ -3382,7 +5231,7 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Get any component's model
+ * Get any component's model
**/
public static function getModel($name, $path = JPATH_COMPONENT_SITE, $component = 'Membersmanager', $config = array())
{
@@ -3426,9 +5275,9 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Add to asset Table
+ * Add to asset Table
*/
- public static function setAsset($id,$table)
+ public static function setAsset($id, $table, $inherit = true)
{
$parent = JTable::getInstance('Asset');
$parent->loadByName('com_membersmanager');
@@ -3445,8 +5294,6 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
if ($error)
{
- $this->setError($error);
-
return false;
}
else
@@ -3462,7 +5309,7 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
$asset->name = $name;
$asset->title = $title;
// get the default asset rules
- $rules = self::getDefaultAssetRules('com_membersmanager',$table);
+ $rules = self::getDefaultAssetRules('com_membersmanager', $table, $inherit);
if ($rules instanceof JAccessRules)
{
$asset->rules = (string) $rules;
@@ -3490,55 +5337,62 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Gets the default asset Rules for a component/view.
+ * Gets the default asset Rules for a component/view.
*/
- protected static function getDefaultAssetRules($component,$view)
+ protected static function getDefaultAssetRules($component, $view, $inherit = true)
{
- // Need to find the asset id by the name of the component.
- $db = JFactory::getDbo();
- $query = $db->getQuery(true)
- ->select($db->quoteName('id'))
- ->from($db->quoteName('#__assets'))
- ->where($db->quoteName('name') . ' = ' . $db->quote($component));
- $db->setQuery($query);
- $db->execute();
- if ($db->loadRowList())
+ // if new or inherited
+ $assetId = 0;
+ // Only get the actual item rules if not inheriting
+ if (!$inherit)
{
- // asset alread set so use saved rules
- $assetId = (int) $db->loadResult();
- $result = JAccess::getAssetRules($assetId);
- if ($result instanceof JAccessRules)
+ // Need to find the asset id by the name of the component.
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true)
+ ->select($db->quoteName('id'))
+ ->from($db->quoteName('#__assets'))
+ ->where($db->quoteName('name') . ' = ' . $db->quote($component));
+ $db->setQuery($query);
+ $db->execute();
+ // check that there is a value
+ if ($db->getNumRows())
{
- $_result = (string) $result;
- $_result = json_decode($_result);
- foreach ($_result as $name => &$rule)
- {
- $v = explode('.', $name);
- if ($view !== $v[0])
- {
- // remove since it is not part of this view
- unset($_result->$name);
- }
- else
- {
- // clear the value since we inherit
- $rule = array();
- }
- }
- // check if there are any view values remaining
- if (count((array)$_result))
- {
- $_result = json_encode($_result);
- $_result = array($_result);
- // Instantiate and return the JAccessRules object for the asset rules.
- $rules = new JAccessRules($_result);
-
- return $rules;
- }
- return $result;
+ // asset already set so use saved rules
+ $assetId = (int) $db->loadResult();
}
}
- return JAccess::getAssetRules(0);
+ // get asset rules
+ $result = JAccess::getAssetRules($assetId);
+ if ($result instanceof JAccessRules)
+ {
+ $_result = (string) $result;
+ $_result = json_decode($_result);
+ foreach ($_result as $name => &$rule)
+ {
+ $v = explode('.', $name);
+ if ($view !== $v[0])
+ {
+ // remove since it is not part of this view
+ unset($_result->$name);
+ }
+ elseif ($inherit)
+ {
+ // clear the value since we inherit
+ $rule = array();
+ }
+ }
+ // check if there are any view values remaining
+ if (count($_result))
+ {
+ $_result = json_encode($_result);
+ $_result = array($_result);
+ // Instantiate and return the JAccessRules object for the asset rules.
+ $rules = new JAccessRules($_result);
+ // return filtered rules
+ return $rules;
+ }
+ }
+ return $result;
}
/**
@@ -4291,11 +6145,11 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Check if have an json string
+ * Check if have an json string
*
- * @input string The json string to check
+ * @input string The json string to check
*
- * @returns bool true on success
+ * @returns bool true on success
**/
public static function checkJson($string)
{
@@ -4308,11 +6162,11 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Check if have an object with a length
+ * Check if have an object with a length
*
- * @input object The object to check
+ * @input object The object to check
*
- * @returns bool true on success
+ * @returns bool true on success
**/
public static function checkObject($object)
{
@@ -4324,15 +6178,15 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Check if have an array with a length
+ * Check if have an array with a length
*
- * @input array The array to check
+ * @input array The array to check
*
- * @returns bool true on success
+ * @returns bool/int number of items in array on success
**/
public static function checkArray($array, $removeEmptyString = false)
{
- if (isset($array) && is_array($array) && count((array)$array) > 0)
+ if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
@@ -4346,17 +6200,17 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
return self::checkArray($array, false);
}
- return true;
+ return $nr;
}
return false;
}
/**
- * Check if have a string with a length
+ * Check if have a string with a length
*
- * @input string The string to check
+ * @input string The string to check
*
- * @returns bool true on success
+ * @returns bool true on success
**/
public static function checkString($string)
{
@@ -4368,10 +6222,10 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Check if we are connected
- * Thanks https://stackoverflow.com/a/4860432/1429677
+ * Check if we are connected
+ * Thanks https://stackoverflow.com/a/4860432/1429677
*
- * @returns bool true on success
+ * @returns bool true on success
**/
public static function isConnected()
{
@@ -4393,11 +6247,11 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Merge an array of array's
+ * Merge an array of array's
*
- * @input array The arrays you would like to merge
+ * @input array The arrays you would like to merge
*
- * @returns array on success
+ * @returns array on success
**/
public static function mergeArrays($arrays)
{
@@ -4423,11 +6277,11 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Shorten a string
+ * Shorten a string
*
- * @input string The you would like to shorten
+ * @input string The you would like to shorten
*
- * @returns string on success
+ * @returns string on success
**/
public static function shorten($string, $length = 40, $addTip = true)
{
@@ -4464,11 +6318,11 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Making strings safe (various ways)
+ * Making strings safe (various ways)
*
- * @input string The you would like to make safe
+ * @input string The you would like to make safe
*
- * @returns string on success
+ * @returns string on success
**/
public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
@@ -4608,11 +6462,11 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Convert an integer into an English word string
- * Thanks to Tom Nicholson
+ * Convert an integer into an English word string
+ * Thanks to Tom Nicholson
*
- * @input an int
- * @returns a string
+ * @input an int
+ * @returns a string
**/
public static function numberToString($x)
{
@@ -4699,9 +6553,9 @@ $tmp = JHtml::_('bootstrap.addTab', $code . 'Tab', self::randomkey(10), $name);
}
/**
- * Random Key
+ * Random Key
*
- * @returns a string
+ * @returns a string
**/
public static function randomkey($size)
{
diff --git a/site/helpers/route.php b/site/helpers/route.php
index 9b2afbe..78b40db 100644
--- a/site/helpers/route.php
+++ b/site/helpers/route.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -19,6 +19,49 @@ abstract class MembersmanagerHelperRoute
{
protected static $lookup;
+ /**
+ * @param int The route of the Members
+ */
+ public static function getMembersRoute($id = 0, $catid = 0)
+ {
+ if ($id > 0)
+ {
+ // Initialize the needel array.
+ $needles = array(
+ 'members' => array((int) $id)
+ );
+ // Create the link
+ $link = 'index.php?option=com_membersmanager&view=members&id='. $id;
+ }
+ else
+ {
+ // Initialize the needel array.
+ $needles = array(
+ 'members' => array()
+ );
+ // Create the link but don't add the id.
+ $link = 'index.php?option=com_membersmanager&view=members';
+ }
+ if ($catid > 1)
+ {
+ $categories = JCategories::getInstance('membersmanager.members');
+ $category = $categories->get($catid);
+ if ($category)
+ {
+ $needles['category'] = array_reverse($category->getPath());
+ $needles['categories'] = $needles['category'];
+ $link .= '&catid='.$catid;
+ }
+ }
+
+ if ($item = self::_findItem($needles))
+ {
+ $link .= '&Itemid='.$item;
+ }
+
+ return $link;
+ }
+
/**
* @param int The route of the Cpanel
*/
@@ -36,8 +79,10 @@ abstract class MembersmanagerHelperRoute
else
{
// Initialize the needel array.
- $needles = array();
- //Create the link but don't add the id.
+ $needles = array(
+ 'cpanel' => array()
+ );
+ // Create the link but don't add the id.
$link = 'index.php?option=com_membersmanager&view=cpanel';
}
if ($catid > 1)
@@ -77,8 +122,10 @@ abstract class MembersmanagerHelperRoute
else
{
// Initialize the needel array.
- $needles = array();
- //Create the link but don't add the id.
+ $needles = array(
+ 'profile' => array()
+ );
+ // Create the link but don't add the id.
$link = 'index.php?option=com_membersmanager&view=profile';
}
if ($catid > 1)
@@ -185,8 +232,8 @@ abstract class MembersmanagerHelperRoute
}
}
return $link;
- }
-
+ }
+
protected static function _findItem($needles = null,$type = null)
{
$app = JFactory::getApplication();
@@ -234,6 +281,10 @@ abstract class MembersmanagerHelperRoute
self::$lookup[$language][$view][$item->query['id']] = $item->id;
}
}
+ else
+ {
+ self::$lookup[$language][$view][0] = $item->id;
+ }
}
}
}
@@ -244,17 +295,24 @@ abstract class MembersmanagerHelperRoute
{
if (isset(self::$lookup[$language][$view]))
{
- foreach ($ids as $id)
+ if (MembersmanagerHelper::checkArray($ids))
{
- if (isset(self::$lookup[$language][$view][(int) $id]))
+ foreach ($ids as $id)
{
- return self::$lookup[$language][$view][(int) $id];
+ if (isset(self::$lookup[$language][$view][(int) $id]))
+ {
+ return self::$lookup[$language][$view][(int) $id];
+ }
}
}
+ elseif (isset(self::$lookup[$language][$view][0]))
+ {
+ return self::$lookup[$language][$view][0];
+ }
}
}
}
-
+
if ($type)
{
// Check if the global menu item has been set.
diff --git a/site/language/en-GB/en-GB.com_membersmanager.ini b/site/language/en-GB/en-GB.com_membersmanager.ini
index d20077f..d97ea68 100644
--- a/site/language/en-GB/en-GB.com_membersmanager.ini
+++ b/site/language/en-GB/en-GB.com_membersmanager.ini
@@ -6,6 +6,7 @@ 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_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"
@@ -13,22 +14,25 @@ COM_MEMBERSMANAGER_COULD_NOT_UPLOAD_THE_FILE="Could not upload the file!"
COM_MEMBERSMANAGER_CPANEL="cPanel"
COM_MEMBERSMANAGER_CPANEL_DESC="Control Panel for Members"
COM_MEMBERSMANAGER_CREATE="Create"
-COM_MEMBERSMANAGER_CREATE_A_REGION="create a region"
COM_MEMBERSMANAGER_CREATE_NEW_S="Create New %s"
COM_MEMBERSMANAGER_DOES_NOT_HAVE_A_VALID_FILE_TYPE="Does not have a valid file type."
COM_MEMBERSMANAGER_DOWNLOAD="Download"
COM_MEMBERSMANAGER_EDIT="Edit"
COM_MEMBERSMANAGER_EDIT_S="Edit %s"
-COM_MEMBERSMANAGER_EXTRA_INFO_AREA="Extra info area"
COM_MEMBERSMANAGER_FORMS="Forms"
+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_LOADING="Loading"
COM_MEMBERSMANAGER_LOGIN_MODULE_POSITION="Login Module Position"
COM_MEMBERSMANAGER_MAIN_MEMBER="Main Member"
+COM_MEMBERSMANAGER_MAKE_A_SELECTION_TO_CREATE_A_RELATIONSHIP="Make a selection to create a relationship."
COM_MEMBERSMANAGER_MEMBER="Member"
COM_MEMBERSMANAGER_MEMBERS="Members"
COM_MEMBERSMANAGER_MEMBERS_BATCH_OPTIONS="Batch process the selected Members"
COM_MEMBERSMANAGER_MEMBERS_BATCH_TIP="All changes will be applied to all selected Members"
+COM_MEMBERSMANAGER_MEMBERS_DESC="Any List of Member Details"
COM_MEMBERSMANAGER_MEMBERS_N_ITEMS_ARCHIVED="%s Members archived."
COM_MEMBERSMANAGER_MEMBERS_N_ITEMS_ARCHIVED_1="%s Member archived."
COM_MEMBERSMANAGER_MEMBERS_N_ITEMS_CHECKED_IN_0="No Member successfully checked in."
@@ -145,26 +149,27 @@ 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_MORE_SOON="More Soon"
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!"
COM_MEMBERSMANAGER_NOT_AUTHORISED_TO_VIEW_PROFILE="Not authorised to view profile!"
+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_DETAILS_FOUND="No Details Found"
COM_MEMBERSMANAGER_NO_IMPORT_FILE_SELECTED="No import file selected."
COM_MEMBERSMANAGER_NO_MEMBER_WAS_FOUND="No member was found"
-COM_MEMBERSMANAGER_NO_NAME="No Name"
-COM_MEMBERSMANAGER_NO_PLACEHOLDERS_WERE_FOUND_PLEASE_TRY_AGAIN_LATER="No placeholders were found, please try again later."
COM_MEMBERSMANAGER_NO_PROFILE_FOUND="No Profile Found"
COM_MEMBERSMANAGER_NO_REPORTS_FOUND="No reports found"
-COM_MEMBERSMANAGER_NO_REPORTS_FOUND_IN_S="No reports found in %s"
+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_OPEN="Open"
COM_MEMBERSMANAGER_OPEN_CPANEL="Open cPanel"
COM_MEMBERSMANAGER_OPEN_MAIN_MEMBER_PROFILE="Open Main Member Profile"
COM_MEMBERSMANAGER_OPEN_PROFILE="Open Profile"
COM_MEMBERSMANAGER_OR="or"
+COM_MEMBERSMANAGER_PLACEHOLDERS_NOT_FOUND="Placeholders not found"
COM_MEMBERSMANAGER_PLEASE_ENABLE_POPUPS_IN_YOUR_BROWSER_FOR_THIS_WEBSITE_TO_PRINT_THESE_DETAILS="Please enable pop-ups in your browser for this website to print these details!"
COM_MEMBERSMANAGER_PLEASE_PUBLISH_A_LOGIN_MODULE_TO_THIS_CODESLOGINCODE_POSITION_AND_INSURE_THAT_YOU_TARGET_THESE_PAGES_THIS_IS_POSSIBLE_IF_YOU_ADD_THE_MODULE_TO_ALL_PAGES_SINCE_THIS_MODULE_POSITION_SHOULD_ONLY_BE_AVAILABLE_IN_THIS_COMPONENT="Please publish a login module to this %s-login position, and insure that you target these pages. This is possible if you add the module to all pages, since this module position should only be available in this component."
COM_MEMBERSMANAGER_PRINT="Print"
@@ -172,26 +177,29 @@ COM_MEMBERSMANAGER_PRINT_CLOSE="Print & Close"
COM_MEMBERSMANAGER_PROFILE="Member Profile"
COM_MEMBERSMANAGER_PROFILE_DESC="Member Profile"
COM_MEMBERSMANAGER_PROPORTIONALLY="proportionally"
+COM_MEMBERSMANAGER_RELATIONSHIPS="Relationships"
COM_MEMBERSMANAGER_REMOVE="Remove"
COM_MEMBERSMANAGER_REPORTS="Reports"
COM_MEMBERSMANAGER_SEARCH_MEMBERS_BY_NAME_TOKEN_OR_EMAIL_HERE="Search members by name, token or email here..."
-COM_MEMBERSMANAGER_SELECT_A_REGION="select a region"
COM_MEMBERSMANAGER_SEND_REPORT="Send Report"
COM_MEMBERSMANAGER_S_COULD_NOT_BE_SAVED_PLEASE_TRY_AGAIN_THIS_COULD_BE_DUE_TO_THE_FACT_THIS_THE_MEMBER_ID_WAS_NOT_READY="%s could not be saved, please try again. This could be due to the fact this the member ID was not ready."
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_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"
COM_MEMBERSMANAGER_VALUE_ALREADY_TAKEN_PLEASE_TRY_AGAIN="Value already taken, please try again."
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_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."
COM_MEMBERSMANAGER_YOU_DO_NOT_HAVE_PERMISSION_TO_REMOVE_THIS_FILE="You do not have permission to remove this file."
COM_MEMBERSMANAGER_YOU_DO_NOT_HAVE_PERMISSION_TO_UPLOAD_AN="You do not have permission to upload an"
-COM_MEMBERSMANAGER_YOU_WILL_BE_REDIRECTED_TO_AN_EDIT_VIEW_YOU_SURE_YOU_WANT_TO_CONTINUE="You will be redirected to an edit view, you sure you want to continue?"
COM_MEMBERSMANAGER__HAS_BEEN_CHECKED_OUT_BY_S="% has been checked out by %s"
JGLOBAL_FIELD_ID_DESC="Record number in the database."
JGLOBAL_FIELD_ID_LABEL="ID"
diff --git a/site/layouts/list_name_value.php b/site/layouts/list_name_value.php
index 9b6eba9..b7f0d27 100644
--- a/site/layouts/list_name_value.php
+++ b/site/layouts/list_name_value.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/layouts/many_list_name_value.php b/site/layouts/many_list_name_value.php
index 2af7091..4348558 100644
--- a/site/layouts/many_list_name_value.php
+++ b/site/layouts/many_list_name_value.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -12,7 +12,38 @@
// No direct access to this file
defined('JPATH_BASE') or die('Restricted access');
-
+$ignore = array('id', 'created', 'modified');
?>
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ...
+
diff --git a/site/layouts/member/membership_above.php b/site/layouts/member/membership_above.php
index 2c4cf6f..465b5d4 100644
--- a/site/layouts/member/membership_above.php
+++ b/site/layouts/member/membership_above.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/layouts/member/membership_left.php b/site/layouts/member/membership_left.php
index 343768d..6da2add 100644
--- a/site/layouts/member/membership_left.php
+++ b/site/layouts/member/membership_left.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/layouts/member/membership_right.php b/site/layouts/member/membership_right.php
index d3e9d37..06ff934 100644
--- a/site/layouts/member/membership_right.php
+++ b/site/layouts/member/membership_right.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/layouts/member/publishing.php b/site/layouts/member/publishing.php
index aeaea28..2778547 100644
--- a/site/layouts/member/publishing.php
+++ b/site/layouts/member/publishing.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/layouts/member/publlshing.php b/site/layouts/member/publlshing.php
index 666edf5..7a32c45 100644
--- a/site/layouts/member/publlshing.php
+++ b/site/layouts/member/publlshing.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/layouts/panelbox.php b/site/layouts/panelbox.php
index 38cf28a..3b1481a 100644
--- a/site/layouts/panelbox.php
+++ b/site/layouts/panelbox.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/layouts/profile_uikit_three.php b/site/layouts/profile_uikit_three.php
index b5e1cd9..1a12a94 100644
--- a/site/layouts/profile_uikit_three.php
+++ b/site/layouts/profile_uikit_three.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/layouts/profile_uikit_two.php b/site/layouts/profile_uikit_two.php
index 0ce1268..ca7fac6 100644
--- a/site/layouts/profile_uikit_two.php
+++ b/site/layouts/profile_uikit_two.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/layouts/profileassessment_uikit_three.php b/site/layouts/profileassessment_uikit_three.php
index ea36c9a..bc27e3f 100644
--- a/site/layouts/profileassessment_uikit_three.php
+++ b/site/layouts/profileassessment_uikit_three.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -33,12 +33,26 @@ if ($displayData->setAssessment)
{
foreach ($displayData->assessments[$_name][$_nr] as $_pointer => &$value)
{
- $value->name = $assess->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]))
{
- $displayData->assessments[$_name][$_nr]->name = $assess->name;
+ 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;
+ }
}
}
}
@@ -47,7 +61,14 @@ if ($displayData->setAssessment)
$displayData->assessments[$_name] = MembersmanagerHelper::getAnyFormDetails($displayData->id, 'member', $assessment->element, 'object', 'profile');
if (MembersmanagerHelper::checkObject($displayData->assessments[$_name]))
{
- $displayData->assessments[$_name]->name = $assessment->name;
+ if (isset($displayData->assessments[$_name]->name) && MembersmanagerHelper::checkString($displayData->assessments[$_name]->name))
+ {
+ $displayData->assessments[$_name]->name = $assessment->name . ' - ' . $displayData->assessments[$_name]->name;
+ }
+ else
+ {
+ $displayData->assessments[$_name]->name = $assessment->name;
+ }
}
}
}
@@ -60,51 +81,10 @@ if ($displayData->setAssessment)
assessmentAvailable))); ?>
-
-
-
-
-
-
+
-
-
-
- assessmentAvailable as $typeAssesmentName => $components) : ?>
-
-
-
-
- - name; ?>
-
-
- id, 'member', 'id', '=', str_replace("com_", "", $components->element))) !== false): ?>
- return_path, $components->element)) !== false): ?>
- - name; ?>
-
-
- - name; ?>
-
-
-
-
-
-
-
-
+
diff --git a/site/layouts/profileassessment_uikit_two.php b/site/layouts/profileassessment_uikit_two.php
index dedbc9f..ac15b5d 100644
--- a/site/layouts/profileassessment_uikit_two.php
+++ b/site/layouts/profileassessment_uikit_two.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -33,12 +33,26 @@ if ($displayData->setAssessment)
{
foreach ($displayData->assessments[$_name][$_nr] as $_pointer => &$value)
{
- $value->name = $assess->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]))
{
- $displayData->assessments[$_name][$_nr]->name = $assess->name;
+ 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;
+ }
}
}
}
@@ -47,7 +61,14 @@ if ($displayData->setAssessment)
$displayData->assessments[$_name] = MembersmanagerHelper::getAnyFormDetails($displayData->id, 'member', $assessment->element, 'object', 'profile');
if (MembersmanagerHelper::checkObject($displayData->assessments[$_name]))
{
- $displayData->assessments[$_name]->name = $assessment->name;
+ if (isset($displayData->assessments[$_name]->name) && MembersmanagerHelper::checkString($displayData->assessments[$_name]->name))
+ {
+ $displayData->assessments[$_name]->name = $assessment->name . ' - ' . $displayData->assessments[$_name]->name;
+ }
+ else
+ {
+ $displayData->assessments[$_name]->name = $assessment->name;
+ }
}
}
}
@@ -60,51 +81,10 @@ if ($displayData->setAssessment)
assessmentAvailable))); ?>
-
-
+
-
-
-
- assessmentAvailable as $typeAssesmentName => $components) : ?>
-
-
-
-
- - name; ?>
-
-
- id, 'member', 'id', '=', str_replace("com_", "", $components->element))) !== false): ?>
- return_path, $components->element)) !== false): ?>
- - name; ?>
-
-
- - name; ?>
-
-
-
-
-
-
-
-
+
diff --git a/site/layouts/profileassessmentselection_uikit_three.php b/site/layouts/profileassessmentselection_uikit_three.php
new file mode 100644
index 0000000..7969bcc
--- /dev/null
+++ b/site/layouts/profileassessmentselection_uikit_three.php
@@ -0,0 +1,41 @@
+
+ * @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');
+
+
+
+?>
+
+
+
+ assessmentAvailable as $typeAssesmentName => $components) : ?>
+
+
+
+
+ - name; ?>
+
+
+ id, 'member', 'id', '=', str_replace("com_", "", $components->element))) !== false): ?>
+ return_path, $components->element)) !== false): ?>
+ - name; ?>
+
+
+ - name; ?>
+
+
+
+
+
+
+
diff --git a/site/layouts/profileassessmentselection_uikit_two.php b/site/layouts/profileassessmentselection_uikit_two.php
new file mode 100644
index 0000000..0c4443f
--- /dev/null
+++ b/site/layouts/profileassessmentselection_uikit_two.php
@@ -0,0 +1,41 @@
+
+ * @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');
+
+
+
+?>
+
+
+
+ assessmentAvailable as $typeAssesmentName => $components) : ?>
+
+
+
+
+ - name; ?>
+
+
+ id, 'member', 'id', '=', str_replace("com_", "", $components->element))) !== false): ?>
+ return_path, $components->element)) !== false): ?>
+ - name; ?>
+
+
+ - name; ?>
+
+
+
+
+
+
+
diff --git a/site/layouts/profilebuttons_uikit_three.php b/site/layouts/profilebuttons_uikit_three.php
new file mode 100644
index 0000000..08db040
--- /dev/null
+++ b/site/layouts/profilebuttons_uikit_three.php
@@ -0,0 +1,38 @@
+
+ * @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/profilebuttons_uikit_two.php b/site/layouts/profilebuttons_uikit_two.php
new file mode 100644
index 0000000..120b12a
--- /dev/null
+++ b/site/layouts/profilebuttons_uikit_two.php
@@ -0,0 +1,38 @@
+
+ * @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/profiledetails_uikit_three.php b/site/layouts/profiledetails_uikit_three.php
index ee23627..36787f9 100644
--- a/site/layouts/profiledetails_uikit_three.php
+++ b/site/layouts/profiledetails_uikit_three.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -28,25 +28,43 @@ if ($setInfo)
$infoDetails[$_nr] = MembersmanagerHelper::getAnyFormDetails($displayData->id, 'member', $info->element, 'array', 'profile');
}
}
+// get DB
+$db = JFactory::getDBO();
+// set relationships to false
+$relationships = false;
+// get the types of relationships available to this member
+if (($relationshipTypes = MembersmanagerHelper::getRelationshipsByTypes($displayData->type, $db, false, true, false)) !== false)
+{
+ // load relationships
+ $relationships = MembersmanagerHelper::getRelationshipsByMember($displayData->id, $db, 'member');
+}
?>
-
+
- 3) : ?>
+ 3) : ?>
- $infoDetail): ?>
- params->membersmanager_relation_type) && 2 == $infoAvailable[$_nr]->params->membersmanager_relation_type): ?>
- - $infoDetail, 'com' => $infoAvailable[$_nr]->element, 'user' => $displayData->_USER)); ?>
-
- - $infoDetail, 'com' => $infoAvailable[$_nr]->element, 'user' => $displayData->_USER)); ?>
-
-
+
+ $infoDetail): ?>
+ params->membersmanager_relation_type) && 2 == $infoAvailable[$_nr]->params->membersmanager_relation_type): ?>
+ - $displayData->id, 'data' => $infoDetail, 'com' => $infoAvailable[$_nr]->element, 'return_path' => $displayData->return_path)); ?>
+
+ - $infoDetail, 'com' => $infoAvailable[$_nr]->element, 'user' => $displayData->_USER)); ?>
+
+
+
+ $displayData->id, 'relationshipTypes' => $relationshipTypes, 'relationships' => $relationships, 'return_path' => $displayData->return_path)); ?>
diff --git a/site/layouts/profiledetails_uikit_two.php b/site/layouts/profiledetails_uikit_two.php
index 99e56ac..2ea3077 100644
--- a/site/layouts/profiledetails_uikit_two.php
+++ b/site/layouts/profiledetails_uikit_two.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -28,19 +28,37 @@ if ($setInfo)
$infoDetails[$_nr] = MembersmanagerHelper::getAnyFormDetails($displayData->id, 'member', $info->element, 'array', 'profile');
}
}
+// get DB
+$db = JFactory::getDBO();
+// set relationships to false
+$relationships = false;
+// get the types of relationships available to this member
+if (($relationshipTypes = MembersmanagerHelper::getRelationshipsByTypes($displayData->type, $db, false, true, false)) !== false)
+{
+ // load relationships
+ $relationships = MembersmanagerHelper::getRelationshipsByMember($displayData->id, $db, 'member');
+}
?>
-
+
- $infoDetail): ?>
- params->membersmanager_relation_type) && 2 == $infoAvailable[$_nr]->params->membersmanager_relation_type): ?>
- - $infoDetail, 'com' => $infoAvailable[$_nr]->element, 'user' => $displayData->_USER)); ?>
-
- - $infoDetail, 'com' => $infoAvailable[$_nr]->element, 'user' => $displayData->_USER)); ?>
-
-
+
+ $infoDetail): ?>
+ params->membersmanager_relation_type) && 2 == $infoAvailable[$_nr]->params->membersmanager_relation_type): ?>
+ - $displayData->id, 'data' => $infoDetail, 'com' => $infoAvailable[$_nr]->element, 'return_path' => $displayData->return_path)); ?>
+
+ - $infoDetail, 'com' => $infoAvailable[$_nr]->element, 'user' => $displayData->_USER)); ?>
+
+
+
+ $displayData->id, 'relationshipTypes' => $relationshipTypes, 'relationships' => $relationships, 'return_path' => $displayData->return_path)); ?>
diff --git a/site/layouts/profileextra_uikit_three.php b/site/layouts/profileextra_uikit_three.php
index 9a623eb..fed921c 100644
--- a/site/layouts/profileextra_uikit_three.php
+++ b/site/layouts/profileextra_uikit_three.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -12,11 +12,84 @@
// No direct access to this file
defined('JPATH_BASE') or die('Restricted access');
-
+
+// set default chart switch to false
+$displayData->setCharts = false;
+// get names and values if found
+if ($displayData->setAssessment)
+{
+ // get Document
+ $document = JFactory::getDocument();
+ // Chart Target Types
+ $targets = array(2,3);
+ // get chart details
+ $displayData->charts = array();
+ $_y = MembersmanagerHelper::safeString($displayData->id);
+ foreach ($displayData->assessmentAvailable as $_name => $assessment)
+ {
+ // set the chart array per/assessment type
+ $displayData->charts[$_name] = array();
+ if (MembersmanagerHelper::checkArray($assessment))
+ {
+ foreach ($assessment as $_nr => $assess)
+ {
+ foreach ($targets as $target)
+ {
+ if (($carts = MembersmanagerHelper::getAnyAvailableCharts(null, $target, $assess->element)) !== false)
+ {
+ foreach ($carts as $key => $cartData)
+ {
+ if (($dataTable = MembersmanagerHelper::getAnyMultiChartDataTable($displayData->id, $target, $key, $assess->element)) !== ''
+ && ($code = MembersmanagerHelper::getAnyChartCode($key . $_y, $dataTable, $cartData['details'], 'profile', $assess->element)) !== false)
+ {
+ // load code
+ $displayData->charts[$_name][] = $code;
+ // add script to document
+ $document->addScriptDeclaration($code['script']);
+ // set loading of charts
+ $displayData->setCharts = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ elseif (MembersmanagerHelper::checkObject($assessment) && isset($assessment->element))
+ {
+ foreach ($targets as $target)
+ {
+ if (($carts = MembersmanagerHelper::getAnyAvailableCharts(null, $target, $assess->element)) !== false)
+ {
+ foreach ($carts as $key => $cartData)
+ {
+ if (($dataTable = MembersmanagerHelper::getAnyMultiChartDataTable($displayData->id, $target, $key, $assessment->element)) !== ''
+ && ($code = MembersmanagerHelper::getAnyChartCode($key . $_y, $dataTable, $cartData['details'], 'profile', $assessment->element)) !== false)
+ {
+ // load code
+ $displayData->charts[$_name][] = $code;
+ // add script to document
+ $document->addScriptDeclaration($code['script']);
+ // set loading of charts
+ $displayData->setCharts = true;
+ }
+ }
+ }
+ }
+ }
+ }
+}
?>
diff --git a/site/layouts/profilereports_uikit_two.php b/site/layouts/profilereports_uikit_two.php
index 90ec24c..a01282d 100644
--- a/site/layouts/profilereports_uikit_two.php
+++ b/site/layouts/profilereports_uikit_two.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -34,7 +34,7 @@ defined('JPATH_BASE') or die('Restricted access');
'type' => $displayData->type,
'account' => $displayData->account));
?>
- name; ?> (created); ?>)
+ name; ?> (created); ?>)
id, 'form', 'form', '&return=' . $displayData->return_path, $displayData->assessmentAvailable[$name][$_nr]->element, null); ?>
@@ -48,7 +48,7 @@ defined('JPATH_BASE') or die('Restricted access');
'type' => $displayData->type,
'account' => $displayData->account));
?>
- name; ?> (created); ?>)
+ name; ?> (created); ?>)
id, 'form', 'form', '&return=' . $displayData->return_path, $displayData->assessmentAvailable[$name][$_nr]->element, null); ?>
@@ -60,15 +60,15 @@ defined('JPATH_BASE') or die('Restricted access');
// set key
$report_key = MembersmanagerHelper::lock(array(
'id' => $assessments->id,
- 'element' => $displayData->assessmentAvailable[$name][$_nr]->element,
- 'type' => $assessments->type,
- 'account' => $assessments->account));
+ 'element' => $displayData->assessmentAvailable[$name]->element,
+ 'type' => $displayData->type,
+ 'account' => $displayData->account));
?>
- name; ?> (created); ?>)
+ name; ?> (created); ?>)
id, 'form', 'form', '&return=' . $displayData->return_path, $displayData->assessmentAvailable[$name]->element, null); ?>
-
+
diff --git a/site/layouts/relation_list_name_value.php b/site/layouts/relation_list_name_value.php
new file mode 100644
index 0000000..e68b27c
--- /dev/null
+++ b/site/layouts/relation_list_name_value.php
@@ -0,0 +1,33 @@
+
+ * @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');
+
+
+
+?>
+
+
+
+
+ $linked_members): ?>
+
+ - name; ?>
+
+
+ -
+
+
+
+
+
+
diff --git a/site/membersmanager.php b/site/membersmanager.php
index a4b88fd..ad02553 100644
--- a/site/membersmanager.php
+++ b/site/membersmanager.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/models/ajax.php b/site/models/ajax.php
index b1f9b88..879dd4d 100644
--- a/site/models/ajax.php
+++ b/site/models/ajax.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -60,6 +60,48 @@ class MembersmanagerModelAjax extends JModelList
}
return false;
}
+
+ // get placeholder header if available
+ public function getPlaceHolderHeaders($component)
+ {
+ if ('com_membersmanager' === $component)
+ {
+ return JText::_('COM_MEMBERSMANAGER');
+ }
+ return MembersmanagerHelper::getComponentName($component);
+ }
+
+ // get chart image link
+ public function getChartImageLink($image)
+ {
+ $view = $this->getViewID();
+ // make sure we are in the (allowed) view
+ if (isset($view['a_view']) && ($view['a_view'] === 'message' || $view['a_view'] === 'profile'))
+ {
+ // build image name
+ $imageName = md5($image . 'jnst_f0r_dumm!es');
+ // build image data
+ $image = explode('base64,', $image); unset($image[0]); $image = str_replace(' ', '+', implode('', $image));
+ // validate Base64
+ if (($image = MembersmanagerHelper::openValidBase64($image, null, false)) !== false)
+ {
+ // validate just png (for now)
+ $png_binary_check = "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a";
+ if (substr($image, 0, strlen($png_binary_check)) === $png_binary_check)
+ {
+ // build image path
+ $imagepath = MembersmanagerHelper::getFolderPath('path', 'chartpath') . $imageName . '.png';
+ // now write the file if not exists
+ if (file_exists($imagepath) || MembersmanagerHelper::writeFile($imagepath, $image))
+ {
+ // build and return image link
+ return array('link' => MembersmanagerHelper::getFolderPath('url', 'chartpath') . $imageName . '.png');
+ }
+ }
+ }
+ }
+ return false;
+ }
// set some buckets
protected $target;
@@ -607,13 +649,77 @@ class MembersmanagerModelAjax extends JModelList
}
+ /**
+ * get any placeholder
+ *
+ * @param string $getType Name get type
+ *
+ * @return string The html string of placeholders
+ *
+ */
+ public function getAnyPlaceHolders($getType)
+ {
+ // check if we should add a header
+ if (method_exists(__CLASS__, 'getPlaceHolderHeaders') && ($string = $this->getPlaceHolderHeaders($getType)) !== false)
+ {
+ $string = JText::_($string) . ' ';
+ $header = '' . $string . '';
+ }
+ else
+ {
+ $string = '';
+ $header = '';
+ }
+ // get placeholders
+ if ($placeholders = MembersmanagerHelper::getAnyPlaceHolders($getType))
+ {
+ return '' . $header . '' .
+ implode(' ', $placeholders) .
+ ' ';
+ }
+ // not found
+ return '' .
+ $string . JText::_('COM_MEMBERSMANAGER_PLACEHOLDERS_NOT_FOUND') .
+ '!' .
+ JText::_('COM_MEMBERSMANAGER_THERE_WAS_AN_ERROR_PLEASE_TRY_AGAIN_LATER_IF_THIS_ERROR_CONTINUES_CONTACT_YOUR_SYSTEM_ADMINISTRATOR') .
+ ' ';
+ }
+
+
+ /**
+ * get the placeholder
+ *
+ * @param string $getType Name get type
+ *
+ * @return string The html string of placeholders
+ *
+ */
public function getPlaceHolders($getType)
{
+ // check if we should add a header
+ if (method_exists(__CLASS__, 'getPlaceHolderHeaders') && ($string = $this->getPlaceHolderHeaders($getType)) !== false)
+ {
+ $string = JText::_($string) . ' ';
+ $header = '' . $string . '';
+ }
+ else
+ {
+ $string = '';
+ $header = '';
+ }
+ // get placeholders
if ($placeholders = MembersmanagerHelper::getPlaceHolders($getType))
{
- return ''. implode(' ', $placeholders).' ';
+ return '' . $header . '' .
+ implode(' ', $placeholders) .
+ ' ';
}
- return JText::_('COM_MEMBERSMANAGER_NO_PLACEHOLDERS_WERE_FOUND_PLEASE_TRY_AGAIN_LATER');
+ // not found
+ return '' .
+ $string . JText::_('COM_MEMBERSMANAGER_PLACEHOLDERS_NOT_FOUND') .
+ '!' .
+ JText::_('COM_MEMBERSMANAGER_THERE_WAS_AN_ERROR_PLEASE_TRY_AGAIN_LATER_IF_THIS_ERROR_CONTINUES_CONTACT_YOUR_SYSTEM_ADMINISTRATOR') .
+ ' ';
}
@@ -673,7 +779,7 @@ class MembersmanagerModelAjax extends JModelList
$query = $db->getQuery(true);
// Select some fields
- $query->select($db->quoteName(array('a.id','a.name','a.email','a.token'),array('id','name','email','token')));
+ $query->select($db->quoteName(array('a.id','a.name','a.email','a.token','a.type'),array('id','name','email','token','type')));
// From the membersmanager_item table
$query->from($db->quoteName('#__membersmanager_member', 'a'));
@@ -683,19 +789,8 @@ class MembersmanagerModelAjax extends JModelList
$query->join('LEFT', $db->quoteName('#__users', 'g') . ' ON (' . $db->quoteName('a.user') . ' = ' . $db->quoteName('g.id') . ')');
// Filter by published state always (for now)
- $query->where('(a.published = 1)');
+ $query->where('a.published = 1');
- // get types
- $type_access = MembersmanagerHelper::getAccess($user);
- // filter to only these groups
- if (MembersmanagerHelper::checkArray($type_access))
- {
- $query->where('a.type IN (' . implode(',', $type_access) . ')');
- }
- else
- {
- return false;
- }
// Implement View Level Access
if (!$user->authorise('core.options', 'com_membersmanager'))
{
@@ -722,9 +817,53 @@ class MembersmanagerModelAjax extends JModelList
')');
}
$query->order('a.token DESC');
- // set query
+ // set query (to only get last 10)
$db->setQuery($query, 0, 10);
- return $db->loadObjectList();
+ // get the members
+ $members = $db->loadObjectList();
+ // did we get any
+ if (MembersmanagerHelper::checkArray($members))
+ {
+ // if system admin, return all found
+ if ($user->authorise('core.options', 'com_membersmanager'))
+ {
+ return $members;
+ }
+ // filter by access type
+ $type_access = MembersmanagerHelper::getAccess($user);
+ // filter to only these access types
+ if (MembersmanagerHelper::checkArray($type_access))
+ {
+ // 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; };
+ // the new bucket
+ $member_bucket = array();
+ foreach ($members as $member)
+ {
+ // convert type json to array
+ if (MembersmanagerHelper::checkJson($member->type))
+ {
+ $member->type = json_decode($member->type, true);
+ }
+ // convert type int to array
+ if (is_numeric($member->type) && $member->type > 0)
+ {
+ $member->type = array($member->type);
+ }
+ // now check intersection
+ if (MembersmanagerHelper::checkArray($member->type) && $intersect($member->type, $type_access))
+ {
+ $member_bucket[] = $member;
+ }
+ }
+ // did we get any
+ if (MembersmanagerHelper::checkArray($member_bucket))
+ {
+ return $member_bucket;
+ }
+ }
+ }
+ return false;
}
// Used in profile
diff --git a/site/models/cpanel.php b/site/models/cpanel.php
index 1c82224..47c065e 100644
--- a/site/models/cpanel.php
+++ b/site/models/cpanel.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -81,8 +81,8 @@ class MembersmanagerModelCpanel extends JModelItem
{
$app = JFactory::getApplication();
$app->enqueueMessage(JText::_('COM_MEMBERSMANAGER_NOT_AUTHORISED_TO_VIEW_CPANEL'), 'error');
- // redirect away to the home page if no access allowed.
- $app->redirect(JURI::root());
+ // redirect away to the default view if no access allowed.
+ $app->redirect(JRoute::_('index.php?option=com_membersmanager&view=members'));
return false;
}
$this->userId = $this->user->get('id');
@@ -132,7 +132,7 @@ class MembersmanagerModelCpanel extends JModelItem
$app = JFactory::getApplication();
// If no data is found redirect to default page and show warning.
$app->enqueueMessage(JText::_('COM_MEMBERSMANAGER_NOT_FOUND_OR_ACCESS_DENIED'), 'warning');
- $app->redirect(JURI::root());
+ $app->redirect(JRoute::_('index.php?option=com_membersmanager&view=members'));
return false;
}
diff --git a/site/models/forms/member.js b/site/models/forms/member.js
index 2caf5fb..0fa6d39 100644
--- a/site/models/forms/member.js
+++ b/site/models/forms/member.js
@@ -1,7 +1,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -278,16 +278,16 @@ function getUserDetails(user){
});
}
function getUserDetails_server(user){
- var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.getUserDetails&format=json&vdm="+vastDevMod);
+ var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.getUserDetails&format=json&raw=true&vdm="+vastDevMod);
if(token.length > 0 && user > 0){
var request = 'token='+token+'&user='+user;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
- dataType: 'jsonp',
+ dataType: 'json',
data: request,
- jsonp: 'callback'
+ jsonp: false
});
}
function setUserDetails(result){
@@ -399,16 +399,16 @@ function removeFile(clearServer, target, flush, type){
}
function removeFile_server(currentFileName, target, flush, type){
- var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.removeFile&format=json&vdm="+vastDevMod);
+ var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.removeFile&format=json&raw=true&vdm="+vastDevMod);
if(token.length > 0 && target.length > 0 && type.length > 0){
var request = 'token='+token+'&filename='+currentFileName+'&target='+target+'&flush='+flush+'&type='+type;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
- dataType: 'jsonp',
+ dataType: 'json',
data: request,
- jsonp: 'callback'
+ jsonp: false
});
}
function isJsonString(str) {
@@ -437,16 +437,16 @@ function isEmpty(obj) {
function checkUnique_server(value, field){
- var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.checkUnique&format=json&vdm="+vastDevMod);
+ var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.checkUnique&format=json&raw=true&vdm="+vastDevMod);
if(token.length > 0 && value.length > 0 && field.length > 0){
var request = 'token='+token+'&value='+value+'&field='+field;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
- dataType: 'jsonp',
+ dataType: 'json',
data: request,
- jsonp: 'callback'
+ jsonp: false
});
}
function checkUnique(value, field, show){
@@ -474,66 +474,4 @@ function checkUnique(value, field, show){
}
});
}
-}
-
-// set regions that are on the page
-regions = {};
-var region = 0;
-jQuery(document).ready(function($)
-{
- jQuery("#jform_region option").each(function()
- {
- var key = jQuery(this).val();
- var text = jQuery(this).text();
- regions[key] = text;
- });
- region = jQuery('#jform_region').val();
- getRegion();
-});
-
-function getRegion_server(country){
- var getUrl = "index.php?option=com_membersmanager&task=ajax.getRegion&format=json";
- if(token.length > 0 && country > 0){
- var request = 'token='+token+'&country='+country;
- }
- return jQuery.ajax({
- type: 'GET',
- url: getUrl,
- dataType: 'jsonp',
- data: request,
- jsonp: 'callback'
- });
-}
-function getRegion(){
- jQuery("#loading").show();
- // clear the selection
- jQuery('#jform_region').find('option').remove().end();
- jQuery('#jform_region').trigger('liszt:updated');
- // get country value if set
- var country = jQuery('#jform_country').val();
- getRegion_server(country).done(function(result) {
- setRegion(result);
- jQuery("#loading").hide();
- if (typeof regionButton !== 'undefined') {
- // ensure button is correct
- var region = jQuery('#jform_region').val();
- regionButton(region);
- }
- });
-}
-function setRegion(array){
- if (array) {
- jQuery('#jform_region').append('');
- jQuery.each( array, function( i, id ) {
- if (id in regions) {
- jQuery('#jform_region').append('');
- }
- if (id == region) {
- jQuery('#jform_region').val(id);
- }
- });
- } else {
- jQuery('#jform_region').append('');
- }
- jQuery('#jform_region').trigger('liszt:updated');
}
diff --git a/site/models/forms/member.xml b/site/models/forms/member.xml
index ad80e13..69997f6 100644
--- a/site/models/forms/member.xml
+++ b/site/models/forms/member.xml
@@ -263,14 +263,14 @@
message="COM_MEMBERSMANAGER_MEMBER_SURNAME_MESSAGE"
hint="COM_MEMBERSMANAGER_MEMBER_SURNAME_HINT"
/>
-
+
diff --git a/site/models/member.php b/site/models/member.php
index c95c87f..ef1eff6 100644
--- a/site/models/member.php
+++ b/site/models/member.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -97,6 +97,14 @@ class MembersmanagerModelMember extends JModelAdmin
$item->profile_image = rtrim($medium->decryptString($item->profile_image), "\0");
}
+ if (!empty($item->type))
+ {
+ // Convert the type field to an array.
+ $type = new Registry;
+ $type->loadString($item->type);
+ $item->type = $type->toArray();
+ }
+
if (empty($item->id))
{
@@ -245,12 +253,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('name', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('name'))
+ if (!($val = $form->getValue('name')))
{
// Disable fields while saving.
$form->setFieldAttribute('name', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('name', 'required', 'false');
+ // Make sure
+ $form->setValue('name', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('name');
}
}
// Modify the form based on Edit Email access controls.
@@ -284,12 +301,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('email', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('email'))
+ if (!($val = $form->getValue('email')))
{
// Disable fields while saving.
$form->setFieldAttribute('email', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('email', 'required', 'false');
+ // Make sure
+ $form->setValue('email', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('email');
}
}
// Modify the form based on Edit Account access controls.
@@ -316,12 +342,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('account', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('account'))
+ if (!($val = $form->getValue('account')))
{
// Disable fields while saving.
$form->setFieldAttribute('account', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('account', 'required', 'false');
+ // Make sure
+ $form->setValue('account', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('account');
}
}
// Modify the form based on Edit User access controls.
@@ -348,12 +383,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('user', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('user'))
+ if (!($val = $form->getValue('user')))
{
// Disable fields while saving.
$form->setFieldAttribute('user', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('user', 'required', 'false');
+ // Make sure
+ $form->setValue('user', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('user');
}
}
// Modify the form based on Edit Token access controls.
@@ -380,12 +424,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('token', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('token'))
+ if (!($val = $form->getValue('token')))
{
// Disable fields while saving.
$form->setFieldAttribute('token', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('token', 'required', 'false');
+ // Make sure
+ $form->setValue('token', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('token');
}
}
// Modify the form based on Edit Profile Image access controls.
@@ -419,12 +472,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('profile_image', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('profile_image'))
+ if (!($val = $form->getValue('profile_image')))
{
// Disable fields while saving.
$form->setFieldAttribute('profile_image', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('profile_image', 'required', 'false');
+ // Make sure
+ $form->setValue('profile_image', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('profile_image');
}
}
// Modify the form based on Edit Main Member access controls.
@@ -451,12 +513,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('main_member', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('main_member'))
+ if (!($val = $form->getValue('main_member')))
{
// Disable fields while saving.
$form->setFieldAttribute('main_member', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('main_member', 'required', 'false');
+ // Make sure
+ $form->setValue('main_member', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('main_member');
}
}
// Modify the form based on Edit Password Check access controls.
@@ -490,12 +561,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('password_check', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('password_check'))
+ if (!($val = $form->getValue('password_check')))
{
// Disable fields while saving.
$form->setFieldAttribute('password_check', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('password_check', 'required', 'false');
+ // Make sure
+ $form->setValue('password_check', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('password_check');
}
}
// Modify the form based on Edit Password access controls.
@@ -529,12 +609,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('password', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('password'))
+ if (!($val = $form->getValue('password')))
{
// Disable fields while saving.
$form->setFieldAttribute('password', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('password', 'required', 'false');
+ // Make sure
+ $form->setValue('password', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('password');
}
}
// Modify the form based on Edit Useremail access controls.
@@ -568,12 +657,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('useremail', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('useremail'))
+ if (!($val = $form->getValue('useremail')))
{
// Disable fields while saving.
$form->setFieldAttribute('useremail', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('useremail', 'required', 'false');
+ // Make sure
+ $form->setValue('useremail', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('useremail');
}
}
// Modify the form based on Edit Username access controls.
@@ -607,12 +705,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('username', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('username'))
+ if (!($val = $form->getValue('username')))
{
// Disable fields while saving.
$form->setFieldAttribute('username', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('username', 'required', 'false');
+ // Make sure
+ $form->setValue('username', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('username');
}
}
// Modify the form based on Edit Surname access controls.
@@ -639,12 +746,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('surname', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('surname'))
+ if (!($val = $form->getValue('surname')))
{
// Disable fields while saving.
$form->setFieldAttribute('surname', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('surname', 'required', 'false');
+ // Make sure
+ $form->setValue('surname', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('surname');
}
}
// Modify the form based on Edit Type access controls.
@@ -671,12 +787,21 @@ class MembersmanagerModelMember extends JModelAdmin
// Make the field hidded.
$form->setFieldAttribute('type', 'type', 'hidden');
// If there is no value continue.
- if (!$form->getValue('type'))
+ if (!($val = $form->getValue('type')))
{
// Disable fields while saving.
$form->setFieldAttribute('type', 'filter', 'unset');
// Disable fields while saving.
$form->setFieldAttribute('type', 'required', 'false');
+ // Make sure
+ $form->setValue('type', null, '');
+ }
+ elseif (MembersmanagerHelper::checkArray($val))
+ {
+ // We have to unset then (TODO)
+ // Hiddend field can not handel array value
+ // Even if we conver to json we get an error
+ $form->removeField('type');
}
}
// Only load these values if no id is found
@@ -925,10 +1050,66 @@ class MembersmanagerModelMember extends JModelAdmin
* @since 12.2
*/
public function delete(&$pks)
- {
+ {
+ // check if member is still linked to other sub members as a main member
+ if (MembersmanagerHelper::checkArray($pks))
+ {
+ // get the application object
+ $app = JFactory::getApplication();
+ // now loop the ids
+ foreach ($pks as $key => $pk)
+ {
+ // check if member still have sub accounts linked to it
+ if (($found = MembersmanagerHelper::getVar('member', $pk, 'main_member', 'id')) !== false)
+ {
+ // set the name
+ $name = MembersmanagerHelper::getMemberName($pk);
+ // set a message
+ $app->enqueueMessage(JText::sprintf('COM_MEMBERSMANAGER_YOU_CAN_NOT_DELETE_BSB_FIRST_MOVE_ALL_SUB_ACCOUNTS_TO_NEW_MAIN_MEMBER', $name), 'Error');
+ // remove for the list
+ unset($pks[$key]);
+ }
+ }
+ }
if (!parent::delete($pks))
{
return false;
+ }
+
+ // we must also update all linked tables
+ if (MembersmanagerHelper::checkArray($pks))
+ {
+ $seek = array('Info', 'Assessment');
+ foreach ($seek as $area)
+ {
+ if (($components = MembersmanagerHelper::{'get' . $area . 'Components'}()) !== false)
+ {
+ foreach($components as $_component)
+ {
+ $component = str_replace('com_', '', $_component->element);
+ $Component = MembersmanagerHelper::safeString($component, 'F');
+ // get the linked IDs
+ if (($ids = MembersmanagerHelper::getVars('form', $pks, 'member', 'id', 'IN', $component)) !== false && MembersmanagerHelper::checkArray($ids))
+ {
+ // get the model
+ $_Model = MembersmanagerHelper::getModel('form', JPATH_ADMINISTRATOR . '/components/' . $_component->element, $Component);
+ // do we have the model
+ if ($_Model)
+ {
+ // change publish state
+ $_Model->delete($ids);
+ }
+ }
+ }
+ }
+ }
+ // now loop the ids
+ foreach ($pks as $key => $pk)
+ {
+ // make sure to remove the type_map
+ MembersmanagerHelper::updateTypes($pk);
+ // must still do the relationship clearing (TODO)
+ }
}
return true;
@@ -949,6 +1130,35 @@ class MembersmanagerModelMember extends JModelAdmin
if (!parent::publish($pks, $value))
{
return false;
+ }
+
+ // we must also update all linked tables
+ if (MembersmanagerHelper::checkArray($pks))
+ {
+ $seek = array('Info', 'Assessment');
+ foreach ($seek as $area)
+ {
+ if (($components = MembersmanagerHelper::{'get' . $area . 'Components'}()) !== false)
+ {
+ foreach($components as $_component)
+ {
+ $component = str_replace('com_', '', $_component->element);
+ $Component = MembersmanagerHelper::safeString($component, 'F');
+ // get the linked IDs
+ if (($ids = MembersmanagerHelper::getVars('form', $pks, 'member', 'id', 'IN', $component)) !== false && MembersmanagerHelper::checkArray($ids))
+ {
+ // get the model
+ $_Model = MembersmanagerHelper::getModel('form', JPATH_ADMINISTRATOR . '/components/' . $_component->element, $Component);
+ // do we have the model
+ if ($_Model)
+ {
+ // change publish state
+ $_Model->publish($ids, $value);
+ }
+ }
+ }
+ }
+ }
}
return true;
@@ -1325,16 +1535,39 @@ class MembersmanagerModelMember extends JModelAdmin
$data['metadata'] = (string) $metadata;
}
+ // get user object
+ $user = JFactory::getUser();
+ // set ID
+ $id = (isset($data['id']) && $data['id'] > 0) ? $data['id'] : false;
+ // little function to check user access
+ $checkUserAccess = function ($permission) use($user, $id) {
+ return (($id && $user->authorise('member.' . $permission, 'com_membersmanager.member.' . (int) $id)) || (!$id && $user->authorise('member.' . $permission, 'com_membersmanager')));
+ };
+ // make sure these type is set
+ if ($id && !$checkUserAccess('edit.type'))
+ {
+ $data['type'] = MembersmanagerHelper::getVar('member', $id, 'id', 'type');
+ }
+ // make sure these account is set
+ if ($id && !$checkUserAccess('edit.account'))
+ {
+ $data['account'] = MembersmanagerHelper::getVar('member', $id, 'id', 'account');
+ }
+ // get user value if not set (due to permissions)
+ if ($id && isset($data['account']) && (1 == $data['account'] || 4 == $data['account']) && (!isset($data['user']) || $data['user'] == 0))
+ {
+ $data['user'] = MembersmanagerHelper::getVar('member', $id, 'id', 'user');
+ }
// check if this is a linked user (MUST STILL DO PERMISSIONS)
- if (isset($data['account']) && (1 == $data['account'] || 4 == $data['account']))
+ if (isset($data['account']) && (1 == $data['account'] || 4 == $data['account']) && $checkUserAccess('edit.user'))
{
// get the application object
$app = JFactory::getApplication();
// check if member already exist
- if (isset($data['id']) && $data['id'] > 0 && isset($data['user']) && $data['user'] > 0)
+ if ($id && isset($data['user']) && $data['user'] > 0)
{
// do not allow user link to be changed (should have done this in the controller)
- if (($alreadyUser = MembersmanagerHelper::getVar('member', $data['id'], 'id', 'user')) !== false && is_numeric($alreadyUser) && $alreadyUser > 0 && $alreadyUser != $data['user'])
+ if (($alreadyUser = MembersmanagerHelper::getVar('member', $id, 'id', 'user')) !== false && is_numeric($alreadyUser) && $alreadyUser > 0 && $alreadyUser != $data['user'])
{
$app->enqueueMessage(JText::_('COM_MEMBERSMANAGER_MEMBER_IS_ALREADY_LINKED_TO_AN_USER_THIS_CAN_NOT_BE_CHANGED_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_IF_YOU_NEED_MORE_HELP'), 'Error');
return false;
@@ -1355,27 +1588,17 @@ class MembersmanagerModelMember extends JModelAdmin
{
// set user ID
$bucket['id'] = $data['user'];
- // get user exciting groups
+ // get member user
$memberUser = JFactory::getUser($bucket['id']);
- $excitingGroups = $memberUser->get('groups');
- $typeGroups = array();
- // set the groups
- if (isset($data['type']) && $data['type'] > 0)
- {
- // get the target groups
- $typeGroups = MembersmanagerHelper::getVar('type', $data['type'], 'id', 'groups_target');
- // convert to array
- if (MembersmanagerHelper::checkJson($typeGroups))
- {
- $typeGroups = (array) json_decode($typeGroups, true);
- }
- elseif (is_numeric($typeGroups))
- {
- $typeGroups = array((int) $typeGroups);
- }
- }
+ // get user exciting groups
+ $bucket['groups'] = $memberUser->get('groups');
+ // remove all groups part of members manager
+ MembersmanagerHelper::removeMemberGroups($bucket['groups']);
// load the user groups (TODO)
- $bucket['groups'] = MembersmanagerHelper::mergeArrays(array($excitingGroups, $typeGroups));
+ if (($typeGroups = MembersmanagerHelper::getMemberGroupsByType($data['type'])) !== false)
+ {
+ $bucket['groups'] = MembersmanagerHelper::mergeArrays(array($bucket['groups'], $typeGroups));
+ }
// set password
if (empty($data['password']) || empty($data['password_check']))
{
@@ -1413,25 +1636,11 @@ class MembersmanagerModelMember extends JModelAdmin
{
// make sure to set the user value
$data['user'] = $done;
- if (isset($data['type']) && $data['type'] > 0)
- {
- // get the target groups
- $_groups = MembersmanagerHelper::getVar('type', $data['type'], 'id', 'groups_target');
- // convert to array
- if (MembersmanagerHelper::checkJson($_groups))
- {
- $groups = (array) json_decode($_groups, true);
- }
- elseif (is_numeric($_groups))
- {
- $groups = array((int) $_groups);
- }
- }
// check if we have groups
- if (isset($groups) && $groups)
+ if (($typeGroups = MembersmanagerHelper::getMemberGroupsByType($data['type'])) !== false)
{
// update the user groups
- JUserHelper::setUserGroups((int) $done ,(array) $groups);
+ JUserHelper::setUserGroups((int) $done, (array) $typeGroups);
}
else
{
@@ -1450,12 +1659,25 @@ class MembersmanagerModelMember extends JModelAdmin
$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'];
+ }
+ }
+ // if a sub account and not login access
+ if (isset($data['account']) && 3 == $data['account'] && isset($data['main_member']) && $data['main_member'] > 0
+ && ($mainMemberUser = MembersmanagerHelper::getVar('member', $data['main_member'], 'id', 'user')) !== false && $mainMemberUser > 0)
+ {
+ // the main user must always own it self for edit permissions
+ $data['created_by'] = $mainMemberUser;
}
// always clear out password!!
unset($data['password']);
unset($data['password_check']);
// clear out user if error found
- if (empty($data['user']) || $data['user'] == 0 || empty($data['account']) || (1 != $data['account'] && 4 != $data['account']))
+ if ((empty($data['user']) || $data['user'] == 0 || empty($data['account']) || (1 != $data['account'] && 4 != $data['account'])) && $checkUserAccess('edit.user') && $checkUserAccess('edit.account'))
{
// if not a linked account, then no user can be set
$data['user'] = '';
@@ -1468,7 +1690,7 @@ class MembersmanagerModelMember extends JModelAdmin
// get a token
$token = call_user_func(function($data) {
// get the name of this member
- if ((1 == $data['account'] || 4 == $data['account']) && isset($data['user']) && $data['user'] > 0)
+ if (isset($data['account']) && (1 == $data['account'] || 4 == $data['account']) && isset($data['user']) && $data['user'] > 0)
{
return JFactory::getUser($data['user'])->name;
}
@@ -1483,12 +1705,29 @@ class MembersmanagerModelMember extends JModelAdmin
// make string safe
$data['token'] = MembersmanagerHelper::safeString(trim(implode(' ', $tokenArray), '-'), 'L', '-', false, false);
// get unique token
- while (!MembersmanagerHelper::checkUnique($data['id'], 'token', $data['token'], 'member'))
+ while (!MembersmanagerHelper::checkUnique($id, 'token', $data['token'], 'member'))
{
$data['token'] = JString::increment($data['token'], 'dash');
}
}
+ // Set the type items to data.
+ if (isset($data['type']) && is_array($data['type']))
+ {
+ $type = new JRegistry;
+ $type->loadArray($data['type']);
+ $data['type'] = (string) $type;
+ }
+ // Also check permission since the value may be removed due to permissions
+ // Then we do not want to clear it out, but simple ignore the empty type
+ elseif (!isset($data['type'])
+ && JFactory::getUser()->authorise('member.edit.type', 'com_membersmanager')
+ && JFactory::getUser()->authorise('member.view.type', 'com_membersmanager'))
+ {
+ // Set the empty type to data
+ $data['type'] = '';
+ }
+
// Get the medium encryption key.
$mediumkey = MembersmanagerHelper::getCryptKey('medium');
// Get the encryption object
diff --git a/site/models/members.php b/site/models/members.php
new file mode 100644
index 0000000..d245a82
--- /dev/null
+++ b/site/models/members.php
@@ -0,0 +1,247 @@
+
+ * @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('_JEXEC') or die('Restricted access');
+
+/**
+ * Membersmanager Model for Members
+ */
+class MembersmanagerModelMembers extends JModelList
+{
+ /**
+ * Model user data.
+ *
+ * @var strings
+ */
+ protected $user;
+ protected $userId;
+ protected $guest;
+ protected $groups;
+ protected $levels;
+ protected $app;
+ protected $input;
+ protected $uikitComp;
+
+ /**
+ * Method to build an SQL query to load the list data.
+ *
+ * @return string An SQL query
+ */
+ protected function getListQuery()
+ {
+ // Get the current user for authorisation checks
+ $this->user = JFactory::getUser();
+ $this->userId = $this->user->get('id');
+ $this->guest = $this->user->get('guest');
+ $this->groups = $this->user->get('groups');
+ $this->authorisedGroups = $this->user->getAuthorisedGroups();
+ $this->levels = $this->user->getAuthorisedViewLevels();
+ $this->app = JFactory::getApplication();
+ $this->input = $this->app->input;
+ $this->initSet = true;
+ // Get a db connection.
+ $db = JFactory::getDbo();
+
+ // Create a new query object.
+ $query = $db->getQuery(true);
+
+ // Filtering.
+
+ $params = $this->app->getParams();
+ // get the targeted types
+ if (($target_type = $params->get('target_type', false)) === false)
+ {
+ return false;
+ }
+
+ // Get from #__membersmanager_member as a
+ $query->select($db->quoteName(
+ array('a.id'),
+ array('id')));
+ $query->from($db->quoteName('#__membersmanager_member', 'a'));
+ // Check if $params->get('target_account', false) is an array with values.
+ $array = $params->get('target_account', false);
+ if (isset($array) && MembersmanagerHelper::checkArray($array))
+ {
+ $query->where('a.account IN (' . implode(',', $array) . ')');
+ }
+ else
+ {
+ return false;
+ }
+ // Check if MembersmanagerHelper::getMembersByType($target_type, $db) is an array with values.
+ $array = MembersmanagerHelper::getMembersByType($target_type, $db);
+ if (isset($array) && MembersmanagerHelper::checkArray($array))
+ {
+ $query->where('a.id IN (' . implode(',', $array) . ')');
+ }
+ else
+ {
+ return false;
+ }
+ $query->where('a.access IN (' . implode(',', $this->levels) . ')');
+ // Get where a.published is 1
+ $query->where('a.published = 1');
+ $query->order('a.ordering ASC');
+
+ // return the query object
+ return $query;
+ }
+
+ /**
+ * Method to get an array of data items.
+ *
+ * @return mixed An array of data items on success, false on failure.
+ */
+ public function getItems()
+ {
+ $user = JFactory::getUser();
+ // check if this user has permission to access item
+ if (!$user->authorise('site.members.access', 'com_membersmanager'))
+ {
+ $app = JFactory::getApplication();
+ $app->enqueueMessage(JText::_('COM_MEMBERSMANAGER_NOT_AUTHORISED_TO_VIEW_MEMBERS'), 'error');
+ // redirect away to the home page if no access allowed.
+ $app->redirect(JURI::root());
+ return false;
+ }
+ // load parent items
+ $items = parent::getItems();
+
+ // Get the global params
+ $globalParams = JComponentHelper::getParams('com_membersmanager', true);
+
+ // Insure all item fields are adapted where needed.
+ if (MembersmanagerHelper::checkArray($items))
+ {
+ foreach ($items as $nr => &$item)
+ {
+ // Always create a slug for sef URL's
+ $item->slug = (isset($item->alias) && isset($item->id)) ? $item->id.':'.$item->alias : $item->id;
+ }
+ }
+
+
+ if (MembersmanagerHelper::checkArray($items))
+ {
+ // get the params from menu settings
+ $params = $this->app->getParams();
+ // get the linked components
+ $components = $params->get('components', false);
+ $__components = $params->get('many_components', false);
+ // loop over the members an load the linked data
+ foreach ($items as $nr => &$item)
+ {
+ // get id
+ $id = $item->id;
+
+ // get member details
+ $item = (object) MembersmanagerHelper::getAnyFormDetails($id, 'id', 'com_membersmanager', 'placeholder', 'report', 'id', 'member', 1);
+ // now load the one to one component data
+ if (MembersmanagerHelper::checkArray($components))
+ {
+ foreach ($components as $component)
+ {
+ // get values
+ if (($tmp = MembersmanagerHelper::getAnyFormDetails($id, 'member', $component, 'placeholder', 'report', 'member', 'form', 1)) !== false && MembersmanagerHelper::checkArray($tmp))
+ {
+ // add to the item array
+ foreach ($tmp as $placholder_key => $value)
+ {
+ // keep first data set
+ if (!isset($item->{$placholder_key}))
+ {
+ $item->{$placholder_key} = $value;
+ }
+ }
+ // not needed
+ unset($tmp);
+ }
+ }
+ }
+ // now load the one to many component data
+ if (MembersmanagerHelper::checkArray($__components))
+ {
+ // start many data array
+ foreach ($__components as $_component)
+ {
+ // rest buckets
+ $main_template_0 = '';
+ $main_template_1 = '';
+ // set component name
+ $component = $_component['component'];
+ $qty = (isset($_component['qty']) && is_numeric($_component['qty'])) ? $_component['qty'] : 0;
+ // check if we have a main template
+ if (MembersmanagerHelper::checkString($_component['main_template']))
+ {
+ if (strpos($_component['main_template'], '[load_items]') !==false)
+ {
+ $_tmp = (array) explode('[load_items]', $_component['main_template']);
+ $main_template_0 = $_tmp[0];
+ if (count($_tmp) >= 2)
+ {
+ $main_template_1 = $_tmp[1];
+ }
+ }
+ else
+ {
+ $main_template_0 = $_component['main_template'];
+ }
+ }
+ // get values
+ if (($_data = MembersmanagerHelper::getAnyFormDetails($id, 'member', $component, 'placeholder', 'report', 'member', 'form', $qty)) !== false && MembersmanagerHelper::checkArray($_data))
+ {
+ // start building this linked component view
+ $item->{'[' . $_component['placeholder'] . ']'} = $main_template_0;
+ // check the qty
+ if (!isset($_data[0]))
+ {
+ $item->{'[' . $_component['placeholder'] . ']'} .= MembersmanagerHelper::setDynamicData($_component['item_template'], $_data);
+ }
+ else
+ {
+ foreach ($_data as $data_placeholders)
+ {
+ $item->{'[' . $_component['placeholder'] . ']'} .= MembersmanagerHelper::setDynamicData($_component['item_template'], $data_placeholders);
+ }
+ }
+ $item->{'[' . $_component['placeholder'] . ']'} .= $main_template_1;
+ }
+ // remove if not set
+ if (!isset($item->{'[' . $_component['placeholder'] . ']'}))
+ {
+ $item->{'[' . $_component['placeholder'] . ']'} = '';
+ }
+ }
+ }
+ }
+ }
+
+ // return items
+ return $items;
+ }
+
+ /**
+ * Get the uikit needed components
+ *
+ * @return mixed An array of objects on success.
+ *
+ */
+ public function getUikitComp()
+ {
+ if (isset($this->uikitComp) && MembersmanagerHelper::checkArray($this->uikitComp))
+ {
+ return $this->uikitComp;
+ }
+ return false;
+ }
+}
diff --git a/site/models/profile.php b/site/models/profile.php
index adb390f..faffc83 100644
--- a/site/models/profile.php
+++ b/site/models/profile.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -82,7 +82,7 @@ class MembersmanagerModelProfile extends JModelItem
$app = JFactory::getApplication();
$app->enqueueMessage(JText::_('COM_MEMBERSMANAGER_NOT_AUTHORISED_TO_VIEW_PROFILE'), 'error');
// redirect away to the default view if no access allowed.
- $app->redirect(JRoute::_('index.php?option=com_membersmanager&view=cpanel'));
+ $app->redirect(JRoute::_('index.php?option=com_membersmanager&view=members'));
return false;
}
$this->userId = $this->user->get('id');
@@ -156,7 +156,7 @@ class MembersmanagerModelProfile extends JModelItem
$app = JFactory::getApplication();
// If no data is found redirect to default page and show warning.
$app->enqueueMessage(JText::_('COM_MEMBERSMANAGER_NOT_FOUND_OR_ACCESS_DENIED'), 'warning');
- $app->redirect(JRoute::_('index.php?option=com_membersmanager&view=cpanel'));
+ $app->redirect(JRoute::_('index.php?option=com_membersmanager&view=members'));
return false;
}
// Load the JEvent Dispatcher
@@ -168,6 +168,12 @@ class MembersmanagerModelProfile extends JModelItem
// Decode profile_image
$data->profile_image = rtrim($medium->decryptString($data->profile_image), "\0");
}
+ // Check if we can decode type
+ if (MembersmanagerHelper::checkJson($data->type))
+ {
+ // Decode type
+ $data->type = json_decode($data->type, true);
+ }
// Check if item has params, or pass whole item.
$params = (isset($data->params) && MembersmanagerHelper::checkJson($data->params)) ? json_decode($data->params) : $data;
// Make sure the content prepare plugins fire on type_description
@@ -228,6 +234,31 @@ class MembersmanagerModelProfile extends JModelItem
$item->return_path = urlencode(base64_encode($profile_link));
}
}
+
+ if (empty($this->_item[$pk]->id))
+ {
+ $id = 0;
+ }
+ else
+ {
+ $id = $this->_item[$pk]->id;
+ }
+ // set the id and view name to session
+ if ($vdm = MembersmanagerHelper::get('profile__'.$id))
+ {
+ $this->vastDevMod = $vdm;
+ }
+ else
+ {
+ // set the vast development method key
+ $this->vastDevMod = MembersmanagerHelper::randomkey(50);
+ MembersmanagerHelper::set($this->vastDevMod, 'profile__'.$id);
+ MembersmanagerHelper::set('profile__'.$id, $this->vastDevMod);
+ // set a return value if found
+ $jinput = JFactory::getApplication()->input;
+ $return = $jinput->get('return', null, 'base64');
+ MembersmanagerHelper::set($this->vastDevMod . '__return', $return);
+ }
return $this->_item[$pk];
}
@@ -288,6 +319,12 @@ class MembersmanagerModelProfile extends JModelItem
// Decode profile_image
$item->profile_image = rtrim($medium->decryptString($item->profile_image), "\0");
}
+ // Check if we can decode type
+ if (MembersmanagerHelper::checkJson($item->type))
+ {
+ // Decode type
+ $item->type = json_decode($item->type, true);
+ }
}
return $items;
}
@@ -308,5 +345,10 @@ class MembersmanagerModelProfile extends JModelItem
return $this->uikitComp;
}
return false;
+ }
+
+ public function getVDM()
+ {
+ return $this->vastDevMod;
}
}
diff --git a/site/router.php b/site/router.php
index ea38c0a..82baf51 100644
--- a/site/router.php
+++ b/site/router.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -68,11 +68,11 @@ class MembersmanagerRouter extends JComponentRouterBase
return $segments;
}
- if (isset($view) && isset($query['id']) && ($view === 'member' || $view === 'cpanel' || $view === 'profile'))
+ if (isset($view) && isset($query['id']) && ($view === 'member' || $view === 'members' || $view === 'cpanel' || $view === 'profile'))
{
if ($mId != (int) $query['id'] || $mView != $view)
{
- if (($view === 'member' || $view === 'cpanel' || $view === 'profile'))
+ if (($view === 'member' || $view === 'members' || $view === 'cpanel' || $view === 'profile'))
{
$segments[] = $view;
$id = explode(':', $query['id']);
@@ -124,6 +124,21 @@ class MembersmanagerRouter extends JComponentRouterBase
$vars['id'] = (int) $segments[$count-1];
}
break;
+ case 'members':
+ $vars['view'] = 'members';
+ if (is_numeric($segments[$count-1]))
+ {
+ $vars['id'] = (int) $segments[$count-1];
+ }
+ elseif ($segments[$count-1])
+ {
+ $id = $this->getVar('member', $segments[$count-1], 'alias', 'id');
+ if($id)
+ {
+ $vars['id'] = $id;
+ }
+ }
+ break;
case 'cpanel':
$vars['view'] = 'cpanel';
if (is_numeric($segments[$count-1]))
diff --git a/site/views/cpanel/tmpl/default.php b/site/views/cpanel/tmpl/default.php
index 617bd90..6399c40 100644
--- a/site/views/cpanel/tmpl/default.php
+++ b/site/views/cpanel/tmpl/default.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -34,7 +34,7 @@ defined('_JEXEC') or die('Restricted access');
diff --git a/site/views/cpanel/tmpl/default_loginmodule.php b/site/views/cpanel/tmpl/default_loginmodule.php
index 6bfbb3b..ed61417 100644
--- a/site/views/cpanel/tmpl/default_loginmodule.php
+++ b/site/views/cpanel/tmpl/default_loginmodule.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/views/cpanel/view.html.php b/site/views/cpanel/view.html.php
index 4c86ab8..d516996 100644
--- a/site/views/cpanel/view.html.php
+++ b/site/views/cpanel/view.html.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/views/member/submitbutton.js b/site/views/member/submitbutton.js
index 31b8007..0e6cf69 100644
--- a/site/views/member/submitbutton.js
+++ b/site/views/member/submitbutton.js
@@ -1,7 +1,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
diff --git a/site/views/member/tmpl/edit.php b/site/views/member/tmpl/edit.php
index c1cab90..fb96336 100644
--- a/site/views/member/tmpl/edit.php
+++ b/site/views/member/tmpl/edit.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -285,11 +285,6 @@ jQuery('#adminForm').on('change', '#jform_account',function (e)
jQuery('#error-profile-image-uploader').html('');
-jQuery(document).ready(function(){
- jQuery(window).load(function () {
- jQuery("body").css('background', 'transparent');
- });
-});
jQuery('#adminForm').on('change', '#jform_token',function (e) {
e.preventDefault();
var tokenValue = jQuery('#jform_token').val();
@@ -302,12 +297,6 @@ jQuery('#adminForm').on('change', '#jform_user',function (e) {
// check if this token value is used
getUserDetails(userValue);
});
-jQuery('#adminForm').on('change', '#contact_country',function (e) {
- e.preventDefault();
- getRegion();
-});
-var select_a_region = '';
-var create_a_region = '';
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -232,14 +232,14 @@ class MembersmanagerViewMember extends JViewLegacy
if ($isAdmin || $uikit != 3)
{
// add JavaScripts
- $this->document->addScript( JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/uikit' . $size . '.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
+ $this->document->addScript( JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/uikit' . $size . '.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
}
// add JavaScripts
- $this->document->addScript( JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/components/accordion' . $size . '.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
- $this->document->addScript( JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/components/tooltip' . $size . '.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
- $this->document->addScript( JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/components/lightbox' . $size . '.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
- $this->document->addScript( JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/components/notify' . $size . '.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
- $this->document->addScript( JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/components/upload' . $size . '.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
+ $this->document->addScript( JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/components/accordion' . $size . '.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
+ $this->document->addScript( JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/components/tooltip' . $size . '.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
+ $this->document->addScript( JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/components/lightbox' . $size . '.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
+ $this->document->addScript( JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/components/notify' . $size . '.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
+ $this->document->addScript( JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/components/upload' . $size . '.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
}
// Use Uikit Version 3
elseif (3 == $this->uikitVersion && ($isAdmin || $uikit != 2))
diff --git a/site/views/members/index.html b/site/views/members/index.html
new file mode 100644
index 0000000..fa6d84e
--- /dev/null
+++ b/site/views/members/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/views/members/tmpl/default.php b/site/views/members/tmpl/default.php
new file mode 100644
index 0000000..3d6edd8
--- /dev/null
+++ b/site/views/members/tmpl/default.php
@@ -0,0 +1,69 @@
+
+ * @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('_JEXEC') or die('Restricted access');
+
+// the bucket for uikit 2 classes
+$this->classes = array();
+
+?>
+
diff --git a/site/views/members/tmpl/default.xml b/site/views/members/tmpl/default.xml
new file mode 100644
index 0000000..f8e5fca
--- /dev/null
+++ b/site/views/members/tmpl/default.xml
@@ -0,0 +1,247 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/site/views/members/tmpl/default_member_list.php b/site/views/members/tmpl/default_member_list.php
new file mode 100644
index 0000000..e0cbd1e
--- /dev/null
+++ b/site/views/members/tmpl/default_member_list.php
@@ -0,0 +1,46 @@
+
+ * @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('_JEXEC') or die('Restricted access');
+
+
+// get templates
+$body_template = $this->params->get('list_template', '');
+$item_template = $this->params->get('list_item_template', '');
+// if uikit 2 then we need to load some more components if needed
+if (2 == $this->uikitVersion)
+{
+ $this->classes = MembersmanagerHelper::getUikitComp($body_template, $this->classes);
+ $this->classes = MembersmanagerHelper::getUikitComp($item_template, $this->classes);
+}
+// check that it has the [panel_template] placeholder
+if (strpos($body_template, '[load_items]') !==false)
+{
+ $body_template = explode('[load_items]', $body_template);
+}
+else
+{
+ // we may need to do some defaults here
+ $body_template = array();
+}
+
+?>
+
+
+
+
+items as $item): ?>
+
+
+
+
+
diff --git a/site/views/members/tmpl/default_member_panels.php b/site/views/members/tmpl/default_member_panels.php
new file mode 100644
index 0000000..472539c
--- /dev/null
+++ b/site/views/members/tmpl/default_member_panels.php
@@ -0,0 +1,46 @@
+
+ * @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('_JEXEC') or die('Restricted access');
+
+
+// get templates
+$body_template = $this->params->get('panels_template', '');
+$item_template = $this->params->get('panel_template', '');
+// if uikit 2 then we need to load some more components if needed
+if (2 == $this->uikitVersion)
+{
+ $this->classes = MembersmanagerHelper::getUikitComp($body_template, $this->classes);
+ $this->classes = MembersmanagerHelper::getUikitComp($item_template, $this->classes);
+}
+// check that it has the [panel_template] placeholder
+if (strpos($body_template, '[load_items]') !==false)
+{
+ $body_template = explode('[load_items]', $body_template);
+}
+else
+{
+ // we may need to do some defaults here
+ $body_template = array();
+}
+
+?>
+
+
+
+
+items as $item): ?>
+
+
+
+
+
diff --git a/site/views/members/tmpl/default_member_table.php b/site/views/members/tmpl/default_member_table.php
new file mode 100644
index 0000000..ad9bc31
--- /dev/null
+++ b/site/views/members/tmpl/default_member_table.php
@@ -0,0 +1,46 @@
+
+ * @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('_JEXEC') or die('Restricted access');
+
+
+// get templates
+$body_template = $this->params->get('table_template', '');
+$item_template = $this->params->get('table_row_template', '');
+// if uikit 2 then we need to load some more components if needed
+if (2 == $this->uikitVersion)
+{
+ $this->classes = MembersmanagerHelper::getUikitComp($body_template, $this->classes);
+ $this->classes = MembersmanagerHelper::getUikitComp($item_template, $this->classes);
+}
+// check that it has the [panel_template] placeholder
+if (strpos($body_template, '[load_items]') !==false)
+{
+ $body_template = explode('[load_items]', $body_template);
+}
+else
+{
+ // we may need to do some defaults here
+ $body_template = array();
+}
+
+?>
+
+
+
+
+items as $item): ?>
+
+
+
+
+
diff --git a/site/views/members/tmpl/index.html b/site/views/members/tmpl/index.html
new file mode 100644
index 0000000..fa6d84e
--- /dev/null
+++ b/site/views/members/tmpl/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/views/members/view.html.php b/site/views/members/view.html.php
new file mode 100644
index 0000000..67e148d
--- /dev/null
+++ b/site/views/members/view.html.php
@@ -0,0 +1,153 @@
+
+ * @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('_JEXEC') or die('Restricted access');
+
+/**
+ * Membersmanager View class for the Members
+ */
+class MembersmanagerViewMembers extends JViewLegacy
+{
+ // Overwriting JView display method
+ function display($tpl = null)
+ {
+ // get combined params of both component and menu
+ $this->app = JFactory::getApplication();
+ $this->params = $this->app->getParams();
+ $this->menu = $this->app->getMenu()->getActive();
+ // get the user object
+ $this->user = JFactory::getUser();
+ // Initialise variables.
+ $this->items = $this->get('Items');
+ $this->pagination = $this->get('Pagination');
+ // load the google lib
+ $this->document->addScript('https://www.gstatic.com/charts/loader.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
+ // load the chart current
+ $this->document->addScriptDeclaration("google.charts.load('current');");
+
+ // Set the toolbar
+ $this->addToolBar();
+
+ // set the document
+ $this->_prepareDocument();
+
+ // Check for errors.
+ if (count($errors = $this->get('Errors')))
+ {
+ throw new Exception(implode("\n", $errors), 500);
+ }
+
+ parent::display($tpl);
+ }
+
+ /**
+ * Prepares the document
+ */
+ protected function _prepareDocument()
+ {
+
+ // always make sure jquery is loaded.
+ JHtml::_('jquery.framework');
+ // Load the header checker class.
+ require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' );
+ // Initialize the header checker.
+ $HeaderCheck = new membersmanagerHeaderCheck;
+
+ // Load uikit options.
+ $uikit = $this->params->get('uikit_load');
+ // Set script size.
+ $size = $this->params->get('uikit_min');
+
+ // Load uikit version.
+ $this->uikitVersion = $this->params->get('uikit_version', 2);
+
+ // Use Uikit Version 2
+ if (2 == $this->uikitVersion)
+ {
+ // Set css style.
+ $style = $this->params->get('uikit_style');
+
+ // The uikit css.
+ if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
+ {
+ $this->document->addStyleSheet(JURI::root(true) .'/media/com_membersmanager/uikit-v2/css/uikit'.$style.$size.'.css', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
+ }
+ // The uikit js.
+ if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
+ {
+ $this->document->addScript(JURI::root(true) .'/media/com_membersmanager/uikit-v2/js/uikit'.$size.'.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
+ }
+ }
+ // Use Uikit Version 3
+ elseif (3 == $this->uikitVersion)
+ {
+ // The uikit css.
+ if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
+ {
+ $this->document->addStyleSheet(JURI::root(true) .'/media/com_membersmanager/uikit-v3/css/uikit'.$size.'.css', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
+ }
+ // The uikit js.
+ if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
+ {
+ $this->document->addScript(JURI::root(true) .'/media/com_membersmanager/uikit-v3/js/uikit'.$size.'.js', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
+ }
+ }
+ // load the meta description
+ if ($this->params->get('menu-meta_description'))
+ {
+ $this->document->setDescription($this->params->get('menu-meta_description'));
+ }
+ // load the key words if set
+ if ($this->params->get('menu-meta_keywords'))
+ {
+ $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
+ }
+ // check the robot params
+ if ($this->params->get('robots'))
+ {
+ $this->document->setMetadata('robots', $this->params->get('robots'));
+ }
+ // add the document default css file
+ $this->document->addStyleSheet(JURI::root(true) .'/components/com_membersmanager/assets/css/members.css', (MembersmanagerHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
+ }
+
+ /**
+ * Setting the toolbar
+ */
+ protected function addToolBar()
+ {
+ // adding the joomla toolbar to the front
+ JLoader::register('JToolbarHelper', JPATH_ADMINISTRATOR.'/includes/toolbar.php');
+
+ // set help url for this view if found
+ $help_url = MembersmanagerHelper::getHelpUrl('members');
+ if (MembersmanagerHelper::checkString($help_url))
+ {
+ JToolbarHelper::help('COM_MEMBERSMANAGER_HELP_MANAGER', false, $help_url);
+ }
+ // now initiate the toolbar
+ $this->toolbar = JToolbar::getInstance();
+ }
+
+ /**
+ * Escapes a value for output in a view script.
+ *
+ * @param mixed $var The output to escape.
+ *
+ * @return mixed The escaped value.
+ */
+ public function escape($var, $sorten = false, $length = 40)
+ {
+ // use the helper htmlEscape method instead.
+ return MembersmanagerHelper::htmlEscape($var, $this->_charset, $sorten, $length);
+ }
+}
diff --git a/site/views/profile/tmpl/default.php b/site/views/profile/tmpl/default.php
index c8a8bf1..02afe03 100644
--- a/site/views/profile/tmpl/default.php
+++ b/site/views/profile/tmpl/default.php
@@ -2,7 +2,7 @@
/**
* @package Joomla.Members.Manager
*
- * @created 6th September, 2015
+ * @created 6th July, 2018
* @author Llewellyn van der Merwe
* @github Joomla Members Manager
* @copyright Copyright (C) 2015. All Rights Reserved
@@ -13,13 +13,30 @@
defined('_JEXEC') or die('Restricted access');
JHtml::_('bootstrap.modal');
+// check if this was directed here from a list view of member manager
+$return_to = $this->app->input->get('return', null, 'base64');
+if (!is_null($return_to) && \JUri::isInternal(base64_decode($return_to)))
+{
+ $return_to = base64_decode($return_to);
+}
?>
user->id > 0): ?>
-
-
-
+
+
+
+
+
+
+
loadTemplate('profiles'); ?>
| | |