Exemple #1
0
 public static function GetURI($p_publicationId, $p_languageId, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = null)
 {
     $languageObj = new Language($p_languageId);
     if (!$languageObj->exists()) {
         return new PEAR_Error(getGS('Language does not exist.'));
     }
     $uri = $GLOBALS['Campsite']['SUBDIR'] . '/' . $languageObj->getCode() . '/';
     if (!is_null($p_issueNo) && is_null($p_articleNo)) {
         $issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo);
         if (!$issueObj->exists()) {
             return new PEAR_Error(getGS('Issue does not exist.'));
         }
         $uri .= $issueObj->getUrlName() . '/';
     }
     if (!is_null($p_sectionNo) && is_null($p_articleNo)) {
         $sectionObj = new Section($p_publicationId, $p_issueNo, $p_languageId, $p_sectionNo);
         if (!$sectionObj->exists()) {
             return new PEAR_Error(getGS('Section does not exist.'));
         }
         $uri .= $sectionObj->getUrlName() . '/';
     }
     if (!is_null($p_articleNo)) {
         $articleObj = new Article($p_languageId, $p_articleNo);
         if (!$articleObj->exists()) {
             return new PEAR_Error(getGS('Article does not exist.'));
         }
         $issueObj = new Issue($p_publicationId, $p_languageId, $articleObj->getIssueNumber());
         $sectionObj = new Section($p_publicationId, $articleObj->getIssueNumber(), $p_languageId, $articleObj->getSectionNumber());
         $uri .= $issueObj->getUrlName() . '/';
         $uri .= $sectionObj->getUrlName() . '/';
         $uri .= $articleObj->getUrlName() . '/';
     }
     return $uri;
 }
 public function setIssueAndChanges(Issue $issue, array $old_values)
 {
     $this->Issue = $issue;
     $this->exists = $issue->exists();
     $this->modified = $issue->getModified();
     $this->old_values = $old_values;
 }
Exemple #3
0
 public static function GetURI($p_publicationId, $p_languageId, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = null)
 {
     $translator = \Zend_Registry::get('container')->getService('translator');
     $languageObj = new Language($p_languageId);
     if (!$languageObj->exists()) {
         return new PEAR_Error($translator->trans('Language does not exist.'));
     }
     $uri = '/' . $languageObj->getCode() . '/';
     if (!is_null($p_issueNo) && is_null($p_articleNo)) {
         $issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo);
         if (!$issueObj->exists()) {
             return new PEAR_Error($translator->trans('Issue does not exist.'));
         }
         $uri .= $issueObj->getUrlName() . '/';
     }
     if (!is_null($p_sectionNo) && is_null($p_articleNo)) {
         $sectionObj = new Section($p_publicationId, $p_issueNo, $p_languageId, $p_sectionNo);
         if (!$sectionObj->exists()) {
             return new PEAR_Error($translator->trans('Section does not exist.'));
         }
         $uri .= $sectionObj->getUrlName() . '/';
     }
     if (!is_null($p_articleNo)) {
         $articleObj = new Article($p_languageId, $p_articleNo);
         if (!$articleObj->exists()) {
             return new PEAR_Error($translator->trans('Article does not exist.'));
         }
         $issueObj = new Issue($p_publicationId, $p_languageId, $articleObj->getIssueNumber());
         $sectionObj = new Section($p_publicationId, $articleObj->getIssueNumber(), $p_languageId, $articleObj->getSectionNumber());
         $uri .= $issueObj->getUrlName() . '/';
         $uri .= $sectionObj->getUrlName() . '/';
         $uri .= $articleObj->getUrlName() . '/';
     }
     return $uri;
 }
Exemple #4
0
function validateIssueNumbers()
{
    $issues = explode(',', $_REQUEST['values']);
    $check_project = $_REQUEST['check_project'] != 0;
    $exclude_issue = isset($_REQUEST['exclude_issue']) ? $_REQUEST['exclude_issue'] : null;
    $exclude_duplicates = isset($_REQUEST['exclude_duplicates']) ? $_REQUEST['exclude_duplicates'] == 1 : false;
    $bad_issues = array();
    foreach ($issues as $issue_id) {
        if ($issue_id != '' && !Issue::exists($issue_id, $check_project) || $exclude_issue == $issue_id || $exclude_duplicates && Issue::isDuplicate($issue_id)) {
            $bad_issues[] = $issue_id;
        }
    }
    if (count($bad_issues)) {
        return implode(', ', $bad_issues);
    } else {
        return 'ok';
    }
}
Exemple #5
0
 /**
  * Get consistency errors
  * @param int $teamid
  * @return mixed[]
  */
 private function getTeamConsistencyErrors($teamid)
 {
     if (self::$logger->isDebugEnabled()) {
         self::$logger->debug("getTeamConsistencyErrors teamid={$teamid}");
     }
     // get team projects
     $issueList = TeamCache::getInstance()->getTeam($teamid)->getTeamIssueList(true, false);
     if (self::$logger->isDebugEnabled()) {
         self::$logger->debug("getTeamConsistencyErrors nbIssues=" . count($issueList));
     }
     #$ccheck = new ConsistencyCheck2($issueList);
     $ccheck = new ConsistencyCheck2($issueList, $teamid);
     $cerrList = $ccheck->check();
     $cerrs = NULL;
     if (count($cerrList) > 0) {
         $i = 0;
         foreach ($cerrList as $cerr) {
             $i += 1;
             if (NULL != $cerr->userId) {
                 $user = UserCache::getInstance()->getUser($cerr->userId);
             } else {
                 $user = NULL;
             }
             if (Issue::exists($cerr->bugId)) {
                 $issue = IssueCache::getInstance()->getIssue($cerr->bugId);
                 $summary = $issue->getSummary();
                 $projName = $issue->getProjectName();
                 $refExt = $issue->getTcId();
             } else {
                 $summary = '';
                 $projName = '';
             }
             $cerrs[$i] = array('userName' => isset($user) ? $user->getName() : '', 'issueURL' => NULL == $cerr->bugId ? '' : Tools::issueInfoURL($cerr->bugId, $summary), 'mantisURL' => NULL == $cerr->bugId ? '' : Tools::mantisIssueURL($cerr->bugId, $summary, true), 'extRef' => NULL == $refExt ? '' : $refExt, 'date' => NULL == $cerr->timestamp ? '' : date("Y-m-d", $cerr->timestamp), 'status' => NULL == $cerr->status ? '' : Constants::$statusNames[$cerr->status], 'severity' => $cerr->getLiteralSeverity(), 'project' => $projName, 'desc' => $cerr->desc, 'summary' => $summary);
         }
     }
     return $cerrs;
 }
