static function getProfiletypes($filter_type, $limitstart, $limit, $filter_order, $filter_order_Dir, $search) { // Check that JS is installed $jcheck = JPATH_BASE . '/components/com_community/libraries/core.php'; if (!file_exists($jcheck)) { return array(); } $db = JFactory::getDBO(); $wheres = array(); if ($filter_type) { /* kludge to use 0 as a value */ if ($filter_type == -1) { $filter_type = 0; } $wheres[] = "create_on_moodle = " . $db->Quote($filter_type); } if ($search) { $wheres_search[] = "joomla_field = " . $db->Quote($search); $wheres_search[] = "moodle_field = " . $db->Quote($search); $wheres[] = "(name LIKE " . $search . ")"; } if ($filter_type == 2) { $query = "SELECT p.id, p.name from #__community_profiles as p " . "LEFT JOIN #__joomdle_profiletypes AS pt ON p.id = pt.profiletype_id " . " WHERE create_on_moodle = '0' OR create_on_moodle IS NULL "; } else { if ($filter_type == 1) { $query = "SELECT p.id, p.name from #__community_profiles as p " . "LEFT JOIN #__joomdle_profiletypes AS pt ON p.id = pt.profiletype_id " . " WHERE create_on_moodle = '1'"; } else { $query = "SELECT p.id, p.name, pt.id as profiletype_id from #__community_profiles as p " . "LEFT JOIN #__joomdle_profiletypes AS pt ON p.id = pt.profiletype_id "; } } $query .= " ORDER BY " . $filter_order . " " . $filter_order_Dir; if (!empty($limit)) { $query .= " LIMIT {$limitstart}, {$limit}"; } $db->setQuery($query); $profiletypes = $db->loadObjectList(); if (!$profiletypes) { return NULL; } $m = array(); foreach ($profiletypes as $profiletype) { $profiletype->published = JoomdleHelperProfiletypes::create_this_type($profiletype->id); $profiletype->create_on_moodle = $profiletype->published; $m[] = $profiletype; } return $m; }
static function getProfiletypes($filter_type, $limitstart, $limit, $filter_order, $filter_order_Dir, $search) { $db = JFactory::getDBO(); $wheres = array(); if ($filter_type) { /* kludge to use 0 as a value */ if ($filter_type == -1) { $filter_type = 0; } $wheres[] = "create_on_moodle = " . $db->Quote($filter_type); } if ($search) { $wheres_search[] = "joomla_field = " . $db->Quote($search); $wheres_search[] = "moodle_field = " . $db->Quote($search); $wheres[] = "(name LIKE " . $search . ")"; } $query = "SELECT * from #__xipt_profiletypes"; // $query = 'SELECT j.id, name, create_on_moodle // FROM #__xipt_profiletypes as x, #__joomdle_profiletypes as j // where x.id = j.profiletype_id'; if (!empty($wheres)) { $query .= " AND " . implode(' AND ', $wheres); } $query .= " ORDER BY " . $filter_order . " " . $filter_order_Dir; if (!empty($limit)) { $query .= " LIMIT {$limitstart}, {$limit}"; } $db->setQuery($query); $profiletypes = $db->loadObjectList(); if (!$profiletypes) { return NULL; } foreach ($profiletypes as $profiletype) { $profiletype->published = JoomdleHelperProfiletypes::create_this_type($profiletype->id); $profiletype->create_on_moodle = $profiletype->published; $m[] = $profiletype; } return $m; }