Update of /cvsroot/phpslash/phpslash-ft/class
In directory usw-pr-cvs1:/tmp/cvs-serv20627/phpslash-ft/class
Modified Files:
Topic.class Story_base.class
Log Message:
[ 530216 ] Story_base.class+Topic.class++
Index: Topic.class
===================================================================
RCS file: /cvsroot/phpslash/phpslash-ft/class/Topic.class,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Topic.class 3 Feb 2002 02:49:40 -0000 1.10
--- Topic.class 15 Mar 2002 19:16:28 -0000 1.11
***************
*** 17,21 ****
/**
! * The Section Constructor
*
* sets up the local version of the global _PSL array, the templates
--- 17,21 ----
/**
! * The Topic Constructor
*
* sets up the local version of the global _PSL array, the templates
***************
*** 452,455 ****
--- 452,530 ----
return $topic_array;
}
+
+ /**
+ * renormTopic - renormalizes the topic info in the DB
+ * Param: $topic_id
+ *
+ * Updates the topic onlinkbar value on the DB
+ * Obligatory fields: topic_id
+ * Returns true if sucessful updated, false on error
+ * Used only by admin
+ *
+ * TODO: a) make this function deal with the whole array
+ * complete arrays... b) Take care of deleting stories
+ * c) clean up ... later ;-)
+ *
+ * @param array $topic_id_val
+ *
+ * @access private
+ */
+ function renormTopic($topic_id_val) {
+
+ if (!empty($topic_id_val)) {
+ // this is required!
+ $topic_id = $topic_id_val[0];
+ }else{
+ // bye bye
+ return false;
+ }
+
+ $limit = $this->psl['bar_limit']; // variables are easier to deal with
+ // less typing :-)
+
+ // updates the topic's onlinkbar values first,
+ //
+ // then set the values of onlinkbar higher
+ // than $limit to zero (so that they
+ // don't display)
+
+ // This is done by parts in case something or somebody
+ // is working on the same database at the same
+ // time ...
+ // 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()
} /* end of Topic.class */
Index: Story_base.class
===================================================================
RCS file: /cvsroot/phpslash/phpslash-ft/class/Story_base.class,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Story_base.class 14 Mar 2002 20:42:08 -0000 1.6
--- Story_base.class 15 Mar 2002 19:16:28 -0000 1.7
***************
*** 569,573 ****
$this->db->query($lut_insert);
}
! return true;
}
--- 569,589 ----
$this->db->query($lut_insert);
}
!
! // Change value of $_PSL["auto_norm"] to true
! // in your config.php3 file if you want to automatically
! // update your topic bar e/a time a story gets submitted
! //
! if ($this->psl["auto_renorm"]) {
! // create topic object
! $topic = new Topic;
!
! // use only the first topic in this array
! // most people choose one topic per story
! if ( !$topic->renormTopic($topic_id_ary) ) {
! $this->message="Topic bar could not be reorganized";
! }
! } // end if auto_renorm
!
! return true;
}
|