diff --git a/src/administrator/controllers/organization.php b/src/administrator/controllers/organization.php deleted file mode 100755 index 1955d7c..0000000 --- a/src/administrator/controllers/organization.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.controllerform'); - -/** - * Organization controller class. - * - * @since 1.6 - */ -class SubusersControllerOrganization extends JControllerForm -{ - /** - * Constructor - * - * @throws Exception - */ - public function __construct() - { - $this->view_list = 'organizations'; - parent::__construct(); - } -} diff --git a/src/administrator/controllers/organizations.php b/src/administrator/controllers/organizations.php deleted file mode 100755 index 13a4eef..0000000 --- a/src/administrator/controllers/organizations.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access. -defined('_JEXEC') or die; - -jimport('joomla.application.component.controlleradmin'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Organizations list controller class. - * - * @since 1.6 - */ -class SubusersControllerOrganizations extends JControllerAdmin -{ - /** - * Method to clone existing Organizations - * - * @return void - */ - public function duplicate() - { - // Check for request forgeries - Jsession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Get id(s) - $pks = $this->input->post->get('cid', array(), 'array'); - - try - { - if (empty($pks)) - { - throw new Exception(JText::_('COM_SUBUSERS_NO_ELEMENT_SELECTED')); - } - - ArrayHelper::toInteger($pks); - $model = $this->getModel(); - $model->duplicate($pks); - $this->setMessage(Jtext::_('COM_SUBUSERS_ITEMS_SUCCESS_DUPLICATED')); - } - catch (Exception $e) - { - JFactory::getApplication()->enqueueMessage($e->getMessage(), 'warning'); - } - - $this->setRedirect('index.php?option=com_subusers&view=organizations'); - } - - /** - * Proxy for getModel. - * - * @param string $name Optional. Model name - * @param string $prefix Optional. Class prefix - * @param array $config Optional. Configuration array for model - * - * @return object The Model - * - * @since 1.6 - */ - public function getModel($name = 'organization', $prefix = 'SubusersModel', $config = array()) - { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; - } - - /** - * Method to save the submitted ordering values for records via AJAX. - * - * @return void - * - * @since 3.0 - */ - public function saveOrderAjax() - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - $order = $input->post->get('order', array(), 'array'); - - // Sanitize the input - ArrayHelper::toInteger($pks); - ArrayHelper::toInteger($order); - - // Get the model - $model = $this->getModel(); - - // Save the ordering - $return = $model->saveorder($pks, $order); - - if ($return) - { - echo "1"; - } - - // Close the application - JFactory::getApplication()->close(); - } -} diff --git a/src/administrator/models/forms/organization.xml b/src/administrator/models/forms/organization.xml deleted file mode 100755 index 53fa812..0000000 --- a/src/administrator/models/forms/organization.xml +++ /dev/null @@ -1,69 +0,0 @@ - -
-
- - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/administrator/models/organization.php b/src/administrator/models/organization.php deleted file mode 100755 index 7f907ad..0000000 --- a/src/administrator/models/organization.php +++ /dev/null @@ -1,225 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access. -defined('_JEXEC') or die; - -jimport('joomla.application.component.modeladmin'); - -/** - * Subusers model. - * - * @since 1.6 - */ -class SubusersModelOrganization extends JModelAdmin -{ - /** - * @var string The prefix to use with controller messages. - * @since 1.6 - */ - protected $text_prefix = 'COM_SUBUSERS'; - - /** - * @var null Item data - * @since 1.6 - */ - protected $item = null; - - /** - * Returns a reference to the a Table object, always creating it. - * - * @param string $type The table type to instantiate - * @param string $prefix A prefix for the table class name. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JTable A database object - * - * @since 1.6 - */ - public function getTable($type = 'Organization', $prefix = 'SubusersTable', $config = array()) - { - return JTable::getInstance($type, $prefix, $config); - } - - /** - * Method to get the record form. - * - * @param array $data An optional array of data for the form to interogate. - * @param boolean $loadData True if the form is to load its own data (default case), false if not. - * - * @return JForm A JForm object on success, false on failure - * - * @since 1.6 - */ - public function getForm($data = array(), $loadData = true) - { - // Initialise variables. - $app = JFactory::getApplication(); - - // Get the form. - $form = $this->loadForm( - 'com_subusers.organization', 'organization', - array('control' => 'jform', - 'load_data' => $loadData - ) - ); - - if (empty($form)) - { - return false; - } - - return $form; - } - - /** - * Method to get the data that should be injected in the form. - * - * @return mixed The data for the form. - * - * @since 1.6 - */ - protected function loadFormData() - { - // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_subusers.edit.organization.data', array()); - - if (empty($data)) - { - if ($this->item === null) - { - $this->item = $this->getItem(); - } - - $data = $this->item; - } - - return $data; - } - - /** - * Method to get a single record. - * - * @param integer $pk The id of the primary key. - * - * @return mixed Object on success, false on failure. - * - * @since 1.6 - */ - public function getItem($pk = null) - { - if ($item = parent::getItem($pk)) - { - // Do any procesing on fields here if needed - } - - return $item; - } - - /** - * Method to duplicate an Organization - * - * @param array &$pks An array of primary key IDs. - * - * @return boolean True if successful. - * - * @throws Exception - */ - public function duplicate(&$pks) - { - $user = JFactory::getUser(); - - // Access checks. - if (!$user->authorise('core.create', 'com_subusers')) - { - throw new Exception(JText::_('JERROR_CORE_CREATE_NOT_PERMITTED')); - } - - $dispatcher = JEventDispatcher::getInstance(); - $context = $this->option . '.' . $this->name; - - // Include the plugins for the save events. - JPluginHelper::importPlugin($this->events_map['save']); - - $table = $this->getTable(); - - foreach ($pks as $pk) - { - if ($table->load($pk, true)) - { - // Reset the id to create a new record. - $table->id = 0; - - if (!$table->check()) - { - throw new Exception($table->getError()); - } - - if (!empty($table->logo)) - { - if (is_array($table->logo)) - { - $table->logo = implode(',', $table->logo); - } - } - else - { - $table->logo = ''; - } - - - // Trigger the before save event. - $result = $dispatcher->trigger($this->event_before_save, array($context, &$table, true)); - - if (in_array(false, $result, true) || !$table->store()) - { - throw new Exception($table->getError()); - } - - // Trigger the after save event. - $dispatcher->trigger($this->event_after_save, array($context, &$table, true)); - } - else - { - throw new Exception($table->getError()); - } - } - - // Clean cache - $this->cleanCache(); - - return true; - } - - /** - * Prepare and sanitise the table prior to saving. - * - * @param JTable $table Table Object - * - * @return void - * - * @since 1.6 - */ - protected function prepareTable($table) - { - jimport('joomla.filter.output'); - - if (empty($table->id)) - { - // Set ordering to the last item if not set - if (@$table->ordering === '') - { - $db = JFactory::getDbo(); - $db->setQuery('SELECT MAX(ordering) FROM #__tjsu_organizations'); - $max = $db->loadResult(); - $table->ordering = $max + 1; - } - } - } -} diff --git a/src/administrator/models/organizations.php b/src/administrator/models/organizations.php deleted file mode 100755 index 0200e71..0000000 --- a/src/administrator/models/organizations.php +++ /dev/null @@ -1,181 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -defined('_JEXEC') or die; - -jimport('joomla.application.component.modellist'); - -/** - * Methods supporting a list of Subusers records. - * - * @since 1.6 - */ -class SubusersModelOrganizations extends JModelList -{ -/** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * - * @see JController - * @since 1.6 - */ - public function __construct($config = array()) - { - if (empty($config['filter_fields'])) - { - $config['filter_fields'] = array( - 'id', 'a.`id`', - 'name', 'a.`name`', - 'created_by', 'a.`created_by`', - 'ordering', 'a.`ordering`', - 'state', 'a.`state`', - 'email', 'a.`email`', - 'logo', 'a.`logo`', - ); - } - - parent::__construct($config); - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @param string $ordering Elements order - * @param string $direction Order direction - * - * @return void - * - * @throws Exception - */ - protected function populateState($ordering = null, $direction = null) - { - // Initialise variables. - $app = JFactory::getApplication('administrator'); - - // Load the filter state. - $search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); - $this->setState('filter.search', $search); - - $published = $app->getUserStateFromRequest($this->context . '.filter.state', 'filter_published', '', 'string'); - $this->setState('filter.state', $published); - - // Load the parameters. - $params = JComponentHelper::getParams('com_subusers'); - $this->setState('params', $params); - - // List state information. - parent::populateState('a.id', 'desc'); - } - - /** - * Method to get a store id based on model configuration state. - * - * This is necessary because the model is used by the component and - * different modules that might need different sets of data or different - * ordering requirements. - * - * @param string $id A prefix for the store id. - * - * @return string A store id. - * - * @since 1.6 - */ - protected function getStoreId($id = '') - { - // Compile the store id. - $id .= ':' . $this->getState('filter.search'); - $id .= ':' . $this->getState('filter.state'); - - return parent::getStoreId($id); - } - - /** - * Build an SQL query to load the list data. - * - * @return JDatabaseQuery - * - * @since 1.6 - */ - protected function getListQuery() - { - // Create a new query object. - $db = $this->getDbo(); - $query = $db->getQuery(true); - - // Select the required fields from the table. - $query->select( - $this->getState( - 'list.select', 'DISTINCT a.*' - ) - ); - $query->from('`#__tjsu_organizations` AS a'); - - // Join over the users for the checked out user - $query->select("uc.name AS editor"); - $query->join("LEFT", "#__users AS uc ON uc.id=a.checked_out"); - - // Join over the user field 'created_by' - $query->select('`created_by`.name AS `created_by`'); - $query->join('LEFT', '#__users AS `created_by` ON `created_by`.id = a.`created_by`'); - - // Filter by published state - $published = $this->getState('filter.state'); - - if (is_numeric($published)) - { - $query->where('a.state = ' . (int) $published); - } - elseif ($published === '') - { - $query->where('(a.state IN (0, 1))'); - } - - // Filter by search in title - $search = $this->getState('filter.search'); - - if (!empty($search)) - { - if (stripos($search, 'id:') === 0) - { - $query->where('a.id = ' . (int) substr($search, 3)); - } - else - { - $search = $db->Quote('%' . $db->escape($search, true) . '%'); - $query->where('( a.`name` LIKE ' . $search . ' OR a.`created_by` LIKE ' . $search . ' OR a.`email` LIKE ' . $search . ' )'); - } - } - - // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering'); - $orderDirn = $this->state->get('list.direction'); - - if ($orderCol && $orderDirn) - { - $query->order($db->escape($orderCol . ' ' . $orderDirn)); - } - - return $query; - } - - /** - * Get an array of data items - * - * @return mixed Array of data items on success, false on failure. - */ - public function getItems() - { - $items = parent::getItems(); - - return $items; - } -} diff --git a/src/administrator/tables/announcement.php b/src/administrator/tables/announcement.php deleted file mode 100755 index ed7fdb2..0000000 --- a/src/administrator/tables/announcement.php +++ /dev/null @@ -1,372 +0,0 @@ - - * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -use Joomla\Utilities\ArrayHelper; -/** - * organization Table class - * - * @since 1.6 - */ -class SubusersTableannouncement extends JTable -{ - /** - * Constructor - * - * @param JDatabase &$db A database connector object - */ - public function __construct(&$db) - { - parent::__construct('#__tjsu_organizations', 'id', $db); - } - - /** - * Overloaded bind function to pre-process the params. - * - * @param array $array Named array - * @param mixed $ignore Optional array or list of parameters to ignore - * - * @return null|string null is operation was satisfactory, otherwise returns an error - * - * @see JTable:bind - * @since 1.5 - */ - public function bind($array, $ignore = '') - { - $input = JFactory::getApplication()->input; - $task = $input->getString('task', ''); - - if (($task == 'save' || $task == 'apply') && (!JFactory::getUser()->authorise('core.edit.state', 'com_subusers') && $array['state'] == 1)) - { - $array['state'] = 0; - } - // Support for multi file field: logo - if (!empty($array['logo'])) - { - if (is_array($array['logo'])) - { - $array['logo'] = implode(',', $array['logo']); - } - elseif (strpos($array['logo'], ',') != false) - { - $array['logo'] = explode(',', $array['logo']); - } - } - else - { - $array['logo'] = ''; - } - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - if (!JFactory::getUser()->authorise('core.admin', 'com_subusers.announcement.' . $array['id'])) - { - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_subusers/access.xml', - "/access/section[@name='announcement']/" - ); - $default_actions = JAccess::getAssetRules('com_subusers.announcement.' . $array['id'])->getData(); - $array_jaccess = array(); - - foreach ($actions as $action) - { - $array_jaccess[$action->name] = $default_actions[$action->name]; - } - - $array['rules'] = $this->JAccessRulestoArray($array_jaccess); - } - - // Bind the rules for ACL where supported. - if (isset($array['rules']) && is_array($array['rules'])) - { - $this->setRules($array['rules']); - } - - return parent::bind($array, $ignore); - } - - /** - * This function convert an array of JAccessRule objects into an rules array. - * - * @param array $jaccessrules An array of JAccessRule objects. - * - * @return array - */ - private function JAccessRulestoArray($jaccessrules) - { - $rules = array(); - - foreach ($jaccessrules as $action => $jaccess) - { - $actions = array(); - - foreach ($jaccess->getData() as $group => $allow) - { - $actions[$group] = ((bool) $allow); - } - - $rules[$action] = $actions; - } - - return $rules; - } - - /** - * Overloaded check function - * - * @return bool - */ - public function check() - { - // If there is an ordering column and this is a new row then get the next ordering value - if (property_exists($this, 'ordering') && $this->id == 0) - { - $this->ordering = self::getNextOrder(); - } - - // Support multi file field: logo - $app = JFactory::getApplication(); - $files = $app->input->files->get('jform', array(), 'raw'); - $array = $app->input->get('jform', array(), 'ARRAY'); - - if (!empty($files['logo'])) - { - $this->logo = ""; - - foreach ($files['logo'] as $singleFile ) - { - jimport('joomla.filesystem.file'); - - // Check if the server found any error. - $fileError = $singleFile['error']; - $message = ''; - - if ($fileError > 0 && $fileError != 4) - { - switch ($fileError) - { - case 1: - $message = JText::_('File size exceeds allowed by the server'); - break; - case 2: - $message = JText::_('File size exceeds allowed by the html form'); - break; - case 3: - $message = JText::_('Partial upload error'); - break; - } - - if ($message != '') - { - $app->enqueueMessage($message, 'warning'); - - return false; - } - } - elseif ($fileError == 4) - { - if (isset($array['logo'])) - { - $this->logo = $array['logo']; - } - } - else - { - // Replace any special characters in the filename - jimport('joomla.filesystem.file'); - $filename = JFile::stripExt($singleFile['name']); - $extension = JFile::getExt($singleFile['name']); - $filename = preg_replace("/[^A-Za-z0-9]/i", "-", $filename); - $filename = $filename . '.' . $extension; - $uploadPath = JPATH_ROOT . '/images/com_subusers/partners/' . $filename; - $fileTemp = $singleFile['tmp_name']; - - if (!JFile::exists($uploadPath)) - { - if (!JFile::upload($fileTemp, $uploadPath)) - { - $app->enqueueMessage('Error moving file', 'warning'); - - return false; - } - } - - $this->logo .= (!empty($this->logo)) ? "," : ""; - $this->logo .= $filename; - } - } - } - - return parent::check(); - } - - /** - * Method to set the publishing state for a row or list of rows in the database - * table. The method respects checked out rows by other users and will attempt - * to checkin rows that it can after adjustments are made. - * - * @param mixed $pks An optional array of primary key values to update. If not - * set the instance property value is used. - * @param integer $state The publishing state. eg. [0 = unpublished, 1 = published] - * @param integer $userId The user id of the user performing the operation. - * - * @return boolean True on success. - * - * @since 1.0.4 - * - * @throws Exception - */ - public function publish($pks = null, $state = 1, $userId = 0) - { - // Initialise variables. - $k = $this->_tbl_key; - - // Sanitize input. - ArrayHelper::toInteger($pks); - $userId = (int) $userId; - $state = (int) $state; - - // If there are no primary keys set check to see if the instance key is set. - if (empty($pks)) - { - if ($this->$k) - { - $pks = array($this->$k); - } - // Nothing to set publishing state on, return false. - else - { - throw new Exception(500, JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED')); - } - } - - // Build the WHERE clause for the primary keys. - $where = $k . '=' . implode(' OR ' . $k . '=', $pks); - - // Determine if there is checkin support for the table. - if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) - { - $checkin = ''; - } - else - { - $checkin = ' AND (checked_out = 0 OR checked_out = ' . (int) $userId . ')'; - } - - // Update the publishing state for rows with the given primary keys. - $this->_db->setQuery( - 'UPDATE `' . $this->_tbl . '`' . - ' SET `state` = ' . (int) $state . - ' WHERE (' . $where . ')' . - $checkin - ); - $this->_db->execute(); - - // If checkin is supported and all rows were adjusted, check them in. - if ($checkin && (count($pks) == $this->_db->getAffectedRows())) - { - // Checkin each row. - foreach ($pks as $pk) - { - $this->checkin($pk); - } - } - - // If the JTable instance value is in the list of primary keys that were set, set the instance. - if (in_array($this->$k, $pks)) - { - $this->state = $state; - } - - return true; - } - - /** - * Define a namespaced asset name for inclusion in the #__assets table - * - * @return string The asset name - * - * @see JTable::_getAssetName - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - - return 'com_subusers.organization.' . (int) $this->$k; - } - - /** - * Returns the parent asset's id. If you have a tree structure, retrieve the parent's id using the external key field - * - * @param JTable $table Table name - * @param integer $id Id - * - * @see JTable::_getAssetParentId - * - * @return mixed The id on success, false on failure. - */ - protected function _getAssetParentId(JTable $table = null, $id = null) - { - // We will retrieve the parent-asset from the Asset-table - $assetParent = JTable::getInstance('Asset'); - - // Default: if no asset-parent can be found we take the global asset - $assetParentId = $assetParent->getRootId(); - - // The item has the component as asset-parent - $assetParent->loadByName('com_subusers'); - - // Return the found asset-parent-id - if ($assetParent->id) - { - $assetParentId = $assetParent->id; - } - - return $assetParentId; - } - - /** - * Delete a record by id - * - * @param mixed $pk Primary key value to delete. Optional - * - * @return bool - */ - public function delete($pk = null) - { - $this->load($pk); - $result = parent::delete($pk); - - if ($result) - { - jimport('joomla.filesystem.file'); - - foreach ($this->logo as $logoFile) - { - JFile::delete(JPATH_ROOT . '/images/partners/' . $logoFile); - } - } - - return $result; - } -} diff --git a/src/administrator/tables/organization.php b/src/administrator/tables/organization.php deleted file mode 100755 index 5cee1c1..0000000 --- a/src/administrator/tables/organization.php +++ /dev/null @@ -1,372 +0,0 @@ - - * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -use Joomla\Utilities\ArrayHelper; -/** - * organization Table class - * - * @since 1.6 - */ -class SubusersTableorganization extends JTable -{ - /** - * Constructor - * - * @param JDatabase &$db A database connector object - */ - public function __construct(&$db) - { - parent::__construct('#__tjsu_organizations', 'id', $db); - } - - /** - * Overloaded bind function to pre-process the params. - * - * @param array $array Named array - * @param mixed $ignore Optional array or list of parameters to ignore - * - * @return null|string null is operation was satisfactory, otherwise returns an error - * - * @see JTable:bind - * @since 1.5 - */ - public function bind($array, $ignore = '') - { - $input = JFactory::getApplication()->input; - $task = $input->getString('task', ''); - - if (($task == 'save' || $task == 'apply') && (!JFactory::getUser()->authorise('core.edit.state', 'com_subusers') && $array['state'] == 1)) - { - $array['state'] = 0; - } - // Support for multi file field: logo - if (!empty($array['logo'])) - { - if (is_array($array['logo'])) - { - $array['logo'] = implode(',', $array['logo']); - } - elseif (strpos($array['logo'], ',') != false) - { - $array['logo'] = explode(',', $array['logo']); - } - } - else - { - $array['logo'] = ''; - } - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - if (!JFactory::getUser()->authorise('core.admin', 'com_subusers.organization.' . $array['id'])) - { - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_subusers/access.xml', - "/access/section[@name='organization']/" - ); - $default_actions = JAccess::getAssetRules('com_subusers.organization.' . $array['id'])->getData(); - $array_jaccess = array(); - - foreach ($actions as $action) - { - $array_jaccess[$action->name] = $default_actions[$action->name]; - } - - $array['rules'] = $this->JAccessRulestoArray($array_jaccess); - } - - // Bind the rules for ACL where supported. - if (isset($array['rules']) && is_array($array['rules'])) - { - $this->setRules($array['rules']); - } - - return parent::bind($array, $ignore); - } - - /** - * This function convert an array of JAccessRule objects into an rules array. - * - * @param array $jaccessrules An array of JAccessRule objects. - * - * @return array - */ - private function JAccessRulestoArray($jaccessrules) - { - $rules = array(); - - foreach ($jaccessrules as $action => $jaccess) - { - $actions = array(); - - foreach ($jaccess->getData() as $group => $allow) - { - $actions[$group] = ((bool) $allow); - } - - $rules[$action] = $actions; - } - - return $rules; - } - - /** - * Overloaded check function - * - * @return bool - */ - public function check() - { - // If there is an ordering column and this is a new row then get the next ordering value - if (property_exists($this, 'ordering') && $this->id == 0) - { - $this->ordering = self::getNextOrder(); - } - - // Support multi file field: logo - $app = JFactory::getApplication(); - $files = $app->input->files->get('jform', array(), 'raw'); - $array = $app->input->get('jform', array(), 'ARRAY'); - - if (!empty($files['logo'])) - { - $this->logo = ""; - - foreach ($files['logo'] as $singleFile ) - { - jimport('joomla.filesystem.file'); - - // Check if the server found any error. - $fileError = $singleFile['error']; - $message = ''; - - if ($fileError > 0 && $fileError != 4) - { - switch ($fileError) - { - case 1: - $message = JText::_('File size exceeds allowed by the server'); - break; - case 2: - $message = JText::_('File size exceeds allowed by the html form'); - break; - case 3: - $message = JText::_('Partial upload error'); - break; - } - - if ($message != '') - { - $app->enqueueMessage($message, 'warning'); - - return false; - } - } - elseif ($fileError == 4) - { - if (isset($array['logo'])) - { - $this->logo = $array['logo']; - } - } - else - { - // Replace any special characters in the filename - jimport('joomla.filesystem.file'); - $filename = JFile::stripExt($singleFile['name']); - $extension = JFile::getExt($singleFile['name']); - $filename = preg_replace("/[^A-Za-z0-9]/i", "-", $filename); - $filename = $filename . '.' . $extension; - $uploadPath = JPATH_ROOT . '/images/com_subusers/partners/' . $filename; - $fileTemp = $singleFile['tmp_name']; - - if (!JFile::exists($uploadPath)) - { - if (!JFile::upload($fileTemp, $uploadPath)) - { - $app->enqueueMessage('Error moving file', 'warning'); - - return false; - } - } - - $this->logo .= (!empty($this->logo)) ? "," : ""; - $this->logo .= $filename; - } - } - } - - return parent::check(); - } - - /** - * Method to set the publishing state for a row or list of rows in the database - * table. The method respects checked out rows by other users and will attempt - * to checkin rows that it can after adjustments are made. - * - * @param mixed $pks An optional array of primary key values to update. If not - * set the instance property value is used. - * @param integer $state The publishing state. eg. [0 = unpublished, 1 = published] - * @param integer $userId The user id of the user performing the operation. - * - * @return boolean True on success. - * - * @since 1.0.4 - * - * @throws Exception - */ - public function publish($pks = null, $state = 1, $userId = 0) - { - // Initialise variables. - $k = $this->_tbl_key; - - // Sanitize input. - ArrayHelper::toInteger($pks); - $userId = (int) $userId; - $state = (int) $state; - - // If there are no primary keys set check to see if the instance key is set. - if (empty($pks)) - { - if ($this->$k) - { - $pks = array($this->$k); - } - // Nothing to set publishing state on, return false. - else - { - throw new Exception(500, JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED')); - } - } - - // Build the WHERE clause for the primary keys. - $where = $k . '=' . implode(' OR ' . $k . '=', $pks); - - // Determine if there is checkin support for the table. - if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) - { - $checkin = ''; - } - else - { - $checkin = ' AND (checked_out = 0 OR checked_out = ' . (int) $userId . ')'; - } - - // Update the publishing state for rows with the given primary keys. - $this->_db->setQuery( - 'UPDATE `' . $this->_tbl . '`' . - ' SET `state` = ' . (int) $state . - ' WHERE (' . $where . ')' . - $checkin - ); - $this->_db->execute(); - - // If checkin is supported and all rows were adjusted, check them in. - if ($checkin && (count($pks) == $this->_db->getAffectedRows())) - { - // Checkin each row. - foreach ($pks as $pk) - { - $this->checkin($pk); - } - } - - // If the JTable instance value is in the list of primary keys that were set, set the instance. - if (in_array($this->$k, $pks)) - { - $this->state = $state; - } - - return true; - } - - /** - * Define a namespaced asset name for inclusion in the #__assets table - * - * @return string The asset name - * - * @see JTable::_getAssetName - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - - return 'com_subusers.organization.' . (int) $this->$k; - } - - /** - * Returns the parent asset's id. If you have a tree structure, retrieve the parent's id using the external key field - * - * @param JTable $table Table name - * @param integer $id Id - * - * @see JTable::_getAssetParentId - * - * @return mixed The id on success, false on failure. - */ - protected function _getAssetParentId(JTable $table = null, $id = null) - { - // We will retrieve the parent-asset from the Asset-table - $assetParent = JTable::getInstance('Asset'); - - // Default: if no asset-parent can be found we take the global asset - $assetParentId = $assetParent->getRootId(); - - // The item has the component as asset-parent - $assetParent->loadByName('com_subusers'); - - // Return the found asset-parent-id - if ($assetParent->id) - { - $assetParentId = $assetParent->id; - } - - return $assetParentId; - } - - /** - * Delete a record by id - * - * @param mixed $pk Primary key value to delete. Optional - * - * @return bool - */ - public function delete($pk = null) - { - $this->load($pk); - $result = parent::delete($pk); - - if ($result) - { - jimport('joomla.filesystem.file'); - - foreach ($this->logo as $logoFile) - { - JFile::delete(JPATH_ROOT . '/images/com_subusers/partners/' . $logoFile); - } - } - - return $result; - } -} diff --git a/src/administrator/views/organization/index.html b/src/administrator/views/organization/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/administrator/views/organization/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/administrator/views/organization/tmpl/edit.php b/src/administrator/views/organization/tmpl/edit.php deleted file mode 100755 index a6cb716..0000000 --- a/src/administrator/views/organization/tmpl/edit.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); -JHtml::_('behavior.tooltip'); -JHtml::_('behavior.formvalidation'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); - -// Import CSS -$document = JFactory::getDocument(); -$document->addStyleSheet(JPATH_ROOT . 'media/com_subusers/css/edit.css'); -?> - - -
- -
- 'general')); ?> - -
-
-
-
-
form->getLabel('id'); ?>
-
form->getInput('id'); ?>
-
- -
-
form->getLabel('name'); ?>
-
form->getInput('name'); ?>
-
- - - - - - - -
-
form->getLabel('email'); ?>
-
form->getInput('email'); ?>
-
- -
-
form->getLabel('logo'); ?>
-
form->getInput('logo'); ?>
-
- - item->logo)) : ?> - item->logo as $fileSingle) : ?> - - | - - - - -
-
-
- - - - -
-
diff --git a/src/administrator/views/organization/tmpl/index.html b/src/administrator/views/organization/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/administrator/views/organization/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/administrator/views/organization/view.html.php b/src/administrator/views/organization/view.html.php deleted file mode 100755 index eb3d2a4..0000000 --- a/src/administrator/views/organization/view.html.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.view'); - -/** - * View to edit - * - * @since 1.6 - */ -class SubusersViewOrganization extends JViewLegacy -{ - protected $state; - - protected $item; - - protected $form; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $this->state = $this->get('State'); - $this->item = $this->get('Item'); - $this->form = $this->get('Form'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - - $this->addToolbar(); - parent::display($tpl); - } - - /** - * Add the page title and toolbar. - * - * @return void - * - * @throws Exception - */ - protected function addToolbar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - - $user = JFactory::getUser(); - $isNew = ($this->item->id == 0); - - if (isset($this->item->checked_out)) - { - $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); - } - else - { - $checkedOut = false; - } - - $canDo = SubusersHelper::getActions(); - - JToolBarHelper::title(JText::_('COM_SUBUSERS_TITLE_ORGANIZATION'), 'organization.png'); - - // If not checked out, can save the item. - if (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create')))) - { - JToolBarHelper::apply('organization.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('organization.save', 'JTOOLBAR_SAVE'); - } - - if (!$checkedOut && ($canDo->get('core.create'))) - { - JToolBarHelper::custom('organization.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - - // If an existing item, can save to a copy. - if (!$isNew && $canDo->get('core.create')) - { - JToolBarHelper::custom('organization.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - - if (empty($this->item->id)) - { - JToolBarHelper::cancel('organization.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - JToolBarHelper::cancel('organization.cancel', 'JTOOLBAR_CLOSE'); - } - } -} diff --git a/src/administrator/views/organizations/index.html b/src/administrator/views/organizations/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/administrator/views/organizations/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/administrator/views/organizations/tmpl/default.php b/src/administrator/views/organizations/tmpl/default.php deleted file mode 100755 index 07dab9d..0000000 --- a/src/administrator/views/organizations/tmpl/default.php +++ /dev/null @@ -1,264 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access -defined('_JEXEC') or die; - -JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('behavior.multiselect'); -JHtml::_('formbehavior.chosen', 'select'); - -// Import CSS -$document = JFactory::getDocument(); -$document->addStyleSheet(JPATH_ROOT . 'media/com_subusers/css/list.css'); - -$user = JFactory::getUser(); -$userId = $user->get('id'); -$listOrder = $this->state->get('list.ordering'); -$listDirn = $this->state->get('list.direction'); -$canOrder = $user->authorise('core.edit.state', 'com_subusers'); -$saveOrder = $listOrder == 'a.`ordering`'; - -if ($saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_subusers&task=organizations.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'organizationList', 'adminForm', strtolower($listDirn), $saveOrderingUrl); -} - -$sortFields = $this->getSortFields(); -?> - - -extra_sidebar)) -{ - $this->sidebar .= $this->extra_sidebar; -}?> - -
- sidebar)): ?> -
- sidebar; ?> -
- -
- -
- - -
- - -
- - -
- -
- - pagination->getLimitBox(); ?> -
- -
- - -
- -
- - -
-
- -
- - - - - items[0]->ordering)): ?> - - - - - items[0]->state)): ?> - - - - - - - - - - items[0]->id)): ?> - - - - - - - - - - - - - items as $i => $item) : - $ordering = ($listOrder == 'a.ordering'); - $canCreate = $user->authorise('core.create', 'com_subusers'); - $canEdit = $user->authorise('core.edit', 'com_subusers'); - $canCheckin = $user->authorise('core.manage', 'com_subusers'); - $canChange = $user->authorise('core.edit.state', 'com_subusers'); - ?> - - items[0]->ordering)) : ?> - - - - items[0]->state)): ?> - - - - - - - - - - items[0]->id)): ?> - - - - - -
- ', 'a.`ordering`', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> - - - - - - - - - - - - -
- pagination->getListFooter(); ?> -
- - - - - - - - - - - - - id); ?> - - state, $i, 'organizations.', $canChange, 'cb'); ?> - - checked_out) && $item->checked_out && ($canEdit || $canChange)) : ?> - editor, $item->checked_out_time, 'organizations.', $canCheckin); ?> - - - - escape($item->name); ?> - - - escape($item->name); ?> - - - created_by; ?> - - email; ?> - - id; ?> -
- - - - - -
- diff --git a/src/administrator/views/organizations/tmpl/index.html b/src/administrator/views/organizations/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/administrator/views/organizations/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/administrator/views/organizations/view.html.php b/src/administrator/views/organizations/view.html.php deleted file mode 100755 index c85903c..0000000 --- a/src/administrator/views/organizations/view.html.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.view'); - -/** - * View class for a list of Subusers. - * - * @since 1.6 - */ -class SubusersViewOrganizations extends JViewLegacy -{ - protected $items; - - protected $pagination; - - protected $state; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $this->state = $this->get('State'); - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - - SubusersHelper::addSubmenu('organizations'); - - $this->addToolbar(); - - $this->sidebar = JHtmlSidebar::render(); - parent::display($tpl); - } - - /** - * Add the page title and toolbar. - * - * @return void - * - * @since 1.6 - */ - protected function addToolbar() - { - require_once JPATH_COMPONENT . '/helpers/subusers.php'; - - $state = $this->get('State'); - $canDo = SubusersHelper::getActions($state->get('filter.category_id')); - - JToolBarHelper::title(JText::_('COM_SUBUSERS_TITLE_ORGANIZATIONS'), 'organizations.png'); - - // Check if the form exists before showing the add/edit buttons - $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/organization'; - - if (file_exists($formPath)) - { - if ($canDo->get('core.create')) - { - JToolBarHelper::addNew('organization.add', 'JTOOLBAR_NEW'); - JToolbarHelper::custom('organizations.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true); - } - - if ($canDo->get('core.edit') && isset($this->items[0])) - { - JToolBarHelper::editList('organization.edit', 'JTOOLBAR_EDIT'); - } - } - - if ($canDo->get('core.edit.state')) - { - if (isset($this->items[0]->state)) - { - JToolBarHelper::divider(); - JToolBarHelper::custom('organizations.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); - JToolBarHelper::custom('organizations.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); - } - elseif (isset($this->items[0])) - { - // If this component does not use state then show a direct delete button as we can not trash - JToolBarHelper::deleteList('', 'organizations.delete', 'JTOOLBAR_DELETE'); - } - - if (isset($this->items[0]->state)) - { - JToolBarHelper::divider(); - JToolBarHelper::archiveList('organizations.archive', 'JTOOLBAR_ARCHIVE'); - } - - if (isset($this->items[0]->checked_out)) - { - JToolBarHelper::custom('organizations.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); - } - } - - // Show trash and delete for components that uses the state field - if (isset($this->items[0]->state)) - { - if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) - { - JToolBarHelper::deleteList('', 'organizations.delete', 'JTOOLBAR_EMPTY_TRASH'); - JToolBarHelper::divider(); - } - elseif ($canDo->get('core.edit.state')) - { - JToolBarHelper::trash('organizations.trash', 'JTOOLBAR_TRASH'); - JToolBarHelper::divider(); - } - } - - if ($canDo->get('core.admin')) - { - JToolbarHelper::custom('database.fix', 'refresh', 'refresh', 'COM_SUBUSERS_TOOLBAR_DATABASE_FIX', false); - JToolBarHelper::preferences('com_subusers'); - } - - // Set sidebar action - New in 3.0 - JHtmlSidebar::setAction('index.php?option=com_subusers&view=organizations'); - - $this->extra_sidebar = ''; - JHtmlSidebar::addFilter( - - JText::_('JOPTION_SELECT_PUBLISHED'), - - 'filter_published', - - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true) - - ); - } - - /** - * Method to order fields - * - * @return void - */ - protected function getSortFields() - { - return array( - 'a.`id`' => JText::_('JGRID_HEADING_ID'), - 'a.`name`' => JText::_('COM_SUBUSERS_ORGANIZATIONS_NAME'), - 'a.`created_by`' => JText::_('COM_SUBUSERS_ORGANIZATIONS_CREATED_BY'), - 'a.`ordering`' => JText::_('JGRID_HEADING_ORDERING'), - 'a.`state`' => JText::_('JSTATUS'), - 'a.`email`' => JText::_('COM_SUBUSERS_ORGANIZATIONS_EMAIL'), - ); - } -} diff --git a/src/site/controller.php b/src/site/controller.php index 809aa5b..3957c4a 100755 --- a/src/site/controller.php +++ b/src/site/controller.php @@ -33,7 +33,7 @@ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT . '/helpers/subusers.php'; - $view = JFactory::getApplication()->input->getCmd('view', 'organizations'); + $view = JFactory::getApplication()->input->getCmd('view', 'roles'); JFactory::getApplication()->input->set('view', $view); parent::display($cachable, $urlparams); diff --git a/src/site/controllers/announcementform.php b/src/site/controllers/announcementform.php deleted file mode 100755 index f98f19f..0000000 --- a/src/site/controllers/announcementform.php +++ /dev/null @@ -1,265 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -require_once JPATH_COMPONENT . '/controller.php'; - -/** - * Organization controller class. - * - * @since 1.6 - */ -class SubusersControllerAnnouncementForm extends SubusersController -{ - /** - * Method to check out an item for editing and redirect to the edit form. - * - * @return void - * - * @since 1.6 - */ - public function edit() - { - $app = JFactory::getApplication(); - - // Get the previous edit id (if any) and the current edit id. - $previousId = (int) $app->getUserState('com_subusers.edit.organization.id'); - $editId = $app->input->getInt('id', 0); - $org_id = $app->input->getInt('org_id', 0); - - // Set the user id for the user to edit in the session. - $app->setUserState('com_subusers.edit.organization.id', $editId); - - // Get the model. - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - // Check out the item - if ($editId) - { - $model->checkout($editId); - } - - // Check in the previous user. - if ($previousId) - { - $model->checkin($previousId); - } - - // Redirect to the edit screen. - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=announcementform&layout=edit&org_id=' . $org_id, false)); - } - - /** - * Method to save a user's profile data. - * - * @return void - * - * @throws Exception - * @since 1.6 - */ - public function save() - { - // Check for request forgeries. - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Initialise variables. - $app = JFactory::getApplication(); - $model = $this->getModel('AnnouncementForm', 'SubusersModel'); - - // Get the user data. - $data = JFactory::getApplication()->input->get('jform', array(), 'array'); - - // Get the user data. - $data = JFactory::getApplication()->input->get('jform', array(), 'array'); - /* - Validate the posted data. - $form = $model->getForm(); - - if (!$form) - { - throw new Exception($model->getError(), 500); - } - - Validate the posted data. - $data = $model->validate($form, $data); - - Check for errors. - if ($data === false) - { - Get the validation messages. - $errors = $model->getErrors(); - - Push up to three validation messages out to the user. - for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) - { - if ($errors[$i] instanceof Exception) - { - $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); - } - else - { - $app->enqueueMessage($errors[$i], 'warning'); - } - } - - $input = $app->input; - $jform = $input->get('jform', array(), 'ARRAY'); - - Save the data in the session. - $app->setUserState('com_subusers.edit.announcement.data', $jform); - - Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.announcement.id'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=announcementform&layout=edit&id=' . $id, false)); - }*/ - - // Attempt to save the data. - $return = $model->save($data); - - // Check for errors. - if ($return === false) - { - // Save the data in the session. - $app->setUserState('com_subusers.edit.announcement.data', $data); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.announcement.id'); - $this->setMessage(JText::sprintf('Save failed', $model->getError()), 'warning'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=announcementform&layout=edit&id=' . $id, false)); - } - - // Check in the profile. - if ($return) - { - $model->checkin($return); - } - - // Clear the profile id from the session. - $app->setUserState('com_subusers.edit.announcement.id', null); - - // Redirect to the list screen. - $this->setMessage(JText::_('COM_SUBUSERS_ITEM_SAVED_SUCCESSFULLY')); - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - $url = (empty($item->link) ? 'index.php?option=com_subusers&view=organization' . '/' . $data['orgid'] : $item->link); - $this->setRedirect(JRoute::_($url, false)); - - // Flush the data from the session. - $app->setUserState('com_subusers.edit.announcement.data', null); - } - - /** - * Method to abort current operation - * - * @return void - * - * @throws Exception - */ - public function cancel() - { - $app = JFactory::getApplication(); - $id = $app->input->get('orgid'); - - // Get the current edit id. - $editId = (int) $app->getUserState('com_subusers.edit.organization.id'); - - // Get the model. - $model = $this->getModel('AnnouncementForm', 'SubusersModel'); - - // Check in the item - if ($editId) - { - $model->checkin($editId); - } - - $url = 'index.php?option=com_subusers&view=organization' . '/' . $id; - $this->setRedirect(JRoute::_($url, false)); - } - - /** - * Method to remove data - * - * @return void - * - * @throws Exception - */ - public function remove() - { - // Initialise variables. - $app = JFactory::getApplication(); - $model = $this->getModel('AnnouncementForm', 'SubusersModel'); - - // Get the user data. - $data = array(); - $data['id'] = $app->input->getInt('id'); - - // Check for errors. - if (empty($data['id'])) - { - // Get the validation messages. - $errors = $model->getErrors(); - - // Push up to three validation messages out to the user. - for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) - { - if ($errors[$i] instanceof Exception) - { - $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); - } - else - { - $app->enqueueMessage($errors[$i], 'warning'); - } - } - - // Save the data in the session. - $app->setUserState('com_subusers.edit.organization.data', $data); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.organization.id'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=announcement&layout=edit&id=' . $id, false)); - } - - // Attempt to save the data. - $return = $model->delete($data); - - // Check for errors. - if ($return === false) - { - // Save the data in the session. - $app->setUserState('com_subusers.edit.organization.data', $data); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.organization.id'); - $this->setMessage(JText::sprintf('Delete failed', $model->getError()), 'warning'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=announcement&layout=edit&id=' . $id, false)); - } - - // Check in the profile. - if ($return) - { - $model->checkin($return); - } - - // Clear the profile id from the session. - $app->setUserState('com_subusers.edit.organization.id', null); - - // Redirect to the list screen. - $this->setMessage(JText::_('COM_SUBUSERS_ITEM_DELETED_SUCCESSFULLY')); - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - $url = (empty($item->link) ? 'index.php?option=com_subusers&view=organizations&layout=pin' : $item->link); - $this->setRedirect(JRoute::_($url, false)); - - // Flush the data from the session. - $app->setUserState('com_subusers.edit.organization.data', null); - } -} diff --git a/src/site/controllers/announcements.php b/src/site/controllers/announcements.php deleted file mode 100755 index 81249cb..0000000 --- a/src/site/controllers/announcements.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access. -defined('_JEXEC') or die; - -require_once JPATH_COMPONENT . '/controller.php'; - -/** - * Organizations list controller class. - * - * @since 1.6 - */ -class SubusersControllerAnnouncements extends SubusersController -{ - /** - * Proxy for getModel. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional - * @param array $config Configuration array for model. Optional - * - * @return object The model - * - * @since 1.6 - */ - public function &getModel($name = 'Announcements', $prefix = 'SubusersModel', $config = array()) - { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; - } -} diff --git a/src/site/controllers/organization.php b/src/site/controllers/organization.php deleted file mode 100755 index 59f9a77..0000000 --- a/src/site/controllers/organization.php +++ /dev/null @@ -1,207 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -require_once JPATH_COMPONENT . '/controller.php'; - -/** - * Organization controller class. - * - * @since 1.6 - */ -class SubusersControllerOrganization extends SubusersController -{ - /** - * Method to check out an item for editing and redirect to the edit form. - * - * @return void - * - * @since 1.6 - */ - public function edit() - { - $app = JFactory::getApplication(); - - // Get the previous edit id (if any) and the current edit id. - $previousId = (int) $app->getUserState('com_subusers.edit.organization.id'); - $editId = $app->input->getInt('id', 0); - - // Set the user id for the user to edit in the session. - $app->setUserState('com_subusers.edit.organization.id', $editId); - - // Get the model. - $model = $this->getModel('Organization', 'SubusersModel'); - - // Check out the item - if ($editId) - { - $model->checkout($editId); - } - - // Check in the previous user. - if ($previousId && $previousId !== $editId) - { - $model->checkin($previousId); - } - - // Redirect to the edit screen. - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organizationform&layout=edit', false)); - } - - /** - * Method to save a user's profile data. - * - * @return void - * - * @throws Exception - * @since 1.6 - */ - public function publish() - { - // Initialise variables. - $app = JFactory::getApplication(); - - // Checking if the user can remove object - $user = JFactory::getUser(); - - if ($user->authorise('core.edit', 'com_subusers') || $user->authorise('core.edit.state', 'com_subusers')) - { - $model = $this->getModel('Organization', 'SubusersModel'); - - // Get the user data. - $id = $app->input->getInt('id'); - $state = $app->input->getInt('state'); - - // Attempt to save the data. - $return = $model->publish($id, $state); - - // Check for errors. - if ($return === false) - { - $this->setMessage(JText::sprintf('Save failed: %s', $model->getError()), 'warning'); - } - - // Clear the profile id from the session. - $app->setUserState('com_subusers.edit.organization.id', null); - - // Flush the data from the session. - $app->setUserState('com_subusers.edit.organization.data', null); - - // Redirect to the list screen. - $this->setMessage(JText::_('COM_SUBUSERS_ITEM_SAVED_SUCCESSFULLY')); - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - - if (!$item) - { - // If there isn't any menu item active, redirect to list view - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organizations', false)); - } - else - { - $this->setRedirect(JRoute::_($item->link . $menuitemid, false)); - } - } - else - { - throw new Exception(500); - } - } - - /** - * Remove data - * - * @return void - * - * @throws Exception - */ - public function remove() - { - // Initialise variables. - $app = JFactory::getApplication(); - - // Checking if the user can remove object - $user = JFactory::getUser(); - - if ($user->authorise('core.delete', 'com_subusers')) - { - $model = $this->getModel('Organization', 'SubusersModel'); - - // Get the user data. - $id = $app->input->getInt('id', 0); - - // Attempt to save the data. - $return = $model->delete($id); - - // Check for errors. - if ($return === false) - { - $this->setMessage(JText::sprintf('Delete failed', $model->getError()), 'warning'); - } - else - { - // Check in the profile. - if ($return) - { - $model->checkin($return); - } - - // Clear the profile id from the session. - $app->setUserState('com_subusers.edit.organization.id', null); - - // Flush the data from the session. - $app->setUserState('com_subusers.edit.organization.data', null); - - $this->setMessage(JText::_('COM_SUBUSERS_ITEM_DELETED_SUCCESSFULLY')); - } - - // Redirect to the list screen. - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - $this->setRedirect(JRoute::_($item->link, false)); - } - else - { - throw new Exception(500); - } - } - - /** - * Apply for membership - * - * @return void - * - * @throws Exception - */ - public function applymembership() - { - $input = JFactory::getApplication()->input; - $post = $input->post; - $orgid = $post->get('orgid', '', 'INT'); - - if ($orgid) - { - $oluser_id = JFactory::getUser()->id; - $model = $this->getModel('organization'); - $check = $model->applymembership($orgid, $oluser_id); - - if ($check) - { - $msg = JText::_('COM_SUBUSERS_APPLY_SUCCESSFULY'); - } - else - { - $msg = JText::_('COM_SUBUSERS_APPLY_FAILED'); - } - - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organization&layout=details&id=' . $orgid, false), $msg); - } - } -} diff --git a/src/site/controllers/organizationform.php b/src/site/controllers/organizationform.php deleted file mode 100755 index 78422c6..0000000 --- a/src/site/controllers/organizationform.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -require_once JPATH_COMPONENT . '/controller.php'; - -/** - * Organization controller class. - * - * @since 1.6 - */ -class SubusersControllerOrganizationForm extends SubusersController -{ - /** - * Method to check out an item for editing and redirect to the edit form. - * - * @return void - * - * @since 1.6 - */ - public function edit() - { - $app = JFactory::getApplication(); - - // Get the previous edit id (if any) and the current edit id. - $previousId = (int) $app->getUserState('com_subusers.edit.organization.id'); - $editId = $app->input->getInt('id', 0); - - // Set the user id for the user to edit in the session. - $app->setUserState('com_subusers.edit.organization.id', $editId); - - // Get the model. - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - // Check out the item - if ($editId) - { - $model->checkout($editId); - } - - // Check in the previous user. - if ($previousId) - { - $model->checkin($previousId); - } - - // Redirect to the edit screen. - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organizationform&layout=edit', false)); - } - - /** - * Method to save a user's profile data. - * - * @return void - * - * @throws Exception - * @since 1.6 - */ - public function save() - { - // Check for request forgeries. - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Initialise variables. - $app = JFactory::getApplication(); - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - // Get the user data. - $data = JFactory::getApplication()->input->get('jform', array(), 'array'); - - // Validate the posted data. - $form = $model->getForm(); - - if (!$form) - { - throw new Exception($model->getError(), 500); - } - - // Validate the posted data. - $data = $model->validate($form, $data); - - // Check for errors. - if ($data === false) - { - // Get the validation messages. - $errors = $model->getErrors(); - - // Push up to three validation messages out to the user. - for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) - { - if ($errors[$i] instanceof Exception) - { - $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); - } - else - { - $app->enqueueMessage($errors[$i], 'warning'); - } - } - - $input = $app->input; - $jform = $input->get('jform', array(), 'ARRAY'); - - // Save the data in the session. - $app->setUserState('com_subusers.edit.organization.data', $jform); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.organization.id'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organizationform&layout=edit&id=' . $id, false)); - } - - // Attempt to save the data. - $return = $model->save($data); - - // Check for errors. - if ($return === false) - { - // Save the data in the session. - $app->setUserState('com_subusers.edit.organization.data', $data); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.organization.id'); - $this->setMessage(JText::sprintf('Save failed', $model->getError()), 'warning'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organizationform&layout=edit&id=' . $id, false)); - } - - // Check in the profile. - if ($return) - { - $model->checkin($return); - } - - // Clear the profile id from the session. - $app->setUserState('com_subusers.edit.organization.id', null); - - // Redirect to the list screen. - $this->setMessage(JText::_('COM_SUBUSERS_ITEM_SAVED_SUCCESSFULLY')); - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - $url = (empty($item->link) ? 'index.php?option=com_subusers&view=organizations' : $item->link); - $this->setRedirect(JRoute::_($url, false)); - - // Flush the data from the session. - $app->setUserState('com_subusers.edit.organization.data', null); - } - - /** - * Method to abort current operation - * - * @return void - * - * @throws Exception - */ - public function cancel() - { - $app = JFactory::getApplication(); - - // Get the current edit id. - $editId = (int) $app->getUserState('com_subusers.edit.organization.id'); - - // Get the model. - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - // Check in the item - if ($editId) - { - $model->checkin($editId); - } - - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - $url = (empty($item->link) ? 'index.php?option=com_subusers&view=organizations' : $item->link); - $this->setRedirect(JRoute::_($url, false)); - } - - /** - * Method to remove data - * - * @return void - * - * @throws Exception - */ - public function remove() - { - // Initialise variables. - $app = JFactory::getApplication(); - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - // Get the user data. - $data = array(); - $data['id'] = $app->input->getInt('id'); - - // Check for errors. - if (empty($data['id'])) - { - // Get the validation messages. - $errors = $model->getErrors(); - - // Push up to three validation messages out to the user. - for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) - { - if ($errors[$i] instanceof Exception) - { - $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); - } - else - { - $app->enqueueMessage($errors[$i], 'warning'); - } - } - - // Save the data in the session. - $app->setUserState('com_subusers.edit.organization.data', $data); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.organization.id'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organization&layout=edit&id=' . $id, false)); - } - - // Attempt to save the data. - $return = $model->delete($data); - - // Check for errors. - if ($return === false) - { - // Save the data in the session. - $app->setUserState('com_subusers.edit.organization.data', $data); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.organization.id'); - $this->setMessage(JText::sprintf('Delete failed', $model->getError()), 'warning'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organization&layout=edit&id=' . $id, false)); - } - - // Check in the profile. - if ($return) - { - $model->checkin($return); - } - - // Clear the profile id from the session. - $app->setUserState('com_subusers.edit.organization.id', null); - - // Redirect to the list screen. - $this->setMessage(JText::_('COM_SUBUSERS_ITEM_DELETED_SUCCESSFULLY')); - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - $url = (empty($item->link) ? 'index.php?option=com_subusers&view=organizations' : $item->link); - $this->setRedirect(JRoute::_($url, false)); - - // Flush the data from the session. - $app->setUserState('com_subusers.edit.organization.data', null); - } - - /** - * Method to check out an org id is already exist or not. - * - * @return void - * - * @since 1.6 - */ - public function validateOrgId() - { - $app = JFactory::getApplication(); - $orgId = $app->input->get('id', '', 'STRING'); - - // Get the model. - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - if ( $model->validateOrgId($orgId)) - { - // If already present - echo "failure"; - exit(); - } - else - { - // New email found - echo "success"; - exit(); - } - - exit; - } - - /** - * Method to check out an orgemail is already exist or not. - * - * @return void - * - * @since 1.6 - */ - public function validateOrgEmail() - { - $app = JFactory::getApplication(); - $orgEmail = $app->input->get('email', '', 'STRING'); - - // Get the model. - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - if ( $model->validateOrgEmail($orgEmail)) - { - // If already present - echo "failure"; - exit(); - } - else - { - // New email found - echo "success"; - exit(); - } - - exit; - } -} diff --git a/src/site/controllers/organizations.php b/src/site/controllers/organizations.php deleted file mode 100755 index 71656d3..0000000 --- a/src/site/controllers/organizations.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access. -defined('_JEXEC') or die; - -require_once JPATH_COMPONENT . '/controller.php'; - -/** - * Organizations list controller class. - * - * @since 1.6 - */ -class SubusersControllerOrganizations extends SubusersController -{ - /** - * Proxy for getModel. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional - * @param array $config Configuration array for model. Optional - * - * @return object The model - * - * @since 1.6 - */ - public function &getModel($name = 'Organizations', $prefix = 'SubusersModel', $config = array()) - { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; - } -} diff --git a/src/site/models/announcementform.php b/src/site/models/announcementform.php deleted file mode 100755 index 81f91ff..0000000 --- a/src/site/models/announcementform.php +++ /dev/null @@ -1,423 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access. -defined('_JEXEC') or die; - -jimport('joomla.application.component.modelform'); -jimport('joomla.event.dispatcher'); - -use Joomla\Utilities\ArrayHelper; -/** - * Subusers model. - * - * @since 1.6 - */ -class SubusersModelAnnouncementForm extends JModelForm -{ - private $item = null; - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @return void - * - * @since 1.6 - */ - protected function populateState() - { - $app = JFactory::getApplication('com_subusers'); - - // Load state from the request userState on edit or from the passed variable on default - if (JFactory::getApplication()->input->get('layout') == 'edit') - { - $id = JFactory::getApplication()->getUserState('com_subusers.edit.organization.id'); - } - else - { - $id = JFactory::getApplication()->input->get('id'); - JFactory::getApplication()->setUserState('com_subusers.edit.organization.id', $id); - } - - $this->setState('organization.id', $id); - - // Load the parameters. - $params = $app->getParams(); - $params_array = $params->toArray(); - - if (isset($params_array['item_id'])) - { - $this->setState('organization.id', $params_array['item_id']); - } - - $this->setState('params', $params); - } - - /** - * Method to get an ojbect. - * - * @param integer $id The id of the object to get. - * - * @return Object|boolean Object on success, false on failure. - * - * @throws Exception - */ - public function &getData($id = null) - { - if ($this->item === null) - { - $this->item = false; - - if (empty($id)) - { - $id = $this->getState('organization.id'); - } - - // Get a level row instance. - $table = $this->getTable(); - - // Attempt to load the row. - if ($table !== false && $table->load($id)) - { - $user = JFactory::getUser(); - $id = $table->id; - $canEdit = $user->authorise('core.edit', 'com_subusers') || $user->authorise('core.create', 'com_subusers'); - - if (!$canEdit && $user->authorise('core.edit.own', 'com_subusers')) - { - $canEdit = $user->id == $table->created_by; - } - - if (!$canEdit) - { - throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 500); - } - - // Check published state. - if ($published = $this->getState('filter.published')) - { - if ($table->state != $published) - { - return $this->item; - } - } - - // Convert the JTable to a clean JObject. - $properties = $table->getProperties(1); - $this->item = ArrayHelper::toObject($properties, 'JObject'); - } - } - - return $this->item; - } - - /** - * Method to get the table - * - * @param string $type Name of the JTable class - * @param string $prefix Optional prefix for the table class name - * @param array $config Optional configuration array for JTable object - * - * @return JTable|boolean JTable if found, boolean false on failure - */ - public function getTable($type = 'Announcement', $prefix = 'SubusersTable', $config = array()) - { - $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_subusers/tables'); - - return JTable::getInstance($type, $prefix, $config); - } - - /** - * Get an item by alias - * - * @param string $alias Alias string - * - * @return int Element id - */ - public function getItemIdByAlias($alias) - { - $table = $this->getTable(); - - $table->load(array('alias' => $alias)); - - return $table->id; - } - - /** - * Get an $org_id by alias - * - * @param string $org_id Alias string - * - * @return org id - */ - - public function getCatId($org_id) - { - // Get a db connection. - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - - // Create a new query object. - $query - ->select('a.category_id') - ->from('`#__es_group_xref` AS a'); - $query->where('a.client_id=' . $org_id); - $db->setQuery($query); - $cat_id = $db->loadResult(); - - return $cat_id; - } - - /** - * Method to check in an item. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkin($id = null) - { - // Get the id. - $id = (!empty($id)) ? $id : (int) $this->getState('organization.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Attempt to check the row in. - if (method_exists($table, 'checkin')) - { - if (!$table->checkin($id)) - { - return false; - } - } - } - - return true; - } - - /** - * Method to check out an item for editing. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkout($id = null) - { - // Get the user id. - $id = (!empty($id)) ? $id : (int) $this->getState('organization.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Get the current user object. - $user = JFactory::getUser(); - - // Attempt to check the row out. - if (method_exists($table, 'checkout')) - { - if (!$table->checkout($user->get('id'), $id)) - { - return false; - } - } - } - - return true; - } - - /** - * Method to get the profile form. - * - * The base form is loaded from XML - * - * @param array $data An optional array of data for the form to interogate. - * @param boolean $loadData True if the form is to load its own data (default case), false if not. - * - * @return JForm A JForm object on success, false on failure - * - * @since 1.6 - */ - public function getForm($data = array(), $loadData = true) - { - // Get the form. - $form = $this->loadForm('com_subusers.organization', 'announcementform', array( - 'control' => 'jform', - 'load_data' => $loadData - ) - ); - - if (empty($form)) - { - return false; - } - - return $form; - } - - /** - * Method to get the data that should be injected in the form. - * - * @return mixed The data for the form. - * - * @since 1.6 - */ - protected function loadFormData() - { - $data = JFactory::getApplication()->getUserState('com_subusers.edit.organization.data', array()); - - if (empty($data)) - { - $data = $this->getData(); - } - - return $data; - } - - /** - * Method to save the form data. - * - * @param array $data The form data - * - * @return bool - * - * @throws Exception - * @since 1.6 - */ - public function save($data) - { - $user = JFactory::getUser(); - $id = ''; - - if ($data['id']) - { - $id = $data['id']; - } - - $org_id = $data['orgid']; - $data['catid'] = $this->getCatId($org_id); - $data['access'] = 1; - $data['state'] = 1; - $data['language'] = '*'; - - // Added to fetch data of organsiation form - $input = JFactory::getApplication()->input; - $formData = new JRegistry($input->get('jform', '', 'array')); - - if ($id) - { - // Check the user can edit this item - $authorised = $user->authorise('core.edit', 'com_subusers') || $authorised = $user->authorise('core.edit.own', 'com_subusers'); - - if ($user->authorise('core.edit.state', 'com_subusers') !== true && $state == 1) - { - // The user cannot edit the state of the item. - $data['state'] = 0; - } - } - else - { - // Check the user can create new items in this section - $authorised = $user->authorise('core.create', 'com_subusers'); - - if ($user->authorise('core.edit.state', 'com_subusers') !== true && $state == 1) - { - // The user cannot edit the state of the item. - $data['state'] = 0; - } - } - - if ($authorised !== true) - { - throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); - } - - // Insert data in content table - $db = JFactory::getDBO(); - $table = JTable::getInstance('Content', 'JTable', array('dbo', $db)); - $table->load(array('id' => $id)); - - if ($id) - { - if ($table->save($data) === true) - { - return true; - } - else - { - return false; - } - } - else - { - $data['id'] = ''; - - if ($table->save($data) === true) - { - } - else - { - return false; - } - } - } - - /** - * Method to delete data - * - * @param array $data Data to be deleted - * - * @return bool|int If success returns the id of the deleted item, if not false - * - * @throws Exception - */ - public function delete($data) - { - $id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('organization.id'); - - if (JFactory::getUser()->authorise('core.delete', 'com_subusers') !== true) - { - throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR')); - } - - $table = $this->getTable(); - - if ($table->delete($data['id']) === true) - { - return $id; - } - else - { - return false; - } - } - - /** - * Check if data can be saved - * - * @return bool - */ - public function getCanSave() - { - $table = $this->getTable(); - - return $table !== false; - } -} diff --git a/src/site/models/announcements.php b/src/site/models/announcements.php deleted file mode 100755 index 8c299a0..0000000 --- a/src/site/models/announcements.php +++ /dev/null @@ -1,295 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -defined('_JEXEC') or die; - -jimport('joomla.application.component.modellist'); - -/** - * Methods supporting a list of Subusers records. - * - * @since 1.6 - */ -class SubusersModelAnnouncements extends JModelList -{ - /** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * - * @see JController - * @since 1.6 - */ - public function __construct($config = array()) - { - if (empty($config['filter_fields'])) - { - $config['filter_fields'] = array( - 'id', 'a.id', - 'name', 'a.name', - 'created_by', 'a.created_by', - 'ordering', 'a.ordering', - 'state', 'a.state', - 'email', 'a.email', - 'logo', 'a.logo', - ); - } - - parent::__construct($config); - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @param string $ordering Elements order - * @param string $direction Order direction - * - * @return void - * - * @throws Exception - * - * @since 1.6 - */ - protected function populateState($ordering = null, $direction = null) - { - // Initialise variables. - $app = JFactory::getApplication(); - - // List state information - $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit')); - $this->setState('list.limit', $limit); - - $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0); - $this->setState('list.start', $limitstart); - - if ($list = $app->getUserStateFromRequest($this->context . '.list', 'list', array(), 'array')) - { - foreach ($list as $name => $value) - { - // Extra validations - switch ($name) - { - case 'fullordering': - $orderingParts = explode(' ', $value); - - if (count($orderingParts) >= 2) - { - // Latest part will be considered the direction - $fullDirection = end($orderingParts); - - if (in_array(strtoupper($fullDirection), array('ASC', 'DESC', ''))) - { - $this->setState('list.direction', $fullDirection); - } - - unset($orderingParts[count($orderingParts) - 1]); - - // The rest will be the ordering - $fullOrdering = implode(' ', $orderingParts); - - if (in_array($fullOrdering, $this->filter_fields)) - { - $this->setState('list.ordering', $fullOrdering); - } - } - else - { - $this->setState('list.ordering', $ordering); - $this->setState('list.direction', $direction); - } - break; - - case 'ordering': - if (!in_array($value, $this->filter_fields)) - { - $value = $ordering; - } - break; - - case 'direction': - if (!in_array(strtoupper($value), array('ASC', 'DESC', ''))) - { - $value = $direction; - } - break; - - case 'limit': - $limit = $value; - break; - - // Just to keep the default case - default: - $value = $value; - break; - } - - $this->setState('list.' . $name, $value); - } - } - - // Receive & set filters - if ($filters = $app->getUserStateFromRequest($this->context . '.filter', 'filter', array(), 'array')) - { - foreach ($filters as $name => $value) - { - $this->setState('filter.' . $name, $value); - } - } - - $ordering = $app->input->get('filter_order'); - - if (!empty($ordering)) - { - $list = $app->getUserState($this->context . '.list'); - $list['ordering'] = $app->input->get('filter_order'); - $app->setUserState($this->context . '.list', $list); - } - - $orderingDirection = $app->input->get('filter_order_Dir'); - - if (!empty($orderingDirection)) - { - $list = $app->getUserState($this->context . '.list'); - $list['direction'] = $app->input->get('filter_order_Dir'); - $app->setUserState($this->context . '.list', $list); - } - - $list = $app->getUserState($this->context . '.list'); - - if (empty($list['ordering'])) - { - $list['ordering'] = 'ordering'; - } - - if (empty($list['direction'])) - { - $list['direction'] = 'asc'; - } - - if (isset($list['ordering'])) - { - $this->setState('list.ordering', $list['ordering']); - } - - if (isset($list['direction'])) - { - $this->setState('list.direction', $list['direction']); - } - } - - /** - * Build an SQL query to load the list data for organisation - * - * @return JDatabaseQuery - * - * @since 1.6 - */ - protected function getListQuery() - { - // Create a new query object. - $db = $this->getDbo(); - $query = $db->getQuery(true); - - // Select the required fields from the table. - $query - ->select($this->getState( - 'list.select', 'DISTINCT a.*') - ); - $query->from('`#__content` AS a'); - - // Join over the users for the checked out user. - $query->join('INNER', '#__es_group_xref AS b ON (a.catid = b.category_id)'); - $query->where('a.state = 1'); - - // Filter by search in announcement name - $mainframe = JFactory::getApplication(); - $search = $mainframe->getUserStateFromRequest('.filter.search', 'filter_announcement_search'); - - if (!empty($search)) - { - if (stripos($search, 'id:') === 0) - { - $query->where('a.id = ' . (int) substr($search, 3)); - } - else - { - $search = $db->Quote('%' . $db->escape($search, true) . '%'); - $query->where('( a.title LIKE ' . $search . ' OR a.created_by LIKE ' . $search . ' )'); - } - } - - // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering'); - $orderDirn = $this->state->get('list.direction'); - - if ($orderCol && $orderDirn) - { - $query->order($db->escape($orderCol . ' ' . $orderDirn)); - } - - return $query; - } - - /** - * Method to get an array of data items - * - * @return mixed An array of data on success, false on failure. - */ - public function getItems() - { - $items = parent::getItems(); - - return $items; - } - - /** - * Overrides the default function to check Date fields format, identified by - * "_dateformat" suffix, and erases the field if it's not correct. - * - * @return void - */ - protected function loadFormData() - { - $app = JFactory::getApplication(); - $filters = $app->getUserState($this->context . '.filter', array()); - $error_dateformat = false; - - foreach ($filters as $key => $value) - { - if (strpos($key, '_dateformat') && !empty($value) && $this->isValidDate($value) == null) - { - $filters[$key] = ''; - $error_dateformat = true; - } - } - - if ($error_dateformat) - { - $app->enqueueMessage(JText::_("COM_SUBUSERS_SEARCH_FILTER_DATE_FORMAT"), "warning"); - $app->setUserState($this->context . '.filter', $filters); - } - - return parent::loadFormData(); - } - - /** - * Checks if a given date is valid and in a specified format (YYYY-MM-DD) - * - * @param string $date Date to be checked - * - * @return bool - */ - private function isValidDate($date) - { - $date = str_replace('/', '-', $date); - - return (date_create($date)) ? JFactory::getDate($date)->format("Y-m-d") : null; - } -} diff --git a/src/site/models/forms/announcementform.xml b/src/site/models/forms/announcementform.xml deleted file mode 100755 index 81f2213..0000000 --- a/src/site/models/forms/announcementform.xml +++ /dev/null @@ -1,23 +0,0 @@ - -
-
- - - - - - - - -
- -
diff --git a/src/site/models/forms/filter_organizations.xml b/src/site/models/forms/filter_organizations.xml deleted file mode 100755 index 995dfa5..0000000 --- a/src/site/models/forms/filter_organizations.xml +++ /dev/null @@ -1,11 +0,0 @@ - -
- - - - - - -
\ No newline at end of file diff --git a/src/site/models/forms/organizationform.xml b/src/site/models/forms/organizationform.xml deleted file mode 100755 index bfc3092..0000000 --- a/src/site/models/forms/organizationform.xml +++ /dev/null @@ -1,81 +0,0 @@ - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/site/models/organization.php b/src/site/models/organization.php deleted file mode 100755 index dde5d6b..0000000 --- a/src/site/models/organization.php +++ /dev/null @@ -1,396 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access. -defined('_JEXEC') or die; - -require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; -jimport('joomla.application.component.modelitem'); -jimport('joomla.event.dispatcher'); - -use Joomla\Utilities\ArrayHelper; -/** - * Subusers model. - * - * @since 1.6 - */ -class SubusersModelOrganization extends JModelItem -{ - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @return void - * - * @since 1.6 - * - */ - protected function populateState() - { - $app = JFactory::getApplication('com_subusers'); - - // Load state from the request userState on edit or from the passed variable on default - if (JFactory::getApplication()->input->get('layout') == 'edit') - { - $id = JFactory::getApplication()->getUserState('com_subusers.edit.organization.id'); - } - else - { - $id = JFactory::getApplication()->input->get('id'); - JFactory::getApplication()->setUserState('com_subusers.edit.organization.id', $id); - } - - $this->setState('organization.id', $id); - - // Load the parameters. - $params = $app->getParams(); - $params_array = $params->toArray(); - - if (isset($params_array['item_id'])) - { - $this->setState('organization.id', $params_array['item_id']); - } - - $this->setState('params', $params); - } - - /** - * Method to get an object. - * - * @param integer $id The id of the object to get. - * - * @return mixed Object on success, false on failure. - */ - public function &getData($id = null) - { - if ($this->_item === null) - { - $this->_item = false; - - if (empty($id)) - { - $id = $this->getState('organization.id'); - } - - // Get a level row instance. - $table = $this->getTable(); - - // Attempt to load the row. - if ($table->load($id)) - { - // Check published state. - if ($published = $this->getState('filter.published')) - { - if ($table->state != $published) - { - return $this->_item; - } - } - - // Convert the JTable to a clean JObject. - $properties = $table->getProperties(1); - $this->_item = ArrayHelper::toObject($properties, 'JObject'); - } - } - - return $this->_item; - } - - /** - * Get an instance of JTable class - * - * @param string $type Name of the JTable class to get an instance of. - * @param string $prefix Prefix for the table class name. Optional. - * @param array $config Array of configuration values for the JTable object. Optional. - * - * @return JTable|bool JTable if success, false on failure. - */ - public function getTable($type = 'Organization', $prefix = 'SubusersTable', $config = array()) - { - $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_subusers/tables'); - - return JTable::getInstance($type, $prefix, $config); - } - - /** - * Get the id of an item by alias - * - * @param string $alias Item alias - * - * @return mixed - */ - public function getItemIdByAlias($alias) - { - $table = $this->getTable(); - $table->load(array('alias' => $alias)); - - return $table->id; - } - - /** - * Method to check in an item. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkin($id = null) - { - // Get the id. - $id = (!empty($id)) ? $id : (int) $this->getState('organization.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Attempt to check the row in. - if (method_exists($table, 'checkin')) - { - if (!$table->checkin($id)) - { - return false; - } - } - } - - return true; - } - - /** - * Method to check out an item for editing. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkout($id = null) - { - // Get the user id. - $id = (!empty($id)) ? $id : (int) $this->getState('organization.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Get the current user object. - $user = JFactory::getUser(); - - // Attempt to check the row out. - if (method_exists($table, 'checkout')) - { - if (!$table->checkout($user->get('id'), $id)) - { - return false; - } - } - } - - return true; - } - - /** - * Get the name of a category by id - * - * @param int $id Category id - * - * @return Object|null Object if success, null in case of failure - */ - public function getCategoryName($id) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query - ->select('title') - ->from('#__categories') - ->where('id = ' . $id); - $db->setQuery($query); - - return $db->loadObject(); - } - - /** - * Publish the element - * - * @param int $id Item id - * @param int $state Publish state - * - * @return boolean - */ - public function publish($id, $state) - { - $table = $this->getTable(); - $table->load($id); - $table->state = $state; - - return $table->store(); - } - - /** - * Method to delete an item - * - * @param int $id Element id - * - * @return bool - */ - public function delete($id) - { - $table = $this->getTable(); - - return $table->delete($id); - } - - /** - * Check member - * - * @param int $user_id Element id - * - * @return check - */ - public function checkmember($user_id,$orgid) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select('id') - ->from('#__tjsu_users') - ->where('user_id = ' . $user_id) - ->where('client_id = ' . $orgid); - $db->setQuery($query); - $result = $db->loadResult(); - - return $result; - } - - /** - * check state - * - * @param int $user_id Element id - * - * @return bool - */ - public function checkmemberstate($user_id,$orgid) - { - $table = $this->getTable('user'); - $table->load(array('user_id' => $user_id,'client_id' => $orgid)); - $result = $table->state; - - return $result; - } - - /** - * check state - * - * @param int $orgid Element id - * - * @param int $oluser_id Element id - * - * @return bool - */ - public function applymembership($orgid,$oluser_id) - { - $table = $this->getTable('user'); - $table->load(array('user_id' => $oluser_id)); - $tjsuid = $table->id; - $tjsuid = 0; - - if (!$tjsuid) - { - /*$table->client_id = $orgid; - return $table->store(); - Create the array of new fields.*/ - - $from = array('id' => '', - 'user_id' => $oluser_id, - 'client' => 'com_subusers.organisation', - 'client_id' => $orgid, - 'role_id' => '2', - 'state' => '0' - ); - - // Bind the array to the table object. - $table->bind($from); - - $grpid = $this->getGrpId($orgid); - $group = FD::group($grpid); - - // Get the user's access as we want to limit the number of groups they can join - $user = FD::user($oluser_id); - $access = $user->getAccess(); - $total = $user->getTotalGroups(); - - if ($access->exceeded('groups.join', $total)) - { - $obj->success = 0; - $obj->message = 'group joining limit exceeded'; - - return $obj; - } - - if (!$group->isMember($oluser_id)) - { - // Create a member record for the group - $members = $group->createMember($oluser_id); - } - - return $table->store(); - - return true; - } - - return false; - } - - /** - * Get $orgid - * - * @param int $orgid Org id - * - * @return org id - */ - - public function getGrpId($orgid) - { - // Get a db connection. - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - - // Create a new query object. - $query - ->select('a.grp_id') - ->from('`#__es_group_xref` AS a'); - $query->where('a.client_id=' . $orgid); - $db->setQuery($query); - $grp_id = $db->loadResult(); - - return $grp_id; - } - - /** - * Get $orgid - * - * @param int $orgid Org id - * - * @param int $oluser_id oluser id - * - * @return org id - */ - - public function checkIfOrgAdmin($orgid,$oluser_id) - { - $table = $this->getTable('user'); - $table->load(array('user_id' => $oluser_id,'client_id' => $orgid)); - - return $table->role_id; - } -} diff --git a/src/site/models/organizationform.php b/src/site/models/organizationform.php deleted file mode 100755 index 10d24ba..0000000 --- a/src/site/models/organizationform.php +++ /dev/null @@ -1,584 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access. -defined('_JEXEC') or die; - -jimport('joomla.application.component.modelform'); -jimport('joomla.event.dispatcher'); - -use Joomla\Utilities\ArrayHelper; -/** - * Subusers model. - * - * @since 1.6 - */ -class SubusersModelOrganizationForm extends JModelForm -{ - private $item = null; - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @return void - * - * @since 1.6 - */ - protected function populateState() - { - $app = JFactory::getApplication('com_subusers'); - - // Load state from the request userState on edit or from the passed variable on default - if (JFactory::getApplication()->input->get('layout') == 'edit') - { - $id = JFactory::getApplication()->getUserState('com_subusers.edit.organization.id'); - } - else - { - $id = JFactory::getApplication()->input->get('id'); - JFactory::getApplication()->setUserState('com_subusers.edit.organization.id', $id); - } - - $this->setState('organization.id', $id); - - // Load the parameters. - $params = $app->getParams(); - $params_array = $params->toArray(); - - if (isset($params_array['item_id'])) - { - $this->setState('organization.id', $params_array['item_id']); - } - - $this->setState('params', $params); - } - - /** - * Method to get an ojbect. - * - * @param integer $id The id of the object to get. - * - * @return Object|boolean Object on success, false on failure. - * - * @throws Exception - */ - public function &getData($id = null) - { - if ($this->item === null) - { - $this->item = false; - - if (empty($id)) - { - $id = $this->getState('organization.id'); - } - - // Get a level row instance. - $table = $this->getTable(); - - // Attempt to load the row. - if ($table !== false && $table->load($id)) - { - $user = JFactory::getUser(); - $id = $table->id; - $canEdit = $user->authorise('core.edit', 'com_subusers') || $user->authorise('core.create', 'com_subusers'); - - if (!$canEdit && $user->authorise('core.edit.own', 'com_subusers')) - { - $canEdit = $user->id == $table->created_by; - } - - if (!$canEdit) - { - throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 500); - } - - // Check published state. - if ($published = $this->getState('filter.published')) - { - if ($table->state != $published) - { - return $this->item; - } - } - - // Convert the JTable to a clean JObject. - $properties = $table->getProperties(1); - $this->item = ArrayHelper::toObject($properties, 'JObject'); - } - } - - return $this->item; - } - - /** - * Method to get the table - * - * @param string $type Name of the JTable class - * @param string $prefix Optional prefix for the table class name - * @param array $config Optional configuration array for JTable object - * - * @return JTable|boolean JTable if found, boolean false on failure - */ - public function getTable($type = 'Organization', $prefix = 'SubusersTable', $config = array()) - { - $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_subusers/tables'); - - return JTable::getInstance($type, $prefix, $config); - } - - /** - * Get an item by alias - * - * @param string $alias Alias string - * - * @return int Element id - */ - public function getItemIdByAlias($alias) - { - $table = $this->getTable(); - - $table->load(array('alias' => $alias)); - - return $table->id; - } - - /** - * Method to check in an item. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkin($id = null) - { - // Get the id. - $id = (!empty($id)) ? $id : (int) $this->getState('organization.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Attempt to check the row in. - if (method_exists($table, 'checkin')) - { - if (!$table->checkin($id)) - { - return false; - } - } - } - - return true; - } - - /** - * Method to check out an item for editing. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkout($id = null) - { - // Get the user id. - $id = (!empty($id)) ? $id : (int) $this->getState('organization.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Get the current user object. - $user = JFactory::getUser(); - - // Attempt to check the row out. - if (method_exists($table, 'checkout')) - { - if (!$table->checkout($user->get('id'), $id)) - { - return false; - } - } - } - - return true; - } - - /** - * Method to get the profile form. - * - * The base form is loaded from XML - * - * @param array $data An optional array of data for the form to interogate. - * @param boolean $loadData True if the form is to load its own data (default case), false if not. - * - * @return JForm A JForm object on success, false on failure - * - * @since 1.6 - */ - public function getForm($data = array(), $loadData = true) - { - // Get the form. - $form = $this->loadForm('com_subusers.organization', 'organizationform', array( - 'control' => 'jform', - 'load_data' => $loadData - ) - ); - - if (empty($form)) - { - return false; - } - - return $form; - } - - /** - * Method to get the data that should be injected in the form. - * - * @return mixed The data for the form. - * - * @since 1.6 - */ - protected function loadFormData() - { - $data = JFactory::getApplication()->getUserState('com_subusers.edit.organization.data', array()); - - if (empty($data)) - { - $data = $this->getData(); - } - - return $data; - } - - /** - * Method to save the form data. - * - * @param array $data The form data - * - * @return bool - * - * @throws Exception - * @since 1.6 - */ - public function save($data) - { - $id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('organization.id'); - $state = (!empty($data['state'])) ? 1 : 0; - $user = JFactory::getUser(); - - // Added to fetch data of organsiation form - $input = JFactory::getApplication()->input; - $formData = new JRegistry($input->get('jform', '', 'array')); - - if ($id) - { - // Check the user can edit this item - $authorised = $user->authorise('core.edit', 'com_subusers') || $authorised = $user->authorise('core.edit.own', 'com_subusers'); - - if ($user->authorise('core.edit.state', 'com_subusers') !== true && $state == 1) - { - // The user cannot edit the state of the item. - $data['state'] = 0; - } - } - else - { - // Check the user can create new items in this section - $authorised = $user->authorise('core.create', 'com_subusers'); - - if ($user->authorise('core.edit.state', 'com_subusers') !== true && $state == 1) - { - // The user cannot edit the state of the item. - $data['state'] = 0; - } - } - - if ($authorised !== true) - { - throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); - } - - // Insert daat in organisation table - $table = $this->getTable(); - - if ($id) - { - if ($table->save($data) === true) - { - return true; - } - else - { - return false; - } - } - else - { - if ($table->save($data) === true) - { - if ($table->id) - { - $userdata = new stdClass; - $userdata->user_id = $formData->get('userid', 0); - $userdata->client = 'com_subusers.organisation'; - $userdata->client_id = $table->id; - $userdata->role_id = 1; - $userdata->created_by = $user->id; - $userdata->ordering = '2'; - $userdata->state = '1'; - - $result = JFactory::getDBO()->insertObject('#__tjsu_users', $userdata); - - $params = JComponentHelper::getParams('com_subusers'); - $maincatid = $params->get('announementcategory', ''); - - // Set the extension. For content categories, use 'com_content' - $extension = 'com_content'; - - // Set the title for the category - $title = $formData->get('name'); - - // Type the description, this is also the 'body'. HTML allowed here. - $desc = ''; - - // Set the parent category. 1 is the root item. - $parent_id = $maincatid; - - // JTableCategory is autoloaded in J! 3.0, so... - if (version_compare(JVERSION, '3.0', 'lt')) - { - JTable::addIncludePath(JPATH_PLATFORM . 'joomla/database/table'); - } - - // Initialize a new category - $category = JTable::getInstance('Category'); - $category->extension = $extension; - $category->title = $title; - $category->description = $desc; - $category->published = 1; - $category->access = 1; - $category->params = '{"target":"","image":""}'; - $category->metadata = '{"page_title":"","author":"","robots":""}'; - $category->language = '*'; - - // Set the location in the tree - $category->setLocation($parent_id, 'last-child'); - - // Check to make sure our data is valid - if (!$category->check()) - { - JError::raiseNotice(500, $category->getError()); - - return false; - } - - // Now store the category - if (!$category->store(true)) - { - JError::raiseNotice(500, $category->getError()); - - return false; - } - - // Build the path for our category - $category->rebuildPath($category->id); - - // Check if data is inserted correctly in tjsu_users table - if ($result) - { - // Creat easysocial group - jimport('techjoomla.jsocial.jsocial'); - jimport('techjoomla.jsocial.easysocial'); - - $esdata = array(); - $esdata['title'] = $formData->get('name', 'string'); - $esdata['description'] = $formData->get('description', 'string'); - $esdata['uid'] = $formData->get('userid', 0); - - /* Easysocial group type - - 1. Open Group - 2. Closed Group - 3. Invite only groupInvite only */ - $esdata['type'] = '3'; - - $catid = array(); - $params = JComponentHelper::getParams('com_subusers'); - $catid['catId'] = $params->get('escategory', ''); - - // Create object - $jsSocialEasysocialObj = new JSocialEasysocial; - $groupid = $jsSocialEasysocialObj->createGroup($esdata, $catid); - - // @TODO with easy social - $member = $formData->get('userid', 0); - - if ($member) - { - $memberdata = new stdClass; - $memberdata->cluster_id = $groupid; - $memberdata->uid = $member; - $memberdata->type = 'user'; - $memberdata->created = 'user'; - $memberdata->state = '1'; - $memberdata->owner = '1'; - $memberdata->admin = '1'; - $memberdata->invited_by = '0'; - $memberdata->admin = '1'; - $memberdata->reminder_sent = $category->id; - - // Insert data in easysocial cluster table table - $grpMember = JFactory::getDBO()->insertObject('#__social_clusters_nodes', $memberdata); - } - - // Check if data is inserted correctly in tjsu_users table - if ($groupid) - { - $groupdata = new stdClass; - $groupdata->grp_id = $groupid; - $groupdata->client_id = $table->id; - $groupdata->category_id = $category->id; - - // Insert data in easysocial xref table - $grpid = JFactory::getDBO()->insertObject('#__es_group_xref', $groupdata); - - if ($grpid) - { - return true; - } - else - { - return false; - } - } - else - { - return false; - } - } - else - { - return false; - } - } - else - { - return false; - } - } - else - { - return false; - } - } - } - - /** - * Method to delete data - * - * @param array $data Data to be deleted - * - * @return bool|int If success returns the id of the deleted item, if not false - * - * @throws Exception - */ - public function delete($data) - { - $id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('organization.id'); - - if (JFactory::getUser()->authorise('core.delete', 'com_subusers') !== true) - { - throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR')); - } - - $table = $this->getTable(); - - if ($table->delete($data['id']) === true) - { - return $id; - } - else - { - return false; - } - } - - /** - * Check if data can be saved - * - * @return bool - */ - public function getCanSave() - { - $table = $this->getTable(); - - return $table !== false; - } - - /** - * To check if entered org id is already exists or not - * - * @param string $orgId orgId - * - * @return boolean - * - * @since 1.6 - */ - public function validateOrgId($orgId) - { - $query = "SELECT id FROM #__tjsu_organizations WHERE id = '" . $orgId . "'"; - $this->_db->setQuery($query); - $orgIdExists = $this->_db->loadResult(); - $nameid = ""; - - if ($orgIdExists) - { - return true; - } - else - { - return false; - } - } - - /** - * To check if entered is orgemail - * - * @param string $orgEmail Eamilid - * - * @return boolean - * - * @since 1.6 - */ - public function validateOrgEmail($orgEmail) - { - $query = "SELECT id FROM #__tjsu_organizations WHERE email = '" . $orgEmail . "'"; - $this->_db->setQuery($query); - $emailExists = $this->_db->loadResult(); - $nameid = ""; - - if ($emailExists) - { - return true; - } - else - { - return false; - } - } -} diff --git a/src/site/models/organizations.php b/src/site/models/organizations.php deleted file mode 100755 index 367c1a8..0000000 --- a/src/site/models/organizations.php +++ /dev/null @@ -1,302 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -defined('_JEXEC') or die; - -jimport('joomla.application.component.modellist'); - -/** - * Methods supporting a list of Subusers records. - * - * @since 1.6 - */ -class SubusersModelOrganizations extends JModelList -{ - /** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * - * @see JController - * @since 1.6 - */ - public function __construct($config = array()) - { - if (empty($config['filter_fields'])) - { - $config['filter_fields'] = array( - 'id', 'a.id', - 'name', 'a.name', - 'created_by', 'a.created_by', - 'ordering', 'a.ordering', - 'state', 'a.state', - 'email', 'a.email', - 'logo', 'a.logo', - ); - } - - parent::__construct($config); - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @param string $ordering Elements order - * @param string $direction Order direction - * - * @return void - * - * @throws Exception - * - * @since 1.6 - */ - protected function populateState($ordering = null, $direction = null) - { - // Initialise variables. - $app = JFactory::getApplication(); - - // List state information - $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit')); - $this->setState('list.limit', $limit); - - $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0); - $this->setState('list.start', $limitstart); - - if ($list = $app->getUserStateFromRequest($this->context . '.list', 'list', array(), 'array')) - { - foreach ($list as $name => $value) - { - // Extra validations - switch ($name) - { - case 'fullordering': - $orderingParts = explode(' ', $value); - - if (count($orderingParts) >= 2) - { - // Latest part will be considered the direction - $fullDirection = end($orderingParts); - - if (in_array(strtoupper($fullDirection), array('ASC', 'DESC', ''))) - { - $this->setState('list.direction', $fullDirection); - } - - unset($orderingParts[count($orderingParts) - 1]); - - // The rest will be the ordering - $fullOrdering = implode(' ', $orderingParts); - - if (in_array($fullOrdering, $this->filter_fields)) - { - $this->setState('list.ordering', $fullOrdering); - } - } - else - { - $this->setState('list.ordering', $ordering); - $this->setState('list.direction', $direction); - } - break; - - case 'ordering': - if (!in_array($value, $this->filter_fields)) - { - $value = $ordering; - } - break; - - case 'direction': - if (!in_array(strtoupper($value), array('ASC', 'DESC', ''))) - { - $value = $direction; - } - break; - - case 'limit': - $limit = $value; - break; - - // Just to keep the default case - default: - $value = $value; - break; - } - - $this->setState('list.' . $name, $value); - } - } - - // Receive & set filters - if ($filters = $app->getUserStateFromRequest($this->context . '.filter', 'filter', array(), 'array')) - { - foreach ($filters as $name => $value) - { - $this->setState('filter.' . $name, $value); - } - } - - $ordering = $app->input->get('filter_order'); - - if (!empty($ordering)) - { - $list = $app->getUserState($this->context . '.list'); - $list['ordering'] = $app->input->get('filter_order'); - $app->setUserState($this->context . '.list', $list); - } - - $orderingDirection = $app->input->get('filter_order_Dir'); - - if (!empty($orderingDirection)) - { - $list = $app->getUserState($this->context . '.list'); - $list['direction'] = $app->input->get('filter_order_Dir'); - $app->setUserState($this->context . '.list', $list); - } - - $list = $app->getUserState($this->context . '.list'); - - if (empty($list['ordering'])) - { - $list['ordering'] = 'ordering'; - } - - if (empty($list['direction'])) - { - $list['direction'] = 'asc'; - } - - if (isset($list['ordering'])) - { - $this->setState('list.ordering', $list['ordering']); - } - - if (isset($list['direction'])) - { - $this->setState('list.direction', $list['direction']); - } - } - - /** - * Build an SQL query to load the list data for organisation - * - * @return JDatabaseQuery - * - * @since 1.6 - */ - protected function getListQuery() - { - $app = JFactory::getApplication(); - - // Create a new query object. - $db = $this->getDbo(); - $query = $db->getQuery(true); - - // Select the required fields from the table. - $query - ->select( - $this->getState( - 'list.select', 'DISTINCT a.*' - ) - ); - - $query->from('`#__tjsu_organizations` As a'); - - // $query->join('LEFT', '#__tjsu_users AS uc ON uc.client_id = a.id'); - - if (!JFactory::getUser()->authorise('core.edit.state', 'com_subusers')) - { - $query->where('a.state = 1'); - } - - // Filter by search in organisation name - $search = $app->getUserStateFromRequest('.filter.search', 'filter_organisation_search'); - - if (!empty($search)) - { - if (stripos($search, 'id:') === 0) - { - $query->where('a.id = ' . (int) substr($search, 3)); - } - else - { - $search = $db->Quote('%' . $db->escape($search, true) . '%'); - $query->where('( a.name LIKE ' . $search . ' OR a.created_by LIKE ' . $search . ' )'); - } - } - - // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering'); - $orderDirn = $this->state->get('list.direction'); - - if ($orderCol && $orderDirn) - { - $query->order($db->escape($orderCol . ' ' . $orderDirn)); - } - - return $query; - } - - /** - * Method to get an array of data items - * - * @return mixed An array of data on success, false on failure. - */ - public function getItems() - { - $items = parent::getItems(); - - return $items; - } - - /** - * Overrides the default function to check Date fields format, identified by - * "_dateformat" suffix, and erases the field if it's not correct. - * - * @return void - */ - protected function loadFormData() - { - $app = JFactory::getApplication(); - $filters = $app->getUserState($this->context . '.filter', array()); - $error_dateformat = false; - - foreach ($filters as $key => $value) - { - if (strpos($key, '_dateformat') && !empty($value) && $this->isValidDate($value) == null) - { - $filters[$key] = ''; - $error_dateformat = true; - } - } - - if ($error_dateformat) - { - $app->enqueueMessage(JText::_("COM_SUBUSERS_SEARCH_FILTER_DATE_FORMAT"), "warning"); - $app->setUserState($this->context . '.filter', $filters); - } - - return parent::loadFormData(); - } - - /** - * Checks if a given date is valid and in a specified format (YYYY-MM-DD) - * - * @param string $date Date to be checked - * - * @return bool - */ - private function isValidDate($date) - { - $date = str_replace('/', '-', $date); - - return (date_create($date)) ? JFactory::getDate($date)->format("Y-m-d") : null; - } -} diff --git a/src/site/views/announcementform/index.html b/src/site/views/announcementform/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/announcementform/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/announcementform/tmpl/default.php b/src/site/views/announcementform/tmpl/default.php deleted file mode 100755 index 6d34e88..0000000 --- a/src/site/views/announcementform/tmpl/default.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -JHtml::_('behavior.keepalive'); -JHtml::_('behavior.tooltip'); -JHtml::_('behavior.formvalidation'); -JHtml::_('formbehavior.chosen', 'select'); - -// Load admin language file -$lang = JFactory::getLanguage(); -$lang->load('com_subusers', JPATH_SITE); -$doc = JFactory::getDocument(); -$doc->addScript(JUri::base() . '/media/com_subusers/js/form.js'); -$user = JFactory::getUser(); -$userId = $user->get('id'); - -?> - - - -
-
-
- item->id)): ?> -

