Update of /cvsroot/basedb/basedb/www In directory usw-pr-cvs1:/tmp/cvs-serv19687 Modified Files: bio.inc.php common.inc.php extract_edit.phtml index.phtml item.inc.php left.phtml newinit.inc.php sample_annotate.phtml sample_edit.phtml sample_list.phtml sampleannot_edit.phtml sampleannot_list.phtml sampleannotation.inc.php session.inc.php test.phtml user.inc.php Log Message: Started work on new user/group system Index: bio.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/bio.inc.php,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** bio.inc.php 12 Sep 2002 22:37:56 -0000 1.25 --- bio.inc.php 16 Sep 2002 14:20:57 -0000 1.26 *************** *** 26,30 **** // require_once("item.inc.php"); - /*require_once("project.inc.php");*/ define("CLEN_SAMPLE_NAME", CLEN_ITEM_NAME); --- 26,29 ---- *************** *** 90,96 **** $ok = true; [...187 lines suppressed...] { ! return parent::isSharedId("Sample", $id, $user); ! } ! function shareId($id, $userid) ! { ! return parent::shareId("Sample", $id, $userid); ! } ! function unshareId($id, $userid) ! { ! return parent::unshareId("Sample", $id, $userid); ! } ! function shareExclusiveId($id, $userid) ! { ! return parent::shareExclusiveId("Sample", $id, $userid); ! } ! function getSharersForId($id) ! { ! return parent::getSharersForId("Sample", $id); } } Index: common.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/common.inc.php,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** common.inc.php 9 Sep 2002 10:56:08 -0000 1.19 --- common.inc.php 16 Sep 2002 14:20:57 -0000 1.20 *************** *** 38,42 **** "adminEmail", "uploadDir", "tempDir", "jobDir", "rawFileDir", "rawImageDir", "printMapDir", "execDir", "webDir", "gnuplot", ! "mime.types"); foreach($cfgvars as $v) { --- 38,42 ---- "adminEmail", "uploadDir", "tempDir", "jobDir", "rawFileDir", "rawImageDir", "printMapDir", "execDir", "webDir", "gnuplot", ! "mime.types", "displayCookie", "accessColumns"); foreach($cfgvars as $v) { Index: extract_edit.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/extract_edit.phtml,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** extract_edit.phtml 12 Sep 2002 22:37:56 -0000 1.15 --- extract_edit.phtml 16 Sep 2002 14:20:57 -0000 1.16 *************** *** 91,95 **** $ext->setQuantityLeft($i_qty, true); } ! ignore_user_about($iua); $extid = $ext->getId(); --- 91,95 ---- $ext->setQuantityLeft($i_qty, true); } ! ignore_user_abort($iua); $extid = $ext->getId(); *************** *** 231,235 **** ?> ! <tr><th>Date added</th><td><?= html($ext->getAddedDate()) ?></td></tr> <? if(isset($i_ext)) --- 231,235 ---- ?> ! <tr><th>Date added</th><td><?= htmldate($ext->getAddedDate()) ?></td></tr> <? if(isset($i_ext)) Index: index.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/index.phtml,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** index.phtml 29 Aug 2002 16:51:34 -0000 1.17 --- index.phtml 16 Sep 2002 14:20:57 -0000 1.18 *************** *** 42,46 **** setcookie($config["cookieName"], $curSession->cookie->getCookie(), 0, $config["urlpath"]); ! EventLog::log('login', $curSession->user->getUserName()); } else --- 42,46 ---- setcookie($config["cookieName"], $curSession->cookie->getCookie(), 0, $config["urlpath"]); ! EventLog::log('login', $curSession->user->getName()); } else *************** *** 63,67 **** --- 63,69 ---- else if(isset($_COOKIE[$config["cookieName"]]) && $_COOKIE[$config["cookieName"]] != "" && !$loggedIn) + { $err = 1; + } // Save display settings if they've been submitted. *************** *** 78,82 **** isset($i_showlogo) && isset($i_showlogo[$logo])); } ! setcookie("display", $curDisplay->getCookie(), 0x7fffffff, $config["urlpath"]); } --- 80,84 ---- isset($i_showlogo) && isset($i_showlogo[$logo])); } ! setcookie($config["displayCookie"], $curDisplay->getCookie(), 0x7fffffff, $config["urlpath"]); } Index: item.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/item.inc.php,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** item.inc.php 12 Sep 2002 22:37:56 -0000 1.30 --- item.inc.php 16 Sep 2002 14:20:57 -0000 1.31 *************** *** 32,39 **** class Item { ! var $type, $id, $name, $descr, $owner, $addedDate, $removed; function Item($type, $name, $descr, $owner, $addedDate, $id, ! $removed = NULL) { $this->type = $type; --- 32,40 ---- class Item [...437 lines suppressed...] ! function isSharedId($type, $id, &$user) { $id = (int)$id; $user = (int)$user; ! $query = "SELECT 1 FROM $type i ". ! "WHERE i.id = $id AND ".Item::whereShared("i", $user); $res = query($query); return db_num_rows($res) > 0; } ! // Returns true if $userid owns item $id of type $type. ! function isOwner($type, $id, $userid) { $query = "SELECT owner FROM $type WHERE id = ".(int)$id; $res = query($query); if($row =& db_fetch_row($res)) ! return $row[0] == (int)$userid; return false; } Index: left.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/left.phtml,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** left.phtml 10 Sep 2002 23:05:58 -0000 1.46 --- left.phtml 16 Sep 2002 14:20:57 -0000 1.47 *************** *** 32,36 **** if($loggedIn && isset($i_broad) && $i_broad != "" && acc(BUA_BROADCAST)) { ! EventLog::log("broadcast", $curUser->getUserName().": ". substr($i_broad, 0, 60)); } --- 32,36 ---- if($loggedIn && isset($i_broad) && $i_broad != "" && acc(BUA_BROADCAST)) { ! EventLog::log("broadcast", $curUser->getName().": ". substr($i_broad, 0, 60)); } *************** *** 115,119 **** ?> <tr><td class=tiny>Logged in as ! <span class=special><?= html($curUser->getUserName()) ?></span> [<a target=_top href="index.phtml?i_logout=1">Log out</a>]<br> Users online: <?= $loggedin ?></td></tr> --- 115,119 ---- ?> <tr><td class=tiny>Logged in as ! <span class=special><?= html($curUser->getName()) ?></span> [<a target=_top href="index.phtml?i_logout=1">Log out</a>]<br> Users online: <?= $loggedin ?></td></tr> *************** *** 255,260 **** <? } ! else echo "<tr><th class=subhead><a target=_top href='index.phtml". ! "?l=upl&m=upload_list.phtml'>Uploads</a></td></tr>\n"; if(!$loggedIn || !acc(BUA_ANALYZE)) {} --- 255,263 ---- <? } ! else ! { ! echo "<tr><th class=subhead><a target=_top href='index.phtml". ! "?l=upl&m=upload_list.phtml'>Uploads</a></td></tr>\n"; ! } if(!$loggedIn || !acc(BUA_ANALYZE)) {} *************** *** 272,276 **** ?> <tr><td><img src='img/1.gif' alt='' width=1 height=1></td></tr> ! <tr><td><a target=main href='experiment_edit.phtml?i_e=-1&location=experiment_list.phtml' >Current experiment</a></td></tr> <? --- 275,280 ---- ?> <tr><td><img src='img/1.gif' alt='' width=1 height=1></td></tr> ! <tr><td><a target=main ! href='experiment_edit.phtml?i_e=-1&location=experiment_list.phtml' >Current experiment</a></td></tr> <? *************** *** 278,282 **** { ?> ! <tr><td><a target=main href='gene_explore.phtml?i_set=-1&location=experiment_list.phtml' >Experiment Explorer</a></td></tr> <? --- 282,287 ---- { ?> ! <tr><td><a target=main ! href='gene_explore.phtml?i_set=-1&location=experiment_list.phtml' >Experiment Explorer</a></td></tr> <? Index: newinit.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/newinit.inc.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** newinit.inc.php 7 Sep 2002 11:36:32 -0000 1.10 --- newinit.inc.php 16 Sep 2002 14:20:57 -0000 1.11 *************** *** 44,48 **** Session::purgeSessions($config["sessionTimeout"]); ! // Override $PHP_SELF with what's supposed to be the relative path. $GLOBALS["PHP_SELF"] = ereg_replace(".*/", "", $_SERVER["SCRIPT_NAME"]); --- 44,50 ---- Session::purgeSessions($config["sessionTimeout"]); ! // Override $PHP_SELF with what's supposed to be the relative path ! // of the script. This also gets rid of PATH_INFO, which is otherwise ! // included in PHP_SELF. $GLOBALS["PHP_SELF"] = ereg_replace(".*/", "", $_SERVER["SCRIPT_NAME"]); *************** *** 59,63 **** redirect("nologin.phtml?location=".urlencode($url)); } ! $GLOBALS["curUser"] = new Submitter(); return false; } --- 61,65 ---- redirect("nologin.phtml?location=".urlencode($url)); } ! $GLOBALS["curUser"] = new UserAccount(); return false; } Index: sample_annotate.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/sample_annotate.phtml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** sample_annotate.phtml 29 Aug 2002 16:51:34 -0000 1.11 --- sample_annotate.phtml 16 Sep 2002 14:20:57 -0000 1.12 *************** *** 70,74 **** for(reset($i_del); list($id) = each($i_del); ) { ! SampleAnnotation::removeId($sampid, $id); unset($i_use[$id]); } --- 70,74 ---- for(reset($i_del); list($id) = each($i_del); ) { ! SampleAnnotation::remove($sampid, $id); unset($i_use[$id]); } Index: sample_edit.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/sample_edit.phtml,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** sample_edit.phtml 12 Sep 2002 22:37:56 -0000 1.19 --- sample_edit.phtml 16 Sep 2002 14:20:57 -0000 1.20 *************** *** 40,44 **** if(isset($i_samp) && $i_samp) { ! if(!$samp->read($i_samp, $curUser->getId())) $err = "No such sample"; else if(!isset($i_tissue)) --- 40,44 ---- if(isset($i_samp) && $i_samp) { ! if(!$samp->readShared($i_samp, $curUser)) $err = "No such sample"; else if(!isset($i_tissue)) *************** *** 76,80 **** $newsamp = $samp->getId() == 0; ! $iua = ignore_user_abort(1); // To ensure sharing gets done if($err != "") {} else if(!acc(BUA_BIO_EDIT)) --- 76,80 ---- $newsamp = $samp->getId() == 0; ! if($err != "") {} else if(!acc(BUA_BIO_EDIT)) *************** *** 88,99 **** else $err = "Unable to save sample"; } - else - { - if(isset($i_public)) - $samp->share(0); - else - $samp->share($curUser->getId(), true); - } - ignore_user_abort($iua); $sampid = $samp->getId(); --- 88,91 ---- *************** *** 217,227 **** } - if(isset($i_public)) $pub = "checked"; - else $pub = $samp->isSharedWith(0) ? "checked" : ""; - ?> <tr><th>Description</th><td><textarea cols=50 rows=5 name=i_descr ><?= html($samp->getDescr(), 0) ?></textarea></td></tr> - <tr><th>Public</th><td><input type=checkbox name=i_public <?= $pub ?>></td></tr> <tr><th>Sample date</th><td><input type=text name=i_sdate size=10 value="<?= html($samp->getSampleDate(), 0) ?>"> --- 209,215 ---- *************** *** 274,278 **** } ! $uname = Submitter::getNameFromId($samp->getOwner()); $tnames = SampleTissue::getAncestorNames($samp->getTissue()); if(!count($tnames)) --- 262,266 ---- } ! $uname = UserGroup::getNameFromId($samp->getOwner()); $tnames = SampleTissue::getAncestorNames($samp->getTissue()); if(!count($tnames)) *************** *** 286,290 **** <tr><th>Date added</th><td><?= htmldate($samp->getAddedDate()) ?></td></tr> <tr><th>Owner</th><td><?= html($uname) ?></td></tr> - <tr><th>Public</th><td><?= $samp->isSharedWith(0) ? "Yes" : "No" ?></td></tr> <tr><td colspan=2 class=tiny> </td></tr> <tr><th colspan=2 class=subhead>Annotations</th></tr> --- 274,277 ---- Index: sample_list.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/sample_list.phtml,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** sample_list.phtml 12 Sep 2002 22:37:56 -0000 1.15 --- sample_list.phtml 16 Sep 2002 14:20:57 -0000 1.16 *************** *** 39,42 **** --- 39,86 ---- showDelPrep(); + // Sharing + if(!isset($i_sh) || !is_array($i_sh)) + $i_sh = array(); + $userid = $curUser->getId(); + $users = UserGroup::getBrief(); + unset($users[$userid]); + [...261 lines suppressed...] + <option value=1>Share + <option value=0 <?= isset($i_shhow) && !$i_shhow ? "selected" : "" + ?>>Unshare</select> marked samples with + <select name=i_shwho> + <? + for(reset($users); list($id, $n) = each($users); ) + { + $sel = isset($i_shwho) && $id == $i_shwho ? "selected" : ""; + echo "<option $sel value=$id>".html($n, 0)."\n"; + } + ?> + </select><input type=submit name=i_shgo value='Ok'> + <input type=submit name=i_shunall value="Unshare with all" + onClick="return confirm('Are you sure?')"> + </td></tr> + <? + } + showDelLinks($cols); ?> Index: sampleannot_edit.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/sampleannot_edit.phtml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** sampleannot_edit.phtml 10 Sep 2002 23:06:29 -0000 1.10 --- sampleannot_edit.phtml 16 Sep 2002 14:20:57 -0000 1.11 *************** *** 26,29 **** --- 26,30 ---- require_once("init.inc.php"); require_once("sampleannotation.inc.php"); + require_once("item_common.inc.php"); verifyAccess(BUA_BIO_ANNOT); *************** *** 44,108 **** $edit = true; $err = ""; [...169 lines suppressed...] ! } ! ?> <tr><th>Name</th><td><input type=text size=30 name=i_name maxlength=<?= CLEN_SAMPLEANNOTATION_NAME ?> value="<?= html($sat->getName(), 0) ?>"> <?= webHelp(59) ?></td></tr> + <tr><th>Description</th><td><textarea cols=50 rows=5 name=i_descr + ><?= html($sat->getDescr(), 0) ?></textarea></td></tr> + + <tr><th>Date added</th><td><?= htmldate($sat->getAddedDate()) ?></td></tr> + <tr><th>Added by</th><td><?= + html(Submitter::getNameFromId($sat->getOwner())) ?></td></tr> <tr><th>Type</th><td><select name=i_type onChange='this.form.submit()'> <? *************** *** 169,170 **** --- 203,205 ---- </body> </html> + Index: sampleannot_list.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/sampleannot_list.phtml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** sampleannot_list.phtml 29 Aug 2002 16:51:34 -0000 1.9 --- sampleannot_list.phtml 16 Sep 2002 14:20:57 -0000 1.10 *************** *** 26,31 **** --- 26,44 ---- require_once("init.inc.php"); require_once("sampleannotation.inc.php"); + require_once("search.inc.php"); + require_once("searchhtml.inc.php"); + require_once("item_common.inc.php"); verifyAccess(BUA_BIO_READ); + showDelPrep(); + [...82 lines suppressed...] echo "<tr bgcolor=$tdbg[$odd]>". ! "<td>$link".remMark($s["removed"])."</td>". ! "<td>".html($types[$s["valueType"]])."</td>". ! "<td>".html($s["options"])."</td>". ! "<td>".html($s["defaultValue"])."</td>". ! "<td>".html($s["descr"])."</td>". ! "<td>".htmldate($s["addedDate"])."</td>". ! "<td>".html($s["userName"])."</td>". "</tr>\n"; } ! $cols = 7; ! if($addlink != "") ! echo "<tr><td colspan=$cols>$addlink</td></tr>\n"; ! showDelLinks($cols); ?> + </form> </table> Index: sampleannotation.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/sampleannotation.inc.php,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** sampleannotation.inc.php 10 Sep 2002 23:06:29 -0000 1.17 --- sampleannotation.inc.php 16 Sep 2002 14:20:57 -0000 1.18 *************** *** 24,28 **** // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // ! require_once("db.inc.php"); define("CLEN_SAMPLEANNOTATION_NAME", 40); --- 24,28 ---- // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // ! require_once("item.inc.php"); [...421 lines suppressed...] ! "FROM SampleAnnotation sa, SampleAnnotationType sat ". ! "WHERE sa.sample = ".(int)$sample." ". ! "AND sat.id = sa.`annotationType` ". ! Item::whereRemovedAnd("sat", $removed); ! "ORDER BY sa.`annotationType`"; $arr = array(); $res = query($query); *************** *** 297,301 **** } ! function removeId($sample, $annotationType) { $sample = (int)$sample; --- 335,339 ---- } ! function remove($sample, $annotationType) { $sample = (int)$sample; Index: session.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/session.inc.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** session.inc.php 8 Sep 2002 22:38:08 -0000 1.6 --- session.inc.php 16 Sep 2002 14:20:57 -0000 1.7 *************** *** 42,46 **** function read($cookie = "", $ip = "") { ! if($cookie != "") $this->cookie = $cookie; $query = "SELECT * FROM Cookie ". --- 42,47 ---- function read($cookie = "", $ip = "") { ! if($cookie != "") ! $this->cookie = $cookie; $query = "SELECT * FROM Cookie ". *************** *** 81,86 **** { $query = "UPDATE Cookie SET ". ! "`lastSeen` = NOW(), ". ! "`IP` = '".addslashes($this->IP)."' ". "WHERE cookie = '".addslashes($this->cookie)."'"; return (bool)query($query); --- 82,86 ---- { $query = "UPDATE Cookie SET ". ! "`lastSeen` = NOW() ". "WHERE cookie = '".addslashes($this->cookie)."'"; return (bool)query($query); *************** *** 154,158 **** function Session() { ! $this->user = new Submitter(); $this->cookie = new Cookie(); } --- 154,158 ---- function Session() { ! $this->user = new UserAccount(); $this->cookie = new Cookie(); } *************** *** 175,185 **** } ! // Update time and IP address now. ! $this->cookie->setIP($remoteAddr); $this->cookie->write(); return true; } ! function attemptLogin($userName, $password, $remoteAddr = "") { // Correct username and password? --- 175,184 ---- } ! // Update cookie timestamp. $this->cookie->write(); return true; } ! function attemptLogin($userName, $password, $remoteAddr) { // Correct username and password? *************** *** 213,226 **** } - function justLoggedIn() - { - $query = "SELECT u.`userName` FROM Cookie c, Submitter u ". - "WHERE c.owner = u.id AND c.`loginDate` > NOW() - ".db_interval(200); - $res = query($query); - $arr = array(); - while($row =& db_fetch_row($res)) - $arr[] = $row[0]; - return $arr; - } } --- 212,215 ---- Index: test.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/test.phtml,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** test.phtml 12 Sep 2002 11:45:26 -0000 1.48 --- test.phtml 16 Sep 2002 14:20:57 -0000 1.49 *************** *** 26,33 **** header("content-type: text/plain"); ! echo "old PHP_SELF: $_SERVER[PHP_SELF]\n"; ! require_once("init.inc.php"); - echo "new PHP_SELF: $PHP_SELF\n"; /*echo "Testing db...\n"; --- 26,52 ---- header("content-type: text/plain"); ! function foo($s1, $s2) ! { ! for($sub = 0; $sub < 3; $sub++) ! { ! sscanf(substr($s1, $sub * 6, 6), "%x", $a); ! sscanf(substr($s2, $sub * 6, 6), "%x", $b); ! if($a & $b) return 1; ! } ! return 0; ! } ! ! for($p = 3; $p < 32; $p += 4) ! { ! $s = sprintf("%x", 1 << $p); ! $s = "$s$s"; ! echo "$s / 192 : ".foo($s, "300")."\n"; ! echo "$s / 8.. : ".foo($s, "80000000")."\n"; ! echo "$s / max : ".foo($s, "ffffffff")."\n"; ! } ! ! ! //require_once("init.inc.php"); /*echo "Testing db...\n"; Index: user.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/user.inc.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** user.inc.php 11 Sep 2002 09:02:50 -0000 1.11 --- user.inc.php 16 Sep 2002 14:20:57 -0000 1.12 *************** *** 25,107 **** // require_once("db.inc.php"); ! define("CLEN_SUBMITTER_USERNAME", 40); ! define("CLEN_SUBMITTER_NAME", 40); ! define("CLEN_SUBMITTER_EMAIL", 80); ! define("CLEN_SUBMITTER_ADDRESS", 255); ! define("CLEN_SUBMITTER_PHONE", 60); ! define("CLEN_SUBMITTER_FAX", 60); [...689 lines suppressed...] ! $query = "SELECT ug.*, ua.*, ". ! "(ug.`accessMask` & (".BUA_SUPERUSER.")) AS `superUser` ". ! "FROM UserGroup ug, UserAccount ua ". ! "WHERE ug.id = ua.`userGroup` ".$search->getWhere()." ". ! $search->getExtraWhere()." $ob ".$search->makeLimit(); $arr = array(); $res = query($query); + $now = strtotime(now()); while($row =& db_fetch_assoc($res)) { ! $row["daysLeft"] = (strtotime($row["activeUntil"]) - $now) / 86400; $arr[] = $row; } return $arr; } + } |