Issues (1868)

public/main/auth/profile.php (4 issues)

1
<?php
2
/* For licensing terms, see /license.txt */
3
4
use Chamilo\CoreBundle\Entity\User;
5
use Chamilo\CoreBundle\Entity\UserAuthSource;
6
use Chamilo\CoreBundle\Enums\ActionIcon;
7
use Chamilo\CoreBundle\Enums\ToolIcon;
8
use Chamilo\CoreBundle\Event\AbstractEvent;
9
use Chamilo\CoreBundle\Event\Events;
10
use Chamilo\CoreBundle\Event\UserUpdatedEvent;
11
use Chamilo\CoreBundle\Framework\Container;
12
use ChamiloSession as Session;
13
14
/**
15
 * This file displays the user's profile,
16
 * optionally it allows users to modify their profile as well.
17
 *
18
 * See inc/conf/profile.conf.php to modify settings
19
 */
20
$cidReset = true;
21
require_once __DIR__.'/../inc/global.inc.php';
22
23
$this_section = SECTION_MYPROFILE;
24
$allowSocialTool = 'true' == api_get_setting('allow_social_tool');
25
if ($allowSocialTool) {
26
    $this_section = SECTION_SOCIAL;
27
}
28
29
$logInfo = [
30
    'tool' => 'profile',
31
    'action' => $this_section,
32
];
33
Event::registerLog($logInfo);
0 ignored issues
show
The method registerLog() does not exist on Event. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
Event::/** @scrutinizer ignore-call */ 
34
       registerLog($logInfo);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
35
$profileList = (array) api_get_setting('profile');
36
37
$_user = api_get_user_info();
38
$_SESSION['this_section'] = $this_section;
39
40
if (!(isset($_user['user_id']) && $_user['user_id']) || api_is_anonymous($_user['user_id'], true)) {
41
    api_not_allowed(true);
42
}
43
44
$htmlHeadXtra[] = api_get_password_checker_js('#username', '#password1');
45
//$htmlHeadXtra[] = api_get_css_asset('cropper/dist/cropper.min.css');
46
//$htmlHeadXtra[] = api_get_asset('cropper/dist/cropper.min.js');
47
$htmlHeadXtra[] = '<script>
48
$(function() {
49
    $("#id_generate_api_key").on("click", function (e) {
50
        e.preventDefault();
51
52
        $.ajax({
53
            contentType: "application/x-www-form-urlencoded",
54
            type: "POST",
55
            url: "'.api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=generate_api_key",
56
            data: "num_key_id="+"",
57
            success: function(datos) {
58
                $("#div_api_key").html(datos);
59
            }
60
        });
61
    });
62
63
});
64
65
function confirmation(name) {
66
    if (confirm("'.get_lang('Are you sure to delete?').' " + name + " ?")) {
67
            document.forms["profile"].submit();
68
    } else {
69
        return false;
70
    }
71
}
72
function show_image(image,width,height) {
73
    width = parseInt(width) + 20;
74
    height = parseInt(height) + 20;
75
    window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
76
}
77
</script>';
78
79
$jquery_ready_content = '';
80
if ('true' === api_get_setting('allow_message_tool')) {
81
    $jquery_ready_content = <<<EOF
82
    $(".message-content .message-delete").click(function(){
83
        $(this).parents(".message-content").animate({ opacity: "hide" }, "slow");
84
        $(".message-view").animate({ opacity: "show" }, "slow");
85
    });
86
EOF;
87
}
88
89
$tool_name = get_lang('View my e-portfolio');
90
$table_user = Database::get_main_table(TABLE_MAIN_USER);
91
92
/*
93
 * Get initial values for all fields.
94
 */
