本文整理汇总了PHP中elgg_get_entities_from_relationship函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_entities_from_relationship函数的具体用法?PHP elgg_get_entities_from_relationship怎么用?PHP elgg_get_entities_from_relationship使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_get_entities_from_relationship函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pleiofile_add_folder_to_zip
function pleiofile_add_folder_to_zip(ZipArchive &$zip_archive, ElggObject $folder, $folder_path = "")
{
if (!empty($zip_archive) && !empty($folder) && elgg_instanceof($folder, "object", "folder")) {
$folder_title = elgg_get_friendly_title($folder->title);
$zip_archive->addEmptyDir($folder_path . $folder_title);
$folder_path .= $folder_title . DIRECTORY_SEPARATOR;
$file_options = array("type" => "object", "subtype" => "file", "limit" => false, "relationship" => "folder_of", "relationship_guid" => $folder->getGUID());
// add files from this folder to the zip
if ($files = elgg_get_entities_from_relationship($file_options)) {
foreach ($files as $file) {
// check if the file exists
if ($zip_archive->statName($folder_path . $file->originalfilename) === false) {
// doesn't exist, so add
$zip_archive->addFile($file->getFilenameOnFilestore(), $folder_path . sanitize_file_name($file->originalfilename));
} else {
// file name exists, so create a new one
$ext_pos = strrpos($file->originalfilename, ".");
$file_name = substr($file->originalfilename, 0, $ext_pos) . "_" . $file->getGUID() . substr($file->originalfilename, $ext_pos);
$zip_archive->addFile($file->getFilenameOnFilestore(), $folder_path . sanitize_file_name($file_name));
}
}
}
// check if there are subfolders
$folder_options = array("type" => "object", "subtype" => "folder", "limit" => false, "metadata_name_value_pairs" => array("parent_guid" => $folder->getGUID()));
if ($sub_folders = elgg_get_entities_from_metadata($folder_options)) {
foreach ($sub_folders as $sub_folder) {
pleiofile_add_folder_to_zip($zip_archive, $sub_folder, $folder_path);
}
}
}
}
示例2: get_object_sites
/**
* Get the sites this object is part of
*
* @param int $object_guid The object's GUID
* @param int $limit Number of results to return
* @param int $offset Any indexing offset
*
* @return array On success, an array of ElggSites
*/
function get_object_sites($object_guid, $limit = 10, $offset = 0)
{
$object_guid = (int) $object_guid;
$limit = (int) $limit;
$offset = (int) $offset;
return elgg_get_entities_from_relationship(array('relationship' => 'member_of_site', 'relationship_guid' => $object_guid, 'types' => 'site', 'limit' => $limit, 'offset' => $offset));
}
示例3: getGroup
/**
* @SWG\Get(
* path="/api/groups/{guid}/members",
* security={{"oauth2": {"all"}}},
* tags={"members"},
* summary="Find members in a specific group.",
* description="Find the members from a specific group.",
* produces={"application/json"},
* @SWG\Parameter(
* name="guid",
* in="path",
* description="The guid of the specific group",
* required=true,
* type="integer",
* @SWG\Items(type="integer")
* ),
* @SWG\Parameter(
* name="offset",
* in="query",
* description="Offset the results by",
* default=0,
* required=false,
* type="integer",
* @SWG\Items(type="integer")
* ),
* @SWG\Parameter(
* name="limit",
* in="query",
* description="Limit the results by",
* default=20,
* required=false,
* type="integer",
* @SWG\Items(type="integer")
* ),
* @SWG\Response(
* response=200,
* description="Succesful operation.",
* @SWG\Schema(
* type="array",
* @SWG\Items(ref="#/definitions/Event")
* ),
* ),
* @SWG\Response(
* response="404",
* description="Could not find the requested event.",
* )
* )
*/
public function getGroup($request, $response, $args)
{
$currentUser = elgg_get_logged_in_user_entity();
$guid = (int) $args['guid'];
$group = get_entity($guid);
if (!$group | !$group instanceof \ElggGroup) {
return $response->withStatus(404);
}
$params = $request->getQueryParams();
$limit = (int) $params['limit'];
$offset = (int) $params['offset'];
if (!$limit | $limit < 0 | $limit > 100) {
$limit = 20;
}
$db_prefix = elgg_get_config('dbprefix');
$options = array('relationship' => 'member', 'relationship_guid' => $group->guid, 'inverse_relationship' => true, 'type' => 'user', 'limit' => $limit, 'offset' => $offset, 'joins' => array("JOIN {$db_prefix}users_entity oe ON e.guid = oe.guid"), 'order_by' => 'oe.name');
$entities = array();
foreach (elgg_get_entities_from_relationship($options) as $entity) {
$entities[] = $this->parseUser($entity);
}
$options['count'] = true;
$total = elgg_get_entities_from_relationship($options);
$response = $response->withHeader('Content-type', 'application/json');
return $response->write(json_encode(array('total' => $total, 'entities' => $entities), JSON_PRETTY_PRINT));
}
示例4: countRegistrations
/**
* Counts the number of registrations
*
* @return boolean|int
*/
public function countRegistrations()
{
$old_ia = elgg_set_ignore_access(true);
$result = elgg_get_entities_from_relationship(array("relationship" => EVENT_MANAGER_RELATION_SLOT_REGISTRATION, "relationship_guid" => $this->getGUID(), "inverse_relationship" => true, "count" => true, "site_guids" => false));
elgg_set_ignore_access($old_ia);
return $result;
}
示例5: countAttendees
public function countAttendees($count = true)
{
$old_ia = elgg_set_ignore_access(true);
$entities = elgg_get_entities_from_relationship(array('relationship' => ZHAOHU_MANAGER_RELATION_ATTENDING, 'relationship_guid' => $this->getGUID(), 'inverse_relationship' => FALSE, 'count' => $count));
elgg_set_ignore_access($old_ia);
return $entities;
}
示例6: threads_get_all_replies
function threads_get_all_replies($entity_guid, $options = array())
{
$options['relationship_guid'] = $entity_guid;
$defaults = array('relationship' => 'top', 'inverse_relationship' => true, 'order_by' => 'e.time_created asc');
$options = array_merge($defaults, $options);
return elgg_get_entities_from_relationship($options);
}
示例7: GetPendingNotifications
public function GetPendingNotifications($data)
{
$notifications = elgg_get_entities_from_relationship(array('relationship' => \WizmassNotifier\Interfaces\WizmassNotification::HAS_ACTOR, 'relationship_guid' => $data->token->user_guid, 'inverse_relationship' => true));
$readNotifications = elgg_get_entities_from_relationship(array('relationship' => \WizmassNotifier\Interfaces\WizmassNotification::WAS_READ, 'relationship_guid' => $data->token->user_guid, 'inverse_relationship' => true));
$readNotificationsGuids = array_map(function ($item) {
return $item->guid;
}, $readNotifications);
$this->logger->info('processing ' . count($notifications) . ' notifications');
$notificationFactory = NotificationFactory::getInstance();
/** @var WizmassNotification[] $notificationsToSend */
$notificationsToSend = [];
/** @var \ElggEntity $notification */
foreach ($notifications as $notification) {
/** @var WizmassNotification $wizmassNotification */
$wizmassNotification = $notificationFactory->Build($notification);
if (!$wizmassNotification) {
$this->logger->info('error building notification: ' . $notification->guid);
} else {
$data = $wizmassNotification->BuildNotificationData();
if (!in_array($notification->guid, $readNotificationsGuids)) {
$data['read'] = false;
} else {
$data['read'] = true;
}
$notificationsToSend[] = $data;
}
}
return $notificationsToSend;
}
示例8: friend_request_pagesetup
function friend_request_pagesetup()
{
$context = elgg_get_context();
$page_owner = elgg_get_page_owner_entity();
// Remove link to friendsof
elgg_unregister_menu_item("page", "friends:of");
if ($user = elgg_get_logged_in_user_entity()) {
$options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $user->getGUID(), "inverse_relationship" => true);
if ($count = elgg_get_entities_from_relationship($options)) {
$params = array("name" => "friend_request", "href" => "friend_request/" . $user->username, "text" => elgg_view_icon("user") . "<span class='friend-request-new'>" . $count . "</span>", "title" => elgg_echo("friend_request:menu"), "priority" => 301);
elgg_register_menu_item("topbar", $params);
}
}
// Show menu link in the correct context
if (in_array($context, array("friends", "friendsof", "collections", "messages")) && !empty($page_owner) && $page_owner->canEdit()) {
$options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $page_owner->getGUID(), "inverse_relationship" => true);
if ($count = elgg_get_entities_from_relationship($options)) {
$extra = " [" . $count . "]";
} else {
$extra = "";
}
// add menu item
$menu_item = array("name" => "friend_request", "text" => elgg_echo("friend_request:menu") . $extra, "href" => "friend_request/" . $page_owner->username, "contexts" => array("friends", "friendsof", "collections", "messages"), "section" => "friend_request");
elgg_register_menu_item("page", $menu_item);
}
}
示例9: countRegistrations
/**
* Counts the number of registrations
*
* @return boolean|int
*/
public function countRegistrations()
{
$old_ia = elgg_set_ignore_access(true);
$result = elgg_get_entities_from_relationship(['relationship' => EVENT_MANAGER_RELATION_SLOT_REGISTRATION, 'relationship_guid' => $this->getGUID(), 'inverse_relationship' => true, 'count' => true, 'site_guids' => false]);
elgg_set_ignore_access($old_ia);
return $result;
}
示例10: file_tools_object_handler_delete
function file_tools_object_handler_delete($event, $type, $object)
{
static $delete_files;
if (!empty($object) && elgg_instanceof($object, "object", FILE_TOOLS_SUBTYPE)) {
// find subfolders
$options = array("type" => "object", "subtype" => FILE_TOOLS_SUBTYPE, "container_guid" => $object->getContainerGUID(), "limit" => false, "metadata_name_value_pairs" => array("name" => "parent_guid", "value" => $object->getGUID()), "wheres" => array("(e.guid <> " . $object->getGUID() . ")"));
if ($subfolders = elgg_get_entities_from_metadata($options)) {
// delete subfolders
foreach ($subfolders as $subfolder) {
$subfolder->delete();
}
}
// fill the static, to delete files in a folder
if (!isset($delete_files)) {
$delete_files = false;
if (get_input("files") == "yes") {
$delete_files = true;
}
}
// should we remove files?
if ($delete_files) {
// find file in this folder
$options = array("type" => "object", "subtype" => "file", "container_guid" => $object->getContainerGUID(), "limit" => false, "relationship" => FILE_TOOLS_RELATIONSHIP, "relationship_guid" => $object->getGUID());
if ($files = elgg_get_entities_from_relationship($options)) {
// delete files in folder
foreach ($files as $file) {
$file->delete();
}
}
}
}
}
示例11: gvfriendrequest_pagesetup
function gvfriendrequest_pagesetup()
{
$context = elgg_get_context();
$page_owner = elgg_get_page_owner_entity();
// Remove link to friendsof
elgg_unregister_menu_item("page", "friends:of");
if ($user = elgg_get_logged_in_user_entity()) {
$options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $user->getGUID(), "inverse_relationship" => true);
if ($count = elgg_get_entities_from_relationship($options)) {
$class = "elgg-icon elgg-icon-users";
$text = "<span class='{$class}'></span>";
$tooltip = elgg_echo('gvtheme:myfriends');
if ($count > 0) {
$text .= "<span class=\"messages-new\">{$count}</span>";
$tooltip = elgg_echo("friend_request:unreadcount", array($count));
}
$params = array("name" => "friends", "href" => "friend_request/" . $user->username, "text" => $text, "section" => 'alt', "title" => $tooltip);
elgg_register_menu_item("topbar", $params);
}
}
// Show menu link in the correct context
if (in_array($context, array("friends", "friendsof", "collections")) && !empty($page_owner) && $page_owner->canEdit()) {
$options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $page_owner->getGUID(), "inverse_relationship" => true);
if ($count = elgg_get_entities_from_relationship($options)) {
$extra = " (" . $count . ")";
} else {
$extra = "";
}
// add menu item
$menu_item = array("name" => "friend_request", "text" => elgg_echo("friend_request:menu") . $extra, "href" => "friend_request/" . $page_owner->username, "contexts" => array("friends", "friendsof", "collections"), "section" => "friend_request");
elgg_register_menu_item("page", $menu_item);
}
}
示例12: hj_forum_get_latest_posts
/**
* Get latest posts
*
* @param int $container_guid Guid of the topic or forum
* @param int $limit Number of posts to return
* @param boolean $count Return a total number of posts
* @param boolean $recursive Recurse into the forum tree (nested forums and topics)
* @return mixed
*/
function hj_forum_get_latest_posts($container_guid, $limit = 10, $count = false, $recursive = false)
{
$options = array('types' => 'object', 'subtypes' => array('hjforumpost', 'hjforumtopic'), 'count' => $count, 'limit' => $limit, 'relationship' => 'descendant', 'relationship_guid' => $container_guid, 'inverse_relationship' => true, 'order_by' => 'e.time_created DESC');
if (!$recursive) {
$options['container_guids'] = $container_guid;
}
return elgg_get_entities_from_relationship($options);
}
示例13: hj_framework_get_entities_by_priority
/**
* Get a list of entities sorted by priority
*
* @param string $type
* @param string $subtype
* @param int $owner_guid
* @param int $container_guid
* @param int $limit
* @return array An array of ElggEntity
*/
function hj_framework_get_entities_by_priority($options = array())
{
if (!is_array($options) || empty($options)) {
return false;
}
$defaults = array('order_by_metadata' => array('name' => 'priority', 'value' => 'ASC'));
$options = array_merge($defaults, $options);
return elgg_get_entities_from_relationship($options);
}
示例14: get_relatedgroups
/**
* Gives the list of the group related groups
*
* @param ElggGroup $group
* @return array
*/
function get_relatedgroups($group, $options = array())
{
if ($group instanceof ElggGroup) {
$options['relationship'] = 'related';
$options['relationship_guid'] = $group->guid;
return elgg_get_entities_from_relationship(array($options));
} else {
return false;
}
}
示例15: get_parent_group
function get_parent_group($guid)
{
global $CONFIG;
$parent = elgg_get_entities_from_relationship(array('types' => array('group'), 'limit' => 1, 'relationship' => AU_SUBGROUPS_RELATIONSHIP, 'relationship_guid' => $guid));
if (is_array($parent)) {
$CONFIG->padre = $parent[0];
//echo $CONFIG->padre->guid;
return $parent[0];
}
}