function getAllObjects() { $variableList = array(); $variable = new Variable(); $variable->orderBy('name'); $variable->find(); while ($variable->fetch()) { $variableList[$variable->id] = clone $variable; } return $variableList; }
function getIndexStatus() { // global $serverName; $partialIndexUpToDate = false; $fullIndexUpToDate = false; $overDriveExtractUpToDate = false; $solrRestartUpToDate = false; $notes = array(); $currentTime = time(); // Full Index // $lastFullIndexVariable = new Variable(); $lastFullIndexVariable->name = 'lastFullReindexFinish'; if ($lastFullIndexVariable->find(true)) { //Check to see if the last full index finished more than FULL_INDEX_INTERVAL seconds ago if ($lastFullIndexVariable->value >= $currentTime - self::FULL_INDEX_INTERVAL) { $fullIndexUpToDate = true; } else { $notes[] = 'Full Index last finished ' . date('m-d-Y H:i:s', $lastFullIndexVariable->value) . ' - ' . round(($currentTime - $lastFullIndexVariable->value) / 3600, 2) . ' hours ago'; } } else { $notes[] = 'Full index has never been run'; } // Partial Index // $lastPartialIndexVariable = new Variable(); $lastPartialIndexVariable->name = 'lastPartialReindexFinish'; if ($lastPartialIndexVariable->find(true)) { //Check to see if the last partial index finished more than PARTIAL_INDEX_INTERVAL seconds ago if ($lastPartialIndexVariable->value >= $currentTime - self::PARTIAL_INDEX_INTERVAL) { $partialIndexUpToDate = true; } else { $notes[] = 'Partial Index last finished ' . date('m-d-Y H:i:s', $lastPartialIndexVariable->value) . ' - ' . round(($currentTime - $lastPartialIndexVariable->value) / 60, 2) . ' minutes ago'; } } else { $notes[] = 'Partial index has never been run'; } // OverDrive Extract // $lastOverDriveExtractVariable = new Variable(); $lastOverDriveExtractVariable->name = 'last_overdrive_extract_time'; if ($lastOverDriveExtractVariable->find(true)) { //Check to see if the last partial index finished more than OVERDRIVE_EXTRACT_INTERVAL seconds ago $lastOverDriveExtractTime = $lastOverDriveExtractVariable->value / 1000; if ($lastOverDriveExtractTime >= $currentTime - self::OVERDRIVE_EXTRACT_INTERVAL) { $overDriveExtractUpToDate = true; } else { $notes[] = 'OverDrive Extract last finished ' . date('m-d-Y H:i:s', $lastOverDriveExtractTime) . ' - ' . round(($currentTime - $lastOverDriveExtractTime) / 3600, 2) . ' hours ago'; } } else { $notes[] = 'OverDrive Extract has never been run'; } // Solr Restart // global $configArray; if ($configArray['Index']['engine'] == 'Solr') { $xml = @file_get_contents($configArray['Index']['url'] . '/admin/cores'); if ($xml) { $options = array('parseAttributes' => 'true', 'keyAttribute' => 'name'); $unxml = new XML_Unserializer($options); $unxml->unserialize($xml); $data = $unxml->getUnserializedData(); $uptime = $data['status']['grouped']['uptime']['_content'] / 1000; // Grouped Index, puts uptime into seconds. $uptime2 = $data['status']['grouped2']['uptime']['_content'] / 1000; // Grouped 2 Index, puts uptime into seconds. $solrStartTime = strtotime($data['status']['grouped']['startTime']['_content']); $solrStartTime2 = strtotime($data['status']['grouped2']['startTime']['_content']); if ($uptime < self::SOLR_RESTART_INTERVAL) { // Grouped Index if ($uptime2 < self::SOLR_RESTART_INTERVAL) { // Grouped 2 Index $solrRestartUpToDate = true; } else { $notes[] = 'Solr Index (Grouped2) last restarted ' . date('m-d-Y H:i:s', $solrStartTime) . ' - ' . round($uptime / 3600, 2) . ' hours ago'; } } else { $notes[] = 'Solr Index (Grouped) last restarted ' . date('m-d-Y H:i:s', $solrStartTime2) . ' - ' . round($uptime / 3600, 2) . ' hours ago'; } } // else { // Notice if XML wasn't readable? eg Solr not responding // } } if (!$fullIndexUpToDate || !$partialIndexUpToDate || !$overDriveExtractUpToDate || !$solrRestartUpToDate) { $result = array('result' => false, 'message' => implode('; ', $notes)); } else { $result = array('result' => true, 'message' => "Everything is current"); } return $result; }
function loadUserData() { global $user; global $interface; //Load profile information $catalog = CatalogFactory::getCatalogConnectionInstance(); $profile = $catalog->getMyProfile($user); if (!PEAR_Singleton::isError($profile)) { $interface->assign('profile', $profile); } //Load a list of lists $lists = array(); require_once ROOT_DIR . '/sys/LocalEnrichment/UserList.php'; $tmpList = new UserList(); $tmpList->user_id = $user->id; $tmpList->deleted = 0; $tmpList->orderBy("title ASC"); $tmpList->find(); if ($tmpList->N > 0) { while ($tmpList->fetch()) { $lists[$tmpList->id] = array('name' => $tmpList->title, 'url' => '/MyAccount/MyList/' . $tmpList->id, 'id' => $tmpList->id, 'numTitles' => $tmpList->num_titles()); } } $interface->assign('lists', $lists); // Get My Tags $tagList = $user->getTags(); $interface->assign('tagList', $tagList); if ($user->hasRole('opacAdmin') || $user->hasRole('libraryAdmin') || $user->hasRole('cataloging')) { $variable = new Variable(); $variable->name = 'lastFullReindexFinish'; if ($variable->find(true)) { $interface->assign('lastFullReindexFinish', date('m-d-Y H:i:s', $variable->value)); } else { $interface->assign('lastFullReindexFinish', 'Unknown'); } $variable = new Variable(); $variable->name = 'lastPartialReindexFinish'; if ($variable->find(true)) { $interface->assign('lastPartialReindexFinish', date('m-d-Y H:i:s', $variable->value)); } else { $interface->assign('lastPartialReindexFinish', 'Unknown'); } } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $this->variable->find($id)->delete(); return Redirect::route('variables.index'); }