95
$user_data = api_get_user_info(
96
    api_get_user_id(),
97
    false,
98
    false,
99
    false,
100
    false,
101
    true,
102
    true
103
);
104
$array_list_key = UserManager::get_api_keys(api_get_user_id());
105
$id_temp_key = UserManager::get_api_key_id(api_get_user_id(), 'default');
106
$value_array = [];
107
if (isset($array_list_key[$id_temp_key])) {
108
    $value_array = $array_list_key[$id_temp_key];
109
}
110
$user_data['api_key_generate'] = $value_array;
111
112
if (false !== $user_data) {
113
    if ('true' == api_get_setting('login_is_email')) {
114
        $user_data['username'] = $user_data['email'];
115
    }
116
    if (is_null($user_data['language'])) {
117
        $user_data['language'] = api_get_setting('platformLanguage');
118
    }
119
}
120
121
$form = new FormValidator('profile');
122
123
if (api_is_western_name_order()) {
124
    //    FIRST NAME and LAST NAME
125
    $form->addElement('text', 'firstname', get_lang('First name'), ['size' => 40]);
126
    $form->addElement('text', 'lastname', get_lang('Last name'), ['size' => 40]);
127
} else {
128
    //    LAST NAME and FIRST NAME
129
    $form->addElement('text', 'lastname', get_lang('Last name'), ['size' => 40]);
130
    $form->addElement('text', 'firstname', get_lang('First name'), ['size' => 40]);
131
}
132
if (!in_array('name', $profileList)) {
133
    $form->freeze(['lastname', 'firstname']);
134
}
135
$form->applyFilter(['lastname', 'firstname'], 'stripslashes');
136
$form->applyFilter(['lastname', 'firstname'], 'trim');
137
$form->applyFilter(['lastname', 'firstname'], 'html_filter');
138
$form->addRule('lastname', get_lang('Required field'), 'required');
139
$form->addRule('firstname', get_lang('Required field'), 'required');
140
141
//    USERNAME
142
$form->addElement(
143
    'text',
144
    'username',
145
    get_lang('Username'),
146
    [
147
        'id' => 'username',
148
        'maxlength' => User::USERNAME_MAX_LENGTH,
149
        'size' => User::USERNAME_MAX_LENGTH,
150
    ]
151
);
152
if (!in_array('login', $profileList) || 'true' == api_get_setting('login_is_email')) {
153
    $form->freeze('username');
154
}
155
$form->applyFilter('username', 'stripslashes');
156
$form->applyFilter('username', 'trim');
157
$form->addRule('username', get_lang('Required field'), 'required');
158
$form->addRule('username', get_lang('Your login can only contain letters, numbers and _.-'), 'username');
159
$form->addRule('username', get_lang('This login is already in use'), 'username_available', $user_data['username']);
160
161
$form->addElement('text', 'official_code', get_lang('Code'), ['size' => 40]);
162
if (!in_array('officialcode', $profileList)) {
163
    $form->freeze('official_code');
164
}
165
$form->applyFilter('official_code', 'stripslashes');
166
$form->applyFilter('official_code', 'trim');
167
$form->applyFilter('official_code', 'html_filter');
168
if ('true' === api_get_setting('registration', 'officialcode') &&
169
    in_array('officialcode', $profileList)
170
) {
171
    $form->addRule('official_code', get_lang('Required field'), 'required');
172
}
173
174
//    EMAIL
175
$form->addElement('email', 'email', get_lang('e-mail'), ['size' => 40]);
176
if (!in_array('email', $profileList)) {
177
    $form->freeze('email');
178
}
179
180
if ('true' == api_get_setting('registration', 'email') && in_array('email', $profileList)
181
) {
182
    $form->applyFilter('email', 'stripslashes');
183
    $form->applyFilter('email', 'trim');
184
    $form->addRule('email', get_lang('Required field'), 'required');
185
    $form->addEmailRule('email');
186
}
187
188
//    PHONE
189
$form->addElement('text', 'phone', get_lang('Phone'), ['size' => 20]);
190
if (!in_array('phone', $profileList)) {
191
    $form->freeze('phone');
192
}
193
$form->applyFilter('phone', 'stripslashes');
194
$form->applyFilter('phone', 'trim');
195
$form->applyFilter('phone', 'html_filter');
196
197
//  PICTURE
198
if (in_array('picture', $profileList)) {
199
    $form->addFile(
200
        'picture',
201
        [
202
            '' != $user_data['picture_uri'] ? get_lang('Update Image') : get_lang('Add image'),
203
            get_lang('Only PNG, JPG or GIF images allowed'),
204
        ],
205
        [
206
            'id' => 'picture',
207
            'class' => 'picture-form',
208
            'crop_image' => true,
209
            'crop_ratio' => '1 / 1',
210
            'accept' => 'image/*',
211
        ]
212
    );
213
214
    $form->addProgress();
215
    if (!empty($user_data['picture_uri'])) {
216
        $form->addElement('checkbox', 'remove_picture', null, get_lang('Remove picture'));
217
    }
218
    $allowed_picture_types = api_get_supported_image_extensions(false);
219
    $form->addRule(
220
        'picture',
221
        get_lang('Only PNG, JPG or GIF images allowed').' ('.implode(', ', $allowed_picture_types).')',
222
        'filetype',
223
        $allowed_picture_types
224
    );
225
}
226
227
//    LANGUAGE
228
$form->addSelectLanguage('language', get_lang('Language'));
229
if (!in_array('language', $profileList)) {
230
    $form->freeze('language');
231
}
232
233
// THEME
234
if ('true' === api_get_setting('user_selected_theme')) {
235
    $form->addSelectTheme('theme', get_lang('Graphical theme'));
236
    if (!in_array('theme', $profileList)) {
237
        $form->freeze('theme');
238
    }
239
    $form->applyFilter('theme', 'trim');
240
}
241
242
//    EXTENDED PROFILE  this make the page very slow!
243
if ('true' === api_get_setting('extended_profile')) {
244
    $width_extended_profile = 500;
245
    //    MY COMPETENCES
246
    $form->addHtmlEditor(
247
        'competences',
248
        get_lang('My competences'),
249
        false,
250
        false,
251
        [
252
            'ToolbarSet' => 'Profile',
253
            'Width' => $width_extended_profile,
254
            'Height' => '130',
255
        ]
256
    );
257
    //    MY DIPLOMAS
258
    $form->addHtmlEditor(
259
        'diplomas',
260
        get_lang('My diplomas'),
261
        false,
262
        false,
263
        [
264
            'ToolbarSet' => 'Profile',
265
            'Width' => $width_extended_profile,
266
            'Height' => '130',
267
        ]
268
    );
269
    // WHAT I AM ABLE TO TEACH
270
    $form->addHtmlEditor(
271
        'teach',
272
        get_lang('What I am able to teach'),
273
        false,
274
        false,
275
        [
276
            'ToolbarSet' => 'Profile',
277
            'Width' => $width_extended_profile,
278
            'Height' => '130',
279
        ]
280
    );
281
282
    //    MY PRODUCTIONS
283
    /*
284
    $form->addElement('file', 'production', get_lang('My productions'));
285
    if ($production_list = UserManager::build_production_list(api_get_user_id(), '', true)) {
286
        $form->addElement('static', 'productions_list', null, $production_list);
287
    }
288
    */
289
    //    MY PERSONAL OPEN AREA
290
    $form->addHtmlEditor(
291
        'openarea',
292
        get_lang('My personal open area'),
293
        false,
294
        false,
295
        [
296
            'ToolbarSet' => 'Profile',
297
            'Width' => $width_extended_profile,
298
            'Height' => '350',
299
        ]
300
    );
301
    // openarea is untrimmed for maximum openness
302
    $form->applyFilter(['competences', 'diplomas', 'teach', 'openarea'], 'stripslashes');
303
    $form->applyFilter(['competences', 'diplomas', 'teach'], 'trim');
304
}
305
306
//    PASSWORD, if auth_source is platform
307
if (in_array(UserAuthSource::PLATFORM, $user_data['auth_sources']) &&
308
    in_array('password', $profileList)
309
) {
310
    $form->addElement('password', 'password0', [get_lang('Pass'), get_lang('Enter2passToChange')], ['size' => 40]);
311
    $form->addElement('password', 'password1', get_lang('New password'), ['id' => 'password1', 'size' => 40]);
312
313
    $form->addElement('password', 'password2', get_lang('Confirm password'), ['size' => 40]);
314
    //    user must enter identical password twice so we can prevent some user errors
315
    $form->addRule(['password1', 'password2'], get_lang('You have typed two different passwords'), 'compare');
316
    $form->addPasswordRule('password1');
317
}
318
319
$extraField = new ExtraField('user');
320
$return = $extraField->addElements(
321
    $form,
322
    api_get_user_id()
323
);
324
325
$jquery_ready_content = $return['jquery_ready_content'];
326
327
// the $jquery_ready_content variable collects all functions that
328
// will be load in the $(document).ready javascript function
329
$htmlHeadXtra[] = '<script>
330
$(function() {
331
    '.$jquery_ready_content.'
332
});
333
</script>';
334
335
if (in_array('apikeys', $profileList)) {
336
    $form->addElement('html', '<div id="div_api_key">');
337
    $form->addElement(
338
        'text',
339
        'api_key_generate',
340
        get_lang('My API key'),
341
        ['size' => 40, 'id' => 'id_api_key_generate']
342
    );
343
    $form->addElement('html', '</div>');
344
    $form->addButton(
345
        'generate_api_key',
346
        get_lang('Generate API key'),
347
        'cogs',
348
        'default',
349
        'default',
350
        null,
351
        ['id' => 'id_generate_api_key']
352
    );
353
}
354
//    SUBMIT
355
$form->addButtonUpdate(get_lang('Save settings'), 'apply_change');
356
$form->setDefaults($user_data);
357
358
$filtered_extension = false;
359
360
if ($form->validate()) {
361
    Container::getEventDispatcher()->dispatch(
362
        new UserUpdatedEvent([], AbstractEvent::TYPE_PRE),
363
        Events::USER_UPDATED
364
    );
365
366
    $wrong_current_password = false;
367
    $user_data = $form->getSubmitValues(1);
368
    $user_data['item_id'] = api_get_user_id();
369
    $user = api_get_user_entity(api_get_user_id());
370
371
    // set password if a new one was provided
372
    $validPassword = false;
373
    $passwordWasChecked = false;
374
375
    if ($user &&
0 ignored issues
show
Consider adding parentheses for clarity. Current Interpretation: ($user && ! empty($user_...('email', $profileList), Probably Intended Meaning: $user && (! empty($user_...'email', $profileList))
Loading history...
376
        (!empty($user_data['password0']) &&
377
        !empty($user_data['password1'])) ||
378
        (!empty($user_data['password0']) &&
379
            in_array('email', $profileList)
380
        )
381
    ) {
382
        $passwordWasChecked = true;
383
        $validPassword = UserManager::isPasswordValid(
384
            $user,
385
            $user_data['password0'],
386
        );
387
388
        if ($validPassword) {
389
            $password = $user_data['password1'];
390
        } else {
391
            Display::addFlash(
392
                Display:: return_message(
393
                    get_lang('The current password is incorrect'),
394
                    'warning',
395
                    false
396
                )
397
            );
398
        }
399
    }
400
401
    $allow_users_to_change_email_with_no_password = true;
402
    if (isset($user_data['auth_sources']) && in_array(UserAuthSource::PLATFORM, $user_data['auth_sources']) &&
403
        'false' === api_get_setting('allow_users_to_change_email_with_no_password')
404
    ) {
405
        $allow_users_to_change_email_with_no_password = false;
406
    }
407
408
    // If user sending the email to be changed (input available and not frozen )
409
    if (in_array('email', $profileList)) {
410
        $userFromEmail = api_get_user_info_from_email($user_data['email']);
411
        if ($allow_users_to_change_email_with_no_password) {
412
            if (!empty($userFromEmail)) {
413
                $changeemail = $user_data['email'];
414
            }
415
        } else {
416
            // Normal behaviour
417
            if (!empty($userFromEmail) && $validPassword) {
418
                $changeemail = $user_data['email'];
419
            }
420
421
            if (!empty($userFromEmail) && empty($user_data['password0'])) {
422
                Display::addFlash(
423
                    Display:: return_message(
424
                        get_lang('ToChangeYoure-mailMustTypeYourPassword'),
425
                        'error',
426
                        false
427
                    )
428
                );
429
            }
430
        }
431
    }
432
433
    // Upload picture if a new one is provided
434
    if (isset($_FILES['picture']) && $_FILES['picture']['size']) {
435
        $new_picture = UserManager::update_user_picture(
436
            api_get_user_id(),
437
            $_FILES['picture']['name'],
438
            $_FILES['picture']['tmp_name'],
439
            $user_data['picture_crop_result']
440
        );
441
442
        if ($new_picture) {
0 ignored issues
show
$new_picture is of type false|null, thus it always evaluated to false.
Loading history...
443
            $user_data['picture_uri'] = $new_picture;
444
445
            Display::addFlash(
446
                Display:: return_message(
447
                    get_lang('Your picture has been uploaded'),
448
                    'normal',
449
                    false
450
                )
451
            );
452
        }
453
    } elseif (!empty($user_data['remove_picture'])) {
454
        // remove existing picture if asked
455
        UserManager::deleteUserPicture(api_get_user_id());
456
        $user_data['picture_uri'] = '';
457
    }
458
459
    // Remove production.
460
    /*
461
    if (isset($user_data['remove_production']) &&
462
        is_array($user_data['remove_production'])
463
    ) {
464
        foreach (array_keys($user_data['remove_production']) as $production) {
465
            UserManager::remove_user_production(api_get_user_id(), urldecode($production));
466
        }
467
        if ($production_list = UserManager::build_production_list(api_get_user_id(), true, true)) {
468
            $form->insertElementBefore(
469
                $form->createElement('static', null, null, $production_list),
470
                'productions_list'
471
            );
472
        }
473
        $form->removeElement('productions_list');
474
        Display::addFlash(
475
            Display:: return_message(get_lang('File deleted'), 'normal', false)
476
        );
477
    }
478
    */
479
    // upload production if a new one is provided
480
    /*if (isset($_FILES['production']) && $_FILES['production']['size']) {
481
        $res = upload_user_production(api_get_user_id());
482
        if (!$res) {
483
            //it's a bit excessive to assume the extension is the reason why
484
            // upload_user_production() returned false, but it's true in most cases
485
            $filtered_extension = true;
486
        } else {
487
            Display::addFlash(
488
                Display:: return_message(
489
                    get_lang('Your production file has been uploaded'),
490
                    'normal',
491
                    false
492
                )
493
            );
494
        }
495
    }*/
496
497
    // remove values that shouldn't go in the database
498
    unset(
499
        $user_data['password0'],
500
        $user_data['password1'],
501
        $user_data['password2'],
502
        $user_data['MAX_FILE_SIZE'],
503
        $user_data['remove_picture'],
504
        $user_data['apply_change'],
505
        $user_data['email']
506
    );
507
508
    // Following RFC2396 (http://www.faqs.org/rfcs/rfc2396.html), a URI uses ':' as a reserved character
509
    // we can thus ensure the URL doesn't contain any scheme name by searching for ':' in the string
510
    $my_user_openid = isset($user_data['openid']) ? $user_data['openid'] : '';
511
    if (!preg_match('/^[^:]*:\/\/.*$/', $my_user_openid)) {
512
        //ensure there is at least a http:// scheme in the URI provided
513
        $user_data['openid'] = 'http://'.$my_user_openid;
514
    }
515
    $extras = [];
516
517
    //Checking the user language
518
    $languages = array_keys(api_get_languages());
519
    if (!in_array($user_data['language'], $languages)) {
520
        $user_data['language'] = api_get_setting('platformLanguage');
521
    }
522
    $_SESSION['_user']['language'] = $user_data['language'];
523
524
    //Only update values that are request by the "profile" setting
525
    //Adding missing variables
526
527
    $available_values_to_modify = [];
528
    foreach ($profileList as $key) {
529
        switch ($key) {
530
            case 'language':
531
                $available_values_to_modify[] = 'language';
532
                $available_values_to_modify[] = 'locale';
533
                $user_data['locale'] = $user_data['language'];
534
                break;
535
            case 'login':
536
                $available_values_to_modify[] = 'username';
537
                break;
538
            case 'name':
539
                $available_values_to_modify[] = 'firstname';
540
                $available_values_to_modify[] = 'lastname';
541
                break;
542
            case 'picture':
543
                $available_values_to_modify[] = 'picture_uri';
544
                break;
545
            default:
546
                $available_values_to_modify[] = $key;
547
                break;
548
        }
549
    }
550
551
    //Fixing missing variables
552
    $available_values_to_modify = array_merge(
553
        $available_values_to_modify,
554
        ['competences', 'diplomas', 'openarea', 'teach', 'openid', 'address']
555
    );
556
557
    // build SQL query
558
    $sql = "UPDATE $table_user SET";
559
    unset($user_data['api_key_generate']);
560
561
    foreach ($user_data as $key => $value) {
562
        if ('extra_' === substr($key, 0, 6)) { //an extra field
563
            continue;
564
        } elseif (false !== strpos($key, 'remove_extra_')) {
565
        } else {
566
            if (in_array($key, $available_values_to_modify)) {
567
                $sql .= " $key = '".Database::escape_string($value)."',";
568
            }
569
        }
570
    }
571
572
    $changePassword = false;
573
    // Change email
574
    if ($allow_users_to_change_email_with_no_password) {
575
        if (isset($changeemail) && in_array('email', $available_values_to_modify)) {
576
            $sql .= " email = '".Database::escape_string($changeemail)."' ";
577
        }
578
        if (isset($password) && in_array('password', $available_values_to_modify)) {
579
            $changePassword = true;
580
        }
581
    } else {
582
        if (isset($changeemail) && !isset($password) && in_array('email', $available_values_to_modify)) {
583
            $sql .= " email = '".Database::escape_string($changeemail)."'";
584
        } else {
585
            if (isset($password) && in_array('password', $available_values_to_modify)) {
586
                if (isset($changeemail) && in_array('email', $available_values_to_modify)) {
587
                    $sql .= " email = '".Database::escape_string($changeemail)."' ";
588
                }
589
                $changePassword = true;
590
            }
591
        }
592
    }
593
594
    $sql = rtrim($sql, ',');
595
    if ($changePassword && !empty($password)) {
596
        UserManager::updatePassword(api_get_user_id(), $password);
597
    }
598
599
    if (!in_array('officialcode', $profileList) &&
600
        isset($user_data['official_code'])
601
    ) {
602
        $sql .= ", official_code = '".Database::escape_string($user_data['official_code'])."'";
603
    }
604
605
    $sql .= " WHERE id  = '".api_get_user_id()."'";
606
    Database::query($sql);
607
608
    if (isset($user_data['language']) && !empty($user_data['language'])) {
609
        // _locale_user is set in the UserLocaleListener during login
610
        Session::write('_locale_user', $user_data['language']);
611
    }
612
613
    if (false == $passwordWasChecked) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
614
        Display::addFlash(
615
            Display:: return_message(get_lang('Your new profile has been saved'), 'normal', false)
616
        );
617
    } else {
618
        if ($validPassword) {
619
            Display::addFlash(
620
                Display:: return_message(get_lang('Your new profile has been saved'), 'normal', false)
621
            );
622
        }
623
    }
624
625
    $extraField = new ExtraFieldValue('user');
626
    $extraField->saveFieldValues($user_data);
627
628
    $userInfo = api_get_user_info(
629
        api_get_user_id(),
630
        false,
631
        false,
632
        false,
633
        false,
634
        true,
635
        true
636
    );
637
    Session::write('_user', $userInfo);
638
639
    Container::getEventDispatcher()->dispatch(
640
        new UserUpdatedEvent(
641
            ['user' => api_get_user_entity()],
642
            AbstractEvent::TYPE_POST
643
        ),
644
        Events::USER_UPDATED
645
    );
646
647
    /*if ($hook) {
648
        Database::getManager()->clear(User::class); // Avoid cache issue (user entity is used before)
649
        $user = api_get_user_entity(api_get_user_id()); // Get updated user info for hook event
650
        $hook->setEventData(['user' => $user]);
651
        $hook->notifyUpdateUser(HOOK_EVENT_TYPE_POST);
652
    }*/
653
654
    Session::erase('system_timezone');
655
656
    $url = api_get_self();
657
    header("Location: $url");
658
    exit;
659
}
660
661
$actions = '';
662
if ($allowSocialTool) {
663
    if ('true' === api_get_setting('extended_profile')) {
664
        if ('true' === api_get_setting('allow_message_tool')) {
665
            $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
666
                Display::getMdiIcon(ToolIcon::SHARED_PROFILE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('View shared profile')).'</a>';
667
            $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
668
                Display::getMdiIcon(ToolIcon::MESSAGE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Messages')).'</a>';
669
        }
670
        $show = isset($_GET['show']) ? '&show='.(int) $_GET['show'] : '';
671
672
        if (isset($_GET['type']) && 'extended' === $_GET['type']) {
673
            $actions .= '<a href="profile.php?type=reduced'.$show.'">'.
674
                Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_TINY, get_lang('Edit normal profile')).'</a>';
675
        } else {
676
            $actions .= '<a href="profile.php?type=extended'.$show.'">'.
677
                Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_TINY, get_lang('Edit extended profile')).'</a>';
678
        }
679
    }
680
}
681
682
$show_delete_account_button = 'true' === api_get_setting('platform_unsubscribe_allowed') ? true : false;
683
684
$tpl = new Template(get_lang('Profile'));
685
686
if ($actions) {
687
    $tpl->assign(
688
        'actions',
689
        Display::toolbarAction('toolbar', [$actions])
690
    );
691
}
692
693
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
694
$tabs = SocialManager::getHomeProfileTabs('profile');
695
696
if ($allowSocialTool) {
697
    SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');
698
    $tpl->assign('social_right_content', $form->returnForm());
699
    $social_layout = $tpl->get_template('social/edit_profile.html.twig');
700
    $tpl->display($social_layout);
701
} else {
702
    $bigImage = UserManager::getUserPicture(api_get_user_id(), USER_IMAGE_SIZE_BIG);
703
    $normalImage = UserManager::getUserPicture(api_get_user_id(), USER_IMAGE_SIZE_ORIGINAL);
704
705
    $imageToShow = '<div id="image-message-container">';
706
    $imageToShow .= '<a class="expand-image float-right" href="'.$bigImage.'" /><img src="'.$normalImage.'"></a>';
707
    $imageToShow .= '</div>';
708
709
    $content = $imageToShow.$form->returnForm();
710
711
    $tpl->assign('content', $content);
712
    $tpl->display_one_col_template();
713
}
714