summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-09-20 11:21:14 -0400
committerFrederic Guillot <fred@kanboard.net>2015-09-20 11:21:14 -0400
commit8079b5af64fbebd14a3a0e470bc48bcb4a9bade3 (patch)
tree74da6e544529a4d74b5fdbf3ab854e43809eeb10 /app
parentd019eb4d2f193c7daea8ae0b098a0eb25084a975 (diff)
Fix Mysql error about gitlab_id when creating remote user
Diffstat (limited to 'app')
-rw-r--r--app/Model/Base.php20
-rw-r--r--app/Model/User.php8
-rw-r--r--app/Template/user/create_remote.php6
3 files changed, 26 insertions, 8 deletions
diff --git a/app/Model/Base.php b/app/Model/Base.php
index 973462cc..e700f326 100644
--- a/app/Model/Base.php
+++ b/app/Model/Base.php
@@ -62,14 +62,30 @@ abstract class Base extends \Core\Base
public function removeFields(array &$values, array $keys)
{
foreach ($keys as $key) {
- if (isset($values[$key])) {
+ if (array_key_exists($key, $values)) {
+ unset($values[$key]);
+ }
+ }
+ }
+
+ /**
+ * Remove keys from an array if empty
+ *
+ * @access public
+ * @param array $values Input array
+ * @param string[] $keys List of keys to remove
+ */
+ public function removeEmptyFields(array &$values, array $keys)
+ {
+ foreach ($keys as $key) {
+ if (array_key_exists($key, $values) && empty($values[$key])) {
unset($values[$key]);
}
}
}
/**
- * Force some fields to be at 0 if empty
+ * Force fields to be at 0 if empty
*
* @access public
* @param array $values Input array
diff --git a/app/Model/User.php b/app/Model/User.php
index 8a7eff4a..5792a549 100644
--- a/app/Model/User.php
+++ b/app/Model/User.php
@@ -91,7 +91,7 @@ class User extends Base
->table(User::TABLE)
->eq('id', $user_id)
->eq('is_admin', 1)
- ->count() === 1;
+ ->exists();
}
/**
@@ -251,7 +251,7 @@ class User extends Base
$result = array();
foreach ($users as $user) {
- $result[$user['id']] = $user['name'] ?: $user['username'];
+ $result[$user['id']] = $this->getFullname($user);
}
asort($result);
@@ -278,7 +278,9 @@ class User extends Base
}
$this->removeFields($values, array('confirmation', 'current_password'));
- $this->resetFields($values, array('is_admin', 'is_ldap_user', 'is_project_admin'));
+ $this->resetFields($values, array('is_admin', 'is_ldap_user', 'is_project_admin', 'disable_login_form'));
+ $this->removeEmptyFields($values, array('gitlab_id'));
+ $this->convertIntegerFields($values, array('gitlab_id'));
}
/**
diff --git a/app/Template/user/create_remote.php b/app/Template/user/create_remote.php
index 1d04bc87..559d3d72 100644
--- a/app/Template/user/create_remote.php
+++ b/app/Template/user/create_remote.php
@@ -21,13 +21,13 @@
<?= $this->form->email('email', $values, $errors) ?><br/>
<?= $this->form->label(t('Google Id'), 'google_id') ?>
- <?= $this->form->password('google_id', $values, $errors) ?><br/>
+ <?= $this->form->text('google_id', $values, $errors) ?><br/>
<?= $this->form->label(t('Github Id'), 'github_id') ?>
- <?= $this->form->password('github_id', $values, $errors) ?><br/>
+ <?= $this->form->text('github_id', $values, $errors) ?><br/>
<?= $this->form->label(t('Gitlab Id'), 'gitlab_id') ?>
- <?= $this->form->password('gitlab_id', $values, $errors) ?><br/>
+ <?= $this->form->text('gitlab_id', $values, $errors) ?><br/>
</div>
<div class="form-column">