diff options
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/Base.php | 20 | ||||
-rw-r--r-- | app/Model/User.php | 8 |
2 files changed, 23 insertions, 5 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')); } /** |