News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1265578633:v:use_geshi-1:v:type-php

Started by SleePy, Feb 07, 2010, 09:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SleePy

// Close bugs.
function svnProjectTools($data, $id_member)
{
   global $smcFunc, $sourcedir, $context, $user_profile, $issue, $project;

   $project = 2;

   if (empty($data->log))
      return;

   $entries = explode("\n", $data->log);
   $bugs = array();
   foreach ($entries as $entry)
   {
      $bug_data = array();
      preg_match('~\[[Bug|Feature]+\s+([\d,]+)\]~i', $entry, $matches);

      // Nothing to log?
      if (empty($matches[1]))
         continue;

      $temp = array_unique(array_map('intval', explode(',', $matches[1])));;

      foreach ($temp as $id)
         $bugs[$id][] = str_replace($matches[0], 'Revision: ' . $data->revision, $entry);
   }

   // Now loop our bugs.
   foreach ($bugs as $id => $bug)
      $bugs[$id] = implode("\n", array_unique($bug));

   // Still nothing?
   if (empty($bugs))
      return;

   require_once($sourcedir . '/Subs-Post.php');
   require_once($sourcedir . '/Subs-Issue.php');
   require_once($sourcedir . '/Subs-Project.php');
   require_once($sourcedir . '/IssueReport.php');
   require_once($sourcedir . '/IssueComment.php');

   // Get their data.
   loadMemberData($id_member);

   // Prep the changes.
   $posterOptions = array(
      'id' => $id_member,
      'ip' => $user_profile[$id_member]['member_ip'],
      'name' => $data->author,
      'email' => $user_profile[$id_member]['email_address'],
   );
   $issueOptions = array(
      'mark_read' => true,
      'assignee' => $id_member,
      'status' => 5, // Resolved.
   );
   $commentOptions = array('body' => '');
   loadProjectTools();

   // Lets do some loops.
   foreach ($bugs as $bug => $message)
   {
      $issue = $bug;
      loadIssue();

      // Update our body message
      $commentOptions['body'] = $smcFunc['htmlspecialchars']($message, ENT_QUOTES);

      $event_data = updateIssue($bug, $issueOptions, $posterOptions, true);

      if ($event_data === true)
         $event_data = array();

      $id_comment = createComment($project, $bug, $commentOptions, $posterOptions);
      $commentOptions['id'] = $id_comment;

      sendIssueNotification(array('id' => $bug, 'project' => $project), $commentOptions, $event_data, 'new_comment', $id_member);

   }
}
No siggy! :D

SleePy

// Close bugs.
function svnProjectTools($data, $id_member)
{
   global $smcFunc, $sourcedir, $context, $user_profile, $issue, $project;

   $project = 2;

   if (empty($data->log))
      return;

   $entries = explode("\n", $data->log);
   $bugs = array();
   foreach ($entries as $entry)
   {
      $bug_data = array();
      preg_match('~\[[Bug|Feature]+\s+([\d,]+)\]~i', $entry, $matches);

      // Nothing to log?
      if (empty($matches[1]))
         continue;

      $temp = array_unique(array_map('intval', explode(',', $matches[1])));;

      foreach ($temp as $id)
         $bugs[$id][] = str_replace($matches[0], 'Revision: ' . $data->revision, $entry);
   }

   // Now loop our bugs.
   foreach ($bugs as $id => $bug)
      $bugs[$id] = implode("\n", array_unique($bug));

   // Still nothing?
   if (empty($bugs))
      return;

   require_once($sourcedir . '/Subs-Post.php');
   require_once($sourcedir . '/Subs-Issue.php');
   require_once($sourcedir . '/Subs-Project.php');
   require_once($sourcedir . '/IssueReport.php');
   require_once($sourcedir . '/IssueComment.php');

   // Get their data.
   loadMemberData($id_member);

   // Prep the changes.
   $posterOptions = array(
      'id' => $id_member,
      'ip' => $user_profile[$id_member]['member_ip'],
      'name' => $data->author,
      'email' => $user_profile[$id_member]['email_address'],
   );
   $issueOptions = array(
      'mark_read' => true,
      'assignee' => $id_member,
      'status' => 5, // Resolved.
   );
   $commentOptions = array('body' => '');
   loadProjectTools();

   // Lets do some loops.
   foreach ($bugs as $bug => $message)
   {
      $issue = $bug;
      loadIssue();

      // Update our body message
      $commentOptions['body'] = $smcFunc['htmlspecialchars']($message, ENT_QUOTES);

      // Update the info like assigned and status.
      $event_data = updateIssue($bug, $issueOptions, $posterOptions, true);

      // Fix a Project tracker bug...
      if ($event_data === true)
         $event_data = array();

      // Create a comment.
      $id_comment = createComment($project, $bug, $commentOptions, $posterOptions);
      $commentOptions['id'] = $id_comment;

      // Spam people.
      sendIssueNotification(array('id' => $bug, 'project' => $project), $commentOptions, $event_data, 'new_comment', $id_member);

   }
}
No siggy! :D

SleePy

// Close bugs.
function svnProjectTools($data, $id_member)
{
   global $smcFunc, $sourcedir, $context, $user_profile, $issue, $project;

   $project = 2;

   if (empty($data->log))
      return;

   // First, explode all entires by new line.
   $entries = explode("\n", $data->log);
   $bugs = array();
   foreach ($entries as $entry)
   {
      // Pull out the bug/feature index.
      preg_match('~\[[Bug|Feature]+\s+([\d,]+)\]~i', $entry, $matches);

      // Nothing to log?
      if (empty($matches[1]))
         continue;

      // Only list them once.
      $temp = array_unique(array_map('intval', explode(',', $matches[1])));;

      // Dump this into an array whos key is the bug id.
      foreach ($temp as $id)
         $bugs[$id][] = str_replace($matches[0], 'Revision: ' . $data->revision, $entry);
   }

   // Mash that multi-dimensional array to a single array.
   foreach ($bugs as $id => $bug)
      $bugs[$id] = implode("\n", array_unique($bug));

   // Still nothing?
   if (empty($bugs))
      return;

   // Some junk we need.
   require_once($sourcedir . '/Subs-Post.php');
   require_once($sourcedir . '/Subs-Issue.php');
   require_once($sourcedir . '/Subs-Project.php');
   require_once($sourcedir . '/IssueReport.php');
   require_once($sourcedir . '/IssueComment.php');

   // Call a few friends.
   loadMemberData($id_member);
   loadProjectTools();

   // Prep the changes.
   $posterOptions = array(
      'id' => $id_member,
      'ip' => $user_profile[$id_member]['member_ip'],
      'name' => $data->author,
      'email' => $user_profile[$id_member]['email_address'],
   );
   $issueOptions = array(
      'mark_read' => true,
      'assignee' => $id_member,
      'status' => 5, // Resolved.
   );
   $commentOptions = array('body' => '');

   // Lets do some loops.
   foreach ($bugs as $bug => $message)
   {
      $issue = $bug;
      loadIssue();

      // Update our body message
      $commentOptions['body'] = $smcFunc['htmlspecialchars']($message, ENT_QUOTES);

      // Update status and assigne.
      $event_data = updateIssue($bug, $issueOptions, $posterOptions, true);

      // Fix a Project tracker bug...
      if ($event_data === true)
         $event_data = array();

      // Create a comment.
      $id_comment = createComment($project, $bug, $commentOptions, $posterOptions);
      $commentOptions['id'] = $id_comment;

      // Spam people.
      sendIssueNotification(array('id' => $bug, 'project' => $project), $commentOptions, $event_data, 'new_comment', $id_member);

   }
}
No siggy! :D