[Phpslash-commit] CVS: phpslash-dev/include/modules/section Section.class,1.3,1.4
Brought to you by:
joestewart,
nhruby
From: Peter C. <kr...@us...> - 2004-07-07 17:40:49
|
Update of /cvsroot/phpslash/phpslash-dev/include/modules/section In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18190 Modified Files: Section.class Log Message: Notice squashing. Improvements to logic + presentation of validation process Index: Section.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/modules/section/Section.class,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Section.class 16 May 2003 17:09:52 -0000 1.3 --- Section.class 7 Jul 2004 17:40:40 -0000 1.4 *************** *** 50,53 **** --- 50,54 ---- $this->sec_templ->set_block("listsection","row2","rows2"); + $count = 0; while ($this->db->next_record()) { *************** *** 110,118 **** $ary["section_name"] = str_replace(" "," ",$ary["section_name"]); ! $optionname_ary = $ary[optionname]; ! $optionval_ary = $ary[optionval]; ! ! for( $i=1 ; $i <= count($optionname_ary) ; $i++) { if( $optionname_ary[$i] != "") { $optname = $optionname_ary[$i]; --- 111,119 ---- $ary["section_name"] = str_replace(" "," ",$ary["section_name"]); ! $optionname_ary = $ary['optionname']; ! $optionval_ary = $ary['optionval']; + if (@is_array($optionname_ary)) { + for( $i=0 ; $i < count($optionname_ary) ; $i++) { if( $optionname_ary[$i] != "") { $optname = $optionname_ary[$i]; *************** *** 123,126 **** --- 124,130 ---- } $serial_opts=addslashes(serialize($section_options_ary)); + } else { + $serial_opts = NULL; + } // if a record exists, then we update, else we insert a new section! *************** *** 163,166 **** --- 167,181 ---- $go_ahead = true; + // We need to fetch section's title, so might as well check for people trying + // to mess with the system + $section_id = intval($section_id); + $q = "SELECT section_name FROM psl_section WHERE section_id = $section_id"; + $this->db->query($q); + if (!$this->db->next_record()) { + $this->message .= getError(pslgettext('Attempting to delete non-existent section:') . " $section_id"); + return false; + } + $section_name = $this->db->Record['section_name']; + $q = "SELECT psl_story.title, psl_story.story_id *************** *** 168,172 **** psl_section_lut WHERE psl_story.story_id = psl_section_lut.story_id ! AND psl_section_lut.section_id = '$section_id'"; $this->db->query($q); while ($this->db->next_record()) { --- 183,188 ---- psl_section_lut WHERE psl_story.story_id = psl_section_lut.story_id ! AND psl_section_lut.section_id = '$section_id' ! ORDER BY psl_story.title"; $this->db->query($q); while ($this->db->next_record()) { *************** *** 174,179 **** $title = $this->db->Record["title"]; $story_id = $this->db->Record["story_id"]; ! $section_name = $this->db->Record["section_name"]; ! $this->message .= "STORY: '$title' "; } --- 190,194 ---- $title = $this->db->Record["title"]; $story_id = $this->db->Record["story_id"]; ! $this->message .= getError(pslgettext("Still linked to Story:") . " '$title'"); } *************** *** 183,187 **** psl_section_submission_lut WHERE psl_submission.story_id = psl_section_submission_lut.story_id ! AND psl_section_submission_lut.section_id = '$section_id'"; $this->db->query($q); while ($this->db->next_record()) { --- 198,203 ---- psl_section_submission_lut WHERE psl_submission.story_id = psl_section_submission_lut.story_id ! AND psl_section_submission_lut.section_id = '$section_id' ! ORDER BY psl_submission.title"; $this->db->query($q); while ($this->db->next_record()) { *************** *** 189,196 **** $title = $this->db->Record["title"]; $story_id = $this->db->Record["story_id"]; ! $section_name = $this->db->Record["section_name"]; ! $this->message .= "SUBMISSION: '$title' "; } $q = "SELECT psl_block.title, psl_block.id --- 205,215 ---- $title = $this->db->Record["title"]; $story_id = $this->db->Record["story_id"]; ! $this->message .= getError(pslgettext("Still linked to Submission:") . " '$title'"); } + // I am not sure if this check makes sense from the user's point of view + // - it's a real pain deleting all the blocks one at a time. + // Much better to just silently clear out psl_section_block_lut I think + // - pac Jul-2004 $q = "SELECT psl_block.title, psl_block.id *************** *** 198,202 **** psl_section_block_lut WHERE psl_block.id = psl_section_block_lut.block_id ! AND psl_section_block_lut.section_id = '$section_id'"; $this->db->query($q); while ($this->db->next_record()) { --- 217,222 ---- psl_section_block_lut WHERE psl_block.id = psl_section_block_lut.block_id ! AND psl_section_block_lut.section_id = '$section_id' ! ORDER BY psl_block.title"; $this->db->query($q); while ($this->db->next_record()) { *************** *** 204,221 **** $title = $this->db->Record["title"]; $block_id = $this->db->Record["id"]; ! $section_name = $this->db->Record["section_name"]; ! $this->message .= "BLOCK($block_id): $title "; } if (!$go_ahead) { return false; ! } else { $q = "DELETE FROM psl_section where section_id = '$section_id'"; $this->db->query($q); ! $this->message .= pslgetText(sprintf("Section %s(%s) deleted", $section_name, $section_id)); return true; } ! } /** --- 224,243 ---- $title = $this->db->Record["title"]; $block_id = $this->db->Record["id"]; ! $this->message .= getError(pslgettext("Still linked to Block:") . " '$title' ($block_id)"); } if (!$go_ahead) { + $this->message = getError(sprintf(pslGetText("Could not delete Section '%s' (%s)"), $section_name, $section_id)) + . $this->message; return false; ! } ! $q = "DELETE FROM psl_section where section_id = '$section_id'"; $this->db->query($q); ! $this->message .= getError(sprintf(pslGetText("Section '%s' (%s) deleted"), $section_name, $section_id)); return true; } ! /** |