/** * Find Child nodes * @param boolean $show_hidden * @return array * @see caretaker/trunk/classes/nodes/tx_caretaker_AggregatorNode#findChildren() */ protected function findChildren($show_hidden = FALSE) { $node_repository = tx_caretaker_NodeRepository::getInstance(); $root_instancegroups = $node_repository->getInstancegroupsByParentGroupUid(0, $this, $show_hidden); $root_instances = $node_repository->getInstancesByInstancegroupUid(0, $this, $show_hidden); return array_merge($root_instancegroups, $root_instances); }
/** * @see caretaker/trunk/classes/nodes/tx_caretaker_AggregatorNode#findChildren() * @param bool $show_hidden * @return array */ protected function findChildren($show_hidden = FALSE) { $node_repository = tx_caretaker_NodeRepository::getInstance(); $subgroups = $node_repository->getTestgroupsByParentGroupUid($this->uid, $this, $show_hidden); $tests = $node_repository->getTestsByGroupUid($this->uid, $this, $show_hidden); return array_merge($subgroups, $tests); }
/** * @return array */ function getNodes() { $this->pi_initPIflexForm(); $node_ids = $this->pi_getFFValue($this->cObj->data['pi_flexform'], 'node_ids'); // Node ids not specified? Try TypoScript instead if (!$node_ids && $this->conf['node_ids']) { $node_ids = $this->conf['node_ids']; } $nodes = array(); $ids = explode(chr(10), $node_ids); $node_repository = tx_caretaker_NodeRepository::getInstance(); foreach ($ids as $id) { $node = $node_repository->id2node($id); if (!$node) { continue; } if ($this->root_id !== 'root') { // Check if node is in the specified subtree $parent_node = $node; do { // One parent of node should be the subtree root if ($parent_node->getCaretakerNodeId() == $this->root_id) { $nodes[] = $node; } } while ($parent_node = $parent_node->getParent()); } else { $nodes[] = $node; } } return $nodes; }
/** * @return bool */ public function execute() { $node_repository = tx_caretaker_NodeRepository::getInstance(); $node = $node_repository->id2node($this->node_id); if (!$node) { return false; } if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode'] != 'disable') { $lockObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Locking\\Locker', 'tx_caretaker_update_' . $node->getCaretakerNodeId(), $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']); // no output during scheduler runs tx_caretaker_ServiceHelper::unregisterCaretakerNotificationService('CliNotificationService'); if ($lockObj->acquire()) { $node->updateTestResult(); $lockObj->release(); } else { return false; } } else { $node->updateTestResult(); } // send aggregated notifications $notificationServices = tx_caretaker_ServiceHelper::getAllCaretakerNotificationServices(); /** @var tx_caretaker_AbstractNotificationService $notificationService */ foreach ($notificationServices as $notificationService) { $notificationService->sendNotifications(); } return true; }
/** * @return tx_caretaker_AbstractNode */ function getNode() { $id = $this->piVars['id']; $node_repository = tx_caretaker_NodeRepository::getInstance(); if ($id) { $node = $node_repository->id2node($id); } else { $this->pi_initPIflexForm(); $node_id = $this->pi_getFFValue($this->cObj->data['pi_flexform'], 'node_id'); // Node id not specified? Try TypoScript instead if (!$node_id && $this->conf['node_id']) { $node_id = $this->conf['node_id']; } $node = $node_repository->id2node($node_id); } if ($this->root_id !== 'root') { // Check if node is in the specified subtree $parent_node = $node; do { // One parent of node should be the subtree root if ($parent_node->getCaretakerNodeId() == $this->root_id) { return $node; } } while ($parent_node = $parent_node->getParent()); return false; } else { return $node; } }
/** * @return tx_caretaker_AggregatorNode */ private function getRequestedNode($nodeId) { $node = false; if ($nodeId) { $node_repository = tx_caretaker_NodeRepository::getInstance(); $node = $node_repository->id2node($nodeId, false); } return $node; }
/** * @return tx_caretaker_AbstractNode */ function getNode() { $id = $this->piVars['id']; $node_repository = tx_caretaker_NodeRepository::getInstance(); if ($id) { $node = $node_repository->id2node($id); } else { $this->pi_initPIflexForm(); $node_id = $this->pi_getFFValue($this->cObj->data['pi_flexform'], 'node_id'); $node = $node_repository->id2node($node_id); } return $node; }
function getNodes() { $this->pi_initPIflexForm(); $node_ids = $this->pi_getFFValue($this->cObj->data['pi_flexform'], 'node_ids'); $nodes = array(); $ids = explode(chr(10), $node_ids); $node_repository = tx_caretaker_NodeRepository::getInstance(); foreach ($ids as $id) { $node = $node_repository->id2node($id); if ($node) { $nodes[] = $node; } } return $nodes; }
/** * @param array $params * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj */ public function ajaxLoadTree($params, &$ajaxObj) { $node_id = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('node'); if ($node_id == 'root') { $node_repository = tx_caretaker_NodeRepository::getInstance(); $node = $node_repository->getRootNode(true); $result = $this->nodeToArray($node, 2); } else { $node_repository = tx_caretaker_NodeRepository::getInstance(); $node = $node_repository->id2node($node_id, 1); $result = $this->nodeToArray($node); } $ajaxObj->setContent($result['children']); $ajaxObj->setContentFormat('jsonbody'); }
public function execute() { $node_repository = tx_caretaker_NodeRepository::getInstance(); $node = $node_repository->id2node($this->node_id); if (!$node) { return false; } $lockObj = t3lib_div::makeInstance('t3lib_lock', 'tx_caretaker_update_' . $node->getCaretakerNodeId(), $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']); // no output during scheduler runs tx_caretaker_ServiceHelper::unregisterCaretakerNotificationService('CliNotificationService'); if ($lockObj->acquire()) { $node->updateTestResult(); $lockObj->release(); } else { return false; } // send aggregated notifications $notificationServices = tx_caretaker_ServiceHelper::getAllCaretakerNotificationServices(); foreach ($notificationServices as $notificationService) { $notificationService->sendNotifications(); } $success = true; return $success; }
/** * @param array $argv */ public function cli_main($argv) { $task = (string) $this->cli_args['_DEFAULT'][1]; if (!$task) { $this->cli_validateArgs(); $this->cli_help(); exit; } if ($task == 'update' || $task == 'get' || $task == 'ack' || $task == 'due') { $force = (bool) $this->readArgument('--force', '-f'); $return_status = (bool) $this->readArgument('-r'); $options = array('forceUpdate' => $force); $options = array_merge($options, $this->parseOptions($this->readArgument('--options', '-o'))); $node = FALSE; $node_repository = tx_caretaker_NodeRepository::getInstance(); $nodeId = $this->readArgument('--node', '-N'); if ((bool) $this->readArgument('--root', '-R')) { $node = $node_repository->getRootNode(); } else { if ($nodeId) { $node = $node_repository->id2node($nodeId); } } if ($node) { $this->cli_echo('node ' . $node->getCaretakerNodeId() . chr(10)); $result = FALSE; if ($task == 'update' || $task == 'ack' || $task == 'due') { try { $lockObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Locking\\Locker', 'tx_caretaker_update_' . $node->getCaretakerNodeId(), $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']); $lockIsAquired = $lockObj->acquire(); } catch (Exception $e) { $this->cli_echo('lock ' . 'tx_caretaker_update_' . $node->getCaretakerNodeId() . ' could not be aquired!' . chr(10) . $e->getMessage()); exit; } if ($lockIsAquired) { if ($task == 'update') { $result = $node->updateTestResult($options); } else { if ($task == 'ack' && is_a($node, 'tx_caretaker_TestNode')) { $result = $node->setModeAck(); } else { if ($task == 'due' && is_a($node, 'tx_caretaker_TestNode')) { $result = $node->setModeDue(); } } } $lockObj->release(); } else { $result = false; $this->cli_echo('node ' . $node->getCaretakerNodeId() . ' is locked because of other running update processes!' . chr(10)); exit; } } if ($task == 'get') { $result = $node->getTestResult(); $this->cli_echo($node->getTitle() . ' [' . $node->getCaretakerNodeId() . ']' . chr(10)); $this->cli_echo($result->getLocallizedStateInfo() . ' [' . $node->getCaretakerNodeId() . ']' . chr(10)); } // send aggregated notifications $notificationServices = tx_caretaker_ServiceHelper::getAllCaretakerNotificationServices(); /** @var tx_caretaker_NotificationBaseExitPoint $notificationService */ foreach ($notificationServices as $notificationService) { $notificationService->sendNotifications(); } if ($return_status) { exit((int) $result->getState()); } else { exit; } } else { $this->cli_echo('Node not found or inactive' . chr(10)); exit; } } elseif ($task == 'update-typo3-latest-version-list') { $result = tx_caretaker_LatestVersionsHelper::updateLatestTypo3VersionRegistry(); $this->cli_echo('TYPO3 latest version list update result: ' . $result . chr(10)); $versions = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry')->get('tx_caretaker', 'TYPO3versions'); foreach ($versions as $key => $version) { $this->cli_echo($key . ' => ' . $version . chr(10)); } } if ($task == 'help') { $this->cli_validateArgs(); $this->cli_help(); exit; } }
/** * Main function of the module. Write the content to $this->content * If you chose "web" as main module, you will need to consider the $this->id parameter which will contain the uid-number of the page clicked in the page tree * * @return void */ function main() { global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS; $PATH_TYPO3 = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/'; if ($BE_USER->user["admin"]) { // find node $node_repository = tx_caretaker_NodeRepository::getInstance(); $node = $node_repository->id2node($this->node_id, true); if (!$node) { $node = $node_repository->getRootNode(); } // Draw the header. $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); $this->doc->backPath = $BACK_PATH; $this->pageRenderer = $this->doc->getPageRenderer(); // Include Ext JS $this->pageRenderer->loadExtJS(); $this->pageRenderer->addJsFile($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.js'); $panels = array(); foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['caretaker']['extJsBackendPanels'] as $extJsBackendPanel) { // register JS foreach ($extJsBackendPanel['jsIncludes'] as $jsInclude) { $filename = $BACK_PATH . '../' . str_replace(PATH_site, '', \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($jsInclude)); $this->pageRenderer->addJsFile($filename); } // register CSS foreach ($extJsBackendPanel['cssIncludes'] as $cssInclude) { $filename = $BACK_PATH . '../' . str_replace(PATH_site, '', \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($cssInclude)); $this->pageRenderer->addCssFile($filename); } // add ExtJs Panel $panels[$extJsBackendPanel['id']] = $extJsBackendPanel['xtype']; } $this->pageRenderer->addJsFile($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.NodeToolbar.js'); // Enable debug mode for Ext JS $this->pageRenderer->enableExtJsDebug(); // storage Pid $confArray = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['caretaker']); $storagePid = (int) $confArray['storagePid']; //Add caretaker css $this->pageRenderer->addCssFile($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/css/tx.caretaker.overview.css'); $pluginItems = array(); foreach ($panels as $id => $xtype) { $pluginItems[] = '{ id: "' . $id . '", xtype: "' . $xtype . '" , back_path: back_path , node_id: node_id }'; } $this->pageRenderer->addJsInlineCode('Caretaker_Overview', ' Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); Ext.namespace("tx","tx.caretaker"); Ext.onReady( function() { var back_path = "' . $this->doc->backPath . '"; var back_url = "' . urlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')) . '"; var path_typo3 = "' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/"; var add_url = "' . $PATH_TYPO3 . 'alt_doc.php?edit[###NODE_TYPE###][' . $storagePid . ']=new"; var node_id = "' . $node->getCaretakerNodeId() . '"; var node_type = "' . strtolower($node->getType()) . '"; var node_hidden = "' . $node->getHidden() . '"; var node_uid = "' . $node->getUid() . '"; var node_title = "' . htmlspecialchars($node->getTitle() ? $node->getTitle() : '[no title]') . '( ' . ($node->getTypeDescription() ? htmlspecialchars($node->getTypeDescription()) : $node->getType()) . ' )" ; var node_state = "' . $node->getTestResult()->getState() . '" ; var node_state_info = "' . $node->getTestResult()->getStateInfo() . '" ; tx.caretaker.view = new Ext.Viewport({ layout: "fit", items: { xtype : "panel", id : "node", autoScroll: true, title : node_title, iconCls : "icon-caretaker-type-" + node_type, tbar : { xtype: "caretaker-nodetoolbar", back_path: back_path, path_typo3: path_typo3, back_url: back_url, add_url :add_url, node_id: node_id, node_type: node_type, node_uid: node_uid, node_hidden: node_hidden, node_state: node_state, node_state_info: node_state_info }, items : [ { xtype : "panel", padding : "10", layout : "fit", id : "caretaker-panels", items : [ ' . implode(chr(10) . ',', $pluginItems) . chr(10) . ' ] } ], } }); }); '); $this->content .= $this->doc->startPage($LANG->getLL("title")); $this->doc->form = ''; } else { // If no access or if not admin $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\MediumDocumentTemplate'); $this->doc->backPath = $BACK_PATH; $this->content .= $this->doc->startPage($LANG->getLL("title")); $this->content .= $this->doc->header($LANG->getLL("title")); $this->content .= $this->doc->spacer(5); $this->content .= $this->doc->spacer(10); } }
/** * Find Child nodes * @param boolean $show_hidden * @return array * @see tx_caretaker_AggregatorNode#findChildren() */ public function findChildren($show_hidden = false) { $node_repository = tx_caretaker_NodeRepository::getInstance(); $testgroups = $node_repository->getTestgroupsByInstanceUid($this->uid, $this, $show_hidden); $tests = $node_repository->getTestsByInstanceUid($this->uid, $this, $show_hidden); return array_merge($testgroups, $tests); }
/** * Get the contacts for the given node for AJAX * * @param array $params * @param TYPO3AJAX $ajaxObj */ public function ajaxGetNodeContacts($params, &$ajaxObj) { $node_id = t3lib_div::_GP('node'); $node_repository = tx_caretaker_NodeRepository::getInstance(); if ($node_id && ($node = $node_repository->id2node($node_id, true))) { $count = 0; $contacts = array(); $nodeContacts = $node->getContacts(); foreach ($nodeContacts as $nodeContact) { if ($role = $nodeContact->getRole()) { $role_assoc = array('uid' => $role->getUid(), 'id' => $role->getId(), 'name' => $role->getTitle(), 'description' => $role->getDescription()); } else { $role_assoc = array('uid' => '', 'id' => '', 'name' => '', 'description' => ''); } $address = $nodeContact->getAddress(); if ($address) { $address['email_md5'] = md5($address['email']); } $contact = array('num' => $count++, 'id' => $node->getCaretakerNodeId() . '_role_' . $role_assoc['uid'] . '_address_' . $address['uid'], 'node_title' => $node->getTitle(), 'node_type' => $node->getType(), 'node_type_ll' => $node->getTypeDescription(), 'node_id' => $node->getCaretakerNodeId(), 'role' => $role_assoc, 'address' => $address); foreach ($address as $key => $value) { $contact['address_' . $key] = $value; } foreach ($role_assoc as $key => $value) { $contact['role_' . $key] = $value; } $contacts[] = $contact; } $content = array(); $content['contacts'] = $contacts; $content['totalCount'] = $count; $ajaxObj->setContent($content); $ajaxObj->setContentFormat('jsonbody'); } }
protected function setUp() { $this->repository = tx_caretaker_NodeRepository::getInstance(); }
/** * Find Parent Node * @return tx_caretaker_AbstractNode */ protected function findParent() { $node_repository = tx_caretaker_NodeRepository::getInstance(); $parent = $node_repository->getInstancegroupByChildGroupUid($this->uid, $this); return $parent; }
/** * Get Singleton Instance * @return tx_caretaker_NodeRepository */ public function getInstance() { if (!self::$instance) { self::$instance = new tx_caretaker_NodeRepository(); } return self::$instance; }