Example #1
2
/**
 * Validates imported data.
 */
function validate_data($users)
{
    global $defined_auth_sources;
    $errors = array();
    $usernames = array();
    if (is_array($users)) {
        foreach ($users as $index => $user) {
            // 1. Check whether mandatory fields have been set.
            $mandatory_fields = array('LastName', 'FirstName');
            if (api_get_setting('registration', 'email') == 'true') {
                $mandatory_fields[] = 'Email';
            }
            foreach ($mandatory_fields as $key => $field) {
                if (!isset($user[$field]) || strlen($user[$field]) == 0) {
                    $user['error'] = get_lang($field . 'Mandatory');
                    $errors[] = $user;
                }
            }
            // 2. Check username.
            if (!UserManager::is_username_empty($user['UserName'])) {
                // 2.1. Check whether username was used twice in the import file.
                if (isset($usernames[$user['UserName']])) {
                    $user['error'] = get_lang('UserNameUsedTwice');
                    $errors[] = $user;
                }
                $usernames[$user['UserName']] = 1;
                // 2.2. Check whether username is allready in use in database.
                if (!UserManager::is_username_available($user['UserName'])) {
                    $user['error'] = get_lang('UserNameNotAvailable');
                    $errors[] = $user;
                }
                // 2.3. Check whether username is too long.
                if (UserManager::is_username_too_long($user['UserName'])) {
                    $user['error'] = get_lang('UserNameTooLong');
                    $errors[] = $user;
                }
            }
            // 3. Check status.
            if (isset($user['Status']) && !api_status_exists($user['Status'])) {
                $user['error'] = get_lang('WrongStatus');
                $errors[] = $user;
            }
            // 4. Check classname.
            if (isset($user['ClassName']) && strlen($user['ClassName']) != 0) {
                if (!ClassManager::class_name_exists($user['ClassName'])) {
                    $user['error'] = get_lang('ClassNameNotAvailable');
                    $errors[] = $user;
                }
            }
            // 5. Check authentication source.
            if (isset($user['AuthSource']) && strlen($user['AuthSource']) != 0) {
                if (!in_array($user['AuthSource'], $defined_auth_sources)) {
                    $user['error'] = get_lang('AuthSourceNotAvailable');
                    $errors[] = $user;
                }
            }
        }
    }
    return $errors;
}
function reports_template_exercicesMultiCourses_getSQL()
{
    // foreach quiz
    $result = array();
    $columns = Database::query('select r.id as kid, c.title as course, ' . 'r.child_name as test from ' . Database::get_main_table(TABLE_MAIN_REPORTS_KEYS) . ' r, ' . Database::get_main_table(TABLE_MAIN_COURSE) . ' c ' . 'where r.course_id=c.id and r.tool_id=' . reports_getToolId(TOOL_QUIZ) . ' order by r.course_id, r.child_name');
    if (Database::num_rows($columns) == 0) {
        die('<b>' . get_lang('no data found') . '</b>');
    }
    $query = 'select u.lastname Name, u.firstname Firstname';
    $columns = Database::store_result($columns);
    if ($_REQUEST['tattempt'] == 'min' || $_REQUEST['tattempt'] == 'max') {
        $function = $_REQUEST['tattempt'];
    } else {
        $function = 'avg';
    }
    foreach ($columns as $key => $column) {
        $query .= ', ' . $function . '(k' . $key . '.score) as `' . $column['course'] . ' - ' . $column['test'] . '` ';
    }
    $query .= ' from ' . Database::get_main_table(TABLE_MAIN_USER) . ' u ';
    foreach ($columns as $key => $column) {
        // fixme sessions
        $query .= 'left outer join ' . Database::get_main_table(TABLE_MAIN_REPORTS_VALUES) . ' k' . $key . ' on k' . $key . '.key_id = ' . $column['kid'] . ' and k' . $key . '.user_id = u.user_id ';
    }
    $query .= ' group by ';
    foreach ($columns as $key => $column) {
        // grouping attempt
        $query .= 'k' . $key . '.attempt, ';
    }
    $query = substr($query, 0, -2);
    // removing last ', ';
    return $query;
}
 /**
  * Constructor
  */
 function MultipleAnswerCombinationTrueFalse()
 {
     parent::question();
     $this->type = MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE;
     $this->isContent = $this->getIsContent();
     $this->options = array('1' => get_lang('True'), '0' => get_lang('False'), '2' => get_lang('DontKnow'));
 }
