[Customisation Database Commits] r935 - in /trunk/titania: contributions/manage.php styles/default/template/contributions/contribution_manage.html

Mickael SALFATI elglobo at phpbb-services.com
Mon Mar 29 12:11:45 BST 2010


Author: elglobo
Date: Mon Mar 29 12:11:44 2010
New Revision: 935

Log:
Add option to change permalink for moderators.

Modified:
    trunk/titania/contributions/manage.php
    trunk/titania/styles/default/template/contributions/contribution_manage.html

Modified: trunk/titania/contributions/manage.php
==============================================================================
*** trunk/titania/contributions/manage.php (original)
--- trunk/titania/contributions/manage.php Mon Mar 29 12:11:44 2010
***************
*** 37,42 ****
--- 37,43 ----
  $error = array();
  $contrib_status = request_var('contrib_status', (int) titania::$contrib->contrib_status);
  $status_list = array(TITANIA_CONTRIB_NEW => 'CONTRIB_NEW', TITANIA_CONTRIB_APPROVED => 'CONTRIB_APPROVED', TITANIA_CONTRIB_CLEANED => 'CONTRIB_CLEANED');
+ $permalink = utf8_normalize_nfc(request_var('permalink', titania::$contrib->contrib_name_clean, true));
  
  /**
  * ---------------------------- Confirm main author change ----------------------------
***************
*** 138,143 ****
--- 139,174 ----
  			$error[] = sprintf(phpbb::$user->lang['CONTRIB_CHANGE_OWNER_NOT_FOUND'], $change_owner);
  		}
  	}
+ 	
+ 	// Changed permalink?
+ 	$old_permalink = titania::$contrib->contrib_name_clean;
+ 	if ($old_permalink != $permalink)
+ 	{
+ 		// We check permalink
+ 		if (!$permalink)
+ 		{
+ 			// If they leave it blank automatically create it
+ 			$permalink = titania_url::url_slug(titania::$contrib->contrib_name);
+ 
+ 			$append = '';
+ 			$i = 2;
+ 			while (titania::$contrib->validate_permalink($permalink . $append) == false)
+ 			{
+ 				$append = '_' . $i;
+ 				$i++;
+ 			}
+ 
+ 			$permalink = $permalink . $append;
+ 		}
+ 		elseif (titania_url::url_slug($permalink) !== $permalink)
+ 		{
+ 			$error[] = sprintf(phpbb::$user->lang['INVALID_PERMALINK'], titania_url::url_slug($permalink));
+ 		}
+ 		elseif (!titania::$contrib->validate_permalink($permalink))
+ 		{
+ 			$error[] = phpbb::$user->lang['CONTRIB_NAME_EXISTS'];
+ 		}
+ 	}
  
  	// Did we succeed or have an error?
  	if (!sizeof($error))
***************
*** 207,212 ****
--- 238,256 ----
  
  		// Submit screenshots
  		$screenshot->submit();
+ 		
+ 		// Update contrib_status/permalink if we can moderate. only if contrib_status is valid and permalink altered
+ 		if (phpbb::$auth->acl_get('u_titania_mod_contrib_mod') || titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate'))
+ 		{
+ 			if (array_key_exists($contrib_status, $status_list))
+ 			{
+ 				titania::$contrib->change_status($contrib_status);
+ 			}
+ 			if ($old_permalink != $permalink)
+ 			{
+ 				titania::$contrib->contrib_name_clean = $permalink;
+ 			}
+ 		}
  
  		titania::$contrib->submit();
  
***************
*** 214,225 ****
  
  		// Create relations
  		titania::$contrib->put_contrib_in_categories($contrib_categories);
- 		
- 		// Update contrib status if we can moderate and contrib_status is valid
- 		if ((phpbb::$auth->acl_get('u_titania_mod_contrib_mod') || titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate')) && array_key_exists($contrib_status, $status_list))
- 		{
- 			titania::$contrib->change_status($contrib_status);
- 		}
  
  		if ($change_owner == '')
  		{
--- 258,263 ----
***************
*** 284,289 ****
--- 322,328 ----
  	'S_POST_ACTION'				=> titania::$contrib->get_url('manage'),
  	'S_EDIT_SUBJECT'			=> (phpbb::$auth->acl_get('u_titania_mod_contrib_mod') || titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate')) ? true : false,
  
+ 	'CONTRIB_PERMALINK'			=> $permalink,
  	'SCREENSHOT_UPLOADER'		=> $screenshot->parse_uploader('posting/attachments/simple.html'),
  	'ERROR_MSG'					=> (sizeof($error)) ? implode('<br />', $error) : false,
  	'ACTIVE_COAUTHORS'			=> $active_coauthors,

Modified: trunk/titania/styles/default/template/contributions/contribution_manage.html
==============================================================================
*** trunk/titania/styles/default/template/contributions/contribution_manage.html (original)
--- trunk/titania/styles/default/template/contributions/contribution_manage.html Mon Mar 29 12:11:44 2010
***************
*** 18,28 ****
  					<dd><input type="text" name="{POSTING_SUBJECT_NAME}" id="{POSTING_SUBJECT_NAME}" size="45" maxlength="60" value="{CONTRIB_NAME}" class="inputbox autowidth" /></dd>
  				</dl>
  				<!-- ENDIF -->
! 				<!-- IF S_CREATE -->
  				<dl>
  					<dt><label for="permalink">{L_CONTRIB_PERMALINK}:</label><br /><span>{L_CONTRIB_PERMALINK_EXPLAIN}</span></dt>
  					<dd><input type="text" name="permalink" id="permalink" size="45" maxlength="60" value="{CONTRIB_PERMALINK}" class="inputbox autowidth" /></dd>
  				</dl>
  				<dl>
  					<dt><label for="contrib_type">{L_CONTRIB_TYPE}:</label></dt>
  					<dd>
--- 18,30 ----
  					<dd><input type="text" name="{POSTING_SUBJECT_NAME}" id="{POSTING_SUBJECT_NAME}" size="45" maxlength="60" value="{CONTRIB_NAME}" class="inputbox autowidth" /></dd>
  				</dl>
  				<!-- ENDIF -->
! 				<!-- IF S_CREATE or (not S_CREATE and S_EDIT_SUBJECT) -->
  				<dl>
  					<dt><label for="permalink">{L_CONTRIB_PERMALINK}:</label><br /><span>{L_CONTRIB_PERMALINK_EXPLAIN}</span></dt>
  					<dd><input type="text" name="permalink" id="permalink" size="45" maxlength="60" value="{CONTRIB_PERMALINK}" class="inputbox autowidth" /></dd>
  				</dl>
+ 				<!-- ENDIF -->
+ 				<!-- IF S_CREATE -->
  				<dl>
  					<dt><label for="contrib_type">{L_CONTRIB_TYPE}:</label></dt>
  					<dd>




More information about the customisationdb-commits mailing list