| @@ 82-98 (lines=17) @@ | ||
| 79 | * |
|
| 80 | * @return array |
|
| 81 | **/ |
|
| 82 | public function getAccountList() |
|
| 83 | { |
|
| 84 | $cache = new HierarchicalSimpleCache($this->getMySQL(), __CLASS__); |
|
| 85 | ||
| 86 | $accounts = $cache->getCache('accounts'); |
|
| 87 | if ($accounts === false) { |
|
| 88 | $accountsResponse = $this->api_get('accounts/1/sub_accounts', [ |
|
| 89 | 'recursive' => 'true' |
|
| 90 | ]); |
|
| 91 | $accounts = array(); |
|
| 92 | foreach ($accountsResponse as $account) { |
|
| 93 | $accounts[$account['id']] = $account; |
|
| 94 | } |
|
| 95 | $cache->setCache('accounts', $accounts, 7 * 24 * 60 * 60); |
|
| 96 | } |
|
| 97 | return $accounts; |
|
| 98 | } |
|
| 99 | ||
| 100 | /** |
|
| 101 | * Get a listing of all terms organized for presentation in a select picker |
|
| @@ 105-122 (lines=18) @@ | ||
| 102 | * |
|
| 103 | * @return array |
|
| 104 | **/ |
|
| 105 | public function getTermList() |
|
| 106 | { |
|
| 107 | $cache = new HierarchicalSimpleCache($this->getMySQL(), __CLASS__); |
|
| 108 | ||
| 109 | $terms = $cache->getCache('terms'); |
|
| 110 | if ($terms === false) { |
|
| 111 | $_terms = $this->api_get('accounts/1/terms', [ |
|
| 112 | 'workflow_state' => 'active' |
|
| 113 | ]); |
|
| 114 | $termsResponse = $_terms['enrollment_terms']; |
|
| 115 | $terms = array(); |
|
| 116 | foreach ($termsResponse as $term) { |
|
| 117 | $terms[$term['id']] = $term; |
|
| 118 | } |
|
| 119 | $cache->setCache('terms', $terms, 7 * 24 * 60 * 60); |
|
| 120 | } |
|
| 121 | return $terms; |
|
| 122 | } |
|
| 123 | ||
| 124 | /** |
|
| 125 | * A standard format for an error message due to an exception |
|