Completed
Push — api-test ( c6440b...e52d76 )
by
unknown
72:06 queued 45:47
created

blog.php ➔ save_blog()   F

Complexity

Conditions 62
Paths > 20000

Size

Total Lines 173
Code Lines 115

Duplication

Lines 34
Ratio 19.65 %

Importance

Changes 0
Metric Value
cc 62
eloc 115
nc 13471776
nop 10
dl 34
loc 173
rs 2
c 0
b 0
f 0

How to fix   Long Method    Complexity    Many Parameters   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
/*
3
 * Exposes API endpoints for Blog entities
4
 */
5
6
elgg_ws_expose_function(
7
	"get.blogpost",
8
	"get_blogpost",
9
	array(
10
		"user" => array('type' => 'string', 'required' => true),
11
		"guid" => array('type' => 'int', 'required' => true),
12
		"lang" => array('type' => 'string', 'required' => false, 'default' => "en")
13
	),
14
	'Retrieves a blog post & all replies based on user id and blog post id',
15
	'POST',
16
	true,
17
	false
18
);
19
20
elgg_ws_expose_function(
21
	"get.blogposts",
22
	"get_blogposts",
23
	array(
24
		"user" => array('type' => 'string', 'required' => true),
25
		"limit" => array('type' => 'int', 'required' => false, 'default' => 10),
26
		"offset" => array('type' => 'int', 'required' => false, 'default' => 0),
27
		"filters" => array('type' => 'string', 'required' => false, 'default' => ""),
28
		"lang" => array('type' => 'string', 'required' => false, 'default' => "en")
29
	),
30
	'Retrieves blog posts & all replies based on user id',
31
	'POST',
32
	true,
33
	false
34
);
35
36
elgg_ws_expose_function(
37
	"get.blogpostsbyowner",
38
	"get_blogposts_by_owner",
39
	array(
40
		"user" => array('type' => 'string', 'required' => true),
41
		"limit" => array('type' => 'int', 'required' => false, 'default' => 10),
42
		"offset" => array('type' => 'int', 'required' => false, 'default' => 0),
43
		"lang" => array('type' => 'string', 'required' => false, 'default' => "en"),
44
		"target" => array('type' => 'string', 'required'=> false, 'default' => '')
45
	),
46
	'Retrieves blog posts & all replies based on user id',
47
	'POST',
48
	true,
49
	false
50
);
51
52
elgg_ws_expose_function(
53
 "get.blogpostsbycolleague",
54
 "get_blogposts_by_colleague",
55
 array(
56
	"user" => array('type' => 'string', 'required' => true),
57
	"limit" => array('type' => 'int', 'required' => false, 'default' => 10),
58
	"offset" => array('type' => 'int', 'required' => false, 'default' => 0),
59
	"lang" => array('type' => 'string', 'required' => false, 'default' => "en")
60
 ),
61
 'Retrieves a container\'s blogs based on user id and container guid. Used for groups, as a group\'s blogs have container_id of the group.',
62
 'POST',
63
 true,
64
 false
65
);
66
67
elgg_ws_expose_function(
68
 "get.blogpostsbycontainer",
69
 "get_blogposts_by_container",
70
 array(
71
	 "user" => array('type' => 'string', 'required' => true),
72
	 "guid" => array('type' => 'int', 'required' => true),
73
	 "limit" => array('type' => 'int', 'required' => false, 'default' => 10),
74
	 "offset" => array('type' => 'int', 'required' => false, 'default' => 0),
75
	 "lang" => array('type' => 'string', 'required' => false, 'default' => "en")
76
 ),
77
 'Retrieves a container\'s blogs based on user id and container guid. Used for groups, as a group\'s blogs have container_id of the group.',
78
 'POST',
79
 true,
80
 false
81
);
82
83
elgg_ws_expose_function(
84
 "get.blogedit",
85
 "get_blog_edit",
86
 array(
87
	 "user" => array('type' => 'string', 'required' => true),
88
	 "guid" => array('type' => 'int', 'required' => true),
89
	 "lang" => array('type' => 'string', 'required' => false, 'default' => "en")
90
 ),
91
 'Retrieves a blog post based on user id and blog post id, with only info needed for edit form',
92
 'POST',
93
 true,
94
 false
95
);
96
97
elgg_ws_expose_function(
98
 "save.blog",
99
 "save_blog",
100
 array(
101
	 "user" => array('type' => 'string', 'required' => true),
102
	 "title" => array('type' => 'string', 'required' => true),
103
	 "excerpt" => array('type' =>'string', 'required' => false, 'default' => ''),
104
	 "body" => array('type' =>'string', 'required' => true),
105
	 "container_guid" => array('type' =>'string', 'required' => false, 'default' => ''),
106
	 "blog_guid" => array('type' =>'string', 'required' => false, 'default' => ''),
107
	 "comments" => array('type' =>'int', 'required' => false, 'default' => 1),
108
	 "access" => array('type' =>'int', 'required' => false, 'default' => 1),
109
	 "status" => array('type' =>'int', 'required' => false, 'default' => 0),
110
	 "lang" => array('type' => 'string', 'required' => false, 'default' => "en")
111
 ),
112
 'Posts/Saves a blog post',
113
 'POST',
114
 true,
115
 false
116
);
117
118
function foreach_blogs($blogs, $user_entity, $lang)
119
{
120
	foreach ($blogs as $blog_post) {
121
		$blog_post->title = gc_explode_translation($blog_post->title, $lang);
122
		$blog_post->description = gc_explode_translation($blog_post->description, $lang);
123
124
		$likes = elgg_get_annotations(array(
125
			'guid' => $blog_post->guid,
126
			'annotation_name' => 'likes'
127
		));
128
		$blog_post->likes = count($likes);
129
130
		$liked = elgg_get_annotations(array(
131
			'guid' => $blog_post->guid,
132
			'annotation_owner_guid' => $user_entity->guid,
133
			'annotation_name' => 'likes'
134
		));
135
		$blog_post->liked = count($liked) > 0;
136
137
		$blog_post->comments = get_entity_comments($blog_post->guid);
138
139
		$blog_post->userDetails = get_user_block($blog_post->owner_guid, $lang);
140
141
		$group = get_entity($blog_post->container_guid);
142
		$blog_post->group = gc_explode_translation($group->name, $lang);
143
144
		if (is_callable(array($group, 'getURL'))) {
145
			$blog_post->groupURL = $group->getURL();
146
		}
147
	}
148
	return $blogs;
149
}
150
151
function get_blogpost($user, $guid, $lang)
152
{
153
	$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user));
