Author Topic: Paste-1265578633:v:use_geshi-1:v:type-php  (Read 589 times)

0 Members and 1 Guest are viewing this topic.

Offline SleePy

  • PHP Lover
  • Administrator
  • ********
  • Posts: 343
  • Karma: +1339/-0
  • Gender: Male
  • I like Pi
    • View Profile
    • SleePy Code
Paste-1265578633:v:use_geshi-1:v:type-php
« on: February 07, 2010, 01:37:13 pm »
// 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

Offline SleePy

  • PHP Lover
  • Administrator
  • ********
  • Posts: 343
  • Karma: +1339/-0
  • Gender: Male
  • I like Pi
    • View Profile
    • SleePy Code
Paste-1265578715:v:use_geshi-1:v:type-php
« Reply #1 on: February 07, 2010, 01:38:35 pm »
// 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

Offline SleePy

  • PHP Lover
  • Administrator
  • ********
  • Posts: 343
  • Karma: +1339/-0
  • Gender: Male
  • I like Pi
    • View Profile
    • SleePy Code
Paste-1265578909:v:use_geshi-1:v:type-php
« Reply #2 on: February 07, 2010, 01:41:49 pm »
// 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

 

Templates: 3: index (CurveSite), Display (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 1: index+Modifications.english (CurveSite).
Style sheets: 1: site (default).
Files included: 15 - 643KB. (show)
Cache hits: 9: 0.00125s for 14,733 bytes (show)
Queries used: 16.

[Show Queries]