diff --git a/app/Migrations/Schema/V111/Version20160418113000.php b/app/Migrations/Schema/V111/Version20160418113000.php new file mode 100644 index 0000000000..9a1725955b --- /dev/null +++ b/app/Migrations/Schema/V111/Version20160418113000.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE user ADD address VARCHAR(250) DEFAULT NULL;'); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $this->addSql('ALTER TABLE user DROP COLUMN address'); + } +} diff --git a/main/auth/inscription.php b/main/auth/inscription.php index f06a54e96f..b6b750b610 100755 --- a/main/auth/inscription.php +++ b/main/auth/inscription.php @@ -20,7 +20,8 @@ $allowedFields = [ 'phone', 'status', 'language', - 'extra_fields' + 'extra_fields', + 'address' ]; $allowedFieldsConfiguration = api_get_configuration_value('allow_fields_inscription'); @@ -30,6 +31,84 @@ if ($allowedFieldsConfiguration !== false) { } $htmlHeadXtra[] = api_get_password_checker_js('#username', '#pass1'); +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; // User is not allowed if Terms and Conditions are disabled and // registration is disabled too. @@ -167,6 +246,26 @@ if ($user_already_registered_show_terms == false) { } } + // Geolocation + if (in_array('address', $allowedFields)) { + $form->addElement('text', 'address', get_lang('AddressField'), ['id' => 'address']); + $form->addButton('geolocalization', get_lang('geolocalization'), 'globe', 'default', 'default', 'null', ['id' => 'geolocalization']); + $form->addButton('myLocation', get_lang('MyLocation'), 'map-marker', 'default', 'default', 'null', ['id' => 'myLocation']); + + $form->addHtml(' +
+ +
+
+
+
+
+ '); + } + + // LANGUAGE if (in_array('language', $allowedFields)) { if (api_get_setting('registration', 'language') == 'true') { @@ -483,7 +582,9 @@ if ($form->validate()) { 0, $extras, null, - true + true, + false, + $values['address'] ); //update the extra fields diff --git a/main/auth/profile.php b/main/auth/profile.php index e14956aa2a..0f0db7d988 100755 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -33,6 +33,7 @@ if (!(isset($_user['user_id']) && $_user['user_id']) || api_is_anonymous($_user[ $htmlHeadXtra[] = api_get_password_checker_js('#username', '#password1'); $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; + if ($user_data !== false) { if (api_get_setting('login_is_email') == 'true') { $user_data['username'] = $user_data['email']; @@ -249,6 +330,24 @@ $form->applyFilter('phone', 'stripslashes'); $form->applyFilter('phone', 'trim'); $form->applyFilter('phone', 'html_filter'); +// Geolocation +$form->addElement('text', 'address', get_lang('AddressField'), ['id' => 'address']); +$form->addButton('geolocalization', get_lang('geolocalization'), 'globe', 'default', 'default', 'null', ['id' => 'geolocalization']); +$form->addButton('myLocation', get_lang('MyLocation'), 'map-marker', 'default', 'default', 'null', ['id' => 'myLocation']); + +$form->addHtml(' +
+ +
+
+
+
+
+'); + + // PICTURE if (is_profile_editable() && api_get_setting('profile', 'picture') == 'true') { $form->addElement( @@ -676,7 +775,7 @@ if ($form->validate()) { //Fixing missing variables $available_values_to_modify = array_merge( $available_values_to_modify, - array('competences', 'diplomas', 'openarea', 'teach', 'openid') + array('competences', 'diplomas', 'openarea', 'teach', 'openid', 'address') ); // build SQL query diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 2b0f110bb5..77cc350db6 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -1273,6 +1273,7 @@ function _api_format_user($user, $add_password = false) $attributes = array( 'phone', + 'address', 'picture_uri', 'official_code', 'status', diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index d204e0e4fc..3f7c696b5c 100755 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -211,6 +211,7 @@ class UserManager * @param string Encrypt method used if password is given encrypted. Set to an empty string by default * @param bool $send_mail * @param bool $isAdmin + * @param string $address * * @return mixed new user id - if the new user creation succeeds, false otherwise * @desc The function tries to retrieve user id from the session. @@ -237,7 +238,8 @@ class UserManager $extra = null, $encrypt_method = '', $send_mail = false, - $isAdmin = false + $isAdmin = false, + $address = '' ) { $currentUserId = api_get_user_id(); $hook = HookCreateUser::create(); @@ -346,6 +348,7 @@ class UserManager ->setCreatorId($creator_id) ->setAuthSource($auth_source) ->setPhone($phone) + ->setAddress($address) ->setLanguage($language) ->setRegistrationDate($now) ->setHrDeptId($hr_dept_id) diff --git a/src/Chamilo/UserBundle/Entity/User.php b/src/Chamilo/UserBundle/Entity/User.php index d3d6fb0348..526802de57 100644 --- a/src/Chamilo/UserBundle/Entity/User.php +++ b/src/Chamilo/UserBundle/Entity/User.php @@ -180,6 +180,13 @@ class User implements UserInterface //implements ParticipantInterface, ThemeUser */ protected $phone; + /** + * @var string + * + * @ORM\Column(name="address", type="string", length=250, nullable=true, unique=false) + */ + private $address; + /** * Vich\UploadableField(mapping="user_image", fileNameProperty="picture_uri") * @@ -948,6 +955,29 @@ class User implements UserInterface //implements ParticipantInterface, ThemeUser return $this->phone; } + /** + * Set address + * + * @param string $address + * @return User + */ + public function setAddress($address) + { + $this->address = $address; + + return $this; + } + + /** + * Get address + * + * @return string + */ + public function getAddress() + { + return $this->address; + } + /** * Set pictureUri *