Beispiel #1
0
 static function activate($uid, $karmalevel = 'pear.dev')
 {
     require_once 'Damblan/Karma.php';
     global $dbh, $auth_user;
     $karma = new Damblan_Karma($dbh);
     $user = user::info($uid, null, 0);
     if (!isset($user['registered'])) {
         return false;
     }
     @($arr = unserialize($user['userinfo']));
     include_once 'pear-database-note.php';
     note::removeAll($uid);
     $data = array();
     $data['registered'] = 1;
     $data['active'] = 1;
     /* $data['ppp_only'] = 0; */
     if (is_array($arr)) {
         $data['userinfo'] = $arr[1];
     }
     $data['created'] = gmdate('Y-m-d H:i');
     $data['createdby'] = $auth_user->handle;
     $data['handle'] = $user['handle'];
     user::update($data, true);
     $karma->grant($user['handle'], $karmalevel);
     if ($karma->has($user['handle'], 'pear.dev')) {
         include_once 'pear-rest.php';
         $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
         $pear_rest->saveMaintainerREST($user['handle']);
         $pear_rest->saveAllMaintainersREST();
     }
     include_once 'pear-database-note.php';
     note::add($uid, "Account opened");
     $msg = "Your PEAR account request has been opened.\n" . "To log in, go to http://" . PEAR_CHANNELNAME . "/ and click on \"login\" in\n" . "the top-right menu.\n";
     $xhdr = 'From: ' . $auth_user->handle . '@php.net';
     if (!DEVBOX) {
         mail($user['email'], "Your PEAR Account Request", $msg, $xhdr, '-f ' . PEAR_BOUNCE_EMAIL);
     }
     return true;
 }
 /**
  * Add new maintainer
  *
  * @static
  * @param  mixed  Name of the package or it's ID
  * @param  string Handle of the user
  * @param  string Role of the user
  * @param  integer Is the developer actively working on the project?
  * @return mixed True or PEAR error object
  */
 static function add($package, $user, $role, $active = 1)
 {
     global $dbh;
     include_once 'pear-database-user.php';
     if (!user::exists($user)) {
         throw new InvalidArgumentException("User {$user} does not exist");
     }
     include_once 'pear-database-package.php';
     if (is_string($package)) {
         $package = package::info($package, 'id');
     }
     $sql = 'INSERT INTO maintains (handle, package, role, active) VALUES (?, ?, ?, ?)';
     $err = $dbh->query($sql, array($user, $package, $role, (int) $active));
     if (DB::isError($err)) {
         return $err;
     }
     $packagename = package::info($package, 'name');
     include_once 'pear-rest.php';
     $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
     $pear_rest->savePackageMaintainerREST($packagename);
     return true;
 }
