Skip to content

Commit

Permalink
5522 first commit with mysqli updates
Browse files Browse the repository at this point in the history
  • Loading branch information
atutorlangs committed Sep 1, 2014
1 parent ea5a7b5 commit 76dc153
Show file tree
Hide file tree
Showing 51 changed files with 304 additions and 774 deletions.
58 changes: 5 additions & 53 deletions home/classes/ContentManager.class.php
Expand Up @@ -64,12 +64,6 @@ function ContentManager($course_id) {
$max_depth = array();
$_menu_info = array();

// $sql = "SELECT content_id, content_parent_id, ordering, title, UNIX_TIMESTAMP(release_date) AS u_release_date, content_type
// FROM ".TABLE_PREFIX."content
// WHERE course_id=$this->course_id
// ORDER BY content_parent_id, ordering";
// $result = mysql_query($sql, $this->db);

$rows = $this->contentDAO->getContentByCourseID($this->course_id);


Expand Down Expand Up @@ -282,17 +276,14 @@ function moveContent($content_id, $new_content_parent_id, $new_content_ordering)
}

/* first get the content to make sure it exists */
// $sql = "SELECT ordering, content_parent_id FROM ".TABLE_PREFIX."content WHERE content_id=$content_id AND course_id=$_SESSION[course_id]";
// $result = mysql_query($sql, $this->db);
if (!($row = $this->getContentPage($content_id)) ) {
return FALSE;
}
$old_ordering = $row['ordering'];
$old_content_parent_id = $row['content_parent_id'];

$sql = "SELECT max(ordering) max_ordering FROM ".TABLE_PREFIX."content WHERE content_parent_id=$old_content_parent_id AND course_id=$_course_id";
// $result = mysql_query($sql, $this->db);
// $row = mysql_fetch_assoc($result);

$row = $this->contentDAO->execute($sql);
$max_ordering = $row[0]['max_ordering'];

Expand Down Expand Up @@ -327,7 +318,7 @@ function moveContent($content_id, $new_content_parent_id, $new_content_ordering)
AND content_parent_id=$old_content_parent_id
AND content_id<>$content_id
AND course_id=$_course_id";
// $result = mysql_query($sql, $this->db);

$this->contentDAO->execute($sql);

// shift the new neighbouring content down
Expand All @@ -337,13 +328,13 @@ function moveContent($content_id, $new_content_parent_id, $new_content_ordering)
AND content_parent_id=$new_content_parent_id
AND content_id<>$content_id
AND course_id=$_course_id";
// $result = mysql_query($sql, $this->db);

$this->contentDAO->execute($sql);

$sql = "UPDATE ".TABLE_PREFIX."content
SET content_parent_id=$new_content_parent_id, ordering=$new_content_ordering
WHERE content_id=$content_id AND course_id=$_course_id";
// $result = mysql_query($sql, $this->db);

$this->contentDAO->execute($sql);
}
}
Expand All @@ -356,9 +347,7 @@ function deleteContent($content_id) {
}

/* check if exists */
// $sql = "SELECT ordering, content_parent_id FROM ".TABLE_PREFIX."content WHERE content_id=$content_id AND course_id=$_SESSION[course_id]";
// $result = mysql_query($sql, $this->db);
// if (!($row = @mysql_fetch_assoc($result)) ) {

if (!($row = $this->getContentPage($content_id)) ) {
return false;
}
Expand Down Expand Up @@ -391,33 +380,6 @@ function deleteContent($content_id) {
unset($_SESSION['s_cid']);
unset($_SESSION['from_cid']);

/* delete this content page */
// $sql = "DELETE FROM ".TABLE_PREFIX."content WHERE content_id=$content_id AND course_id=$_SESSION[course_id]";
// $result = mysql_query($sql, $this->db);

/* delete this content from member tracking page */
// $sql = "DELETE FROM ".TABLE_PREFIX."member_track WHERE content_id=$content_id AND course_id=$_SESSION[course_id]";
// $result = mysql_query($sql, $this->db);

// $sql = "DELETE FROM ".TABLE_PREFIX."related_content WHERE content_id=$content_id OR related_content_id=$content_id";
// $result = mysql_query($sql, $this->db);

/* delete the content tests association */
// $sql = "DELETE FROM ".TABLE_PREFIX."content_tests_assoc WHERE content_id=$content_id";
// $result = mysql_query($sql, $this->db);

/* delete the content forum association */
// $sql = "DELETE FROM ".TABLE_PREFIX."content_forums_assoc WHERE content_id=$content_id";
// $result = mysql_query($sql, $this->db);

/* Delete all AccessForAll contents */
// require_once(TR_INCLUDE_PATH.'classes/A4a/A4a.class.php');
// $a4a = new A4a($content_id);
// $a4a->deleteA4a();

/* remove the "resume" to this page, b/c it was deleted */
// $sql = "UPDATE ".TABLE_PREFIX."course_enrollment SET last_cid=0 WHERE course_id=$_SESSION[course_id] AND last_cid=$content_id";
// $result = mysql_query($sql, $this->db);

return true;
}
Expand All @@ -439,16 +401,6 @@ function deleteContentRecursive($content_id) {

// delete this content page
$this->contentDAO->Delete($content_id);
// $sql = "DELETE FROM ".TABLE_PREFIX."content WHERE content_id=$content_id AND course_id=$_SESSION[course_id]";
// $result = mysql_query($sql, $this->db);

/* delete this content from member tracking page */
// $sql = "DELETE FROM ".TABLE_PREFIX."member_track WHERE content_id=$content_id";
// $result = mysql_query($sql, $this->db);

/* delete the content tests association */
// $sql = "DELETE FROM ".TABLE_PREFIX."content_tests_assoc WHERE content_id=$content_id";
// $result = mysql_query($sql, $this->db);
}