154
	if (!$user_entity) {
155
		return "User was not found. Please try a different GUID, username, or email address";
156
	}
157
	if (!$user_entity instanceof ElggUser) {
158
		return "Invalid user. Please try a different GUID, username, or email address";
159
	}
160
161
	$entity = get_entity($guid);
162
	if (!isset($entity)) {
163
		return "Blog was not found. Please try a different GUID";
164
	}
165
166
	if (!elgg_is_logged_in()) {
167
		login($user_entity);
168
	}
169
170
	$blog_posts = elgg_list_entities(array(
171
		'type' => 'object',
172
		'subtype' => 'blog',
173
		'guid' => $guid
174
	));
175
	$blog_post = json_decode($blog_posts)[0];
176
177
	$blog_post->title = gc_explode_translation($blog_post->title, $lang);
178
	$blog_post->description = gc_explode_translation($blog_post->description, $lang);
179
180
	$likes = elgg_get_annotations(array(
181
		'guid' => $blog_post->guid,
182
		'annotation_name' => 'likes'
183
	));
184
	$blog_post->likes = count($likes);
185
186
	$liked = elgg_get_annotations(array(
187
		'guid' => $blog_post->guid,
188
		'annotation_owner_guid' => $user_entity->guid,
189
		'annotation_name' => 'likes'
190
	));
