コード例 #1
0
 /**
  * Send the notification mail, about an event
  *
  * @return boolean
  */
 function handleNotification()
 {
     global $art_field_fact;
     $logger = new TrackerDateReminder_Logger_Prefix($this->logger, '[handleNotification]');
     $logger->info("Start");
     $group = ProjectManager::instance()->getProject($this->getGroupId());
     $at = new ArtifactType($group, $this->getGroupArtifactId());
     $art_field_fact = new ArtifactFieldFactory($at);
     $field = $art_field_fact->getFieldFromId($this->getFieldId());
     $art = new Artifact($at, $this->getArtifactId(), false);
     $logger->info("tracker: " . $this->getGroupArtifactId());
     $logger->info("artifact: " . $this->getArtifactId());
     $sent = true;
     $week = date("W", $this->getDateValue());
     $mail = new Mail();
     $mail->setFrom($GLOBALS['sys_noreply']);
     $mail->setSubject("[" . $this->getTrackerName() . "] " . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_subject', array($field->getLabel(), date("j F Y", $this->getDateValue()), $art->getSummary())));
     $body = "\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_header', array($field->getLabel(), date("l j F Y", $this->getDateValue()), $week)) . "\n\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_project', array($group->getPublicName())) . "\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_tracker', array($this->getTrackerName())) . "\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_art', array($art->getSummary())) . "\n" . $field->getLabel() . ": " . date("D j F Y", $this->getDateValue()) . "\n\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_body_art_link') . "\n" . get_server_url() . "/tracker/?func=detail&aid=" . $this->getArtifactId() . "&atid=" . $this->getGroupArtifactId() . "&group_id=" . $this->getGroupId() . "\n\n______________________________________________________________________" . "\n" . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_mail_footer') . "\n";
     $mail->setBody($body);
     $allNotified = $this->getNotifiedPeople();
     $logger->info("notify: " . implode(', ', $allNotified));
     foreach ($allNotified as $notified) {
         $mail->setTo($notified);
         if (!$mail->send()) {
             $logger->error("faild to notify {$notified}");
             $sent = false;
         }
     }
     $logger->info("End");
     return $sent;
 }
コード例 #2
0
ファイル: permissions.php プロジェクト: pombredanne/tuleap
/**
 * Return the name of a given object
 */
function permission_get_object_name($permission_type, $object_id)
{
    global $Language, $group_id;
    $pm = ProjectManager::instance();
    if ($permission_type == 'NEWS_READ') {
        return get_news_name_from_forum_id($object_id);
    } else {
        if ($permission_type == 'PACKAGE_READ') {
            return file_get_package_name_from_id($object_id);
        } else {
            if ($permission_type == 'RELEASE_READ') {
                return file_get_release_name_from_id($object_id);
            } else {
                if ($permission_type == 'DOCUMENT_READ') {
                    return util_unconvert_htmlspecialchars(doc_get_title_from_id($object_id));
                } else {
                    if ($permission_type == 'DOCGROUP_READ') {
                        return doc_get_docgroupname_from_id($object_id);
                    } else {
                        if ($permission_type == 'WIKI_READ') {
                            return $Language->getText('project_admin_permissions', 'wiki');
                        } else {
                            if ($permission_type == 'WIKIPAGE_READ') {
                                #$wikipage= new WikiPage($object_id);
                                #return $wikipage->getPagename();
                                return "{$object_id}";
                            } else {
                                if ($permission_type == 'WIKIATTACHMENT_READ') {
                                    return $Language->getText('project_admin_permissions', 'wikiattachment');
                                } else {
                                    if (strpos($permission_type, 'TRACKER_ACCESS') === 0) {
                                        $group = $pm->getProject($group_id);
                                        $at = new ArtifactType($group, $object_id);
                                        return $at->getName();
                                    } else {
                                        if (strpos($permission_type, 'TRACKER_FIELD') === 0) {
                                            $ret = "{$object_id}";
                                            if ($group = $pm->getProject($group_id)) {
                                                $atid = permission_extract_atid($object_id);
                                                $at = new ArtifactType($group, $atid);
                                                $ret = $at->getName();
                                                if ($ath = new ArtifactTypeHtml($group, $atid)) {
                                                    if ($art_field_fact = new ArtifactFieldFactory($ath)) {
                                                        $field_id = permission_extract_field_id($object_id);
                                                        if ($field = $art_field_fact->getFieldFromId($field_id)) {
                                                            $ret = $field->getName() . ' (' . $ret . ')';
                                                        }
                                                    }
                                                }
                                            }
                                            return $ret;
                                        } else {
                                            if ($permission_type == 'TRACKER_ARTIFACT_ACCESS') {
                                                $ret = $object_id;
                                                $sql = "SELECT group_artifact_id FROM artifact WHERE artifact_id= " . db_ei($object_id);
                                                $result = db_query($sql);
                                                if (db_numrows($result) > 0) {
                                                    $row = db_fetch_array($result);
                                                    $atid = $row['group_artifact_id'];
                                                }
                                                $group = $pm->getProject($group_id);
                                                $at = new ArtifactType($group, $atid);
                                                $a = new Artifact($at, $object_id);
                                                return 'art #' . $a->getId() . ' - ' . util_unconvert_htmlspecialchars($a->getSummary());
                                            } else {
                                                $em =& EventManager::instance();
                                                $object_name = false;
                                                $em->processEvent('permission_get_object_name', array('permission_type' => $permission_type, 'object_id' => $object_id, 'object_name' => &$object_name));
                                                return $object_name ? $object_name : $object_id;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}