Example #1
0
            $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
            $pear_rest->savePackageREST($row['name']);
            $pear_rest->saveAllPackagesREST();
            include_once 'pear-database-package.php';
            $pear_rest->savePackagesCategoryREST(package::info($row['name'], 'category'));
        }
        // {{{ Logging mechanism
        require_once "Damblan/Log.php";
        require_once "Damblan/Log/Mail.php";
        $logger = new Damblan_Log();
        $observer = new Damblan_Log_Mail();
        $observer->setRecipients(PEAR_GROUP_EMAIL);
        $observer->setHeader("In-Reply-To", "<approve-request-" . $row['id'] . "@" . PEAR_CHANNELNAME . ">");
        $observer->setHeader("Subject", "[" . SITE_BIG . " Group] Package " . $row['name'] . " has been " . $action);
        $logger->attach($observer);
        $logger->log($auth_user->handle . " " . $action . " " . $row['name']);
        // }}}
        if (!DEVBOX) {
            $mailtext = 'Your package "' . $row['name'] . '" has been ' . $action . ' by the PEAR Group.';
            $mailtext = wordwrap($mailtext, 72);
            $query = 'SELECT u.email FROM users u, maintains m WHERE m.package = ? AND u.handle = m.handle';
            $rows = $dbh->getAll($query, array($id), DB_FETCHMODE_ASSOC);
            foreach ($rows as $u_row) {
                mail($u_row['email'], SITE_BIG . ' Package ' . $action, $mailtext, 'From: "' . SITE_BIG . ' Package Approval System" <' . PEAR_GROUP_EMAIL . '>', '-f ' . PEAR_BOUNCE_EMAIL);
            }
        }
        echo "Successfully <b>" . $action . " package</b>.<br /><br />";
    } else {
        echo "There have been problems: Either an error occured while " . "updating the database or the package has already been " . $action . " by someone else.<br /><br />";
    }
}
Example #2
0
 /**
  * Add new package
  *
  * @param array
  * @return mixed ID of new package or PEAR error object
  */
 static function add($data)
 {
     global $dbh, $auth_user;
     // name, category
     // license, summary, description
     // lead
     extract($data);
     if (empty($license)) {
         $license = 'BSD License';
     }
     if (!empty($category) && (int) $category == 0) {
         $sql = 'SELECT id FROM categories WHERE name = ?';
         $category = $dbh->getOne($sql, array($category));
     }
     if (empty($category)) {
         return PEAR::raiseError("package::add: invalid `category' field");
     }
     if (empty($name)) {
         return PEAR::raiseError("package::add: invalid `name' field");
     }
     $query = '
         INSERT INTO packages
             (id, name, package_type, category, license, summary, description, homepage, cvs_link)
         VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)';
     $id = $dbh->nextId('packages');
     $err = $dbh->query($query, array($id, $name, $type, $category, $license, $summary, $description, $homepage, $cvs_link));
     if (DB::isError($err)) {
         return $err;
     }
     $sql = 'UPDATE categories SET npackages = npackages + 1 WHERE id = ?';
     $err = $dbh->query($sql, array($category));
     if (DB::isError($err)) {
         return $err;
     }
     include_once 'pear-database-maintainer.php';
     $err = maintainer::add($id, $lead, 'lead');
     if (isset($lead) && DB::isError($err)) {
         return $err;
     }
     $event = $auth_user->handle . " (" . $auth_user->name . ") has added a new package " . $name;
     $mailtext = $event . "\n\nApprove: http://" . PEAR_CHANNELNAME . "/admin/package-approval.php?approve=" . $id;
     $mailtext .= "\nReject: http://" . PEAR_CHANNELNAME . "/admin/package-approval.php?reject=" . $id;
     // {{{ Logging mechanism
     require_once "Damblan/Log.php";
     require_once "Damblan/Log/Mail.php";
     // Syslog
     $logger = new Damblan_Log();
     $logger->log($event);
     // Logging via email
     $logger = new Damblan_Log_Mail();
     $logger->setRecipients("*****@*****.**");
     $logger->setHeader("From", $auth_user->email);
     $logger->setHeader("Message-Id", "<approve-request-" . $id . "@" . PEAR_CHANNELNAME . ">");
     $logger->setHeader("Subject", "New package");
     $logger->log($mailtext);
     // }}}
     return $id;
 }
