Пример #1
0
function select_media(&$out, &$lang)
{
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.multimedia.php';
    $form = new Form();
    $from = importVar("from");
    $item_id = (int) importVar("item_id");
    $src = "";
    $title = "";
    $path = "";
    switch ($from) {
        case "cms":
            if (!canAccessCmsMedia()) {
                die("You can't access!");
            }
            $path = _FPATH_INTERNAL;
            $relative_path = _FPATH;
            $preview_path = _PPATH;
            $qtxt = "SELECT t1.fname, t1.real_fname, t1.media_url, t2.title FROM " . $GLOBALS["prefix_cms"] . "_media as t1 ";
            $qtxt .= "LEFT JOIN " . $GLOBALS["prefix_cms"] . "_media_info as t2 ON (t2.idm=t1.idMedia) ";
            $qtxt .= "WHERE t1.idMedia='" . $item_id . "' AND t1.publish='1'";
            $q = sql_query($qtxt);
            if ($q && mysql_num_rows($q) > 0) {
                $row = mysql_fetch_array($q);
                $src = $row["real_fname"];
                $title = $row["title"];
                if (!empty($row["media_url"])) {
                    $src = $row["media_url"];
                } else {
                    $src = $row["real_fname"];
                }
            }
            break;
        case "personal":
            if (!canAccessPersonalMedia()) {
                die("You can't access!");
            }
            $user_id = Docebo::user()->getIdSt();
            $path = _USER_FPATH_INTERNAL;
            $relative_path = _USER_FPATH;
            $preview_path = _USER_FPATH;
            $qtxt = "SELECT real_fname, media_url FROM " . $GLOBALS["prefix_fw"] . "_user_file ";
            $qtxt .= "WHERE id='" . $item_id . "' AND user_idst='" . $user_id . "' AND type='image'";
            $q = sql_query($qtxt);
            if ($q && mysql_num_rows($q) > 0) {
                $row = mysql_fetch_array($q);
                if (!empty($row["media_url"])) {
                    $src = $row["media_url"];
                } else {
                    $src = $row["real_fname"];
                }
            }
            break;
    }
    //	$src=rawurlencode($src);
    $res = "";
    $url = getPopupBaseUrl() . "&op=main";
    if (!empty($row["media_url"])) {
        $media_url = $row["media_url"];
        $popup_file_path = $media_url;
    } else {
        $popup_file_path = $path . $src;
    }
    addMediaPopupJS($popup_file_path);
    // TODO: remove inline style
    if (file_exists($preview_path . $src)) {
        $style = "width: 100px; padding: 2px; border: 1px solid #AAAAAA; margin-bottom: 0.4em;";
        $res .= "<img style=\"" . $style . "\" src=\"" . $preview_path . $src . "\" alt=\"" . $title . "\" title=\"" . $title . "\" />\n";
    } else {
        $media_type = getMediaType($src);
        $style = "width: 64px; padding: 2px; border: 1px solid #AAAAAA; margin-bottom: 0.4em;";
        $res .= "<img style=\"" . $style . "\" src=\"" . getPathImage('fw') . "media/" . $media_type . ".png\" alt=\"" . $title . "\" title=\"" . $title . "\" />\n";
    }
    $res .= $form->openForm("popup_form", $url, false, false, '', "onSubmit=\"insItem();\" onReset=\"closePopup();\"");
    $res .= $form->openElementSpace();
    $type = getPopupSelType();
    switch ($type) {
        case "image":
            $res .= $form->getTextfield($lang->def("_ALT_TXT"), "alt_text", "alt_text", 255, $title);
            $res .= $form->getTextfield($lang->def("_TITLE"), "title_text", "title_text", 255, $title);
            //$res.=$form->getTextfield($lang->def("_BORDER"), "border", "border", 3, "0");
            break;
        case "flash":
            $flash_info = getSwfInfoArray($relative_path . $src);
            $res .= $form->getTextfield($lang->def("_WIDTH"), "width", "width", 4, $flash_info["width"]);
            $res .= $form->getTextfield($lang->def("_HEIGHT"), "height", "height", 4, $flash_info["height"]);
            $res .= $form->getTextfield($lang->def("_BGCOLOR"), "bgcolor", "border", 7, "#FFF");
            break;
        case "audio":
        case "video":
        case "streaming":
            require_once _base_ . '/lib/lib.json.php';
            $json = new Services_JSON();
            if (!empty($media_url)) {
                $code = getStreamingEmbed($media_url, FALSE, $src);
            } else {
                $cut_from = strlen($GLOBALS["where_files_relative"]);
                $base_relative_path = $GLOBALS["base_where_files_relative"] . substr($relative_path, $cut_from);
                $current_pl = Get::cur_plat();
                $site_file_path = getPLSetting($current_pl, "url") . $base_relative_path;
                $code = getEmbedPlay($site_file_path, $src, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE);
            }
            $code = '<div>' . $code . '</div>';
            $core_url = getPLSetting("framework", "url");
            $bad_path = $GLOBALS["where_framework_relative"] . "/addons/players/";
            $good_path = $core_url . "addons/players/";
            $code = str_replace($bad_path, $good_path, $code);
            $content = array("code" => $code);
            $embed_code = $json->encode($content);
            $res .= $form->getHidden("embed_code", "embed_code", rawurlencode($embed_code));
            $res .= $src;
            break;
    }
    $res .= $form->closeElementSpace();
    $res .= $form->openButtonSpace();
    $res .= $form->getButton('apply', 'apply', $lang->def('_SAVE'));
    $res .= $form->getReset('undo', 'undo', $lang->def('_UNDO'));
    $res .= $form->closeButtonSpace();
    $res .= $form->closeForm();
    $out->add($res);
}
Пример #2
0
 require_once $GLOBALS["where_lms"] . "/lib/lib.course.php";
 require_once $GLOBALS["where_lms"] . "/modules/coursecatalogue/lib.coursecatalogue.php";
 $lang =& DoceboLanguage::createInstance('standard', 'framework');
 $lang->setGlobal();
 if (Docebo::user()->isAnonymous()) {
     $lang =& DoceboLanguage::createInstance('catalogue', 'lms');
     $lang =& DoceboLanguage::createInstance('course', 'lms');
     $man_course = new DoceboCourse(importVar('id_course', true, 0));
     $course_name = $man_course->getValue('name');
     $string = $lang->def('_THANKS_LOGIN_OR_REGISTER');
     $string = substr($string, strpos($string, '<a'));
     $subst = array('[name]' => $course_name, '[link_register]' => 'index.php?modname=login&amp;op=register');
     $value = array("next_op" => '', "id" => 'course_editions', "title" => $lang->def('_COURSE_SUBSCRIPTION', 'catalogue'), "content" => str_replace(array_keys($subst), $subst, $string));
 } else {
     if (!defined("_ECOM_CURRENCY")) {
         $currency_label = getPLSetting("ecom", "currency_label", "");
         define("_ECOM_CURRENCY", $currency_label);
     }
     $lang =& DoceboLanguage::createInstance('course', 'lms');
     $id_course = importVar('id_course', true, 0);
     $man_course = new DoceboCourse($id_course);
     $cinfo = $man_course->getAllInfo();
     $man_courseuser = new Man_CourseUser();
     $usercourses =& $man_courseuser->getUserSubscriptionsInfo(getLogUserId(), false);
     // retrive subscribed -----------------------------------------------------
     $select_count = "SELECT COUNT(*) as user_count ";
     $from_count = " FROM " . $GLOBALS["prefix_lms"] . "_courseuser AS u";
     $where_count = " WHERE u.idCourse = '" . $id_course . "' " . " AND u.level = '3'" . " AND u.status IN ('" . _CUS_CONFIRMED . "', '" . _CUS_SUBSCRIBED . "', '" . _CUS_BEGIN . "', '" . _CUS_END . "', '" . _CUS_SUSPEND . "', '" . _CUS_WAITING_LIST . "')" . " AND u.absent = '0'";
     $re_count = sql_query($select_count . $from_count . $where_count);
     list($cinfo['enrolled']) = sql_fetch_row($re_count);
     $action = relationWithCourse($cinfo['idCourse'], $cinfo, isset($usercourses[$cinfo['idCourse']]) ? $usercourses[$cinfo['idCourse']] : false, false);
Пример #3
0
/**
 * Returns the site base url of a website that means the full website
 * url without the platform-specific folder
 * example: browsing "www.mysite.com/test/appCore" you'll get
 * "www.mysite.com/test"
 */
function getSiteBaseUrl()
{
    $current_pl = Get::cur_plat();
    $url = substr(getPLSetting($current_pl, "url"), 0, -1);
    $search = str_replace("\\", '/', $GLOBALS["where_" . $current_pl]);
    $cut_from = strrpos($search, "/");
    $search = substr($search, $cut_from);
    $search = str_replace('/', '\\/', $search);
    $base_url = preg_replace('/' . $search . '/i', "", $url);
    return $base_url;
}
Пример #4
0
/**
 * Load in a global variable an array with information on bought courses or edition
 * or their reservations if ecommerce is modered by a buyer.
 */
function loadEcomItems()
{
    $GLOBALS["lms_bought_items"] = array();
    $ecom_type = getPLSetting("ecom", "ecom_type", "none");
    if ($ecom_type !== "none") {
        require_once $GLOBALS["where_ecom"] . "/admin/modules/reservation/lib.reservation.php";
        $res = array();
        $user_id = getLogUserId();
        // --- Transactions:  ------------------------------------
        // TODO: move this on a ecom lib / class[*] :
        $qtxt = "SELECT * FROM " . $GLOBALS['prefix_ecom'] . "_transaction_product WHERE id_user='******'";
        $q = sql_query($qtxt);
        $action = "transaction";
        $res[$action] = array();
        if ($q && mysql_num_rows($q) > 0) {
            while ($row = mysql_fetch_assoc($q)) {
                if (!isset($res[$action][$row["type"]]) || !in_array($row["id_prod"], $res[$action][$row["type"]])) {
                    $key = $row["id_prod"];
                    $res[$action][$row["type"]][$key] = $key;
                }
            }
        }
        // --- Reservations:  ------------------------------------
        // [*]something like this:
        $rm = new ReservationManager();
        $data_info = $rm->getReservationList(FALSE, FALSE, "user_id='" . $user_id . "'");
        $data_arr =& $data_info["data_arr"];
        $action = "reservation";
        $res[$action] = array();
        foreach ($data_arr as $item) {
            if (!isset($res[$action][$item["type"]]) || !in_array($item["product_code"], $res[$action][$item["type"]])) {
                $key = $item["product_code"];
                $res[$action][$item["type"]][$key] = $key;
            }
        }
        $GLOBALS["lms_bought_items"] = $res;
    }
}