Пример #1
0
 function display($tpl = null)
 {
     $params = JComponentHelper::getParams('com_joomdle');
     $this->sidebar = JHtmlSidebar::render();
     if ($params->get('shop_integration') == 'no') {
         JToolbarHelper::title(JText::_('COM_JOOMDLE_VIEW_SHOP_TITLE'), 'shop');
         $this->message = JText::_('COM_JOOMDLE_SHOP_INTEGRATION_NOT_ENABLED');
         $tpl = "disabled";
         parent::display($tpl);
         return;
     }
     $this->addToolbar();
     $this->bundles = JoomdleHelperShop::get_bundles();
     $this->courses = JoomdleHelperShop::getShopCourses();
     parent::display($tpl);
 }
Пример #2
0
 static function enrol_bundle($username, $sku)
 {
     $user_id = JUserHelper::getUserId($username);
     $user = JFactory::getUser($user_id);
     $email = $user->email;
     $bundle_id = substr($sku, 7);
     $bundle = JoomdleHelperShop::get_bundle_info($bundle_id);
     $courses = explode(',', $bundle['courses']);
     $comp_params = JComponentHelper::getParams('com_joomdle');
     $send_bundle_emails = $comp_params->get('send_bundle_emails');
     $c = array();
     foreach ($courses as $course_id) {
         if ($send_bundle_emails) {
             JoomdleHelperShop::send_confirmation_email($email, $course_id);
         }
         $course['id'] = (int) $course_id;
         $c[] = $course;
     }
     JoomdleHelperContent::call_method('multiple_enrol', $username, $c, 5);
 }
Пример #3
0
    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>&nbsp;</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;
    }
Пример #4
0
 static function assign_course($course_id, $assingment)
 {
     foreach ($assingment as $user_id) {
         $user = JFactory::getUser($user_id);
         $username = $user->get('username');
         JoomdleHelperContent::enrolUser($username, $course_id);
         /* Send confirmation email */
         JoomdleHelperShop::send_confirmation_email($user->email, $course_id);
     }
     JoomdleHelperParents::update_purchase($course_id, $assingment);
 }
Пример #5
0
    function getSellUrl ($action, $params)
    {
		$course_id = $params[0];

        return JoomdleHelperShop::get_sell_url ($course_id);
    }
Пример #6
0
 function save_bundle()
 {
     $bundle['courses'] = JRequest::getVar('courses', array(), 'post', 'array');
     $bundle['name'] = JRequest::getVar('name');
     $bundle['description'] = JRequest::getVar('description');
     $bundle['cost'] = JRequest::getVar('cost');
     $bundle['currency'] = JRequest::getVar('currency');
     $bundle_id = JRequest::getVar('bundle_id');
     if ($bundle_id) {
         $bundle['id'] = $bundle_id;
     }
     JoomdleHelperShop::create_bundle($bundle);
     $this->setRedirect('index.php?option=com_joomdle&view=shop');
 }