Merge pull request #23690 from totten/master-queue-visibility
[civicrm-core.git] / CRM / Core / BAO / UserJob.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * This class contains user jobs functionality.
20 */
21 class CRM_Core_BAO_UserJob extends CRM_Core_DAO_UserJob {
22
23 /**
24 * Restrict access to the relevant user.
25 *
26 * Note that it is likely we might want to permit other users such as
27 * sysadmins to access other people's user_jobs in future but it has been
28 * kept tightly restricted for initial simplicity (ie do we want to
29 * use an existing permission? a new permission ? do they require
30 * 'view all contacts' etc.
31 *
32 * @inheritDoc
33 */
34 public function addSelectWhereClause(): array {
35 $clauses = [];
36 if (!\CRM_Core_Permission::check('administer queues')) {
37 $clauses['created_id'] = '= ' . (int) CRM_Core_Session::getLoggedInContactID();
38 }
39 CRM_Utils_Hook::selectWhereClause($this, $clauses);
40 return $clauses;
41 }
42
43 /**
44 * Get the statuses for Import Jobs.
45 *
46 * @return array
47 */
48 public static function getStatuses(): array {
49 return [
50 [
51 'id' => 1,
52 'name' => 'completed',
53 'label' => ts('Completed'),
54 ],
55 [
56 'id' => 2,
57 'name' => 'draft',
58 'label' => ts('Draft'),
59 ],
60 [
61 'id' => 3,
62 'name' => 'scheduled',
63 'label' => ts('Scheduled'),
64 ],
65 [
66 'id' => 4,
67 'name' => 'in_progress',
68 'label' => ts('In Progress'),
69 ],
70 ];
71 }
72
73 /**
74 * Get the types Import Jobs.
75 *
76 * This is largely a placeholder at this stage. It will likely wind
77 * up as an option value so extensions can add different types.
78 *
79 * However, for now it just holds the one type being worked on.
80 *
81 * @return array
82 */
83 public static function getTypes(): array {
84 return [
85 [
86 'id' => 1,
87 'name' => 'contact_import',
88 'label' => ts('Contact Import'),
89 ],
90 ];
91 }
92
93 }