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


PHP api_get_languages函数代码示例

本文整理汇总了PHP中api_get_languages函数的典型用法代码示例。如果您正苦于以下问题:PHP api_get_languages函数的具体用法?PHP api_get_languages怎么用?PHP api_get_languages使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: SelectLanguage

 /**
  * Class constructor
  */
 function SelectLanguage($elementName = null, $elementLabel = null, $options = null, $attributes = null)
 {
     parent::__construct($elementName, $elementLabel, $options, $attributes);
     // Get all languages
     $languages = api_get_languages();
     $this->_options = array();
     $this->_values = array();
     foreach ($languages['name'] as $index => $name) {
         if ($languages['folder'][$index] == api_get_setting('platformLanguage')) {
             $this->addOption($name, $languages['folder'][$index], array('selected' => 'selected'));
         } else {
             $this->addOption($name, $languages['folder'][$index]);
         }
     }
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:18,代码来源:SelectLanguage.php

示例2: __construct

 /**
  * Class constructor
  */
 public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
 {
     parent::__construct($elementName, $elementLabel, $options, $attributes);
     // Get all languages
     $languages = api_get_languages();
     $this->_options = array();
     $this->_values = array();
     foreach ($languages as $iso => $name) {
         if ($iso == api_get_setting('language.platform_language')) {
             $this->addOption($name, $iso, array('selected' => 'selected'));
         } else {
             $this->addOption($name, $iso);
         }
     }
 }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:18,代码来源:SelectLanguage.php

示例3: HTML_QuickForm_Select_Language

 /**
  * Class constructor
  */
 function HTML_QuickForm_Select_Language($elementName = null, $elementLabel = null, $options = null, $attributes = null)
 {
     if (!isset($attributes['class'])) {
         $attributes['class'] = 'chzn-select';
     }
     parent::HTML_QuickForm_Select($elementName, $elementLabel, $options, $attributes);
     // Get all languages
     $languages = api_get_languages();
     $this->_options = array();
     $this->_values = array();
     foreach ($languages['name'] as $index => $name) {
         if ($languages['folder'][$index] == api_get_setting('platformLanguage')) {
             $this->addOption($name, $languages['folder'][$index], array('selected' => 'selected'));
         } else {
             $this->addOption($name, $languages['folder'][$index]);
         }
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:21,代码来源:select_language.php

示例4: HTML_QuickForm_Select_Language

 /**
  * Class constructor
  */
 function HTML_QuickForm_Select_Language($elementName = null, $elementLabel = null, $options = null, $attributes = null)
 {
     if (!isset($attributes['class'])) {
         $attributes['class'] = 'chzn-select';
     }
     parent::HTML_QuickForm_Select($elementName, $elementLabel, $options, $attributes);
     // Get all languages
     $languages = api_get_languages();
     $this->_options = array();
     $this->_values = array();
     $platformLanguage = Container::getTranslator()->getLocale();
     foreach ($languages as $language) {
         if ($language['isocode'] == $platformLanguage) {
             $this->addOption($language['english_name'], $language['isocode'], array('selected' => 'selected'));
         } else {
             $this->addOption($language['english_name'], $language['isocode']);
         }
     }
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:22,代码来源:select_language.php

示例5: update_user

 /**
  * Update user information with all the parameters passed to this function
  * @param int The ID of the user to be updated
  * @param string The user's firstname
  * @param string The user's lastname
  * @param string The user's username (login)
  * @param string The user's password
  * @param string The authentication source (default: "platform")
  * @param string The user's e-mail address
  * @param int The user's status
  * @param string The user's official code (usually just an internal institutional code)
  * @param string The user's phone number
  * @param string The user's picture URL (internal to the Chamilo directory)
  * @param int The user ID of the person who registered this user (optional, defaults to null)
  * @param int The department of HR in which the user is registered (optional, defaults to 0)
  * @param array A series of additional fields to add to this user as extra fields (optional, defaults to null)
  * @return boolean true if the user information was updated
  * @assert (false, false, false, false, false, false, false, false, false, false, false, false, false) === false
  */
 public static function update_user($user_id, $firstname, $lastname, $username, $password = null, $auth_source = null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active, $creator_id = null, $hr_dept_id = 0, $extra = null, $language = 'english', $encrypt_method = '', $send_email = false, $reset_password = 0)
 {
     $hook = HookUpdateUser::create();
     if (!empty($hook)) {
         $hook->notifyUpdateUser(HOOK_EVENT_TYPE_PRE);
     }
     global $_configuration;
     $original_password = $password;
     if (empty($user_id)) {
         return false;
     }
     $user_info = api_get_user_info($user_id, false, true);
     if ($reset_password == 0) {
         $password = null;
         $auth_source = $user_info['auth_source'];
     } elseif ($reset_password == 1) {
         $original_password = $password = api_generate_password();
         $auth_source = PLATFORM_AUTH_SOURCE;
     } elseif ($reset_password == 2) {
         $password = $password;
         $auth_source = PLATFORM_AUTH_SOURCE;
     } elseif ($reset_password == 3) {
         $password = $password;
         $auth_source = $auth_source;
     }
     if ($user_id != strval(intval($user_id))) {
         return false;
     }
     if ($user_id === false) {
         return false;
     }
     //Checking the user language
     $languages = api_get_languages();
     if (!in_array($language, $languages['folder'])) {
         $language = api_get_setting('platformLanguage');
     }
     $change_active = 0;
     if ($user_info['active'] != $active) {
         $change_active = 1;
     }
     $userManager = self::getManager();
     /** @var Chamilo\UserBundle\Entity\User $user */
     $user = self::getRepository()->find($user_id);
     if (empty($user)) {
         return false;
     }
     if (!empty($expiration_date)) {
         $expiration_date = api_get_utc_datetime($expiration_date);
         $expiration_date = new \DateTime($expiration_date, new DateTimeZone('UTC'));
     }
     $user->setLastname($lastname)->setFirstname($firstname)->setUsername($username)->setStatus($status)->setAuthSource($auth_source)->setLanguage($language)->setEmail($email)->setOfficialCode($official_code)->setPhone($phone)->setPictureUri($picture_uri)->setExpirationDate($expiration_date)->setActive($active)->setHrDeptId($hr_dept_id);
     if (!is_null($password)) {
         $user->setPlainPassword($password);
     }
     $userManager->updateUser($user, true);
     if ($change_active == 1) {
         if ($active == 1) {
             $event_title = LOG_USER_ENABLE;
         } else {
             $event_title = LOG_USER_DISABLE;
         }
         Event::addEvent($event_title, LOG_USER_ID, $user_id);
     }
     if (is_array($extra) && count($extra) > 0) {
         $res = true;
         foreach ($extra as $fname => $fvalue) {
             $res = $res && self::update_extra_field_value($user_id, $fname, $fvalue);
         }
     }
     if (!empty($email) && $send_email) {
         $recipient_name = api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS);
         $emailsubject = '[' . api_get_setting('siteName') . '] ' . get_lang('YourReg') . ' ' . api_get_setting('siteName');
         $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
         $email_admin = api_get_setting('emailAdministrator');
         if (api_is_multiple_url_enabled()) {
             $access_url_id = api_get_current_access_url_id();
             if ($access_url_id != -1) {
                 $url = api_get_access_url($access_url_id);
                 $emailbody = get_lang('Dear') . " " . stripslashes(api_get_person_name($firstname, $lastname)) . ",\n\n" . get_lang('YouAreReg') . " " . api_get_setting('siteName') . " " . get_lang('WithTheFollowingSettings') . "\n\n" . get_lang('Username') . " : " . $username . ($reset_password > 0 ? "\n" . get_lang('Pass') . " : " . stripslashes($original_password) : "") . "\n\n" . get_lang('Address') . " " . api_get_setting('siteName') . " " . get_lang('Is') . " : " . $url['url'] . "\n\n" . get_lang('Problem') . "\n\n" . get_lang('SignatureFormula') . ",\n\n" . api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname')) . "\n" . get_lang('Manager') . " " . api_get_setting('siteName') . "\nT. " . api_get_setting('administratorTelephone') . "\n" . get_lang('Email') . " : " . api_get_setting('emailAdministrator');
             }
         } else {
//.........这里部分代码省略.........
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:101,代码来源:usermanager.lib.php

示例6: display_survey_search_form

    /**
     * This function displays the form for searching a survey
     *
     * @return	void	(direct output)
     *
     * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
     * @version January 2007
     *
     * @todo use quickforms
     * @todo consider moving this to surveymanager.inc.lib.php
     */
    static function display_survey_search_form()
    {
        echo '<form class="form-horizontal" method="get" action="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php?search=advanced">';
        echo '<legend>' . get_lang('SearchASurvey') . '</legend>';
        echo '	<div class="control-group">
					<label class="control-label">
						' . get_lang('Title') . '
					</label>
					<div class="controls">
						<input type="text" id="search_title" name="keyword_title"/>
					</div>
				</div>';
        echo '	<div class="control-group">
					<label class="control-label">
						' . get_lang('Code') . '
					</label>
					<div class="controls">
						<input type="text" name="keyword_code"/>
					</div>
				</div>';
        echo '	<div class="control-group">
					<label class="control-label">
						' . get_lang('Language') . '
					</label>
					<div class="controls">';
        echo '			<select name="keyword_language"><option value="%">' . get_lang('All') . '</option>';
        $languages = api_get_languages();
        foreach ($languages['name'] as $index => &$name) {
            echo '<option value="' . $languages['folder'][$index] . '">' . $name . '</option>';
        }
        echo '			</select>';
        echo '		</div>
				</div>';
        echo '<input type="hidden" name="cidReq" value="' . api_get_course_id() . '"/>';
        echo '	<div class="control-group">
					<div class="controls">
						<button class="search" type="submit" name="do_search">' . get_lang('Search') . '</button>
					</div>
				</div>';
        echo '</form>';
        echo '<div style="clear: both;margin-bottom: 10px;"></div>';
    }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:53,代码来源:survey.lib.php

示例7: api_get_valid_language

/**
 * Validates the input language (english, spanish, etc)
 * in order always to return a language that is enabled in the system.
 * This function is to be used for data import when provided language should be validated.
 * @param string $language The language to be validated.
 * @return string Returns the input language identificator. If the input language is not enabled, platform language is returned then.
 */
function api_get_valid_language($language)
{
    static $enabled_languages;
    if (!isset($enabled_languages)) {
        $enabled_languages_info = api_get_languages();
        $enabled_languages = $enabled_languages_info['folder'];
    }
    $language = str_replace('_km', '_KM', strtolower(trim($language)));
    if (empty($language) || !in_array($language, $enabled_languages)) {
        $language = api_get_setting('platformLanguage');
    }
    return $language;
}
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:20,代码来源:internationalization.lib.php

示例8: api_display_language_form

/**
 * Displays a form (drop down menu) so the user can select his/her preferred language.
 * The form works with or without javascript
 * @param  boolean Hide form if only one language available (defaults to false = show the box anyway)
 * @return void Display the box directly
 */
function api_display_language_form($hide_if_no_choice = false)
{
    // Retrieve a complete list of all the languages.
    $language_list = api_get_languages();
    if (count($language_list) <= 1 && $hide_if_no_choice) {
        return;
        //don't show any form
    }
    $user_selected_language = api_get_language_selected_in_login();
    $html = '
    <script type="text/javascript">
    <!--
    $(document).ready(function() {
        $("#language_list").change(function() {
            jumpMenu("parent",this,0);
        });
    });

    function jumpMenu(targ,selObj,restore){ // v3.0
        eval(targ+".location=\'"+selObj.options[selObj.selectedIndex].value+"\'");
        if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>';
    $html .= '<form id="lang_form" name="lang_form" method="post" action="' . api_get_self() . '">';
    $html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>';
    $html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
    foreach ($language_list as $iso => $value) {
        if ($iso == $user_selected_language) {
            $option_end = ' selected="selected" >';
        } else {
            $option_end = '>';
        }
        $html .= '<option value="' . api_get_self() . '?language=' . $iso . '"' . $option_end;
        //echo substr($value, 0, 16); // Cut string to keep 800x600 aspect.
        $html .= $value . '</option>';
    }
    $html .= '</select>';
    $html .= '<noscript><input type="submit" name="user_select_language" value="' . get_lang('Ok') . '" /></noscript>';
    $html .= '</form>';
    return $html;
}
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:48,代码来源:api.lib.php

示例9: get_lang

                    $message = get_lang('TermAndConditionNotSaved');
                }
                Security::clear_token();
                $tok = Security::get_token();
                header('Location: legal_list.php?action=show_message&message=' . urlencode($message) . '&sec_token=' . $tok);
                exit;
            } elseif ($submit == 'preview') {
                $defaults['type'] = $type;
                $defaults['content'] = $content;
                $defaults['changes'] = $changes;
                $term_preview = $defaults;
                $term_preview['type'] = intval($_POST['type']);
            } else {
                $my_lang = $_POST['language'];
                if (isset($_POST['language'])) {
                    $all_langs = api_get_languages();
                    if (in_array($my_lang, $all_langs['folder'])) {
                        $language = api_get_language_id($my_lang);
                        $term_preview = LegalManager::get_last_condition($language);
                        $defaults = $term_preview;
                        if (!$term_preview) {
                            // there are not terms and conditions
                            $term_preview['type'] = -1;
                            $defaults['type'] = 0;
                        }
                    }
                }
            }
        }
    }
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:legal_add.php

示例10: create_user

 /**
  * Creates a new user for the platform
  * @author Hugues Peeters <peeters@ipm.ucl.ac.be>,
  * @author Roan Embrechts <roan_embrechts@yahoo.com>
  * @param   string    Firstname
  * @param   string    Lastname
  * @param   int       Status (1 for course tutor, 5 for student, 6 for anonymous)
  * @param   string    e-mail address
  * @param   string    Login
  * @param   string    Password
  * @param   string    Any official code (optional)
  * @param   string    User language    (optional)
  * @param   string    Phone number    (optional)
  * @param   string    Picture URI        (optional)
  * @param   string    Authentication source    (optional, defaults to 'platform', dependind on constant)
  * @param   string    Account expiration date (optional, defaults to '0000-00-00 00:00:00')
  * @param   int        Whether the account is enabled or disabled by default
  * @param   int        The department of HR in which the user is registered (optional, defaults to 0)
  * @param   array    Extra fields
  * @param   string    Encrypt method used if password is given encrypted. Set to an empty string by default
  * @return  mixed   new user id - if the new user creation succeeds, false otherwise
  * @desc The function tries to retrieve $_user['user_id'] from the global space. If it exists, $_user['user_id'] is the creator id. If a problem arises, it stores the error message in global $api_failureList
  * @assert ('Sam','Gamegie',5,'sam@example.com','jo','jo') > 1
  * @assert ('Pippin','Took',null,null,'jo','jo') === false
  */
 public static function create_user($firstName, $lastName, $status, $email, $loginName, $password, $official_code = '', $language = '', $phone = '', $picture_uri = '', $auth_source = PLATFORM_AUTH_SOURCE, $expiration_date = '0000-00-00 00:00:00', $active = 1, $hr_dept_id = 0, $extra = null, $encrypt_method = '', $send_mail = false)
 {
     global $_configuration;
     $original_password = $password;
     $access_url_id = 1;
     if (api_get_multiple_access_url()) {
         $access_url_id = api_get_current_access_url_id();
     }
     if (is_array($_configuration[$access_url_id]) && isset($_configuration[$access_url_id]['hosting_limit_users']) && $_configuration[$access_url_id]['hosting_limit_users'] > 0) {
         $num = self::get_number_of_users();
         if ($num >= $_configuration[$access_url_id]['hosting_limit_users']) {
             return api_set_failure('portal users limit reached');
         }
     }
     if ($status === 1 && is_array($_configuration[$access_url_id]) && isset($_configuration[$access_url_id]['hosting_limit_teachers']) && $_configuration[$access_url_id]['hosting_limit_teachers'] > 0) {
         $num = self::get_number_of_users(1);
         if ($num >= $_configuration[$access_url_id]['hosting_limit_teachers']) {
             return api_set_failure('portal teachers limit reached');
         }
     }
     $firstName = Security::remove_XSS($firstName);
     $lastName = Security::remove_XSS($lastName);
     $loginName = Security::remove_XSS($loginName);
     $phone = Security::remove_XSS($phone);
     // database table definition
     $table_user = Database::get_main_table(TABLE_MAIN_USER);
     //Checking the user language
     $languages = api_get_languages();
     if (!in_array($language, $languages)) {
         $language = Container::getTranslator()->getLocale();
     }
     $creator_id = api_get_user_id();
     // First check wether the login already exists
     if (!self::is_username_available($loginName)) {
         return api_set_failure('login-pass already taken');
     }
     if (empty($encrypt_method)) {
         $password = api_get_encrypted_password($password);
     } else {
         if ($_configuration['password_encryption'] === $encrypt_method) {
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
                 return api_set_failure('encrypt_method invalid');
             } else {
                 if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
                     return api_set_failure('encrypt_method invalid');
                 }
             }
         } else {
             return api_set_failure('encrypt_method invalid');
         }
     }
     //@todo replace this date with the api_get_utc_date function big problem with users that are already registered
     $current_date = api_get_utc_datetime();
     $em = Database::getManager();
     $expirationDate = new \DateTime($expiration_date);
     $user = new \Chamilo\UserBundle\Entity\User();
     $user->setLastname($lastName)->setFirstname($firstName)->setUsername($loginName)->setPassword($password)->setEmail($email)->setOfficialCode($official_code)->setPictureUri($picture_uri)->setCreatorId($creator_id)->setAuthSource($auth_source)->setPhone($phone)->setLanguage($language)->setExpirationDate($expirationDate)->setHrDeptId($hr_dept_id)->setActive($active);
     /*$sql = "INSERT INTO $table_user ".
              "SET lastname =         '".Database::escape_string(trim($lastName))."',".
              "firstname =         '".Database::escape_string(trim($firstName))."',".
              "username =            '".Database::escape_string(trim($loginName))."',".
              "status =             '".Database::escape_string($status)."',".
              "password =             '".Database::escape_string($password)."',".
              "email =             '".Database::escape_string($email)."',".
              "official_code    =     '".Database::escape_string($official_code)."',".
              "picture_uri     =     '".Database::escape_string($picture_uri)."',".
              "creator_id      =     '".Database::escape_string($creator_id)."',".
              "auth_source =         '".Database::escape_string($auth_source)."',".
              "phone =             '".Database::escape_string($phone)."',".
              "language =             '".Database::escape_string($language)."',".
              "registration_date = '".$current_date."',".
              "expiration_date =     '".Database::escape_string($expiration_date)."',".
              "hr_dept_id =         '".Database::escape_string($hr_dept_id)."',".
              "active =             '".Database::escape_string($active)."'";
       $result = Database::query($sql);*/
//.........这里部分代码省略.........
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:101,代码来源:usermanager.lib.php

示例11: api_get_language_interface

function api_get_language_interface()
{
    $valid_languages = api_get_languages();
    $user_language = api_get_user_language();
    $courseInfo = api_get_course_info();
    $language_interface = 'english';
    $languageFromLogin = api_get_language_selected_in_login();
    if (!empty($languageFromLogin)) {
        $language_interface = $languageFromLogin;
    }
    if (!empty($valid_languages)) {
        // User language or platform lang
        //platformLanguage
        //if (!empty($user_language)) {
        $language_interface = $user_language;
        //}
        // Course language
        if (!empty($courseInfo) && isset($courseInfo['language'])) {
            $language_interface = $courseInfo['language'];
        }
        //error_log('$language_interface: '.$language_interface);
        // Lang priorities could be: course_lang, user_profil_lang, user_selected_lang , platform_lang
        $language_priority1 = api_get_setting('languagePriority1');
        $language_priority2 = api_get_setting('languagePriority2');
        $language_priority3 = api_get_setting('languagePriority3');
        $language_priority4 = api_get_setting('languagePriority4');
        /*error_log('$language_interface1: '.$language_priority1);
          error_log('$language_interface2: '.$language_priority2);
          error_log('$language_interface3: '.$language_priority3);
          error_log('$language_interface4: '.$language_priority4);*/
        if (!empty($language_priority4) && api_get_language_from_type($language_priority4) !== false) {
            $language_interface = api_get_language_from_type($language_priority4);
        }
        if (!empty($language_priority3) && api_get_language_from_type($language_priority3) !== false) {
            $language_interface = api_get_language_from_type($language_priority3);
        }
        if (!empty($language_priority2) && api_get_language_from_type($language_priority2) !== false) {
            $language_interface = api_get_language_from_type($language_priority2);
        }
        if (!empty($language_priority1) && api_get_language_from_type($language_priority1) !== false) {
            $language_interface = api_get_language_from_type($language_priority1);
        }
        // If user lang is not valid get the default platform lang
        if (empty($language_interface) || !in_array($language_interface, $valid_languages['folder'])) {
            $language_interface = api_get_setting('platformLanguage');
        }
    }
    return $language_interface;
}
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:49,代码来源:api.lib.php

示例12: api_set_settings_and_plugins

     if (isset($settings['settings_latest_update']) && $settings['settings_latest_update'] != $settingsLatestUpdate) {
         api_set_settings_and_plugins();
     }
 }
 $app['plugins'] = Session::read('_plugins');
 // Default template style.
 $templateStyle = api_get_setting('template');
 $templateStyle = isset($templateStyle) && !empty($templateStyle) ? $templateStyle : 'default';
 if (!is_dir($app['sys_root'] . 'main/template/' . $templateStyle)) {
     $templateStyle = 'default';
 }
 $app['template_style'] = $templateStyle;
 // Default layout.
 $app['default_layout'] = $app['template_style'] . '/layout/layout_1_col.tpl';
 // Setting languages.
 $app['api_get_languages'] = api_get_languages();
 $app['language_interface'] = $language_interface = api_get_language_interface();
 // Reconfigure template now that we know the user.
 $app['template.hide_global_chat'] = !api_is_global_chat_enabled();
 /** Setting the course quota */
 // Default quota for the course documents folder
 $default_quota = api_get_setting('default_document_quotum');
 // Just in case the setting is not correctly set
 if (empty($default_quota)) {
     $default_quota = 100000000;
 }
 define('DEFAULT_DOCUMENT_QUOTA', $default_quota);
 // Specification for usernames:
 // 1. ASCII-letters, digits, "." (dot), "_" (underscore) are acceptable, 40 characters maximum length.
 // 2. Empty username is formally valid, but it is reserved for the anonymous user.
 // 3. Checking the login_is_email portal setting in order to accept 100 chars maximum
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:global.inc.php

示例13: api_display_language_form

/**
 * Displays a form (drop down menu) so the user can select his/her preferred language.
 * The form works with or without javascript
 * @param  boolean Hide form if only one language available (defaults to false = show the box anyway)
 * @return void Display the box directly
 */
function api_display_language_form($hide_if_no_choice = false)
{
    // Retrieve a complete list of all the languages.
    $language_list = api_get_languages();
    if (count($language_list['name']) <= 1 && $hide_if_no_choice) {
        return;
        //don't show any form
    }
    // The the current language of the user so that his/her language occurs as selected in the dropdown menu.
    if (isset($_SESSION['user_language_choice'])) {
        $user_selected_language = $_SESSION['user_language_choice'];
    }
    if (empty($user_selected_language)) {
        $user_selected_language = api_get_setting('platformLanguage');
    }
    $original_languages = $language_list['name'];
    $folder = $language_list['folder'];
    // This line is probably no longer needed.
    $html = '
    <script type="text/javascript">
    <!--
    $(document).ready(function() {
        $("#language_list").change(function() {
            jumpMenu("parent",this,0);
        });
    });

    function jumpMenu(targ,selObj,restore){ // v3.0
        eval(targ+".location=\'"+selObj.options[selObj.selectedIndex].value+"\'");
        if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>';
    $html .= '<form id="lang_form" name="lang_form" method="post" action="' . api_get_self() . '">';
    $html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>';
    $html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
    foreach ($original_languages as $key => $value) {
        if ($folder[$key] == $user_selected_language) {
            $option_end = ' selected="selected" >';
        } else {
            $option_end = '>';
        }
        $html .= '<option value="' . api_get_self() . '?language=' . $folder[$key] . '"' . $option_end;
        //echo substr($value, 0, 16); // Cut string to keep 800x600 aspect.
        $html .= $value . '</option>';
    }
    $html .= '</select>';
    $html .= '<noscript><input type="submit" name="user_select_language" value="' . get_lang('Ok') . '" /></noscript>';
    $html .= '</form>';
    return $html;
}
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:57,代码来源:api.lib.php

示例14: update_user

 /**
  * Update user information with all the parameters passed to this function
  * @param int The ID of the user to be updated
  * @param string The user's firstname
  * @param string The user's lastname
  * @param string The user's username (login)
  * @param string The user's password
  * @param string The authentication source (default: "platform")
  * @param string The user's e-mail address
  * @param int The user's status
  * @param string The user's official code (usually just an internal institutional code)
  * @param string The user's phone number
  * @param string The user's picture URL (internal to the Chamilo directory)
  * @param int The user ID of the person who registered this user (optional, defaults to null)
  * @param int The department of HR in which the user is registered (optional, defaults to 0)
  * @param    array    A series of additional fields to add to this user as extra fields (optional, defaults to null)
  * @return boolean true if the user information was updated
  * @assert (false) === false
  */
 public static function update_user($user_id, $firstname, $lastname, $username, $password = null, $auth_source = null, $email = null, $status = STUDENT, $official_code = null, $phone = null, $picture_uri = null, $expiration_date = null, $active = 1, $creator_id = null, $hr_dept_id = 0, $extra = null, $language = 'english', $encrypt_method = '', $send_email = false, $reset_password = 0)
 {
     global $_configuration;
     $original_password = $password;
     $user_info = api_get_user_info($user_id, false, true);
     if ($reset_password == 0) {
         $password = null;
         $auth_source = $user_info['auth_source'];
     } elseif ($reset_password == 1) {
         $original_password = $password = api_generate_password();
         $auth_source = PLATFORM_AUTH_SOURCE;
     } elseif ($reset_password == 2) {
         $password = $password;
         $auth_source = PLATFORM_AUTH_SOURCE;
     } elseif ($reset_password == 3) {
         $password = $password;
         $auth_source = $auth_source;
     }
     if ($user_id != strval(intval($user_id))) {
         return false;
     }
     if ($user_id === false) {
         return false;
     }
     $table_user = Database::get_main_table(TABLE_MAIN_USER);
     //Checking the user language
     $languages = api_get_languages();
     if (!in_array($language, $languages['folder'])) {
         $language = api_get_setting('platformLanguage');
     }
     $sql = "UPDATE {$table_user} SET\n                lastname='" . Database::escape_string($lastname) . "',\n                firstname='" . Database::escape_string($firstname) . "',\n                username='" . Database::escape_string($username) . "',\n                language='" . Database::escape_string($language) . "',";
     if (!is_null($password)) {
         if ($encrypt_method == '') {
             $password = api_get_encrypted_password($password);
         } else {
             if ($_configuration['password_encryption'] === $encrypt_method) {
                 if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
                     return api_set_failure('encrypt_method invalid');
                 } else {
                     if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
                         return api_set_failure('encrypt_method invalid');
                     }
                 }
             } else {
                 return api_set_failure('encrypt_method invalid');
             }
         }
         $sql .= " password='" . Database::escape_string($password) . "',";
     }
     if (!is_null($auth_source)) {
         $sql .= " auth_source='" . Database::escape_string($auth_source) . "',";
     }
     $sql .= "\n                email='" . Database::escape_string($email) . "',\n                status='" . Database::escape_string($status) . "',\n                official_code='" . Database::escape_string($official_code) . "',\n                phone='" . Database::escape_string($phone) . "',\n                picture_uri='" . Database::escape_string($picture_uri) . "',\n                expiration_date='" . Database::escape_string($expiration_date) . "',\n                active='" . Database::escape_string($active) . "',\n                hr_dept_id=" . intval($hr_dept_id);
     if (!is_null($creator_id)) {
         $sql .= ", creator_id='" . Database::escape_string($creator_id) . "'";
     }
     $sql .= " WHERE user_id = '{$user_id}' ";
     $return = Database::query($sql);
     if (is_array($extra) && count($extra) > 0) {
         $res = true;
         foreach ($extra as $fname => $fvalue) {
             $res = $res && self::update_extra_field_value($user_id, $fname, $fvalue);
         }
     }
     if ($user_info['active'] != $active) {
         self::change_active_state($user_id, $active);
     }
     global $app;
     // Adding user
     /** @var Entity\User $user */
     $em = $app['orm.ems']['db_write'];
     $user = $em->getRepository('Entity\\User')->find($user_id);
     $role = $em->getRepository('Entity\\Role')->find($status);
     $user->getRolesObj()->remove(0);
     $user->getRolesObj()->add($role);
     $em->persist($user);
     $em->flush();
     if (!empty($email) && $send_email) {
         $recipient_name = api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS);
         $emailsubject = '[' . api_get_setting('siteName') . '] ' . get_lang('YourReg') . ' ' . api_get_setting('siteName');
         $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
//.........这里部分代码省略.........
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:usermanager.lib.php

示例15: isset

        $values['group'] = isset($groups['group_id']) ? $groups['group_id'] : 0;
        $action_todo = true;
        break;
}
if ($action_todo) {
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
        $form_title = get_lang('AddNews');
        $url = api_get_self();
    } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
        $form_title = get_lang('EditNews');
        $url = api_get_self() . '?id=' . intval($_GET['id']);
    }
    $form = new FormValidator('system_announcement', 'post', $url);
    $form->addElement('header', '', $form_title);
    $form->addText('title', get_lang('Title'), true);
    $language_list = api_get_languages();
    $language_list_with_keys = array();
    $language_list_with_keys['all'] = get_lang('All');
    for ($i = 0; $i < count($language_list['name']); $i++) {
        $language_list_with_keys[$language_list['folder'][$i]] = $language_list['name'][$i];
    }
    $form->addElement('select', 'lang', get_lang('Language'), $language_list_with_keys);
    $form->addHtmlEditor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'PortalNews', 'Width' => '100%', 'Height' => '300'));
    $form->addDateRangePicker('range', get_lang('StartTimeWindow'), true, array('id' => 'date_range'));
    $group = array();
    $group[] = $form->createElement('checkbox', 'visible_teacher', null, get_lang('Teacher'));
    $group[] = $form->createElement('checkbox', 'visible_student', null, get_lang('Student'));
    $group[] = $form->createElement('checkbox', 'visible_guest', null, get_lang('Guest'));
    $form->addGroup($group, null, get_lang('Visible'), '');
    $form->addElement('hidden', 'id');
    $userGroup = new UserGroup();
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:system_announcements.php


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