function exec_ogp_module()
{
    global $db;
    global $view;
    $group_id = $_REQUEST['group_id'];
    if (!$db->isAdmin($_SESSION['user_id'])) {
        $result = $db->getUserGroupList($_SESSION['user_id']);
        foreach ($result as $row) {
            if ($row['group_id'] == $group_id) {
                $own_group = TRUE;
            }
        }
    }
    if (!$db->isAdmin($_SESSION['user_id']) && !isset($own_group)) {
        echo "<p class='note'>" . get_lang('not_available') . "</p>";
        return;
    }
    if (isset($_POST['add_user_to_group'])) {
        $group_id = trim($_POST['group_id']);
        $user_id = trim($_POST['user_to_add']);
        $username = $db->getUserById($user_id);
        $group_name = $db->getGroupById($group_id);
        if (!$db->addUsertoGroup($user_id, $group_id)) {
            print_failure(get_lang_f('could_not_add_user_to_group', $username['users_login'], $group_name['group_name']));
            $view->refresh("?m=user_admin&amp;p=show_groups");
            return;
        }
        echo "<p class='success'>" . get_lang_f('successfully_added_to_group', $username['users_login'], $group_name['group_name']) . "</p>";
        $db->logger(get_lang_f('successfully_added_to_group', $username['users_login'], $group_name['group_name']));
        $view->refresh("?m=user_admin&amp;p=show_groups");
    }
}
Example #5
0
 /**
  * Export a whole Wiki to a single HTML String
  * @return  string Wiki content in HTML
  */
 public function export()
 {
     $pageList = $this->wiki->allPagesByCreationDate();
     $result = $this->_htmlHeader();
     $result .= '<h1>' . $this->wiki->getTitle() . '</h1>' . "\n";
     foreach ($pageList as $page) {
         $wikiPage = new WikiPage($this->wiki->getDatabaseConnection(), $this->wiki->getConfig(), $this->wiki->getWikiId());
         $wikiPage->loadPage($page['title']);
         $this->setOpt('note_prefix', $page['title']);
         if ($wikiPage->hasError()) {
             $result .= '<h2><a name="' . $this->_makePageTitleAnchor($page['title']) . '">' . $page['title'] . '</a></h2>' . "\n";
             $result .= get_lang("Could not load page %page", array('%page' => $page['title'])) . "\n";
             $wikiPage = null;
         } else {
             $pgTitle = $wikiPage->getTitle();
             if ('__MainPage__' === $pgTitle) {
                 $pgTitle = get_lang('Main page');
             }
             $result .= '<h2><a name="' . $this->_makePageTitleAnchor($page['title']) . '">' . $pgTitle . '</a></h2>' . "\n";
             $content = $wikiPage->getContent();
             $result .= $this->render($content) . "\n";
             $wikiPage = null;
         }
     }
     $result .= $this->_htmlFooter();
     return $result;
 }
 function prepare_skill_box($skill, $position, $class)
 {
     $block_id = $skill['id'];
     $extra_class = 'third_window';
     if ($skill['parent_id'] == 0) {
         $extra_class = 'second_window';
     }
     $this->html .= '<div id="block_' . $block_id . '" class = "open_block window ' . $extra_class . '  ' . $class . '" style = "top:' . $position['y'] . 'px; left:' . $position['x'] . 'px;">';
     /*$gradebook_string = '';
       if (!empty($skill['gradebooks'])) {
           foreach ($skill['gradebooks'] as $gradebook) {
               //uncomment this to show the gradebook tags
               $gradebook_string .= Display::span($gradebook['name'], array('class'=>'label_tag gradebook','style'=>'width:50px')).'<br />';    
           }
       } */
     $content = $skill['name'];
     $content .= '<div class="btn-group">';
     $content .= Display::url(get_lang('Edit'), '#', array('id' => 'edit_block_' . $block_id, 'class' => 'edit_block btn'));
     $content .= Display::url('+', '#', array('id' => 'edit_block_' . $block_id, 'class' => 'edit_block btn'));
     $content .= '</div>';
     $this->html .= $content . ' ' . $gradebook_string;
     if ($this->type == 'edit' && $skill['parent_id'] != 0) {
         //$this->html .= Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), '#', array('id'=>'edit_block_'.$block_id,'class'=>'edit_block'));
         //$this->html .= Display::url(Display::return_icon('add.png', get_lang('Add'), array(), ICON_SIZE_SMALL), '#', array('id'=>'edit_block_'.$block_id,'class'=>'edit_block'));
         //$this->html .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), '#', array('id=>"edit_block_'.$block_id,'class'=>'edit_block'));
         //$this->html .= Display::url(Display::return_icon('up.png', get_lang('Close'), array(), ICON_SIZE_SMALL), '#', array('id'=>'close_block_'.$block_id,'class'=>'close_block'));
         //$this->html .= Display::url(Display::return_icon('down.png', get_lang('Open'), array(), ICON_SIZE_SMALL), '#', array('id'=>'open_block_'.$block_id,'class'=>'open_block'));
     }
     $this->html .= '</div>';
 }
 /**
  * Builds the form
  */
 protected function build_create()
 {
     $this->addElement('header', get_lang('MakeLink'));
     $select = $this->addElement('select', 'select_link', get_lang('ChooseLink'), null, array('onchange' => 'document.create_link.submit()'));
     $linkTypes = LinkFactory::get_all_types();
     $select->addoption('[' . get_lang('ChooseLink') . ']', 0);
     $courseCode = $this->category_object->get_course_code();
     foreach ($linkTypes as $linkType) {
         // The hot potatoe link will be added "inside" the exercise option.
         if ($linkType == LINK_HOTPOTATOES) {
             continue;
         }
         $link = $this->createLink($linkType, $courseCode);
         // disable this element if the link works with a dropdownlist
         // and if there are no links left
         if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') {
             $select->addoption($link->get_type_name(), $linkType, 'disabled');
         } else {
             if ($link->get_type() == LINK_EXERCISE) {
                 // Adding exercise
                 $select->addoption($link->get_type_name(), $linkType);
                 // Adding hot potatoes
                 $linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode);
                 $select->addoption('&nbsp;&nbsp;&nbsp;' . $linkHot->get_type_name(), LINK_HOTPOTATOES);
             } else {
                 $select->addoption($link->get_type_name(), $linkType);
             }
         }
     }
     if (isset($this->extra)) {
         $this->setDefaults(array('select_link' => $this->extra));
     }
 }
