svn: /pear2/BugManager/trunk/src/BugManager/IssueDecorator/ Mysql.php

From: Date: Sat, 15 Aug 2009 17:51:23 +0000
Subject: svn: /pear2/BugManager/trunk/src/BugManager/IssueDecorator/ Mysql.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-cvs+get-57161@lists.php.net to get a copy of this message
cellog Sat, 15 Aug 2009 17:51:23 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=287348 Log: remove mysql decorator Changed paths: D pear2/BugManager/trunk/src/BugManager/IssueDecorator/Mysql.php Deleted: pear2/BugManager/trunk/src/BugManager/IssueDecorator/Mysql.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/IssueDecorator/Mysql.php 2009-08-15 17:50:38 UTC (rev 287347) +++ pear2/BugManager/trunk/src/BugManager/IssueDecorator/Mysql.php 2009-08-15 17:51:23 UTC (rev 287348) @@ -1,150 +0,0 @@ -<?php -/** - * pear2\BugManager\Issue - * - * PHP version 5 - * - * @category Bugs - * @package PEAR2_BugManager - * @author Gregory Beaver <cellog@php.net> - * @copyright 2009 Gregory Beaver - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id$ - * @link http://svn.php.net/repository/pear2/BugManager - */ - -/** - * Converts issue into change SQL for a mysql database - * - * @category Bugs - * @package PEAR2_BugManager - * @author Gregory Beaver <cellog@php.net> - * @copyright 2009 Gregory Beaver - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @link http://svn.php.net/repository/pear2/BugManager - */ -namespace pear2\BugManager\IssueDecorator; -use pear2\BugManager\IssueDecoratorInterface, pear2\BugManager; -class Mysql implements IssueDecoratorInterface -{ - protected $bug; - protected $manager; - - function __construct(BugManager\Issue $bug, BugManager\IssueManager\Mysql $manager = null) - { - if (null === $manager) { - $manager = $bug->issuemanager; - } - $this->bug = $bug; - $this->manager = $manager; - } - - function getUpdateSQL() - { - $basicdiff = array_flip($this->bug->diff()); - $updatearr = array(); - $contextmap = array( - 'phpversion' => 'php_version', - 'operatingsystem' => 'php_os', - 'packagename' => 'package_name', - 'packageversion' => 'package_version', - 'bugtype' => 'package_name', - ); - $map = array( - 'status' => 'status', - 'type' => 'bug_type', - 'summary' => 'sdesc', - 'createtimestamp' => 'ts1', - 'modifiedtimestamp' => 'ts2', - ); - if (isset($basicdiff['reporter'])) { - $updatearr[] = 'handle="' . $this->manager->esc($this->bug->reporter->handle) . '"'; - $updatearr[] = 'email="' . $this->manager->esc($this->bug->reporter->email) . '"'; - $updatearr[] = 'reporter_name="' . $this->manager->esc($this->bug->reporter->name) . '"'; - if ($this->bug->reporter->karma) { - $updatearr[] = 'registered=1'; - } - } - if (isset($basicdiff['assigned'])) { - $updatearr[] = 'assign="' . $this->manager->esc( - implode('|', array_map(function($a){return $a->handle;}, $this->bug->assigned)) - ); - } - foreach ($basicdiff as $key => $unused) { - if (!isset($map[$key])) { - continue; - } - $updatearr[] = $map[$key] . '="' . $this->manager->esc($this->bug->$key) . '"'; - } - if (isset($basicdiff['context'])) { - $contextdiff = $this->bug->diffContext(); - foreach (array('added', 'deleted', 'changed') as $stuff) { - foreach ($contextdiff[$stuff] as $key) { - if ($stuff !== 'deleted') { - $value = '"' . - $this->manager->esc($this->bug->context[$key]->value()) . - '"'; - } else { - $value = 'NULL'; - } - $updatearr[] = $contextmap[$key] . '=' . $value; - } - } - } - $sql = 'UPDATE bugmanager_issues SET ' . implode(',', $updatearr) . - ' WHERE id=' . $this->bug->id . ";\n"; - $addsql = array(); - if (isset($basicdiff['comments'])) { - $commentdiff = $this->bug->diffComments(); - foreach ($commentdiff['deleted'] as $comment) { - $sql .= 'DELETE FROM bugmanager_comments WHERE id=' . $comment->id . ";\n"; - } - foreach ($commentdiff['changed'] as $comment) { - $sql .= 'UPDATE bugmanager_comments SET - email="' . $this->manager->esc($comment->commenter->email) . '", - handle="' . $this->manager->esc($comment->commenter->uniqueId()) . '", - reporter_name="' . $this->manager->esc($comment->commenter->name) . '", - ts="' . $comment->timestamp->format('Y-m-d H:i:s') . '" - WHERE id=' . $comment->id . ";\n"; - } - foreach ($commentdiff['added'] as $comment) { - $addsql['INSERT INTO bugmanager_comments - (bug_id, email, handle, reporter_name, ts) - VALUES(' . $this->bug->id . ', - "' . $this->manager->esc($comment->commenter->email) . '", - "' . $this->manager->esc($comment->commenter->uniqueId()) . '", - "' . $this->manager->esc($comment->commenter->name) . '", - "' . $comment->timestamp->format('Y-m-d H:i:s') . ");\n"] = $comment; - } - } - if (isset($basicdiff['attachments'])) { - $patchdiff = $this->bug->diffComments(); - foreach ($patchdiff['deleted'] as $attachment) { - $sql .= 'DELETE FROM bugmanager_patchtracker WHERE bug_id=' . $this->bug->id . ' - AND name="' . $this->manager->esc($attachment->name) . '" - AND revision="' . $this->manager->esc($attachment->revision) . "\";\n"; - $sql .= 'DELETE FROM bugmanager_obsoletes_patches WHERE bug_id=' . $this->bug->id . ' - AND name="' . $this->manager->esc($attachment->name) . '" - AND revision="' . $this->manager->esc($attachment->revision) . "\";\n"; - } - foreach ($patchdiff['added'] as $attachment) { - $sql .= "\nINSERT INTO bugmanager_patchtracker - (bug_id, name, revision, handle) - VALUES(" . $id . ', - "' . $this->manager->esc($attachment->name) . '", - "' . $this->manager->esc($attachment->revision) . '", - "' . $this->manager->esc($comment->commenter->uniqueId()) . "\");\n"; - foreach ($attachment->obsoletes as $obsoleted) { - $sql .= "\nINSERT INTO bugmanager_obsoletes_patches - (bug_id, name, revision, obsolete_name, obsolete_revision) - VALUES(" . $id . ', - "' . $this->manager->esc($attachment->name) . '", - "' . $this->manager->esc($attachment->revision) . '", - "' . $this->manager->esc($obsoleted[0]) . '", - "' . $this->manager->esc($obsoleted[1]) . "\");\n"; - } - } - } - return array($sql, $addsql); - } -}

« previous php.pear.cvs (#57161) next »