- -

- -
-
- -
-
-
-
- -
form->getInput('title'); ?>
-
- -
- -
form->getInput('introtext'); ?>
-
- - -
-
-
-
-
- canSave): ?> - - - - - -
-
-
-
- - - - - - - - - - -
-
-
-
diff --git a/src/site/views/announcementform/tmpl/default.xml b/src/site/views/announcementform/tmpl/default.xml deleted file mode 100755 index 7a5e1ff..0000000 --- a/src/site/views/announcementform/tmpl/default.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - -
- - -
-
-
diff --git a/src/site/views/announcementform/tmpl/index.html b/src/site/views/announcementform/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/announcementform/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/announcementform/view.html.php b/src/site/views/announcementform/view.html.php deleted file mode 100755 index 55a96c5..0000000 --- a/src/site/views/announcementform/view.html.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.view'); - -/** - * View to edit - * - * @since 1.6 - */ -class SubusersViewAnnouncementform extends JViewLegacy -{ - protected $state; - - protected $item; - - protected $form; - - protected $params; - - protected $canSave; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $app = JFactory::getApplication(); - $user = JFactory::getUser(); - - $this->state = $this->get('State'); - $this->item = $this->get('Data'); - $this->params = $app->getParams('com_subusers'); - $this->canSave = $this->get('CanSave'); - $this->form = $this->get('Form'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - - $jinput = JFactory::getApplication()->input; - $this->org_id = $jinput->get('org_id', '', 'INT'); - - $this->_prepareDocument(); - - parent::display($tpl); - } - - /** - * Prepares the document - * - * @return void - * - * @throws Exception - */ - protected function _prepareDocument() - { - $app = JFactory::getApplication(); - $menus = $app->getMenu(); - $title = null; - - // Because the application sets a default page title, - // we need to get it from the menu item itself - $menu = $menus->getActive(); - - if ($menu) - { - $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); - } - else - { - $this->params->def('page_heading', JText::_('COM_SUBUSERS_DEFAULT_PAGE_TITLE')); - } - - $title = $this->params->get('page_title', ''); - - if (empty($title)) - { - $title = $app->get('sitename'); - } - elseif ($app->get('sitename_pagetitles', 0) == 1) - { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); - } - elseif ($app->get('sitename_pagetitles', 0) == 2) - { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); - } - - $this->document->setTitle($title); - - if ($this->params->get('menu-meta_description')) - { - $this->document->setDescription($this->params->get('menu-meta_description')); - } - - if ($this->params->get('menu-meta_keywords')) - { - $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); - } - - if ($this->params->get('robots')) - { - $this->document->setMetadata('robots', $this->params->get('robots')); - } - } -} diff --git a/src/site/views/announcements/index.html b/src/site/views/announcements/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/announcements/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/announcements/tmpl/default.php b/src/site/views/announcements/tmpl/default.php deleted file mode 100755 index 2576825..0000000 --- a/src/site/views/announcements/tmpl/default.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('behavior.multiselect'); -JHtml::_('formbehavior.chosen', 'select'); - -$mainframe = JFactory::getApplication(); -$search_organisation = $mainframe->getUserStateFromRequest('.filter_organisation_search', 'filter_organisation_search'); -$user = JFactory::getUser(); -$userId = $user->get('id'); -$listOrder = $this->state->get('list.ordering'); -$listDirn = $this->state->get('list.direction'); -$canCreate = $user->authorise('core.create', 'com_subusers'); -$canEdit = $user->authorise('core.edit', 'com_subusers'); -$canCheckin = $user->authorise('core.manage', 'com_subusers'); -$canChange = $user->authorise('core.edit.state', 'com_subusers'); -$canDelete = $user->authorise('core.delete', 'com_subusers'); -?> - - - - - -
-
-
-

