当前位置: 首页>>代码示例>>PHP>>正文


PHP JoomdleHelperContent::enrolUser方法代码示例

本文整理汇总了PHP中JoomdleHelperContent::enrolUser方法的典型用法代码示例。如果您正苦于以下问题:PHP JoomdleHelperContent::enrolUser方法的具体用法?PHP JoomdleHelperContent::enrolUser怎么用?PHP JoomdleHelperContent::enrolUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JoomdleHelperContent的用法示例。


在下文中一共展示了JoomdleHelperContent::enrolUser方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: enrol

 function enrol()
 {
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     $course_id = JRequest::getVar('course_id');
     $course_id = (int) $course_id;
     $login_url = JoomdleHelperMappings::get_login_url($course_id);
     if (!$user->id) {
         $mainframe->redirect($login_url);
     }
     $params = $mainframe->getParams();
     /* Check that self enrolments are OK in course */
     $enrol_methods = JoomdleHelperContent::call_method('course_enrol_methods', $course_id);
     $self_ok = false;
     foreach ($enrol_methods as $method) {
         if ($method['enrol'] == 'self') {
             $self_ok = true;
             break;
         }
     }
     if (!$self_ok) {
         $url = JRoute::_("index.php?option=com_joomdle&view=detail&course_id={$course_id}");
         $message = JText::_('COM_JOOMDLE_SELF_ENROLMENT_NOT_PERMITTED');
         $this->setRedirect($url, $message);
         return;
     }
     $user = JFactory::getUser();
     $username = $user->get('username');
     JoomdleHelperContent::enrolUser($username, $course_id);
     // Redirect to course
     $url = JoomdleHelperContent::get_course_url($course_id);
     $mainframe->redirect($url);
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:33,代码来源:controller.php

示例2: update_user_enrols

function update_user_enrols()
{
    $user =& JFactory::getUser();
    $id = $user->get('id');
    $username = $user->get('username');
    $db =& JFactory::getDBO();
    $query = 'SELECT order_id from #__vm_orders where user_id=';
    $query .= "'{$id}'" . '';
    $db->setQuery($query);
    $orders = $db->loadObjectList();
    if ($db->getErrorNum()) {
        JError::raiseWarning(500, $db->stderr());
    }
    if (count($orders)) {
        foreach ($orders as $order) {
            $order_id = $order->order_id;
            $query = "SELECT order_status_code from #__vm_order_history where order_id = {$order_id} order by order_status_history_id DESC limit 1";
            $db->setQuery($query);
            $order_status = $db->loadObjectList();
            if ($db->getErrorNum()) {
                JError::raiseWarning(500, $db->stderr());
            }
            $os_code = $order_status[0]->order_status_code;
            //array es? xXX
            /* We only check confirmed orders */
            if ($os_code != 'C') {
                // XXX deberia ser configurable
                continue;
            }
            /* Order is confirmed, check if it has been processed */
            /* Check all downloads with this order_id to see it download_max > 0, 
               which means we have to enrol the user
               */
            $query = 'SELECT download_max,order_id,product_id' . ' FROM #__vm_product_download' . ' WHERE (download_max > 0) and (order_id =';
            $query .= "'{$order_id}')";
            $db->setQuery($query);
            $downloads = $db->loadObjectList();
            if ($db->getErrorNum()) {
                JError::raiseWarning(500, $db->stderr());
            }
            /* All courses in this order already processed */
            if (count($downloads) == 0) {
                continue;
            }
            foreach ($downloads as $download) {
                $product_id = $download->product_id;
                $query = 'SELECT product_sku' . ' FROM #__vm_product' . ' WHERE product_id =';
                $query .= "'{$product_id}'";
                $db->setQuery($query);
                $products = $db->loadObjectList();
                if (count($products)) {
                    foreach ($products as $product) {
                        $sku = $product->product_sku;
                    }
                }
                if ($db->getErrorNum()) {
                    JError::raiseWarning(500, $db->stderr());
                }
                JoomdleHelperContent::enrolUser($username, $sku);
                //echo "You have been enrroled in the course";
                $query = "UPDATE #__vm_product_download set download_max=0 where product_id='{$product_id}'";
                $db->setQuery($query);
                if (!$db->query()) {
                    return JError::raiseWarning(500, $db->getError());
                }
            }
        }
    }
}
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:69,代码来源:helper.php

示例3: add_order_enrols_vm2

 static function add_order_enrols_vm2($order_id, $user_id)
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser($user_id);
     $username = $user->username;
     $email = $user->email;
     /* Update user profile in Moodle  with VM data, if necessary */
     JoomdleHelperContent::call_method('create_joomdle_user', $username);
     $order_id = $db->Quote($order_id);
     $query = 'SELECT *' . ' FROM #__virtuemart_order_items' . ' WHERE virtuemart_order_id =';
     $query .= "{$order_id}";
     $db->setQuery($query);
     $items = $db->loadObjectList();
     if ($db->getErrorNum()) {
         JError::raiseWarning(500, $db->stderr());
     }
     /* No items in this order */
     if (count($items) == 0) {
         return;
     }
     $params = JComponentHelper::getParams('com_joomdle');
     $buy_for_children = $params->get('buy_for_children');
     $courses_category = $params->get('courses_category');
     foreach ($items as $item) {
         /* Only process product in Courses category */
         $product_id = $item->virtuemart_product_id;
         $order_item_id = $item->virtuemart_order_item_id;
         $query = "SELECT virtuemart_category_id" . " FROM #__virtuemart_product_categories" . " WHERE virtuemart_product_id=" . $db->Quote($product_id);
         $db->setQuery($query);
         $cats = $db->loadAssocList();
         $cats_array = array();
         foreach ($cats as $cat) {
             $cats_array[] = $cat['virtuemart_category_id'];
         }
         if ($db->getErrorNum()) {
             JError::raiseWarning(500, $db->stderr());
         }
         /* If it is a course */
         if (in_array($courses_category, $cats_array)) {
             $sku = $item->order_item_sku;
             if ($buy_for_children) {
                 if (strncmp($item->order_item_sku, 'bundle_', 7) == 0) {
                     //bundle
                     JoomdleHelperParents::purchase_bundle($username, $sku, $item->product_quantity);
                 } else {
                     JoomdleHelperParents::purchase_course($username, $sku, $item->product_quantity);
                 }
             } else {
                 if (strncmp($item->order_item_sku, 'bundle_', 7) == 0) {
                     //bundle
                     JoomdleHelperShop::enrol_bundle($username, $sku);
                 } else {
                     //course
                     JoomdleHelperContent::enrolUser($username, $sku);
                     /* Send confirmation email */
                     JoomdleHelperShop::send_confirmation_email($email, $sku);
                 }
             }
         }
     }
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:61,代码来源:shop.php

示例4: approve_applications

 static function approve_applications($cid)
 {
     $db = JFactory::getDBO();
     foreach ($cid as $id) {
         /* get application info */
         $query = "SELECT *\n\t\t\t\t\t\tFROM #__joomdle_course_applications  where id = " . $db->Quote($id);
         $db->setQuery($query);
         $app = $db->loadAssoc();
         $user_id = $app['user_id'];
         $user = JFactory::getUser($user_id);
         $username = $user->username;
         $course_id = $app['course_id'];
         $date = JFactory::getDate();
         $confirmation_date = $date->toSql();
         /* Mark as approved */
         $query = "update  #__joomdle_course_applications set state=" . JOOMDLE_APPLICATION_STATE_APPROVED . ", confirmation_date = '{$confirmation_date}' where id = " . $db->Quote($id);
         $db->setQuery($query);
         $db->query();
         /* Enrol user in course */
         JoomdleHelperContent::enrolUser($username, $course_id);
         /* Send message to user */
         JoomdleHelperApplications::send_confirmation_email($username, $user->email, $course_id, JOOMDLE_APPLICATION_STATE_APPROVED);
     }
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:24,代码来源:applications.php

示例5: assign_course

 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);
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:11,代码来源:parents.php


注:本文中的JoomdleHelperContent::enrolUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。