Ver Fonte

Merge 1.11.x

jmontoyaa há 8 anos atrás
pai
commit
197415934f

+ 9 - 7
app/Migrations/Schema/V111/Version20160804174600.php

@@ -656,9 +656,10 @@ class Version20160804174600 extends AbstractMigrationChamilo
             $tpl = $em
                 ->getRepository('ChamiloCoreBundle:SystemTemplate')
                 ->findOneBy(['title' => $title]);
-            $tpl->setContent($content);
-
-            $em->merge($tpl);
+            if (!empty($tpl)) {
+                $tpl->setContent($content);
+                $em->merge($tpl);
+            }
         }
 
         $em->flush();
@@ -1213,11 +1214,12 @@ class Version20160804174600 extends AbstractMigrationChamilo
             $tpl = $em
                 ->getRepository('ChamiloCoreBundle:SystemTemplate')
                 ->findOneBy(['title' => $title]);
-            $tpl->setContent($content);
-
-            $em->merge($tpl);
+            if (!empty($tpl)) {
+                $tpl->setContent($content);
+                $em->merge($tpl);
+            }
         }
 
         $em->flush();
     }
-}
+}

+ 1 - 1
main/inc/lib/api.lib.php

@@ -823,7 +823,7 @@ function api_get_path($path = '', $configuration = [])
             $paths[$root_web][SYS_HOME_PATH] = api_add_trailing_slash($virtualChamilo[SYS_HOME_PATH]);
             $paths[$root_web][SYS_COURSE_PATH] = api_add_trailing_slash($virtualChamilo[SYS_COURSE_PATH]);
             $paths[$root_web][SYS_UPLOAD_PATH] = api_add_trailing_slash($virtualChamilo[SYS_UPLOAD_PATH]);
-            $paths[$root_web][WEB_UPLOAD_PATH] = api_add_trailing_slash($virtualChamilo[WEB_UPLOAD_PATH]);
+            //$paths[$root_web][WEB_UPLOAD_PATH] = api_add_trailing_slash($virtualChamilo[WEB_UPLOAD_PATH]);
             //$paths[$root_web][REL_PATH] = $virtualChamilo[REL_PATH];
             //$paths[$root_web][REL_COURSE_PATH] = $virtualChamilo[REL_COURSE_PATH];
         }

+ 2 - 2
main/inc/lib/banner.lib.php

@@ -403,7 +403,7 @@ function menuArray()
             $cleanUrl = api_replace_dangerous_char($url);
             $cleanUrl = str_replace('/', '-', $cleanUrl);
             $cleanUrl .= '/';
-            $homepath  = api_get_path(SYS_APP_PATH).'home/'.$cleanUrl; //homep for Home Path
+            $homepath  = api_get_path(SYS_HOME_PATH) . $cleanUrl; //homep for Home Path
 
             //we create the new dir for the new sites
             if (!is_dir($homepath)) {
@@ -411,7 +411,7 @@ function menuArray()
             }
         }
     } else {
-        $homepath = api_get_path(SYS_APP_PATH).'home/';
+        $homepath = api_get_path(SYS_HOME_PATH);
     }
     $ext = '.html';
     $menuTabs = 'home_tabs';

+ 8 - 6
main/inc/lib/document.lib.php

@@ -663,6 +663,7 @@ class DocumentManager
                     $template_result = Database::query($sql);
                     $row['is_template'] = (Database::num_rows($template_result) > 0) ? 1 : 0;
                 }
+                $row['basename'] = basename($row['path']);
                 // Just filling $document_data.
                 $document_data[$row['id']] = $row;
             }
@@ -1444,6 +1445,7 @@ class DocumentManager
             $row['absolute_path_from_document'] = '/document' . $row['path'];
             $row['absolute_parent_path'] = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document'.$pathinfo['dirname'] . '/';
             $row['direct_url'] = $www . $path;
