本文整理汇总了PHP中ElggObject::save方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggObject::save方法的具体用法?PHP ElggObject::save怎么用?PHP ElggObject::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggObject
的用法示例。
在下文中一共展示了ElggObject::save方法的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: setUp
/**
* Called before each test method.
*/
public function setUp()
{
$this->ignoreAccess = elgg_set_ignore_access(false);
$this->cache = elgg_get_metadata_cache();
$this->obj1 = new ElggObject();
$this->obj1->save();
$this->guid1 = $this->obj1->guid;
$this->obj2 = new ElggObject();
$this->obj2->save();
$this->guid2 = $this->obj2->guid;
}
示例3: setUp
/**
* Called before each test method.
*/
public function setUp()
{
$this->ignoreAccess = elgg_set_ignore_access(false);
$this->cache = _elgg_services()->metadataCache;
$this->obj1 = new \ElggObject();
$this->obj1->save();
$this->guid1 = $this->obj1->guid;
$this->obj2 = new \ElggObject();
$this->obj2->save();
$this->guid2 = $this->obj2->guid;
}
示例4: testCommentAccessSync
public function testCommentAccessSync()
{
_elgg_disable_caching_for_entity($this->comment->guid);
_elgg_disable_caching_for_entity($this->container->guid);
$this->assertEqual($this->comment->access_id, $this->container->access_id);
// now change the access of the container
$this->container->access_id = ACCESS_LOGGED_IN;
$this->container->save();
$updated_container = get_entity($this->container->guid);
$updated_comment = get_entity($this->comment->guid);
$this->assertEqual($updated_comment->access_id, $updated_container->access_id);
}
示例5: 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();
}
}
示例6: 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();
}
示例7: 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;
}
}
示例8: 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;
}
}
示例9: save
function save()
{
$guid = parent::save();
try {
$sessionID = $this->startSession();
$groupID = $this->groupID;
// Create a pad if not exists
if (!$this->pname) {
$name = uniqid();
$this->get_pad_client()->createGroupPad($groupID, $name, elgg_get_plugin_setting('new_pad_text', 'etherpad'));
$this->setMetaData('pname', $groupID . "\$" . $name);
}
$padID = $this->getMetadata('pname');
//set etherpad permissions
if ($this->access_id == ACCESS_PUBLIC) {
$this->get_pad_client()->setPublicStatus($padID, "true");
} else {
$this->get_pad_client()->setPublicStatus($padID, "false");
}
$this->get_pad_client()->deleteSession($sessionID);
} catch (Exception $e) {
register_error($e->getMessage());
return false;
}
return $guid;
}
示例10: 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();
}
示例11: 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);
}
示例12: save
/**
* Update container entity last action on successful save.
*
* @param bool $update_last_action Update the container entity's last_action field
* @return bool|int
*/
public function save($update_last_action = true)
{
$result = parent::save();
if ($result && $update_last_action) {
update_entity_last_action($this->container_guid, $this->time_updated);
}
return $result;
}
示例13: save
/**
* Save the subscription to the database
*
* @return bool
*
* @see ElggObject::save()
*/
public function save()
{
// ignore access restrictions
$ia = elgg_set_ignore_access(true);
$result = parent::save();
// restore access
elgg_set_ignore_access($ia);
return $result;
}
示例14: save
function save()
{
if (!$this->guid) {
$this->attributes["owner_guid"] = elgg_get_logged_in_user_guid();
$this->attributes["container_guid"] = elgg_get_logged_in_user_guid();
$this->attributes["access_id"] = ACCESS_PRIVATE;
}
return parent::save();
}
示例15: 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;
}