本文整理汇总了PHP中ElggGroup::annotate方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggGroup::annotate方法的具体用法?PHP ElggGroup::annotate怎么用?PHP ElggGroup::annotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggGroup
的用法示例。
在下文中一共展示了ElggGroup::annotate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: group_tools_invite_email
function group_tools_invite_email(ElggGroup $group, $email, $text = "", $resend = false)
{
$result = false;
if (!empty($group) && $group instanceof ElggGroup && !empty($email) && is_email_address($email) && ($loggedin_user = elgg_get_logged_in_user_entity())) {
// get site secret
$site_secret = get_site_secret();
// generate invite code
$invite_code = md5($site_secret . $email . $group->getGUID());
if (!group_tools_check_group_email_invitation($invite_code, $group->getGUID()) || $resend) {
// make site email
$site = elgg_get_site_entity();
if (!empty($site->email)) {
if (!empty($site->name)) {
$site_from = $site->name . " <" . $site->email . ">";
} else {
$site_from = $site->email;
}
} else {
// no site email, so make one up
if (!empty($site->name)) {
$site_from = $site->name . " <noreply@" . get_site_domain($site->getGUID()) . ">";
} else {
$site_from = "noreply@" . get_site_domain($site->getGUID());
}
}
if (!$resend) {
// register invite with group
$group->annotate("email_invitation", $invite_code, ACCESS_LOGGED_IN, $group->getGUID());
}
// make subject
$subject = elgg_echo("group_tools:groups:invite:email:subject", array($group->name));
// make body
$body = elgg_echo("group_tools:groups:invite:email:body", array($loggedin_user->name, $group->name, $site->name, $text, $site->name, elgg_get_site_url() . "register", elgg_get_site_url() . "groups/invitations/?invitecode=" . $invite_code, $invite_code));
$result = elgg_send_email($site_from, $email, $subject, $body);
} else {
$result = null;
}
}
return $result;
}
示例2: test_disabling_annotations_infinite_loop
/**
* Ensure that \ElggBatch doesn't go into infinite loop when disabling annotations recursively when show hidden is enabled.
*
* https://github.com/Elgg/Elgg/issues/5952
*/
public function test_disabling_annotations_infinite_loop()
{
//let's have some entity
$group = new \ElggGroup();
$group->name = 'test_group';
$group->access_id = ACCESS_PUBLIC;
$this->assertTrue($group->save() !== false);
$total = 51;
//add some annotations
for ($cnt = 0; $cnt < $total; $cnt++) {
$group->annotate('test_annotation', 'value_' . $total);
}
//disable them
$show_hidden = access_get_show_hidden_status();
access_show_hidden_entities(true);
$options = array('guid' => $group->guid, 'limit' => $total);
elgg_disable_annotations($options);
access_show_hidden_entities($show_hidden);
//confirm all being disabled
$annotations = $group->getAnnotations(array('limit' => $total));
foreach ($annotations as $annotation) {
$this->assertTrue($annotation->enabled == 'no');
}
//delete group and annotations
$group->delete();
}
示例3: group_tools_invite_email
/**
* Invite a new user by email to a group
*
* @param ElggGroup $group the group to be invited for
* @param string $email the email address to be invited
* @param string $text (optional) extra text in the invitation
* @param boolean $resend should existing invitations be resend
*
* @return boolean|NULL true is invited, false on failure, null when already send
*/
function group_tools_invite_email(ElggGroup $group, $email, $text = "", $resend = false)
{
$result = false;
$loggedin_user = elgg_get_logged_in_user_entity();
if (!empty($group) && $group instanceof ElggGroup && !empty($email) && is_email_address($email) && !empty($loggedin_user)) {
// generate invite code
$invite_code = group_tools_generate_email_invite_code($group->getGUID(), $email);
if (!empty($invite_code)) {
$found_group = group_tools_check_group_email_invitation($invite_code, $group->getGUID());
if (empty($found_group) || $resend) {
// make site email
$site = elgg_get_site_entity();
if (!empty($site->email)) {
if (!empty($site->name)) {
$site_from = $site->name . " <" . $site->email . ">";
} else {
$site_from = $site->email;
}
} else {
// no site email, so make one up
if (!empty($site->name)) {
$site_from = $site->name . " <noreply@" . get_site_domain($site->getGUID()) . ">";
} else {
$site_from = "noreply@" . get_site_domain($site->getGUID());
}
}
if (empty($found_group)) {
// register invite with group
$group->annotate("email_invitation", $invite_code . "|" . $email, ACCESS_LOGGED_IN, $group->getGUID());
}
// make subject
$subject = elgg_echo("group_tools:groups:invite:email:subject", array($group->name));
// make body
$body = elgg_echo("group_tools:groups:invite:email:body", array($loggedin_user->name, $group->name, $site->name, $text, $site->name, elgg_get_site_url() . "register?group_invitecode=" . $invite_code, elgg_get_site_url() . "groups/invitations/?invitecode=" . $invite_code, $invite_code));
$params = array("group" => $group, "inviter" => $loggedin_user, "invitee" => $email);
$body = elgg_trigger_plugin_hook("invite_notification", "group_tools", $params, $body);
$result = elgg_send_email($site_from, $email, $subject, $body);
} else {
$result = null;
}
}
}
return $result;
}
示例4: group_tools_invite_email
/**
* Invite a new user by email to a group
*
* @param ElggGroup $group the group to be invited for
* @param string $email the email address to be invited
* @param string $text (optional) extra text in the invitation
* @param bool $resend should existing invitations be resend
*
* @return bool|NULL true is invited, false on failure, null when already send
*/
function group_tools_invite_email(ElggGroup $group, $email, $text = "", $resend = false)
{
$loggedin_user = elgg_get_logged_in_user_entity();
$resend = (bool) $resend;
if (!$group instanceof ElggGroup || empty($email) || !is_email_address($email) || empty($loggedin_user)) {
return false;
}
// generate invite code
$invite_code = group_tools_generate_email_invite_code($group->getGUID(), $email);
if (empty($invite_code)) {
return false;
}
$found_group = group_tools_check_group_email_invitation($invite_code, $group->getGUID());
if (!empty($found_group) && empty($resend)) {
return null;
}
// make site email
$site = elgg_get_site_entity();
if (!empty($site->email)) {
if (!empty($site->name)) {
$site_from = "{$site->name} <{$site->email}>";
} else {
$site_from = $site->email;
}
} else {
// no site email, so make one up
if (!empty($site->name)) {
$site_from = "{$site->name} <noreply@{$site->getDomain()}>";
} else {
$site_from = "noreply@{$site->getDomain()}";
}
}
if (empty($found_group)) {
// register invite with group
$group->annotate('email_invitation', "{$invite_code}|{$email}", ACCESS_LOGGED_IN, $group->getGUID());
}
// make subject
$subject = elgg_echo('group_tools:groups:invite:email:subject', [$group->name]);
// make body
$body = elgg_echo('group_tools:groups:invite:email:body', [$loggedin_user->name, $group->name, $site->name, $text, $site->name, elgg_normalize_url("register?group_invitecode={$invite_code}"), elgg_normalize_url("groups/invitations/?invitecode={$invite_code}"), $invite_code]);
$params = ['group' => $group, 'inviter' => $loggedin_user, 'invitee' => $email];
$body = elgg_trigger_plugin_hook('invite_notification', 'group_tools', $params, $body);
return elgg_send_email($site_from, $email, $subject, $body);
}