Example #8
0
 /**
  * Get the necessary javascript for this datepicker
  * @return string
  */
 private function getElementJS()
 {
     $js = null;
     $id = $this->getAttribute('id');
     $js .= "<script>\n            \$(function() {\n                /*\$('#{$id}').hide().datepicker({\n                    defaultDate: '" . $this->getValue() . "',\n                    dateFormat: 'yy-mm-dd',\n                    altField: '#{$id}_alt',\n                    altFormat: \"" . get_lang('DateFormatLongNoDayJS') . "\",\n                    showOn: 'both',\n                    buttonImage: '" . Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true) . "',\n                    buttonImageOnly: true,\n                    buttonText: '" . get_lang('SelectDate') . "',\n                    changeMonth: true,\n                    changeYear: true,\n                    yearRange: 'c-60y:c+5y'\n                });*/\n\n                 \$('#{$id}').datetimepicker({\n                    defaultDate: '" . $this->getValue() . "',\n                    format: 'YYYY-MM-DD'\n                });\n\n            });\n        </script>";
     return $js;
 }
/**
 *  Filter to display the modify-buttons
 *
 *  @param  -   int     $id     The reservation-id
 */
function modify_filter($id)
{
    $out = ' <a href="m_reservation.php?action=accept&amp;rid=' . $id . '" alt="' . get_lang('AutoAccept') . '"><img title="' . get_lang('AutoAccept') . '"  alt="' . get_lang('AutoAccept') . '" src="../img/students.gif" /></a>';
    $out .= '<a href="m_reservation.php?action=edit&amp;id=' . $id . '" alt="' . get_lang('EditBookingPeriod') . '"><img title="' . get_lang('EditBookingPeriod') . '" alt="' . get_lang('EditBookingPeriod') . '" src="../img/edit.gif" /></a>';
    $out .= ' <a href="m_reservation.php?action=delete&amp;id=' . $id . '" alt="' . get_lang('DeleteBookingPeriod') . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang("ConfirmDeleteBookingPeriod"))) . "'" . ')) return false;"><img title="' . get_lang('DeleteBookingPeriod') . '" alt="' . get_lang('DeleteBookingPeriod') . '" src="../img/delete.gif" /></a>';
    return $out;
}
Example #10
0
 /**
  * Get area wiki syntax toolbar
  * @return string toolbar javascript code
  */
 public function getToolbar()
 {
     $toolbar = '';
     $toolbar .= '<script type="text/javascript" src="' . document_web_path() . '/js/toolbar.js"></script>' . "\n";
     $toolbar .= "<script type=\"text/javascript\">if (document.getElementById) {\n    var tb = new dcToolBar(document.getElementById('" . $this->attributeList['id'] . "'),\n    'wiki','" . get_module_url('CLWIKI') . "/img/toolbar/');\n\n    tb.btStrong('" . get_lang('Bold') . "');\n    tb.btEm('" . get_lang('Italic') . "');\n    tb.btIns('" . get_lang('Underline') . "');\n    tb.btDel('" . get_lang('Strike') . "');\n    tb.btQ('" . get_lang('Inline quote') . "');\n    tb.btCode('" . get_lang('Code') . "');\n    tb.addSpace(10);\n    tb.btBr('" . get_lang('Line break') . "');\n    tb.addSpace(10);\n    tb.btBquote('" . get_lang('Blockquote') . "');\n    tb.btPre('" . get_lang('Preformated text') . "');\n    tb.btList('" . get_lang('Unordered list') . "','ul');\n    tb.btList('" . get_lang('Ordered list') . "','ol');\n    tb.addSpace(10);\n    tb.btLink('" . get_lang('External link') . "','" . get_lang('URL?') . "','" . get_lang('Language') . "','" . $GLOBALS['iso639_1_code'] . "');\n    tb.btImgLink('" . get_lang('External image') . "','" . get_lang('URL') . "');\n    tb.draw('');\n}\n</script>\n";
     return $toolbar;
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->type = MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE;
     $this->isContent = $this->getIsContent();
     $this->options = array('1' => get_lang('True'), '0' => get_lang('False'), '2' => get_lang('DontKnow'));
 }
