Example #1
0
 /**
  * Get user account list
  *
  * @param array $user array with keys: email, password, uid, loginName
  * @param boolean $reset
  * @param boolean $by_username
  * @return unknown
  */
 public static function get_user_account_list($user, $reset = false, $by_username = false)
 {
     $portal_url = api_get_path(WEB_PATH);
     if (api_is_multiple_url_enabled()) {
         $url = api_get_current_access_url_info();
         $portal_url = $url['url'];
     }
     if ($reset) {
         if ($by_username) {
             $secret_word = self::get_secret_word($user['email']);
             if ($reset) {
                 $reset_link = $portal_url . "main/auth/lostPassword.php?reset=" . $secret_word . "&id=" . $user['uid'];
             } else {
                 $reset_link = get_lang('Pass') . " : {$user['password']}";
             }
             $user_account_list = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $user['loginName'] . "\n" . get_lang('ResetLink') . ' : ' . $reset_link . '';
             if ($user_account_list) {
                 $user_account_list = "\n-----------------------------------------------\n" . $user_account_list;
             }
         } else {
             foreach ($user as $this_user) {
                 $secret_word = self::get_secret_word($this_user['email']);
                 if ($reset) {
                     $reset_link = $portal_url . "main/auth/lostPassword.php?reset=" . $secret_word . "&id=" . $this_user['uid'];
                 } else {
                     $reset_link = get_lang('Pass') . " : {$this_user['password']}";
                 }
                 $user_account_list[] = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $this_user['loginName'] . "\n" . get_lang('ResetLink') . ' : ' . $reset_link . '';
             }
             if ($user_account_list) {
                 $user_account_list = implode("\n-----------------------------------------------\n", $user_account_list);
             }
         }
     } else {
         if (!$by_username) {
             $user = $user[0];
         }
         $reset_link = get_lang('Pass') . " : {$user['password']}";
         $user_account_list = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $user['loginName'] . "\n" . $reset_link . '';
     }
     return $user_account_list;
 }
Example #2
0
function api_get_home_path()
{
    return null;
    $home = 'home/';
    $access_url_id = api_get_current_access_url_id();
    if (api_get_multiple_access_url() && $access_url_id != -1) {
        $url_info = api_get_current_access_url_info();
        $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url']));
        $clean_url = api_replace_dangerous_char($url);
        $clean_url = str_replace('/', '-', $clean_url);
        $clean_url .= '/';
        // if $clean_url ==  "localhost/" means that the multiple URL was not well configured we don't rename the $home variable
        if ($clean_url != 'localhost/') {
            //$home          = 'home/'.$clean_url;
        }
        $home = 'home/' . $clean_url;
    }
    return $home;
}
Example #3
0
 Online::loginCheck(api_get_user_id());
 // Setting access_url id (multiple url feature)
 if (api_get_multiple_access_url()) {
     $_configuration = $app['configuration'];
     $_configuration['access_url'] = 1;
     $access_urls = api_get_access_urls();
     $protocol = $request->getScheme() . '://';
     $request_url1 = $protocol . $_SERVER['SERVER_NAME'] . '/';
     $request_url2 = $protocol . $_SERVER['HTTP_HOST'] . '/';
     foreach ($access_urls as &$details) {
         if ($request_url1 == $details['url'] or $request_url2 == $details['url']) {
             $_configuration['access_url'] = $details['id'];
         }
     }
     Session::write('url_id', $_configuration['access_url']);
     Session::write('url_info', api_get_current_access_url_info($_configuration['access_url']));
 } else {
     Session::write('url_id', 1);
 }
 // Loading portal settings from DB.
 $settingsRefreshInfo = api_get_settings_params_simple(array('variable = ?' => 'settings_latest_update'));
 $settingsLatestUpdate = $settingsRefreshInfo ? $settingsRefreshInfo['selected_value'] : null;
 $settings = Session::read('_setting');
 if (empty($settings)) {
     api_set_settings_and_plugins();
 } else {
     if (isset($settings['settings_latest_update']) && $settings['settings_latest_update'] != $settingsLatestUpdate) {
         api_set_settings_and_plugins();
     }
 }
 $app['plugins'] = Session::read('_plugins');
