Exemplo n.º 1
0
 public function import()
 {
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("FruityResourceImporter beginning to import Resources.");
     // Resources
     $res = $this->dbConn->query("SELECT * FROM nagios_resources");
     // Fruity has just one record in the resources, if we get it, import
     // it.
     $row = $res->fetch(PDO::FETCH_ASSOC);
     // Get our resources obj.
     $resourceCfg = NagiosResourcePeer::doSelectOne(new Criteria());
     if (!$resourceCfg) {
         $resourceCfg = new NagiosResource();
         $resourceCfg->save();
     }
     foreach ($row as $key => $val) {
         unset($name);
         if ($key == "id") {
             continue;
         }
         // Iterate through and, if we have a valid key, we set it to
         // the NagiosResource obj.
         try {
             $name = NagiosResourcePeer::translateFieldName($key, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);
         } catch (Exception $e) {
             $job->addNotice("Fruity Resource Importer: Was unable to store unsupported value: " . $key);
         }
         if (!empty($name)) {
             $method = "set" . $name;
             $resourceCfg->{$method}($val);
         }
     }
     $resourceCfg->save();
     // Save resources configuration
     $job->addNotice("FruityResourceImporter finished importing Resources.");
 }
Exemplo n.º 2
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
/*
Lilac Resource
*/
include_once 'includes/config.inc';
require_once 'NagiosResource.php';
$resourceCfg = NagiosResourcePeer::doSelectOne(new Criteria());
if (!$resourceCfg) {
    $resourceCfg = new NagiosResource();
    $resourceCfg->save();
}
if (isset($_POST['request'])) {
    if ($_POST['request'] == 'update') {
        $resourceCfg->setUser1($_POST['resource_config']['user1']);
        $resourceCfg->setUser2($_POST['resource_config']['user2']);
        $resourceCfg->setUser3($_POST['resource_config']['user3']);
        $resourceCfg->setUser4($_POST['resource_config']['user4']);
        $resourceCfg->setUser5($_POST['resource_config']['user5']);
        $resourceCfg->setUser6($_POST['resource_config']['user6']);
        $resourceCfg->setUser7($_POST['resource_config']['user7']);
        $resourceCfg->setUser8($_POST['resource_config']['user8']);
        $resourceCfg->setUser9($_POST['resource_config']['user9']);
        $resourceCfg->setUser10($_POST['resource_config']['user10']);
        $resourceCfg->setUser11($_POST['resource_config']['user11']);
        $resourceCfg->setUser12($_POST['resource_config']['user12']);