Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug #107010 #5

Open
wants to merge 1 commit into
base: release-1.1.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions administrator/controllers/hierarchys.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,14 @@ public function setUser()
{
$jinput = JFactory::getApplication()->input;
$subuserId = $jinput->get->get('subuserId', '', 'int');
$bossuserId = $jinput->post->get('user_id', '', 'int');
$userId = $jinput->post->get('user_id', '', 'int');

// Get the model
$model = $this->getModel();
$return = $model->saveUserHier($bossuserId, $subuserId);
$data = array();
$data['subuser_id'] = $subuserId;
$data['user_id'] = $userId;
$return = $model->save($data);

jexit();
}
Expand Down
35 changes: 35 additions & 0 deletions administrator/models/hierarchy.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,39 @@ public function saveCSVdata($userData)

return $output;
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranjit-redekar We do not need hierarchy model and controller. only Hierarchys model and controlller will be used

* Prepare and sanitise the data prior to saving.
*
* @param ARRAY $data it is array of managerId, empId, client, clientId and state.
*
* @return void
*
* @since 1.6
*/
public function save($data)
{
$db = $this->getDbo();

try
{
JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_hierarchy/tables');
$userHierarchyObj = JTable::getInstance('Hierarchy', 'HierarchyTable', array('dbo', $db));
$userHierarchyObj->load(array('subuser_id' => (int) $data['subuser_id']));
$data['id'] = isset($userHierarchyObj->id) ? $userHierarchyObj->id : '' ;

if (parent::save($data))
{
return $data;
}
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());

return false;
}

return false;
}
}
2 changes: 1 addition & 1 deletion administrator/models/hierarchys.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function getSubusers($userId)
}

$query->select($db->quoteName('hu.subuser_id'));
$query->from($db->quoteName('#__hierarchy_users'), 'hu');
$query->from($db->quoteName('#__hierarchy_users', 'hu'));
$query->join('inner', $db->quoteName('#__users') . 'as u ON u.id=hu.subuser_id');
$query->where($conditions);
$db->setQuery($query);
Expand Down