Example #4
0
function api_set_settings_and_plugins()
{
    global $_configuration;
    $_setting = array();
    $_plugins = array();
    // access_url == 1 is the default chamilo location
    $settings_by_access_list = array();
    $access_url_id = api_get_current_access_url_id();
    if ($access_url_id != 1) {
        $url_info = api_get_current_access_url_info();
        if ($url_info['active'] == 1) {
            $settings_by_access = api_get_settings(null, 'list', $_configuration['access_url'], 1);
            foreach ($settings_by_access as $row) {
                if (empty($row['variable'])) {
                    $row['variable'] = 0;
                }
                if (empty($row['subkey'])) {
                    $row['subkey'] = 0;
                }
                if (empty($row['category'])) {
                    $row['category'] = 0;
                }
                $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row;
            }
        }
    }
    $result = api_get_settings(null, 'list', 1);
    foreach ($result as &$row) {
        if ($access_url_id != 1) {
            if ($url_info['active'] == 1) {
                $var = empty($row['variable']) ? 0 : $row['variable'];
                $subkey = empty($row['subkey']) ? 0 : $row['subkey'];
                $category = empty($row['category']) ? 0 : $row['category'];
            }
            if ($row['access_url_changeable'] == 1 && $url_info['active'] == 1) {
                if (isset($settings_by_access_list[$var]) && $settings_by_access_list[$var][$subkey][$category]['selected_value'] != '') {
                    if ($row['subkey'] == null) {
                        $_setting[$row['variable']] = $settings_by_access_list[$var][$subkey][$category]['selected_value'];
                    } else {
                        $_setting[$row['variable']][$row['subkey']] = $settings_by_access_list[$var][$subkey][$category]['selected_value'];
                    }
                } else {
                    if ($row['subkey'] == null) {
                        $_setting[$row['variable']] = $row['selected_value'];
                    } else {
                        $_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
                    }
                }
            } else {
                if ($row['subkey'] == null) {
                    $_setting[$row['variable']] = $row['selected_value'];
                } else {
                    $_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
                }
            }
        } else {
            if ($row['subkey'] == null) {
                $_setting[$row['variable']] = $row['selected_value'];
            } else {
                $_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
            }
        }
    }
    $result = api_get_settings('Plugins', 'list', $access_url_id);
    foreach ($result as &$row) {
        $key =& $row['variable'];
        if (is_string($_setting[$key])) {
            $_setting[$key] = array();
        }
        $_setting[$key][] = $row['selected_value'];
        $_plugins[$key][] = $row['selected_value'];
    }
    Session::write('_setting', $_setting);
    Session::write('_plugins', $_plugins);
}
Example #5
0
 /**
  * @return null|string
  */
 public function returnMenu()
 {
     return null;
     $navigation = $this->navigation_array;
     $navigation = $navigation['navigation'];
     // Displaying the tabs
     $lang = api_get_user_language();
     // Preparing home folder for multiple urls
     if (api_get_multiple_access_url()) {
         $access_url_id = api_get_current_access_url_id();
         if ($access_url_id != -1) {
             $url_info = api_get_current_access_url_info();
             $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url']));
             $clean_url = api_replace_dangerous_char($url);
             $clean_url = str_replace('/', '-', $clean_url);
             $clean_url .= '/';
             $homep = $this->app['path.data'] . 'home/' . $clean_url;
             //homep for Home Path
             //we create the new dir for the new sites
             if (!is_dir($homep)) {
                 mkdir($homep, api_get_permissions_for_new_directories());
             }
         }
     } else {
         $homep = $this->app['path.data'] . 'home/';
     }
     $ext = '.html';
     $menutabs = 'home_tabs';
     $home_top = '';
     if (is_file($homep . $menutabs . '_' . $lang . $ext) && is_readable($homep . $menutabs . '_' . $lang . $ext)) {
         $home_top = @(string) file_get_contents($homep . $menutabs . '_' . $lang . $ext);
     } elseif (is_file($homep . $menutabs . $lang . $ext) && is_readable($homep . $menutabs . $lang . $ext)) {
         $home_top = @(string) file_get_contents($homep . $menutabs . $lang . $ext);
     }
     $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
     $open = str_replace('{rel_path}', $this->app['path.data'], $home_top);
     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
     $lis = '';
     if (!empty($open)) {
         if (strpos($open, 'show_menu') === false) {
             if (api_is_anonymous()) {
                 $navigation[SECTION_CAMPUS] = null;
             }
         } else {
             $lis .= $open;
         }
     }
     if (count($navigation) > 0 || !empty($lis)) {
         $pre_lis = '';
         foreach ($navigation as $section => $navigation_info) {
             if (isset($GLOBALS['this_section'])) {
                 $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active" ' : '';
             } else {
                 $current = '';
             }
             if (!empty($navigation_info['title'])) {
                 $pre_lis .= '<li' . $current . ' ><a  href="' . $navigation_info['url'] . '" target="_top">' . $navigation_info['title'] . '</a></li>';
             }
         }
         $lis = $pre_lis . $lis;
     }
     $menu = null;
     if (!empty($lis)) {
         $menu .= $lis;
     }
     return $menu;
 }
 /**
  * This function returns an icon path that represents the favicon of the website of which the url given. Defaults to the current Chamilo favicon
  * @param    string    URL of website where to look for favicon.ico
  * @param    string    Optional second URL of website where to look for favicon.ico
  * @return    string    Path of icon to load
  */
 public static function get_favicon_from_url($url1, $url2 = null)
 {
     $icon_link = '';
     $url = $url1;
     if (empty($url1)) {
         $url = $url2;
         if (empty($url)) {
             $url = api_get_current_access_url_info();
             $url = $url[0];
         }
     }
     if (!empty($url)) {
         $pieces = parse_url($url);
         $icon_link = $pieces['scheme'] . '://' . $pieces['host'] . '/favicon.ico';
     }
     return $icon_link;
 }