static function doesWorkflowHaveUserName($workflow_id, $user_name) { $user_id = Workflow_Users::getUserIDFromName($user_name); return Workflow_Users::doesWorkflowHaveUserID($workflow_id, $user_id); }
function insert_users($workflow_id, $returnJSON) { if (isset($_POST['selected_users']) && $_POST['selected_users'] != '') { $selected_users = trim($_POST['selected_users']); $user_list = explode(',', $selected_users); } else { global $user; $user_list = array($user->name); } $users_to_insert = count($user_list); $users_inserted = 0; $users_excluded = ''; db_query("DELETE FROM {apiary_project_workflow_users} WHERE workflow_id='{$workflow_id}'"); for ($i = 0; $i < count($user_list); $i++) { $user_name = $user_list[$i]; if ($user_name != '') { $user_id = Workflow_Users::getUserIDFromName($user_name); if (db_query("INSERT INTO {apiary_project_workflow_users} (workflow_id, user_id) Values('%s','%s')", $workflow_id, $user_id)) { $users_inserted++; } else { $users_excluded .= $user_name; } } } if ($users_inserted == $users_to_insert) { $returnJSON['workflow_users_successfully_created'] = "true"; $returnJSON['msg'] .= " All users sucessfully set"; } else { $returnJSON['workflow_users_successfully_created'] = "false"; $returnJSON['workflow_users_successfully_entered'] = $users_inserted; $returnJSON['workflow_users_excluded'] = $users_excluded; $returnJSON['msg'] .= ' Not all users sucessfully set, only ' . $users_inserted . ' inserted. Excluded users are ' . $users_excluded . '.'; } return $returnJSON; }