Example #1
0
function sendEventDigestPerGroup($group_guid)
{
    $group = get_entity($group_guid);
    if (empty($group) || !$group instanceof ElggGroup) {
        register_error(elgg_echo("zhgroup:digest:error") . elgg_echo("zhaohu:sorry"));
        elgg_log("ZHError, sendEventDigestPerGroup, group is invalid group_id {$group_guid}, user_id " . elgg_get_logged_in_user_guid(), "ERROR");
        return false;
    }
    $options = array("container_guid" => $group_guid, "has_updates" => true, 'offset' => 0, 'limit' => EVENT_IN_GROUP_DIGEST_LIMIT);
    $res = zhaohu_manager_find_zhaohus($options);
    $events = $res["entities"];
    $count = $res["count"];
    if ($count < EVENT_IN_GROUP_DIGEST_LIMIT) {
        return true;
    }
    $subject = elgg_echo("zhgroup:digest:subject", array($events['0']->title, $events['1']->title));
    $body = '<table align="center" border="0" cellspacing="0" cellpadding="0" width="634" bgcolor="#FFFFFF" style="min-width:634px;border-collapse:collapse;color:#222222"><tbody><tr>';
    $body .= '<table border="0" bgcolor="#f1f1f1" cellspacing="0" cellpadding="0" width="630" style="min-width:630px;border-collapse:collapse">' . '<tbody><tr><td style="padding:18px 0 15px 25px;color:#222222;font-family:sans-serif;font-size:20px;font-weight:bold">' . elgg_echo("zhgroup:digest:intro", array($group->getURL(), $group->name)) . '</td></tr></tbody></table>';
    $body .= '<table border="0" bgcolor="#FAFBFB" cellspacing="0" cellpadding="0" width="630" style="min-width:630px;border-collapse:collapse"><tbody>';
    $eventsInfo = array();
    $eventsIcon = array();
    $eventsAttendees = array();
    foreach ($events as $key => $event) {
        //fordebug register_error("event id {$event->title}");
        $eventsInfo[] = printDigestEventInfo($event);
        $eventsIcon[] = printDigestEventIcon($event);
        $eventsAttendees[] = '<tr><td width="606" style="min-width:606px;padding:0px 0 5px 25px">' . zhaohuPubEmailAttendees($event) . '</td></tr>';
    }
    $members = $group->getMembers(false);
    set_time_limit(0);
    //fordebug $done= false;
    foreach ($members as $member) {
        //fordebug register_error('mem id '.$member->guid . 'ground id '.$group_guid);
        if ($notification_settings = get_user_notification_settings($member->guid)) {
            if ($notification_settings->email && check_entity_relationship($member->guid, 'notifyemail', $group_guid)) {
                $bodyPerUser = $body;
                for ($i = 0; $i < $count; $i++) {
                    //left
                    $bodyPerUser .= $eventsInfo[$i];
                    $bodyPerUser .= '<tr><td>' . zhaohuPubEmailPart2($events[$i], $member->guid) . '</td></tr>';
                    $bodyPerUser .= '</tbody></table></td></tr></tbody></table>';
                    //right
                    $bodyPerUser .= $eventsIcon[$i];
                    $bodyPerUser .= '</div></td></tr>';
                    $bodyPerUser .= $eventsAttendees[$i];
                    $events[$i]->hasUpdates = false;
                }
                $bodyPerUser .= '</tbody></table></tr></tbody></table>';
                //fordebug if(!$done){ register_error("body {$bodyPerUser}"); $done=true;}
                zhgroups_send_email_to_user($group, $member, $subject, $bodyPerUser, true, true);
            }
        }
    }
    system_message(elgg_echo("zhgroup:digest:ok"));
}
Example #2
0
<?php

/**
 * Group zhaohu manager module
 */
$group = elgg_get_page_owner_entity();
if ($group->zhaohu_manager_enable == "no") {
    return true;
}
$zhaohu_options = array();
$zhaohu_options["container_guid"] = elgg_get_page_owner_guid();
$zhaohus = zhaohu_manager_find_zhaohus($zhaohu_options);
elgg_push_context("widgets");
$content = elgg_view_entity_list($zhaohus['entities'], array('count' => 0, 'offset' => 0, 'limit' => 5, 'full_view' => false));
elgg_pop_context();
if (!$content) {
    $content = '<p>' . elgg_echo('zhaohu:noresults') . '</p>';
}
$all_link = elgg_view('output/url', array('href' => "/zhaohus/zhaohu/list/" . $group->getGUID(), 'text' => elgg_echo('link:view:all')));
$new_link = elgg_view('output/url', array('href' => "/zhaohus/zhaohu/new/" . $group->getGUID(), 'text' => elgg_echo('zhaohu:new')));
echo elgg_view('groups/profile/module', array('title' => elgg_echo('zhaohu_manager:group'), 'content' => $content, 'all_link' => $all_link, 'add_link' => $new_link));
<?php

// generate a div which includes all the recommended zhaohus
$search_options = array('tags' => elgg_echo('AllInterests'), 'state' => elgg_echo('All'), 'city' => elgg_echo('All'), 'offset' => 0, 'limit' => ZHAOHU_RECOMMENDED_SHOW_LIMIT, 'featured_only' => 'y');
$zhaohus = zhaohu_manager_find_zhaohus($search_options);
$zhaohus_entities = $zhaohus["entities"];
$display_options = array("count" => ZHAOHU_RECOMMENDED_SHOW_LIMIT, "offset" => 0, "limit" => ZHAOHU_RECOMMENDED_SHOW_LIMIT, "full_view" => false, "pagination" => false);
$list = elgg_view_entity_list($zhaohus_entities, $display_options);
$content = "<div id='zhaohu_homepage_recommended_zhaohus' class='zhaohu_listing_mobile'>";
if (!empty($list)) {
    $content .= $list;
} else {
    $content .= elgg_echo('zhaohu:noresults');
}
$content .= "</div>";
echo $content;
Example #4
0
function getNextZhaohuForGroup($groupId)
{
    $zhaohu_options = array("container_guid" => $groupId, "limit" => 1, "past_zhaohus" => false);
    $zhaohus = zhaohu_manager_find_zhaohus($zhaohu_options);
    $zhEntities = $zhaohus["entities"];
    $nextZhaohu = null;
    if ($zhEntities) {
        $nextZhaohu = $zhEntities['0'];
    }
    return $nextZhaohu;
}