Example #3
0
File: add.php Project: stof/pearweb
     $dir[] = 'channel.xml';
     $url->setPath(implode("/", $dir));
     $req->setURL($url->getURL());
     channel::validate($req, $chan);
     if (channel::exists($project_name->getValue())) {
         throw new Exception("Already exists");
     }
     $text = sprintf("[Channels] Please activate %s (%s) on the channel index.", $project_name->getValue(), $project_link->getValue());
     $from = sprintf('"%s" <%s>', $contact_name->getValue(), $contact_email->getValue());
     $logger = new Damblan_Log();
     $observer = new Damblan_Log_Mail();
     $observer->setRecipients(PEAR_WEBMASTER_EMAIL);
     $observer->setHeader("From", $from);
     $observer->setHeader("Subject", "Channel link submission");
     $logger->attach($observer);
     $logger->log($text);
     // Add the channel to the DB, but not yet activated
     channel::add($project_name->getValue());
     channel::edit($project_name->getValue(), $project_label->getValue(), $project_link->getValue(), $contact_name->getValue(), $contact_email->getValue());
     echo "<div class=\"success\">Thanks for your submission.  It will ";
     echo "be reviewed as soon as possible.</div>\n";
 } catch (Exception $exception) {
     echo '<div class="errors">';
     switch ($exception->getMessage()) {
         case "Invalid channel site":
         case "Empty channel.xml":
             echo "The submitted URL does not ";
             echo "appear to point to a valid channel site.  You will ";
             echo "have to make sure that <tt>/channel.xml</tt> at least ";
             echo "exists and is valid.";
         default:
Example #4
0
 /**
  * Notification method
  *
  * Sends out an email to the administrative body when karma has
  * been updated.
  *
  * @access private
  * @param  string Handle of the administrator who granted karma
  * @param  string Handle of the user whose karma has been updated
  * @param  string Describes the type of karma update
  * @return void
  */
 function _notify($admin_user, $user, $action)
 {
     require_once "Damblan/Log.php";
     require_once "Damblan/Log/Mail.php";
     static $logger, $observer;
     if (!isset($logger)) {
         $logger = new Damblan_Log();
     }
     if (!DEVBOX && !isset($observer)) {
         $observer = new Damblan_Log_Mail();
         $observer->setRecipients("*****@*****.**");
         $observer->setHeader("From", "\"PEAR Karma Manager\" <*****@*****.**>");
         $observer->setHeader("Reply-To", "<*****@*****.**>");
         $observer->setHeader("Subject", "[PEAR Group] Karma update");
         $logger->attach($observer);
     }
     $text = $admin_user . " has updated karma for " . $user . ": " . $action;
     $logger->log($text);
 }
 /**
  * Update user and roles of a package
  *
  * @static
  * @param int $pkgid The package id to update
  * @param array $users Assoc array containing the list of users
  *                     in the form: '<user>' => array('role' => '<role>', 'active' => '<active>')
  * @param bool Whether to print the logging information to the screen
  * @return mixed PEAR_Error or true
  */
 static function updateAll($pkgid, $users, $print = false, $releasing = false)
 {
     require_once 'Damblan/Log.php';
     global $dbh, $auth_user;
     // Only admins and leads can do this.
     if (maintainer::mayUpdate($pkgid) == false) {
         return PEAR::raiseError('maintainer::updateAll: insufficient privileges');
     }
     $logger = new Damblan_Log();
     if ($print) {
         require_once 'Damblan/Log/Print.php';
         $observer = new Damblan_Log_Print();
         $logger->attach($observer);
     }
     include_once 'pear-database-package.php';
     $pkg_name = package::info((int) $pkgid, "name");
     // Needed for logging
     if (empty($pkg_name)) {
         PEAR::raiseError('maintainer::updateAll: no such package');
     }
     $old = maintainer::get($pkgid);
     if (DB::isError($old)) {
         return $old;
     }
     $old_users = array_keys($old);
     $new_users = array_keys($users);
     $admin = $auth_user->isAdmin();
     $qa = $auth_user->isQA();
     if (!$admin && !$qa && !in_array($auth_user->handle, $new_users)) {
         return PEAR::raiseError("You can not delete your own maintainer role or you will not " . "be able to complete the update process. Set your name " . "in package.xml or let the new lead developer upload " . "the new release");
     }
     if ($releasing && user::maintains($auth_user->handle, (int) $pkgid, 'lead') && $users[$auth_user->handle]['role'] != 'lead') {
         return PEAR::raiseError('You cannot demote your role from lead to ' . $users[$auth_user->handle]['role']);
     }
     foreach ($users as $user => $u) {
         $role = $u['role'];
         $active = $u['active'];
         if (!maintainer::isValidRole($role)) {
             return PEAR::raiseError("invalid role '{$role}' for user '{$user}'");
         }
         // The user is not present -> add him
         if (!in_array($user, $old_users)) {
             $e = maintainer::add($pkgid, $user, $role, $active);
             if (PEAR::isError($e)) {
                 return $e;
             }
             $logger->log("[Maintainer] NEW: " . $user . " (" . $role . ") to package " . $pkg_name . " by " . $auth_user->handle);
             continue;
         }
         // Users exists but the role or the "active" flag have changed -> update it
         if ($role != $old[$user]['role'] || $active != $old[$user]['active']) {
             $res = maintainer::update($pkgid, $user, $role, $active);
             if (DB::isError($res)) {
                 return $res;
             }
             $logger->log("[Maintainer] UPDATE: " . $user . " (" . $role . ") to package " . $pkg_name . " by " . $auth_user->handle);
         }
     }
     // Drop users who are no longer maintainers
     foreach ($old_users as $old_user) {
         if (!in_array($old_user, $new_users)) {
             $res = maintainer::remove($pkgid, $old_user);
             if (DB::isError($res)) {
                 return $res;
             }
             $logger->log("[Maintainer] REMOVED: " . $old_user . " (" . $role . ") to package " . $pkg_name . " by " . $auth_user->handle);
         }
     }
     return true;
 }