Skip to content

Commit

Permalink
edit.php: reindent
Browse files Browse the repository at this point in the history
git-svn-id: https://xerteonlinetoolkits.googlecode.com/svn/trunk@279 912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641
  • Loading branch information
Dave Goodwin committed Mar 6, 2012
1 parent 99706c3 commit 516b6bf
Showing 1 changed file with 50 additions and 127 deletions.
177 changes: 50 additions & 127 deletions edit.php
@@ -1,4 +1,5 @@
<?php

/**
*
* Edit page, brings up the xerte editor window
Expand Down Expand Up @@ -53,42 +54,31 @@ function update_access_time($row_edit){

$query_for_edit_content = str_replace("TEMPLATE_ID_TO_REPLACE", $safe_template_id, $query_for_edit_content_strip);

$query_for_edit_content_response = mysql_query($query_for_edit_content);
$row_edit = db_query_one($query_for_edit_content);

$row_edit = mysql_fetch_array($query_for_edit_content_response);
if(empty($row_edit)) {
die("Invalid template_id (could not find in DB)");
}

if(has_rights_to_this_template($safe_template_id,$_SESSION['toolkits_logon_id'])){

/*
* Check if user is editor (could be read only)
*/
// Check if user is editor (could be read only)

if(is_user_an_editor($safe_template_id,$_SESSION['toolkits_logon_id'])){

/*
* Check for multiple editors
*/

// Check for multiple editors
if(has_template_multiple_editors($safe_template_id)){

/*
* Check for lock file. A lock file is created to prevent more than one
*/

// Check for lock file. A lock file is created to prevent more than one
if(file_exists($xerte_toolkits_site->users_file_area_full . $row_edit['template_id'] . "-" . $row_edit['username'] . "-" . $row_edit['template_name'] . "/lockfile.txt")){

/*
* Lock file exists, so open it up and see who created it
*/

// Lock file exists, so open it up and see who created it
$lock_file_data = file_get_contents($xerte_toolkits_site->users_file_area_full . $row_edit['template_id'] . "-" . $row_edit['username'] . "-" . $row_edit['template_name'] . "/lockfile.txt");

$temp = explode("*",$lock_file_data);

if(count($temp)==1){

$temp = explode(" ",$lock_file_data);

}

$lock_file_creator = $temp[0];
Expand All @@ -97,31 +87,20 @@ function update_access_time($row_edit){
* Check if lock file creator is current user, if so, continue into the code
*/

if($lock_file_creator==$_SESSION['toolkits_logon_username']){

if(update_access_time($row_edit)){

/*
* Display the editor
*/

if($lock_file_creator==$_SESSION['toolkits_logon_username']) {
if(update_access_time($row_edit)) {
// Display the editor
require $xerte_toolkits_site->root_file_path . "modules/" . $row_edit['template_framework'] . "/edit.php";

output_editor_code($row_edit, $xerte_toolkits_site, "true", true);

}else{

/*
* Show an error
*/

}
else {
// show error
error_show_template();

exit(0);
}

}else{

if(isset($_POST['lockfile_clear'])){
}
else {
if(isset($_POST['lockfile_clear'])) {

/*
* Delete the lockfile
Expand All @@ -140,139 +119,83 @@ function update_access_time($row_edit){
if(update_access_time($row_edit)){

require $xerte_toolkits_site->root_file_path . "modules/" . $row_edit['template_framework'] . "/edit.php";

output_editor_code($row_edit, $xerte_toolkits_site, "true", true);

}else{

}
else {
error_show_template();

exit(0);
}
}
else {

}else{

/*
* Update the lock file. The lock file format is creator id*id that tried to access 1 <space> id that tried to access 2 and so on
*/

// Update the lock file. The lock file format is creator id*id that tried to access 1 <space> id that tried to access 2 and so on
$new_lock_file = $lock_file_data . $_SESSION['toolkits_logon_username'] . " ";

$file_handle = fopen($xerte_toolkits_site->users_file_area_full . $row_edit['template_id'] . "-" . $row_edit['username'] . "-" . $row_edit['template_name'] . "/lockfile.txt",'w');

fwrite($file_handle, $new_lock_file);

fclose($file_handle);

output_locked_file_code($lock_file_creator);

}

}
}
else {

}else{

/*
* No lock file, so create one
*/

// No lock file, so create one
$file_handle = fopen($xerte_toolkits_site->users_file_area_full . $row_edit['template_id'] . "-" . $row_edit['username'] . "-" . $row_edit['template_name'] . "/lockfile.txt", 'w');

fwrite($file_handle, $_SESSION['toolkits_logon_username'] . "*");

fclose($file_handle);

/*
* Update the time this template was last edited
*/

// Update the time this template was last edited
if(update_access_time($row_edit)){

require $xerte_toolkits_site->root_file_path . "modules/" . $row_edit['template_framework'] . "/edit.php";

output_editor_code($row_edit, $xerte_toolkits_site, "true", true);

}else{

error_show_template();

exit(0);
}

}

}else{

/*
* One editor (but shared) for this prohect, so continue without creating a lock file
*/

}
else {
// One editor (but shared) for this prohect, so continue without creating a lock file
if(update_access_time($row_edit)){
require $xerte_toolkits_site->root_file_path . "modules/" . $row_edit['template_framework'] . "/edit.php";
output_editor_code($row_edit, $xerte_toolkits_site, "true", false);
}else{
}
else {
error_show_template();

exit(0);
}

}

}else{

/*
* One editor (and no sharing) for this prohect, so continue without creating a lock file
*/

}
else {
// One editor (and no sharing) for this prohect, so continue without creating a lock file
if(update_access_time($row_edit)){
_debug("editphp - no sharing etc");
require $xerte_toolkits_site->root_file_path . "modules/" . $row_edit['template_framework'] . "/edit.php";

output_editor_code($row_edit, $xerte_toolkits_site, "false", false);

}else{

}
else {
error_show_template();

exit(0);
}


}

}else if(is_user_admin()){

/*
* Is the current user an administrator - If so access here.
*/

}
else if(is_user_admin()) {
// Is the current user an administrator - If so access here.
require $xerte_toolkits_site->root_file_path . "modules/" . $row_edit['template_framework'] . "/edit.php";

output_editor_code($row_edit, $xerte_toolkits_site, "false", false);

}else{

/*
* Wiki mode - check to see if template allows anonymous editing.
*/
}
else {
// Wiki mode - check to see if template allows anonymous editing.

$string_for_flash_xml = $xerte_toolkits_site->users_file_area_short . $row_edit['template_id'] . "-" . $row_edit['username'] . "-" . $row_edit['template_name'] . "/data.xml";

$buffer = file_get_contents($string_for_flash_xml);

if(strpos($buffer,"editable=true")==false){

/*
* Wiki mode not set
*/

// so the user sees a blank page?
}else{

/*
* Wiki mode set
*/

// Wiki mode set
require $xerte_toolkits_site->root_file_path . "modules/" . $row_edit['template_framework'] . "/edit.php";

output_editor_code($row_edit, $xerte_toolkits_site, "true", false);

}

}

0 comments on commit 516b6bf

Please sign in to comment.