[Phpslash-commit] CVS: phpslash-ft/class Author.class,1.16,1.17
Brought to you by:
joestewart,
nhruby
From: Joe S. <joe...@us...> - 2002-04-11 21:05:13
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv17227/phpslash-ft/class Modified Files: Author.class Log Message: saveAuthor check Index: Author.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Author.class,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Author.class 3 Feb 2002 02:49:39 -0000 1.16 --- Author.class 11 Apr 2002 21:05:06 -0000 1.17 *************** *** 63,66 **** --- 63,67 ---- $this->author_templ->set_block("listauthor","row","rows"); + $this->author_templ->set_block("listauthor","row2","rows2"); $count = 0; *************** *** 82,87 **** 'AMP' => $this->psl['amp'] )); ! $this->author_templ->parse("rows","row",true); ! $count++; }; $this->author_templ->parse('OUT',array("listauthor")); --- 83,92 ---- 'AMP' => $this->psl['amp'] )); ! if ($count%2 == 0) { ! $this->author_templ->parse("rows","row","true"); ! } else { ! $this->author_templ->parse("rows","row2","true"); ! } ! $count++; }; $this->author_templ->parse('OUT',array("listauthor")); *************** *** 130,133 **** --- 135,145 ---- if ($this->db->next_record()) { if ($ary['password'] == "") { + + // if username changes password value in db has to change also + if ($ary[author_name] != $this->db->Record['author_name']) { + $this->message = "When changing the username, the password field must also be completed."; + return $false; + } + $q = "UPDATE psl_author SET author_name = '$ary[author_name]', *************** *** 149,152 **** --- 161,167 ---- WHERE author_id = '$ary[author_id]'"; } + + $this->message = "Author Updated"; + } else { *************** *** 177,180 **** --- 192,197 ---- '$ary[seclev]', '$joined_perms')"; + + $this->message = "Author Created"; } *************** *** 183,187 **** --- 200,266 ---- return true; } + + /** + * saveProfile - save the perm limited author info to the DB for + * users to modify their own info. + * + * Saves the author in the $ary array to the DB + * Obligatory fields: author_name, some others + * Optional fields: author_id + * + * Returns true if sucessful (author updated), false on error + * Used only by logged in users. + * + * @param array $ary + * + * @access public + */ + function saveProfile($ary) { + + if ($ary['author_name'] == "") { + error("There is no author_name in Author.class::saveAuthor"); + return false; + } + /* addslashes for the (') AND str_replace for the (") */ + + $ary["quote"] = clean($ary["quote"]); + $ary['author_name'] = clean($ary["author_name"]); + // $ary['author_name'] = clean($ary["author_name"]); + $ary['author_realname'] = clean($ary["author_realname"]); + + $this->db->query("SELECT author_id + FROM psl_author + WHERE author_id = '".$ary['author_id']."'"); + + if ($this->db->next_record()) { + if ($ary['password'] == "") { + $q = "UPDATE psl_author + SET author_name = '$ary[author_name]', + author_realname = '$ary[author_realname]', + url = '$ary[url]', + email = '$ary[email]', + quote = '$ary[quote]' + WHERE author_id = '$ary[author_id]'"; + } else { + $q = "UPDATE psl_author + SET author_name = '$ary[author_name]', + author_realname = '$ary[author_realname]', + url = '$ary[url]', + email = '$ary[email]', + quote = '$ary[quote]', + password = MD5('$ary[author_name]:$ary[password]') + WHERE author_id = '$ary[author_id]'"; + } + } + + # echo "<BR><PRE><B>QUERY: $q</B></PRE><BR>\n"; + $this->db->query($q); + + $this->message = "Profile Updated"; + return true; + } + + /** * deleteAuthor - deletes the author info to the DB *************** *** 200,204 **** if ($author_id_to_delete == $author_id) { ! echo "<BR><BR>You can't delete yourself! Create another user, log in as he/she and then delete this account.<BR><BR>"; return false; }; --- 279,283 ---- if ($author_id_to_delete == $author_id) { ! $this->message = "You can't delete yourself! Create another user, log in as he/she and then delete this account."; return false; }; *************** *** 233,236 **** --- 312,316 ---- $this->db->query($q); if ($this->db->affected_rows() > 0) { + $this->message = "Author deleted"; return true; } else { *************** *** 289,293 **** * @access public */ ! function editAuthor($id) { titlebar("100%","Update Author ($id)"); --- 369,388 ---- * @access public */ ! function editAuthor($id, $tpl='') { ! ! $default_tpl = "newauthor"; ! ! if( empty($tpl) ) { ! $template = $default_tpl; ! } elseif ( file_exists($this->psl['templatedir'] . "/" . basename($tpl) . ".tpl") ) { ! $tpl_file = basename($tpl) . ".tpl"; ! $this->author_templ->set_file(array( ! "template" => "$tpl_file" ! )); ! $template = "template"; ! } else { ! debug ( "Story.class::getStory:Template file doesn't exist, using default instead", $tpl); ! $template = $default_tpl; ! } titlebar("100%","Update Author ($id)"); *************** *** 332,336 **** }; ! $this->author_templ->parse('OUT',array("newauthor")); $this->author_templ->p('OUT'); --- 427,431 ---- }; ! $this->author_templ->parse('OUT',$template); $this->author_templ->p('OUT'); |