Example #1
0
    require_once 'include/not_installed.php';
}
// Initialize global debug mechanism
require_once 'modules/admin/debug.php';
// Connect to database
require_once 'modules/db/database.php';
try {
    Database::get();
} catch (Exception $ex) {
    require_once 'include/not_installed.php';
}
if (isset($language)) {
    // Old-style config.php, redirect to upgrade
    $language = langname_to_code($language);
    if (isset($_SESSION['langswitch'])) {
        $_SESSION['langswitch'] = langname_to_code($_SESSION['langswitch']);
        $_SESSION['givenname'] = $_SESSION['surname'] = '';
    }
    $session = new Session();
    $uid = $session->user_id;
    $session->active_ui_languages = array($language);
    if (!defined('UPGRADE')) {
        redirect_to_home_page('upgrade/');
    }
} else {
    // Global configuration
    $siteName = get_config('site_name');
    $Institution = get_config('institution');
    $InstitutionUrl = get_config('institution_url');
    $urlServer = get_config('base_url');
    $session = new Session();
Example #2
0
/**
 * Initialize copyright/license global arrays
 */
function copyright_info($cid, $noImg = 1)
{
    global $language, $license, $themeimg;
    $lang = langname_to_code($language);
    $lic = Database::get()->querySingle("SELECT course_license FROM course WHERE id = ?d", $cid)->course_license;
    if ($lic == 0 or $lic >= 10) {
        $link_suffix = '';
    } else {
        if ($language != 'en') {
            $link_suffix = 'deed.' . $lang;
        } else {
            $link_suffix = '';
        }
    }
    if ($noImg == 1) {
        $link = "<a href='" . $license[$lic]['link'] . "{$link_suffix}'><img src='{$themeimg}/" . $license[$lic]['image'] . ".png' title='" . $license[$lic]['title'] . "' alt='" . $license[$lic]['title'] . "' /></a><br>";
    } else {
        if ($noImg == 0) {
            $link = "";
        }
    }
    return $link . q($license[$lic]['title']);
}
Example #3
0
         }
     }
 }
 // Rename table `cours` to `course` and `cours_user` to `course_user`
 if (!DBHelper::tableExists('course')) {
     DBHelper::fieldExists('cours', 'expand_glossary') or Database::get()->query("ALTER TABLE `cours` ADD `expand_glossary` BOOL NOT NULL DEFAULT 0");
     DBHelper::fieldExists('cours', 'glossary_index') or Database::get()->query("ALTER TABLE `cours` ADD `glossary_index` BOOL NOT NULL DEFAULT 1");
     Database::get()->query("RENAME TABLE `cours` TO `course`");
     Database::get()->query("UPDATE course SET description = '' WHERE description IS NULL");
     Database::get()->query("UPDATE course SET course_keywords = '' WHERE course_keywords IS NULL");
     if (DBHelper::fieldExists('course', 'course_objectives')) {
         Database::get()->query("ALTER TABLE course DROP COLUMN `course_objectives`,\n                                                DROP COLUMN `course_prerequisites`,\n                                                DROP COLUMN `course_references`");
     }
     Database::get()->query("ALTER TABLE course CHANGE `cours_id` `id` INT(11) NOT NULL AUTO_INCREMENT,\n                                             CHANGE `languageCourse` `lang` VARCHAR(16) DEFAULT 'el',\n                                             CHANGE `intitule` `title` VARCHAR(250) NOT NULL DEFAULT '',\n                                             CHANGE `description` `description` MEDIUMTEXT NOT NULL,\n                                             CHANGE `course_keywords` `keywords` TEXT NOT NULL,\n                                             DROP COLUMN `course_addon`,\n                                             CHANGE `titulaires` `prof_names` varchar(200) NOT NULL DEFAULT '',\n                                             CHANGE `fake_code` `public_code` varchar(20) NOT NULL DEFAULT '',\n                                             DROP COLUMN `departmentUrlName`,\n                                             DROP COLUMN `departmentUrl`,\n                                             DROP COLUMN `lastVisit`,\n                                             DROP COLUMN `lastEdit`,\n                                             DROP COLUMN `expirationDate`,\n                                             DROP COLUMN `type`,\n                                             DROP COLUMN `faculteid`,\n                                             CHANGE `first_create` `created` datetime NOT NULL default '0000-00-00 00:00:00',\n                                             CHANGE `expand_glossary` `glossary_expand` BOOL NOT NULL DEFAULT 0,\n                                             ADD `view_type` VARCHAR(255) NOT NULL DEFAULT 'units',\n                                             ADD `start_date` DATE NOT NULL default '0000-00-00',\n                                             ADD `finish_date` DATE NOT NULL default '0000-00-00',\n                                             DROP INDEX cours");
     Database::get()->queryFunc("SELECT DISTINCT lang from course", function ($old_lang) {
         Database::get()->query("UPDATE course SET lang = ?s WHERE lang = ?s", langname_to_code($old_lang->lang), $old_lang->lang);
     });
     Database::get()->query("RENAME TABLE `cours_user` TO `course_user`");
     Database::get()->query('ALTER TABLE `course_user`
                                         CHANGE `statut` `status` TINYINT(4) NOT NULL DEFAULT 0,
                                         CHANGE `cours_id` `course_id` INT(11) NOT NULL DEFAULT 0');
     if (DBHelper::fieldExists('course_user', 'code_cours')) {
         Database::get()->query('ALTER TABLE `course_user`
                                     DROP COLUMN `code_cours`');
     }
 }
 DBHelper::fieldExists('ebook', 'visible') or Database::get()->query("ALTER TABLE `ebook` ADD `visible` BOOL NOT NULL DEFAULT 1");
 DBHelper::fieldExists('admin', 'privilege') or Database::get()->query("ALTER TABLE `admin` ADD `privilege` INT NOT NULL DEFAULT '0'");
 DBHelper::fieldExists('course_user', 'editor') or Database::get()->query("ALTER TABLE `course_user` ADD `editor` INT NOT NULL DEFAULT '0' AFTER `tutor`");
 if (!DBHelper::fieldExists('glossary', 'category_id')) {
     Database::get()->query("ALTER TABLE glossary\n                                ADD category_id INT(11) DEFAULT NULL,\n                                ADD notes TEXT NOT NULL");
Example #4
0
define('STATIC_MODULE', 1);
require_once '../../include/baseTheme.php';
$pageName = $langCourseMetadataControlPanel;
require_once 'CourseXML.php';
// exit if feature disabled or is not reviewer
if (!get_config('opencourses_enable') || !$is_opencourses_reviewer) {
    header("Location: {$urlServer}courses/{$course_code}/index.php");
    exit;
}
// initialize data from xml and db
$xml = CourseXMLElement::init($course_id, $course_code);
$xmlData = $xml->asFlatArray();
$visible = Database::get()->querySingle("SELECT visible FROM course WHERE id = ?d", $course_id)->visible;
$hasOpenAccess = $visible == 2 || $visible == 1;
$hasMandatoryMetadata = $xml->hasMandatoryMetadata();
$clang = langname_to_code($currentCourseLanguage);
$hasLicense = isset($xmlData['course_license_' . $clang]) && !empty($xmlData['course_license_' . $clang]);
$hasTeacherConfirm = isset($xmlData['course_confirmCurriculum']) && $xmlData['course_confirmCurriculum'] == 'true';
$numDocs = Database::get()->querySingle("SELECT count(id) as count FROM document WHERE course_id = ?d", $course_id)->count;
$numUnits = Database::get()->querySingle("SELECT count(id) as count FROM course_units WHERE course_id = ?d AND `order` >= 1 AND visible = 1", $course_id)->count;
$numVideo = Database::get()->querySingle("SELECT count(id) as count FROM video WHERE course_id = ?d", $course_id)->count;
$numVideoLinks = Database::get()->querySingle("SELECT count(id) as count FROM videolink WHERE course_id = ?d", $course_id)->count;
$numMedia = $numVideo + $numVideoLinks;
$hasTeacherConfirmVideo = isset($xmlData['course_confirmVideolectures']) && $xmlData['course_confirmVideolectures'] == 'true';
// auto detect level
$looksAMinus = false;
if ($hasOpenAccess && $hasMandatoryMetadata && $hasLicense && $hasTeacherConfirm && $numDocs > 0 && $numUnits > 0) {
    $looksAMinus = true;
}
$looksA = false;
if ($looksAMinus && $numMedia > 0) {
Example #5
0
    /**
     * Populate a single simple HTML Div Element (leaf).
     * 
     * @global string $currentCourseLanguage
     * @param  string $fullKey
     * @return string
     */
    private function appendLeafDivElement($fullKey) {
        global $currentCourseLanguage;

        // init vars
        $keyLbl = (isset($GLOBALS['langCMeta'][$fullKey])) ? $GLOBALS['langCMeta'][$fullKey] : $fullKey;
        $fullKeyNoLang = $fullKey;
        $sameAsCourseLang = false;
        $lang = '';
        if ($this->getAttribute('lang')) {
            $fullKey .= '_' . $this->getAttribute('lang');
            $lang = ' (' . $GLOBALS['langCMeta'][(string) $this->getAttribute('lang')] . ')';
            if ($this->getAttribute('lang') == langname_to_code($currentCourseLanguage)) {
                $sameAsCourseLang = true;
            }
        }

        // proper divs initializations
        $fieldStart = "";
        if (array_key_exists($fullKey, CourseXMLConfig::$breakAccordionStartFields)) {
            $fieldStart .= "<div class='panel-group'>
                <div class='panel panel-default'>
                    <div class='panel-heading'>
                        <h3 class='panel-title'>
                            <a data-toggle='collapse' href='#metacollapse-" . CourseXMLConfig::$breakAccordionStartFields[$fullKey] . "'>" . $GLOBALS['langMore'] . "</a>
                        </h3>
                    </div>
                    <div id='metacollapse-" . CourseXMLConfig::$breakAccordionStartFields[$fullKey] . "' class='panel-collapse collapse'>
                        <div class='panel-body'>";
        }
        $cmetalabel = (in_array($fullKey, CourseXMLConfig::$mandatoryFields) || strpos($fullKey, 'course_unit_') === 0 || strpos($fullKey, 'course_numberOfUnits') === 0) ? 'cmetalabel cmetalabel-wd' : 'cmetalabelinaccordion cmetalabelinaccordion-wd';
        $fieldStart .= "<div class='row margin-top-thin margin-bottom-thin'><div class='col-sm-3'><strong>" . q($keyLbl . $lang) . ":</strong></div><div class='col-sm-9'>";

        $fieldEnd = "</div></div>";
        if (in_array($fullKey, CourseXMLConfig::$breakAccordionEndFields)) {
            $fieldEnd .= "</div></div></div></div>";
        }
        if (array_key_exists($fullKey, CourseXMLConfig::$breakFields)) {
            $fieldEnd .= "</div><div class='tab-pane fade' style='padding-top:20px' id='tabs-" . CourseXMLConfig::$breakFields[$fullKey] . "'>";
        }

        // hidden/auto-generated fields
        if (in_array($fullKeyNoLang, CourseXMLConfig::$hiddenFields) && (!$this->getAttribute('lang') || $sameAsCourseLang)) {
            return;
        }

        // fields hidden from anonymous users
        if ((!isset($GLOBALS['course_code']) || $_SESSION['courses'][$GLOBALS['course_code']] == 0) && in_array($fullKeyNoLang, CourseXMLConfig::$hiddenFromAnonymousFields)) {
            return;
        }

        // print nothing for empty and non-breaking-necessary fields
        if (!array_key_exists($fullKey, CourseXMLConfig::$breakAccordionStartFields) &&
                !in_array($fullKey, CourseXMLConfig::$breakAccordionEndFields) &&
                !array_key_exists($fullKey, CourseXMLConfig::$breakFields) &&
                strlen((string) $this) <= 0) {
            return;
        }

        // boolean fields
        if (in_array($fullKeyNoLang, CourseXMLConfig::$booleanFields)) {
            $value = (string) $this;
            if (empty($value)) {
                $value = 'false';
            }
            $valueOut = $GLOBALS['langCMeta'][$value];
            return $fieldStart . $valueOut . $fieldEnd;
        }

        // enumeration and multiple enumeration fields
        if (in_array($fullKeyNoLang, CourseXMLConfig::$enumerationFields)) {
            $valArr = CourseXMLConfig::getEnumerationValues($fullKey);
            $value = "";
            if (!isset($valArr[(string) $this]) && isset($GLOBALS['langCMeta'][(string) $this])) {
                $value = $GLOBALS['langCMeta'][(string) $this];
            } else {
                $value = $valArr[(string) $this];
            }
            return $fieldStart . $value . $fieldEnd;
        }

        // multiple enumeration fiels
        if (in_array($fullKeyNoLang, CourseXMLConfig::$multiEnumerationFields)) {
            $valueOut = '';
            $valArr = CourseXMLConfig::getEnumerationValues($fullKey);
            $i = 1;
            foreach (explode(',', (string) $this) as $value) {
                if ($i > 1) {
                    $valueOut .= ', ';
                }
                $valueOut .= $valArr[$value];
                $i++;
            }
            return $fieldStart . $valueOut . $fieldEnd;
        }

        // binary (file-upload) fields
        if (in_array($fullKeyNoLang, CourseXMLConfig::$binaryFields)) {
            $html = $fieldStart;
            $value = (string) $this;
            if (!empty($value)) { // image already exists
                $mime = (string) $this->getAttribute('mime');
                $html .= "<img src='data:" . q($mime) . ";base64," . q($value) . "'/>";
            }
            $html .= $fieldEnd;
            return $html;
        }

        if ($fullKey == 'course_language') {
            return $fieldStart . $GLOBALS['native_language_names_init'][((string) $this)] . $fieldEnd;
        }

        // all others get a typical printout
        return $fieldStart . q((string) $this) . $fieldEnd;
    }
Example #6
0
 /**
  * Turn a non-multiLang field into multiLang.
  * 
  * @global string $currentCourseLanguage
  * @global string $webDir
  * @global string $siteName
  * @global string $Institution
  * @global string $InstitutionUrl
  * @param  CourseXMLElement $ele
  * @return array
  */
 private static function makeMultiLang($ele)
 {
     global $currentCourseLanguage, $webDir, $siteName, $Institution, $InstitutionUrl;
     if (empty($currentCourseLanguage)) {
         $currentCourseLanguage = 'greek';
     }
     $clang = langname_to_code($currentCourseLanguage);
     $arr = array();
     $key = (string) $ele;
     if (!isset($GLOBALS['langCMeta'][$key])) {
         if ($ele->getName() === 'institution') {
             $key = 'otherinst';
         }
         if ($ele->getName() === 'thematic') {
             $key = 'othersubj';
         }
         if ($ele->getName() === 'subthematic') {
             $key = 'othersubsubj';
         }
     }
     $arr[$clang] = $GLOBALS['langCMeta'][$key];
     $revert = false;
     if ($clang != 'en') {
         include "{$webDir}/lang/en/common.inc.php";
         include "{$webDir}/lang/en/messages.inc.php";
         $arr['en'] = $langCMeta[$key];
         $revert = true;
     }
     if ($clang != 'el') {
         include "{$webDir}/lang/el/common.inc.php";
         include "{$webDir}/lang/el/messages.inc.php";
         $arr['en'] = $langCMeta[$key];
         $revert = true;
     }
     if ($revert) {
         // revert messages back to current language
         include "{$webDir}/lang/" . $currentCourseLanguage . "/common.inc.php";
         include "{$webDir}/lang/" . $currentCourseLanguage . "/messages.inc.php";
     }
     return base64_encode(serialize($arr));
 }