Update of /cvsroot/phpslash/phpslash-ft/class
In directory usw-pr-cvs1:/tmp/cvs-serv24679/phpslash-ft/class
Modified Files:
Author.class
Log Message:
deleteAuthor now checks for stories
Index: Author.class
===================================================================
RCS file: /cvsroot/phpslash/phpslash-ft/class/Author.class,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Author.class 2001/12/16 21:33:40 1.12
--- Author.class 2001/12/17 18:20:16 1.13
***************
*** 173,183 ****
}
! /**
* deleteAuthor - deletes the author info to the DB
*
! * Given the author_id, it deletes that from the author table. The
! * psl_author_lut and psl_author_submission_lut table must be cleaned
! * first by updating all the stories to point to different authors. It
! * will also check and make sure there are NO stories/submissions
* associated with this author before deleting it. Returns true if
* author is deleted, false if not.
--- 173,181 ----
}
! /**
* deleteAuthor - deletes the author info to the DB
*
! * Given the author_id, it deletes that from the author table.
! * It will also check and make sure there are NO stories
* associated with this author before deleting it. Returns true if
* author is deleted, false if not.
***************
*** 198,212 ****
return false;
}
! $q = "DELETE
! FROM psl_author
! WHERE author_id = '$author_id_to_delete'";
$this->db->query($q);
! if ($this->db->affected_rows() > 0) {
! return true;
! } else {
return false;
! };
}
/**
--- 196,232 ----
return false;
}
+
+ // prevent deletion of an author with stories
+ $go_ahead = true;
! $q = "SELECT title,
! story_id
! FROM psl_story
! WHERE user_id = '$author_id_to_delete' ";
$this->db->query($q);
! while ($this->db->next_record()) {
! $go_ahead = false;
! $title = $this->db->Record["title"];
! $story_id = $this->db->Record["story_id"];
! $section_name = $this->db->Record["section_name"];
! error("$title($story_id)");
! }
!
! if (!$go_ahead) {
return false;
! } else {
!
! $q = "DELETE
! FROM psl_author
! WHERE author_id = '$author_id_to_delete'";
! $this->db->query($q);
! if ($this->db->affected_rows() > 0) {
! return true;
! } else {
! return false;
! }
! }
}
+
/**
|