コード例 #1
0
ファイル: save.php プロジェクト: hypeJunction/news
    foreach ($values as $name => $value) {
        $news->{$name} = $value;
    }
}
// only try to save base entity if no errors
if (!$error) {
    if ($news->save()) {
        // remove sticky form entries
        elgg_clear_sticky_form('news');
        // remove autosave draft if exists
        $news->deleteAnnotations('news_auto_save');
        // no longer a brand new post.
        $news->deleteMetadata('new_post');
        // if this was an edit, create a revision annotation
        if (!$new_post && $revision_text) {
            $news->annotate('news_revision', $revision_text);
        }
        system_message(elgg_echo('news:message:saved'));
        $status = $news->status;
        // add to river if changing status or published, regardless of new post
        // because we remove it for drafts.
        if (($new_post || $old_status == 'draft') && $status == 'published') {
            elgg_create_river_item(array('view' => 'river/object/news/create', 'action_type' => 'create', 'subject_guid' => $news->owner_guid, 'object_guid' => $news->getGUID()));
            elgg_trigger_event('publish', 'news', $news);
            // reset the creation time for news posts that move from draft to published
            if ($guid) {
                $news->time_created = time();
                $news->save();
            }
        } elseif ($old_status == 'published' && $status == 'draft') {
            elgg_delete_river(array('object_guid' => $news->guid, 'action_type' => 'create'));
コード例 #2
0
            $error = elgg_echo('news:error:cannot_save');
        }
    }
    // create draft annotation
    if (!$error) {
        // annotations don't have a "time_updated" so
        // we have to delete everything or the times are wrong.
        // don't save if nothing changed
        $auto_save_annotations = $news->getAnnotations(array('annotation_name' => 'news_auto_save', 'limit' => 1));
        if ($auto_save_annotations) {
            $auto_save = $auto_save_annotations[0];
        } else {
            $auto_save = false;
        }
        if (!$auto_save) {
            $annotation_id = $news->annotate('news_auto_save', $description);
        } elseif ($auto_save instanceof ElggAnnotation && $auto_save->value != $description) {
            $news->deleteAnnotations('news_auto_save');
            $annotation_id = $news->annotate('news_auto_save', $description);
        } elseif ($auto_save instanceof ElggAnnotation && $auto_save->value == $description) {
            // this isn't an error because we have an up to date annotation.
            $annotation_id = $auto_save->id;
        }
        if (!$annotation_id) {
            $error = elgg_echo('news:error:cannot_auto_save');
        }
    }
} else {
    $error = elgg_echo('news:error:missing:description');
}
if ($error) {