191
	$blog_post->liked = count($liked) > 0;
192
193
	$blog_post->comments = get_entity_comments($blog_post->guid);
194
195
	$blog_post->userDetails = get_user_block($blog_post->owner_guid, $lang);
196
197
	$group = get_entity($blog_post->container_guid);
198
	$blog_post->group = gc_explode_translation($group->name, $lang);
199
200
	if (is_callable(array($group, 'getURL'))) {
201
		$blog_post->groupURL = $group->getURL();
202
	}
203
204
	return $blog_post;
205
}
206
207
function get_blogposts($user, $limit, $offset, $filters, $lang)
208
{
209
	$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user));
210
	if (!$user_entity) {
211
		return "User was not found. Please try a different GUID, username, or email address";
212
	}
213
	if (!$user_entity instanceof ElggUser) {
214
		return "Invalid user. Please try a different GUID, username, or email address";
215
	}
216
217
	if (!elgg_is_logged_in()) {
218
		login($user_entity);
219
	}
220
221
	$filter_data = json_decode($filters);
222
	if (!empty($filter_data)) {
223
		$params = array(
224
			'type' => 'object',
225
			'subtype' => 'blog',
226
			'limit' => $limit,
227
			'offset' => $offset
228
		);
229
230 View Code Duplication
		if ($filter_data->name) {
231
			$db_prefix = elgg_get_config('dbprefix');
232
			$params['joins'] = array("JOIN {$db_prefix}objects_entity oe ON e.guid = oe.guid");
233
			$params['wheres'] = array("(oe.title LIKE '%" . $filter_data->name . "%' OR oe.description LIKE '%" . $filter_data->name . "%')");
234
		}
235
236
		$all_blog_posts = elgg_list_entities_from_metadata($params);
237
	} else {
238
		$all_blog_posts = elgg_list_entities(array(
239
			'type' => 'object',
240
			'subtype' => 'blog',
241
			'limit' => $limit,
242
			'offset' => $offset
243
		));
244
	}
245
246
	$blog_posts = json_decode($all_blog_posts);
247
248
	$blogs = foreach_blogs($blog_posts, $user_entity, $lang);
249
250
	return $blogs;
251
}
252
253
function get_blogposts_by_owner($user, $limit, $offset, $lang, $target)
254
{
255
	$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user));
256
	if (!$user_entity) {
257
		return "User was not found. Please try a different GUID, username, or email address";
258
	}
259
	if (!$user_entity instanceof ElggUser) {
260
		return "Invalid user. Please try a different GUID, username, or email address";
261
	}
262
263
	$target_entity = $user_entity;
264
	if (!empty($target)){
265
		$target_entity =  is_numeric($target) ? get_user($target) : (strpos($target, '@') !== false ? get_user_by_email($target)[0] : get_user_by_username($target));
266
		if (!$target_entity) {
267
			return "Target user was not found. Please try a different GUID, username, or email address";
268
		}
269
		if (!$target_entity instanceof ElggUser) {
270
			return "Invalid target user. Please try a different GUID, username, or email address";
271
		}
272
	}
273
274
	if (!elgg_is_logged_in()) {
275
		login($user_entity);
276
	}
277
278
	$all_blog_posts = elgg_list_entities(array(
279
		'type' => 'object',
280
		'subtype' => 'blog',
281
		'owner_guid' => $target_entity->guid,
282
		'limit' => $limit,
283
		'offset' => $offset
284
	));
285
286
	$blog_posts = json_decode($all_blog_posts);
287
288
	$blogs = foreach_blogs($blog_posts, $user_entity, $lang);
289
290
	return $blogs;
291
}
292
293 View Code Duplication
function get_blogposts_by_colleague($user, $limit, $offset, $lang, $target)
294
{
295
 $user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user));
