diff --git a/CHANGELOG.md b/CHANGELOG.md index 6606d671f..711dc8dc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,13 @@ This file documents all notable changes made to ITFlow. ### Upgrading to 26.12.6 -Update from Maintenance > Update as usual. This release has two database changes: 4.4.4 adds the settings for Warranty Lookup, and 4.4.5 puts the email and phone links back in Knowledge Base articles and documents written in Markdown. +Update from Maintenance > Update as usual. This release has three database changes: 4.4.4 adds the settings for Warranty Lookup, 4.4.5 puts the email and phone links back in Knowledge Base articles and documents written in Markdown, and 4.4.6 adds the Vendors permission to roles. - If you have switched a module off in Admin > Settings > Modules - IT documentation, ticketing, invoicing and accounting or any of the others - check that you meant it before updating. Its pages, bookmarks to them and links in old emails stop opening, and the nightly run stops doing its work: with ticketing off, no recurring tickets are raised and resolved tickets aren't closed; with invoicing and accounting off, no recurring invoices or expenses are made, no autopay is charged and no payment reminders go out; with IT documentation off, no domain, certificate, warranty or service review notifications, and shared links - logins, files, documents and IT documentation exports sent to clients - don't open. Switch it back on and the next run picks up what is due, and shared links that haven't run out open again. - API keys get a 403 saying which module is off for anything of a module that is switched off - tickets with ticketing off, assets and credentials with IT documentation off, invoices with invoicing off. - Contacts imported before with a ? in place of an accented letter keep it. Import the same file again with **A contact already here** set to **Update it** and their names are put right - contacts are matched by email. Anything else imported that way, such as a location or vendor, is matched by its name, so correct those by hand. - The warranty lookup button shows beside **Warranty expires** on the asset form straight after the update, as Lenovo needs no key and is switched on. It only asks Lenovo when someone clicks it. Switch Lenovo off in Admin > Warranty Lookup if you'd rather ITFlow didn't ask Lenovo's support site at all. +- Roles have a new **Vendors** permission, for your own vendors. The update gives each role what it had - **Read**, or its **Financial** level where that is higher - so nobody gains or loses anything until you change it in Admin > Roles. - A `.md` file uploaded to a client's Files now becomes a document you can edit. To upload one as a file, as before, turn on **Keep them as files** in the Upload window. **Import Markdown Files** has gone from the Upload menu - Upload does it. ### New Features & Updates @@ -26,6 +27,7 @@ Update from Maintenance > Update as usual. This release has two database changes - Upload a `.md` file and it becomes a document written in Markdown, that you can edit, in the folder it goes into - with **Upload** or by dropping it on the list, no import step. Upload the pictures it uses with it - pick them together, or upload the folder they're in - and they go into the document, found where its links say or by their name; a picture no file uses uploads as a file. A zip of Markdown pages, such as an export from Notion, Obsidian or Confluence, is opened in the Upload window and brought in as the folder it holds: each page a document in its folder with its pictures, its other files uploaded beside them, and Notion's IDs taken off the names. Afterwards ITFlow says which pictures a file uses that weren't uploaded with it, to add in the editor. The Upload window says what will become a document, and **Keep them as files** uploads the `.md` files as they are and a zip as a zip. - A `.md` already in Files shows as it reads in its preview and quick look, with its pictures that are in the client's files, and **Make it a document**, in its menu and quick look, makes it a document: the pictures it uses are copied in, and the document takes the file's place and its links. - Copy a Knowledge Base article's link from its **⋮** menu, on its page or beside it in the list - to send it to someone, or to link to it from another article. It offers the links that suit who can read it: **Copy Public Link** for an article for anyone, **Copy Portal Link** for one in the client portal, and **Copy Link** to its page here for one for agents only. A link that won't open yet is greyed out with the reason under it, such as **Publish it first** or **The public help center is off**. Agents who can read articles but not edit them get the menu with these links too. +- A **Vendors** permission in Admin > Roles, for your own vendors - the ones with no client: suppliers, distributors, the colo - at **None**, **Read**, **Modify** or **Full**. Set a role to **None** to keep its agents out of your suppliers' numbers, accounts and contacts: **Vendors** in the menu opens your clients' vendors instead, your own vendors' pages and their export are refused, search leaves them out, and where a client's license, network, ticket or service names one of yours, they see only its name. A client's vendors stay with the **Clients** permission. Adding, editing and deleting your own vendors moves from **Financial** to **Vendors** too. ### Bug Fixes @@ -34,6 +36,7 @@ Update from Maintenance > Update as usual. This release has two database changes - Connecting Microsoft 365 for mail works with an app that has only Microsoft Graph's permissions, and where your users can't approve apps. Connect asked Microsoft for Exchange's SMTP and IMAP permissions every time and forced the consent screen, so an app with only Graph's Mail.Send and Mail.ReadWrite couldn't connect, and a mailbox account that isn't allowed to approve apps was stopped at "Need admin approval" even after an admin had granted consent. On the OAuth tab, **The app has**, above **Connect Microsoft 365**, says which permissions you gave the app, and Connect asks for just those - Microsoft asks which account to sign in as instead. Coming back, ITFlow says how email now goes, or what the app is missing. **Test OAuth Token Refresh** no longer fails an app with only Graph's permissions: it checks Graph first, and SMTP and IMAP only for what Graph can't do. - A card is saved once per client, however often it's entered. A client who set up autopay on two recurring invoices with the same card - or added it again in the portal - ended up with the card saved twice, once for each, as Stripe gives the card a new reference each time it's entered. ITFlow now knows the same card when it comes back: the one saved card is kept, with the details just entered, and every recurring invoice it pays carries on with it. A card that is already saved twice is merged into one overnight - the copy that runs out last is kept and the autopay on the others moves to it - so you don't need to do anything, and its client isn't sent two expiry reminders for it. - Email and phone links work in Knowledge Base articles and documents - a `mailto:` or `tel:` link showed as plain text on the published article, in the client portal and on the document, while the editor still had it. Those in an article or document written in Markdown were taken out when it was saved; the database update puts them back in the ones already saved, so they don't need saving again. Email and phone links in ticket replies, such as those in an email signature, work too. +- Opening one of your own vendors from a client's license or service works - it said there was nothing to see. ### Developer Updates @@ -51,6 +54,7 @@ Update from Maintenance > Update as usual. This release has two database changes - `js/zip_reader.js` - `window.itflowZip.list(file)` reads a zip's central directory, `.unpack(file, entry)` takes a file out, inflating with `DecompressionStream('deflate-raw')`; no zip64 or encrypted entries. The upload window sends a zip with Markdown pages as the folder it holds, through the folder upload, so PHP's zip extension isn't needed. Make it a document: `agent/modals/file/file_make_document.php`, `make_file_document`, `markdownFileMakeDocument()`. `get_file_markdown` (`agent/ajax.php`) and `fileMarkdownPreviewHtml()` render an uploaded .md - its pictures in Files as `file.php` links - for the grid previewer (`kind: 'markdown'`) and the file quick look. `agent/modals/document/document_import_markdown.php` and `import_markdown_documents` are removed. `fileUploadExtensions()` takes `.markdown`, and `fileTypeInfo()` calls `.md` Markdown. - `purifierUriSchemes()` (`functions/sanitize.php`) is the one list of address schemes HTMLPurifier lets through - `http`, `https`, `mailto`, `tel` and `data` - for `documentHtmlPurify()` and the ticket views (`agent/ticket.php`, `agent/modals/ticket/ticket.php`, `client/ticket.php`, `guest/guest_view_ticket.php`, `guest/guest_approve_ticket_task.php`), each of which set `http`/`https`/`data` only. HTMLPurifier still checks each: a `mailto:` must be an address, a `tel:` is cut down to its digits, and `javascript:`, `vbscript:`, `file:` and the rest go. Database 4.4.5 makes `document_content` and `kb_article_content` (with their `_raw` search text) again from the Markdown of those with `mailto:` or `tel:` in it, keeping `_updated_at`; it stops, to be run again, if the process still has the functions from before it. - `kbCopyLinks($row)` (`functions/kb.php`) gives an article's links for its readers - `[label, icon, url, why not, what it is]`, from `kbPublicUrl()`, `kbPortalArticleUrl()` and the new `kbAgentArticleUrl()` - with why one won't open yet (a draft, `kbPublicOn()` or `moduleOn('portal')` off); `kbCopyLinksMenuHtml()` makes them `.clipboardjs` dropdown items, or disabled ones with the reason in `.itflow-dropdown-why`. `agent/kb_article.php` and the rows of `agent/kb.php` show their ⋮ menu for `kbCan(1)` as well as `kbCan(2)` - with only these items for those who can't edit. +- Vendors permission: `module_vendor` (database 4.4.6, module 9 on a fresh install, `setup/seed_data.php` - Technician Read, Accountant Full); 4.4.6 gives every role `max(1, its module_financial level)`. In `functions/vendor.php`, `vendorPermissionReady()` (4.4.6) switches `vendorModule(0)` from `module_financial` to `module_vendor`, and `vendorCan(0, 1)` from always-yes to the permission; `vendorEnforce(0, $level)` enforces it at every level. `vendorIsOurs($vendor_id)` (one query a page) and `vendorCanOpen($vendor_id)` decide whether a mention of a vendor opens: `vendorLink()` and the new `vendorNameHtml()` show the name without a link, and `vendorRedact($row, $vendor_id)` blanks a row's `vendor_phone`, `vendor_account_number`, `vendor_code`, `vendor_email`, contacts and hours - used by `agent/network.php`, `agent/license.php`, `agent/ticket.php`, `agent/service.php` and the network, license and service quick looks. `vendorLink()` no longer puts a client's id on a page link to one of ours. The ours list (`agent/vendors.php`), its export, the vendor quick look and global search's Vendors group check it; the side nav's Vendors goes to `vendors.php?view=clients` without it. `roleModules()` lists modules in `roleModuleInfo()`'s order, then by id. ## [26.12.5] diff --git a/admin/database_updates/4.4.6.php b/admin/database_updates/4.4.6.php new file mode 100644 index 000000000..f8e9b6292 --- /dev/null +++ b/admin/database_updates/4.4.6.php @@ -0,0 +1,36 @@ + Roles (module_vendor, functions/vendor.php): our own vendors - + * the ones with no client: suppliers, distributors, the colo - to see (Read), change (Modify) and + * delete (Full), so a role can keep technicians out of their numbers, accounts and contacts. A + * client's vendors stay with the Clients permission. + * + * Until now anyone could see ours and Financial changed them, so each role is given that here: + * Read, or its Financial level when that is higher. Nothing changes until an admin lowers it. + * Admins have every permission. + * + * Re-runnable: the permission, and each role's level for it, is added only where it isn't there. + */ + +defined('FROM_DB_UPDATER') || die("Direct file access is not allowed"); + +if (!mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM modules WHERE module_name = 'module_vendor'"))) { + mysqli_query($mysqli, "INSERT INTO modules SET module_name = 'module_vendor', module_description = 'Our own vendors - suppliers, distributors, the colo - with their numbers, accounts and contacts'"); +} +$itflow_vendor_module = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT module_id FROM modules WHERE module_name = 'module_vendor' LIMIT 1"))[0]); +$itflow_financial_module = intval((mysqli_fetch_row(mysqli_query($mysqli, "SELECT module_id FROM modules WHERE module_name = 'module_financial' LIMIT 1")) ?: [0])[0]); + +$itflow_roles = mysqli_query($mysqli, "SELECT role_id, + (SELECT MAX(user_role_permission_level) FROM user_role_permissions WHERE user_role_id = role_id AND module_id = $itflow_financial_module) AS financial, + (SELECT COUNT(*) FROM user_role_permissions WHERE user_role_id = role_id AND module_id = $itflow_vendor_module) AS has_vendor + FROM user_roles"); +while ($itflow_roles && ($itflow_role = mysqli_fetch_assoc($itflow_roles))) { + if (intval($itflow_role['has_vendor']) === 0) { + mysqli_query($mysqli, "INSERT INTO user_role_permissions SET user_role_id = " . intval($itflow_role['role_id']) . ", + module_id = $itflow_vendor_module, user_role_permission_level = " . max(1, min(3, intval($itflow_role['financial'])))); + } +} diff --git a/agent/includes/side_nav.php b/agent/includes/side_nav.php index 54a3b28ed..c5f7e4ca5 100644 --- a/agent/includes/side_nav.php +++ b/agent/includes/side_nav.php @@ -66,12 +66,16 @@ - + + = 1 ? '/agent/vendors.php?view=clients' : ''); ?> + + +