Example #12
0
function get_file_upload_errstring_from_errno($errorLevel)
{
    if (!defined('UPLOAD_ERR_CANT_WRITE')) {
        // Introduced in PHP 5.1.0
        define('UPLOAD_ERR_CANT_WRITE', 5);
    }
    switch ($errorLevel) {
        case UPLOAD_ERR_OK:
            $details = get_lang('No error');
        case UPLOAD_ERR_INI_SIZE:
            $details = get_lang('File too large. Notice : Max file size %size', array('%size' => get_cfg_var('upload_max_filesize')));
            break;
        case UPLOAD_ERR_FORM_SIZE:
            $details = get_lang('File size exceeds');
            break;
        case UPLOAD_ERR_PARTIAL:
            $details = get_lang('File upload incomplete');
            break;
        case UPLOAD_ERR_NO_FILE:
            $details = get_lang('No file uploaded');
            break;
        case UPLOAD_ERR_NO_TMP_DIR:
            $details = get_lang('Temporary folder missing');
            break;
        case UPLOAD_ERR_CANT_WRITE:
            $details = get_lang('Failed to write file to disk');
            break;
        default:
            $details = get_lang('Unknown error code %errCode%', array('%errCode%' => $errorLevel));
            break;
    }
    return $details;
}
Example #13
0
 /**
  * constructor
  * @path the path to a folder
  * @calculateSubdir force to get the subdirectories information
  */
 function __construct($path = null, $calculateSubdir = true)
 {
     $this->calculateSubdir = $calculateSubdir;
     if (defined('CONFIG_SYS_FOLDER_SHOWN_ON_TOP')) {
         $this->forceFolderOnTop = CONFIG_SYS_FOLDER_SHOWN_ON_TOP;
     }
     if (!is_null($path)) {
         $this->currentFolderPath = $path;
     } elseif (isset($_GET[$this->folderPathIndex]) && file_exists(base64_decode($_GET[$this->folderPathIndex])) && !is_file(base64_decode($_GET[$this->folderPathIndex]))) {
         $this->currentFolderPath = api_htmlentities(Security::remove_XSS($_GET[$this->folderPathIndex]));
     } elseif (isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex])) {
         $this->currentFolderPath = $_SESSION[$this->lastVisitedFolderPathIndex];
     } else {
         $this->currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
     }
     $this->currentFolderPath = isUnderRoot($this->getCurrentFolderPath()) ? backslashToSlash(addTrailingSlash($this->getCurrentFolderPath())) : $this->currentFolderPath;
     $this->currentFolderPath = base64_encode($this->currentFolderPath);
     if ($this->calculateSubdir) {
         // keep track of this folder path in session
         $_SESSION[$this->lastVisitedFolderPathIndex] = $this->currentFolderPath;
     }
     if (is_dir($this->getCurrentFolderPath())) {
         $file = new file($this->getCurrentFolderPath());
         $folderInfo = $file->getFileInfo();
         if (sizeof($folderInfo)) {
             //for Chamilo in a name folder, replace num user by user names
             if (preg_match('/sf_user_/', basename($this->getCurrentFolderPath()))) {
                 $userinfo = api_get_user_info(substr(basename($this->getCurrentFolderPath()), 8));
                 $this->currentFolderInfo['name'] = $userinfo['complete_name'];
             } else {
                 $this->currentFolderInfo['name'] = str_replace('_', ' ', basename($this->getCurrentFolderPath()));
                 //for Chamilo. Prevent long directory name
             }
             if (preg_match('/shared_folder/', basename($this->getCurrentFolderPath()))) {
                 $this->currentFolderInfo['name'] = get_lang('UserFolders');
             }
             if (preg_match('/shared_folder_session_/', basename($this->getCurrentFolderPath()))) {
                 $session = explode('_', basename($this->getCurrentFolderPath()));
                 $session = strtolower($session[sizeof($session) - 1]);
                 $this->currentFolderInfo['name'] = get_lang('UserFolders') . ' (' . api_get_session_name($session) . ')*';
             }
             //end Chamilo
             $this->currentFolderInfo['subdir'] = 0;
             $this->currentFolderInfo['file'] = 0;
             $this->currentFolderInfo['ctime'] = $folderInfo['ctime'];
             $this->currentFolderInfo['mtime'] = $folderInfo['mtime'];
             $this->currentFolderInfo['is_readable'] = $folderInfo['is_readable'];
             $this->currentFolderInfo['is_writable'] = $folderInfo['is_writable'];
             $this->currentFolderInfo['path'] = $this->getCurrentFolderPath();
             $this->currentFolderInfo['path_base64'] = base64_encode($this->getCurrentFolderPath());
             $this->currentFolderInfo['friendly_path'] = transformFilePath($this->getCurrentFolderPath());
             $this->currentFolderInfo['type'] = 'folder';
             $this->currentFolderInfo['cssClass'] = 'folder';
             //$this->currentFolderInfo['flag'] = $folderInfo['flag'];
         }
     }
     if ($calculateSubdir && !file_exists($this->getCurrentFolderPath())) {
         die(ERR_FOLDER_NOT_FOUND . $this->getCurrentFolderPath());
     }
 }
function exec_ogp_module()
{
    global $db;
    echo "<h2>" . get_lang('game_servers') . "</h2>";
    echo "<p><a href='?m=user_games&amp;p=add'>" . get_lang('add_new_game_home') . "</a></p>";
    $game_homes = $db->getGameHomes();
    if (empty($game_homes)) {
        echo "<p>" . get_lang('no_game_homes_found') . "</p>";
        return;
    }
    echo "<h2>" . get_lang('available_game_homes') . "</h2>";
    echo '<table class="center">';
    echo "<tr><th>" . get_lang('home_id') . "</th><th>" . get_lang('game_server') . "</th>\n        <th>" . get_lang('game_type') . "</th>\n        <th align='center'>" . get_lang('game_home') . "</th>\n        <th>" . get_lang('game_home_name') . "</th><th>" . get_lang('actions') . "</th></tr>";
    $i = 0;
    sort($game_homes);
    foreach ($game_homes as $row) {
        echo "<tr class='tr" . $i++ % 2 . "'><td class='tdh'>{$row['home_id']}</td><td>" . $row['agent_ip'] . "</td>" . "<td class='tdh'>{$row['game_name']}</td><td>{$row['home_path']}<br><div class='size' id='" . $row["home_id"] . "' style='cursor:pointer;' >[" . get_lang('get_size') . "]</div></td><td class='tdh'>";
        echo empty($row['home_name']) ? get_lang('not_available') : $row['home_name'];
        echo "</td><td>\n            <a href='?m=user_games&amp;p=del&amp;home_id={$row['home_id']}'>[" . get_lang('delete') . "]</a>\n            <a href='?m=user_games&amp;p=edit&amp;home_id={$row['home_id']}'>[" . get_lang('edit') . "]</a>\n            <a href='?m=user_games&amp;p=clone&amp;home_id={$row['home_id']}'>[" . get_lang('clone') . "]</a>\n            </td></tr>";
    }
    echo "<tr><td colspan='3' style='border:none;' ></td><td style='border:none;' ><div style='float:left;margin-left:5px;' >" . get_lang('total_size') . ":</div><div class='size' id='total' " . "style='cursor:pointer;float:left;margin-left:5px;' >[" . get_lang('get_size') . "]</div></td><td colspan='2' style='border:none;' ></td></tr>";
    echo "</table>";
    ?>
	<script type="text/javascript">
	$('.size').click(function(){
		var $id = $(this).attr('id');
		$.get( "home.php?m=user_games&type=cleared&p=get_size&home_id="+$id, function( data ) {
			$('#'+$id+".size").text( data );
		});
	});
	</script>
	<?php 
}
 public function get_announcement_data($username, $password, $course_code, $announcement_id, $field)
 {
     if ($this->verifyUserPass($username, $password) == "valid") {
         $htmlcode = false;
         $user_id = UserManager::get_user_id_from_username($username);
         $result = self::get_announcements($username, $course_code, $announcement_id);
         while ($announcement = Database::fetch_array($result)) {
             $announcements[] = $announcement;
         }
         switch ($field) {
             case 'sender':
                 $field_table = "insert_user_id";
                 $sender = api_get_user_info($announcements[0][$field_table]);
                 $announcements[0][$field_table] = $sender['firstname'] . " " . $sender['lastname'];
                 break;
             case 'title':
                 $htmlcode = true;
                 $field_table = "title";
                 break;
             case 'date':
                 $field_table = "end_date";
                 break;
             case 'content':
                 $htmlcode = true;
                 $field_table = "content";
                 $announcements[0][$field_table] = nl2br_revert($announcements[0][$field_table]);
                 break;
             default:
                 $field_table = "title";
         }
         return htmlcode ? html_entity_decode($announcements[0][$field_table]) : $announcements[0][$field_table];
     } else {
         return get_lang('InvalidId');
     }
 }
