Example #1
0
 /**
  * Remove release
  *
  * @param integer ID of the package
  * @param integer ID of the release
  * @return boolean
  */
 function remove($package, $release)
 {
     global $dbh, $auth_user;
     if (!$auth_user->isAdmin() && !user::maintains($auth_user->handle, $package, 'lead')) {
         return PEAR::raiseError('release::remove: insufficient privileges');
     }
     $success = true;
     // get files that have to be removed
     $query = sprintf("SELECT `fullpath` FROM `files` WHERE `package` = '%s' AND `release` = '%s'", $package, $release);
     $sth = $dbh->query($query);
     while ($row = $sth->fetchRow(DB_FETCHMODE_ASSOC)) {
         if (!@unlink($row['fullpath'])) {
             $success = false;
         }
         $basename = basename($row['fullpath']);
         $basename = substr($basename, 0, -4);
         @unlink(PEAR_TARBALL_DIR . '/' . $basename . '.tar');
     }
     $query = sprintf("DELETE FROM `files` WHERE `package` = '%s' AND `release` = '%s'", $package, $release);
     $sth = $dbh->query($query);
     $pname = package::info($package, 'name');
     $version = $dbh->getOne('SELECT version from releases WHERE package = ? and id = ?', array($package, $release));
     $query = sprintf("DELETE FROM releases WHERE package = '%s' AND id = '%s'", $package, $release);
     $sth = $dbh->query($query);
     $GLOBALS['pear_rest']->saveAllReleasesREST($pname);
     $GLOBALS['pear_rest']->deleteReleaseREST($pname, $version);
     $GLOBALS['pear_rest']->savePackagesCategoryREST(package::info($pname, 'category'));
     if (PEAR::isError($sth)) {
         return false;
     } else {
         return true;
     }
 }
Example #2
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;
 }
Example #3
0
    if (confirm(message)) {
        location = url;
    }
}
// -->
</script>

<?php 
echo '<h1>Edit Package</h1>';
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
    report_error('No package ID specified.');
    response_footer();
    exit;
}
include_once 'pear-database-user.php';
if (!user::maintains($auth_user->handle, $_GET['id'], 'lead') && !user::isAdmin($auth_user->handle) && !user::isQA($auth_user->handle)) {
    report_error('Editing only permitted by package leads, PEAR Admins or PEAR QA');
    response_footer();
    exit;
}
// Update
include_once 'pear-database-package.php';
if (isset($_POST['submit'])) {
    if (!validate_csrf_token($csrf_token_name)) {
        report_error('Invalid token.');
    } elseif (!$_POST['name'] || !$_POST['license'] || !$_POST['summary']) {
        report_error('You have to enter values for name, license and summary!');
    } elseif ($_POST['new_channel'] && !$_POST['new_package'] || $_POST['new_package'] && !$_POST['new_channel']) {
        report_error('You have to enter both channel + package name for packages moved out of PEAR!');
    } else {
        $query = '
Example #4
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);
 }
Example #5
0
 } else {
     $compatible_pxml = false;
     $packagexml = $tar->extractInString('package.xml');
 }
 if ($packagexml === null) {
     $errors[] = 'No package.xml found in this release';
     break;
 }
 include_once 'pear-database-package.php';
 $pacid = package::info($info->getPackage(), 'id');
 if (PEAR::isError($pacid)) {
     $errors[] = $pacid->getMessage();
     break;
 }
 include_once 'pear-database-user.php';
 if (!auth_check('pear.admin') && !auth_check('pear.qa') && !user::maintains($auth_user->handle, $pacid, 'lead')) {
     $errors[] = 'You don\'t have permissions to upload this release.';
     break;
 }
 $license = $info->getLicense();
 if (is_array($license)) {
     $license = $license['_content'];
 }
 $users = array();
 foreach ($info->getMaintainers() as $user) {
     if (!user::exists($user['handle'])) {
         $errors[] = 'Unknown user: '******'handle'];
         continue;
     }
     $users[strtolower($user['handle'])] = array('role' => $user['role'], 'active' => !isset($user['active']) || $user['active'] == 'yes');
 }
Example #6
0
}
// -->
</script>

<?php 
echo "<h1>Edit package</h1>";
if (!isset($_GET['id'])) {
    PEAR::raiseError("No package ID specified.");
    response_footer();
    exit;
}
/**
 * The user has to be either a lead developer of the package or
 * a PEAR administrator.
 */
