Browse Source

Merge branch '1.10.x' of github.com:chamilo/chamilo-lms into 1.10.x

aragonc 9 years ago
parent
commit
131af74c69

+ 15 - 5
.travis.yml

@@ -6,22 +6,30 @@ php:
   - 5.6
 
 before_install:
-  - sudo apt-get install python-software-properties
-  - sudo add-apt-repository ppa:ondrej/php5 -y
+  #- sudo apt-get install python-software-properties
+  #- sudo add-apt-repository ppa:ondrej/php5 -y
   - sudo apt-get update -qq
   - sudo apt-get install -qq mysql-server
   - sudo apt-get install -qq apache2 libapache2-mod-fastcgi
-  - sudo apt-get install -qq php5-imagick php5-curl php5-intl php5-json php5-fpm php5-mysql
+  # Install additional PHP packages (check http://docs.travis-ci.com/user/ci-environment/#CI-environment-OS
+  # for pre-installed packages)
+  #- sudo apt-get install -qq php5-imagick
+  # Following http://docs.travis-ci.com/user/languages/php/#PHP-installation,
+  # php is compiled with --enable-fpm, so no install of FPM is needed.
+  # However, not installing it generates errors with service php5-fpm restart
+  # further down (need to use php-fpm without 5)
+  - sudo apt-get install -qq php5-cli php5-fpm
 
 before_script:
   - php5 -v
+  - php5 -m
   - composer self-update
   - composer global require "fxp/composer-asset-plugin:1.0.0"
   - composer install -n
   - composer -v update
   - phpenv config-add tests/travis-php-config.ini
   # enable php-fpm
-  - sudo service php5-fpm stop
+  - sudo service php-fpm stop
   - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
   - sudo a2enmod rewrite actions fastcgi alias
   - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
@@ -30,6 +38,8 @@ before_script:
   - sudo cp -f tests/travis-apache /etc/apache2/sites-available/default
   - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default
   - sudo service apache2 restart
+  - sudo service php-fpm restart
+  - php5 -v
   # install Chash, a database, and then install Chamilo
   - git clone https://github.com/chamilo/chash
   - cd chash
@@ -48,7 +58,7 @@ before_script:
   #- cd ../..
   # install Chamilo with Chash - see reference https://github.com/sonnym/travis-ci-drupal-module-example/blob/master/.travis.yml
   - cd /home/travis/build/chamilo/chamilo-lms
-  - sudo chash chash:chamilo_install --no-interaction --sitename="Chamilo" --site_url="http://localhost/" --institution="Chamilo" --institution_url="https://chamilo.org" --encrypt_method="sha1" --firstname="John" --lastname="Doe" --language="english" --driver="pdo_mysql" --host="localhost" --port="3306" --dbname="chamilo" --dbuser="root" --permissions_for_new_directories="0777" --permissions_for_new_files="0666" --linux-user="www-data" --linux-group="www-data" --username="admin" --password="admin" --email="admin@example.com" --phone="555-5555" 1.10.x
+  - sudo chash chash:chamilo_install --no-interaction --sitename="Chamilo" --site_url="http://localhost/" --institution="Chamilo" --institution_url="https://chamilo.org" --encrypt_method="sha1" --firstname="John" --lastname="Doe" --language="english" --driver="mysqlnd" --host="localhost" --port="3306" --dbname="chamilo" --dbuser="root" --permissions_for_new_directories="0777" --permissions_for_new_files="0666" --linux-user="www-data" --linux-group="www-data" --username="admin" --password="admin" --email="admin@example.com" --phone="555-5555" 1.10.x
 
 script:
   # - phpunit -c tests/phpunit

+ 1 - 0
composer.json

@@ -53,6 +53,7 @@
         "symfony/validator": "2.6.4",
         "symfony/filesystem": "~2.6",
         "symfony/security": "~2.6",
+        "ircmaxell/password-compat": "~1.0.4",
         "sylius/attribute": "0.13.0",
         "sylius/translation": "0.13.0",
         "gedmo/doctrine-extensions": "~2.3",

+ 35 - 14
main/admin/session_import.php

@@ -117,22 +117,43 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
                             $phone = trim(api_utf8_decode($node_user->Phone));
                             $status = trim(api_utf8_decode($node_user->Status));
                             switch ($status) {
-                                case 'student' : $status = 5; break;
-                                case 'teacher' : $status = 1; break;
-                                default : $status = 5; $error_message .= get_lang('StudentStatusWasGivenTo').' : '.$username.'<br />';
+                                case 'student':
+                                    $status = 5;
+                                    break;
+                                case 'teacher':
+                                    $status = 1;
+                                    break;
+                                default:
+                                    $status = 5;
+                                    $error_message .= get_lang('StudentStatusWasGivenTo').' : '.$username.'<br />';
                             }
 
-                            $sql = "UPDATE $tbl_user SET
-                                    lastname = '".Database::escape_string($lastname)."',
-                                    firstname = '".Database::escape_string($firstname)."',
-                                    ".(empty($password) ? "" : "password = '".(api_get_encrypted_password($password))."',")."
-                                    email = '".Database::escape_string($email)."',
-                                    official_code = '".Database::escape_string($official_code)."',
-                                    phone = '".Database::escape_string($phone)."',
-                                    status = '".intval($status)."'
-                                WHERE username = '".Database::escape_string($username)."'";
-
-                            Database::query($sql);
+                            $userId = UserManager::get_user_id_from_username($username);
+
+                            if (!empty($userId)) {
+                                UserManager::update_user(
+                                    $userId,
+                                    $firstname,
+                                    $lastname,
+                                    $username,
+                                    $password,
+                                    null,
+                                    $email,
+                                    $status,
+                                    $official_code,
+                                    $phone,
+                                    null, //$picture_uri,
+                                    null, //$expiration_date,
+                                    null, //$active,
+                                    null, //$creator_id = null,
+                                    0,
+                                    null, //$extra = null,
+                                    null, //$language = 'english',
+                                    null, //$encrypt_method = '',
+                                    false,
+                                    0 //$reset_password = 0
+                                );
+                            }
                         }
                     }
                 }

