本文整理汇总了PHP中ElggObject类的典型用法代码示例。如果您正苦于以下问题:PHP ElggObject类的具体用法?PHP ElggObject怎么用?PHP ElggObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ElggObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: process_page
function process_page(ElggObject $page)
{
$tags_to_groups = array('ib' => 10113262, 'inkomstenbelasting' => 10113262, 'ob' => 12967492, 'btw' => 12967492, 'omzetbelasting' => 12967492, 'lh' => 10112672, 'loonheffingen' => 10112672, 'open forum' => 7746192, 'toeslagen' => 7746232, 'Toeslagen' => 7746232, 'vennootschapsbelasting' => 7746292);
$container_guid = false;
if (!$page->tags) {
return;
}
if (!is_array($page->tags)) {
$tags = array($page->tags);
} else {
$tags = $page->tags;
}
foreach ($tags_to_groups as $tag => $group_guid) {
if (in_array($tag, $tags)) {
$container_guid = $group_guid;
continue;
}
}
$news = new ElggObject();
$news->subtype = "news";
$news->title = $page->title;
$news->description = $page->description;
$news->tags = $page->tags;
$news->owner_guid = $page->owner_guid;
$news->container_guid = $container_guid;
$news->access_id = get_default_access();
$news->save();
$news->time_created = $page->time_created;
$news->time_updated = $page->time_updated;
$news->save();
}
开发者ID:pleio,项目名称:rijkshuisstijl,代码行数:31,代码来源:ffd-copy-news.php
示例2: pleiofile_generate_file_thumbs
function pleiofile_generate_file_thumbs(ElggObject $file)
{
if ($file->simpletype != "image") {
return null;
}
$file->icontime = time();
$sizes = array(60 => "thumb", 153 => "tinythumb", 153 => "smallthumb", 600 => "largethumb");
$filename = str_replace("file/", "", $file->getFilename());
foreach ($sizes as $size => $description) {
if ($size < 600) {
$upscale = true;
} else {
$upscale = false;
}
$thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), $size, $size, $upscale);
if ($thumbnail) {
$path = "file/" . $description . "_" . $filename;
$thumb = new ElggFile();
$thumb->setMimeType($_FILES['upload']['type']);
$thumb->setFilename($path);
$thumb->open("write");
$thumb->write($thumbnail);
$thumb->close();
if ($description == "thumb") {
$file->thumbnail = $path;
} else {
$file->{$description} = $path;
}
unset($thumbnail);
}
}
}
开发者ID:pleio,项目名称:pleiofile,代码行数:32,代码来源:functions.php
示例3: current_dokuwiki_entity
function current_dokuwiki_entity($create = true)
{
$page_owner = elgg_get_page_owner_guid();
$user = elgg_get_logged_in_user_entity();
//error_log($page_owner->guid);
//error_log($user->guid);
if (!$page_owner) {
$page_owner = 0;
}
$entities = elgg_get_entities(array('types' => 'object', 'subtypes' => 'dokuwiki', 'limit' => 1, 'owner_guid' => $page_owner));
if ($entities) {
$doku = $entities[0];
return $doku;
} elseif ($user && $create) {
elgg_set_ignore_access(true);
$newdoku = new ElggObject();
$newdoku->access_id = ACCESS_PUBLIC;
$newdoku->owner_guid = $page_owner;
$newdoku->subtype = 'dokuwiki';
$newdoku->container_guid = $page_owner;
$newdoku->save();
$acl = array();
$acl[] = "# acl.auth.php";
$acl[] = '# <?php exit()?\\>';
$acl[] = "* @ALL 0";
$acl[] = "* @user 1";
$acl[] = "* @member 8";
$acl[] = "* @admin 16";
$acl[] = "* @root 255";
$newdoku->wiki_acl = implode("\n", $acl) . "\n";
elgg_set_ignore_access(false);
return $newdoku;
}
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:34,代码来源:dokuwiki.php
示例4: community_spam_messages_throttle
/**
* ban user if sending too many messages
*
* @param string $event
* @param string $type
* @param ElggObject $object
* @return bool
*/
function community_spam_messages_throttle($event, $type, $object)
{
if ($object->getSubtype() !== 'messages') {
return;
}
if (community_spam_is_new_user()) {
$msg_limit = elgg_get_plugin_setting('new_user_msg_limit', 'community_spam_tools');
} else {
$msg_limit = elgg_get_plugin_setting('msg_limit', 'community_spam_tools');
}
if (!$msg_limit) {
return;
}
// two message objects created per message but after they are saved,
// both are set to private so we only have access to one later on
$msg_limit = $msg_limit + 1;
$params = array('type' => 'object', 'subtype' => 'messages', 'created_time_lower' => time() - 5 * 60, 'metadata_names' => 'fromId', 'metadata_values' => elgg_get_logged_in_user_guid(), 'count' => true);
$num_msgs = elgg_get_entities_from_metadata($params);
if ($num_msgs > $msg_limit) {
$spammer = elgg_get_logged_in_user_entity();
$spammer->annotate('banned', 1);
// this integrates with ban plugin
$spammer->ban("Sent {$num_msgs} in 5 minutes");
return false;
}
}
开发者ID:elgg,项目名称:community_spam_tools,代码行数:34,代码来源:start.php
示例5: testCanSaveNewObject
/**
* @group current
*/
public function testCanSaveNewObject()
{
$subtype = 'test_subtype';
$subtype_id = add_subtype('object', $subtype);
$user = $this->mocks()->getUser();
_elgg_services()->session->setLoggedInUser($user);
$object = new \ElggObject();
$object->subtype = $subtype;
$object->title = 'Foo';
$object->description = 'Bar';
$object->owner_guid = $user->guid;
$object->container_guid = $user->guid;
$object->access_id = ACCESS_LOGGED_IN;
$object->time_created = time();
$object->setCurrentTime();
// We should be able to match timestamps
$now = $object->getCurrentTime()->getTimestamp();
$guid = $object->save();
$this->assertNotFalse($guid);
$object = get_entity($guid);
$this->assertEquals('object', $object->type);
$this->assertEquals($subtype_id, $object->subtype);
$this->assertEquals('Foo', $object->title);
$this->assertEquals('Foo', $object->getDisplayName());
$this->assertEquals('Bar', $object->description);
$this->assertEquals($user->guid, $object->getOwnerGUID());
$this->assertEquals($user, $object->getOwnerEntity());
$this->assertEquals($user->guid, $object->getContainerGUID());
$this->assertEquals($user, $object->getContainerEntity());
$this->assertEquals(ACCESS_LOGGED_IN, $object->access_id);
_elgg_services()->session->removeLoggedInUser();
}
开发者ID:elgg,项目名称:elgg,代码行数:35,代码来源:ElggObjectTest.php
示例6: app2_blog_save
function app2_blog_save($title, $text, $excerpt, $tags, $access, $container_guid)
{
$user = elgg_get_logged_in_user_entity();
if (!$user) {
throw new InvalidParameterException('registration:usernamenotvalid');
}
$obj = new ElggObject();
$obj->subtype = "blog";
$obj->owner_guid = $user->guid;
$obj->container_guid = $container_guid;
$obj->access_id = strip_tags($access);
$obj->method = "api";
$obj->description = strip_tags($text);
$obj->title = elgg_substr(strip_tags($title), 0, 140);
$obj->status = 'published';
$obj->comments_on = 'On';
$obj->excerpt = strip_tags($excerpt);
$obj->tags = strip_tags($tags);
$guid = $obj->save();
elgg_create_river_item('river/object/blog/create', 'create', $user->guid, $obj->guid);
if ($guid) {
return true;
} else {
return false;
}
}
开发者ID:elahegol,项目名称:APIPlugin,代码行数:26,代码来源:app.php
示例7: spam_login_filter_verify_action_hook
function spam_login_filter_verify_action_hook($hook, $entity_type, $returnvalue, $params)
{
//Check against stopforumspam and domain blacklist
$email = get_input('email');
$ip = spam_login_filter_get_ip();
if (spam_login_filter_check_spammer($email, $ip)) {
return true;
} else {
//Check if the ip exists
$options = array("type" => "object", "subtype" => "spam_login_filter_ip", "metadata_name_value_pairs" => array("name" => "ip_address", "value" => $ip), "count" => TRUE);
$ia = elgg_set_ignore_access(true);
$spam_login_filter_ip_list = elgg_get_entities_from_metadata($options);
if ($spam_login_filter_ip_list == 0) {
//Create the banned ip
$ip_obj = new ElggObject();
$ip_obj->subtype = 'spam_login_filter_ip';
$ip_obj->access_id = ACCESS_PRIVATE;
$ip_obj->ip_address = $ip;
$ip_obj->owner_guid = elgg_get_site_entity()->guid;
$ip_obj->container_guid = elgg_get_site_entity()->guid;
$ip_obj->save();
}
elgg_set_ignore_access($ia);
//return false;
forward();
}
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:27,代码来源:start.php
示例8: tidypics_2012111901
/**
* Change the tidypics_batch's access_id to container's access_id (album object)
*
* @param ElggObject $entity
* @param string $getter
* @param array $options
*/
function tidypics_2012111901($entity, $getter, $options)
{
$album = $entity->getContainerEntity();
if ($guid = tidypics_adjust_batch_access_id($entity, $album)) {
return $guid;
}
}
开发者ID:juho-jaakkola,项目名称:tidypics,代码行数:14,代码来源:2012111901.php
示例9: au_subgroups_clone_layout
/**
* Clones the custom layout of a parent group, for a newly created subgroup
* @param type $group
* @param type $parent
*/
function au_subgroups_clone_layout($group, $parent)
{
if (!elgg_is_active_plugin('group_custom_layout') || !group_custom_layout_allow($parent)) {
return false;
}
// get the layout object for the parent
if ($parent->countEntitiesFromRelationship(GROUP_CUSTOM_LAYOUT_RELATION) <= 0) {
return false;
}
$parentlayout = $parent->getEntitiesFromRelationship(GROUP_CUSTOM_LAYOUT_RELATION);
$parentlayout = $parentlayout[0];
$layout = new ElggObject();
$layout->subtype = GROUP_CUSTOM_LAYOUT_SUBTYPE;
$layout->owner_guid = $group->getGUID();
$layout->container_guid = $group->getGUID();
$layout->access_id = ACCESS_PUBLIC;
$layout->save();
// background image
$layout->enable_background = $parentlayout->enable_background;
$parentimg = elgg_get_config('dataroot') . 'group_custom_layout/backgrounds/' . $parent->getGUID() . '.jpg';
$groupimg = elgg_get_config('dataroot') . 'group_custom_layout/backgrounds/' . $group->getGUID() . '.jpg';
if (file_exists($parentimg)) {
copy($parentimg, $groupimg);
}
$layout->enable_colors = $parentlayout->enable_colors;
$layout->background_color = $parentlayout->background_color;
$layout->border_color = $parentlayout->border_color;
$layout->title_color = $parentlayout->title_color;
$group->addRelationship($layout->getGUID(), GROUP_CUSTOM_LAYOUT_RELATION);
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:35,代码来源:functions.php
示例10: hypeapps_inbox_monitor_flag_suspicious_messages
/**
* Flag suspicious messages
*
* @param string $event "create"
* @param string $type "object"
* @param ElggObject $entity Message
* @return void
*/
function hypeapps_inbox_monitor_flag_suspicious_messages($event, $type, $entity)
{
if ($entity->getSubtype() != 'messages') {
return;
}
$policy = elgg_get_plugin_setting('policy', 'hypeInboxMonitor', 'nothing');
$blacklist = hypeapps_inbox_monitor_get_blacklist();
$options = array('also_check' => $blacklist);
$filter = new \JCrowe\BadWordFilter\BadWordFilter($options);
$badWords = $filter->getDirtyWordsFromString("{$entity->title} {$entity->description}");
$entity->badwords = $badWords;
switch ($policy) {
case 'mask':
$entity->title = $filter->clean($entity->title);
$entity->description = $filter->clean($entity->title);
break;
case 'silence':
$replacement = '<span rel="bwsilent">$0</span>';
$entity->title = $filter->clean($entity->title, $replacement);
$entity->description = $filter->clean($entity->description, $replacement);
break;
case 'remove':
$replacement = '<span rel="bwremoved">[' . elgg_echo('inbox:monitor:removed') . ']</span>';
$entity->title = $filter->clean($entity->title, $replacement);
$entity->description = $filter->clean($entity->description, $replacement);
break;
}
$entity->save();
}
开发者ID:hypejunction,项目名称:hypeinboxmonitor,代码行数:37,代码来源:start.php
示例11: updateQuestion
/**
* After the question is updated in the databse make sure the answers have the same access_id
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param \ElggObject $entity the affected object
*
* @return void
*/
public static function updateQuestion($event, $type, $entity)
{
if (!$entity instanceof \ElggQuestion) {
return;
}
$org_attributes = $entity->getOriginalAttributes();
if (elgg_extract('access_id', $org_attributes) === null) {
// access wasn't updated
return;
}
// ignore access for this part
$ia = elgg_set_ignore_access(true);
// get all the answers for this question
$answers = $entity->getAnswers(['limit' => false]);
if (empty($answers)) {
// restore access
elgg_set_ignore_access($ia);
return;
}
/* @var $answer \ElggAnswer */
foreach ($answers as $answer) {
// update the access_id with the questions access_id
$answer->access_id = $entity->access_id;
$answer->save();
}
// restore access
elgg_set_ignore_access($ia);
}
开发者ID:coldtrick,项目名称:questions,代码行数:37,代码来源:Access.php
示例12: removeFolderContents
/**
* Remove all the files in this folder
*
* @param \ElggObject $entity the folder to removed the file from
*
* @return void
*/
protected static function removeFolderContents(\ElggObject $entity)
{
$batch = new \ElggBatch('elgg_get_entities_from_relationship', ['type' => 'object', 'subtype' => 'file', 'container_guid' => $entity->getContainerGUID(), 'limit' => false, 'relationship' => FILE_TOOLS_RELATIONSHIP, 'relationship_guid' => $entity->getGUID()]);
$batch->setIncrementOffset(false);
foreach ($batch as $file) {
$file->delete();
}
}
开发者ID:coldtrick,项目名称:file_tools,代码行数:15,代码来源:Folder.php
示例13: pad_pages_object_actions_menu
/**
* Prepare the add/edit form variables
*
* @param ElggObject $page
* @return array
*/
function pad_pages_object_actions_menu($colab, $page)
{
if (elgg_get_logged_in_user_guid() == $page->getOwnerGuid()) {
$name = $colab ? 'collaborative' : 'non-collaborative';
$url = "action/pages/make-{$name}/?guid={$page->guid}";
$text = elgg_echo("pages:make:{$name}");
elgg_register_menu_item('title', array('name' => $name, 'href' => $url, 'text' => $text, 'link_class' => 'elgg-button elgg-button-action', 'is_action' => true));
}
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:15,代码来源:pad_pages.php
示例14: save_question
function save_question($title, $body)
{
$question = new ElggObject();
$question->subtype = "question";
$question->access_id = ACCESS_PUBLIC;
$question->title = $title;
$question->description = $body;
$question->save();
return $question;
}
开发者ID:rkvsraman,项目名称:stackoverflow-elgg-plugin,代码行数:10,代码来源:save.php
示例15: createObject
/**
* Make sure we can autosubscribe the user to further updates
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param ElggObject $object the created comment
*
* @return void
*/
public static function createObject($event, $type, \ElggObject $object)
{
if (!$object instanceof \ElggComment) {
return;
}
$owner = $object->getOwnerEntity();
$entity = $object->getContainerEntity();
// add auto subscription for this user
content_subscriptions_autosubscribe($entity->getGUID(), $owner->getGUID());
}
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:19,代码来源:Comments.php
示例16: setUp
/**
* Create the entities used for each test
*/
protected function setUp()
{
$this->markTestSkipped("Skipped test as Elgg can not yet run PHP Unit tests that interact with the database");
$this->guids = array();
$obj1 = new \ElggObject();
$obj1->save();
$this->guids[] = $obj1->guid;
$obj2 = new \ElggObject();
$obj2->save();
$this->guids[] = $obj2->guid;
}
开发者ID:ibou77,项目名称:elgg,代码行数:14,代码来源:RelationshipsTest.php
示例17: elgg_modifications_generate_digischool_menu_page_handler
function elgg_modifications_generate_digischool_menu_page_handler($page)
{
admin_gatekeeper();
if (elgg_is_active_plugin("menu_builder")) {
// remove current menu items
$current_options = array("type" => "object", "subtype" => "menu_builder_menu_item", "limit" => false);
if ($current_items = elgg_get_entities($current_options)) {
foreach ($current_items as $current_item) {
$current_item->delete();
}
}
// var_dump($current_items);
// exit();
// add the new ones
$site = elgg_get_site_entity();
$site_acl = $site->getACL();
$menu_items = array(array("title" => "Voorpagina", "url" => "[wwwroot]", "access_id" => ACCESS_PUBLIC, "children" => array(array("title" => "Alle blogs", "url" => "[wwwroot]blog/all", "access_id" => ACCESS_PUBLIC), array("title" => "Alle activiteiten", "url" => "[wwwroot]activity", "access_id" => ACCESS_LOGGED_IN))), array("title" => "Statische pagina's", "url" => "[wwwroot]lidworden", "access_id" => ACCESS_LOGGED_IN), array("title" => "Archief", "url" => "Zelf in te vullen", "access_id" => ACCESS_PUBLIC), array("title" => "Leermiddelen", "url" => "#", "access_id" => ACCESS_PUBLIC, "children" => array(array("title" => "Vakpagina", "url" => "hier de link naar uw vakp", "access_id" => ACCESS_PUBLIC), array("title" => "Leermiddelenbank Digischool", "url" => "[wwwroot]", "access_id" => ACCESS_PUBLIC), array("title" => "Leden keurmerkgroepen", "url" => "zelf te vullen", "access_id" => ACCESS_PUBLIC))), array("title" => "Leden", "url" => "#", "access_id" => ACCESS_LOGGED_IN, "children" => array(array("title" => "Mijn groepen", "url" => "[wwwroot]groups/member/[username]", "access_id" => $site_acl), array("title" => "Mijn profielpagina", "url" => "[wwwroot]profile/[username]", "access_id" => $site_acl), array("title" => "Alle groepen", "url" => "[wwwroot]groups/all/?filter=pop", "access_id" => $site_acl), array("title" => "Lid worden", "url" => "[wwwroot]lidworden", "access_id" => ACCESS_PUBLIC), array("title" => "Content toevoegen", "url" => "[wwwroot]add", "access_id" => $site_acl), array("title" => "Mijn dashboard", "url" => "[wwwroot]dashboard", "access_id" => $site_acl), array("title" => "Zoeken leden", "url" => "[wwwroot]members", "access_id" => $site_acl), array("title" => "Mijn contacten", "url" => "[wwwroot]friends/[username]", "access_id" => $site_acl), array("title" => "Contactverzoeken", "url" => "[wwwroot]friend_request/", "access_id" => $site_acl), array("title" => "Mijn instellingen", "url" => "[wwwroot]settings", "access_id" => $site_acl), array("title" => "Nieuwe groep maken", "url" => "[wwwroot]groups/add", "access_id" => $site_acl))), array("title" => "Beheer", "url" => "[wwwroot]admin", "access_id" => ACCESS_PRIVATE, "children" => array(array("title" => "Gebruikersbeheer", "url" => "[wwwroot]admin/users/newest", "access_id" => ACCESS_PRIVATE), array("title" => "Nodig leden uit", "url" => "[wwwroot]admin/users/invite", "access_id" => ACCESS_PRIVATE), array("title" => "Pluginbeheer", "url" => "[wwwroot]admin/plugins", "access_id" => ACCESS_PRIVATE), array("title" => "Beheer template", "url" => "[wwwroot]admin/appearance/template", "access_id" => ACCESS_PRIVATE))));
$i = 0;
foreach ($menu_items as $main_item) {
$item = new ElggObject();
$item->subtype = "menu_builder_menu_item";
$item->owner_guid = $site->getGUID();
$item->container_guid = $site->getGUID();
$item->site_guid = $site->getGUID();
$item->access_id = $main_item["access_id"];
$item->parent_guid = 0;
$item->title = $main_item["title"];
$item->url = $main_item["url"];
$item->order = $i;
$i++;
$item->save();
if (array_key_exists("children", $main_item)) {
foreach ($main_item["children"] as $sub_item) {
$submenu_item = new ElggObject();
$submenu_item->subtype = "menu_builder_menu_item";
$submenu_item->owner_guid = $site->getGUID();
$submenu_item->container_guid = $site->getGUID();
$submenu_item->site_guid = $site->getGUID();
$submenu_item->access_id = $sub_item["access_id"];
$submenu_item->parent_guid = $item->getGUID();
$submenu_item->title = $sub_item["title"];
$submenu_item->url = $sub_item["url"];
$submenu_item->order = $i;
$i++;
$submenu_item->save();
}
}
}
system_message("menu created");
} else {
register_error("plugin menu_builder not activated");
}
forward();
}
开发者ID:pleio,项目名称:elgg_modifications,代码行数:54,代码来源:page_handlers.php
示例18: groups_2011030101
/**
* Condense annotation into object
*
* @param ElggObject $topic
*/
function groups_2011030101($topic)
{
$annotation = $topic->getAnnotations('group_topic_post', 1);
if (!$annotation) {
// no text for this forum post so we delete (probably caused by #2624)
return $topic->delete();
}
$topic->description = $annotation[0]->value;
$topic->save();
return $annotation[0]->delete();
}
开发者ID:redvabel,项目名称:Vabelgg,代码行数:16,代码来源:2011030101.php
示例19: testElggUserLoad
public function testElggUserLoad()
{
// new object
$object = new ElggObject();
$this->AssertEqual($object->getGUID(), 0);
$guid = $object->save();
$this->AssertNotEqual($guid, 0);
// fail on wrong type
$this->assertFalse(get_user($guid));
// clean up
$object->delete();
}
开发者ID:tjcaverly,项目名称:Elgg,代码行数:12,代码来源:ElggUserTest.php
示例20: crud_url_handler
/**
* Format and return the URL for crud object.
*
* @param ElggObject $entity Assembly object
* @return string URL of crud object.
*/
function crud_url_handler($entity)
{
if (!$entity->getOwnerEntity()) {
// default to a standard view if no owner.
return FALSE;
}
/*if (!$entity->testAssembly()) {
return FALSE;
}*/
//$friendly_title = elgg_get_friendly_title($entity->title);
return $entity->getSubtype() . "/view/{$entity->guid}";
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:18,代码来源:start.php
注:本文中的ElggObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论