Esempio n. 1
0
 if ($error) {
     break;
 }
 switch ($name) {
     case 'tags':
         if ($value) {
             $values[$name] = string_to_tag_array($value);
         } else {
             unset($values[$name]);
         }
         break;
     case 'excerpt':
         if ($value) {
             $value = blog_make_excerpt($value);
         } else {
             $value = blog_make_excerpt($values['description']);
         }
         $values[$name] = $value;
         break;
     case 'container_guid':
         // this can't be empty or saving the base entity fails
         if (!empty($value)) {
             if (can_write_to_container($user->getGUID(), $value)) {
                 $values[$name] = $value;
             } else {
                 $error = elgg_echo("blog:error:cannot_write_to_container");
             }
         } else {
             unset($values[$name]);
         }
         break;
Esempio n. 2
0
 if ($guid) {
     $entity = get_entity($guid);
     if (elgg_instanceof($entity, 'object', 'blog') && $entity->canEdit()) {
         $blog = $entity;
     } else {
         $error = elgg_echo('blog:error:post_not_found');
     }
 } else {
     $blog = new ElggObject();
     $blog->subtype = 'blog';
     // force draft and private for autosaves.
     $blog->status = 'unsaved_draft';
     $blog->access_id = ACCESS_PRIVATE;
     $blog->title = $title;
     $blog->description = $description;
     $blog->excerpt = blog_make_excerpt($excerpt);
     // must be present or doesn't show up when metadata sorting.
     $blog->publish_date = time();
     if (!$blog->save()) {
         $error = elgg_echo('blog:error:cannot_save');
     }
 }
 // creat 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
     if ($auto_save_annotations = $blog->getAnnotations('blog_auto_save', 1)) {
         $auto_save = $auto_save_annotations[0];
     } else {
         $auto_save == FALSE;