예제 #1
0
 /**
  * PHPWS_Email has a built-in simple logging function.  This replicates
  * the functionality of that function for SwiftMail.
  */
 public static function logSwiftmailMessage(Swift_Message $message)
 {
     $id = 'id:' . $message->getId();
     $from = 'from:' . $message->getSender();
     $to = 'to:' . implode(',', array_keys($message->getTo()));
     // Optional fields, If the message has them, implode the arrays to simple strings.
     $cc = $message->getCc() != null ? 'cc:' . implode(',', array_keys($message->getCc())) : '';
     $bcc = $message->getBcc() != null ? 'bcc:' . implode(',', array_keys($message->getBcc())) : '';
     $replyto = $message->getReplyTo() != null ? 'reply-to:' . implode(',', array_keys($message->getReplyTo())) : '';
     $subject = 'subject:' . $message->getSubject();
     $module = 'module:' . PHPWS_Core::getCurrentModule();
     $user = '******' . (Current_User::isLogged() ? Current_User::getUsername() : '');
     PHPWS_Core::log("{$id} {$module} {$user} {$subject} {$from} {$to} {$cc} {$bcc} {$replyto}", 'phpws-mail.log', 'mail');
 }
예제 #2
0
 public static function display($content = null, $current_tab = null)
 {
     self::deleteLinksAdmin();
     Layout::addStyle('controlpanel');
     $panel = new PHPWS_Panel('controlpanel');
     $panel->disableSecure();
     $current_mod = PHPWS_Core::getCurrentModule();
     $checkTabs = PHPWS_ControlPanel::loadTabs();
     $panel->setTabs($checkTabs);
     $allLinks = PHPWS_ControlPanel::getAllLinks();
     if (empty($checkTabs)) {
         PHPWS_Error::log(CP_NO_TABS, 'controlpanel', 'display');
         PHPWS_ControlPanel::makeDefaultTabs();
         PHPWS_ControlPanel::reset();
         PHPWS_Core::errorPage();
         exit;
     }
     $defaultTabs = PHPWS_ControlPanel::getDefaultTabs();
     foreach ($defaultTabs as $tempTab) {
         $tabList[] = $tempTab['id'];
     }
     if (!empty($allLinks)) {
         $links = array_keys($allLinks);
         if ($current_mod != 'controlpanel' && !$current_tab) {
             foreach ($allLinks as $key => $tablinks) {
                 foreach ($tablinks as $link) {
                     if ($link->itemname == $current_mod) {
                         $current_tab = $key;
                         break 2;
                     }
                 }
             }
         }
     }
     foreach ($checkTabs as $tab) {
         if ($tab->getItemname() == 'controlpanel' && in_array($tab->id, $tabList) && (!isset($links) || !in_array($tab->id, $links))) {
             $panel->dropTab($tab->id);
         }
     }
     if (empty($panel->tabs)) {
         return dgettext('controlpanel', 'No tabs available in the Control Panel.');
     }
     if (!isset($content) && $current_mod == 'controlpanel') {
         if (isset($allLinks[$panel->getCurrentTab()])) {
             foreach ($allLinks[$panel->getCurrentTab()] as $id => $link) {
                 $link_content[] = $link->view();
             }
             $link_content = PHPWS_Template::process(array('LINKS' => implode('', $link_content)), 'controlpanel', 'links.tpl');
             $panel->setContent($link_content);
         }
     } else {
         $panel->setContent($content);
     }
     if (isset($current_tab)) {
         $panel->setCurrentTab($current_tab);
     }
     if (!isset($panel->tabs[$panel->getCurrentTab()])) {
         return dgettext('controlpanel', 'An error occurred while accessing the Control Panel.');
     }
     $tab = $panel->tabs[$panel->getCurrentTab()];
     $link = str_replace('&', '&', $tab->getLink(false)) . '&tab=' . $tab->id;
     $current_link = str_replace($_SERVER['PHP_SELF'] . '\\?', '', $_SERVER['REQUEST_URI']);
     // Headers to the tab's link if it is not a control panel
     // link tab.
     if (isset($_REQUEST['command']) && $_REQUEST['command'] == 'panel_view' && !preg_match('/controlpanel/', $link) && $link != $current_link) {
         PHPWS_Core::reroute($link);
     }
     return $panel->display();
 }
예제 #3
0
<?php

/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
// Destroy unused sessions
if (PHPWS_Core::getCurrentModule() != 'users') {
    PHPWS_Core::killSession('Member_Pager');
    PHPWS_Core::killSession('All_Demo');
    PHPWS_Core::killSession('User_Manager');
    PHPWS_Core::killSession('Group_Manager');
}
Current_User::permissionMenu();
예제 #4
0
 protected static function log($to, $headers, $result)
 {
     $id = 'id:' . $headers['Message-Id'];
     $from = 'from:' . (isset($headers['From']) ? $headers['From'] : '');
     $to = 'to:' . $to;
     $cc = 'cc:' . (isset($headers['Cc']) ? $headers['Cc'] : '');
     $bcc = 'bcc:' . (isset($headers['Bcc']) ? $headers['Bcc'] : '');
     $replyto = 'reply-to:' . (isset($headers['Reply-To']) ? $headers['Reply-To'] : '');
     $subject = 'subject:' . (isset($headers['Subject']) ? $headers['Subject'] : '');
     $module = 'module:' . PHPWS_Core::getCurrentModule();
     $user = '******' . (Current_User::isLogged() ? Current_User::getUsername() : '');
     $result = 'result:' . (PHPWS_Error::isError($result) ? 'Failure' : 'Success');
     PHPWS_Core::log("{$id} {$module} {$user} {$subject} {$from} {$to} {$cc} {$bcc} {$replyto} {$result}", 'phpws-mail.log', 'mail');
 }