From f9f485ffcb1e75c2f449339113ab529dd9344f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Mon, 18 Apr 2016 17:13:01 -0500 Subject: [PATCH 1/2] Added Geolocalization to user profile - Refs #10992 --- .../Schema/V111/Version20160418113000.php | 31 ++++++ main/auth/inscription.php | 105 +++++++++++++++++- main/auth/profile.php | 105 +++++++++++++++++- main/inc/lib/api.lib.php | 1 + main/inc/lib/usermanager.lib.php | 5 +- src/Chamilo/UserBundle/Entity/User.php | 30 +++++ 6 files changed, 271 insertions(+), 6 deletions(-) create mode 100644 app/Migrations/Schema/V111/Version20160418113000.php 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..eabac90973 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..915d75abe5 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 56720df40b..158378fb02 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -1311,6 +1311,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 fc72f0915f..82ac61ccfb 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 * From 6b49c40c83b6f24ff64d6d948300bb9d65ae4cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Tue, 17 May 2016 17:07:25 -0500 Subject: [PATCH 2/2] Fix Minor gmaps plugin call - Refs #10992 --- main/auth/inscription.php | 2 +- main/auth/profile.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/auth/inscription.php b/main/auth/inscription.php index eabac90973..b6b750b610 100755 --- a/main/auth/inscription.php +++ b/main/auth/inscription.php @@ -31,7 +31,7 @@ if ($allowedFieldsConfiguration !== false) { } $htmlHeadXtra[] = api_get_password_checker_js('#username', '#pass1'); -$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; -$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; $htmlHeadXtra[] = '