本文整理汇总了PHP中ElggObject类的典型用法代码示例。如果您正苦于以下问题:PHP ElggObject类的具体用法?PHP ElggObject怎么用?PHP ElggObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ElggObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
}
示例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();
}
示例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;
}
}
示例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();
}
}
示例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;
}
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
}
示例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));
}
}
示例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;
}
示例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());
}