function getContentPage($content_id) {
Expand Down
47 changes: 0 additions & 47 deletions home/editor/edit_content.php
Expand Up @@ -295,36 +295,6 @@
echo '<input type="hidden" name="test_message" value="'.AT_print($_POST['test_message'], 'input.hidden').'" />';

/* get glossary terms */
// $matches = find_terms(stripslashes($_POST['body_text']));
// $num_terms = count($matches[0]);
// $matches = $matches[0];
// $word = str_replace(array('[?]', '[/?]'), '', $matches);
//
// if (is_array($word)) {
// /* update $_POST['glossary_defs'] with any new/changed terms */
// for($i=0; $i<$num_terms; $i++) {
// $word[$i] = $word[$i];
// if (!isset($_POST['glossary_defs'][$word[$i]])) {
// $_POST['glossary_defs'][$word[$i]] = $glossary[$word[$i]];
// }
// }
// }
//
// if (is_array($_POST['glossary_defs']) && ($current_tab != 2)) {
// foreach($_POST['glossary_defs'] as $w => $d) {
// /* this term still exists in the content */
// if (!in_array($w, $word)) {
// unset($_POST['glossary_defs'][$w]);
// continue;
// }
// echo '<input type="hidden" name="glossary_defs['.$w.']" value="'.htmlspecialchars(stripslashes($d)).'" />';
// }
// if (isset($_POST['related_term'])) {
// foreach($_POST['related_term'] as $w => $d) {
// echo '<input type="hidden" name="related_term['.$w.']" value="'.$d.'" />';
// }
// }
// }

// adapted content
$sql = "SELECT pr.primary_resource_id, prt.type_id
Expand All @@ -333,7 +303,6 @@
WHERE pr.content_id = ".$cid."
AND pr.language_code = '".$_SESSION['lang']."'
AND pr.primary_resource_id = prt.primary_resource_id";
// $all_types_result = mysql_query($sql, $db);
$types = $dao->execute($sql);

$i = 0;
Expand Down Expand Up @@ -373,22 +342,6 @@
}
}
}

// // set pre-tests
// if (is_array($_POST['pre_tid'])) {
// foreach ($_POST['pre_tid'] as $i=>$pre_tid){
// echo '<input type="hidden" name="pre_tid['.$i.']" value="'.$pre_tid.'" />';
// }
// }
// else
// {
// $i = 0;
// $sql = 'SELECT * FROM '.TABLE_PREFIX."content_prerequisites WHERE content_id=$cid AND type='".CONTENT_PRE_TEST."'";
// $pretests_result = mysql_query($sql, $db);
// while ($pretest_row = mysql_fetch_assoc($pretests_result)) {
// echo '<input type="hidden" name="pre_tid['.$i++.']" value="'.$pretest_row['item_id'].'" />';
// }
// }
}

if ($do_check) {
Expand Down
23 changes: 1 addition & 22 deletions home/editor/edit_content_folder.php
Expand Up @@ -148,21 +148,7 @@
}

$parent = 0;
// foreach ($path as $i=>$page) {
// if (!$parent) {
// $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['title'] = $page['content_number'] . $page['title'];
// $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['parent'] = 'index.php';
// } else {
// $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['title'] = $page['content_number'] . $page['title'];
// $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['parent'] = 'editor/edit_content_folder.php?cid='.$parent;
// }
//
// $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['ignore'] = true;
// $parent = $page['content_id'];
// }
// $last_page = array_pop($_pages);
// $_pages['editor/edit_content_folder.php'] = $last_page;


reset($path);
$first_page = current($path);

Expand All @@ -174,14 +160,7 @@
$_tool_shortcuts = ContentUtility::getToolShortcuts($content_row); // used by header.tmpl.php

// display pre-tests
// $sql = 'SELECT * FROM '.TABLE_PREFIX."content_prerequisites WHERE content_id=$_REQUEST[cid] AND type='".CONTENT_PRE_TEST."'";
// $result = mysql_query($sql, $db);
// while ($row = mysql_fetch_assoc($result)) {
// $_POST['pre_tid'][] = $row['item_id'];
// }

$savant->assign('ftitle', $content_row['title']);
// $savant->assign('shortcuts', $shortcuts);
$savant->assign('cid', $cid);
}

Expand Down
23 changes: 1 addition & 22 deletions home/editor/edit_content_struct.php
Expand Up @@ -163,21 +163,7 @@


$parent = 0;
// foreach ($path as $i=>$page) {
// if (!$parent) {
// $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['title'] = $page['content_number'] . $page['title'];
// $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['parent'] = 'index.php';
// } else {
// $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['title'] = $page['content_number'] . $page['title'];
// $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['parent'] = 'editor/edit_content_folder.php?cid='.$parent;
// }
//
// $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['ignore'] = true;
// $parent = $page['content_id'];
// }
// $last_page = array_pop($_pages);
// $_pages['editor/edit_content_folder.php'] = $last_page;


reset($path);
$first_page = current($path);

Expand All @@ -189,14 +175,7 @@
$_tool_shortcuts = ContentUtility::getToolShortcuts($content_row); // used by header.tmpl.php

// display pre-tests
// $sql = 'SELECT * FROM '.TABLE_PREFIX."content_prerequisites WHERE content_id=$_REQUEST[cid] AND type='".CONTENT_PRE_TEST."'";
// $result = mysql_query($sql, $db);
// while ($row = mysql_fetch_assoc($result)) {
// $_POST['pre_tid'][] = $row['item_id'];
// }

$savant->assign('ftitle', $content_row['title']);
// $savant->assign('shortcuts', $shortcuts);
$savant->assign('cid', $cid);
}

Expand Down

0 comments on commit 76dc153

Please sign in to comment.