automatic checkin issues in Jomla 1.0.x (.15)

Forum closed, please submit your tips and tricks to: http://docs.joomla.org/Category:Tips_and_tricks
Locked
stianhaugli
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Mon Jun 16, 2008 9:11 pm

automatic checkin issues in Jomla 1.0.x (.15)

Post by stianhaugli » Mon Jun 16, 2008 9:27 pm

hi there,
finally joining this fine forum :-) .. to contribute - well thats at least what i intend to.
You might prove me wrong, - but i've found a weird fix to the problem where users complain that
articles are locked by another user (as in they've used the back button, closed the browser etc, without
using the buttons in the editor.

Of course you can link to "check in my items" in frontend, OR do a "global checkin" in backend every now and then.
But its Just Not Functional when you got a few user, and are administrating too many sites...
This causes a Lot of Hazzle!

So here is what i did: I've mounted the Joomla in a subfolder "cms" under webroot.
In webroot I've put an "index.asp" (im more comfy with asp you see. sorry,
you can do the same with PHP, i just dont know "how" yet..)
this index.asp runs a SQL UPDATE statement, and before it redirects to the /cms (joomla) folder.

The SQL statement simply sets "checked_out" to "0" in every record in "content" where "checked_out" doesnt exist in Sessions.Userid. The SQL string looks like this:

Code: Select all

"UPDATE jos_content SET jos_content.checked_out = '0' WHERE jos_content.checked_out > '0' And jos_content.checked_out Not In (SELECT userid from jos_session) "
OK? ,, the whole asp looks like this:

Code: Select all

<%   

	'STARTUP SCRIPT
	   
	on error resume next
	dim Connection1, strQuery,  MM_serverside_STRING
	
	
	'database connection
	MM_serverside_STRING = "DRIVER={MySQL ODBC 3.51 Driver}; Server=localhost; Port=3306; Option=3; Socket=; Stmt=; Database=thedatabase; Uid=userid; Pwd= password"
	Set Connection1 = Server.CreateObject("ADODB.Connection")				
	Connection1.open MM_serverside_STRING

	'set checked_out status to 0 for all content items that doesnt exist in session table
	strQuery =  "UPDATE jos_content SET jos_content.checked_out = '0' WHERE jos_content.checked_out > '0' And jos_content.checked_out Not In (SELECT userid from jos_session) "

	'do it			
	Connection1.Execute strQuery

  	'tidy up and close
	Connection1.Close
	Set Connection1 = Nothing	
					
	'then redirect to live site
	response.Redirect("http://www.yourdomain.com/cms")

	'no error handler yet....
	
%>
let me know what you think - this seems to work like a breeeze.
Why the &^&£$&^! isnt this a part of the CORE, fireing everytime joomla starts - to clean up,.??!!
are anyone up for developing a mambot - i just dont have the skills.....

OH. i heard this is resolved in 1.5, i just cant migrate all these sites. so had to tweak the 1.0.15

looking forward to hear your comments...

best
STIAN

mikk
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu Nov 02, 2006 6:10 am

Re: automatic checkin issues in Jomla 1.0.x (.15)

Post by mikk » Tue Jul 01, 2008 9:08 am

this looks very interesting.

can anyone verify that this works?

i tried it on a 1.0.12 site in a php script but it doesn't work. not sure if i did anything wrong though.

here's the code i made:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Automatic Checkin</title>
</head>

<body>

<?php
$username = "user1";
$password = "pass1";
$hostname = "localhost";
$database = "db1";
$dbh = mysql_connect($hostname, $username, $password) 
	or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
$selected = mysql_select_db($database, $dbh) 
	or die("Could not select " . $database);

// you're going to do lots more here soon
// mysql_close($dbh);
?>

<?php
// $dbh = mysql_connect ($Host, $User, $Password); 
$query = "UPDATE jos_content SET jos_content.checked_out = '0' WHERE jos_content.checked_out > '0' And jos_content.checked_out Not In (SELECT userid from jos_session)";
$results = mysql_db_query($database, $query, $dbh); 
?> 

<?
mysql_close ($dbh); 
?>

</body>
</html>

Doing a checkin of all content items works: "UPDATE jos_content SET jos_content.checked_out = '0' WHERE jos_content.checked_out > '0' "

The query makes no changes to the datbase when it has "And jos_content.checked_out Not In (SELECT userid from jos_session)" in it.


Locked

Return to “Submit Your Suggested Tips & Tricks to Docs.joomla.org now please.”