Update of /cvsroot/basedb/basedb/www In directory usw-pr-cvs1:/tmp/cvs-serv2429 Modified Files: bio.inc.php common.inc.php extract_edit.phtml extract_list.phtml htmlinit.phtml hyb_common.inc.php hyb_list.phtml image.inc.php image_get.phtml item.inc.php item_common.inc.php labeled_edit.phtml labeled_list.phtml left.phtml misc.inc.php molecule.inc.php plate_edit.phtml protocol.inc.php sample_edit.phtml sample_list.phtml sampletissue.inc.php sampletissue_tree.phtml test.phtml Added Files: links_common.inc.php Log Message: Many changes large and small --- NEW FILE: links_common.inc.php --- <? // $Id: links_common.inc.php,v 1.1 2002/09/30 08:26:44 troein Exp $ // // BioArray Software Environment (BASE) - homepage http://base.thep.lu.se/ // Copyright (C) 2002 Lao Saal, Carl Troein, Johan Vallon-Christersson (LSCTJVC) // // Write to LSCTJVC, Dept. of Oncology, Lund University Hospital, // Klinikgatan 7, SE-22185, Lund, Sweden. // // This file is part of BASE. // // BASE is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // BASE is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // require_once("item_common.inc.php"); function protocolLink(&$arr) { if(!$arr["protocolRead"]) return html($arr["protocolName"]).remMark($arr["protocolRemoved"]); return "<a ".href("protocol_edit.phtml?i_p=".(int)$arr["protocol"], 2).">". html($arr["protocolName"])."</a>".remMark($arr["protocolRemoved"]); } function protocolIdLink($id, &$user) { $id = (int)$id; $arr = Protocol::getBasicFromId($id); if(!Protocol::isSharedId($id, $user)) return html($arr["name"]).remMark($arr["removed"]); return "<a ".href("protocol_edit.phtml?i_p=$id", 2).">". html($arr["name"]).remMark($arr["removed"])."</a>"; } ?> Index: bio.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/bio.inc.php,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** bio.inc.php 20 Sep 2002 18:25:00 -0000 1.27 --- bio.inc.php 30 Sep 2002 08:26:43 -0000 1.28 *************** *** 407,412 **** $query = "SELECT e.*, ug.name AS `userName`, ". ! Item::whereShared("s", $user)." AS `samplePublic`, ". ! "p.name AS `protocolName`, ". "s.name AS `sampleName`, s.removed AS `sampleRemoved` ". "FROM Extract e, Sample s, UserGroup ug, Protocol p ". --- 407,413 ---- $query = "SELECT e.*, ug.name AS `userName`, ". ! Item::whereShared("s", $user)." AS `sampleRead`, ". ! "p.name AS `protocolName`, p.removed AS `protocolRemoved`, ". ! Item::whereShared("p", $user)." AS `protocolRead`, ". "s.name AS `sampleName`, s.removed AS `sampleRemoved` ". "FROM Extract e, Sample s, UserGroup ug, Protocol p ". *************** *** 630,633 **** --- 631,650 ---- } + // Returns array id->array(name,removed) with all labeled extracts that + // were made from a specific extract and that the owner has access to. + function getBriefForExtract($extract, &$user, $removed = 0) + { + $extract = (int)$extract; + $query = "SELECT i.id, i.name, i.removed ". + "FROM LabeledExtract i WHERE i.extract = $extract ". + "AND ".Item::whereShared("i", $user)." ". + Item::whereRemovedAnd("i", $removed); + $res = query($query); + $arr = array(); + while($row =& db_fetch_assoc($res)) + $arr[$row["id"]] = $row; + return $arr; + } + // Returns array from position to array(id,...,private,label, // quantity,qtyLeft,removed) *************** *** 715,721 **** $query = "SELECT le.*, ug.name AS `userName`, ". ! Item::whereShared("s", $user)." AS `samplePublic`, ". ! Item::whereShared("e", $user)." AS `extractPublic`, ". ! "p.name AS `protocolName`, ". "e.name AS `extractName`, e.removed AS `extractRemoved`, ". "e.sample, s.name AS `sampleName`, s.removed AS `sampleRemoved` ". --- 732,739 ---- $query = "SELECT le.*, ug.name AS `userName`, ". ! Item::whereShared("s", $user)." AS `sampleRead`, ". ! Item::whereShared("e", $user)." AS `extractRead`, ". ! Item::whereShared("p", $user)." AS `protocolRead`, ". ! "p.name AS `protocolName`, p.removed AS `protocolRemoved`, ". "e.name AS `extractName`, e.removed AS `extractRemoved`, ". "e.sample, s.name AS `sampleName`, s.removed AS `sampleRemoved` ". Index: common.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/common.inc.php,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** common.inc.php 16 Sep 2002 14:20:57 -0000 1.20 --- common.inc.php 30 Sep 2002 08:26:43 -0000 1.21 *************** *** 38,42 **** "adminEmail", "uploadDir", "tempDir", "jobDir", "rawFileDir", "rawImageDir", "printMapDir", "execDir", "webDir", "gnuplot", ! "mime.types", "displayCookie", "accessColumns"); foreach($cfgvars as $v) { --- 38,42 ---- "adminEmail", "uploadDir", "tempDir", "jobDir", "rawFileDir", "rawImageDir", "printMapDir", "execDir", "webDir", "gnuplot", ! "mime.types", "displayCookie", "accessColumns", "protocolDir"); foreach($cfgvars as $v) { Index: extract_edit.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/extract_edit.phtml,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** extract_edit.phtml 22 Sep 2002 23:37:34 -0000 1.18 --- extract_edit.phtml 30 Sep 2002 08:26:43 -0000 1.19 *************** *** 28,31 **** --- 28,32 ---- require_once("bio.inc.php"); require_once("item_common.inc.php"); + require_once("links_common.inc.php"); verifyAccess(BUA_BIO_READ); *************** *** 63,67 **** if(isset($i_name)) $ext->setName($i_name); [...71 lines suppressed...] --- 302,306 ---- { $sname = "<a ".href("sample_edit.phtml?i_samp=$sid", 2).">". ! $sname.remMark($sinfo["removed"])."</a>"; } *************** *** 297,301 **** <tr><th>Name</th><td><?= html($ext->getName()).remMark($ext) ?></td></tr> <tr><th>Sample</th><td><?= $sname ?></td></tr> ! <tr><th>Protocol</th><td><?= html($pname) ?></td></tr> <tr><th>Description</th><td><?= html($ext->getDescr()) ?></td></tr> <tr><th>Extracted quantity (µg)</th><td><?= $ext->getQuantity() ?></td></tr> --- 308,313 ---- <tr><th>Name</th><td><?= html($ext->getName()).remMark($ext) ?></td></tr> <tr><th>Sample</th><td><?= $sname ?></td></tr> ! <tr><th>Protocol</th><td><?= ! protocolIdLink($ext->getProtocol(), $curUser) ?></td></tr> <tr><th>Description</th><td><?= html($ext->getDescr()) ?></td></tr> <tr><th>Extracted quantity (µg)</th><td><?= $ext->getQuantity() ?></td></tr> Index: extract_list.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/extract_list.phtml,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** extract_list.phtml 22 Sep 2002 23:37:34 -0000 1.14 --- extract_list.phtml 30 Sep 2002 08:26:43 -0000 1.15 *************** *** 31,34 **** --- 31,35 ---- require_once("searchhtml.inc.php"); require_once("item_common.inc.php"); + require_once("links_common.inc.php"); verifyAccess(BUA_BIO_READ); *************** *** 80,84 **** $s =& $extracts[$i]; ! if($s["samplePublic"]) { $slink = "<a href='sample_edit.phtml?i_samp=$s[sample]'>". --- 81,85 ---- $s =& $extracts[$i]; ! if($s["sampleRead"]) { $slink = "<a href='sample_edit.phtml?i_samp=$s[sample]'>". *************** *** 94,104 **** html($arr["name"]).remMark($arr["removed"])."</a>"; } ! $hybs = implode(" ", $hybs); if($hybs == "") $hybs = html(""); ! $labs = LabeledExtract::countForExtract($s["id"]); ! if(!$s["removed"]) ! $labs .= " <a href='labeled_edit.phtml?i_ext=$s[id]'>[new]</a>"; $qty = isset($s["quantityLeft"]) ? $s["quantityLeft"] : "n/a"; --- 95,114 ---- html($arr["name"]).remMark($arr["removed"])."</a>"; } ! $hybs = implode(", ", $hybs); if($hybs == "") $hybs = html(""); ! $labs = LabeledExtract::getBriefForExtract($s["id"], ! $curUser, showDelSublist()); ! for(reset($labs); list($id, $arr) = each($labs); ) ! { ! $labs[$id] = "<a href='labeled_edit.phtml?i_lab=$id'>". ! html($arr["name"]).remMark($arr["removed"])."</a>"; ! } ! if(!$s["removed"] && acc(BUA_BIO_EDIT)) ! $labs[] = "<a href='labeled_edit.phtml?i_ext=$s[id]'>[new]</a>"; ! $labs = implode(", ", $labs); ! if($labs == "") ! $labs = html(""); $qty = isset($s["quantityLeft"]) ? $s["quantityLeft"] : "n/a"; *************** *** 108,117 **** html($s["name"]).remMark($s["removed"])."</a></td>". "<td>$slink</td>". ! "<td>".html($s["extractionDate"])."</td>". "<td>".html($s["userName"])."</td>". "<td>".groupAccessCheckbox($s["id"])."</td>". "<td>".groupInfo($s, $users)."</td>". "<td>".worldInfo($s)."</td>". ! "<td>".html($s["protocolName"])."</td>". "<td>".$qty."</td>". "<td>".$labs."</td>". --- 118,127 ---- html($s["name"]).remMark($s["removed"])."</a></td>". "<td>$slink</td>". ! "<td>".htmldate($s["extractionDate"])."</td>". "<td>".html($s["userName"])."</td>". "<td>".groupAccessCheckbox($s["id"])."</td>". "<td>".groupInfo($s, $users)."</td>". "<td>".worldInfo($s)."</td>". ! "<td>".protocolLink($s)."</td>". "<td>".$qty."</td>". "<td>".$labs."</td>". Index: htmlinit.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/htmlinit.phtml,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** htmlinit.phtml 12 Sep 2002 22:37:56 -0000 1.25 --- htmlinit.phtml 30 Sep 2002 08:26:43 -0000 1.26 *************** *** 45,49 **** $bgColor = "#f0f4f4"; ?> - <meta name=creator content="Typoed by Círdan"> <style type="text/css"> a:active { text-decoration: none; color: #ff5050; } --- 45,48 ---- Index: hyb_common.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/hyb_common.inc.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** hyb_common.inc.php 22 Sep 2002 23:37:34 -0000 1.8 --- hyb_common.inc.php 30 Sep 2002 08:26:43 -0000 1.9 *************** *** 83,87 **** html(Protocol::getNameFromId($hyb->getProtocol())) ?></td></tr> <tr><th>Description</th><td><?= html($hyb->getDescr()) ?></td></tr> ! <tr><th>Hybridized</th><td><?= html($hyb->getHybridizationDate()) ?></td></tr> <? dateAndOwnerTable($hyb, $curUser); --- 83,87 ---- html(Protocol::getNameFromId($hyb->getProtocol())) ?></td></tr> <tr><th>Description</th><td><?= html($hyb->getDescr()) ?></td></tr> ! <tr><th>Hybridized</th><td><?= htmldate($hyb->getHybridizationDate()) ?></td></tr> <? dateAndOwnerTable($hyb, $curUser); Index: hyb_list.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/hyb_list.phtml,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** hyb_list.phtml 22 Sep 2002 23:37:34 -0000 1.14 --- hyb_list.phtml 30 Sep 2002 08:26:43 -0000 1.15 *************** *** 121,125 **** "<td>".implode(",\n", $llink)."</td>". "<td>".html($s["barcode"])."</td>". ! "<td>".html($s["hybridizationDate"])."</td>". "<td>".html($s["userName"])."</td>". "<td>".groupAccessCheckbox($s["id"])."</td>". --- 121,125 ---- "<td>".implode(",\n", $llink)."</td>". "<td>".html($s["barcode"])."</td>". ! "<td>".htmldate($s["hybridizationDate"])."</td>". "<td>".html($s["userName"])."</td>". "<td>".groupAccessCheckbox($s["id"])."</td>". Index: image.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/image.inc.php,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** image.inc.php 20 Sep 2002 18:25:01 -0000 1.15 --- image.inc.php 30 Sep 2002 08:26:43 -0000 1.16 *************** *** 27,31 **** require_once("acquisition.inc.php"); ! define("CLEN_IMAGE_NAME", 150); class Image extends Item --- 27,31 ---- require_once("acquisition.inc.php"); ! define("CLEN_IMAGE_NAME", 255); class Image extends Item Index: image_get.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/image_get.phtml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** image_get.phtml 5 Aug 2002 11:29:34 -0000 1.3 --- image_get.phtml 30 Sep 2002 08:26:43 -0000 1.4 *************** *** 41,46 **** $err = ""; $img = new Image(); ! if(!isset($i_img)) $err = "No image specified"; ! else if(!$img->read($i_img, $curUser->getId())) $err = "No such image"; --- 41,47 ---- $err = ""; $img = new Image(); ! if(!isset($i_img)) ! $err = "No image specified"; ! else if(!$img->readShared($i_img, $curUser)) $err = "No such image"; Index: item.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/item.inc.php,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** item.inc.php 22 Sep 2002 23:37:34 -0000 1.33 --- item.inc.php 30 Sep 2002 08:26:43 -0000 1.34 *************** *** 108,129 **** } - function whereShared($table, &$user, $write = 0) - { - if(!is_object($user)) - { - error_log("Invalid user in Item::whereShared($table, $user, $write)"); - } - $write = $write ? 1 : 0; - $where = "$table.worldAccess > $write ". [...94 lines suppressed...] return ($access !== false || $user->access($access)) ! && $this->owner == $user->getId(); } function mayEdit(&$user, $access = false) { return ($access !== false || $user->access($access)) ! && $this->isShared($user, true) && !$this->removed; } --- 425,434 ---- { return ($access !== false || $user->access($access)) ! && $this->isShared($user, 2); } function mayEdit(&$user, $access = false) { return ($access !== false || $user->access($access)) ! && $this->isShared($user, 1) && !$this->removed; } Index: item_common.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/item_common.inc.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** item_common.inc.php 22 Sep 2002 23:37:35 -0000 1.3 --- item_common.inc.php 30 Sep 2002 08:26:43 -0000 1.4 *************** *** 49,66 **** <tr><th>Date added</th><td><?= htmldate($item->getAddedDate()) ?></td></tr> <? ! if(!$edit || $item->getOwner() != $user->getId()) ! { ! ?> ! <tr><th>Owner</th><td><?= userInfo($item, $void) ?></td></tr> ! <tr><th>Group</th><td><?= groupInfo($item, $void) ?></td></tr> ! <tr><th>World access</th><td><?= worldInfo($item) ?></td></tr> ! <? ! } [...68 lines suppressed...] ! if(isset($i_delete) && $i_delete) { $err = ""; $undel = $i_delete == 2; $act = $undel ? "undelete" : "delete"; ! if(!$user->access($access)) ! $err = "Can't $act ".$item->getType().": access denied ($access)"; ! else if($sharing && !$item->mayDelete($user)) $err = "Can't $act someone else's ".$item->getType(); else if($item->getRemoved() && !$undel) *************** *** 320,324 **** --- 335,341 ---- if($err == "") redirect($GLOBALS["location"]); + return $err; } + return ""; } Index: labeled_edit.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/labeled_edit.phtml,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** labeled_edit.phtml 22 Sep 2002 23:37:35 -0000 1.17 --- labeled_edit.phtml 30 Sep 2002 08:26:43 -0000 1.18 *************** *** 327,331 **** html($lext->getQuantity()) ?></td></tr> <tr><th>Quantity left</th><td><?= $lext->getQuantityLeft() ?></td></tr> ! <tr><th>Labeled</th><td><?= html($lext->getLabelingDate()) ?></td></tr> <? dateAndOwnerTable($lext, $curUser); --- 327,331 ---- html($lext->getQuantity()) ?></td></tr> <tr><th>Quantity left</th><td><?= $lext->getQuantityLeft() ?></td></tr> ! <tr><th>Labeled</th><td><?= htmldate($lext->getLabelingDate()) ?></td></tr> <? dateAndOwnerTable($lext, $curUser); Index: labeled_list.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/labeled_list.phtml,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** labeled_list.phtml 22 Sep 2002 23:37:35 -0000 1.15 --- labeled_list.phtml 30 Sep 2002 08:26:44 -0000 1.16 *************** *** 31,34 **** --- 31,35 ---- require_once("searchhtml.inc.php"); require_once("item_common.inc.php"); + require_once("links_common.inc.php"); verifyAccess(BUA_BIO_READ); *************** *** 84,88 **** $s =& $lexts[$i]; ! if($s["samplePublic"]) { $slink = "<a href='sample_edit.phtml?i_samp=$s[sample]'>". --- 85,89 ---- $s =& $lexts[$i]; ! if($s["sampleRead"]) { $slink = "<a href='sample_edit.phtml?i_samp=$s[sample]'>". *************** *** 91,95 **** else $slink = html($s["sampleName"]); ! if($s["extractPublic"]) { $elink = "<a href='extract_edit.phtml?i_ext=$s[extract]'>". --- 92,96 ---- else $slink = html($s["sampleName"]); ! if($s["extractRead"]) { $elink = "<a href='extract_edit.phtml?i_ext=$s[extract]'>". *************** *** 122,126 **** "<td>".groupInfo($s, $users)."</td>". "<td>".worldInfo($s)."</td>". ! "<td>".html($s["protocolName"])."</td>". "<td>".$qty."</td>". "<td>".$hybs."</td></tr>\n"; --- 123,127 ---- "<td>".groupInfo($s, $users)."</td>". "<td>".worldInfo($s)."</td>". ! "<td>".protocolLink($s)."</td>". "<td>".$qty."</td>". "<td>".$hybs."</td></tr>\n"; Index: left.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/left.phtml,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** left.phtml 16 Sep 2002 14:20:57 -0000 1.47 --- left.phtml 30 Sep 2002 08:26:44 -0000 1.48 *************** *** 117,120 **** --- 117,121 ---- <span class=special><?= html($curUser->getName()) ?></span> [<a target=_top href="index.phtml?i_logout=1">Log out</a>]<br> + <?= acc(BUA_SUPERUSER) ? "<span class=special>Superuser</span><br>" : "" ?> Users online: <?= $loggedin ?></td></tr> <tr><td class=tiny><img src="img/1.gif" alt="" width=1 height=1></td></tr> Index: misc.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/misc.inc.php,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** misc.inc.php 12 Sep 2002 22:37:56 -0000 1.38 --- misc.inc.php 30 Sep 2002 08:26:44 -0000 1.39 *************** *** 185,189 **** // Generates a file name which is bloody well near unique ! function tempFileName() { global $config; --- 185,189 ---- // Generates a file name which is bloody well near unique ! function tempFilename() { global $config; Index: molecule.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/molecule.inc.php,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** molecule.inc.php 12 Sep 2002 13:53:29 -0000 1.33 --- molecule.inc.php 30 Sep 2002 08:26:44 -0000 1.34 *************** *** 261,268 **** --- 261,274 ---- function setSpecies($val) { + $p = strpos($val, "."); + if($p !== false) + $val = substr($val, 0, $p); $this->species = maxlen($val, CLEN_MOLECULE_SPECIES); } function setClusterId($val) { + $p = strpos($val, "."); + if($p !== false) + $val = substr($val, $p + 1); $this->clusterId = (int)$val; } Index: plate_edit.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/plate_edit.phtml,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** plate_edit.phtml 22 Sep 2002 23:37:35 -0000 1.30 --- plate_edit.phtml 30 Sep 2002 08:26:44 -0000 1.31 *************** *** 36,85 **** setLocation("plate_list.phtml"); ! $edit = true; $clone = 0; $err = ""; - if(isset($i_act)) - { - // Deal with input from delete of validation input row - if(is_array($i_act)) - { [...154 lines suppressed...] *************** *** 201,207 **** $i_edit = 1; } ! else if(!isset($i_p)) $err = "You must specify a plate id"; ! else if(!$plate->read($i_p)) $err = "No such plate"; ! else $ptype->read($plate->getPlateType()); $edit = isset($i_edit); $eventTypes = $ptype->getEventTypes(); --- 232,241 ---- $i_edit = 1; } ! else if(!isset($i_p)) ! $err = "You must specify a plate id"; ! else if(!$plate->read($i_p)) ! $err = "No such plate"; ! else ! $ptype->read($plate->getPlateType()); $edit = isset($i_edit); $eventTypes = $ptype->getEventTypes(); Index: protocol.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/protocol.inc.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** protocol.inc.php 26 Sep 2002 19:35:05 -0000 1.11 --- protocol.inc.php 30 Sep 2002 08:26:44 -0000 1.12 *************** *** 143,147 **** $search->addExtraWhere(Item::whereShared("p", $user)); if($typeid) ! $search->addExtraWhere("p.protocolType = $typeid"); $query = "SELECT COUNT(*) FROM Protocol p, UserGroup ug ". --- 143,147 ---- $search->addExtraWhere(Item::whereShared("p", $user)); if($typeid) ! $search->addExtraWhere("p.`protocolType` = $typeid"); $query = "SELECT COUNT(*) FROM Protocol p, UserGroup ug ". *************** *** 168,172 **** $query = "SELECT p.*, ug.name AS `userName`, pt.name AS `typeName` ". "FROM Protocol p, UserGroup ug, ProtocolType pt ". ! "WHERE ug.id = p.owner AND pt.id = p.protocolType ". $search->getWhere()." ".$search->getExtraWhere(). " $ob ".$search->makeLimit(); --- 168,172 ---- $query = "SELECT p.*, ug.name AS `userName`, pt.name AS `typeName` ". "FROM Protocol p, UserGroup ug, ProtocolType pt ". ! "WHERE ug.id = p.owner AND pt.id = p.`protocolType` ". $search->getWhere()." ".$search->getExtraWhere(). " $ob ".$search->makeLimit(); *************** *** 184,194 **** $query = "SELECT p.id, p.name, p.removed ". "FROM Protocol p ". ! "WHERE p.etype = ".(int)$typeid." ". "AND ".Item::whereShared("p", $user)." ". ! Item::whereRemovedAnd("p", $removed); $res = query($query); $arr = array(); while($row =& db_fetch_assoc($res)) ! $arr[$row[0]] = $row; return $arr; } --- 184,195 ---- $query = "SELECT p.id, p.name, p.removed ". "FROM Protocol p ". ! "WHERE p.`protocolType` = ".(int)$typeid." ". "AND ".Item::whereShared("p", $user)." ". ! Item::whereRemovedAnd("p", $removed)." ". ! "ORDER BY name"; $res = query($query); $arr = array(); while($row =& db_fetch_assoc($res)) ! $arr[$row["id"]] = $row; return $arr; } *************** *** 259,263 **** $id = (int)$id; $query = "SELECT 1 FROM Protocol p, ProtocolType pt ". ! "WHERE p.id = $id AND pt.id = p.protocolType ". "AND pt.name = '".addslashes($typename)."' ". "AND ".Item::whereShared("p", $user, $write); --- 260,264 ---- $id = (int)$id; $query = "SELECT 1 FROM Protocol p, ProtocolType pt ". ! "WHERE p.id = $id AND pt.id = p.`protocolType` ". "AND pt.name = '".addslashes($typename)."' ". "AND ".Item::whereShared("p", $user, $write); Index: sample_edit.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/sample_edit.phtml,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** sample_edit.phtml 22 Sep 2002 23:37:35 -0000 1.22 --- sample_edit.phtml 30 Sep 2002 08:26:44 -0000 1.23 *************** *** 25,29 **** // require_once("init.inc.php"); - require_once("protocol.inc.php"); require_once("bio.inc.php"); require_once("sampletissue.inc.php"); --- 25,28 ---- *************** *** 48,52 **** { if(!isset($i_tissue)) ! $i_tissue = SampleTissue::getAncestors($samp->getTissue()); $edit = isset($i_edit) && $i_edit && $samp->isShared($curUser, true); --- 47,51 ---- { if(!isset($i_tissue)) ! $i_tissue = SampleTissue::getAncestorsOf($samp->getTissue()); $edit = isset($i_edit) && $i_edit && $samp->isShared($curUser, true); *************** *** 153,157 **** value="<?= html($samp->getName(), 0) ?>"></td></tr> <? ! $tarr = SampleTissue::getChildren(0); echo "<tr><th><a target=_blank ". "href='http://www.ncbi.nlm.nih.gov/Taxonomy'>Organism</a></th>". --- 152,156 ---- value="<?= html($samp->getName(), 0) ?>"></td></tr> <? ! $tarr = SampleTissue::getChildrenOf(0); echo "<tr><th><a target=_blank ". "href='http://www.ncbi.nlm.nih.gov/Taxonomy'>Organism</a></th>". *************** *** 169,174 **** if(isset($i_tissue[0]) && $i_tissue[0]) { ! $tarr = SampleTissue::getChildren($i_tissue[0]); ! $tarr[] = new SampleTissue(0, "Other"); $anc = isset($i_tissue[1]) ? $i_tissue[1] : 0; for($i = 0; $i < count($tarr); $i++) --- 168,175 ---- if(isset($i_tissue[0]) && $i_tissue[0]) { ! $tarr = SampleTissue::getChildrenOf($i_tissue[0]); ! $t = new SampleTissue(); ! $t->setName("Other"); ! $tarr[] = $t; $anc = isset($i_tissue[1]) ? $i_tissue[1] : 0; for($i = 0; $i < count($tarr); $i++) *************** *** 242,246 **** } ! $tnames = SampleTissue::getAncestorNames($samp->getTissue()); if(!count($tnames)) $tnames = "None"; --- 243,247 ---- } ! $tnames = SampleTissue::getAncestorNamesOf($samp->getTissue()); if(!count($tnames)) $tnames = "None"; *************** *** 286,290 **** { if(!isset($i_tissue[$lvl - 1]) || !$i_tissue[$lvl - 1]) return; ! $tarr = SampleTissue::getChildren($i_tissue[$lvl - 1]); if(!count($tarr)) return; echo "<select name='i_tissue[$lvl]' onChange='this.form.submit()'>". --- 287,291 ---- { if(!isset($i_tissue[$lvl - 1]) || !$i_tissue[$lvl - 1]) return; ! $tarr = SampleTissue::getChildrenOf($i_tissue[$lvl - 1]); if(!count($tarr)) return; echo "<select name='i_tissue[$lvl]' onChange='this.form.submit()'>". Index: sample_list.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/sample_list.phtml,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** sample_list.phtml 22 Sep 2002 23:37:35 -0000 1.18 --- sample_list.phtml 30 Sep 2002 08:26:44 -0000 1.19 *************** *** 25,29 **** // require_once("init.inc.php"); - require_once("protocol.inc.php"); require_once("bio.inc.php"); require_once("hyb.inc.php"); --- 25,28 ---- *************** *** 81,85 **** "sample", $searchfields, $searchtypes, 2, "", true); ! Sample::prepareSearch($search, $curUser, 30, showDelValue()); groupAccessScripts(); --- 80,84 ---- "sample", $searchfields, $searchtypes, 2, "", true); ! Sample::prepareSearch($search, $curUser, 20, showDelValue()); groupAccessScripts(); *************** *** 117,121 **** $id = $s["id"]; ! $tnames = SampleTissue::getAncestorNames($s["tissue"]); if(!count($tnames)) $tnames = "None"; else $tnames = implode(", ", $tnames); --- 116,120 ---- $id = $s["id"]; ! $tnames = SampleTissue::getAncestorNamesOf($s["tissue"]); if(!count($tnames)) $tnames = "None"; else $tnames = implode(", ", $tnames); Index: sampletissue.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/sampletissue.inc.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** sampletissue.inc.php 10 Sep 2002 23:06:30 -0000 1.9 --- sampletissue.inc.php 30 Sep 2002 08:26:44 -0000 1.10 *************** *** 24,89 **** // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // ! require_once("db.inc.php"); define("CLEN_SAMPLETISSUE_NAME", 40); ! class SampleTissue { ! var $id, $parent, $name; [...240 lines suppressed...] ! function hasChildren() { ! $query = "SELECT COUNT(*) FROM SampleTissue WHERE parent = $this->id"; $res = query($query); ! if($row =& db_fetch_row($res)) return (bool)$row[0]; return false; } --- 152,163 ---- } ! function hasChildren($removed = 0) { ! $query = "SELECT COUNT(*) FROM SampleTissue st ". ! "WHERE st.parent = $this->id ". ! Item::whereRemovedAnd("st", $removed); $res = query($query); ! if($row =& db_fetch_row($res)) ! return $row[0] > 0; return false; } Index: sampletissue_tree.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/sampletissue_tree.phtml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** sampletissue_tree.phtml 10 Sep 2002 23:06:30 -0000 1.9 --- sampletissue_tree.phtml 30 Sep 2002 08:26:44 -0000 1.10 *************** *** 26,32 **** require_once("init.inc.php"); require_once("sampletissue.inc.php"); verifyAccess(BUA_BIO_TISSUE); ! setLocation("sampletissue_tree.phtml"); $err = ""; --- 26,35 ---- require_once("init.inc.php"); require_once("sampletissue.inc.php"); [...275 lines suppressed...] ! <tr><td><input type=button value="Add new organism" onClick="addOrg(this.form)" ! ></td></tr> ! </form> ! </table> ! </body> ! </html> --- 198,209 ---- $w = $cl * 20 + 150; echo "<td colspan=$cl width=$w>". ! "<a href='javascript:setTissue($id)' $class>". ! html($tiss[$i]["name"])."</a>".remMark($tiss[$i]["removed"]). ! "</td></tr>\n"; ! if($recHere) ! tissTree($ancs, $lv+1, $newtiss, $extralv, $islast); } } ! ?> \ No newline at end of file Index: test.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/test.phtml,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** test.phtml 16 Sep 2002 14:20:57 -0000 1.49 --- test.phtml 30 Sep 2002 08:26:44 -0000 1.50 *************** *** 26,29 **** --- 26,31 ---- header("content-type: text/plain"); + print_r($GLOBALS); + function foo($s1, $s2) { |