7d56cd6635651dfd4c9926d062d92ad7b65a3e80 chmalee Wed Jun 3 14:52:52 2026 -0700 More myVariants changes: make the share to accept a comma-sep list of usernames, allow both the read/edit flag and the usernames setting to be editable after creation. When editing usernames, add a confirmation if the field is left blank that this will make the share viewable/editable by anyone with the link, refs #33808 diff --git src/hg/inc/myVariantsShare.h src/hg/inc/myVariantsShare.h index 9fc2d3cab5d..4d6378834f5 100644 --- src/hg/inc/myVariantsShare.h +++ src/hg/inc/myVariantsShare.h @@ -1,120 +1,137 @@ /* myVariantsShare.h was originally generated by the autoSql program, which also * generated myVariantsShare.c and myVariantsShare.sql. This header links the database and * the RAM representation of objects. */ #ifndef MYVARIANTSSHARE_H #define MYVARIANTSSHARE_H #include "jksql.h" #define MYVARIANTSSHARE_NUM_COLS 9 #define MYVAR_TOKEN_LENGTH 48 extern char *myVariantsShareCommaSepFieldNames; struct myVariantsShare /* A share record linking an owner's myVariants project to a recipient. */ { struct myVariantsShare *next; /* Next in singly linked list. */ unsigned id; /* Auto-increment primary key */ char *ownerUser; /* Owner who created the share */ char *shareToken; /* 48-char URL-safe token */ char *project; /* Project name, or * for all */ char *db; /* Assembly (hg38, mm39, etc.) */ unsigned char permission; /* 0=read-only, 1=read-write */ char *targetUser; /* Specific user, or NULL for anyone with link */ char *label; /* Optional human-readable label */ char *createdAt; /* Timestamp of creation */ }; void myVariantsShareStaticLoad(char **row, struct myVariantsShare *ret); /* Load a row from myVariantsShare table into ret. The contents of ret will * be replaced at the next call to this function. */ struct myVariantsShare *myVariantsShareLoadByQuery(struct sqlConnection *conn, char *query); /* Load all myVariantsShare from table that satisfy the query given. * Where query is of the form 'select * from example where something=something' * or 'select example.* from example, anotherTable where example.something = * anotherTable.something'. * Dispose of this with myVariantsShareFreeList(). */ void myVariantsShareSaveToDb(struct sqlConnection *conn, struct myVariantsShare *el, char *tableName, int updateSize); /* Save myVariantsShare as a row to the table specified by tableName. * As blob fields may be arbitrary size updateSize specifies the approx size * of a string that would contain the entire query. Arrays of native types are * converted to comma separated strings and loaded as such, User defined types are * inserted as NULL. This function automatically escapes quoted strings for mysql. */ struct myVariantsShare *myVariantsShareLoad(char **row); /* Load a myVariantsShare from row fetched with select * from myVariantsShare * from database. Dispose of this with myVariantsShareFree(). */ struct myVariantsShare *myVariantsShareLoadAll(char *fileName); /* Load all myVariantsShare from whitespace-separated file. * Dispose of this with myVariantsShareFreeList(). */ struct myVariantsShare *myVariantsShareLoadAllByChar(char *fileName, char chopper); /* Load all myVariantsShare from chopper separated file. * Dispose of this with myVariantsShareFreeList(). */ #define myVariantsShareLoadAllByTab(a) myVariantsShareLoadAllByChar(a, '\t'); /* Load all myVariantsShare from tab separated file. * Dispose of this with myVariantsShareFreeList(). */ struct myVariantsShare *myVariantsShareCommaIn(char **pS, struct myVariantsShare *ret); /* Create a myVariantsShare out of a comma separated string. * This will fill in ret if non-null, otherwise will * return a new myVariantsShare */ void myVariantsShareFree(struct myVariantsShare **pEl); /* Free a single dynamically allocated myVariantsShare such as created * with myVariantsShareLoad(). */ void myVariantsShareFreeList(struct myVariantsShare **pList); /* Free a list of dynamically allocated myVariantsShare's */ void myVariantsShareOutput(struct myVariantsShare *el, FILE *f, char sep, char lastSep); /* Print out myVariantsShare. Separate fields with sep. Follow last field with lastSep. */ #define myVariantsShareTabOut(el,f) myVariantsShareOutput(el,f,'\t','\n'); /* Print out myVariantsShare as a line in a tab-separated file. */ #define myVariantsShareCommaOut(el,f) myVariantsShareOutput(el,f,',',','); /* Print out myVariantsShare as a comma separated list including final comma. */ /* -------------------------------- End autoSql Generated Code -------------------------------- */ #define MYVAR_PERM_READONLY 0 #define MYVAR_PERM_READWRITE 1 struct myVariantsShare *myVariantsCreateShare(struct sqlConnection *conn, char *ownerUser, char *project, char *db, int permission, char *targetUser, char *label); /* Create a new share record. Returns the share with token and id filled in. * Free with myVariantsShareFree. */ struct myVariantsShare *myVariantsGetShareByToken(struct sqlConnection *conn, char *token); /* Look up a single share by token. Returns NULL if not found. */ struct myVariantsShare *myVariantsGetSharesForOwner(struct sqlConnection *conn, char *ownerUser, char *db); /* Get all shares created by this user for the given assembly. */ struct myVariantsShare *myVariantsGetSharesForUser(struct sqlConnection *conn, char *targetUser, char *db); /* Get all shares targeted at this user for the given assembly. */ boolean myVariantsRevokeShare(struct sqlConnection *conn, char *shareToken, char *ownerUser); /* Delete a share record. ownerUser must match the share's owner. * Returns TRUE if a row was deleted, FALSE if not found or not owner. */ +boolean myVariantsSetSharePermission(struct sqlConnection *conn, + char *shareToken, char *ownerUser, int permission); +/* Update a share's permission (0=read-only, 1=read-write). ownerUser must + * match the share's owner. Returns TRUE if a row was updated, FALSE if not + * found or not owner. */ + +boolean myVariantsSetShareTargets(struct sqlConnection *conn, + char *shareToken, char *ownerUser, char *targetUser); +/* Update a share's targetUser list (NULL for anyone with link). ownerUser + * must match the share's owner. Returns TRUE if a row was updated, FALSE if + * not found or not owner. */ + +boolean myVariantsShareAllowsUser(struct myVariantsShare *share, char *userName); +/* Return TRUE if userName may access share. TRUE when targetUser is empty + * (anyone with link); otherwise TRUE only if userName is non-empty and + * appears in the comma-separated targetUser list. NULL-safe. */ + #define MYVAR_SHARE_CGI_VAR "myVarShare" #define MYVAR_SHARED_CART_PREFIX "myVarShared_" char *myVariantsShareCartValue(struct myVariantsShare *share); /* Build JSON cart value string from a share record. * Caller must freeMem the result. */ #endif /* MYVARIANTSSHARE_H */