当前位置: 首页>>代码示例>>PHP>>正文


PHP user::maintains方法代码示例

本文整理汇总了PHP中user::maintains方法的典型用法代码示例。如果您正苦于以下问题:PHP user::maintains方法的具体用法?PHP user::maintains怎么用?PHP user::maintains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在user的用法示例。


在下文中一共展示了user::maintains方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: remove

 /**
  * 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;
     }
 }
开发者ID:ThaDafinser,项目名称:web-pecl,代码行数:40,代码来源:pear-database.php

示例2: remove

 /**
  * 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;
 }
开发者ID:stof,项目名称:pearweb,代码行数:45,代码来源:pear-database-release.php

示例3: report_error

    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 = '
开发者ID:stof,项目名称:pearweb,代码行数:31,代码来源:package-edit.php

示例4: updateInfo

 /**
  * 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);
 }
开发者ID:stof,项目名称:pearweb,代码行数:42,代码来源:pear-database-package.php

示例5: array

 } 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: ' . $user['handle'];
         continue;
     }
     $users[strtolower($user['handle'])] = array('role' => $user['role'], 'active' => !isset($user['active']) || $user['active'] == 'yes');
 }
开发者ID:stof,项目名称:pearweb,代码行数:31,代码来源:release-upload.php

示例6: response_footer

}
// -->
</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 = ?,
开发者ID:phpsource,项目名称:web-pecl,代码行数:31,代码来源:package-edit.php

示例7: print_package_navigation

/**
 * 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";
}
开发者ID:stof,项目名称:pearweb,代码行数:33,代码来源:pear-format-html.php

示例8: implode

}
?>
  <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>';
开发者ID:stof,项目名称:pearweb,代码行数:31,代码来源:bug.php

示例9: mayUpdate

 /**
  * 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;
 }
开发者ID:stof,项目名称:pearweb,代码行数:16,代码来源:pear-database-maintainer.php

示例10: md5_file

         }
         $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();
开发者ID:phpsource,项目名称:web-pecl,代码行数:31,代码来源:release-upload.php


注:本文中的user::maintains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。