preInstallCheck( $p_fromdir, 'mambot' )) { return false; } $xmlDoc = $this->xmlDoc(); $mosinstall =& $xmlDoc->documentElement; // Set some vars $e = &$mosinstall->getElementsByPath( 'name', 1 ); $this->elementName( $e->getText() ); $folder = $mosinstall->getAttribute( 'group' ); $this->elementDir( mosPathName( $mosConfig_absolute_path . '/mambots/' . $folder ) ); if(!file_exists($this->elementDir()) && !mosMakePath($this->elementDir())) { $this->setError( 1, 'Failed to create directory "' . $this->elementDir() . '"' ); return false; } if ($this->parseFiles( 'files', 'mambot', 'No file is marked as mambot file' ) === false) { return false; } // Insert mambot in DB $query = "SELECT id" . "\n FROM #__mambots" . "\n WHERE element = " . $database->Quote( $this->elementName() ) ; $database->setQuery( $query ); if (!$database->query()) { $this->setError( 1, 'SQL error: ' . $database->stderr( true ) ); return false; } $id = $database->loadResult(); if (!$id) { $row = new mosMambot( $database ); $row->name = $this->elementName(); $row->ordering = 0; $row->folder = $folder; $row->iscore = 0; $row->access = 0; $row->client_id = 0; $row->element = $this->elementSpecial(); if ($folder == 'editors') { $row->published = 1; } if (!$row->store()) { $this->setError( 1, 'SQL error: ' . $row->getError() ); return false; } } else { $this->setError( 1, 'Mambot "' . $this->elementName() . '" already exists!' ); return false; } if ($e = &$mosinstall->getElementsByPath( 'description', 1 )) { $this->setError( 0, $this->elementName() . '
' . $e->getText() . '
' ); } return $this->copySetupFile('front'); } /** * Custom install method * @param int The id of the module * @param string The URL option * @param int The client id */ function uninstall( $id, $option, $client=0 ) { global $database, $mosConfig_absolute_path; josSpoofCheck(null, null, 'request'); $id = intval( $id ); $query = "SELECT name, folder, element, iscore" . "\n FROM #__mambots" . "\n WHERE id = " . (int) $id ; $database->setQuery( $query ); $row = null; $database->loadObject( $row ); if ($database->getErrorNum()) { HTML_installer::showInstallMessage( $database->stderr(), 'Uninstall - error', $this->returnTo( $option, 'mambot', $client ) ); exit(); } if ($row == null) { HTML_installer::showInstallMessage( 'Invalid object id', 'Uninstall - error', $this->returnTo( $option, 'mambot', $client ) ); exit(); } if (trim( $row->folder ) == '') { HTML_installer::showInstallMessage( 'Folder field empty, cannot remove files', 'Uninstall - error', $this->returnTo( $option, 'mambot', $client ) ); exit(); } $basepath = $mosConfig_absolute_path . '/mambots/' . $row->folder . '/'; $xmlfile = $basepath . $row->element . '.xml'; // see if there is an xml install file, must be same name as element if (file_exists( $xmlfile )) { $this->i_xmldoc = new DOMIT_Lite_Document(); $this->i_xmldoc->resolveErrors( true ); if ($this->i_xmldoc->loadXML( $xmlfile, false, true )) { $mosinstall =& $this->i_xmldoc->documentElement; // get the files element $files_element =& $mosinstall->getElementsByPath( 'files', 1 ); if (!is_null( $files_element )) { $files = $files_element->childNodes; foreach ($files as $file) { // delete the files $filename = $file->getText(); if (file_exists( $basepath . $filename )) { $parts = pathinfo( $filename ); $subpath = $parts['dirname']; if ($subpath != '' && $subpath != '.' && $subpath != '..') { echo '