예제 #1
0
/**
 * Check is notifications for this entity are allowed
 *
 * @param int $entity_guid the entity guid
 *
 * @return bool
 */
function tag_tools_is_notification_entity($entity_guid)
{
    $entity_guid = sanitise_int($entity_guid);
    $entity_row = get_entity_as_row($entity_guid);
    if (empty($entity_row)) {
        return false;
    }
    $type_subtypes = tag_tools_get_notification_type_subtypes();
    if (empty($type_subtypes) || !is_array($type_subtypes)) {
        return false;
    }
    $type = $entity_row->type;
    if (empty($type) || !isset($type_subtypes[$type])) {
        return false;
    }
    $subtype = get_subtype_from_id($entity_row->subtype);
    if (empty($subtype)) {
        // user, group, site
        return true;
    }
    return in_array($subtype, elgg_extract($type, $type_subtypes));
}
<?php

// add description
echo elgg_view('output/longtext', ['value' => elgg_echo('admin:upgrades:set_tag_notifications_sent:description')]);
// how much content to upgrade
$count = 0;
$type_subtypes = tag_tools_get_notification_type_subtypes();
if (!empty($type_subtypes)) {
    $dbprefix = elgg_get_config('dbprefix');
    $count = elgg_get_entities_from_metadata(['type_subtype_pairs' => $type_subtypes, 'count' => true, 'metadata_name_value_pairs' => ['name' => 'tags', 'value' => '', 'operand' => '!='], 'wheres' => ["NOT EXISTS (\n\t\t\tSELECT 1 FROM {$dbprefix}private_settings ps\n\t\t\tWHERE ps.entity_guid = e.guid\n\t\t\tAND ps.name = 'tag_tools:sent_tags')"]]);
}
// show upgrade progress + start button
echo elgg_view('admin/upgrades/view', ['count' => $count, 'action' => 'action/tag_tools/upgrades/set_tag_notifications_sent']);
예제 #3
0
/**
 * Check is notifications for this entity are allowed
 *
 * @param int $entity_guid the entity guid
 *
 * @return bool
 */
function tag_tools_is_notification_entity($entity_guid)
{
    $entity_guid = sanitise_int($entity_guid);
    $entity = get_entity($entity_guid);
    if (empty($entity)) {
        return false;
    }
    $type_subtypes = tag_tools_get_notification_type_subtypes();
    if (empty($type_subtypes) || !is_array($type_subtypes)) {
        return false;
    }
    $type = $entity->getType();
    if (empty($type) || !isset($type_subtypes[$type])) {
        return false;
    }
    $subtypes = elgg_extract($type, $type_subtypes);
    $subtype = $entity->getSubtype();
    if (empty($subtype)) {
        // user, group, site
        return true;
    }
    return in_array($subtype, $subtypes);
}