Exemple #6
0
 if (!$publicationObj->exists()) {
     camp_html_display_error(getGS('Publication does not exist.'), $backLink);
     exit;
 }
 $f_issue_number = $articleObj->getIssueNumber();
 $issueObj = new Issue($f_publication_id, $f_language_id, $f_issue_number);
 if (!$issueObj->exists()) {
     camp_html_display_error(getGS('No such issue.'), $backLink);
     exit;
 }
 //$translationIssueObj = new Issue($f_publication_id, $f_translation_language, $f_issue_number);
 $translationIssueObj = $issueObj->copy(null, $issueObj->getIssueNumber(), $f_translation_language);
 if (!$translationIssueObj) {
     $translationIssueObj = new Issue($f_publication_id, $f_translation_language, $f_issue_number);
 }
 if (!$translationIssueObj->exists()) {
     if (!$g_user->hasPermission("ManageIssue")) {
         camp_html_add_msg(getGS('An issue must be created for the selected language but you do not have the right to create an issue.'));
         camp_html_goto_page($backLink);
     }
     foreach ($issueObj->getData() as $field => $fieldValue) {
         if ($field != 'IdLanguage') {
             $translationIssueObj->setProperty($field, $fieldValue, false);
         }
     }
     $f_issue_name = Input::Get('f_issue_name', 'string', '');
     if ($f_issue_name != '') {
         $translationIssueObj->setName($f_issue_name);
     }
     $f_issue_urlname = Input::Get('f_issue_urlname', 'string', $issueObj->getUrlName());
     if ($f_issue_urlname == "") {
Exemple #7
0
        $displayLanguages[$language->getLanguageId()] = $language->getNativeName();
    }
}
asort($displayLanguages);
foreach ($displayLanguages as $tmpLangId => $nativeName) {
    camp_html_select_option($tmpLangId, $f_language_selected, $nativeName);
}
?>
	</SELECT>
	</TD>
