diff --git a/administrator/helpers/hierarchy.php b/administrator/helpers/hierarchy.php index c601a5f..4e0c491 100755 --- a/administrator/helpers/hierarchy.php +++ b/administrator/helpers/hierarchy.php @@ -55,4 +55,34 @@ public static function getActions() return $result; } + +/** + * Check the user is Course creator or not + * + * @param user_Id $user_Id Id of user* + * + * @return result format + * + * @since 1.0 + */ + public function checkManager($user_Id = null) + { + if (empty($user_Id)) + { + $user_Id = JFactory::getUser()->id; + } + + if ($user_Id) + { + // Checking if the user is having subuser in hierarchy + JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_hierarchy/models', 'hierarchys'); + $HierarchyModelHierarchys = JModelLegacy::getInstance('Hierarchys', 'HierarchyModel'); + $HierarchyModelHierarchys->setState('filter.user_id', $user_Id); + $isManager = $HierarchyModelHierarchys->getItems(); + + return $isManager; + } + + return false; + } } diff --git a/administrator/models/hierarchys.php b/administrator/models/hierarchys.php index 4f0ac94..2d3c9cb 100755 --- a/administrator/models/hierarchys.php +++ b/administrator/models/hierarchys.php @@ -61,9 +61,12 @@ protected function populateState($ordering = null, $direction = null) $published = $app->getUserStateFromRequest($this->context . '.filter.state', 'filter_published', '', 'string'); $this->setState('filter.state', $published); + $user_id = $app->getUserState('filter.user_id'); - // Filtering user_id - $this->setState('filter.user_id', $app->getUserStateFromRequest($this->context . '.filter.user_id', 'filter_user_id', '', 'string')); + if (!empty($user_id)) + { + $this->setState('filter.user_id', $app->getUserStateFromRequest($this->context . '.filter.user_id', 'filter_user_id', '', 'string')); + } // Load the parameters. $params = JComponentHelper::getParams('com_hierarchy'); @@ -146,7 +149,6 @@ protected function getListQuery() $query->where('a.block=0'); - // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); diff --git a/site/helpers/hierarchy.php b/site/helpers/hierarchy.php index fd1eec5..094ef5d 100644 --- a/site/helpers/hierarchy.php +++ b/site/helpers/hierarchy.php @@ -16,52 +16,102 @@ */ class HierarchyFrontendHelper { - // $ + /** + * Check the Ticket + * + * @param tid $tid uid of user + * + * @return result format + * + * @since 1.0 + */ public static function checkTicketJTicket($tid) { if ($tid) { $db = JFactory::getDBO(); - echo $query = "SELECT CONCAT_WS('-', order_id, id) AS ticketid FROM `#__jticketing_order` as o WHERE CONCAT_WS('-', order_id, id) = '". $tid ."'"; + echo $query = "SELECT CONCAT_WS('-', order_id, id) AS ticketid FROM `#__jticketing_order` + as o WHERE CONCAT_WS('-', order_id, id) = '" . $tid . "'"; $db->setQuery($query); return $managerId = $db->loadResult(); } } + + /** + * Check the Ticket + * + * @param tid $tid uid of user + * + * @return result format + * + * @since 1.0 + */ public static function checkTicketExit($tid) { if ($tid) { $db = JFactory::getDBO(); - $query = "SELECT * FROM `#__hierarchy_reschedule` WHERE `ticket_id` = '". $tid ."'"; + $query = "SELECT * FROM `#__hierarchy_reschedule` WHERE `ticket_id` = '" . $tid . "'"; $db->setQuery($query); return $managerId = $db->loadObjectlist(); } } + + /** + * Get the TicketStatus + * + * @param tid $tid uid of user + * + * @return result format + * + * @since 1.0 + */ public static function checkTicketStatus($tid) { if ($tid) { $db = JFactory::getDBO(); - $query = "SELECT * FROM `#__hierarchy_reschedule` WHERE `ticket_id` LIKE '%-". $tid ."-%' "; + $query = "SELECT * FROM `#__hierarchy_reschedule` WHERE `ticket_id` LIKE '%-" . $tid . "-%' "; $db->setQuery($query); return $managerId = $db->loadObjectlist(); } } + + /** + * Get the TicketStatus + * + * @param tid $tid uid of user + * @param rid $rid rid of user + * + * @return result format + * + * @since 1.0 + */ public static function checkTicketStatusLast($tid,$rid) { if ($tid) { $db = JFactory::getDBO(); - $query = "SELECT * FROM `#__hierarchy_reschedule` WHERE `ticket_id` LIKE '%-". $tid ."-%' AND id= '".$rid."'"; + $query = "SELECT * FROM `#__hierarchy_reschedule` WHERE `ticket_id` LIKE '%-" . $tid . "-%' AND id= '" . $rid . "'"; $db->setQuery($query); return $managerId = $db->loadObjectlist(); } } - public static function getUserManager($uid) + + /** + * Get the UserManager + * + * @param uid $uid uid of user + * + * @return result format + * + * @since 1.0 + */ + public static function getUserManager($uid) { if ($uid) { @@ -72,6 +122,16 @@ public static function getUserManager($uid) return $managerId = $db->loadResult(); } } + + /** + * Get the admin + * + * @param uid $uid uid of user + * + * @return result format + * + * @since 1.0 + */ public static function getUserProfileData($uid) { if ($uid) @@ -83,102 +143,169 @@ public static function getUserProfileData($uid) return $managerId = $db->loadObject(); } } + + /** + * Get the admin + * + * @param uid $uid uid of user + * + * @param ticketid $ticketid ticketid of user + * + * @return result format + * + * @since 1.0 + */ public static function getTicketRescheduleData($uid, $ticketid) { if ($uid && $ticketid) { $db = JFactory::getDBO(); - $query = "SELECT * FROM `#__hierarchy_reschedule` WHERE `ticket_id` = '". $ticketid ."' and user_id = '". $uid ."' order by id DESC LIMIT 0 , 10 "; + $query = "SELECT * FROM `#__hierarchy_reschedule` WHERE `ticket_id` = '" . $ticketid . "' + and user_id = '" . $uid . "' order by id DESC LIMIT 0 , 10 "; $db->setQuery($query); return $managerId = $db->loadObjectlist(); } } + + /** + * Get the admin + * + * @param ticketid $reschedule_id reschedule_id of user + * + * @return result format + * + * @since 1.0 + */ public static function getRescheduleData($reschedule_id) { if ($reschedule_id) { $db = JFactory::getDBO(); - $query = "SELECT * FROM `#__hierarchy_reschedule` WHERE `id` = '". $reschedule_id ."'"; + $query = "SELECT * FROM `#__hierarchy_reschedule` WHERE `id` = '" . $reschedule_id . "'"; $db->setQuery($query); return $db->loadObject(); } } + + /** + * Get the admin + * + * @param ticketid $ticketid Id of user + * @param ticketid $rid rid of user + * + * @return result format + * + * @since 1.0 + */ public static function getTicketData($ticketid, $rid =null) { if ($ticketid) { $db = JFactory::getDBO(); - $query = "SELECT * FROM `#__hierarchy_reschedule` WHERE `ticket_id`='". $ticketid ."'"; + $query = "SELECT * FROM `#__hierarchy_reschedule` WHERE `ticket_id`='" . $ticketid . "'"; + if ($rid) { - $query .= "AND `id` = '". $rid ."'"; + $query . = "AND `id` = '" . $rid . "'"; } + $db->setQuery($query); return $managerId = $db->loadObject(); } } + + /** + * Get the admin + * + * @param ticketid $ticketid Id of user + * + * @return result format + * + * @since 1.0 + */ public static function getUserId($ticketid) { if ($ticketid) { - $db = JFactory::getDBO(); - $query = "SELECT user_id FROM `#__hierarchy_reschedule` WHERE `ticket_id` = '". $ticketid ."'"; + $query = "SELECT user_id FROM `#__hierarchy_reschedule` WHERE `ticket_id` = '" . $ticketid . "'"; $db->setQuery($query); return $managerId = $db->loadResult(); } } + /** + * Get the admin + * + * @param reschedule_id $reschedule_id Id of user + * + * @return result format + * + * @since 1.0 + */ public static function getTicketID($reschedule_id) { if ($reschedule_id) { $db = JFactory::getDBO(); - $query = "SELECT ticket_id FROM `#__hierarchy_reschedule` WHERE `id` = '". $reschedule_id ."'"; + $query = "SELECT ticket_id FROM `#__hierarchy_reschedule` WHERE `id` = '" . $reschedule_id . "'"; $db->setQuery($query); return $managerId = $db->loadResult(); } } + + /** + * Get the admin + * + * @param groupid $groupid Id of user + * + * @return result format + * + * @since 1.0 + */ public static function getTrainingAdmin($groupid) { if ($groupid) { $db = JFactory::getDBO(); - $query = "SELECT user_id FROM `#__user_usergroup_map` WHERE `group_id` = '". $groupid ."'"; + $query = "SELECT user_id FROM `#__user_usergroup_map` WHERE `group_id` = '" . $groupid . "'"; $db->setQuery($query); return $managerId = $db->loadColumn(); } } - /** - * Email sendmail function. - * - * @param string $mailfrom from mail address. - * @param string $fromname from user name. - * @param string $email to mail address. - * @param string $emailSubject subject of mail. - * @param string $emailBody body of mail. - * - * @return boolan - * - * @since 1.0 - */ +/** + * Email sendmail function. + * + * @param string $mailfrom from mail address. + * @param string $fromname from user name. + * @param string $email to mail address. + * @param string $emailSubject subject of mail. + * @param string $emailBody body of mail. + * + * @param string $cc cc of mail. + * + * @return boolan + * + * @since 1.0 + */ static public function RescheduleEmail($mailfrom, $fromname, $email, $emailSubject, $emailBody,$cc = null) { $params = JComponentHelper::getParams('com_hierarchy'); - $fromname = $params->get('reschedule_email_from', '','STRING'); - $replyTo = $params->get('reschedule_email_Reply_To', '','RAW'); - - $return = JFactory::getMailer()->sendMail($mailfrom, $fromname, $email, $emailSubject, $emailBody, $mode = 1, $cc, $bcc=null,$attachment=null,$replyTo,$replyToName=null); + $fromname = $params->get('reschedule_email_from', '', 'STRING'); + $replyTo = $params->get('reschedule_email_Reply_To', '', 'RAW'); + $return = JFactory::getMailer()-> + sendMail($mailfrom, $fromname, $email, $emailSubject, $emailBody, $mode = 1, $cc, $bcc = null, $attachment = null, $replyTo, $replyToName = null); return $return; } + /** * Email Body function * @@ -244,20 +371,59 @@ static public function EmailBody($replaceData, $email_body) return $EmailBody; } + /** + * TrainingAdmin function + * + * @param int $uid user Id. + * + * @return manager id + * + * @since 1.0 + */ public static function getTrainingAdminExit($uid = null) { $params = JComponentHelper::getParams('com_hierarchy'); - $groupid = $params->get('groupid', '','INT'); + $groupid = $params->get('groupid', '', 'INT'); $user = JFactory::getUser(); $uid = $user->id; if ($uid) { $db = JFactory::getDBO(); - $query = "SELECT group_id FROM `#__user_usergroup_map` WHERE `user_id` = '". $uid ."' AND group_id = '".$groupid."'"; + $query = "SELECT group_id FROM `#__user_usergroup_map` WHERE `user_id` = '" . $uid . "' AND group_id = '" . $groupid . "'"; $db->setQuery($query); return $managerId = $db->loadResult(); } } + + /** + * Check the user is Course creator or not + * + * @param user_Id $user_Id Id of user + * + * @return result format + * + * @since 1.0 + */ + public function checkManager($user_Id = null) + { + if (empty($user_Id)) + { + $user_Id = JFactory::getUser()->id; + } + + if ($user_Id) + { + // Checking if the user is having subuser in hierarchy + JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_hierarchy/models', 'hierarchys'); + $HierarchyModelHierarchys = JModelLegacy::getInstance('Hierarchys', 'HierarchyModel'); + $HierarchyModelHierarchys->setState('filter.user_id', $user_Id); + $isManager = $HierarchyModelHierarchys->getItems(); + + return $isManager; + } + + return false; + } }