$lead = user::maintains($auth_user->handle, $_GET['id'], "lead");
$admin = user::isAdmin($auth_user->handle);
if (!$lead && !$admin) {
    PEAR::raiseError("Only the lead maintainer of the package or PEAR\n                      administrators can edit the package.");
    response_footer();
    exit;
}
/** Update */
if (isset($_POST['submit'])) {
    if (!$_POST['name'] || !$_POST['license'] || !$_POST['summary']) {
        PEAR::raiseError("You have to enter values for name, license and summary!");
    }
    $query = 'UPDATE packages SET name = ?, license = ?,
              summary = ?, description = ?, category = ?,
              homepage = ?, cvs_link = ?,
              doc_link = ?, bug_link = ?, unmaintained = ?,
Example #7
0
/**
 * Prints a tabbed navigation bar for the various package pages.
 *
 * @param int    $pacid   the id number of the package being viewed
 * @param string $name    the name of the package being viewed
 * @param string $action  the indicator of the current page view
 *
 * @return void
 */
function print_package_navigation($pacid, $name, $action)
{
    global $auth_user;
    $items = array('Main' => array('url' => '', 'title' => 'Main view'), 'Download' => array('url' => 'download', 'title' => 'Download releases of this package'), 'Documentation' => array('url' => 'docs', 'title' => 'Read the available documentation'), 'Bugs' => array('url' => 'bugs', 'title' => 'View/Report Bugs'), 'Trackbacks' => array('url' => 'trackbacks', 'title' => 'Show Related Sites'));
    if (isset($auth_user) && is_object($auth_user) && (user::maintains($auth_user->handle, $pacid, 'lead') || user::isAdmin($auth_user->handle) || user::isQA($auth_user->handle))) {
        $items['Edit'] = array('url' => '/package-edit.php?id=' . $pacid, 'title' => 'Edit this package');
        $items['Edit Maintainers'] = array('url' => '/admin/package-maintainers.php?pid=' . $pacid, 'title' => 'Edit the maintainers of this package');
    }
    if (isset($auth_user) && is_object($auth_user) && ($auth_user->isAdmin() || $auth_user->isQA())) {
        $items['Delete'] = array('url' => '/package-delete.php?id=' . $pacid, 'title' => 'Delete this package');
    }
    //echo print_tabbed_navigation($nav_items);
    echo '<div id="nav">' . "\n";
    foreach ($items as $title => $item) {
        if (!empty($item['url']) && $item['url'][0] == '/') {
            $url = $item['url'];
        } else {
            $url = '/package/' . htmlspecialchars($name) . '/' . $item['url'];
        }
        $css = $action == $item['url'] ? ' class="current" ' : '';
        echo make_link($url, $title, '', $css, $item['title']);
    }
    echo '</div>' . "\n";
}
Example #8
0
File: bug.php Project: stof/pearweb
}
?>
  <tr id="roadmap">
   <th>Roadmaps: </th>

   <td>
   <?php 
echo implode(', ', $assignedRoadmap);
?>
   </td>
   <th>&nbsp;</th>
   <td>&nbsp;</td>
  </tr>

<?php 
if (!isset($auth_user) || !user::maintains($auth_user->handle, $bug['package_id'], array('developer', 'lead'))) {
    ?>
 <form id="subscribetobug" action="bug.php?id=<?php 
    echo $id;
    ?>
" method="post">
  <tr>
    <th>Subscription</th>
<?php 
    if (isset($auth_user) && $auth_user && $auth_user->registered) {
        $sql = 'SELECT COUNT(bug_id) FROM bugdb_subscribe WHERE email = ? AND bug_id = ?';
        $res = $dbh->getOne($sql, array($auth_user->email, $id));
        if ($res === '0') {
            echo '<td><input type="submit" name="subscribe_to_bug" value="Subscribe" /></td>';
        } else {
            echo '<td><input type="submit" name="unsubscribe_to_bug" value="Unsubscribe" /></td>';
 /**
  * Checks if the current user is allowed to update the maintainer data
  *
  * @access public
  * @param  int  ID of the package
  * @return boolean
  */
 static function mayUpdate($package)
 {
     global $auth_user;
     include_once 'pear-database-user.php';
     if (!$auth_user->isAdmin() && !$auth_user->isQA() && !user::maintains($auth_user->handle, $package, 'lead')) {
         return false;
     }
     return true;
 }
Example #10
0
         }
         $e = maintainer::updateAll($pacid, $users);
         if (PEAR::isError($e)) {
             $errors[] = $e->getMessage();
             break;
         }
         $pear_rest->savePackageMaintainerREST($info->getPackage());
         $file = release::upload($info->getPackage(), $info->getVersion(), $info->getState(), $info->getNotes(), $distfile, md5_file($distfile));
     }
 } else {
     $pacid = package::info($info['package'], 'id');
     if (PEAR::isError($pacid)) {
         $errors[] = $pacid->getMessage();
         break;
     }
     if (!user::isAdmin($auth_user->handle) && !user::maintains($auth_user->handle, $pacid, 'lead')) {
         $errors[] = 'You don\'t have permissions to upload this release.';
         break;
     }
     $e = package::updateInfo($pacid, array('summary' => $info['summary'], 'description' => $info['description'], 'license' => $info['release_license']));
     if (PEAR::isError($e)) {
         $errors[] = $e->getMessage();
         break;
     }
     $users = array();
     foreach ($info['maintainers'] as $user) {
         $users[strtolower($user['handle'])] = array('role' => $user['role'], 'active' => 1);
     }
     $e = maintainer::updateAll($pacid, $users);
     if (PEAR::isError($e)) {
         $errors[] = $e->getMessage();