function lp_upload_quiz_main()
{
    // variable initialisation
    $lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : null;
    $form = new FormValidator('upload', 'POST', api_get_self() . '?' . api_get_cidreq() . '&lp_id=' . $lp_id, '', array('enctype' => 'multipart/form-data'));
    $form->addElement('header', get_lang('ImportExcelQuiz'));
    $form->addElement('file', 'user_upload_quiz', get_lang('FileUpload'));
    $link = '<a href="../exercice/quiz_template.xls">' . Display::return_icon('export_excel.png', get_lang('DownloadExcelTemplate')) . get_lang('DownloadExcelTemplate') . '</a>';
    $form->addElement('label', '', $link);
    $table = new HTML_Table(array('class' => 'table'));
    $tableList = array(UNIQUE_ANSWER => get_lang('UniqueSelect'), MULTIPLE_ANSWER => get_lang('MultipleSelect'), FILL_IN_BLANKS => get_lang('FillBlanks'), MATCHING => get_lang('Matching'), FREE_ANSWER => get_lang('FreeAnswer'), GLOBAL_MULTIPLE_ANSWER => get_lang('GlobalMultipleAnswer'));
    $table->setHeaderContents(0, 0, get_lang('QuestionType'));
    $table->setHeaderContents(0, 1, '#');
    $row = 1;
    foreach ($tableList as $key => $label) {
        $table->setCellContents($row, 0, $label);
        $table->setCellContents($row, 1, $key);
        $row++;
    }
    $table = $table->toHtml();
    $form->addElement('label', get_lang('QuestionType'), $table);
    $form->addElement('checkbox', 'user_custom_score', null, get_lang('UseCustomScoreForAllQuestions'), array('id' => 'user_custom_score'));
    $form->addElement('html', '<div id="options" style="display:none">');
    $form->addElement('text', 'correct_score', get_lang('CorrectScore'));
    $form->addElement('text', 'incorrect_score', get_lang('IncorrectScore'));
    $form->addElement('html', '</div>');
    $form->addRule('user_upload_quiz', get_lang('ThisFieldIsRequired'), 'required');
    $form->add_progress_bar();
    $form->addButtonUpload(get_lang('Upload'), 'submit_upload_quiz');
    // Display the upload field
    $form->display();
}
function exec_ogp_module()
{
    global $db;
    echo '<h2>' . get_lang('users') . "</h2>";
    echo "<p><a href='?m=user_admin&amp;p=add'>" . get_lang('add_new_user') . "</a></p>";
    echo '<table class="center" style="width: 100%;">';
    echo '<tr><th>' . get_lang('actions') . "</th><th>" . get_lang('username') . "</th>";
    echo "<th>" . get_lang('user_role') . "</th>";
    echo "<th>" . get_lang('email_address') . "</th>";
    echo "<th>" . get_lang('expires') . "</th>";
    echo "<th>" . get_lang('ownedby') . "</th></tr>";
    $result = $db->getUserList();
    $i = 0;
    foreach ($result as $row) {
        // Show user's parent
        $ownedBy = "";
        if (is_null($row['users_parent'])) {
            if ($row['users_role'] != "admin") {
                $ownedBy = "Root Admin";
            }
        } else {
            $ownedBy = $db->getUserById($row['users_parent']);
            $ownedBy = $ownedBy['users_login'];
        }
        $user_expires = read_expire($row['user_expires']);
        print "<tr class='tr" . $i++ % 2 . "'>";
        print "<td><a href='?m=user_games&amp;p=assign&amp;user_id={$row['user_id']}'>[" . get_lang('assign_homes') . "]</a><br />\n            <a href='?m=user_admin&amp;p=del&amp;user_id={$row['user_id']}'>[" . get_lang('delete') . "]</a><br />\n            <a href='?m=user_admin&amp;p=edit_user&amp;user_id={$row['user_id']}'>[" . get_lang('edit_profile') . "]</a></td>\n            <td>{$row['users_login']}</td><td>{$row['users_role']}</td>\n            <td>{$row['users_email']}</td>\n            <td>{$user_expires}</td>\n            <td>{$ownedBy}</td></tr>";
    }
    echo '</table>';
}
Example #18
0
 /**
  * Render content
  */
 public function render()
 {
     CssLoader::getInstance()->load('profile', 'all');
     load_kernel_config('user_profile');
     $userData = user_get_properties($this->userId);
     $pictureUrl = '';
     if (get_conf('allow_profile_picture')) {
         $picturePath = user_get_picture_path($userData);
         if ($picturePath && file_exists($picturePath)) {
             $pictureUrl = user_get_picture_url($userData);
         } else {
             $pictureUrl = get_icon_url('nopicture');
         }
     }
     $userFullName = claro_htmlspecialchars(get_lang('%firstName %lastName', array('%firstName' => $userData['firstname'], '%lastName' => $userData['lastname'])));
     $dock = new ClaroDock('userProfileBox');
     $template = new CoreTemplate('user_profilebox.tpl.php');
     $template->assign('userId', $this->userId);
     $template->assign('pictureUrl', $pictureUrl);
     $template->assign('userFullName', $userFullName);
     $template->assign('dock', $dock);
     $template->assign('condensedMode', $this->condensedMode);
     $template->assign('userData', $userData);
     return $template->render();
 }