Beispiel #3
0
        $sth = $dbh->query($query, $qparams);
        if (PEAR::isError($sth)) {
            report_error('Unable to save data!');
        } else {
            if (isset($_POST['tags']) && is_array($_POST['tags'])) {
                $manager = new Tags_Manager();
                $manager->clearTags($_POST['name']);
                foreach ($_POST['tags'] as $tag) {
                    if (!$tag) {
                        continue;
                    }
                    $manager->createPackageTag($tag, $_POST['name']);
                }
            }
            include_once 'pear-rest.php';
            $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
            $pear_rest->saveAllPackagesREST();
            $pear_rest->savePackageREST($_POST['name']);
            $pear_rest->savePackagesCategoryREST(package::info($_POST['name'], 'category'));
            report_success('Package information successfully updated.');
        }
    }
} else {
    if (isset($_GET['action'])) {
        switch ($_GET['action']) {
            case 'release_remove':
                if (!isset($_GET['release'])) {
                    report_error('Missing package ID!');
                    break;
                }
                include_once 'pear-database-release.php';
Beispiel #4
0
ob_start();
require_once 'pear-config.php';
require_once 'PEAR.php';
include_once 'pear-rest.php';
if (!isset($pear_rest)) {
    if (isset($_SERVER['argv']) && $_SERVER['argv'][1] == 'pear') {
        $rest_path = '/var/lib/pearweb/rest';
    } else {
        $rest_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'public_html' . DIRECTORY_SEPARATOR . 'rest';
    }
    include_once 'DB.php';
    if (empty($dbh)) {
        $options = array('persistent' => false, 'portability' => DB_PORTABILITY_ALL);
        $dbh =& DB::connect(PEAR_DATABASE_DSN, $options);
    }
    $pear_rest = new pearweb_Channel_REST_Generator($rest_path, $dbh);
}
ob_end_clean();
PEAR::setErrorHandling(PEAR_ERROR_DIE);
require_once 'System.php';
System::rm(array('-r', $rest_path));
System::mkdir(array('-p', $rest_path));
chmod($rest_path, 0777);
echo "Generating Category REST...\n";
include_once 'pear-database-category.php';
foreach (category::listAll() as $category) {
    echo "  {$category['name']}...";
    $pear_rest->saveCategoryREST($category['name']);
    echo "done\n";
}
$pear_rest->saveAllCategoriesREST();
Beispiel #5
0
 /**
  * Remove release
  *
  * @param integer ID of the package
  * @param integer ID of the release
  * @return boolean
  */
 static function remove($package, $release)
 {
     global $dbh, $auth_user;
     include_once 'pear-database-user.php';
     if (!$auth_user->isAdmin() && !$auth_user->isQA() && !user::maintains($auth_user->handle, $package, 'lead')) {
         return PEAR::raiseError('release::remove: insufficient privileges');
     }
     // get files that have to be removed
     $sql = 'SELECT fullpath FROM files WHERE package = ? AND `release` = ?';
     $sth = $dbh->query($sql, array($package, $release));
     // Should we error out if the removal fails ?
     $success = true;
     while ($row = $sth->fetchRow(DB_FETCHMODE_ASSOC)) {
         if (!@unlink($row['fullpath'])) {
             $success = false;
         }
     }
     $sql = 'DELETE FROM files WHERE package = ? AND `release` = ?';
     $sth = $dbh->query($sql, array($package, $release));
     $sql = 'SELECT version from releases WHERE package = ? and id = ?';
     $version = $dbh->getOne($sql, array($package, $release));
     $query = 'DELETE FROM releases WHERE package = ? AND id = ?';
     $sth = $dbh->query($query, array($package, $release));
     // remove statistics on this release
     $dbh->query('DELETE FROM package_stats WHERE pid = ? AND rid = ?', array($package, $release));
     $dbh->query('DELETE FROM aggregated_package_stats WHERE package_id = ? AND release_id = ?', array($package, $release));
     include_once 'pear-database-package.php';
     $pname = package::info($package, 'name');
     include_once 'pear-rest.php';
     $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
     $pear_rest->saveAllReleasesREST($pname);
     $pear_rest->deleteReleaseREST($pname, $version);
     $pear_rest->savePackagesCategoryREST(package::info($pname, 'category'));
     if (PEAR::isError($sth)) {
         return false;
     }
     return true;
 }
Beispiel #6
0
                WHERE p.id = r.package AND r.package = ?';
    $row = $dbh->getAll($query, array($id));
    foreach ($row as $value) {
        $file = sprintf("%s/%s-%s.tgz", PEAR_TARBALL_DIR, $value[0], $value[1]);
        if (@unlink($file)) {
            echo "Deleting release archive \"" . $file . "\"\n";
            $file_rm++;
        } else {
            echo "<font color=\"#ff0000\">Unable to delete file " . $file . "</font>\n";
        }
    }
    echo "\n" . $file_rm . " file(s) deleted\n\n";
    $catid = package::info($id, 'categoryid');
    $packagename = package::info($id, 'name');
    $dbh->query("UPDATE categories SET npackages = npackages - 1 WHERE id = {$catid}");
    foreach ($tables as $table => $field) {
        $query = sprintf("DELETE FROM %s WHERE %s = '%s'", $table, $field, $id);
        echo "Removing package information from table \"" . $table . "\": ";
        $dbh->query($query);
        echo "<b>" . $dbh->affectedRows() . "</b> rows affected.\n";
    }
    include_once 'pear-rest.php';
    $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
    $pear_rest->deletePackageREST($packagename);
    echo "</pre>\nPackage " . $id . " has been deleted.\n";
} else {
    $pkg = package::info($id);
    print_package_navigation($id, $pkg['name'], '/package-delete.php?id=' . $id);
    echo "The package has not been deleted.\n<br /><br />\n";
}
response_footer();
Beispiel #7
0
         }
         $users[strtolower($user['handle'])] = array('role' => $user['role'], 'active' => !isset($user['active']) || $user['active'] == 'yes');
     }
     include_once 'pear-database-maintainer.php';
     $e = maintainer::updateAll($pacid, $users, false, true);
     if (PEAR::isError($e)) {
         $errors[] = $e->getMessage();
         break;
     }
     $e = package::updateInfo($pacid, array('summary' => $info->getSummary(), 'description' => $info->getDescription(), 'license' => $license));
     if (PEAR::isError($e)) {
         $errors[] = $e->getMessage();
         break;
     }
     include_once 'pear-rest.php';
     $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
     $return = $pear_rest->savePackageMaintainerREST($info->getPackage());
     if (PEAR::isError($return)) {
         if (auth_check('pear.admin')) {
             $errors[] = $return->getMessage();
         } else {
             $errors[] = 'There seems to have been a problem with saving the REST files - please inform the webmasters at ' . PEAR_WEBMASTER_EMAIL;
         }
     }
     include_once 'pear-database-release.php';
     $file = release::upload($info->getPackage(), $info->getVersion(), $info->getState(), $info->getNotes(), $distfile, md5_file($distfile), $info, $packagexml, $compatible_pxml);
 }
 if (PEAR::isError($file)) {
     $ui = $file->getUserInfo();
     $errors[] = 'Error while uploading package: ' . $file->getMessage() . ($ui ? " ({$ui})" : '');
     break;
Beispiel #8
0
 /**
  * Updates fields of an existant package
  *
  * @param int $pkgid The package ID to update
  * @param array $data Assoc in the form 'field' => 'value'.
  * @return mixed True or PEAR_Error
  */
 static function updateInfo($pkgid, $data)
 {
     global $dbh, $auth_user;
     $package_id = package::info($pkgid, 'id');
     if (PEAR::isError($package_id) || empty($package_id)) {
         return PEAR::raiseError('Package not registered or not approved. Please register it first with "New Package" or wait until it gets approved.');
     }
     if ($auth_user->isAdmin() === false && $auth_user->isQA() === false) {
         include_once 'pear-database-user.php';
         $role = user::maintains($auth_user->handle, $package_id);
         if ($role != 'lead' && $role != 'developer') {
             return PEAR::raiseError('package::updateInfo: insufficient privileges');
         }
     }
     // XXX (cox) what about 'name'?
     $allowed = array('license', 'summary', 'description', 'category');
     $fields = $prep = array();
     foreach ($allowed as $a) {
         if (isset($data[$a])) {
             $fields[] = "{$a} = ?";
             $prep[] = $data[$a];
         }
     }
     if (!count($fields)) {
         return;
     }
     $sql = 'UPDATE packages SET ' . implode(', ', $fields) . " WHERE id = {$package_id}";
     $row = package::info($pkgid, 'name');
     include_once 'pear-rest.php';
     $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
     $pear_rest->saveAllPackagesREST();
     $pear_rest->savePackageREST($row);
     $pear_rest->savePackagesCategoryREST(package::info($pkgid, 'category'));
     return $dbh->query($sql, $prep);
 }
 /**
  * Deletes a category
  *
  * @param integer $id Cateogry ID
  */
 static function delete($id)
 {
     $name = $GLOBALS['dbh']->getOne('SELECT name FROM categories WHERE id = ?', array($id));
     // Get parent ID if any
     $parentID = $GLOBALS['dbh']->getOne('SELECT parent FROM categories WHERE id = ?', array($id));
     // Delete it
     $deleted_cat_left = $GLOBALS['dbh']->getOne('SELECT cat_left FROM categories WHERE id = ?', array($id));
     $deleted_cat_right = $GLOBALS['dbh']->getOne('SELECT cat_right FROM categories WHERE id = ?', array($id));
     $GLOBALS['dbh']->query('DELETE FROM categories WHERE id = ' . $id);
     // Renumber
     $GLOBALS['dbh']->query('UPDATE categories SET cat_left = cat_left - 1, cat_right = cat_right - 1 WHERE cat_left > ? AND cat_right < ?', array($deleted_cat_left, $deleted_cat_right));
     $GLOBALS['dbh']->query('UPDATE categories SET cat_left = cat_left - 2, cat_right = cat_right - 2 WHERE cat_right > ?', array($deleted_cat_right));
     // Update any child categories
     $GLOBALS['dbh']->query('UPDATE categories SET parent = ? WHERE parent = ?', array($parentID ? $parentID : 'NULL', $id));
     include_once 'pear-rest.php';
     $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $GLOBALS['dbh']);
     $pear_rest->deleteCategoryREST($name);
     $pear_rest->saveAllCategoriesREST();
     return true;
 }
Beispiel #10
0
            break;
        default:
            localRedirect('/admin/category-manager.php');
    }
}
/**
 * Create the menu, set the db to assoc mode
 */
require_once 'HTML/TreeMenu.php';
$treeMenu = new HTML_TreeMenu();
/**
 * Get the categories
 */
parseTree($treeMenu);
/**
 * Template
 */
// Check for any error msg
if (!empty($_SESSION['category_manager']['error_msg'])) {
    $message = $_SESSION['category_manager']['error_msg'];
    unset($_SESSION['category_manager']['error_msg']);
}
$categories = $dbh->getAll('SELECT id, name, description FROM categories ORDER BY id', null, DB_FETCHMODE_ASSOC);
$treeMenuPres = new HTML_TreeMenu_DHTML($treeMenu, array('images' => '../gifs/TreeMenu', 'defaultClass' => 'treeMenuOff'));
include_once 'pear-rest.php';
global $dbh;
$pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
if (!is_writable($pear_rest->getCategoryDirectory())) {
    $message = 'Warning: ' . $pear_rest->getCategoryDirectory() . ' is not writable';
}
include PEARWEB_TEMPLATEDIR . 'category-manager.html';