function getEditService() { $app = JFactory::getApplication(); $db = JFactory::getDbo(); $id = $app->input->get('id', 0, 'int'); $user = JFactory::getUser(); $isNew = $id > 0 ? false : true; //check if the owner is editing the service $isOwnedOperation = JblanceHelper::checkOwnershipOfOperation($id, 'service'); if ($id > 0 && !$isOwnedOperation) { $msg = JText::sprintf('COM_JBLANCE_NOT_AUTHORIZED_TO_ACCESS_THIS_PAGE'); $app->enqueueMessage($msg, 'error'); $link = JRoute::_('index.php?option=com_jblance&view=user&layout=dashboard', false); $app->redirect($link); return false; } //check if the user's plan is expired or not approved. If so, do not allow him to create service $planStatus = JblanceHelper::planStatus($user->id); if ($isNew && ($planStatus == 1 || $planStatus == 2)) { $msg = JText::sprintf('COM_JBLANCE_NOT_ALLOWED_TO_DO_OPERATION_NO_ACTIVE_SUBSCRIPTION'); $app->enqueueMessage($msg, 'error'); $link = JRoute::_('index.php?option=com_jblance&view=user&layout=dashboard', false); $app->redirect($link); return false; } //check if the user has enough fund to create new services. This should be checked for new services only $plan = JblanceHelper::whichPlan($user->id); $chargePerService = $plan->flChargePerService; if ($isNew && $chargePerService > 0) { $totalFund = JblanceHelper::getTotalFund($user->id); if ($totalFund < $chargePerService) { $msg = JText::sprintf('COM_JBLANCE_BALANCE_INSUFFICIENT_TO_POST_SERVICE', JblanceHelper::formatCurrency($chargePerService)); $app->enqueueMessage($msg, 'error'); $link = JRoute::_('index.php?option=com_jblance&view=membership&layout=depositfund', false); $app->redirect($link); return false; } } $row = JTable::getInstance('service', 'Table'); $row->load($id); //show reason if service is not approved. if (!$isNew && !$row->approved) { $msg = empty($row->disapprove_reason) ? JText::_('COM_JBLANCE_SERVICE_PENDING_APPROVAL_FROM_ADMIN') : $row->disapprove_reason; $app->enqueueMessage(nl2br($msg), 'Error'); } $return[0] = $row; return $return; }
function getInviteUser() { $app = JFactory::getApplication(); $db = JFactory::getDbo(); $where = array(); $project_id = $app->input->get('id', 0, 'int'); $project = JTable::getInstance('project', 'Table'); $project->load($project_id); $id_categ = explode(',', $project->id_category); $isOwnedOperation = JblanceHelper::checkOwnershipOfOperation($project_id, 'project'); if (!$isOwnedOperation) { $msg = JText::sprintf('COM_JBLANCE_NOT_AUTHORIZED_TO_ACCESS_THIS_PAGE'); $link = JRoute::_('index.php?option=com_jblance&view=user&layout=dashboard', false); $app->enqueueMessage($msg, 'error'); $app->redirect($link); return false; } $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit'), 'int'); $limitstart = $app->input->get('limitstart', 0, 'int'); if (count($id_categ) > 0 && !(count($id_categ) == 1 && empty($id_categ[0]))) { if (is_array($id_categ)) { $miniquery = array(); foreach ($id_categ as $cat) { $miniquery[] = "FIND_IN_SET(" . $cat . ", ju.id_category)"; } $querytemp = '(' . implode(' OR ', $miniquery) . ')'; } $queryStrings[] = $querytemp; } $queryStrings[] = "u.block=0"; $queryStrings[] = "u.id <> " . $db->quote($project->publisher_userid); // do not list the project owner $where = count($queryStrings) ? ' WHERE (' . implode(') AND (', $queryStrings) . ') ' : ''; $query = "SELECT DISTINCT ju.*,u.username,u.name,ug.name AS grpname FROM #__jblance_user ju " . "LEFT JOIN #__users u ON ju.user_id=u.id " . "LEFT JOIN #__jblance_usergroup ug ON ju.ug_id=ug.id " . $where . "ORDER BY u.name"; //echo $query; $db->setQuery($query); $db->execute(); $total = $db->getNumRows(); //if there are no matching users, redirect to project edit page if ($total == 0) { $msg = JText::sprintf('COM_JBLANCE_NO_MATCHING_SKILLS_RECHOOSE'); $link = JRoute::_('index.php?option=com_jblance&view=project&layout=editproject&id=' . $project_id, false); $app->enqueueMessage($msg, 'notice'); $app->redirect($link); return false; } jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); $db->setQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $db->loadObjectList(); $return[0] = $rows; $return[1] = $project; $return[2] = $pageNav; return $return; }