mirror of
				https://github.com/Mibew/java.git
				synced 2025-10-31 18:41:09 +03:00 
			
		
		
		
	Adding canned messages during system installation process
This commit is contained in:
		
							parent
							
								
									c119159be6
								
							
						
					
					
						commit
						be3efcfad3
					
				| @ -256,6 +256,27 @@ function check_admin($link) | ||||
| 	return false; | ||||
| } | ||||
| 
 | ||||
| function add_canned_messages($link){ | ||||
| 	global $mysqlprefix; | ||||
| 	foreach (get_available_locales() as $locale) { | ||||
| 		$result = array(); | ||||
| 		foreach (explode("\n", getstring_('chat.predefined_answers', $locale)) as $answer) { | ||||
| 			$result[] = array('id' => '', 'vcvalue' => $answer); | ||||
| 		} | ||||
| 		if (count($result) > 0) { | ||||
| 			$updatequery = "insert into ${mysqlprefix}chatresponses (vcvalue,locale,groupid) values "; | ||||
| 			for ($i = 0; $i < count($result); $i++) { | ||||
| 				if ($i > 0) { | ||||
| 					$updatequery .= ", "; | ||||
| 				} | ||||
| 				$updatequery .= "('" . db_escape_string($result[$i]['vcvalue'], $link) . "','$locale', NULL)"; | ||||
| 			} | ||||
| 			mysql_query($updatequery, $link); | ||||
| 		} | ||||
| 	} | ||||
| 	return; | ||||
| } | ||||
| 
 | ||||
| function check_status() | ||||
| { | ||||
| 	global $page, $webimroot, $settings, $dbversion; | ||||
| @ -290,6 +311,8 @@ function check_status() | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	add_canned_messages($link); | ||||
| 
 | ||||
| 	check_sound(); | ||||
| 
 | ||||
| 	$page['done'][] = getlocal("installed.message"); | ||||
|  | ||||
| @ -31,34 +31,6 @@ function load_canned_messages($locale, $groupid) | ||||
| 			 ") order by vcvalue"; | ||||
| 	$result = select_multi_assoc($query, $link); | ||||
| 	close_connection($link); | ||||
| 	if (!$groupid && count($result) == 0) { | ||||
| 		$result = load_default_canned_messages($locale); | ||||
| 	} | ||||
| 	return $result; | ||||
| } | ||||
| 
 | ||||
| function load_default_canned_messages($locale) | ||||
| { | ||||
| 	global $mysqlprefix; | ||||
| 	$link = connect(); | ||||
| 	$result = array(); | ||||
| 	foreach (explode("\n", getstring_('chat.predefined_answers', $locale)) as $answer) { | ||||
| 		$result[] = array('id' => '', 'vcvalue' => $answer); | ||||
| 	} | ||||
| 	if (count($result) > 0) { | ||||
| 		$updatequery = "insert into ${mysqlprefix}chatresponses (vcvalue,locale,groupid) values "; | ||||
| 		for ($i = 0; $i < count($result); $i++) { | ||||
| 			if ($i > 0) { | ||||
| 				$updatequery .= ", "; | ||||
| 			} | ||||
| 			$updatequery .= "('" . db_escape_string($result[$i]['vcvalue'], $link) . "','$locale', NULL)"; | ||||
| 		} | ||||
| 		perform_query($updatequery, $link); | ||||
| 		$query = "select id, vcvalue from ${mysqlprefix}chatresponses " . | ||||
| 			 "where locale = '" . $locale . "' AND (groupid is NULL OR groupid = 0) order by vcvalue"; | ||||
| 		$result = select_multi_assoc($query, $link); | ||||
| 	} | ||||
| 	close_connection($link); | ||||
| 	return $result; | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user