296
 if (!$user_entity) {
297
	 return "User was not found. Please try a different GUID, username, or email address";
298
 }
299
 if (!$user_entity instanceof ElggUser) {
300
	 return "Invalid user. Please try a different GUID, username, or email address";
301
 }
302
303
 if (!elgg_is_logged_in()) {
304
	 login($user_entity);
305
 }
306
307
 $all_blog_posts = elgg_list_entities_from_relationship(array(
308
	 'type' => 'object',
309
	 'subtype' => 'blog',
310
	 'relationship' => 'friend',
311
	 'relationship_guid' => $user_entity->guid,
312
	 'relationship_join_on' => 'container_guid',
313
	 'limit' => $limit,
314
	 'offset' => $offset
315
 ));
316
317
 $blog_posts = json_decode($all_blog_posts);
318
319
 $blogs = foreach_blogs($blog_posts, $user_entity, $lang);
320
321
 return $blogs;
322
}
323
324
325
function get_blogposts_by_container($user, $guid, $limit, $offset, $lang)
326
{
327
 $user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user));
328
 if (!$user_entity) {
329
	 return "User was not found. Please try a different GUID, username, or email address";
330
 }
331
 if (!$user_entity instanceof ElggUser) {
332
	 return "Invalid user. Please try a different GUID, username, or email address";
333
 }
334
 if (!elgg_is_logged_in()) {
335
	 login($user_entity);
336
 }
337
338
 $group = get_entity($guid);
339
 if (!$group) {
340
	 return "Group was not found. Please try a different GUID";
341
 }
342
 if (!$group instanceof ElggGroup) {
343
	 return "Invalid group. Please try a different GUID";
344
 }
345
346
 $all_blog_posts = elgg_list_entities(array(
347
	 'type' => 'object',
348
	 'subtype' => 'blog',
349
	 'container_guid' => $guid,
350
	 'limit' => $limit,
351
	 'offset' => $offset,
352
	 'order_by' => 'e.last_action desc'
353
 ));
354
355
 $blog_posts = json_decode($all_blog_posts);
356
357
 $blogs_final = foreach_blogs($blog_posts, $user_entity, $lang);
358
359
 return $blogs_final;
360
}
361
362
function get_blog_edit($user, $guid, $lang)
363
{
364
 $user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user));
365
 if (!$user_entity) {
366
	 return "User was not found. Please try a different GUID, username, or email address";
367
 }
368
 if (!$user_entity instanceof ElggUser) {
369
	 return "Invalid user. Please try a different GUID, username, or email address";
370
 }
371
372
 $entity = get_entity($guid);
373
 if (!isset($entity)) {
374
	 return "Blog was not found. Please try a different GUID";
375
 }
376
377
 if (!elgg_is_logged_in()) {
378
	 login($user_entity);
379
 }
380
381
 $blog_posts = elgg_list_entities(array(
382
	 'type' => 'object',
383
	 'subtype' => 'blog',
384
	 'guid' => $guid
385
 ));
386
 $blog_post = json_decode($blog_posts)[0];
387
388
 $blog_post->title = json_decode($blog_post->title);
389
 //$blog_post->excerpt = json_decode($blog_post->excerpt); //not correct
390
 $blog_post->description = json_decode($blog_post->description);
391
392
 $container = get_entity($blog_post->container_guid);
393
 if ($container instanceof ElggGroup){
394
	 $blog_post->group->public = $container->isPublicMembership();
395
	 if (!$blog_post->group->public && !$container->isMember($user_entity)){
396
		return elgg_echo('discussion:error:permissions');
397
	 }
398
 }
399
400
 if (is_callable(array($group, 'getURL'))) {
401
	 $blog_post->groupURL = $group->getURL();
0 ignored issues
show
Bug introduced by
The variable $group does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
402
 }
403
404
 return $blog_post;
405
}
406
407
function save_blog($user, $title, $excerpt, $body, $container_guid, $blog_guid, $comments, $access, $status, $lang)
408
{
409
 $user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user));
