New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Group to src #4046
Move Group to src #4046
Conversation
if (intval($def_gid)) { | ||
group_add_member($importer['uid'], '', $contact_record['id'], $def_gid); | ||
} | ||
Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before the change there was this if
that checked whether the default group was set. Is this covered in Group::addMember
now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, if the group id is invalid it doesn’t add anything.
@@ -289,7 +265,7 @@ function register_content(App $a) { | |||
'$passwords' => $passwords, | |||
'$password1' => array('password1', t('New Password:'), '', t('Leave empty for an auto generated password.')), | |||
'$password2' => array('confirm', t('Confirm:'), '', ''), | |||
'$nickdesc' => str_replace('$sitename',$a->get_hostname(), t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be \'<strong>nickname@$sitename</strong>\'.')), | |||
'$nickdesc' => t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be \'<strong>nickname@%s</strong>\'.', $a->get_hostname()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch that t(...)
already is doing the printf stuff.
src/Model/Group.php
Outdated
*/ | ||
public static function getIdByName($uid, $name) | ||
{ | ||
if ((! $uid) || (! strlen($name))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you could omit some paranthesis, if you want to.
src/Model/Group.php
Outdated
*/ | ||
public static function addMember($gid, $cid) | ||
{ | ||
if (!($gid && $cid)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that some if (!$gid || !$cid) {
is better to read than this line above.
src/Model/Group.php
Outdated
'selected' => '' | ||
] | ||
]; | ||
foreach ($groups as $group) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you use dba::select
you mustn't use a foreach
to go through the result but a dba::fetch
.
src/Model/Group.php
Outdated
} | ||
|
||
if (DBM::is_result($groups)) { | ||
foreach ($groups as $group) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the same like above. Additionally you can omit the is_result
since the dba::fetch
will handle it correctly if there is no result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some places where the database calls need to be fixed. Please have a look at other database calls in your PR as well - possibly I overlooked some of them.
- Improve negative conditions
src/Model/Group.php
Outdated
{ | ||
$o = ''; | ||
|
||
$stmt = dba::select('group', [], ['deleted' => 0, 'uid' => $uid], ['order' => ['name' => 'ASC']]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'ASC'
will not work as parameter. The system is expecting a boolean value (true
for "DESC", false
or no parameter at all for "ASC")
Sorry for spotting this just now. It was very early yesterday :-)
src/Model/Group.php
Outdated
] | ||
]; | ||
|
||
$stmt = dba::select('group', [], ['deleted' => 0, 'uid' => local_user()], ['order' => ['name' => 'ASC']]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There still are two small dba
issues.
Here you go! |
Just got this today, about 5 minutes ago, latest develop. |
It should be |
I just saw that it is wrong in api.php as well. There are two calls to Group::create_member as well. There it should be "addMember" I guess. P.S: Are you looking at it or should I create a PR? |
Watch out, If the group id is available, please use |
I can’t fix it at the moment, knock yourself out. |
Related to #3878
This is my tangential work for #4041, it became so big I have to submit it now before I go further.
Runs with no errors.
Corresponding PR in addons to come.