Example #19
0
    function head()
    {
        $lang = "en";
        if (function_exists('get_lang')) {
            // since Adminer 3.2.0
            $lang = get_lang();
            $lang = $lang == "zh" ? "zh-cn" : ($lang == "zh-tw" ? "zh" : $lang);
            if (!file_exists(dirname($this->path) . "/langs/{$lang}.js")) {
                $lang = "en";
            }
        }
        ?>
<script type="text/javascript" src="<?php 
        echo h($this->path);
        ?>
"></script>
<script type="text/javascript">
tinyMCE.init({
	mode: 'none',
	theme: 'advanced',
	plugins: 'contextmenu,paste,table',
	entity_encoding: 'raw',
	theme_advanced_buttons1: 'bold,italic,link,unlink,|,sub,sup,|,bullist,numlist,|,cleanup,code',
	theme_advanced_buttons2: 'tablecontrols',
	theme_advanced_buttons3: '',
	theme_advanced_toolbar_location: 'top',
	theme_advanced_toolbar_align: 'left',
	language: '<?php 
        echo $lang;
        ?>
'
});
</script>
<?php 
    }
Example #20
0
/**
 * CLAROLINE
 *
 * @version     $Revision: 14314 $
 * @copyright   (c) 2001-2011, Universite catholique de Louvain (UCL)
 * @license     http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE
 * @author      Piraux Sebastien <*****@*****.**>
 * @author      Lederer Guillaume <*****@*****.**>
 * @package     CLLNP
 * @since       1.8
 */
function lp_display_scorm($TABLELEARNPATHMODULE)
{
    $out = '';
    // change raw if value is a number between 0 and 100
    if (isset($_POST['newRaw']) && is_num($_POST['newRaw']) && $_POST['newRaw'] <= 100 && $_POST['newRaw'] >= 0) {
        $sql = "UPDATE `" . $TABLELEARNPATHMODULE . "`\n                SET `raw_to_pass` = " . (int) $_POST['newRaw'] . "\n                WHERE `module_id` = " . (int) $_SESSION['module_id'] . "\n                AND `learnPath_id` = " . (int) $_SESSION['path_id'];
        claro_sql_query($sql);
        $dialogBoxContent = get_lang('Minimum raw to pass has been changed');
    }
    $out .= '<hr noshade="noshade" size="1" />';
    //####################################################################################\\
    //############################### DIALOG BOX SECTION #################################\\
    //####################################################################################\\
    if (!empty($dialogBoxContent)) {
        $dialogBox = new DialogBox();
        $dialogBox->success($dialogBoxContent);
        $out .= $dialogBox->render();
    }
    // form to change raw needed to pass the exercise
    $sql = "SELECT `lock`, `raw_to_pass`\n            FROM `" . $TABLELEARNPATHMODULE . "` AS LPM\n           WHERE LPM.`module_id` = " . (int) $_SESSION['module_id'] . "\n             AND LPM.`learnPath_id` = " . (int) $_SESSION['path_id'];
    $learningPath_module = claro_sql_query_fetch_all($sql);
    if (isset($learningPath_module[0]['lock']) && $learningPath_module[0]['lock'] == 'CLOSE' && isset($learningPath_module[0]['raw_to_pass'])) {
        $out .= "\n\n" . '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">' . "\n" . '<label for="newRaw">' . get_lang('Change minimum raw mark to pass this module (percentage) : ') . '</label>' . "\n" . '<input type="text" value="' . claro_htmlspecialchars($learningPath_module[0]['raw_to_pass']) . '" name="newRaw" id="newRaw" size="3" maxlength="3" /> % ' . "\n" . '<input type="submit" value="' . get_lang('Ok') . '" />' . "\n" . '</form>' . "\n\n";
    }
    return $out;
}
 /**
  * Get the necessary javascript for this datepicker
  * @return string
  */
 private function getElementJS()
 {
     $js = null;
     $id = $this->getAttribute('id');
     $dateRange = $this->getAttribute('value');
     $defaultDates = null;
     if (!empty($dateRange)) {
         $dates = $this->parseDateRange($dateRange);
         $defaultDates = "\n                    startDate: '" . $dates['start'] . "',\n                    endDate: '" . $dates['end'] . "', ";
     }
     $minDate = null;
     $minDateValue = $this->getAttribute('minDate');
     if (!empty($minDateValue)) {
         $minDate = "\n                minDate: '{$minDateValue}',\n            ";
     }
     $maxDate = null;
     $maxDateValue = $this->getAttribute('maxDate');
     if (!empty($maxDateValue)) {
         $maxDate = "\n                maxDate: '{$maxDateValue}',\n            ";
     }
     $format = 'YYYY-MM-DD HH:mm';
     $formatValue = $this->getAttribute('format');
     if (!empty($formatValue)) {
         $format = $formatValue;
     }
     $timePicker = 'true';
     $timePickerValue = $this->getAttribute('timePicker');
     if (!empty($timePickerValue)) {
         $timePicker = $timePickerValue;
     }
     // timeFormat: 'hh:mm'
     $js .= "<script>\n        \$(function() {\n            \$('#{$id}').daterangepicker({\n                format: '{$format}',\n                timePicker: {$timePicker},\n                timePickerIncrement: 30,\n                timePicker12Hour: false,\n                {$defaultDates}\n                {$maxDate}\n                {$minDate}\n                ranges: {\n                     '" . addslashes(get_lang('Today')) . "': [moment(), moment()],\n                     '" . addslashes(get_lang('ThisWeek')) . "': [moment().weekday(1), moment().weekday(5)],\n                     '" . addslashes(get_lang('NextWeek')) . "': [moment().weekday(8), moment().weekday(12)]\n                },\n                //showDropdowns : true,\n                separator: ' / ',\n                locale: {\n                    applyLabel: '" . addslashes(get_lang('Ok')) . "',\n                    cancelLabel: '" . addslashes(get_lang('Cancel')) . "',\n                    fromLabel: '" . addslashes(get_lang('From')) . "',\n                    toLabel: '" . addslashes(get_lang('Until')) . "',\n                    customRangeLabel: '" . addslashes(get_lang('CustomRange')) . "',\n                }\n            });\n        });\n        </script>";
     return $js;
 }
