static function actionbutton($course_info, $free_courses_button = 'enrol', $paid_courses_button = 'buy', $button_text = '') { $course_id = $course_info['remoteid']; $user = JFactory::getUser(); $username = $user->username; $is_enroled = $course_info['enroled']; $guest = $course_info['guest']; $params = JComponentHelper::getParams('com_joomdle'); $show_experience = $params->get('show_detail_application_experience'); $show_motivation = $params->get('show_detail_application_motivation'); $goto_course_button = $params->get('goto_course_button'); $linkstarget = $params->get('linkstarget'); $html = ""; if ($is_enroled || $guest) { if ($goto_course_button) { if (!$button_text) { $button_text = JText::_('COM_JOOMDLE_GO_TO_COURSE'); } $url = JoomdleHelperContent::get_course_url($course_id); if ($linkstarget == 'new') { $html .= '<FORM> <INPUT TYPE="BUTTON" VALUE=" ' . $button_text . ' " ONCLICK="window.open (\'' . $url . '\')"> </FORM>'; } else { $html .= '<FORM> <INPUT TYPE="BUTTON" VALUE=" ' . $button_text . ' " ONCLICK="window.location.href=\' ' . $url . ' \'"> </FORM>'; } } } else { if ((!array_key_exists('cost', $course_info) || !$course_info['cost']) && !JoomdleHelperShop::is_course_on_sell($course_id)) { if ($free_courses_button == 'goto') { if (!$button_text) { $button_text = JText::_('COM_JOOMDLE_GO_TO_COURSE'); } $url = JoomdleHelperContent::get_course_url($course_id); if ($linkstarget == 'new') { $html .= '<FORM> <INPUT TYPE="BUTTON" VALUE=" ' . $button_text . ' " ONCLICK="window.open (\'' . $url . '\')"> </FORM>'; } else { $html .= '<FORM> <INPUT TYPE="BUTTON" VALUE=" ' . $button_text . ' " ONCLICK="window.location.href=\' ' . $url . ' \'"> </FORM>'; } } else { if ($free_courses_button == 'enrol') { if (!$button_text) { $button_text = JText::_('COM_JOOMDLE_ENROL_INTO_COURSE'); } $url = "index.php?option=com_joomdle&task=enrol&course_id={$course_id}"; $can_enrol = $course_info['self_enrolment'] && $course_info['in_enrol_date']; if ($can_enrol) { $html .= '<FORM> <INPUT TYPE="BUTTON" VALUE=" ' . $button_text . ' " ONCLICK="window.location.href=\' ' . $url . ' \'"> </FORM>'; } } else { if ($free_courses_button == 'applicate') { if (!$user->id) { $html .= '<br>' . JText::_('COM_JOOMDLE_YOU_NEED_TO_LOGIN_TO_APPLICATE'); } else { $app = JFactory::getApplication(); $results = $app->triggerEvent('onShowRequestCourseButton', array($course_id, $user->id, &$message)); if (in_array(false, $results)) { $html .= $message; } else { $html .= ' <br> <FORM action="index.php?option=com_joomdle" method="post" id="josForm" name="josForm" class="form-validate">'; if ($show_motivation != 'no') { $html .= JText::_('COM_JOOMDLE_MOTIVATION'); if ($show_motivation == 'mandatory') { $html .= '*'; } $html .= '<br>'; if ($show_motivation == 'mandatory') { $html .= '<textarea id="motivation" class="inputbox required" name="motivation" cols="60" rows="4"></textarea><br>'; } else { $html .= '<textarea id="motivation" name="motivation" cols="60" rows="4"></textarea><br>'; } } $html .= '<br> </br>'; if ($show_experience != 'no') { $html .= JText::_('COM_JOOMDLE_EXPERIENCE'); if ($show_experience == 'mandatory') { $html .= '*'; } $html .= '<br>'; if ($show_experience == 'mandatory') { $html .= '<textarea id="experience" class="inputbox required" name="experience" cols="60" rows="4"></textarea><br>'; } else { $html .= '<textarea id="experience" name="experience" cols="60" rows="4"></textarea><br>'; } } if ($show_motivation == 'mandatory' || $show_experience == 'mandatory') { $html .= JText::_('COM_JOOMDLE_MARKED_FIELDS_MANDATORY') . "<br>"; } $html .= '<INPUT TYPE="SUBMIT" VALUE=" ' . JText::_('COM_JOOMDLE_APPLICATE_FOR_COURSE') . '"> <INPUT TYPE="hidden" name="course_id" VALUE=" ' . $course_id . ' "> <INPUT TYPE="hidden" name="option" VALUE="com_joomdle"> <INPUT TYPE="hidden" name="task" VALUE="applicate"> <input type="hidden" name="id" value="0" /> <input type="hidden" name="gid" value="0" />'; $html .= JHTML::_('form.token'); $html .= '</FORM>'; } } } } } } else { //courses in shop require_once JPATH_ADMINISTRATOR . '/components/com_joomdle/helpers/shop.php'; if ($paid_courses_button == 'buy') { if (JoomdleHelperShop::is_course_on_sell($course_info['remoteid'])) { if (!$button_text) { $button_text = JText::_('COM_JOOMDLE_BUY_COURSE'); } $url = JRoute::_(JoomdleHelperShop::get_sell_url($course_info['remoteid'])); $can_enrol = $course_info['in_enrol_date']; if ($can_enrol) { $html .= ' <FORM> <INPUT TYPE="BUTTON" VALUE=" ' . $button_text . ' " ONCLICK="window.location.href=\' ' . $url . ' \'"> </FORM>'; } } } else { if ($paid_courses_button == 'paypal') { $url = "index.php?option=com_joomdle&view=buycourse&course_id={$course_id}"; $html .= '<br><a href="' . $url . '"><img src="https://www.paypal.com/en_US/i/logo/PayPal_mark_60x38.gif"></a>'; } } } } return $html; }
function getSellUrl ($action, $params) { $course_id = $params[0]; return JoomdleHelperShop::get_sell_url ($course_id); }