[Phpslash-commit] CVS: phpslash-ft/class Author.class,1.22,1.23
Brought to you by:
joestewart,
nhruby
From: Joe S. <joe...@us...> - 2002-05-31 16:45:59
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv27461/phpslash-ft/class Modified Files: Author.class Log Message: author_options Index: Author.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Author.class,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Author.class 24 May 2002 15:25:16 -0000 1.22 --- Author.class 31 May 2002 16:45:56 -0000 1.23 *************** *** 8,11 **** --- 8,22 ---- * This object is how we do anything with authors. * + * optional configuration variables: + * + * $_PSL['author_optioncount'] = integer value for additional author + * information [0]. + * $_PSL['default_author_options'] = array of default values of options for + * all authors. [none] + * example: $default_author_options[] = array( + * 'name' => "ICQ", + * 'value' => "" + * ); + * $_PSL['default_author_options'] = $default_author_options; */ class Author { *************** *** 127,130 **** --- 138,155 ---- $ary['author_realname'] = addslashes(str_replace('\"',""",stripslashes($ary["author_realname"]))); + $optionname_ary = $ary[optionname]; + $optionval_ary = $ary[optionval]; + + for( $i=0 ; $i < count($ary[optionname]) ; $i++) { + + if( $optionname_ary[$i] != "") { + $optname = $optionname_ary[$i]; + $optval = $optionval_ary[$i]; + $author_options_ary[$optname] = $optval; + } + + } + $serial_opts=addslashes(serialize($author_options_ary)); + /* if a record exists, then we update, else we insert a new author! */ *************** *** 150,154 **** email = '$ary[email]', quote = '$ary[quote]', ! perms = '$joined_perms' WHERE author_id = '$ary[author_id]'"; } else { --- 175,180 ---- email = '$ary[email]', quote = '$ary[quote]', ! perms = '$joined_perms', ! author_options = '$serial_opts' WHERE author_id = '$ary[author_id]'"; } else { *************** *** 160,164 **** quote = '$ary[quote]', password = MD5('$ary[author_name]:$ary[password]'), ! perms = '$joined_perms' WHERE author_id = '$ary[author_id]'"; } --- 186,191 ---- quote = '$ary[quote]', password = MD5('$ary[author_name]:$ary[password]'), ! perms = '$joined_perms', ! author_options = '$serial_opts' WHERE author_id = '$ary[author_id]'"; } *************** *** 188,192 **** password, seclev, ! perms) VALUES ('$ary[author_id]', '$ary[author_name]', --- 215,220 ---- password, seclev, ! perms, ! author_options) VALUES ('$ary[author_id]', '$ary[author_name]', *************** *** 197,201 **** MD5('$ary[author_name]:$ary[password]'), '$ary[seclev]', ! '$joined_perms')"; $this->message = "Author Created"; --- 225,230 ---- MD5('$ary[author_name]:$ary[password]'), '$ary[seclev]', ! '$joined_perms', ! '$serial_opts')"; $this->message = "Author Created"; *************** *** 256,259 **** --- 285,302 ---- $ary['author_realname'] = clean($ary["author_realname"]); + $optionname_ary = $ary[optionname]; + $optionval_ary = $ary[optionval]; + + for( $i=0 ; $i < count($ary[optionname]) ; $i++) { + + if( $optionname_ary[$i] != "") { + $optname = $optionname_ary[$i]; + $optval = $optionval_ary[$i]; + $section_options_ary[$optname] = $optval; + } + + } + $serial_opts=addslashes(serialize($section_options_ary)); + $this->db->query("SELECT author_id FROM psl_author *************** *** 267,271 **** url = '$ary[url]', email = '$ary[email]', ! quote = '$ary[quote]' WHERE author_id = '$ary[author_id]'"; } else { --- 310,315 ---- url = '$ary[url]', email = '$ary[email]', ! quote = '$ary[quote]', ! author_options = '$serial_opts' WHERE author_id = '$ary[author_id]'"; } else { *************** *** 276,280 **** email = '$ary[email]', quote = '$ary[quote]', ! password = MD5('$ary[author_name]:$ary[password]') WHERE author_id = '$ary[author_id]'"; } --- 320,325 ---- email = '$ary[email]', quote = '$ary[quote]', ! password = MD5('$ary[author_name]:$ary[password]', ! author_options = '$serial_opts') WHERE author_id = '$ary[author_id]'"; } *************** *** 392,395 **** --- 437,464 ---- )); + $optioncnt = count($this->psl[default_author_options]); + $this->author_templ->set_block("newauthor","each_default_option", "doptions"); + for ($i =0; $i < $optioncnt; $i++) { + $this->author_templ->set_var(array( + 'DOPTION_NAME' => "optionname[]", + 'DOPTION_NAME_VAL' => $this->psl['default_author_options'][$i]['name'], + 'DOPTION_VALUE' => "optionval[]", + 'DOPTION_VALUE_VAL' => $this->psl['default_author_options'][$i]['value'] + )); + $this->author_templ->parse("doptions", "each_default_option", true); + } + + $this->author_templ->set_block("newauthor","each_option", "options"); + $optioncnt = $this->psl[author_optioncount]; + for ($i =1; $i <= $optioncnt; $i++) { + $this->author_templ->set_var(array( + 'OPTION_NAME' => "optionname[$i]", + 'OPTION_NAME_VAL' => "", + 'OPTION_VALUE' => "optionval[$i]", + 'OPTION_VALUE_VAL' => "" + )); + $this->author_templ->parse("options", "each_option", true); + } + $this->author_templ->parse('OUT',array("newauthor")); $this->author_templ->p('OUT'); *************** *** 455,458 **** --- 524,529 ---- )); + $temparray=unserialize($this->db->Record['author_options']); + $allperms_ary = $this->perm->getPerms(); /* *************** *** 499,502 **** --- 570,643 ---- } } + } + + if (is_array($temparray)) { + reset($temparray); + } + + $optioncnt = count($this->psl[default_author_options]); + $this->author_templ->set_block($template,"each_default_option", "doptions"); + for ($i =0; $i < $optioncnt; $i++) { + if(is_array($temparray)) { + reset($temparray); + } + $dname = $this->psl['default_author_options'][$i]['name']; + $dvalue = $this->psl['default_author_options'][$i]['value']; + if(isset($temparray[$dname])) { + $dvalue = $temparray[$dname]; + $this->author_templ->set_var(array( + 'DOPTION_NAME' => "optionname[]", + 'DOPTION_NAME_VAL' => $dname, + 'DOPTION_VALUE' => "optionval[]", + 'DOPTION_VALUE_VAL' => $dvalue + )); + unset($temparray[$dname]); + } else { + $this->author_templ->set_var(array( + 'DOPTION_NAME' => "optionname[]", + 'DOPTION_NAME_VAL' => $dname, + 'DOPTION_VALUE' => "optionval[]", + 'DOPTION_VALUE_VAL' => $dvalue + )); + } + $this->author_templ->parse("doptions", "each_default_option", true); + } + + $this->author_templ->set_block($template,"each_option", "options"); + if (is_array($temparray)) { + reset($temparray); + } + $optioncnt = $this->psl['author_optioncount']; + $i = 1; + + if (is_array($temparray)) { + for ($i =1; $i <= count($temparray); $i++) { + $current=each($temparray); + debug("current", $current); + + if ($current) { + $this->author_templ->set_var(array( + 'OPTION_NAME' => "optionname[]", + 'OPTION_NAME_VAL' => $current[0], + 'OPTION_VALUE' => "optionval[]", + 'OPTION_VALUE_VAL' => $current[1] + )); + } + $this->author_templ->parse("options", "each_option", true); + } + if( (count($temparray) - $optioncnt) >= 0) { + $optioncnt = $i; // spit out one more; + } + } + + while ($i <= $optioncnt) { + $this->author_templ->set_var(array( + 'OPTION_NAME' => "optionname[]", + 'OPTION_NAME_VAL' => "", + 'OPTION_VALUE' => "optionval[]", + 'OPTION_VALUE_VAL' => "" + )); + $this->author_templ->parse("options", "each_option", true); + $i++; } |