/** * Scan all directory checking permissions * @param Zend_Config $options * @param Zend_Controller_Action $controller * @return X_Page_ItemList_Message */ public function getTestItems(Zend_Config $options, Zend_Controller_Action $controller) { $dirs = array('application', 'data', 'library', 'public', 'languages'); $tests = new X_Page_ItemList_Test(); $test = new X_Page_Item_Test($this->getId(), '[PluginInstaller] Checking for directory permissions'); $test->setType(X_Page_Item_Message::TYPE_INFO); try { foreach ($dirs as $dir) { // if there is a write problem, an exception is raised $this->_checkWritable(APPLICATION_PATH . '/../' . $dir); } $test->setReason('OK'); } catch (Exception $e) { $test->setType(X_Page_Item_Message::TYPE_FATAL); $test->setReason($e->getMessage()); } $tests->append($test); return $tests; }
private function _check($name, $test, $success = 'Success', $failure = 'Failure') { //return array($name, $test, ( ($test === true || $test === null) ? $success : $failure)); $t = new X_Page_Item_Test($name, $name); if (is_bool($test)) { if ($test) { $t->setType(X_Page_Item_Test::TYPE_SUCCESS); $t->setReason($success); } else { $t->setType(X_Page_Item_Test::TYPE_ERROR); $t->setReason($failure); } } else { $t->setType($test); $t->setReason($success); } return $t; }
/** * animeftw tests: * - check for username & password * - check for data/animeftw/ path writable * @param Zend_Config $options * @param Zend_Controller_Action $controller * @return X_Page_ItemList_Message */ public function getTestItems(Zend_Config $options, Zend_Controller_Action $controller) { $tests = new X_Page_ItemList_Test(); $test = new X_Page_Item_Test($this->getId() . '-writeaccess', '[AnimeFTW] Checking for write access to /data/animeftw/ folder'); if (is_writable(APPLICATION_PATH . '/../data/animeftw/')) { $test->setType(X_Page_Item_Message::TYPE_INFO); $test->setReason('Write access granted'); } else { $test->setType(X_Page_Item_Message::TYPE_WARNING); $test->setReason("CookieJar file can't be stored, items fetch will be really slow"); } $tests->append($test); $test = new X_Page_Item_Test($this->getId() . '-credentials', '[AnimeFTW] Checking for authentication credentials'); if ($this->config('auth.username', '') != '' && $this->config('auth.password', '') != '') { $test->setType(X_Page_Item_Message::TYPE_INFO); $test->setReason('Credentials configurated'); } else { $test->setType(X_Page_Item_Message::TYPE_FATAL); $test->setReason("Credentials not configurated. Contents cannot be viewed"); } $tests->append($test); return $tests; }