+            $row['basename'] = basename($row['path']);
 
             if (dirname($row['path']) == '.') {
                 $row['parent_id'] = '0';
@@ -2136,7 +2138,7 @@ class DocumentManager
     {
         $max = 5;
         $attributes = array();
-        $wanted_attributes = array('src', 'url', '@import', 'href', 'value', 'flashvars');
+        $wanted_attributes = array('src', 'url', '@import', 'href', 'value', 'flashvars', 'poster');
         $explode_attributes = array('flashvars' => 'file');
         $abs_path = '';
 
@@ -5302,7 +5304,7 @@ class DocumentManager
                     api_is_platform_admin() ||
                     api_get_setting('students_download_folders') == 'true'
                 ) {
-                    //filter when I am into shared folder, I can show for donwload only my shared folder
+                    //filter: when I am into a shared folder, I can only show "my shared folder" for donwload
                     if (DocumentManager::is_shared_folder($curdirpath, $current_session_id)) {
                         if (preg_match('/shared_folder\/sf_user_' . api_get_user_id() . '$/', urldecode($forcedownload_link)) ||
                             preg_match('/shared_folder_session_' . $current_session_id . '\/sf_user_' . api_get_user_id() . '$/', urldecode($forcedownload_link)) ||
@@ -5320,11 +5322,11 @@ class DocumentManager
                     }
                 }
             } else {
-                $force_download_html = ($size == 0) ? '' : '<a href="' . $forcedownload_link . '" style="float:right"' . $prevent_multiple_click . '>' .
+                $force_download_html = ($size == 0) ? '' : '<a href="' . $forcedownload_link . '" style="float:right"' . $prevent_multiple_click . ' download="' . $document_data['basename'] . '">' .
                     Display::return_icon($forcedownload_icon, get_lang('Download'), array(), ICON_SIZE_SMALL) . '</a>';
             }
 
-            // Copy files to users myfiles
+            // Copy files to user's myfiles
             if (api_get_setting('allow_my_files') === 'true' &&
                 api_get_setting('users_copy_files') === 'true'
             ) {
@@ -5393,13 +5395,13 @@ class DocumentManager
                             'class' => $class,
                             'title' => $tooltip_title_alt,
                             'data-title' => $title,
-                            'style' => 'float: left;'
+                            'style' => 'float:left;'
                         ]
                     )
                     . $force_download_html . $send_to . $copy_to_myfiles
                     . $open_in_new_window_link . $pdf_icon;
                 } else {
-                    // For PDF Download the file.
+                    // For a "PDF Download" of the file.
                     $pdfPreview = null;
                     if ($ext != 'pdf' && !in_array($ext, $webOdflist)) {
                         $url = 'showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id'];

+ 32 - 0
main/install/install.lib.php

@@ -122,6 +122,22 @@ function checkPhpSettingExists($phpSetting)
     return false;
 }
 