</TR>
<?php 
$canCreate = true;
if ($f_language_selected > 0 && $f_issue_number > 0) {
    // Every article must live inside a cooresponding issue of the same language.
    if (!$translationIssueObj->exists()) {
        if ($g_user->hasPermission("ManageIssue")) {
            // If a section needs to be translated, but the user doesnt have the permission
            // to create a section, then we dont want to display anything here.  Even
            // if they can create the issue, they still need to create a cooresponding section.
            // If they dont have the permission to do that, then no use in creating the issue.
            if ($translationSectionObj->exists() || $g_user->hasPermission("ManageSection")) {
                ?>
<TR>
	<TD colspan="2" align="left" style="padding-left: 40px; padding-right: 40px; padding-top: 20px;"><strong><?php 
                putGS("An issue must be created for the selected language.  Please enter the issue name and URL name.");
                ?>
</strong></TD>
</TR>
<TR>
	<TD ALIGN="RIGHT" ><?php 
 /**
  * for all timetracks of the team, check that the Mantis issue exist.
  * @return ConsistencyError2[]
  */
 public function checkTimetracksOnRemovedIssues()
 {
     $cerrList = array();
     if (NULL != $this->teamId) {
         $team = TeamCache::getInstance()->getTeam($this->teamId);
         $userList = $team->getMembers();
         $formatedUsers = implode(', ', array_keys($userList));
         $query = "SELECT * " . "FROM `codev_timetracking_table` " . "WHERE date >= " . $team->getDate() . " " . "AND userid IN ({$formatedUsers}) ";
         #"AND    0 = (SELECT COUNT(id) FROM `mantis_bug_table` WHERE id='codev_timetracking_table.bugid' ) ";
         $result = SqlWrapper::getInstance()->sql_query($query);
         if (!$result) {
             echo "<span style='color:red'>ERROR: Query FAILED</span>";
             exit;
         }
         while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
             if (!Issue::exists($row->bugid)) {
                 $cerr = new ConsistencyError2($row->bugid, $row->userid, NULL, $row->date, T_("Timetrack found on a task that does not exist in Mantis DB (duration = {$row->duration})."));
                 $cerr->severity = ConsistencyError2::severity_error;
                 $cerrList[] = $cerr;
             }
         }
     }
     return $cerrList;
 }
Exemple #9
0
 /**
  * Creates a new issue from an email if appropriate. Also returns if this message is related
  * to a previous message.
  *
  * @param   array   $info An array of info about the email account.
  * @param   string  $headers The headers of the email.
  * @param   string  $message_body The body of the message.
  * @param   string  $date The date this message was sent
  * @param   string  $from The name and email address of the sender.
  * @param   string  $subject The subject of this message.
  * @param   array   $to An array of to addresses
  * @param   array   $cc An array of cc addresses
  * @return  array   An array of information about the message
  */
 public function createIssueFromEmail($info, $headers, $message_body, $date, $from, $subject, $to, $cc)
 {
     $should_create_issue = false;
     $issue_id = '';
     $associate_email = '';
     $type = 'email';
     $parent_id = '';
     $customer_id = false;
     $contact_id = false;
     $contract_id = false;
     $severity = false;
     // we can't trust the in-reply-to from the imap c-client, so let's
     // try to manually parse that value from the full headers
     $references = Mail_Helper::getAllReferences($headers);
     $message_id = Mail_Helper::getMessageID($headers, $message_body);
     $workflow = Workflow::getIssueIDforNewEmail($info['ema_prj_id'], $info, $headers, $message_body, $date, $from, $subject, $to, $cc);
     if (is_array($workflow)) {
         if (isset($workflow['customer_id'])) {
             $customer_id = $workflow['customer_id'];
         }
         if (isset($workflow['contract_id'])) {
             $contract_id = $workflow['contract_id'];
         }
         if (isset($workflow['contact_id'])) {
             $contact_id = $workflow['contact_id'];
         }
         if (isset($workflow['severity'])) {
             $severity = $workflow['severity'];
         }
         if (isset($workflow['should_create_issue'])) {
             $should_create_issue = $workflow['should_create_issue'];
         } else {
             $should_create_issue = true;
         }
     } elseif ($workflow == 'new') {
         $should_create_issue = true;
     } elseif (is_numeric($workflow)) {
         $issue_id = $workflow;
     } else {
         $setup = Setup::load();
         if (@$setup['subject_based_routing']['status'] == 'enabled') {
             // Look for issue ID in the subject line
             // look for [#XXXX] in the subject line
             if (preg_match("/\\[#(\\d+)\\]( Note| BLOCKED)*/", $subject, $matches)) {
                 $should_create_issue = false;
                 $issue_id = $matches[1];
                 if (!Issue::exists($issue_id, false)) {
                     $issue_id = '';
                 } elseif (!empty($matches[2])) {
                     $type = 'note';
                 }
             } else {
                 $should_create_issue = true;
             }
         } else {
             // - if this email is a reply:
             if (count($references) > 0) {
                 foreach ($references as $reference_msg_id) {
                     //  -> check if the replied email exists in the database:
                     if (Note::exists($reference_msg_id)) {
                         // note exists
                         // get what issue it belongs too.
                         $issue_id = Note::getIssueByMessageID($reference_msg_id);
                         $should_create_issue = false;
                         $type = 'note';
                         $parent_id = Note::getIDByMessageID($reference_msg_id);
                         break;
                     } elseif (self::exists($reference_msg_id) || Issue::getIssueByRootMessageID($reference_msg_id) != false) {
                         // email or issue exists
                         $issue_id = self::getIssueByMessageID($reference_msg_id);
                         if (empty($issue_id)) {
                             $issue_id = Issue::getIssueByRootMessageID($reference_msg_id);
                         }
                         if (empty($issue_id)) {
                             // parent email isn't associated with issue.
                             //      --> create new issue, associate current email and replied email to this issue
                             $should_create_issue = true;
                             $associate_email = $reference_msg_id;
                         } else {
                             // parent email is associated with issue:
                             //      --> associate current email with existing issue
                             $should_create_issue = false;
                         }
                         break;
                     } else {
                         //  no matching note, email or issue:
                         //    => create new issue and associate current email with it
                         $should_create_issue = true;
                     }
                 }
             } else {
                 // - if this email is not a reply:
                 //  -> create new issue and associate current email with it
                 $should_create_issue = true;
             }
         }
     }
     $sender_email = Mail_Helper::getEmailAddress($from);
     if (Misc::isError($sender_email)) {
         $sender_email = 'Error Parsing Email <>';
     }
     // only create a new issue if this email is coming from a known customer
     if ($should_create_issue && $info['ema_issue_auto_creation_options']['only_known_customers'] == 'yes' && CRM::hasCustomerIntegration($info['ema_prj_id']) && !$customer_id) {
         try {
             $crm = CRM::getInstance($info['ema_prj_id']);
             $should_create_issue = true;
         } catch (CRMException $e) {
             $should_create_issue = false;
         }
     }
     // check whether we need to create a new issue or not
     if ($info['ema_issue_auto_creation'] == 'enabled' && $should_create_issue && !Notification::isBounceMessage($sender_email)) {
         $options = Email_Account::getIssueAutoCreationOptions($info['ema_id']);
         Auth::createFakeCookie(APP_SYSTEM_USER_ID, $info['ema_prj_id']);
         $issue_id = Issue::createFromEmail($info['ema_prj_id'], APP_SYSTEM_USER_ID, $from, Mime_Helper::decodeQuotedPrintable($subject), $message_body, @$options['category'], @$options['priority'], @$options['users'], $date, $message_id, $severity, $customer_id, $contact_id, $contract_id);
         // add sender to authorized repliers list if they are not a real user
         $sender_usr_id = User::getUserIDByEmail($sender_email, true);
         if (empty($sender_usr_id)) {
             Authorized_Replier::manualInsert($issue_id, $sender_email, false);
         }
         // associate any existing replied-to email with this new issue
         if (!empty($associate_email) && !empty($reference_issue_id)) {
             $reference_sup_id = self::getIDByMessageID($associate_email);
             self::associate(APP_SYSTEM_USER_ID, $issue_id, array($reference_sup_id));
         }
     }
     // need to check crm for customer association
     if (!empty($from)) {
         if (CRM::hasCustomerIntegration($info['ema_prj_id']) && !$customer_id) {
             // check for any customer contact association
             try {
                 $crm = CRM::getInstance($info['ema_prj_id']);
                 $contact = $crm->getContactByEmail($sender_email);
                 $contact_id = $contact->getContactID();
                 $contracts = $contact->getContracts(array(CRM_EXCLUDE_EXPIRED));
                 $contract = $contracts[0];
                 $customer_id = $contract->getCustomerID();
             } catch (CRMException $e) {
                 $customer_id = null;
                 $contact_id = null;
             }
         }
     }
     return array('should_create_issue' => $should_create_issue, 'associate_email' => $associate_email, 'issue_id' => $issue_id, 'customer_id' => $customer_id, 'contact_id' => $contact_id, 'type' => $type, 'parent_id' => $parent_id);
 }
Exemple #10
0
// | along with this program; if not, write to:                           |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 51 Franklin Street, Suite 330                                          |
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: Raul Raat <*****@*****.**>                              |
// | Authors: Elan Ruusamäe <*****@*****.**>                               |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../../init.php';
// check login
Auth::checkAuthentication(APP_COOKIE);
$field_name = !empty($_POST['field_name']) ? $_POST['field_name'] : null;
$issue_id = !empty($_POST['issue_id']) ? (int) $_POST['issue_id'] : null;
// check if correct issue id was sent
if (!$issue_id || !Issue::exists($issue_id)) {
    die('Invalid issue_id');
}
$usr_id = Auth::getUserID();
// check if user role is above "Standard User"
if (User::getRoleByUser($usr_id, Issue::getProjectID($issue_id)) < User::getRoleID('Standard User')) {
    die('Forbidden');
}
// check if user can acess the issue
if (!Issue::canAccess($issue_id, $usr_id)) {
    die('Forbidden');
}
switch ($field_name) {
    case 'expected_resolution_date':
        $day = Misc::escapeInteger($_POST['day']);
        $month = Misc::escapeInteger($_POST['month']);
Exemple #11
0
 /**
  * Update the issue associations
  *
  * @param int $issue_id issue to associate
  * @param array $associated_issues issue_id's to associate with
  */
 private function updateAssociatedIssuesRelations($issue_id, $associated_issues)
 {
     global $errors;
     // trim and remove empty values
     $associated_issues = array_filter(array_map(function ($s) {
         return trim($s);
     }, $associated_issues));
     // make sure all associated issues are valid (and in this project)
     foreach ($associated_issues as $i => $iss_id) {
         if ($iss_id == $issue_id) {
             // skip issue itself
             unset($associated_issues[$i]);
             continue;
         }
         if (!Issue::exists($iss_id, false)) {
             $error = ev_gettext('Issue #%s does not exist and was removed from the list of associated issues.', $iss_id);
             $errors['Associated Issues'][] = $error;
             unset($associated_issues[$i]);
         }
     }
     // this reindexes the array and removes duplicates filled by user
     $associated_issues = array_unique($associated_issues);
     $current = self::getDetails($issue_id);
     $association_diff = Misc::arrayDiff($current['associated_issues'], $associated_issues);
     if (!$association_diff) {
         // no diffs, return back
         return;
     }
     $usr_id = Auth::getUserID();
     // go through the new associations, if association already exists, skip it
     $associations_to_remove = $current['associated_issues'];
     if (count($associated_issues) > 0) {
         foreach ($associated_issues as $associated_id) {
             if (!in_array($associated_id, $current['associated_issues'])) {
                 self::addAssociation($issue_id, $associated_id, $usr_id);
             } else {
                 // already assigned, remove this user from list of issues to remove
                 unset($associations_to_remove[array_search($associated_id, $associations_to_remove)]);
             }
         }
     }
     if ($associations_to_remove) {
         foreach ($associations_to_remove as $associated_id) {
             self::deleteAssociation($issue_id, $associated_id);
         }
     }
 }
Exemple #12
0
}

if (!Input::IsValid()) {
	camp_html_display_error(getGS('Invalid input: $1', Input::GetErrorString()), $_SERVER['REQUEST_URI']);
	exit;
}

$issueObj = new Issue($Pub, $Language, $Issue);
$publicationObj = new Publication($Pub);
$sectionObj = new Section($Pub, $Issue, $Language, $Section);

if (!$publicationObj->exists()) {
    camp_html_display_error(getGS('Publication does not exist.'));
    exit;
}
if (!$issueObj->exists()) {
	camp_html_display_error(getGS('No such issue.'));
	exit;
}

$correct = true;
$modified = false;

$errors = array();
if ($cName == "") {
	camp_html_add_msg(getGS('You must fill in the $1 field.','"'.getGS('Name').'"'));
}
if ($cShortName == "")  {
	camp_html_add_msg(getGS('You must fill in the $1 field.','"'.getGS('URL Name').'"'));
}
$isValidShortName = camp_is_valid_url_name($cShortName);
 /**
  * Creates a new issue from an email if appropriate. Also returns if this message is related
  * to a previous message.
  *
  * @access  private
  * @param   array   $info An array of info about the email account.
  * @param   string  $headers The headers of the email.
  * @param   string  $message_body The body of the message.
  * @param   string  $date The date this message was sent
  * @param   string  $from The name and email address of the sender.
  * @param   string  $subject The subject of this message.
  * @return  array   An array of information about the message
  */
 function createIssueFromEmail($info, $headers, $message_body, $date, $from, $subject)
 {
     $should_create_issue = false;
     $issue_id = '';
     $associate_email = '';
     $type = 'email';
     $parent_id = '';
     // we can't trust the in-reply-to from the imap c-client, so let's
     // try to manually parse that value from the full headers
     $references = Mail_API::getAllReferences($headers);
     $message_id = Mail_API::getMessageID($headers, $message_body);
     $setup = Setup::load();
     if (@$setup['subject_based_routing']['status'] == 'enabled' && preg_match("/\\[#(\\d+)\\]( Note| BLOCKED)*/", $subject, $matches)) {
         $should_create_issue = false;
         $issue_id = $matches[1];
         if (!Issue::exists($issue_id, false)) {
             $issue_id = '';
         } elseif (!empty($matches[2])) {
             $type = 'note';
         }
     } else {
         // - if this email is a reply:
         if (count($references) > 0) {
             foreach ($references as $reference_msg_id) {
                 //  -> check if the replied email exists in the database:
                 if (Note::exists($reference_msg_id)) {
                     // note exists
                     // get what issue it belongs too.
                     $issue_id = Note::getIssueByMessageID($reference_msg_id);
                     $should_create_issue = false;
                     $type = 'note';
                     $parent_id = Note::getIDByMessageID($reference_msg_id);
                     break;
                 } elseif (Support::exists($reference_msg_id) || Issue::getIssueByRootMessageID($reference_msg_id) != false) {
                     // email or issue exists
                     $issue_id = Support::getIssueByMessageID($reference_msg_id);
                     if (empty($issue_id)) {
                         $issue_id = Issue::getIssueByRootMessageID($reference_msg_id);
                     }
                     if (empty($issue_id)) {
                         // parent email isn't associated with issue.
                         //      --> create new issue, associate current email and replied email to this issue
                         $should_create_issue = true;
                         $associate_email = $reference_msg_id;
                     } else {
                         // parent email is associated with issue:
                         //      --> associate current email with existing issue
                         $should_create_issue = false;
                     }
                     break;
                 } else {
                     //  no matching note, email or issue:
                     //    => create new issue and associate current email with it
                     $should_create_issue = true;
                 }
             }
         } else {
             // - if this email is not a reply:
             //  -> create new issue and associate current email with it
             $should_create_issue = true;
         }
         if (empty($issue_id)) {
             $issue_id = Issue::getIssueBy($subject, 'iss_summary');
             if (!empty($issue_id)) {
                 $should_create_issue = false;
             }
         }
     }
     $sender_email = Mail_API::getEmailAddress($from);
     // only create a new issue if this email is coming from a known customer
     if ($should_create_issue && $info['ema_issue_auto_creation_options']['only_known_customers'] == 'yes' && Customer::hasCustomerIntegration($info['ema_prj_id'])) {
         list($customer_id, ) = Customer::getCustomerIDByEmails($info['ema_prj_id'], array($sender_email));
         if (empty($customer_id)) {
             $should_create_issue = false;
         }
     }
     // check whether we need to create a new issue or not
     if ($info['ema_issue_auto_creation'] == 'enabled' && $should_create_issue) {
         $options = Email_Account::getIssueAutoCreationOptions($info['ema_id']);
         Auth::createFakeCookie(APP_SYSTEM_USER_ID, $info['ema_prj_id']);
         $issue_id = Issue::createFromEmail($info['ema_prj_id'], APP_SYSTEM_USER_ID, $from, Mime_Helper::fixEncoding($subject), $message_body, @$options['category'], $options['priority'], @$options['users'], $date, $message_id);
         // associate any existing replied-to email with this new issue
         if (!empty($associate_email) && !empty($reference_issue_id)) {
             $reference_sup_id = Support::getIDByMessageID($associate_email);
             Support::associate(APP_SYSTEM_USER_ID, $issue_id, array($reference_sup_id));
         }
     }
     // need to check crm for customer association
     if (!empty($from)) {
         $details = Email_Account::getDetails($info['ema_id']);
         if (Customer::hasCustomerIntegration($info['ema_prj_id'])) {
             // check for any customer contact association
             @(list($customer_id, ) = Customer::getCustomerIDByEmails($info['ema_prj_id'], array($sender_email)));
         }
     }
     return array('should_create_issue' => $should_create_issue, 'associate_email' => $associate_email, 'issue_id' => $issue_id, 'customer_id' => @$customer_id, 'type' => $type, 'parent_id' => $parent_id);
 }
Exemple #14
0
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: João Prado Maia <*****@*****.**>                             |
// | Authors: Elan Ruusamäe <*****@*****.**>                               |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('close.tpl.html');
Auth::checkAuthentication(APP_COOKIE);
$usr_id = Auth::getUserID();
$prj_id = Auth::getCurrentProject();
$role_id = Auth::getCurrentRole();
$issue_id = isset($_POST['issue_id']) ? (int) $_POST['issue_id'] : (isset($_GET['id']) ? (int) $_GET['id'] : null);
$tpl->assign('extra_title', "Close Issue #{$issue_id}");
$tpl->assign('user_prefs', Prefs::get($usr_id));
if (!Issue::exists($issue_id, false)) {
    $tpl->assign('no_issue', true);
    $tpl->displayTemplate();
    exit;
} elseif ($role_id == User::getRoleID('customer') || !Issue::canAccess($issue_id, $usr_id)) {
    $tpl->assign('auth_customer', 'denied');
    $tpl->displayTemplate();
    exit;
}
$details = Issue::getDetails($issue_id);
$notification_list = Notification::getSubscribers($issue_id, 'closed');
$tpl->assign('notification_list_all', $notification_list['all']);
$notification_list_internal = Notification::getSubscribers($issue_id, 'closed', User::getRoleID('Standard User'));
$tpl->assign('notification_list_internal', $notification_list_internal['all']);
$cat = isset($_REQUEST['cat']) ? (string) $_REQUEST['cat'] : null;
if ($cat == 'close') {
Exemple #15
0
 /**
  * @param int $p_publicationId
  *
  * @param int $p_languageId
  *
  * @param int $p_skipCache
  *
  *
  * @return mixed
  *      array of issue publication dates
  *      null if query does not match any issue
  */
 public static function GetPublicationDates($p_publicationId, $p_languageId, $p_skipCache = false)
 {
     global $g_ado_db;
     $queryStr = 'SELECT Number FROM Issues ' . 'WHERE IdPublication = ' . $p_publicationId . ' AND ' . 'IdLanguage = ' . $p_languageId . " AND Published = 'Y'";
     $rows = $g_ado_db->GetAll($queryStr);
     $dates = array();
     if (is_array($rows)) {
         foreach ($rows as $row) {
             $tmpObj = new Issue($p_publicationId, $p_languageId, $row['Number']);
             if ($tmpObj->exists()) {
                 $dates[] = $tmpObj->getPublicationDate();
             }
         }
     }
     if (empty($dates)) {
         return null;
     }
     return array_unique($dates);
 }
Exemple #16
0
    /**
     * Set the article workflow on issue status change. Articles to be
     * published with the issue will be published on article publish.
     * Published articles are set to "publish with issue" on issue
     * unpublish.
     *
     * @param int $p_publicationId
     * @param int $p_languageId
     * @param int $p_issueNo
     * @param int $p_publish
     */
    public static function OnIssuePublish($p_publicationId, $p_languageId,
    $p_issueNo, $p_publish = true)
    {
        global $g_ado_db;

        settype($p_publicationId, 'integer');
        settype($p_languageId, 'integer');
        settype($p_issueNo, 'integer');

        $issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo);
        if (!$issueObj->exists()) {
            return false;
        }

        if (($issueObj->isPublished() && $p_publish)
        || (!$issueObj->isPublished() && !$p_publish)) {
            return false;
        }

        $fromState = $p_publish ? 'M' : 'Y';
        $toState = $p_publish ? 'Y' : 'M';

        $sql = "UPDATE Articles SET Published = '$toState' WHERE "
        . "IdPublication = $p_publicationId AND IdLanguage = $p_languageId"
        . " AND NrIssue = $p_issueNo AND Published = '$fromState'";
        $res = $g_ado_db->Execute($sql);

        CampCache::singleton()->clear('user');
        if (CampTemplateCache::factory()) {
            CampTemplateCache::factory()->update(array(
                'language' => $p_languageId,
                'publication' => $p_publicationId,
                'issue' => $p_issueNo,
                'section' => null,
                'article' => null,
            ));
        }
        return $res;
    }
Exemple #17
0
 /**
  * Get consistency errors
  * @param Command $cmd
  * @return mixed[]
  */
 private function getConsistencyErrors(Command $cmd)
 {
     $consistencyErrors = array();
     // if null, array_merge fails !
     $cerrList = $cmd->getConsistencyErrors();
     if (count($cerrList) > 0) {
         foreach ($cerrList as $cerr) {
             if (!is_null($cerr->userId)) {
                 $user = UserCache::getInstance()->getUser($cerr->userId);
             } else {
                 $user = NULL;
             }
             if (Issue::exists($cerr->bugId)) {
                 $issue = IssueCache::getInstance()->getIssue($cerr->bugId);
                 $projName = $issue->getProjectName();
                 $summary = $issue->getSummary();
             } else {
                 $projName = '';
                 $summary = '';
             }
             $titleAttr = array(T_('Project') => $projName, T_('Summary') => $summary);
             $consistencyErrors[] = array('issueURL' => Tools::issueInfoURL($cerr->bugId, $titleAttr), 'issueStatus' => Constants::$statusNames[$cerr->status], 'user' => isset($user) ? $user->getName() : '', 'severity' => $cerr->getLiteralSeverity(), 'severityColor' => $cerr->getSeverityColor(), 'desc' => $cerr->desc);
         }
     }
     return $consistencyErrors;
 }
Exemple #18
0
    /**
     * Gets an issues list based on the given parameters.
     *
     * @param array $p_parameters
     *    An array of ComparisonOperation objects
     * @param string $p_order
     *    An array of columns and directions to order by
     * @param integer $p_start
     *    The record number to start the list
     * @param integer $p_limit
     *    The offset. How many records from $p_start will be retrieved.
     * @param integer $p_count
     *    The total count of the elements; this count is computed without
     *    applying the start ($p_start) and limit parameters ($p_limit)
     *
     * @return array $issuesList
     *    An array of Issue objects
     */
    public static function GetList(array $p_parameters, $p_order = null,
                                   $p_start = 0, $p_limit = 0, &$p_count, $p_skipCache = false)
    {
        global $g_ado_db;

        if (!$p_skipCache && CampCache::IsEnabled()) {
        	$paramsArray['parameters'] = serialize($p_parameters);
        	$paramsArray['order'] = (is_null($p_order)) ? 'null' : $p_order;
        	$paramsArray['start'] = $p_start;
        	$paramsArray['limit'] = $p_limit;
        	$cacheListObj = new CampCacheList($paramsArray, __METHOD__);
        	$issuesList = $cacheListObj->fetchFromCache();
        	if ($issuesList !== false && is_array($issuesList)) {
        		return $issuesList;
        	}
        }

        $hasPublicationId = false;
        $selectClauseObj = new SQLSelectClause();
        $countClauseObj = new SQLSelectClause();

        // sets the where conditions
        foreach ($p_parameters as $param) {
            $comparisonOperation = self::ProcessListParameters($param);
            if (empty($comparisonOperation)) {
                break;
            }
            if (strpos($comparisonOperation['left'], 'IdPublication') !== false) {
                $hasPublicationId = true;
            }

            $whereCondition = $comparisonOperation['left'] . ' '
                . $comparisonOperation['symbol'] . " '"
                . $g_ado_db->escape($comparisonOperation['right']) . "' ";
            $selectClauseObj->addWhere($whereCondition);
            $countClauseObj->addWhere($whereCondition);
        }

        // validates whether publication identifier was given
        if ($hasPublicationId == false) {
            CampTemplate::singleton()->trigger_error('missed parameter Publication '
                .'Identifier in statement list_topics');
            return;
        }

        // sets the columns to be fetched
        $tmpIssue = new Issue();
		$columnNames = $tmpIssue->getColumnNames(true);
        foreach ($columnNames as $columnName) {
            $selectClauseObj->addColumn($columnName);
        }
        $countClauseObj->addColumn('COUNT(*)');

        // sets the main table for the query
        $selectClauseObj->setTable($tmpIssue->getDbTableName());
        $countClauseObj->setTable($tmpIssue->getDbTableName());
        unset($tmpIssue);

        if (is_array($p_order)) {
            $order = Issue::ProcessListOrder($p_order);
            // sets the order condition if any
            foreach ($order as $orderDesc) {
                $orderField = $orderDesc['field'];
                $orderDirection = $orderDesc['dir'];
                $selectClauseObj->addOrderBy($orderField . ' ' . $orderDirection);
            }
        }

        $selectClauseObj->addGroupField('Number');
        $selectClauseObj->addGroupField('IdLanguage');

        // sets the limit
        $selectClauseObj->setLimit($p_start, $p_limit);

        // builds the query and executes it
        $selectQuery = $selectClauseObj->buildQuery();
        $countQuery = $countClauseObj->buildQuery();
        $issues = $g_ado_db->GetAll($selectQuery);
        if (is_array($issues)) {
        	$p_count = $g_ado_db->GetOne($countQuery);

        	// builds the array of issue objects
        	$issuesList = array();
        	foreach ($issues as $issue) {
        		$issObj = new Issue($issue['IdPublication'],
        		$issue['IdLanguage'],
        		$issue['Number']);
        		if ($issObj->exists()) {
        			$issuesList[] = $issObj;
        		}
        	}
        } else {
        	$issuesList = array();
        	$p_count = 0;
        }
        if (!$p_skipCache && CampCache::IsEnabled()) {
        	$cacheListObj->storeInCache($issuesList);
        }

        return $issuesList;
    } // fn GetList
$f_src_section_number = Input::Get('f_src_section_number', 'int', 0);
$f_language_id = Input::Get('f_language_id', 'int', 0);
$f_dest_publication_id = Input::Get('f_dest_publication_id', 'int', 0);
$f_dest_issue_number = Input::Get('f_dest_issue_number', 'int', 0);
$f_dest_section_number = Input::Get('f_dest_section_number', 'int', 0);
if (!Input::IsValid()) {
    camp_html_display_error($translator->trans('Invalid input: $1', array('$1' => Input::GetErrorString())));
    exit;
}
$srcPublicationObj = new Publication($f_src_publication_id);
if (!$srcPublicationObj->exists()) {
    camp_html_display_error($translator->trans('Publication does not exist.'));
    exit;
}
$srcIssueObj = new Issue($f_src_publication_id, $f_language_id, $f_src_issue_number);
if (!$srcIssueObj->exists()) {
    camp_html_display_error($translator->trans('Issue does not exist.'));
    exit;
}
$srcSectionObj = new Section($f_src_publication_id, $f_src_issue_number, $f_language_id, $f_src_section_number);
if (!$srcSectionObj->exists()) {
    camp_html_display_error($translator->trans('Section does not exist.'));
    exit;
}
$dstPublicationObj = new Publication($f_dest_publication_id);
$dstIssueObj = new Issue($f_dest_publication_id, $f_language_id, $f_dest_issue_number);
$dstSectionObj = new Section($f_dest_publication_id, $f_dest_issue_number, $f_language_id, $f_dest_section_number);
$topArray = array('Pub' => $srcPublicationObj, 'Issue' => $srcIssueObj, 'Section' => $srcSectionObj);
camp_html_content_top($translator->trans('Duplicating section', array(), 'sections'), $topArray);
?>
<P>
Exemple #20
0
 /**
  *
  * @param boolean $hasDetail if true, add [Progress, EffortEstim, Elapsed, Backlog, Drift]
  * @param boolean $isManager
  * @param int $userid
  * @return array
  */
 public function getDynatreeData($hasDetail = false, $isManager = false, $teamid = 0)
 {
     // TODO AND root_id = $this->getRootId()
     $query = "SELECT * FROM `codev_wbs_table` WHERE `parent_id` = " . $this->getId() . " ORDER BY `order`";
     $result = SqlWrapper::getInstance()->sql_query($query);
     //file_put_contents('/tmp/loadWBS.txt', "$query \n", FILE_APPEND);
     if ($result) {
         $parentArray = array();
         while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
             $wbselement = new WBSElement($row->id, $this->getRootId());
             $childArray = array();
             if ($wbselement->isFolder()) {
                 $childArray['isFolder'] = true;
                 $childArray['expand'] = $wbselement->isExpand();
                 $childArray['key'] = $wbselement->getId();
                 $detail = '';
                 if ($hasDetail) {
                     $bugids = $this->getBugidList($wbselement->getId());
                     $isel = new IssueSelection("wbs_" . $wbselement->getId());
                     foreach ($bugids as $bugid) {
                         try {
                             $isel->addIssue($bugid);
                         } catch (Exception $e) {
                             self::$logger->error("Issue {$bugid} does not exist in Mantis DB.");
                         }
                     }
                     if ($isManager) {
                         $effortEstim = $isel->getMgrEffortEstim();
                         $driftInfo = $isel->getDriftMgr();
                         $reestimated = $isel->getReestimated();
                     } else {
                         $effortEstim = $isel->getEffortEstim();
                         $driftInfo = $isel->getDrift();
                         $reestimated = '0';
                     }
                     $detail = '~' . round(100 * $isel->getProgress()) . '~' . $effortEstim . '~' . $reestimated . '~' . $isel->getElapsed() . '~' . $isel->duration . '~' . $driftInfo['nbDays'] . '~' . $isel->getDriftColor($driftInfo['nbDays']);
                 }
                 $childArray['title'] = $wbselement->getTitle() . $detail;
                 $childArray['children'] = $wbselement->getDynatreeData($hasDetail, $isManager, $teamid);
             } else {
                 try {
                     // avoid logging an exception...
                     if (!Issue::exists($wbselement->getBugId())) {
                         $e = new Exception("Issue with id=" . $wbselement->getBugId() . " not found.");
                         throw $e;
                     }
                     $issue = IssueCache::getInstance()->getIssue($wbselement->getBugId());
                     $detail = '';
                     if ($hasDetail) {
                         if ($isManager) {
                             $effortEstim = $issue->getMgrEffortEstim();
                             $drift = $issue->getDriftMgr();
                             $reestimated = $issue->getReestimated();
                         } else {
                             $effortEstim = $issue->getEffortEstim();
                             $drift = $issue->getDrift();
                             $reestimated = '0';
                         }
                         $detail = '~' . round(100 * $issue->getProgress()) . '~' . $effortEstim . '~' . $reestimated . '~' . $issue->getElapsed() . '~' . $issue->getBacklog() . '~' . $drift . '~' . $issue->getDriftColor($drift);
                     }
                     $formattedSummary = '<b>' . $issue->getId() . '</b> ' . $issue->getSummary();
                     //                  if ($hasDetail) {
                     //                     mb_internal_encoding("UTF-8");
                     //                     $formattedSummary = mb_strimwidth($formattedSummary, 0, 70, "...");
                     //                  }
                     $childArray['title'] = $formattedSummary . $detail;
                     $childArray['isFolder'] = false;
                     $childArray['key'] = $issue->getId();
                     // yes, bugid !
                     // add tooltip
                     $user = UserCache::getInstance()->getUser($issue->getHandlerId());
                     $titleAttr = array(T_('Project') => $issue->getProjectName(), T_('Category') => $issue->getCategoryName(), T_('Status') => Constants::$statusNames[$issue->getStatus()], T_('Assigned to') => $user->getRealname(), T_('Tags') => implode(',', $issue->getTagList()));
                     $childArray['href'] = Constants::$codevURL . '/reports/issue_info.php?bugid=' . $issue->getId();
                     #$childArray['htmlTooltip'] = Tools::getTooltip($issue->getTooltipItems($teamid, 0, $isManager));
                     $childArray['htmlTooltip'] = Tools::getTooltip($titleAttr);
                     #$childArray['icon'] = 'mantis_ico.gif';
                 } catch (Exception $e) {
                     //$childArray['title'] = $wbselement->getBugId().' - '.T_('Error: Task not found in Mantis DB !');
                     //$childArray['isFolder'] = false;
                     self::$logger->warn("Issue {$bugid} does not exist in Mantis DB: calling checkWBS()");
                     $childArray = array();
                     // remove from WBS
                     self::checkWBS();
                 }
             }
             if (sizeof($childArray) > 0) {
                 array_push($parentArray, $childArray);
             }
         }
         // root element not only has children !
         if ($this->id === $this->getRootId()) {
             $detail = '';
             if ($hasDetail) {
                 $bugids = $this->getBugidList($this->id);
                 $isel = new IssueSelection("wbs_" . $this->id);
                 foreach ($bugids as $bugid) {
                     try {
                         $isel->addIssue($bugid);
                     } catch (Exception $e) {
                         self::$logger->error("Issue {$bugid} does not exist in Mantis DB.");
                     }
                 }
                 if ($isManager) {
                     $effortEstim = $isel->getMgrEffortEstim();
                     $driftInfo = $isel->getDriftMgr();
                     $reestimated = $isel->getReestimated();
                 } else {
                     $effortEstim = $isel->getEffortEstim();
                     $driftInfo = $isel->getDrift();
                     $reestimated = '0';
                 }
                 $mgrDriftInfo = $isel->getDriftMgr();
                 $detail = '~' . round(100 * $isel->getProgress()) . '~' . $effortEstim . '~' . $reestimated . '~' . $isel->getElapsed() . '~' . $isel->duration . '~' . $driftInfo['nbDays'] . '~' . $isel->getDriftColor($driftInfo['nbDays']);
             }
             $rootArray = array('title' => $this->getTitle() . $detail, 'isFolder' => true, 'expand' => $this->isExpand(), 'key' => $this->getId(), 'children' => $parentArray);
             return $rootArray;
         } else {
             return $parentArray;
         }
     } else {
         self::$logger->error("Query failed!");
     }
 }