diff --git a/bl-kernel/admin/views/edit-user.php b/bl-kernel/admin/views/edit-user.php index de653be6..f4c8a6ce 100644 --- a/bl-kernel/admin/views/edit-user.php +++ b/bl-kernel/admin/views/edit-user.php @@ -249,104 +249,18 @@ echo Bootstrap::formInputHidden(array(
g('Social Networks')); - echo Bootstrap::formInputText(array( - 'name' => 'twitter', - 'label' => 'Twitter', - 'value' => $user->twitter(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - echo Bootstrap::formInputText(array( - 'name' => 'facebook', - 'label' => 'Facebook', - 'value' => $user->facebook(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'codepen', - 'label' => 'CodePen', - 'value' => $user->codepen(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'instagram', - 'label' => 'Instagram', - 'value' => $user->instagram(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'gitlab', - 'label' => 'GitLab', - 'value' => $user->gitlab(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'github', - 'label' => 'GitHub', - 'value' => $user->github(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'linkedin', - 'label' => 'LinkedIn', - 'value' => $user->linkedin(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'xing', - 'label' => 'Xing', - 'value' => $user->xing(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'telegram', - 'label' => 'Telegram', - 'value' => $user->telegram(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'mastodon', - 'label' => 'Mastodon', - 'value' => $user->mastodon(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); - - echo Bootstrap::formInputText(array( - 'name' => 'vk', - 'label' => 'VK', - 'value' => $user->vk(), - 'class' => '', - 'placeholder' => '', - 'tip' => '' - )); + foreach ($GLOBALS['SOCIAL_NETWORKS'] as $key => $value) { + echo Bootstrap::formInputText(array( + 'name' => Text::cleanUrl($value), + 'label' => $value, + 'value' => $user->getSocialNetwork($value), + 'class' => '', + 'placeholder' => '', + 'tip' => '' + )); + } + echo Bootstrap::cardEnd(); ?>
diff --git a/bl-kernel/user.class.php b/bl-kernel/user.class.php index 07b0962a..3075d7ff 100644 --- a/bl-kernel/user.class.php +++ b/bl-kernel/user.class.php @@ -205,6 +205,10 @@ class User return $this->getValue('vk'); } + public function getSocialNetwork($social) { + return $this->getValue('socials')[Text::cleanUrl($social)]; + } + public function profilePicture() { $filename = $this->getValue('username') . '.png'; diff --git a/bl-kernel/users.class.php b/bl-kernel/users.class.php index d0a2c076..a5eeb679 100644 --- a/bl-kernel/users.class.php +++ b/bl-kernel/users.class.php @@ -26,7 +26,8 @@ class Users extends dbJSON { 'gitlab'=>'', 'linkedin'=>'', 'mastodon'=>'', - 'vk'=>'' + 'vk'=>'', + 'socials' => array() ); function __construct() @@ -128,6 +129,14 @@ class Users extends dbJSON { $row['tokenAuth'] = $this->generateAuthToken(); } + $row['socials'] = array(); + foreach ($GLOBALS['SOCIAL_NETWORKS'] as $key => $social) { + $socialKey = Text::cleanUrl($social); + if (isset($args[$socialKey])) { + $row['socials'][$socialKey] = $args[$socialKey]; + } + } + // Save the database $this->db[$username] = $row; return $this->save();