+/**
+ * Check if the current url is the same root_web when the multiple_access_url is enabled
+ * @return bool
+ */
+function checkAccessUrl()
+{
+    if (api_get_configuration_value('multiple_access_urls') !== true) {
+        return true;
+    }
+
+    $currentWebPath = api_get_path(WEB_PATH);
+    $rootWeb = api_get_configuration_value('root_web');
+
+    return $currentWebPath === $rootWeb;
+}
+
 /**
  * Returns a textual value ('ON' or 'OFF') based on a requester 2-state ini- configuration setting.
  *
@@ -689,6 +705,18 @@ function display_requirements(
     }
     echo '</div>';
 
+    $properlyAccessUrl =  checkAccessUrl();
+
+    if (!$properlyAccessUrl) {
+        echo '
+            <div class="alert alert-danger">
+                ' . Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_MEDIUM) .
+            ' ' .
+            sprintf(get_lang('InstallMultiURLDetectedNotMainURL'), api_get_configuration_value('root_web')) . '
+            </div>
+        ';
+    }
+
     //  SERVER REQUIREMENTS
     echo '<div class="RequirementHeading"><h4>'.get_lang('ServerRequirements').'</h4>';
 
@@ -1092,6 +1120,10 @@ function display_requirements(
             <?php
         }
 
+        if (!$properlyAccessUrl) {
+            $error = true;
+        }
+
         // And now display the choice buttons (go back or install)
         ?>
         <p align="center" style="padding-top:15px">

Diff do ficheiro suprimidas por serem muito extensas
+ 37 - 37
main/lang/english/trad4all.inc.php


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
main/lang/spanish/trad4all.inc.php


+ 64 - 41
plugin/vchamilo/README.md

@@ -1,40 +1,50 @@
 Virtual Chamilo
 ===================
 
-Authors : Valery Fremaux (valery.fremaux@gmail.com), Julio Montoya
+Authors : Valery Fremaux (valery.fremaux@gmail.com), Julio Montoya, Angel Quiroz, Yannick Warnier
 
-Virtual chamilo is a feature that allows running several chamilo instances sharing the same
-code base.
+Virtual Chamilo (or vChamilo) is a feature that allows you to easily run several chamilo instances 
+sharing the same code base, with separate documents and databases, acting mostly like containers
+sharing the same libraries.
+
+With vChamilo, your first Chamilo portal acts as a container (or "controller"), and a seed
+ (or image) for the Chamilo instances you will install afterwards. This first image should be 
+ created automatically when configuring the plugin, but if it isn't, the plugin will tell you
+ so and ask to generate one through the interface.
+ 
+Once the plugin is fully setup, you will be able to create new Chamilo instances in a
+ matter of minutes (or seconds on powerful servers).
 
 Changelog
 =========
 
-Version 1.4
+*Version 1.5*
+
+Improved usability and added validations. No DB update required.
+
+*Version 1.4*
 
 Database upgrade needed: 
 
-ALTER TABLE vchamilo ADD COLUMN password_encryption VARCHAR(255);
+  ALTER TABLE vchamilo ADD COLUMN password_encryption VARCHAR(255);
 
-Version 1.3
+*Version 1.3*
 
-Add vchamilo import
+Added vchamilo import
 
 
 Version features
 ===================
-This is a yet prototypal version that is not full featured in back-office tools.
-At the moment, the setup of virtual clones still is a technical operation and has no
-middle-office GUI. Development is in progress to offer a sufficient medium-level
-administrability of the process.
+This is still a beta version and it is not fully featured with back-office tools.
+As such, you will be able to create, edit, copy, delete and even upgrade instances, but a certain
+amount of manual work will still be required at the web server level to get your instances running.
 
 How to setup
 ===================
 
-You need :
+To set this plugin up, you will need to:
 
-1. Install the vchamilo package into the <chamiloroot>/plugin directory
-2. Install the plugin in Chamilo administration
-3. Insert the virtualization hook into the Chamilo master configuration file:
+1. Insert the virtualization hook into the Chamilo master configuration file and enable multi-urls:
 
 ```
 <chamiloroot>/app/config/configuration.php
@@ -46,38 +56,51 @@ Insert the hook at the end of the file.
 include_once $_configuration['root_sys'].'plugin/vchamilo/lib/Virtual.php';
 Virtual::hookConfiguration($_configuration);
 ```
-
-What you need for a virtual node is:
--------------
-
-- a blank database copy of chamilo
-- a dedicated course directory, that needs being accessible from chamilo installation root (directly, or using symlinks). the name
-of this directory is free, as it will be mapped into the vchamilo record.
-- a dedicated home page directory, that is located into <chamiloroot>/home directory and is named
-as the chamilo instance domain name.
-- a vchamilo record into the vchamilo table of the master installation. (the master installation is the install that refers to
-the effective "configuration.php" information.
-- an appropriate multiroot home root setup in the local chamilo instance
-
-Prerequisites for VChamilo working nice
--------------
-
-Multiple URL access must be enabled:
-
+And add (or uncomment) the line to enable multi-url:
+ 
 ```
-# in <chamiloroot>/main/inc/config/configuration.php
 $_configuration['multiple_access_urls'] = true;
 ```
+At this point, make sure there is no caching mechanism maintaining the previous configuration
+ version before you continue. Enabling the multi-url option should have the immediate effect
+  of adding a multi-url management link at the bottom of the "Platform" block in the 
+  administration main page.
+
+Take a moment to update the configuration of the default host in the multi-url configuration page
+to the real hostname of your main (controller) portal.
+
+2. Change the permissions on the <chamiloroot>/plugin/vchamilo/templates/ directory as it will
+ be necessary for the plugin to create files and directories there
+3. Create a common directory to be used for all Chamilo-related files. 
+ We recommend using <chamiloroot>/var/ for that. Inside that directory, create the following 4
+ directories: cache/, courses/, home/ and upload/ and give permissions to the web user to write
+ into them (exactly the same way you did it for the app/ directory when installing Chamilo)
+4. Enable and configure the plugin in the Chamilo administration's plugins list 
+ (if in doubt, use the suggested values). Please note that the proxy configuration part is 
+ totally optional and is not maintained by the Chamilo team at this point. 
+5. Enable additional virtual hosts in your Apache config (unless you use subdirectories). All virtual hosts should point to the same DocumentRoot as the initial Chamilo installation.
+6. For each virtual host or subdirectory, you will need to configure specific redirection rules (remember, this is still at beta-level):
 
-In the administration, you will need configure an adequate home root definition for the instance finding
-the dedicated home directory. You just need editing the http://localhost default host, and give the real domain
-name you are using.
+```
+RewriteEngine On
+RewriteRule /app/upload/(.*)$ http://[vchamilo-instance-domain]/[selected-common-dir]/upload/[vchamilo-instance-dir]/$1 [QSA,L]
+```
+In the example above, you would need to replace everything that is currently within brackets, with
+the specific details of each instance. For example:
+```
+RewriteRule /app/upload/(.*)$ http://beeznest.chamilo.net/var/upload/beeznest-chamilo-net/$1 [QSA,L]
+```
+Although your vChamilo instances *will* work basically without this rewrite rule, you will end 
+up observing issues of files not appearing while uploading files on the instance.
+ 
+Note that the domain of the instance, in the last part of the path, will be transformed 
+from dot-separated domain (beeznest.chamilo.net) to dash-separated-domain (beeznest-chamilo-net).
 
-Check you have the <chamilo>/home/<instancedomain> clone of the standard home directory.
+7. Finally, go to the "Instances manager" and create new instances. Once an instance 
 
 Important note about file system permissions
 -------------
 
-Vchamilos will use several side-directories apart from the standard installation (dedicated courses,
-dedicated home page). Check you set the adequate filesystem permissions (usually let the server write
-in there) for them.
+vChamilo instances *need* a central directory where to store all their files. You should create
+that directory (as mentioned in point 3 above) and make sure it has the right permissions. 
+The plugin/vchamilo/templates/ directory also needs to be writeable by the web server.

+ 24 - 23
plugin/vchamilo/install.php

@@ -18,38 +18,39 @@ api_protect_admin_script();
 $table = 'vchamilo';
 $tablename = Database::get_main_table($table);
 $sql = "CREATE TABLE IF NOT EXISTS $tablename (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `sitename` varchar(80) NOT NULL,
-   slug varchar(255) NOT NULL,
-  `institution` varchar(80) NOT NULL,
-  `root_web` varchar(120),
-  `db_host` varchar(80) NOT NULL,
-  `db_user` varchar(16) DEFAULT 'root',
-  `db_password` varchar(32),  
-  `table_prefix` varchar(16),
-  `db_prefix` varchar(16),
-  `main_database` varchar(60) DEFAULT 'chamilo',
-  `url_append` varchar(32),
-  `course_folder` varchar(80),
-  `visible` int(1),
-  `lastcrongap` int(11),
-  `lastcron` int(11),
-  `croncount` int(11),
-  `template` varchar(255),
-  `password_encryption` varchar(255),  
-  PRIMARY KEY (`id`)
+  id int NOT NULL AUTO_INCREMENT,
+  sitename varchar(80) NOT NULL,
+  slug varchar(255) NOT NULL,
+  institution varchar(80) NOT NULL,
+  root_web varchar(120),
+  db_host varchar(80) NOT NULL,
+  db_user varchar(16) DEFAULT 'root',
+  db_password varchar(32),  
+  table_prefix varchar(16),
+  db_prefix varchar(16),
+  main_database varchar(60) DEFAULT 'chamilo',
+  url_append varchar(32),
+  course_folder varchar(80),
+  visible int,
+  lastcrongap int,
+  lastcron int,
+  croncount int,
+  template varchar(255),
+  password_encryption varchar(255),  
+  PRIMARY KEY (id)
 ) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
 ";
 Database::query($sql);
 
 $table = 'vchamilo_config';
 $tablename = Database::get_main_table($table);
+// TODO: rename "name" and "value" fields - these are reserved keywords
 $sql = "CREATE TABLE IF NOT EXISTS $tablename (
-    `id` int(11) NOT NULL AUTO_INCREMENT, 
-    `component` int(11) NOT NULL,
+    id int(11) NOT NULL AUTO_INCREMENT, 
+    component int(11) NOT NULL,
     `name` varchar(64) NOT NULL,
     `value` varchar(255) NOT NULL,
-    `longvalue` varchar(255) NOT NULL,
+    longvalue varchar(255) NOT NULL,
     PRIMARY KEY (id)
 )
 ";

+ 4 - 1
plugin/vchamilo/lib/Virtual.php

@@ -97,9 +97,10 @@ class Virtual
 
                 $data['SYS_ARCHIVE_PATH'] = self::addTrailingSlash($archivePath).$data['slug'];
                 $data['SYS_HOME_PATH'] = self::addTrailingSlash($homePath).$data['slug'];
+                $data['WEB_HOME_PATH'] = $_configuration['vchamilo_web_root'] . '/var/home/' . $data['slug'];
                 $data['SYS_COURSE_PATH'] = self::addTrailingSlash($coursePath).$data['slug'];
                 $data['SYS_UPLOAD_PATH'] = self::addTrailingSlash($uploadPath).$data['slug'];
-                $data['WEB_UPLOAD_PATH'] = $_configuration['vchamilo_web_root'] . 'var/upload/' . $data['slug'];
+                //$data['WEB_UPLOAD_PATH'] = $_configuration['vchamilo_web_root'] . '/var/upload/' . $data['slug'];
 
                 if (!empty($passwordEncryption)) {
                     $_configuration['password_encryption'] = $passwordEncryption;
@@ -540,6 +541,8 @@ class Virtual
     */
     public static function getVmanifest($version)
     {
+        $templatewwwroot = '';
+        // Define the $templatewwwroot content, found in manifest.php for this template
         $file = api_get_path(SYS_PATH).'/plugin/vchamilo/templates/'.$version.'/manifest.php';
         if (file_exists($file)) {
             include $file;

+ 1 - 1
src/Chamilo/CoreBundle/Resources/views/default/layout/menu.html.twig

@@ -12,7 +12,7 @@
         <div class="collapse navbar-collapse" id="menuone">
             <ul class="nav navbar-nav">
                 {% for item in menu %}
-                    <li class="{{ item.current }}"><a href="{{ item.url }}">{{ item.title }}</a></li>
+                    <li class="{{ item.current }}"><a href="{{ item.url }}" target="{{ item.target }}" title="{{ item.title }}">{{ item.title }}</a></li>
                 {% endfor %}
             </ul>
            {% if _u.logged == 1 %}

+ 2 - 1
tests/xhprof/footer.php

@@ -15,5 +15,6 @@ if (extension_loaded('tideways')) {
     // url to the XHProf UI libraries (change the host name and path)
     $subDir = substr(__DIR__, strlen(trim($_SERVER['DOCUMENT_ROOT'])));
     $profiler_url = sprintf($subDir.'/xhprof_html/index.php?run=%s&source=%s', $run_id, $profiler_namespace);
-    echo '<a style="z-index:99; position: absolute;" href="'. $profiler_url .'" target="_blank">Profiler output</a>';
+    $mem = round(memory_get_peak_usage()/1024);
+    echo '<a style="z-index:99; position: absolute;" href="'. $profiler_url .'" target="_blank">Profiler output (Memory: '.$mem.'KB)</a>';
 }

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff