diff --git a/website_code/php/display_library.php b/website_code/php/display_library.php index c265f277b9..4a7e9e5be0 100644 --- a/website_code/php/display_library.php +++ b/website_code/php/display_library.php @@ -1,495 +1,495 @@ -database_table_prefix . "folderdetails where login_id =\"" . $_SESSION['toolkits_logon_id'] . "\" and folder_parent=\"" . $folder_id . "\""; + global $xerte_toolkits_site; + + $query="select folder_id, folder_name from " . $xerte_toolkits_site->database_table_prefix . "folderdetails where login_id =\"" . $_SESSION['toolkits_logon_id'] . "\" and folder_parent=\"" . $folder_id . "\""; - $query_response = mysql_query($query); + $query_response = mysql_query($query); - while($row = mysql_fetch_array($query_response)){ + while($row = mysql_fetch_array($query_response)){ - echo "

" . str_replace("_", " ", $row['folder_name']) . "

"; + echo "

" . str_replace("_", " ", $row['folder_name']) . "

"; - list_folder_contents_event_free($row['folder_id']); + list_folder_contents_event_free($row['folder_id']); - echo "
"; - - } + echo "
"; + + } } - /** - * - * Function list files in this folder event free - * This function is used in the folder properties tab to display files - * @param string $folder_id = The id of the folder we are checking - * @version 1.0 - * @author Patrick Lockley - */ +/** + * + * Function list files in this folder event free + * This function is used in the folder properties tab to display files + * @param string $folder_id = The id of the folder we are checking + * @version 1.0 + * @author Patrick Lockley + */ function list_files_in_this_folder_event_free($folder_id){ - global $xerte_toolkits_site; + global $xerte_toolkits_site; - $query = "select template_name, template_id from " . $xerte_toolkits_site->database_table_prefix . "templatedetails where template_id in ( select " . $xerte_toolkits_site->database_table_prefix . "templaterights.template_id from " . $xerte_toolkits_site->database_table_prefix . "templaterights where user_id =\"" . $_SESSION['toolkits_logon_id'] . "\" and folder=\"" . $folder_id . "\") order by " . $xerte_toolkits_site->database_table_prefix . "templatedetails.date_created ASC"; + $query = "select template_name, template_id from " . $xerte_toolkits_site->database_table_prefix . "templatedetails where template_id in ( select " . $xerte_toolkits_site->database_table_prefix . "templaterights.template_id from " . $xerte_toolkits_site->database_table_prefix . "templaterights where user_id =\"" . $_SESSION['toolkits_logon_id'] . "\" and folder=\"" . $folder_id . "\") order by " . $xerte_toolkits_site->database_table_prefix . "templatedetails.date_created ASC"; - $query_response = mysql_query($query); + $query_response = mysql_query($query); - while($row = mysql_fetch_array($query_response)){ + while($row = mysql_fetch_array($query_response)){ - echo "

" . str_replace("_", " ", $row['template_name']) . "

"; + echo "

" . str_replace("_", " ", $row['template_name']) . "

"; - } + } } - /** - * - * Function list folder contents event free - * This function is used as part of the recursion with the above two functions - * @param string $folder_id = The id of the folder we are checking - * @version 1.0 - * @author Patrick Lockley - */ +/** + * + * Function list folder contents event free + * This function is used as part of the recursion with the above two functions + * @param string $folder_id = The id of the folder we are checking + * @version 1.0 + * @author Patrick Lockley + */ function list_folder_contents_event_free($folder_id){ - list_folders_in_this_folder_event_free($folder_id); - list_files_in_this_folder_event_free($folder_id); + list_folders_in_this_folder_event_free($folder_id); + list_files_in_this_folder_event_free($folder_id); } - /** - * - * Function list folder in this folder - * This function is used as part of the recursion to display the main file system - * @param string $folder_id = The id of the folder we are checking - * @param string $sort_type = A variable which dictates how we are sorting this - * @version 1.0 - * @author Patrick Lockley - */ +/** + * + * Function list folder in this folder + * This function is used as part of the recursion to display the main file system + * @param string $folder_id = The id of the folder we are checking + * @param string $sort_type = A variable which dictates how we are sorting this + * @version 1.0 + * @author Patrick Lockley + */ function list_folders_in_this_folder($folder_id, $sort_type){ - /* - * use the global level for folder indenting - */ + /* + * use the global level for folder indenting + */ + + global $level, $xerte_toolkits_site; + + /* + * select the folders in this folder + */ - global $level, $xerte_toolkits_site; + $query="select folder_id, folder_name from " . $xerte_toolkits_site->database_table_prefix . "folderdetails where login_id =\"" . $_SESSION['toolkits_logon_id'] . "\" and folder_parent=\"" . $folder_id . "\" "; - /* - * select the folders in this folder - */ + /* + * Add some more to the query to sort the files + */ - $query="select folder_id, folder_name from " . $xerte_toolkits_site->database_table_prefix . "folderdetails where login_id =\"" . $_SESSION['toolkits_logon_id'] . "\" and folder_parent=\"" . $folder_id . "\" "; + if($sort_type=="alpha_down"){ - /* - * Add some more to the query to sort the files - */ + $query.=" order by folder_name DESC"; - if($sort_type=="alpha_down"){ + }else if($sort_type=="alpha_up"){ - $query.=" order by folder_name DESC"; + $query.=" order by folder_name ASC"; - }else if($sort_type=="alpha_up"){ + }else if($sort_type=="date_down"){ - $query.=" order by folder_name ASC"; + $query.=" order by date_created DESC"; - }else if($sort_type=="date_down"){ + }else if($sort_type=="date_up"){ - $query.=" order by date_created DESC"; + $query.=" order by date_created ASC"; - }else if($sort_type=="date_up"){ + } - $query.=" order by date_created ASC"; + $query_response = mysql_query($query); - } + /* + * recurse through the folders + */ - $query_response = mysql_query($query); + while($row = mysql_fetch_array($query_response)){ - /* - * recurse through the folders - */ + $query_for_folder_content="select template_id from " . $xerte_toolkits_site->database_table_prefix . "templaterights where folder=\"" . $row['folder_id'] . "\" UNION SELECT folder_id from " . $xerte_toolkits_site->database_table_prefix . "folderdetails where folder_parent=\"" . $row['folder_id'] . "\""; - while($row = mysql_fetch_array($query_response)){ + $query_response_for_folder_content = mysql_query($query_for_folder_content); - $query_for_folder_content="select template_id from " . $xerte_toolkits_site->database_table_prefix . "templaterights where folder=\"" . $row['folder_id'] . "\" UNION SELECT folder_id from " . $xerte_toolkits_site->database_table_prefix . "folderdetails where folder_parent=\"" . $row['folder_id'] . "\""; + /* + * Use level to nest the folders + */ - $query_response_for_folder_content = mysql_query($query_for_folder_content); - - /* - * Use level to nest the folders - */ + echo "

" . str_replace("_", " ", $row['folder_name']) . "

"; + echo " src=\"website_code/images/Icon_Folder_Empty.gif\" />" . str_replace("_", " ", $row['folder_name']) . "

"; - }else{ + }else{ - echo " src=\"website_code/images/Icon_Folder.gif\" id=\"folder_" . $row['folder_id'] . "_image\" />" . str_replace("_", " ", $row['folder_name']) . "

"; + echo " src=\"website_code/images/Icon_Folder.gif\" id=\"folder_" . $row['folder_id'] . "_image\" />" . str_replace("_", " ", $row['folder_name']) . "

"; - list_folder_contents($row['folder_id'], $sort_type); + list_folder_contents($row['folder_id'], $sort_type); - } + } - echo "
"; + echo ""; - } + } } - /** - * - * Function list files in this folder - * This function is used as part of the recursion to display the main file system - * @param string $folder_id = The id of the folder we are checking - * @param string $sort_type = A variable which dictates how we are sorting this - * @version 1.0 - * @author Patrick Lockley - */ +/** + * + * Function list files in this folder + * This function is used as part of the recursion to display the main file system + * @param string $folder_id = The id of the folder we are checking + * @param string $sort_type = A variable which dictates how we are sorting this + * @version 1.0 + * @author Patrick Lockley + */ function list_files_in_this_folder($folder_id, $sort_type){ - global $level, $xerte_toolkits_site; + global $level, $xerte_toolkits_site; + + $query = "select template_name, template_id from " . $xerte_toolkits_site->database_table_prefix . "templatedetails where template_id in ( select " . $xerte_toolkits_site->database_table_prefix . "templaterights.template_id from " . $xerte_toolkits_site->database_table_prefix . "templaterights where user_id =\"" . $_SESSION['toolkits_logon_id'] . "\" and folder=\"" . $folder_id . "\") "; - $query = "select template_name, template_id from " . $xerte_toolkits_site->database_table_prefix . "templatedetails where template_id in ( select " . $xerte_toolkits_site->database_table_prefix . "templaterights.template_id from " . $xerte_toolkits_site->database_table_prefix . "templaterights where user_id =\"" . $_SESSION['toolkits_logon_id'] . "\" and folder=\"" . $folder_id . "\") "; + if($sort_type=="alpha_down"){ - if($sort_type=="alpha_down"){ + $query.="order by " . $xerte_toolkits_site->database_table_prefix . "templatedetails.template_name DESC"; - $query.="order by " . $xerte_toolkits_site->database_table_prefix . "templatedetails.template_name DESC"; + }else if($sort_type=="alpha_up"){ - }else if($sort_type=="alpha_up"){ + $query.="order by " . $xerte_toolkits_site->database_table_prefix . "templatedetails.template_name ASC"; - $query.="order by " . $xerte_toolkits_site->database_table_prefix . "templatedetails.template_name ASC"; + }else if($sort_type=="date_down"){ - }else if($sort_type=="date_down"){ + $query.="order by " . $xerte_toolkits_site->database_table_prefix . "templatedetails.date_created DESC"; - $query.="order by " . $xerte_toolkits_site->database_table_prefix . "templatedetails.date_created DESC"; + }else if($sort_type=="date_up"){ - }else if($sort_type=="date_up"){ + $query.="order by " . $xerte_toolkits_site->database_table_prefix . "templatedetails.date_created ASC"; - $query.="order by " . $xerte_toolkits_site->database_table_prefix . "templatedetails.date_created ASC"; + } - } + $query_response = mysql_query($query); - $query_response = mysql_query($query); + while($row = mysql_fetch_array($query_response)){ - while($row = mysql_fetch_array($query_response)){ - - echo "
site_url}/website_code/images/Icon_Page.gif\" style=\"vertical-align:middle\" />" . str_replace("_", " ", $row['template_name']) . "
"; + echo "
site_url}/website_code/images/Icon_Page.gif\" style=\"vertical-align:middle\" />" . str_replace("_", " ", $row['template_name']) . "
"; - } + } } - /** - * - * Function list folder contents - * This function is used as part of the recursion to display the main file system - * @param string $folder_id = The id of the folder we are checking - * @param string $sort_type = A variable which dictates how we are sorting this - * @version 1.0 - * @author Patrick Lockley - */ +/** + * + * Function list folder contents + * This function is used as part of the recursion to display the main file system + * @param string $folder_id = The id of the folder we are checking + * @param string $sort_type = A variable which dictates how we are sorting this + * @version 1.0 + * @author Patrick Lockley + */ function list_folder_contents($folder_id, $sort_type){ - global $level; + global $level; - $level++; - list_folders_in_this_folder($folder_id, $sort_type); - list_files_in_this_folder($folder_id, $sort_type); - $level--; + $level++; + list_folders_in_this_folder($folder_id, $sort_type); + list_files_in_this_folder($folder_id, $sort_type); + $level--; } - /** - * - * Function list users projects - * This function is used as part of the recursion to display the main file system - * @param string $sort_type = A variable which dictates how we are sorting this - * @version 1.0 - * @author Patrick Lockley - */ +/** + * + * Function list users projects + * This function is used as part of the recursion to display the main file system + * @param string $sort_type = A variable which dictates how we are sorting this + * @version 1.0 + * @author Patrick Lockley + */ function list_users_projects($sort_type){ - /* - * Called by index.php to start off the process - */ + /* + * Called by index.php to start off the process + */ - global $level, $xerte_toolkits_site; + global $level, $xerte_toolkits_site; - $root_folder = get_user_root_folder(); - - /* - * Create the workspace folder - */ + $root_folder = get_user_root_folder(); - echo "

site_url}/website_code/images/folder_workspace.gif\""; + echo "

Workspace

"; + echo " src=\"{$xerte_toolkits_site->site_url}/website_code/images/folder_workspace.gif\""; - $level=1; + echo " />Workspace

"; - list_folder_contents(get_user_root_folder(),$sort_type); + $level=1; - $query = "select folder_id from " . $xerte_toolkits_site->database_table_prefix . "folderdetails where folder_name=\"recyclebin\" and login_id =\"" . $_SESSION['toolkits_logon_id'] . "\""; + list_folder_contents(get_user_root_folder(),$sort_type); - $query_response = mysql_query($query); + $query = "select folder_id from " . $xerte_toolkits_site->database_table_prefix . "folderdetails where folder_name=\"recyclebin\" and login_id =\"" . $_SESSION['toolkits_logon_id'] . "\""; - $row = mysql_fetch_array($query_response); + $query_response = mysql_query($query); - $level=1; + $row = mysql_fetch_array($query_response); - $query_for_folder_content="select template_id from " . $xerte_toolkits_site->database_table_prefix . "templaterights where folder=\"" . $row['folder_id'] . "\" UNION SELECT folder_id from " . $xerte_toolkits_site->database_table_prefix . "folderdetails where folder_parent=\"" . $row['folder_id'] . "\""; + $level=1; - $query_response_for_folder_content = mysql_query($query_for_folder_content); + $query_for_folder_content="select template_id from " . $xerte_toolkits_site->database_table_prefix . "templaterights where folder=\"" . $row['folder_id'] . "\" UNION SELECT folder_id from " . $xerte_toolkits_site->database_table_prefix . "folderdetails where folder_parent=\"" . $row['folder_id'] . "\""; - echo "
"; - - /* - * Display the recycle bin - */ + $query_response_for_folder_content = mysql_query($query_for_folder_content); - echo "

"; - if(mysql_num_rows($query_response_for_folder_content)==0){ + /* + * Display the recycle bin + */ - echo " src=\"{$xerte_toolkits_site->site_url}/website_code/images/rb_empty.gif\""; + echo "

site_url}/website_code/images/rb_full.gif\""; - } + echo " src=\"{$xerte_toolkits_site->site_url}/website_code/images/rb_empty.gif\""; - echo " />" . DISPLAY_RECYCLE . "

"; + }else{ - list_folder_contents($row['folder_id'],$sort_type); + echo " src=\"{$xerte_toolkits_site->site_url}/website_code/images/rb_full.gif\""; + } + + echo " />" . DISPLAY_RECYCLE . "

"; + + list_folder_contents($row['folder_id'],$sort_type); + + echo "
"; - echo "
"; - } /** - * - * Function list users projects - * This function is used to display all the unrestricted templates (Access to whom = *) - * @version 1.0 - * @author Patrick Lockley - */ + * + * Function list users projects + * This function is used to display all the unrestricted templates (Access to whom = *) + * @version 1.0 + * @author Patrick Lockley + */ function list_blank_templates(){ - /* - * note the access rights to discern what templates this user can see - */ + /* + * note the access rights to discern what templates this user can see + */ + + global $xerte_toolkits_site; + + $query_for_blank_templates = "select * from " . $xerte_toolkits_site->database_table_prefix . "originaltemplatesdetails where access_rights=\"*\" and active=true order by date_uploaded DESC"; - global $xerte_toolkits_site; + $query_for_blank_templates_response = mysql_query($query_for_blank_templates); - $query_for_blank_templates = "select * from " . $xerte_toolkits_site->database_table_prefix . "originaltemplatesdetails where access_rights=\"*\" and active=true order by date_uploaded DESC"; + while($row = mysql_fetch_array($query_for_blank_templates_response)){ - $query_for_blank_templates_response = mysql_query($query_for_blank_templates); + echo "

"; - while($row = mysql_fetch_array($query_for_blank_templates_response)){ + echo $row['display_name']; - echo "

"; + echo "

"; - echo $row['display_name']; + echo $row['description']; - echo "

"; + /* + * If no example don't display the link + */ - echo $row['description']; - - /* - * If no example don't display the link - */ + if($row['display_id']!=0){ - if($row['display_id']!=0){ + echo "

" . DISPLAY_EXAMPLE . " | "; - echo "

" . DISPLAY_EXAMPLE . " | "; + }else{ - }else{ + echo "
"; - echo "
"; + } - } + echo "" . DISPLAY_CREATE . "
"; + echo "" . DISPLAY_NAME . "

"; - echo "" . DISPLAY_NAME . "

"; - - } + } - /* - * once done listing the blank templates, list if any the specific templates available for this user - */ + /* + * once done listing the blank templates, list if any the specific templates available for this user + */ - list_specific_templates(); + list_specific_templates(); } - /** - * - * Function access check - * This function is used to assess which specific usernames match the access to whom value - * @param string $security_details = the masks used for this template to limit its display - * @version 1.0 - * @author Patrick Lockley - */ +/** + * + * Function access check + * This function is used to assess which specific usernames match the access to whom value + * @param string $security_details = the masks used for this template to limit its display + * @version 1.0 + * @author Patrick Lockley + */ function access_check($security_details){ - $list = explode(",",$security_details); + $list = explode(",",$security_details); - while($dev_mask = array_pop($list)){ + while($dev_mask = array_pop($list)){ - if(strpos($dev_mask,"*")!=0){ + if(strpos($dev_mask,"*")!=0){ - if(strcmp(substr($dev_mask,0,strpos($dev_mask,"*")),substr($_SESSION['toolkits_logon_username'],0,strpos($dev_mask,"*")))==0){ + if(strcmp(substr($dev_mask,0,strpos($dev_mask,"*")),substr($_SESSION['toolkits_logon_username'],0,strpos($dev_mask,"*")))==0){ - return true; + return true; - } - - }else{ - - if(strcmp($dev_mask,$_SESSION['toolkits_logon_username'])==0){ + } - return true; + }else{ - } + if(strcmp($dev_mask,$_SESSION['toolkits_logon_username'])==0){ - } + return true; - } + } - return false; + } + + } + + return false; } - /** - * - * Function list specific templates - * This function is used to display templates with access restrictions - * @version 1.0 - * @author Patrick Lockley - */ +/** + * + * Function list specific templates + * This function is used to display templates with access restrictions + * @version 1.0 + * @author Patrick Lockley + */ function list_specific_templates(){ - global $xerte_toolkits_site; + global $xerte_toolkits_site; + + $query_for_blank_templates = "select * from " . $xerte_toolkits_site->database_table_prefix . "originaltemplatesdetails where access_rights!=\"*\" order by date_uploaded DESC"; - $query_for_blank_templates = "select * from " . $xerte_toolkits_site->database_table_prefix . "originaltemplatesdetails where access_rights!=\"*\" order by date_uploaded DESC"; + $query_for_blank_templates_response = mysql_query($query_for_blank_templates); - $query_for_blank_templates_response = mysql_query($query_for_blank_templates); + while($row = mysql_fetch_array($query_for_blank_templates_response)){ - while($row = mysql_fetch_array($query_for_blank_templates_response)){ + if(access_check($row['access_rights'])){ - if(access_check($row['access_rights'])){ + echo "

"; - echo "

"; + echo "

"; - echo "

"; + echo $row['description']; - echo $row['description']; - - /* - * If no example don't display the link - */ + /* + * If no example don't display the link + */ - if($row['display_id']!=0){ + if($row['display_id']!=0){ - echo "

" . DISPLAY_EXAMPLE . " | "; + echo "

" . DISPLAY_EXAMPLE . " | "; - }else{ + }else{ - echo "
"; + echo "
"; - } + } - echo "" . DISPLAY_CREATE . "
"; - echo "" . DISPLAY_NAME . "

"; - - } - - } + echo "" . DISPLAY_NAME . "

"; + + } + + } } - /** - * - * Function login page format middle - * This function is used to display the index.php HTML - * @param string $buffer = A HTML string to work on - * @version 1.0 - * @author Patrick Lockley - */ +/** + * + * Function login page format middle + * This function is used to display the index.php HTML + * @param string $buffer = A HTML string to work on + * @version 1.0 + * @author Patrick Lockley + */ function logged_in_page_format_middle($buffer){ - global $xerte_toolkits_site; + global $xerte_toolkits_site; - $buffer = str_replace("{{pod_one}}", $xerte_toolkits_site->pod_one , $buffer); - $buffer = str_replace("{{pod_two}}", $xerte_toolkits_site->pod_two , $buffer); + $buffer = str_replace("{{pod_one}}", $xerte_toolkits_site->pod_one , $buffer); + $buffer = str_replace("{{pod_two}}", $xerte_toolkits_site->pod_two , $buffer); - return $buffer; + return $buffer; } - /** - * - * Function error show template - * This function is used to display a respinse when the users accesses a resource they have no right to - * @version 1.0 - * @author Patrick Lockley - */ +/** + * + * Function error show template + * This function is used to display a respinse when the users accesses a resource they have no right to + * @version 1.0 + * @author Patrick Lockley + */ function error_show_template(){ - - echo DISPLAY_ERROR; + + echo DISPLAY_ERROR; } - /** - * - * Function output locked file code - * This function is used to display a message when a lock file is found - * @version 1.0 - * @author Patrick Lockley - */ +/** + * + * Function output locked file code + * This function is used to display a message when a lock file is found + * @version 1.0 + * @author Patrick Lockley + */ function output_locked_file_code($lock_file_creator){ - - echo "

" . DISPLAY_EDITED . $lock_file_creator . "

" . DISPLAY_LOCKFILE_MESSAGE . "

"; - - echo "
"; + + echo "

" . DISPLAY_EDITED . $lock_file_creator . "

" . DISPLAY_LOCKFILE_MESSAGE . "

"; + + echo "
"; } -?> \ No newline at end of file +?>