Skip to content

Commit

Permalink
Merge pull request #259 from CodeForPhilly/develop
Browse files Browse the repository at this point in the history
Release: v3.1.5
  • Loading branch information
themightychris authored Oct 16, 2022
2 parents 10ab09c + 329834f commit 444cab8
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
5 changes: 5 additions & 0 deletions php-classes/Laddr/PeopleRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ protected static function onBeforeRecordDestroyed(\ActiveRecord $Person)
$ProjectMembership->destroy();
}

// delete tags
foreach ($Person->Tags as $Tag) {
$Tag->destroy();
}

// delete comments
foreach ($Person->Comments as $Comment) {
$Comment->destroy();
Expand Down
72 changes: 72 additions & 0 deletions php-config/Emergence/Mueller/Investigator.config.d/laddr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace Emergence\Mueller;

use DB;
use Emergence\People\IUser;
use Emergence\Slack\API as SlackAPI;

Investigator::$tests['email-invalid'] = false;

Investigator::$tests['has-about-url'] = [
'points' => -100,
'function' => function (IUser $User, array &$userCache) {
return $User->About && (stripos($User->About, 'http://') !== false || stripos($User->About, 'https://') !== false);
}
];

Investigator::$tests['has-comment-url'] = [
'points' => -100,
'function' => function (IUser $User, array &$userCache) {

foreach (Investigator::getUserComments($User, $userCache) as $Comment) {
if (
stripos($Comment['Message'], 'http://') !== false
|| stripos($Comment['Message'], 'https://') !== false
) {
return true;
}
}

return false;
}
];

Investigator::$tests['has-project'] = [
'points' => 1000,
'function' => function (IUser $User) {
static $projectMemberIds;

if ($projectMemberIds === null) {
$projectMemberIds = array_map(
'intval',
DB::allValues(
'MemberID',
'SELECT DISTINCT MemberID FROM `project_members`'
)
);
}

return in_array(strtolower($User->ID), $projectMemberIds);
},
];

if (SlackAPI::isAvailable()) {
Investigator::$tests['has-slack-account'] = [
'points' => 1000,
'function' => function (IUser $User) {
static $slackUsernames;

if ($slackUsernames === null) {
$slackMembersResponse = SlackAPI::request('users.list');
$slackUsernames = [];

foreach ($slackMembersResponse['members'] as $member) {
$slackUsernames[] = strtolower($member['name']);
}
}

return in_array(strtolower($User->Username), $slackUsernames);
}
];
}

0 comments on commit 444cab8

Please sign in to comment.