410
	 if (!$user_entity) {
411
		 return "User was not found. Please try a different GUID, username, or email address";
412
	 }
413
	 if (!$user_entity instanceof ElggUser) {
414
		 return "Invalid user. Please try a different GUID, username, or email address";
415
	 }
416
	 if (!elgg_is_logged_in()) {
417
		 login($user_entity);
418
	 }
419
	 $error = FALSE;
420
	 //check required fields being not empty
421
	 $titles = json_decode($title);
422
	 $bodies = json_decode($body);
423
	 $excerpts = json_decode($excerpt);
424
	 //Check Required
425
	 if (!$titles->en && !$titles->fr) { return elgg_echo("blog:error:missing:title"); }
426
	 if (!$bodies->en && !$bodies->fr) { return elgg_echo("blog:error:missing:description");  }
427 View Code Duplication
	 if (!($titles->en && $bodies->en) && !($titles->fr && $bodies->fr)) { return "require-same-lang"; }
428
	 //Default any Missing or faulty
429
	 if (!$titles->en) { $titles->en = ''; }
430
	 if (!$titles->fr) { $titles->fr = ''; }
431
	 if (!$bodies->en) { $bodies->en = ''; }
432
	 if (!$bodies->fr) { $bodies->fr = ''; }
433
	 if (!$excerpts->en) { $excerpts->en = ''; }
434
	 if (!$excerpts->fr) { $excerpts->fr = ''; }
435
	 if ($comments != 0 && $comments != 1) { $comments = 1; }
436
	 if ($access != 0 && $access != 1 && $access != -2 && $access !=2 ) { $access = 1; }
437
	 if ($status != 0 && $status != 1) { $status = 0; }
438
439
	 // if there is a container_guid, .: group, and access is set to group only, set access to proper group only
440
	 if (!empty($container_guid) && $access == 2){
441
		 $container = get_entity($container_guid);
442
		 //validate container and ability to write to it
443
		 if (!$container || !$container->canWriteToContainer(0, 'object', 'blog')) {
444
 			return elgg_echo('blog:error:cannot_write_to_container');
445
 		} else {
446
			$access = $container->group_acl;
447
		}
448
		 //If no group container, use user guid.
449
	 } else if ($container_guid=='') { $container_guid = $user_entity->guid; }
450
451
	 //Set int variables to correct
452
	 if ($status == 1) { $status = 'published'; } else { $status = 'draft'; }
453
	 if ($comments == 1) { $comments = 'On'; } else { $comments = 'Off'; }
454
	 if ($status == 'draft') { $access = 0; }
455
	 $titles->en = htmlspecialchars($titles->en, ENT_QUOTES, 'UTF-8');
456
	 $titles->fr = htmlspecialchars($titles->fr, ENT_QUOTES, 'UTF-8');
457
	 $excerpts->en = elgg_get_excerpt($excerpts->en);
458
	 $excerpts->fr = elgg_get_excerpt($excerpts->fr);
459
460
	 $values = array(
461
		 'title' => JSON_encode($titles),
462
		 'title2' => '',
463
		 //'title3' => '',
464
		 'description' => JSON_encode($bodies),
465
		 'description2' => '',
466
		 'description3' => '',
467
		 'status' => $status,
468
		 'access_id' => $access,
469
		 'comments_on' => $comments,
470
		 'excerpt' => JSON_encode($excerpts),
471
		 'excerpt2' => '',
472
		 'excerpt3' => '',
473
		 'tags' => '',
474
		 'publication_date' => '',
475
		 'expiration_date' => '',
476
		 'show_owner' => 'no'
477
	 );
478
479
	 $blog = new stdClass();
480
	 $revision_text = '';