-
- -
- - - - - -
-
- -
-
- - -
- - -
- -
- - pagination->getLimitBox(); ?> -
-
- - items)) - { - ?> -
- - - - items[0]->id)): ?> - - - - items[0]->state)): ?> - - - - - - - - - - - - - - items as $i => $item) : ?> - authorise('core.edit', 'com_subusers'); ?> - - authorise('core.edit.own', 'com_subusers')): ?> - id == $item->created_by; ?> - - - - items[0]->id)): ?> - - - - items[0]->state)) : ?> - - - - - - - - - - -
- - - - - - - -
- pagination->getListFooter(); ?> -
- id; ?> - - - state == 1): ?> - - - - - - - - - escape($item->title); ?> - - - escape($item->title); ?> - - - introtext; ?> -
-
- -
- - - - - - - -
-
diff --git a/src/site/views/announcements/tmpl/default.xml b/src/site/views/announcements/tmpl/default.xml deleted file mode 100755 index 5328edd..0000000 --- a/src/site/views/announcements/tmpl/default.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/site/views/announcements/tmpl/default_filter.php b/src/site/views/announcements/tmpl/default_filter.php deleted file mode 100755 index cb8b85f..0000000 --- a/src/site/views/announcements/tmpl/default_filter.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -defined('JPATH_BASE') or die; - -$data = $displayData; - -// Receive overridable options -$data['options'] = !empty($data['options']) ? $data['options'] : array(); - -// Check if any filter field has been filled -$filters = false; - -if (isset($data['view']->filterForm)) -{ - $filters = $data['view']->filterForm->getGroup('filter'); -} - -// Check if there are filters set. -if ($filters !== false) -{ - $filterFields = array_keys($filters); - $filtered = false; - $filled = false; - - foreach ($filterFields as $filterField) - { - $filterField = substr($filterField, 7); - $filter = $data['view']->getState('filter.' . $filterField); - - if (!empty($filter)) - { - $filled = $filter; - } - - if (!empty($filled)) - { - $filtered = true; - break; - } - } -} - -$options = $data['options']; - -// Set some basic options -$customOptions = array( - 'filtersHidden' => isset($options['filtersHidden']) ? $options['filtersHidden'] : empty($data['view']->activeFilters) && !$filtered, - 'defaultLimit' => isset($options['defaultLimit']) ? $options['defaultLimit'] : JFactory::getApplication()->get('list_limit', 20), - 'searchFieldSelector' => '#filter_search', - 'orderFieldSelector' => '#list_fullordering' -); - -$data['options'] = array_unique(array_merge($customOptions, $data['options'])); - -$formSelector = !empty($data['options']['formSelector']) ? $data['options']['formSelector'] : '#adminForm'; - -// Load search tools -JHtml::_('searchtools.form', $formSelector, $data['options']); -?> - -
-
-
- - -
- input; ?> - -
- -
- -
- - -
- -
-
-
- -
- - - $field) : ?> - -
- input; ?> -
- - - -
-
\ No newline at end of file diff --git a/src/site/views/announcements/tmpl/index.html b/src/site/views/announcements/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/announcements/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/announcements/view.html.php b/src/site/views/announcements/view.html.php deleted file mode 100755 index b5a1192..0000000 --- a/src/site/views/announcements/view.html.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.view'); - -/** - * View class for a list of Subusers. - * - * @since 1.6 - */ -class SubusersViewAnnouncements extends JViewLegacy -{ - protected $items; - - protected $pagination; - - protected $state; - - protected $params; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $app = JFactory::getApplication(); - $user = JFactory::getUser(); - - $this->state = $this->get('State'); - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->params = $app->getParams('com_subusers'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - - $this->_prepareDocument(); - parent::display($tpl); - } - - /** - * Prepares the document - * - * @return void - * - * @throws Exception - */ - protected function _prepareDocument() - { - $app = JFactory::getApplication(); - $menus = $app->getMenu(); - $title = null; - - // Because the application sets a default page title, - // we need to get it from the menu item itself - $menu = $menus->getActive(); - - if ($menu) - { - $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); - } - else - { - $this->params->def('page_heading', JText::_('COM_SUBUSERS_DEFAULT_PAGE_TITLE')); - } - - $title = $this->params->get('page_title', ''); - - if (empty($title)) - { - $title = $app->get('sitename'); - } - elseif ($app->get('sitename_pagetitles', 0) == 1) - { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); - } - elseif ($app->get('sitename_pagetitles', 0) == 2) - { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); - } - - $this->document->setTitle($title); - - if ($this->params->get('menu-meta_description')) - { - $this->document->setDescription($this->params->get('menu-meta_description')); - } - - if ($this->params->get('menu-meta_keywords')) - { - $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); - } - - if ($this->params->get('robots')) - { - $this->document->setMetadata('robots', $this->params->get('robots')); - } - } - - /** - * Check if state is set - * - * @param mixed $state State - * - * @return bool - */ - public function getState($state) - { - return isset($this->state->{$state}) ? $this->state->{$state} : false; - } -} diff --git a/src/site/views/organization/index.html b/src/site/views/organization/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/organization/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/organization/tmpl/default.php b/src/site/views/organization/tmpl/default.php deleted file mode 100755 index bbf7678..0000000 --- a/src/site/views/organization/tmpl/default.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; -jimport('joomla.application.module.helper'); -JHTML::_('behavior.modal'); - -$document = JFactory::getDocument(); -$document->addStylesheet(JUri::root(true) . '/media/com_subusers/css/subusers.css'); -$canEdit = JFactory::getUser()->authorise('core.edit', 'com_subusers'); -$pagetitle = $this->item->name; -JFactory::getDocument()->setTitle($pagetitle); -if (!$canEdit && JFactory::getUser()->authorise('core.edit.own', 'com_subusers')) -{ - $canEdit = JFactory::getUser()->id == $this->item->created_by; -} -?> - -item): ?> -
- item):?> -
- -
-

