diff options
| author | Cash Costello <cash.costello@gmail.com> | 2013-02-23 08:49:08 -0500 | 
|---|---|---|
| committer | Cash Costello <cash.costello@gmail.com> | 2013-02-23 08:49:08 -0500 | 
| commit | 1a2c97886f7335509ed1e1f65aff4464a32e01eb (patch) | |
| tree | 2ac208c9fdfe59a8be661b6d33af27f7429b02be | |
| parent | 9bda5425d8a1e33ce42ea11de12918706768c39b (diff) | |
| download | elgg-1a2c97886f7335509ed1e1f65aff4464a32e01eb.tar.gz elgg-1a2c97886f7335509ed1e1f65aff4464a32e01eb.tar.bz2  | |
Fixes #5012 drafts are private now
| -rw-r--r-- | mod/blog/actions/blog/save.php | 17 | ||||
| -rw-r--r-- | mod/blog/lib/blog.php | 4 | ||||
| -rw-r--r-- | mod/blog/start.php | 9 | 
3 files changed, 24 insertions, 6 deletions
diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 070c96398..6da70462a 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -2,6 +2,12 @@  /**   * Save blog entity   * + * Can be called by clicking save button or preview button. If preview button, + * we automatically save as draft. The preview button is only available for + * non-published drafts. + * + * Drafts are saved with the access set to private. + *   * @package Blog   */ @@ -99,11 +105,6 @@ foreach ($values as $name => $default) {  			}  			break; -		// don't try to set the guid -		case 'guid': -			unset($values['guid']); -			break; -  		default:  			$values[$name] = $value;  			break; @@ -115,6 +116,12 @@ if ($save == false) {  	$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) { diff --git a/mod/blog/lib/blog.php b/mod/blog/lib/blog.php index 3c71dfbab..8f15bd347 100644 --- a/mod/blog/lib/blog.php +++ b/mod/blog/lib/blog.php @@ -363,6 +363,10 @@ function blog_prepare_form_vars($post = NULL, $revision = NULL) {  				$values[$field] = $post->$field;  			}  		} + +		if ($post->status == 'draft') { +			$values['access_id'] = $post->future_access; +		}  	}  	if (elgg_is_sticky_form('blog')) { diff --git a/mod/blog/start.php b/mod/blog/start.php index eb6eee05f..a6ff84355 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -214,7 +214,14 @@ function blog_entity_menu_setup($hook, $type, $return, $params) {  		return $return;  	} -	if ($entity->canEdit() && $entity->status != 'published') { +	if ($entity->status != 'published') { +		// draft status replaces access +		foreach ($return as $index => $item) { +			if ($item->getName() == 'access') { +				unset($return[$index]); +			} +		} +  		$status_text = elgg_echo("blog:status:{$entity->status}");  		$options = array(  			'name' => 'published_status',  | 
