/** * Custom install method * @param boolean True if installing from directory */ function install($p_fromdir = null) { josSpoofCheck(); global $mosConfig_absolute_path, $database; if (!$this->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', 'Não existem arquivos definidos como Plugin') === 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, 'Erro SQL: ' . $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, 'Erro SQL: ' . $row->getError()); return false; } } else { $this->setError(1, 'O plugin "' . $this->elementName() . '" já existe!'); return false; } if ($e =& $mosinstall->getElementsByPath('description', 1)) { $this->setError(0, $this->elementName() . '<p>' . $e->getText() . '</p>'); } return $this->copySetupFile('front'); }
/** * Custom install method * @param boolean True if installing from directory */ function install($p_fromdir = null) { global $mosConfig_absolute_path, $database; if (!$this->preInstallCheck($p_fromdir, 'mambot')) { return false; } $xml = $this->xmlDoc(); $mosinstall =& $xml->documentElement; // Set some vars $e =& $xml->getElementsByPath('name', 1); $this->elementName($e->getText()); $folder = $mosinstall->getAttribute('group'); $this->elementDir(mosPathName($mosConfig_absolute_path . '/mambots/' . $folder)); //if(!file_exists($this->elementDir()) && !mkdir($this->elementDir(),0777)) { if (!file_exists($this->elementDir()) && !mkdir($this->elementDir(), 0777)) { $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 in module in DB $database->setQuery("SELECT id FROM #__mambots WHERE element = '" . $this->elementName() . "'"); 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 (!$row->store()) { $this->setError(1, 'SQL error: ' . $row->getError()); return false; } } else { $this->setError(1, 'Mambot "' . $this->elementName() . '" already exists!'); return false; } if ($e =& $xml->getElementsByPath('description', 1)) { $this->setError(0, $this->elementName() . '<p>' . $e->getText() . '</p>'); } return $this->copySetupFile('front'); }
/** * changes the access level of a record * @param integer The increment to reorder by */ function accessMenu($uid, $access, $option, $client) { global $database; switch ($access) { case 'accesspublic': $access = 0; break; case 'accessregistered': $access = 1; break; case 'accessspecial': $access = 2; break; } $row = new mosMambot($database); $row->load($uid); $row->access = $access; if (!$row->check()) { return $row->getError(); } if (!$row->store()) { return $row->getError(); } mosRedirect('index2.php?option=' . $option); }