item->name; ?>

-
-
- -
loadTemplate("slider"); ?>
-
 
-
- -
- item->description;?> -
-
-
 
- - - - - - - -
 
-
- - diff --git a/src/site/views/organization/tmpl/default.xml b/src/site/views/organization/tmpl/default.xml deleted file mode 100755 index 9c121d9..0000000 --- a/src/site/views/organization/tmpl/default.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - -
- - -
-
-
diff --git a/src/site/views/organization/tmpl/default_membership.php b/src/site/views/organization/tmpl/default_membership.php deleted file mode 100755 index 2726e70..0000000 --- a/src/site/views/organization/tmpl/default_membership.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; -jimport('joomla.filesystem.file'); -jimport('joomla.filesystem.folder'); -$document = JFactory::getDocument(); -$document->addStylesheet(JUri::root(true) . '/media/com_subusers/css/subusers.css'); -$canEdit = JFactory::getUser()->authorise('core.edit', 'com_subusers'); - -if (!$canEdit && JFactory::getUser()->authorise('core.edit.own', 'com_subusers')) -{ - $canEdit = JFactory::getUser()->id == $this->item->created_by; -} - -?> - oluser_id) - { - if ($this->memberstate == '') - { - ?> -
- - - - - - -
- memberstate == 0) - { - - ?> -
- memberstate == 1) - { - ?> -
- -
- - - - diff --git a/src/site/views/organization/tmpl/default_slider.php b/src/site/views/organization/tmpl/default_slider.php deleted file mode 100755 index 7eba3ee..0000000 --- a/src/site/views/organization/tmpl/default_slider.php +++ /dev/null @@ -1,59 +0,0 @@ - -* @copyright Copyright (C) 2015. All rights reserved. -* @license GNU General Public License version 2 or later; see LICENSE.txt -*/ -// No direct access -defined('_JEXEC') or die; -jimport('joomla.filesystem.file'); -jimport( 'joomla.filesystem.folder' ); - -$document = JFactory::getDocument(); -$document->addStylesheet(JUri::root(true).'/media/com_subusers/css/subusers.css'); -$canEdit = JFactory::getUser()->authorise('core.edit', 'com_subusers'); -if (!$canEdit && JFactory::getUser()->authorise('core.edit.own', 'com_subusers')) { -$canEdit = JFactory::getUser()->id == $this->item->created_by; -} -?> - - diff --git a/src/site/views/organization/tmpl/index.html b/src/site/views/organization/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/organization/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/organization/view.html.php b/src/site/views/organization/view.html.php deleted file mode 100755 index 4b61306..0000000 --- a/src/site/views/organization/view.html.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.view'); - -/** - * View to edit - * - * @since 1.6 - */ -class SubusersViewOrganization extends JViewLegacy -{ - protected $state; - - protected $item; - - protected $form; - - protected $params; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $app = JFactory::getApplication(); - $user = JFactory::getUser(); - - $this->state = $this->get('State'); - $this->item = $this->get('Data'); - $this->params = $app->getParams('com_subusers'); - $this->oluser_id = $user->id; - $model = $this->getModel(); - - $jinput = JFactory::getApplication()->input; - $orgid = $jinput->get('id', '0', 'INT'); - - $this->memberOrgId = $model->checkmember($this->oluser_id, $orgid); - $this->memberstate = $model->checkmemberstate($this->oluser_id, $orgid); - $this->checkIfOrgAdmin = $model->checkIfOrgAdmin($this->item->id, $this->oluser_id); - - if (!empty($this->item)) - { - $this->form = $this->get('Form'); - } - - if (!$orgid) - { - $app->redirect(JRoute::_('index.php?option=com_subusers&view=organizations&layout=pin', false)); - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - - if ($this->_layout == 'edit') - { - $authorised = $user->authorise('core.create', 'com_subusers'); - - if ($authorised !== true) - { - throw new Exception(JText::_('JERROR_ALERTNOAUTHOR')); - } - } - - $this->_prepareDocument(); - - parent::display($tpl); - } - - /** - * Prepares the document - * - * @return void - * - * @throws Exception - */ - protected function _prepareDocument() - { - $app = JFactory::getApplication(); - $menus = $app->getMenu(); - $title = null; - - // Because the application sets a default page title, - // We need to get it from the menu item itself - $menu = $menus->getActive(); - - if ($menu) - { - $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); - } - else - { - $this->params->def('page_heading', JText::_('COM_SUBUSERS_DEFAULT_PAGE_TITLE')); - } - - $title = $this->params->get('page_title', ''); - - if (empty($title)) - { - $title = $app->get('sitename'); - } - elseif ($app->get('sitename_pagetitles', 0) == 1) - { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); - } - elseif ($app->get('sitename_pagetitles', 0) == 2) - { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); - } - - $this->document->setTitle($title); - - if ($this->params->get('menu-meta_description')) - { - $this->document->setDescription($this->params->get('menu-meta_description')); - } - - if ($this->params->get('menu-meta_keywords')) - { - $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); - } - - if ($this->params->get('robots')) - { - $this->document->setMetadata('robots', $this->params->get('robots')); - } - } -} diff --git a/src/site/views/organizationform/index.html b/src/site/views/organizationform/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/organizationform/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/organizationform/tmpl/default.php b/src/site/views/organizationform/tmpl/default.php deleted file mode 100755 index 4bc39df..0000000 --- a/src/site/views/organizationform/tmpl/default.php +++ /dev/null @@ -1,271 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -JHtml::_('behavior.keepalive'); -JHtml::_('behavior.tooltip'); -JHtml::_('behavior.formvalidation'); -JHtml::_('formbehavior.chosen', 'select'); - -// Create object -$doc = JFactory::getDocument(); -$doc->addScript(JUri::base() . '/media/com_subusers/js/sub.js'); - -// Sweet alerts -$doc->addScript(JUri::root(true) . '/media/com_ekcontent/vendors/sweetalert/sweetalert.min.js'); -$doc->addStyleSheet(JUri::root(true) . '/media/com_ekcontent/vendors/sweetalert/sweetalert.css'); - -// Load admin language file -$lang = JFactory::getLanguage(); -$lang->load('com_subusers', JPATH_SITE); - -$doc->addScript(JUri::base() . '/media/com_subusers/js/form.js'); -$doc->addStylesheet(JUri::root(true) . '/media/com_subusers/css/subusers.css'); -$user = JFactory::getUser(); -$userId = $user->get( 'id' ); - -// Acl helper call -require_once JPATH_COMPONENT . '/helpers/acl.php'; - -// Call static method for language constant -SubusersFrontendHelper::getLanguageConstant(); -$orgId = $this->item->id; -$userdata = SubusersAclHelper::partnerAdminName($orgId); -?> - - - - -
-
-
- item->id)): ?> -