481
	 if ($blog_guid){
482
		 $entity = get_entity($blog_guid);
483 View Code Duplication
		 if (elgg_instanceof($entity, 'object', 'blog') && $entity->canEdit()) {
484
			 	$blog = $entity;
485
		 } else {
486
			 return elgg_echo('blog:error:post_not_found');
487
		 }
488
		 $revision_text = $blog->description;
489
		 $new_post = $blog->new_post; //what?
490
	 } else {
491
		 //Create blog
492
		 $blog = new ElggBlog();
493
		 $blog->subtype = 'blog';
494
		 $blog->container_guid = $container_guid;
495
		 $new_post = TRUE;
496
	 }
497
498
	 $old_status = $blog->status;
499
500
	 // assign values to the entity, stopping on error.
501 View Code Duplication
	 if (!$error) {
502
		 foreach ($values as $name => $value) {
503
			 if (($name != 'title2') && ($name != 'description2') &&  ($name != 'excerpt2')){ // remove input 2 in metastring table
504
			 $blog->$name = $value;
505
			 }
506
		 }
507
	 }
508
509
	 if (!$error){
510
		 if ($blog->save()){
511
512
				 $icon_file = get_resized_image_from_uploaded_file("icon", 100, 100);
513
				 $icon_sizes = elgg_get_config("icon_sizes");
514
515 View Code Duplication
				 if (!empty($icon_file) && !empty($icon_sizes)) {
516
					 // create icon
517
					 $prefix = "blogs/" . $blog->getGUID();
518
519
					 $fh = new ElggFile();
520
					 $fh->owner_guid = $blog->getOwnerGUID();
521
522
					 foreach ($icon_sizes as $icon_name => $icon_info) {
523
						 $icon_file = get_resized_image_from_uploaded_file("icon", $icon_info["w"], $icon_info["h"], $icon_info["square"], $icon_info["upscale"]);
524
						 if (!empty($icon_file)) {
525
							 $fh->setFilename($prefix . $icon_name . ".jpg");
526
527
							 if ($fh->open("write")) {
528
								 $fh->write($icon_file);
529
								 $fh->close();
530
							 }
531
						 }
532
					 }
533
534
					 $blog->icontime = time();
535
			 }
536
537
			 // remove autosave draft if exists
538
			 $blog->deleteAnnotations('blog_auto_save');
539
			 // no longer a brand new post.
540
			 $blog->deleteMetadata('new_post');
541
			 if (!$new_post && $revision_text) {
542
				 $blog->annotate('blog_revision', $revision_text);
543
			 }
544
545
			 $status = $blog->status;
546
				 // add to river if changing status or published, regardless of new post
547
				 // because we remove it for drafts.
548
				 if (($new_post || $old_status == 'draft' ||  $old_status == 'published') && $status == 'published') {
549
					 elgg_create_river_item(array(
550
						 'view' => 'river/object/blog/create',
551
						 'action_type' => 'create',
552
						 'subject_guid' => $blog->owner_guid,
553
						 'object_guid' => $blog->getGUID(),
554
					 ));
555
					 // we only want notifications sent when post published
556
					 elgg_trigger_event('publish', 'object', $blog);
0 ignored issues
show
Documentation introduced by
$blog is of type object<ElggEntity>, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
557
558
					 // reset the creation time for posts that move from draft to published
559
					 if ($guid) {
0 ignored issues
show
Bug introduced by
The variable $guid does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
560
						 $blog->time_created = time();
561
						 $blog->save();
562
					 }
563
				 } elseif ($old_status == 'published' && $status == 'draft') {
564
					 elgg_delete_river(array(
565
						 'object_guid' => $blog->guid,
566
						 'action_type' => 'create',
567
					 ));
568
				 }
569
				 if ($blog->status == 'published' || $save == false) {
0 ignored issues
show
Bug introduced by
The variable $save does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
570
					 return ($blog->getURL());
571
				 } else {
572
					 return ("blog/edit/$blog->guid");
573
				 }
574
575
		 } else {
576
			 return elgg_echo('blog:error:cannot_save');
577
		 }
578
	 }
579
}
580