예제 #1
0
     } else {
         $error = elgg_echo('news:error:post_not_found');
     }
 } else {
     $news = new ElggNews();
     $news->subtype = 'news';
     // force draft and private for autosaves.
     $news->status = 'unsaved_draft';
     $news->access_id = ACCESS_PRIVATE;
     $news->title = $title;
     $news->description = $description;
     $news->excerpt = elgg_get_excerpt($excerpt);
     // mark this as a brand new post so we can work out the
     // river / revision logic in the real save action.
     $news->new_post = true;
     if (!$news->save()) {
         $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) {
예제 #2
0
파일: save.php 프로젝트: hypeJunction/news
    $values['status'] = 'draft';
}
// if draft, set access to private and cache the future access
if ($values['status'] == 'draft') {
    $values['future_access'] = $values['access_id'];
    $values['access_id'] = ACCESS_PRIVATE;
}
// assign values to the entity, stopping on error.
if (!$error) {
    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') {
예제 #3
0
파일: save.php 프로젝트: pleio/news
        register_error(elgg_echo('InvalidParameterException:NoEntityFound'));
        forward(REFERER);
    }
} else {
    $news = new ElggNews();
}
if (!$title) {
    register_error(elgg_echo('news:title:missing'));
    forward(REFERER);
}
$news->title = $title;
$news->description = $description;
$news->container_guid = $container_guid;
$news->access_id = $access_id;
$news->tags = $tags;
$news->save();
if ($guid && $top_photo == "remove") {
    $fh = new ElggFile();
    $fh->owner_guid = $news->guid;
    $fh->setFilename("top_photo.jpg");
    $fh->delete();
    $news->topPhotoTime = null;
    $news->save();
} elseif (get_resized_image_from_uploaded_file("top_photo", 1280, 330)) {
    $fh = new ElggFile();
    $fh->owner_guid = $news->guid;
    $fh->setFilename("top_photo.jpg");
    $fh->open("write");
    $contents = get_resized_image_from_uploaded_file("top_photo", 1280, 330);
    $fh->write($contents);
    $fh->close();