[Phpslash-commit] CVS: phpslash-ft/class Topic.class,1.11,1.12
Brought to you by:
joestewart,
nhruby
From: Joe S. <joe...@us...> - 2002-03-20 18:55:06
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv21971/phpslash-ft/class Modified Files: Topic.class Log Message: [ 532333 ] Topic.class bug fixes Index: Topic.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Topic.class,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Topic.class 15 Mar 2002 19:16:28 -0000 1.11 --- Topic.class 20 Mar 2002 18:55:00 -0000 1.12 *************** *** 465,469 **** * complete arrays... b) Take care of deleting stories * c) clean up ... later ;-) ! * * @param array $topic_id_val * --- 465,474 ---- * complete arrays... b) Take care of deleting stories * c) clean up ... later ;-) ! * ! * KNOWN BUGS: a)icons get updated inmediately. This creates a ! * problem when scheduling stories, since ! * the iconbar gets updated but the story ! * will not show until the date arrives ... :-( ! * * @param array $topic_id_val * *************** *** 481,485 **** $limit = $this->psl['bar_limit']; // variables are easier to deal with ! // less typing :-) // updates the topic's onlinkbar values first, --- 486,490 ---- $limit = $this->psl['bar_limit']; // variables are easier to deal with ! // less typing :-) // updates the topic's onlinkbar values first, *************** *** 494,529 **** // And it has to be done this way // until MySQL 4 comes with nested transactions :-) ! ! // 1) begin work: ! $q = "BEGIN WORK"; $this->db->query($q); ! // 2) update values of onlinkbar ! $q = "UPDATE psl_topic SET onlinkbar=onlinkbar+1 ! WHERE onlinkbar != 0"; ! $this->db->query($q); ! // 3) purge values higher than LIMIT ! $q = "UPDATE psl_topic ! SET onlinkbar=0 ! WHERE onlinkbar > '$limit'"; ! $this->db->query($q); ! // 4) put this topic_id as first item in bar ! $q = "UPDATE psl_topic ! SET onlinkbar=1 ! WHERE topic_id = '$topic_id'"; ! $this->db->query($q); ! // 5) commit and release table ! $q = "COMMIT"; ! $this->db->query($q); ! if ($this->db->affected_rows() > 0) { ! return true; ! }else{ ! return false; ! } } // end renormTopic() --- 499,594 ---- // And it has to be done this way // until MySQL 4 comes with nested transactions :-) ! // ! // Try to see whether this topic is already in the bar ! // ! $q = "SELECT onlinkbar ! FROM psl_topic ! WHERE topic_id = '$topic_id'"; $this->db->query($q); + + // if topic it's in the bar, then is_onlinkbar will + // contain the number of the id + // we will need this value later + while ($this->db->next_record()) { + $is_onlinkbar = $this->db->f("onlinkbar"); + } + + if ($is_onlinkbar > 0) { + // this means that the topic id is already + // on the link bar... + + if ($is_onlinkbar > 1) { + // when the link is one, we do nothing + // but when it's greater, we take the ones + // before, update them, and then + // put the is_onlinkbar ID in the first + // slot + // + // 1) begin work: + $q = "BEGIN WORK"; + $this->db->query($q); ! // 2) update values of onlinkbar ! $q = "UPDATE psl_topic SET onlinkbar=onlinkbar+1 ! WHERE onlinkbar > 0 && onlinkbar < '$is_onlinkbar'"; ! $this->db->query($q); ! // 3) put this topic_id as first item in bar ! $q = "UPDATE psl_topic ! SET onlinkbar=1 ! WHERE topic_id = '$topic_id'"; ! $this->db->query($q); ! // 4) commit and release table ! $q = "COMMIT"; ! $this->db->query($q); ! ! // this might not be necessary, ! // but hey, you never know! -luis m ! if ($this->db->affected_rows() > 0) { ! return true; ! }else{ ! return false; ! } ! ! } else { ! // is_onlinkbar is ONE, return true. ! return true; ! }// end is_onlinkbar > 1 ! ! } else { ! // 1) begin work: ! $q = "BEGIN WORK"; ! $this->db->query($q); ! // 2) update values of onlinkbar ! $q = "UPDATE psl_topic ! SET onlinkbar=onlinkbar+1 ! WHERE onlinkbar != 0"; ! $this->db->query($q); ! ! // 3) purge values higher than LIMIT ! $q = "UPDATE psl_topic ! SET onlinkbar=0 ! WHERE onlinkbar > '$limit'"; ! $this->db->query($q); ! ! // 4) put this topic_id as first item in bar ! $q = "UPDATE psl_topic ! SET onlinkbar=1 ! WHERE topic_id = '$topic_id'"; ! $this->db->query($q); ! ! // 5) commit and release table ! $q = "COMMIT"; ! $this->db->query($q); ! if ($this->db->affected_rows() > 0) { ! return true; ! }else{ ! return false; ! } ! } // end is_onlinkbar } // end renormTopic() |