Example #22
0
 /**
  * Constructor
  */
 function HTML_QuickForm_datepicker($elementName = null, $elementLabel = null, $attributes = null, $optionIncrement = null)
 {
     $js_form_name = $attributes['form_name'];
     unset($attributes['form_name']);
     HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
     $this->_persistantFreeze = true;
     $this->_appendName = true;
     $this->_type = 'datepicker';
     $popup_link = '<a href="javascript:openCalendar(\'' . $js_form_name . '\',\'' . $elementName . '\')">
     <img src="' . api_get_path(WEB_IMG_PATH) . 'calendar_select.gif" style="vertical-align:middle;" alt="Select Date" /></a>';
     $special_chars = array('D', 'l', 'd', 'M', 'F', 'm', 'y', 'H', 'a', 'A', 's', 'i', 'h', 'g', ' ');
     $hour_minute_devider = get_lang("HourMinuteDivider");
     foreach ($special_chars as $char) {
         $popup_link = str_replace($char, "\\" . $char, $popup_link);
         $hour_minute_devider = str_replace($char, "\\" . $char, $hour_minute_devider);
     }
     $lang_code = api_get_language_isocode();
     // If translation not available in PEAR::HTML_QuickForm_date, add the Chamilo-translation
     if (!array_key_exists($lang_code, $this->_locale)) {
         $this->_locale[$lang_code]['months_long'] = api_get_months_long();
     }
     $this->_options['format'] = 'dFY ' . $popup_link . '   H ' . $hour_minute_devider . ' i';
     $this->_options['minYear'] = date('Y') - 5;
     $this->_options['maxYear'] = date('Y') + 10;
     $this->_options['language'] = $lang_code;
     if (isset($optionIncrement)) {
         $this->_options['optionIncrement']['i'] = intval($optionIncrement);
     }
 }
Example #23
0
 public static function get($key)
 {
     if (isset(self::$data[$key])) {
         return self::$data[$key];
     }
     throw new \Exception(get_lang('CODES_KEY_NOT_FOUND', $key));
 }
function edit_filter($id, $url_params, $row)
{
    global $charset;
    $return = '<a href="specific_fields_add.php?action=edit&field_id=' . $row[0] . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>';
    $return .= ' <a href="' . api_get_self() . '?action=delete&field_id=' . $row[0] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . Display::return_icon('delete.gif', get_lang('Delete')) . '</a>';
    return $return;
}
Example #25
0
function openid_form()
{
    $form = new FormValidator('openid_login', 'post', null, null, array('class' => 'form-vertical form_login'));
    $form->addElement('text', 'openid_url', array(get_lang('OpenIDURL'), Display::url(get_lang('OpenIDWhatIs'), 'main/auth/openid/whatis.php')), array('class' => 'openid_input'));
    $form->addElement('button', 'submit', get_lang('Login'));
    return $form->return_form();
}
function print_player_list($player_list, $players, $playersmax)
{
    $data = "<table class='player_monitor' style='border:none;'><thead>";
    $data .= "<tr><th>" . get_lang('player_name') . "</th><th>" . get_lang('score') . "</th><th>" . get_lang('time') . "</th></tr>";
    $data .= "</thead><tbody>";
    foreach ($player_list as $key => $row) {
        $name[$key] = $row['name'];
        $score[$key] = $row['score'];
        $time[$key] = $row['time'];
    }
    //Sort by score, the 1st position in this array multisort, score, defines the row that sorts the array, if there are two equal scores then the next row, time, will sort this array.
    array_multisort($score, SORT_DESC, $time, $name, $player_list);
    $i = 0;
    foreach ($player_list as $player) {
        $data .= "<tr";
        if ($i % 2 == 0) {
            $data .= 'class="odd"';
        }
        $data .= "><td>" . @$player['name'] . "</td><td>" . @$player['score'] . "</td><td>" . @$player['time'] . "</td></tr>";
        $i++;
    }
    $data .= "</tbody><tfooter><tr><td colspan='3'>" . get_lang('players') . ": " . $players . "/" . $playersmax . "</td></tr>";
    $data .= "</tfooter></table>";
    return $data;
}
/**
 *
 */