+ 3 - 2
main/install/install.lib.php

@@ -1852,7 +1852,8 @@ function installSettings(
     $allowRegistration = $allowRegistration ? 'true' : 'false';
     $allowTeacherSelfRegistration = $allowTeacherSelfRegistration ? 'true' : 'false';
 
-    $settings = [
+    // Use PHP 5.3 to avoid issue with weird peripherical auto-installers like travis-ci
+    $settings = array(
         'Institution' => $organizationName,
         'InstitutionUrl' => $organizationUrl,
         'siteName' => $siteName,
@@ -1862,7 +1863,7 @@ function installSettings(
         'platformLanguage' => $language,
         'allow_registration' => $allowRegistration,
         'allow_registration_as_teacher' => $allowTeacherSelfRegistration,
-    ];
+    );
 
     foreach ($settings as $variable => $value) {
         $sql = "UPDATE settings_current

+ 0 - 1
src/Chamilo/CoreBundle/Migrations/Schema/V110/Version20150507152600.php

@@ -3,7 +3,6 @@
 
 namespace Chamilo\CoreBundle\Migrations\Schema\V110;
 
-use Chamilo\CoreBundle\Entity\SettingsCurrent;
 use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
 use Doctrine\DBAL\Schema\Schema;
 

+ 28 - 0
src/Chamilo/CoreBundle/Migrations/Schema/V110/Version20150511133949.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace Chamilo\CoreBundle\Migrations\Schema\V110;
+
+use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
+use Doctrine\DBAL\Schema\Schema;
+
+/**
+ * Add salt
+ */
+class Version20150511133949 extends AbstractMigrationChamilo
+{
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        $this->addSql('ALTER TABLE user ADD salt VARCHAR(255) NOT NULL');
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+        $this->addSql('ALTER TABLE user DROP salt');
+    }
+}

+ 14 - 14
src/Chamilo/UserBundle/Entity/User.php

@@ -4,29 +4,28 @@
 namespace Chamilo\UserBundle\Entity;
 
 //use Chamilo\CoreBundle\Entity\UserFieldValues;
-use Sonata\UserBundle\Entity\BaseUser as BaseUser;
-use Doctrine\ORM\Mapping as ORM;
+use Chamilo\CoreBundle\Entity\ExtraFieldValues;
 use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ORM\Event\LifecycleEventArgs;
+use Doctrine\ORM\Mapping as ORM;
+use Sonata\UserBundle\Entity\BaseUser as BaseUser;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Symfony\Component\HttpFoundation\File\File;
 use Symfony\Component\Security\Core\User\UserInterface;
-use Symfony\Component\Validator\Mapping\ClassMetadata;
 use Symfony\Component\Validator\Constraints as Assert;
-use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Symfony\Component\Validator\Mapping\ClassMetadata;
+
 //use Chamilo\CoreBundle\Component\Auth;
-use Doctrine\ORM\Event\LifecycleEventArgs;
 //use FOS\MessageBundle\Model\ParticipantInterface;
 //use Chamilo\ThemeBundle\Model\UserInterface as ThemeUser;
 //use Vich\UploaderBundle\Mapping\Annotation as Vich;
-use Symfony\Component\HttpFoundation\File\File;
 //use Application\Sonata\MediaBundle\Entity\Media;
 //use Chamilo\UserBundle\Model\UserInterface as UserInterfaceModel;
 
-use Doctrine\Common\Collections\Collection;
 //use Sylius\Component\Attribute\Model\AttributeValueInterface as BaseAttributeValueInterface;
 //use Sylius\Component\Variation\Model\OptionInterface as BaseOptionInterface;
 //use Sylius\Component\Variation\Model\VariantInterface as BaseVariantInterface;
 
-use Chamilo\CoreBundle\Entity\ExtraFieldValues;
-
 /**
  * @ORM\HasLifecycleCallbacks
  * @ORM\Table(name="user")
@@ -256,6 +255,11 @@ class User extends BaseUser //implements ParticipantInterface, ThemeUser
      */
     private $hrDeptId;
 
+    /**
+     * @ORM\Column(type="string", length=255)
+     */
+    protected $salt;
+
     /**
      * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseRelUser", mappedBy="user")
      **/
@@ -295,10 +299,6 @@ class User extends BaseUser //implements ParticipantInterface, ThemeUser
      */
     //protected $groups;
 
-    /**
-     * @ORM\Column(type="string", length=255)
-     */
-    //protected $salt;
 
     //private $isActive;
 
@@ -344,7 +344,7 @@ class User extends BaseUser //implements ParticipantInterface, ThemeUser
     {
         parent::__construct();
 
-        //$this->salt = sha1(uniqid(null, true));
+        $this->salt = sha1(uniqid(null, true));
         $this->isActive = true;
         $this->active = 1;
         $this->registrationDate = new \DateTime();