- -

- -
-
- -
- -
-
-
- -
- form->getInput('id'); ?> -
-
- -
- -
- form->getInput('name'); ?>
-
- -
- -
- form->getInput('email'); ?> -
-
- - -
- -
- name; ?> -
-
- - -
- -
- form->getInput('userid'); ?> -
-
- - - -
- form->getLabel('logo'); ?> -
-
- - - - form->getInput('logo'); ?> - - - -
- -

- subusersParams->get('allowed_logo_types')); ?> -
- subusersParams->get('max_logo_size')); ?> -

- -
- item->logo)) : - foreach ((array) $this->item->logo as $singleFile) : - if (!is_array($singleFile)) : - echo ''; - endif; - endforeach; - endif;?> -
- - -
-
- -
- -
- form->getInput('description'); ?> -
-
- -
-
-
-
-
- canSave): ?> - - - - - -
-
-
-
- - - - - - - - - - -
-
-
-
- - diff --git a/src/site/views/organizationform/tmpl/default.xml b/src/site/views/organizationform/tmpl/default.xml deleted file mode 100755 index 0379285..0000000 --- a/src/site/views/organizationform/tmpl/default.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - -
- - -
-
-
diff --git a/src/site/views/organizationform/tmpl/index.html b/src/site/views/organizationform/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/organizationform/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/organizationform/view.html.php b/src/site/views/organizationform/view.html.php deleted file mode 100755 index 6837c1b..0000000 --- a/src/site/views/organizationform/view.html.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.view'); - -/** - * View to edit - * - * @since 1.6 - */ -class SubusersViewOrganizationform extends JViewLegacy -{ - protected $state; - - protected $item; - - protected $form; - - protected $params; - - protected $canSave; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $app = JFactory::getApplication(); - $user = JFactory::getUser(); - - $this->state = $this->get('State'); - $this->item = $this->get('Data'); - $this->params = $app->getParams('com_subusers'); - $this->canSave = $this->get('CanSave'); - $this->form = $this->get('Form'); - $this->subusersParams = JComponentHelper::getParams('com_subusers'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - $this->_prepareDocument(); - - parent::display($tpl); - } - - /** - * Prepares the document - * - * @return void - * - * @throws Exception - */ - protected function _prepareDocument() - { - $app = JFactory::getApplication(); - $menus = $app->getMenu(); - $title = null; - - // Because the application sets a default page title, - // we need to get it from the menu item itself - $menu = $menus->getActive(); - - if ($menu) - { - $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); - } - else - { - $this->params->def('page_heading', JText::_('COM_SUBUSERS_DEFAULT_PAGE_TITLE')); - } - - if (empty($title)) - { - if (!empty($this->item->name)) - { - $title = $this->item->name; - } - else - { - $title = JText::_('COM_SUBUSERS_ORGANIZATION_FORM_PAGE_TITLE'); - } - } - - if (empty($title)) - { - $title = $app->get('sitename'); - } - elseif ($app->get('sitename_pagetitles', 0) == 1) - { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); - } - elseif ($app->get('sitename_pagetitles', 0) == 2) - { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); - } - - $this->document->setTitle($title); - - if ($this->params->get('menu-meta_description')) - { - $this->document->setDescription($this->params->get('menu-meta_description')); - } - - if ($this->params->get('menu-meta_keywords')) - { - $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); - } - - if ($this->params->get('robots')) - { - $this->document->setMetadata('robots', $this->params->get('robots')); - } - } -} diff --git a/src/site/views/organizations/index.html b/src/site/views/organizations/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/organizations/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/organizations/tmpl/default.php b/src/site/views/organizations/tmpl/default.php deleted file mode 100755 index b55bb28..0000000 --- a/src/site/views/organizations/tmpl/default.php +++ /dev/null @@ -1,216 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('behavior.multiselect'); -JHtml::_('formbehavior.chosen', 'select'); - -// Load js -$doc = JFactory::getDocument(); -$doc->addScript(JUri::base() . '/media/com_subusers/js/sub.js'); - -$mainframe = JFactory::getApplication(); -$search_organisation = $mainframe->getUserStateFromRequest('.filter_organisation_search', 'filter_organisation_search'); - -$user = JFactory::getUser(); -$userId = $user->get('id'); -$listOrder = $this->state->get('list.ordering'); -$listDirn = $this->state->get('list.direction'); -$canCreate = $user->authorise('core.create', 'com_subusers'); -$canEdit = $user->authorise('core.edit', 'com_subusers'); -$canCheckin = $user->authorise('core.manage', 'com_subusers'); -$canChange = $user->authorise('core.edit.state', 'com_subusers'); -$canDelete = $user->authorise('core.delete', 'com_subusers');?> - - - -
-
-
-

-
-
-
-
-
- -
- - -
- isSuperAdmin) - { - if ($canCreate) : ?> - - - -
- - -
- - - items)) - { - ?> -
- - - - items[0]->id)): ?> - - - - items[0]->state)): ?> - - - - - - - - - - - - - - - - - - - items as $i => $item) : ?> - authorise('core.edit', 'com_subusers'); ?> - - authorise('core.edit.own', 'com_subusers')): ?> - id == $item->created_by; ?> - - - - items[0]->id)): ?> - - - - items[0]->state)) : ?> - - - - - - - - - - - -
- - - - - - - - - -
- pagination->getListFooter(); ?> -
- id; ?> - - - state == 1): ?> - - - - - - - - - escape($item->name); ?> - - - escape($item->name); ?> - - - email; ?> - - userid); - echo $user->name; ?> - - - - -
-
- -
- -
- - - - - - -
-
-
-
- - - diff --git a/src/site/views/organizations/tmpl/default.xml b/src/site/views/organizations/tmpl/default.xml deleted file mode 100755 index 5328edd..0000000 --- a/src/site/views/organizations/tmpl/default.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/site/views/organizations/tmpl/default_filter.php b/src/site/views/organizations/tmpl/default_filter.php deleted file mode 100755 index cb8b85f..0000000 --- a/src/site/views/organizations/tmpl/default_filter.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -defined('JPATH_BASE') or die; - -$data = $displayData; - -// Receive overridable options -$data['options'] = !empty($data['options']) ? $data['options'] : array(); - -// Check if any filter field has been filled -$filters = false; - -if (isset($data['view']->filterForm)) -{ - $filters = $data['view']->filterForm->getGroup('filter'); -} - -// Check if there are filters set. -if ($filters !== false) -{ - $filterFields = array_keys($filters); - $filtered = false; - $filled = false; - - foreach ($filterFields as $filterField) - { - $filterField = substr($filterField, 7); - $filter = $data['view']->getState('filter.' . $filterField); - - if (!empty($filter)) - { - $filled = $filter; - } - - if (!empty($filled)) - { - $filtered = true; - break; - } - } -} - -$options = $data['options']; - -// Set some basic options -$customOptions = array( - 'filtersHidden' => isset($options['filtersHidden']) ? $options['filtersHidden'] : empty($data['view']->activeFilters) && !$filtered, - 'defaultLimit' => isset($options['defaultLimit']) ? $options['defaultLimit'] : JFactory::getApplication()->get('list_limit', 20), - 'searchFieldSelector' => '#filter_search', - 'orderFieldSelector' => '#list_fullordering' -); - -$data['options'] = array_unique(array_merge($customOptions, $data['options'])); - -$formSelector = !empty($data['options']['formSelector']) ? $data['options']['formSelector'] : '#adminForm'; - -// Load search tools -JHtml::_('searchtools.form', $formSelector, $data['options']); -?> - -
-
-
- - -
- input; ?> - -
- -
- -
- - -
- -
-
-
- -
- - - $field) : ?> - -
- input; ?> -
- - - -
-
\ No newline at end of file diff --git a/src/site/views/organizations/tmpl/index.html b/src/site/views/organizations/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/organizations/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/organizations/tmpl/pin.php b/src/site/views/organizations/tmpl/pin.php deleted file mode 100755 index 9673a26..0000000 --- a/src/site/views/organizations/tmpl/pin.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('behavior.multiselect'); -JHtml::_('formbehavior.chosen', 'select'); - -$mainframe = JFactory::getApplication(); -$search_organisation = $mainframe->getUserStateFromRequest('.filter_organisation_search', 'filter_organisation_search'); - -$user = JFactory::getUser(); -$userId = $user->get('id'); -$listOrder = $this->state->get('list.ordering'); -$listDirn = $this->state->get('list.direction'); -$canCreate = $user->authorise('core.create', 'com_subusers'); -$canEdit = $user->authorise('core.edit', 'com_subusers'); -$canCheckin = $user->authorise('core.manage', 'com_subusers'); -$canChange = $user->authorise('core.edit.state', 'com_subusers'); -$canDelete = $user->authorise('core.delete', 'com_subusers'); - -$document = JFactory::getDocument(); -$document->addStylesheet(JUri::root(true) . '/media/com_subusers/css/subusers.css'); -?> - - - -
-
-
-
- -
- -
- - -
- -
- -
-
-

- -

-
-
- -
- items) - { - foreach ($this->items as $i => $item) - { - ?> - - - - -
-
- -
-
- -
- -
 
- - - - - - - -
-
-
-
diff --git a/src/site/views/organizations/view.html.php b/src/site/views/organizations/view.html.php deleted file mode 100755 index 6e8c444..0000000 --- a/src/site/views/organizations/view.html.php +++ /dev/null @@ -1,162 +0,0 @@ - - * @package Subusers - * @author Techjoomla - * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved - * @license GNU General Public License version 2, or later - */ - -// No direct access -defined('_JEXEC') or die('Restricted access'); - -jimport('joomla.application.component.view'); - -JPATH_SITE . 'components/com_subusers/helpers/subusers.php'; - -/** - * View class for a list of Subusers. - * - * @since 1.6 - */ -class SubusersViewOrganizations extends JViewLegacy -{ - protected $items; - - protected $pagination; - - protected $state; - - protected $params; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $app = JFactory::getApplication(); - $user = JFactory::getUser(); - $layout = $app->input->get('layout', 'default'); - - $this->state = $this->get('State'); - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->params = $app->getParams('com_subusers'); - - $user = JFactory::getUser(); - $uid = $user->id; - - // Import helper file - require_once JPATH_COMPONENT . '/helpers/acl.php'; - - // Check logged in user is admin of organization - $this->isAdmin = SubusersAclHelper::isOrganisationAdmin($uid); - - // Check logged in user is superuser or not - $this->isSuperAdmin = SubusersAclHelper::isSuperAdmin($uid); - - if ($layout == 'default') - { - if (!$user->id) - { - $mainframe = JFactory::getApplication(); - $mainframe->redirect("index.php?option=com_subusers&view=organizations&layout=pin&Itemid="); - } - elseif(!$this->isSuperAdmin) - { - $mainframe = JFactory::getApplication(); - $mainframe->redirect("index.php?option=com_subusers&view=organizations&layout=pin"); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - - $this->_prepareDocument(); - - parent::display($tpl); - } - - /** - * Prepares the document - * - * @return void - * - * @throws Exception - */ - protected function _prepareDocument() - { - $app = JFactory::getApplication(); - $menus = $app->getMenu(); - $title = null; - - // Because the application sets a default page title, - // we need to get it from the menu item itself - $menu = $menus->getActive(); - - if ($menu) - { - $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); - } - else - { - $this->params->def('page_heading', JText::_('COM_SUBUSERS_DEFAULT_PAGE_TITLE')); - } - - if (empty($title)) - { - $title = JText::_('COM_SUBUSERS_ORGANIZATION_LIST_PAGE_TITLE'); - } - - if (empty($title)) - { - $title = $app->get('sitename'); - } - elseif ($app->get('sitename_pagetitles', 0) == 1) - { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); - } - elseif ($app->get('sitename_pagetitles', 0) == 2) - { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); - } - - $this->document->setTitle($title); - - if ($this->params->get('menu-meta_description')) - { - $this->document->setDescription($this->params->get('menu-meta_description')); - } - - if ($this->params->get('menu-meta_keywords')) - { - $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); - } - - if ($this->params->get('robots')) - { - $this->document->setMetadata('robots', $this->params->get('robots')); - } - } - - /** - * Check if state is set - * - * @param mixed $state State - * - * @return bool - */ - public function getState($state) - { - return isset($this->state->{$state}) ? $this->state->{$state} : false; - } -}