Working with users

Previous: Working with roles ] [ Top:  ] [ Next: action: Performing actions with possible deferment ]

The user facilities at this level are very simple: each user element in a datasheet represents one user involved with the process. I'm a tad worried that we'll run into synchronization problems with this (I update my email address, but individual processes I'm involved with don't get the message) but I figure at some point we'll include a user directory pointer in the session, which can be consulted when necessary. I don't know yet.

At any rate, the command-line utility exposes two functions: one lists users, the other lists the attributes of users or sets attributes.

users: list users in a datasheet
 
if (argsleft < 2) {
   printf ("wftk users: repository and ID of the datasheet are required.\n");
   exit (1);
}

datasheet = wftk_process_load (session, PERIOD_TO_NULL(argv[argp]), argv[argp+1]); argp++; argp++;
if (!datasheet) {
   printf ("Datasheet repository %s can't find datasheet %s", argv[argp-2], argv[argp-1]);
   exit (1);
}

list = xml_create ("list");
wftk_user_list (session, datasheet, list);
mark = xml_firstelem (list);
while (mark) {
   printf ("%s ", xml_attrval (mark, "id"));
   if (*xml_attrval (mark, "name")) {
      printf ("(%s) ", xml_attrval (mark, "name"));
   }
   if (*xml_attrval (mark, "email")) {
      printf (": %s", xml_attrval (mark, "email"));
   }
   printf ("\n");
   mark = xml_nextelem (mark);
}


user: display user or set attribute
 
if (argsleft < 3) {
   printf ("wftk user: repository and ID of the datasheet and a userid are all required.\n");
   exit (1);
}

datasheet = wftk_process_load (session, PERIOD_TO_NULL(argv[argp]), argv[argp+1]); argp++; argp++;
if (!datasheet) {
   printf ("Datasheet repository %s can't find datasheet %s", argv[argp-2], argv[argp-1]);
   exit (1);
}

mark = wftk_user_retrieve (session, datasheet, argv[argp++]);
if (argsleft < 1) {
   if (!mark) {
      printf ("User %s apparently not involved with process %s\n", argv[argp-1], argv[argp-2]);
   } else {
      printf ("%s ", xml_attrval (mark, "id"));
      if (*xml_attrval (mark, "name")) {
         printf ("(%s) ", xml_attrval (mark, "name"));
      }
      if (*xml_attrval (mark, "email")) {
         printf (": %s", xml_attrval (mark, "email"));
      }
      printf ("\n");
   }
} else {
   if (argsleft < 2) {
      printf ("wftk user: to set attribute, both attribute and value are required.\n");
   } else {
      xml_set (mark, argv[argp], argv[argp+1]);
      wftk_process_save (session, datasheet);
   }
}
Previous: Working with roles ] [ Top:  ] [ Next: action: Performing actions with possible deferment ]


This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license.