function get_course_usage($course_code, $session_id = 0)
{
    $table = Database::get_main_table(TABLE_MAIN_COURSE);
    $course_code = Database::escape_string($course_code);
    $sql = "SELECT * FROM {$table} WHERE code='" . $course_code . "'";
    $res = Database::query($sql);
    $course = Database::fetch_object($res);
    // Learnpaths
    $table = Database::get_course_table(TABLE_LP_MAIN);
    $usage[] = array(get_lang(ucfirst(TOOL_LEARNPATH)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Forums
    $table = Database::get_course_table(TABLE_FORUM);
    $usage[] = array(get_lang('Forums'), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Quizzes
    $table = Database::get_course_table(TABLE_QUIZ_TEST);
    $usage[] = array(get_lang(ucfirst(TOOL_QUIZ)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Documents
    $table = Database::get_course_table(TABLE_DOCUMENT);
    $usage[] = array(get_lang(ucfirst(TOOL_DOCUMENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Groups
    $table = Database::get_course_table(TABLE_GROUP);
    $usage[] = array(get_lang(ucfirst(TOOL_GROUP)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Calendar
    $table = Database::get_course_table(TABLE_AGENDA);
    $usage[] = array(get_lang(ucfirst(TOOL_CALENDAR_EVENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Link
    $table = Database::get_course_table(TABLE_LINK);
    $usage[] = array(get_lang(ucfirst(TOOL_LINK)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Announcements
    $table = Database::get_course_table(TABLE_ANNOUNCEMENT);
    $usage[] = array(get_lang(ucfirst(TOOL_ANNOUNCEMENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    return $usage;
}
 /**
  * @param array $survey_data
  * @param array $formData
  *
  * @return FormValidator
  */
 public function createForm($survey_data, $formData)
 {
     parent::createForm($survey_data, $formData);
     $options = array('horizontal' => get_lang('Horizontal'), 'vertical' => get_lang('Vertical'));
     $this->getForm()->addRadio('horizontalvertical', get_lang('DisplayAnswersHorVert'), $options);
     $formData['horizontalvertical'] = isset($formData['horizontalvertical']) ? $formData['horizontalvertical'] : 'horizontal';
     $this->getForm()->setDefaults($formData);
     $config = array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120');
     $total = count($formData['answers']);
     if (is_array($formData['answers'])) {
         foreach ($formData['answers'] as $key => $value) {
             $this->getForm()->addHtmlEditor('answers[' . $key . ']', null, false, false, $config);
             if ($key < $total - 1) {
                 //$this->getForm()->addButton("move_down[$key]", get_lang('Down'));
             }
             if ($key > 0) {
                 //$this->getForm()->addButton("move_up[$key]", get_lang('Up'));
             }
             if ($total > 2) {
                 $this->getForm()->addButton("delete_answer[{$key}]", get_lang('Delete'), 'trash', 'danger');
             }
         }
     }
     parent::addRemoveButtons($formData);
 }
function validate_data($skills)
{
    $errors = array();
    $skills = array();
    // 1. Check if mandatory fields are set.
    $mandatory_fields = array('id', 'parent_id', 'name');
    foreach ($skills as $index => $skill) {
        foreach ($mandatory_fields as $field) {
            if (empty($skill[$field])) {
                $skill['error'] = get_lang(ucfirst($field) . 'Mandatory');
                $errors[] = $skill;
            }
        }
        // 2. Check skill ID is not empty
        if (!isset($skill['id']) || empty($skill['id'])) {
            $skill['error'] = get_lang('SkillImportNoID');
            $errors[] = $skill;
        }
        // 3. Check skill Parent
        if (!isset($skill['parent_id'])) {
            $skill['error'] = get_lang('SkillImportNoParent');
            $errors[] = $skill;
        }
        // 4. Check skill Name
        if (!isset($skill['name'])) {
            $skill['error'] = get_lang('SkillImportNoName');
            $errors[] = $skill;
        }
    }
    return $errors;
}
function exec_ogp_module()
{
    global $db;
    global $view;
    $user_id = $_GET['user_id'];
    $y = isset($_GET['y']) ? $_GET['y'] : "";
    $user = $db->getUserById($user_id);
    if (empty($user)) {
        print_failure(get_lang_f('user_with_id_does_not_exist', $user_id));
        return;
    }
    $username = $user['users_login'];
    if ($y !== 'y') {
        if (!$db->isModuleInstalled("subusers")) {
            echo "<p>" . get_lang_f('are_you_sure_you_want_to_delete_user', $username) . "</p>";
        } else {
            if (!$db->isSubUser($user_id)) {
                echo "<p>" . get_lang_f('are_you_sure_you_want_to_delete_user', $username) . get_lang('andSubUsers') . "</p>";
            } else {
                echo "<p>" . get_lang_f('are_you_sure_you_want_to_delete_user', $username) . "</p>";
            }
        }
        echo "<p><a href=\"?m=user_admin&amp;p=del&amp;user_id={$user_id}&amp;y=y\">" . get_lang('yes') . "</a> <a href=\"?m=user_admin\">" . get_lang('no') . "</a></p>";
        return;
    }
    if (!$db->delUser($user_id)) {
        print_failure(get_lang_f('unable_to_delete_user', $username));
        $view->refresh("?m=user_admin");
        return;
    }
    print_success(get_lang_f('successfully_deleted_user', $username));
    $db->logger(get_lang_f('successfully_deleted_user', $username));
    $view->refresh("?m=user_admin");
}