Esempio n. 1
0
 function configure()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(dirname(dirname(__FILE__)))) . '/templates/';
     $sHomeHtml = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_HOME_HTML, '');
     $tpl->assign('home_html', $sHomeHtml);
     $tpl->display("file:{$tpl_path}portal/sc/config/module/home.tpl");
 }
Esempio n. 2
0
 function configure()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(dirname(dirname(__FILE__)))) . '/templates/';
     $sNewsRss = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_NEWS_RSS, '');
     $news_rss = !empty($sNewsRss) ? unserialize($sNewsRss) : array();
     $tpl->assign('news_rss', $news_rss);
     $tpl->display("file:{$tpl_path}portal/sc/config/module/announcements.tpl");
 }
Esempio n. 3
0
 function configure(Model_CommunityTool $instance)
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(dirname(__FILE__))) . '/templates/';
     // F&R
     $fnr_topics = DAO_FnrTopic::getWhere();
     $tpl->assign('fnr_topics', $fnr_topics);
     $sFnrTopics = DAO_CommunityToolProperty::get($instance->code, self::PARAM_FNR_TOPICS, '');
     $fnr_topics = !empty($sFnrTopics) ? unserialize($sFnrTopics) : array();
     $tpl->assign('enabled_topics', $fnr_topics);
     $tpl->display("file:{$tpl_path}portal/sc/config/resources.tpl");
 }
Esempio n. 4
0
 function configure()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(dirname(__FILE__))) . '/templates/';
     //		$require_login = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(),self::PARAM_REQUIRE_LOGIN, 0);
     //		$tpl->assign('kb_require_login', $require_login);
     // F&R
     $fnr_topics = DAO_FnrTopic::getWhere();
     $tpl->assign('fnr_topics', $fnr_topics);
     $sFnrTopics = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_FNR_TOPICS, '');
     $fnr_topics = !empty($sFnrTopics) ? unserialize($sFnrTopics) : array();
     $tpl->assign('enabled_topics', $fnr_topics);
     $tpl->display("file:{$tpl_path}portal/sc/config/resources.tpl");
 }
Esempio n. 5
0
 function doLogout()
 {
     // [TODO] Fall back
     $login_handler = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_LOGIN_HANDLER, 'sc.login.auth.default');
     if (null != ($handler = DevblocksPlatform::getExtension($login_handler, true))) {
         if ($handler->signoff()) {
             // ...
         }
     }
     DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', UmPortalHelper::getCode())));
 }
Esempio n. 6
0
File: kb.php Progetto: Hildy/cerb5
 function configure(Model_CommunityTool $instance)
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(dirname(__FILE__))) . '/templates/';
     // Knowledgebase
     $tree_map = DAO_KbCategory::getTreeMap();
     $tpl->assign('tree_map', $tree_map);
     $levels = DAO_KbCategory::getTree(0);
     $tpl->assign('levels', $levels);
     $categories = DAO_KbCategory::getWhere();
     $tpl->assign('categories', $categories);
     $sKbRoots = DAO_CommunityToolProperty::get($instance->code, self::PARAM_KB_ROOTS, '');
     $kb_roots = !empty($sKbRoots) ? unserialize($sKbRoots) : array();
     $tpl->assign('kb_roots', $kb_roots);
     $tpl->display("file:{$tpl_path}portal/sc/config/kb.tpl");
 }
Esempio n. 7
0
 function writeResponse(DevblocksHttpResponse $response)
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(__FILE__)) . '/templates/';
     $theme = DAO_CommunityToolProperty::get($this->getPortal(), UmScApp::PARAM_THEME, UmScApp::DEFAULT_THEME);
     if (!is_dir($tpl_path . 'portal/sc/themes/' . $theme)) {
         $theme = UmScApp::DEFAULT_THEME;
     }
     $umsession = $this->getSession();
     $active_user = $umsession->getProperty('sc_login', null);
     $stack = $response->path;
     @($module = array_shift($stack));
     switch ($module) {
         default:
         case 'home':
             $sHomeRss = DAO_CommunityToolProperty::get($this->getPortal(), UmScApp::PARAM_HOME_RSS, '');
             $aHomeRss = !empty($sHomeRss) ? unserialize($sHomeRss) : array();
             $feeds = array();
             // [TODO] Implement a feed cache so we aren't bombing out
             foreach ($aHomeRss as $title => $url) {
                 $feed = null;
                 try {
                     $feed = Zend_Feed::import($url);
                 } catch (Exception $e) {
                 }
                 if (!empty($feed) && $feed->count()) {
                     $feeds[] = array('name' => $title, 'feed' => $feed);
                 }
             }
             $tpl->assign('feeds', $feeds);
             $tpl->display("file:{$tpl_path}portal/sc/internal/home/index.tpl");
             break;
         case 'account':
             if (!$this->allow_logins || empty($active_user)) {
                 break;
             }
             $address = DAO_Address::get($active_user->id);
             $tpl->assign('address', $address);
             $tpl->display("file:{$tpl_path}portal/sc/internal/account/index.tpl");
             break;
         case 'kb':
             // KB Roots
             $sKbRoots = DAO_CommunityToolProperty::get($this->getPortal(), UmScApp::PARAM_KB_ROOTS, '');
             $kb_roots = !empty($sKbRoots) ? unserialize($sKbRoots) : array();
             $kb_roots_str = '0';
             if (!empty($kb_roots)) {
                 $kb_roots_str = implode(',', array_keys($kb_roots));
             }
             switch (array_shift($stack)) {
                 case 'article':
                     if (empty($kb_roots)) {
                         return;
                     }
                     $id = intval(array_shift($stack));
                     list($articles, $count) = DAO_KbArticle::search(array(new DevblocksSearchCriteria(SearchFields_KbArticle::ID, '=', $id), new DevblocksSearchCriteria(SearchFields_KbArticle::TOP_CATEGORY_ID, 'in', array_keys($kb_roots))), -1, 0, null, null, false);
                     if (!isset($articles[$id])) {
                         break;
                     }
                     $article = DAO_KbArticle::get($id);
                     $tpl->assign('article', $article);
                     @($article_list = $umsession->getProperty(UmScApp::SESSION_ARTICLE_LIST, array()));
                     if (!empty($article) && !isset($article_list[$id])) {
                         DAO_KbArticle::update($article->id, array(DAO_KbArticle::VIEWS => ++$article->views));
                         $article_list[$id] = $id;
                         $umsession->setProperty(UmScApp::SESSION_ARTICLE_LIST, $article_list);
                     }
                     $categories = DAO_KbCategory::getWhere();
                     $tpl->assign('categories', $categories);
                     $cats = DAO_KbArticle::getCategoriesByArticleId($id);
                     $breadcrumbs = array();
                     foreach ($cats as $cat_id) {
                         if (!isset($breadcrumbs[$cat_id])) {
                             $breadcrumbs[$cat_id] = array();
                         }
                         $pid = $cat_id;
                         while ($pid) {
                             $breadcrumbs[$cat_id][] = $pid;
                             $pid = $categories[$pid]->parent_id;
                         }
                         $breadcrumbs[$cat_id] = array_reverse($breadcrumbs[$cat_id]);
                         // Remove any breadcrumbs not in this SC profile
                         $pid = reset($breadcrumbs[$cat_id]);
                         if (!isset($kb_roots[$pid])) {
                             unset($breadcrumbs[$cat_id]);
                         }
                     }
                     $tpl->assign('breadcrumbs', $breadcrumbs);
                     $tpl->display("file:{$tpl_path}portal/sc/internal/kb/article.tpl");
                     break;
                 default:
                 case 'browse':
                     @($root = intval(array_shift($stack)));
                     $tpl->assign('root_id', $root);
                     $categories = DAO_KbCategory::getWhere();
                     $tpl->assign('categories', $categories);
                     $tree_map = DAO_KbCategory::getTreeMap(0);
                     // Remove other top-level categories
                     if (is_array($tree_map[0])) {
                         foreach ($tree_map[0] as $child_id => $count) {
                             if (!isset($kb_roots[$child_id])) {
                                 unset($tree_map[0][$child_id]);
                             }
                         }
                     }
                     // Remove empty categories
                     if (is_array($tree_map[0])) {
                         foreach ($tree_map as $node_id => $children) {
                             foreach ($children as $child_id => $count) {
                                 if (empty($count)) {
                                     @($pid = $categories[$child_id]->parent_id);
                                     unset($tree_map[$pid][$child_id]);
                                     unset($tree_map[$child_id]);
                                 }
                             }
                         }
                     }
                     $tpl->assign('tree', $tree_map);
                     // Breadcrumb // [TODO] API-ize inside Model_KbTree ?
                     $breadcrumb = array();
                     $pid = $root;
                     while (0 != $pid) {
                         $breadcrumb[] = $pid;
                         $pid = $categories[$pid]->parent_id;
                     }
                     $tpl->assign('breadcrumb', array_reverse($breadcrumb));
                     $tpl->assign('mid', @intval(ceil(count($tree_map[$root]) / 2)));
                     // Articles
                     if (!empty($root)) {
                         list($articles, $count) = DAO_KbArticle::search(array(new DevblocksSearchCriteria(SearchFields_KbArticle::CATEGORY_ID, '=', $root), new DevblocksSearchCriteria(SearchFields_KbArticle::TOP_CATEGORY_ID, 'in', array_keys($kb_roots))), -1, 0, null, null, false);
                     }
                     $tpl->assign('articles', $articles);
                     $tpl->display("file:{$tpl_path}portal/sc/internal/kb/index.tpl");
                     break;
             }
             break;
         case 'answers':
             $query = rawurldecode(array_shift($stack));
             $tpl->assign('query', $query);
             $sFnrSources = DAO_CommunityToolProperty::get($this->getPortal(), UmScApp::PARAM_FNR_SOURCES, '');
             $aFnrSources = !empty($sFnrSources) ? unserialize($sFnrSources) : array();
             if (!empty($query)) {
                 // [JAS]: If we've been customized with specific sources, use them
                 $where = !empty($aFnrSources) ? sprintf("%s IN (%s)", DAO_FnrExternalResource::ID, implode(',', array_keys($aFnrSources))) : sprintf("%s IN (-1)", DAO_FnrExternalResource::ID);
                 $resources = DAO_FnrExternalResource::getWhere($where);
                 $feeds = Model_FnrExternalResource::searchResources($resources, $query);
                 $tpl->assign('feeds', $feeds);
                 $fields = array(DAO_FnrQuery::QUERY => $query, DAO_FnrQuery::CREATED => time(), DAO_FnrQuery::SOURCE => $this->getPortal(), DAO_FnrQuery::NO_MATCH => empty($feeds) ? 1 : 0);
                 DAO_FnrQuery::create($fields);
             }
             // KB
             $sKbRoots = DAO_CommunityToolProperty::get($this->getPortal(), UmScApp::PARAM_KB_ROOTS, '');
             $kb_roots = !empty($sKbRoots) ? unserialize($sKbRoots) : array();
             list($articles, $count) = DAO_KbArticle::search(array(array(DevblocksSearchCriteria::GROUP_OR, new DevblocksSearchCriteria(SearchFields_KbArticle::TITLE, 'fulltext', $query), new DevblocksSearchCriteria(SearchFields_KbArticle::CONTENT, 'fulltext', $query)), new DevblocksSearchCriteria(SearchFields_KbArticle::TOP_CATEGORY_ID, 'in', array_keys($kb_roots))), 100, 0, null, null, true);
             $tpl->assign('articles', $articles);
             $tpl->display("file:{$tpl_path}portal/sc/internal/answers/index.tpl");
             break;
         case 'contact':
             $response = array_shift($stack);
             $settings = CerberusSettings::getInstance();
             $default_from = $settings->get(CerberusSettings::DEFAULT_REPLY_FROM);
             $tpl->assign('default_from', $default_from);
             switch ($response) {
                 case 'confirm':
                     $tpl->assign('last_opened', $umsession->getProperty('support.write.last_opened', ''));
                     $tpl->display("file:{$tpl_path}portal/sc/internal/contact/confirm.tpl");
                     break;
                 default:
                 case 'step1':
                     $umsession->setProperty('support.write.last_error', null);
                 case 'step2':
                     $sFrom = $umsession->getProperty('support.write.last_from', '');
                     $sSubject = $umsession->getProperty('support.write.last_subject', '');
                     $sNature = $umsession->getProperty('support.write.last_nature', '');
                     $sContent = $umsession->getProperty('support.write.last_content', '');
                     //		    			$aLastFollowupQ = $umsession->getProperty('support.write.last_followup_q','');
                     $aLastFollowupA = $umsession->getProperty('support.write.last_followup_a', '');
                     $sError = $umsession->getProperty('support.write.last_error', '');
                     $tpl->assign('last_from', $sFrom);
                     $tpl->assign('last_subject', $sSubject);
                     $tpl->assign('last_nature', $sNature);
                     $tpl->assign('last_content', $sContent);
                     //						$tpl->assign('last_followup_q', $aLastFollowupQ);
                     $tpl->assign('last_followup_a', $aLastFollowupA);
                     $tpl->assign('last_error', $sError);
                     $sDispatch = DAO_CommunityToolProperty::get($this->getPortal(), UmScApp::PARAM_DISPATCH, '');
                     //		    			$dispatch = !empty($sDispatch) ? (is_array($sDispatch) ? unserialize($sDispatch): array($sDispatch)) : array();
                     $dispatch = !empty($sDispatch) ? unserialize($sDispatch) : array();
                     $tpl->assign('dispatch', $dispatch);
                     switch ($response) {
                         default:
                             // If there's only one situation, skip to step2
                             if (1 == count($dispatch)) {
                                 @($sNature = md5(key($dispatch)));
                                 $umsession->setProperty('support.write.last_nature', $sNature);
                                 reset($dispatch);
                             } else {
                                 $tpl->display("file:{$tpl_path}portal/sc/internal/contact/step1.tpl");
                                 break;
                             }
                         case 'step2':
                             // Cache along with answers?
                             if (is_array($dispatch)) {
                                 foreach ($dispatch as $k => $v) {
                                     if (md5($k) == $sNature) {
                                         $umsession->setProperty('support.write.last_nature_string', $k);
                                         $tpl->assign('situation', $k);
                                         $tpl->assign('situation_params', $v);
                                         break;
                                     }
                                 }
                             }
                             $ticket_fields = DAO_CustomField::getBySource('cerberusweb.fields.source.ticket');
                             $tpl->assign('ticket_fields', $ticket_fields);
                             $tpl->display("file:{$tpl_path}portal/sc/internal/contact/step2.tpl");
                             break;
                     }
                     break;
             }
             break;
             //				$tpl->display("file:${tpl_path}portal/sc/internal/contact/index.tpl");
             //				break;
         //				$tpl->display("file:${tpl_path}portal/sc/internal/contact/index.tpl");
         //				break;
         case 'history':
             if (!$this->allow_logins || empty($active_user)) {
                 break;
             }
             $mask = array_shift($stack);
             if (empty($mask)) {
                 list($open_tickets) = DAO_Ticket::search(array(), array(new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_FIRST_WROTE_ID, '=', $active_user->id), new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CLOSED, '=', 0)), -1, 0, SearchFields_Ticket::TICKET_UPDATED_DATE, false, false);
                 $tpl->assign('open_tickets', $open_tickets);
                 list($closed_tickets) = DAO_Ticket::search(array(), array(new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_FIRST_WROTE_ID, '=', $active_user->id), new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CLOSED, '=', 1)), -1, 0, SearchFields_Ticket::TICKET_UPDATED_DATE, false, false);
                 $tpl->assign('closed_tickets', $closed_tickets);
                 $tpl->display("file:{$tpl_path}portal/sc/internal/history/index.tpl");
             } else {
                 // Secure retrieval (address + mask)
                 list($tickets) = DAO_Ticket::search(array(), array(new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_MASK, '=', $mask), new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_FIRST_WROTE_ID, '=', $active_user->id)), 1, 0, null, null, false);
                 $ticket = array_shift($tickets);
                 // Security check (mask compare)
                 if (0 == strcasecmp($ticket[SearchFields_Ticket::TICKET_MASK], $mask)) {
                     $messages = DAO_Ticket::getMessagesByTicket($ticket[SearchFields_Ticket::TICKET_ID]);
                     $messages = array_reverse($messages, true);
                     $tpl->assign('ticket', $ticket);
                     $tpl->assign('messages', $messages);
                     $tpl->display("file:{$tpl_path}portal/sc/internal/history/display.tpl");
                 }
             }
             break;
         case 'register':
             if (!$this->allow_logins) {
                 break;
             }
             @($step = array_shift($stack));
             switch ($step) {
                 case 'forgot':
                     $tpl->display("file:{$tpl_path}portal/sc/internal/register/forgot.tpl");
                     break;
                 case 'forgot2':
                     $tpl->display("file:{$tpl_path}portal/sc/internal/register/forgot_confirm.tpl");
                     break;
                 case 'confirm':
                     $tpl->display("file:{$tpl_path}portal/sc/internal/register/confirm.tpl");
                     break;
                 default:
                     $tpl->display("file:{$tpl_path}portal/sc/internal/register/index.tpl");
                     break;
             }
             break;
     }
     //		print_r($response);
 }
Esempio n. 8
0
    private function _renderRecentChangesRss($portal)
    {
        header("Content-Type: text/xml");
        $xmlstr = <<<XML
\t\t<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'>
\t\t</rss>
XML;
        $xml = new SimpleXMLElement($xmlstr);
        $translate = DevblocksPlatform::getTranslationService();
        $url = DevblocksPlatform::getUrlService();
        // Portal details
        $portal_name = DAO_CommunityToolProperty::get($portal, UmScApp::PARAM_PAGE_TITLE, '');
        // Channel
        $channel = $xml->addChild('channel');
        $channel->addChild('title', (!empty($portal_name) ? '[' . $portal_name . '] ' : '') . "Recently Changed Articles");
        $channel->addChild('link', $url->write(sprintf('c=rss&kb=kb&a=recent_changes', $portal), true));
        $channel->addChild('description', '');
        // Limit topics to portal config
        @($topics = unserialize(DAO_CommunityToolProperty::get($portal, UmScKbController::PARAM_KB_ROOTS, '')));
        if (empty($topics)) {
            return;
        }
        // Search Results
        list($results, $null) = DAO_KbArticle::search(array(SearchFields_KbArticle::TOP_CATEGORY_ID => new DevblocksSearchCriteria(SearchFields_KbArticle::TOP_CATEGORY_ID, 'in', array_keys($topics))), 25, 0, SearchFields_KbArticle::UPDATED, false, false);
        // [TODO] We should probably be building this feed with Zend Framework for compliance
        foreach ($results as $article) {
            $created = intval($article[SearchFields_KbArticle::UPDATED]);
            if (empty($created)) {
                $created = time();
            }
            $eItem = $channel->addChild('item');
            $escapedSubject = htmlspecialchars($article[SearchFields_KbArticle::TITLE], null, LANG_CHARSET_CODE);
            //filter out a couple non-UTF-8 characters (0xC and ESC)
            $escapedSubject = preg_replace("/[\f]/", '', $escapedSubject);
            $eTitle = $eItem->addChild('title', $escapedSubject);
            $eDesc = $eItem->addChild('description', htmlspecialchars($article[SearchFields_KbArticle::CONTENT], null, LANG_CHARSET_CODE));
            $link = $url->write('c=kb&a=article&id=' . $article[SearchFields_KbArticle::ID], true);
            $eLink = $eItem->addChild('link', $link);
            $eDate = $eItem->addChild('pubDate', gmdate('D, d M Y H:i:s T', $created));
            $eGuid = $eItem->addChild('guid', md5($escapedSubject . $link . $created));
            $eGuid->addAttribute('isPermaLink', "false");
        }
        echo $xml->asXML();
    }
Esempio n. 9
0
 /**
  * @param $instance Model_CommunityTool 
  */
 public function configure(Model_CommunityTool $instance)
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(__FILE__) . '/templates/';
     $tpl->assign('config_path', $tpl_path);
     $base_url = DAO_CommunityToolProperty::get($this->getPortal(), self::PARAM_BASE_URL, '');
     $tpl->assign('base_url', $base_url);
     $logo_url = DAO_CommunityToolProperty::get($this->getPortal(), self::PARAM_LOGO_URL, '');
     $tpl->assign('logo_url', $logo_url);
     $page_title = DAO_CommunityToolProperty::get($this->getPortal(), self::PARAM_PAGE_TITLE, 'Knowledgebase');
     $tpl->assign('page_title', $page_title);
     $captcha_enabled = DAO_CommunityToolProperty::get($this->getPortal(), self::PARAM_CAPTCHA_ENABLED, 1);
     $tpl->assign('captcha_enabled', $captcha_enabled);
     // Roots
     $tree_map = DAO_KbCategory::getTreeMap();
     $tpl->assign('tree_map', $tree_map);
     $levels = DAO_KbCategory::getTree(0);
     $tpl->assign('levels', $levels);
     $categories = DAO_KbCategory::getWhere();
     $tpl->assign('categories', $categories);
     $sKbRoots = DAO_CommunityToolProperty::get($this->getPortal(), self::PARAM_KB_ROOTS, '');
     $kb_roots = !empty($sKbRoots) ? unserialize($sKbRoots) : array();
     $tpl->assign('kb_roots', $kb_roots);
     $tpl->display("file:{$tpl_path}portal/kb/config/index.tpl");
 }
Esempio n. 10
0
 function configure()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(dirname(__FILE__))) . '/templates/';
     $require_login = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_REQUIRE_LOGIN, 0);
     $tpl->assign('kb_require_login', $require_login);
     // Knowledgebase
     $tree_map = DAO_KbCategory::getTreeMap();
     $tpl->assign('tree_map', $tree_map);
     $levels = DAO_KbCategory::getTree(0);
     $tpl->assign('levels', $levels);
     $categories = DAO_KbCategory::getWhere();
     $tpl->assign('categories', $categories);
     $sKbRoots = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_KB_ROOTS, '');
     $kb_roots = !empty($sKbRoots) ? unserialize($sKbRoots) : array();
     $tpl->assign('kb_roots', $kb_roots);
     $tpl->display("file:{$tpl_path}portal/sc/config/kb.tpl");
 }
Esempio n. 11
0
 function doContactSendAction()
 {
     @($sFrom = DevblocksPlatform::importGPC($_POST['from'], 'string', ''));
     @($sSubject = DevblocksPlatform::importGPC($_POST['subject'], 'string', ''));
     @($sContent = DevblocksPlatform::importGPC($_POST['content'], 'string', ''));
     @($sCaptcha = DevblocksPlatform::importGPC($_POST['captcha'], 'string', ''));
     @($aFieldIds = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array()));
     @($aFollowUpQ = DevblocksPlatform::importGPC($_POST['followup_q'], 'array', array()));
     // Load the answers to any situational questions
     $aFollowUpA = array();
     if (is_array($aFollowUpQ)) {
         foreach ($aFollowUpQ as $idx => $q) {
             @($answer = DevblocksPlatform::importGPC($_POST['followup_a_' . $idx], 'string', ''));
             $aFollowUpA[$idx] = $answer;
         }
     }
     $umsession = UmPortalHelper::getSession();
     $fingerprint = UmPortalHelper::getFingerprint();
     $settings = CerberusSettings::getInstance();
     $default_from = $settings->get(CerberusSettings::DEFAULT_REPLY_FROM);
     $umsession->setProperty('support.write.last_from', $sFrom);
     $umsession->setProperty('support.write.last_subject', $sSubject);
     $umsession->setProperty('support.write.last_content', $sContent);
     //		$umsession->setProperty('support.write.last_followup_q',$aFollowUpQ);
     $umsession->setProperty('support.write.last_followup_a', $aFollowUpA);
     $sNature = $umsession->getProperty('support.write.last_nature', '');
     $captcha_enabled = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_CAPTCHA_ENABLED, 1);
     // Subject is required if the field  is on the form
     if (isset($_POST['subject']) && empty($sSubject)) {
         $umsession->setProperty('support.write.last_error', 'A subject is required.');
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', UmPortalHelper::getCode(), 'contact', 'step2')));
         return;
     }
     // Sender and CAPTCHA required
     if (empty($sFrom) || $captcha_enabled && 0 != strcasecmp($sCaptcha, @$umsession->getProperty(UmScApp::SESSION_CAPTCHA, '***'))) {
         if (empty($sFrom)) {
             $umsession->setProperty('support.write.last_error', 'Invalid e-mail address.');
         } else {
             $umsession->setProperty('support.write.last_error', 'What you typed did not match the image.');
         }
         // Need to report the captcha didn't match and redraw the form
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', UmPortalHelper::getCode(), 'contact', 'step2')));
         return;
     }
     // Dispatch
     $to = $default_from;
     $subject = 'Contact me: Other';
     $sDispatch = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_SITUATIONS, '');
     $dispatch = !empty($sDispatch) ? unserialize($sDispatch) : array();
     foreach ($dispatch as $k => $v) {
         if (md5($k) == $sNature) {
             $to = $v['to'];
             $subject = 'Contact me: ' . strip_tags($k);
             break;
         }
     }
     if (!empty($sSubject)) {
         $subject = $sSubject;
     }
     $fieldContent = '';
     if (!empty($aFollowUpQ)) {
         $fieldContent = "\r\n\r\n";
         $fieldContent .= "--------------------------------------------\r\n";
         if (!empty($sNature)) {
             $fieldContent .= $subject . "\r\n";
             $fieldContent .= "--------------------------------------------\r\n";
         }
         foreach ($aFollowUpQ as $idx => $q) {
             $answer = isset($aFollowUpA[$idx]) ? $aFollowUpA[$idx] : '';
             $fieldContent .= "Q) " . $q . "\r\n" . "A) " . $answer . "\r\n";
             if ($idx + 1 < count($aFollowUpQ)) {
                 $fieldContent .= "\r\n";
             }
         }
         $fieldContent .= "--------------------------------------------\r\n";
         "\r\n";
     }
     $message = new CerberusParserMessage();
     $message->headers['date'] = date('r');
     $message->headers['to'] = $to;
     $message->headers['subject'] = $subject;
     $message->headers['message-id'] = CerberusApplication::generateMessageId();
     $message->headers['x-cerberus-portal'] = 1;
     // Sender
     $fromList = imap_rfc822_parse_adrlist($sFrom, '');
     if (empty($fromList) || !is_array($fromList)) {
         return;
         // abort with message
     }
     $from = array_shift($fromList);
     $message->headers['from'] = $from->mailbox . '@' . $from->host;
     $message->body = 'IP: ' . $fingerprint['ip'] . "\r\n\r\n" . $sContent . $fieldContent;
     $ticket_id = CerberusParser::parseMessage($message);
     $ticket = DAO_Ticket::getTicket($ticket_id);
     // Auto-save any custom fields
     $fields = DAO_CustomField::getBySource('cerberusweb.fields.source.ticket');
     if (!empty($aFieldIds)) {
         foreach ($aFieldIds as $iIdx => $iFieldId) {
             if (!empty($iFieldId)) {
                 $field =& $fields[$iFieldId];
                 /* @var $field Model_CustomField */
                 $value = "";
                 switch ($field->type) {
                     case Model_CustomField::TYPE_SINGLE_LINE:
                     case Model_CustomField::TYPE_MULTI_LINE:
                         @($value = trim($aFollowUpA[$iIdx]));
                         break;
                     case Model_CustomField::TYPE_NUMBER:
                         @($value = intval($aFollowUpA[$iIdx]));
                         break;
                     case Model_CustomField::TYPE_DATE:
                         if (false !== ($time = strtotime($aFollowUpA[$iIdx]))) {
                             @($value = intval($time));
                         }
                         break;
                     case Model_CustomField::TYPE_DROPDOWN:
                         @($value = $aFollowUpA[$iIdx]);
                         break;
                     case Model_CustomField::TYPE_CHECKBOX:
                         @($value = isset($aFollowUpA[$iIdx]) && !empty($aFollowUpA[$iIdx]) ? 1 : 0);
                         break;
                 }
                 if (!empty($value)) {
                     DAO_CustomFieldValue::setFieldValue('cerberusweb.fields.source.ticket', $ticket_id, $iFieldId, $value);
                 }
             }
         }
     }
     // Clear any errors
     $umsession->setProperty('support.write.last_nature', null);
     $umsession->setProperty('support.write.last_nature_string', null);
     $umsession->setProperty('support.write.last_content', null);
     $umsession->setProperty('support.write.last_error', null);
     $umsession->setProperty('support.write.last_opened', $ticket->mask);
     DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', UmPortalHelper::getCode(), 'contact', 'confirm')));
 }
Esempio n. 12
0
 function doContactSendAction()
 {
     @($sFrom = DevblocksPlatform::importGPC($_POST['from'], 'string', ''));
     @($sSubject = DevblocksPlatform::importGPC($_POST['subject'], 'string', ''));
     @($sContent = DevblocksPlatform::importGPC($_POST['content'], 'string', ''));
     @($sCaptcha = DevblocksPlatform::importGPC($_POST['captcha'], 'string', ''));
     @($aFieldIds = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array()));
     @($aFollowUpQ = DevblocksPlatform::importGPC($_POST['followup_q'], 'array', array()));
     $fields = DAO_CustomField::getBySource('cerberusweb.fields.source.ticket');
     // Load the answers to any situational questions
     $aFollowUpA = array();
     if (is_array($aFollowUpQ)) {
         foreach ($aFollowUpQ as $idx => $q) {
             // Only form values we were passed
             if (!isset($_POST['followup_a_' . $idx])) {
                 continue;
             }
             if (is_array($_POST['followup_a_' . $idx])) {
                 @($answer = DevblocksPlatform::importGPC($_POST['followup_a_' . $idx], 'array', array()));
                 $aFollowUpA[$idx] = implode(', ', $answer);
             } else {
                 @($answer = DevblocksPlatform::importGPC($_POST['followup_a_' . $idx], 'string', ''));
                 $aFollowUpA[$idx] = $answer;
             }
             // Translate field values into something human-readable (if needed)
             if (isset($aFieldIds[$idx]) && !empty($aFieldIds[$idx])) {
                 // Were we given a legit field id?
                 if (null != @($field = $fields[$aFieldIds[$idx]])) {
                     switch ($field->type) {
                         // Translate 'worker' fields into worker name (not ID)
                         case Model_CustomField::TYPE_WORKER:
                             if (null != ($worker = DAO_Worker::getAgent($answer))) {
                                 $aFollowUpA[$idx] = $worker->getName();
                             }
                             break;
                     }
                     // switch
                 }
                 // if
             }
             // if
         }
     }
     $umsession = UmPortalHelper::getSession();
     $active_user = $umsession->getProperty('sc_login', null);
     $fingerprint = UmPortalHelper::getFingerprint();
     $settings = CerberusSettings::getInstance();
     $default_from = $settings->get(CerberusSettings::DEFAULT_REPLY_FROM);
     $umsession->setProperty('support.write.last_from', $sFrom);
     $umsession->setProperty('support.write.last_subject', $sSubject);
     $umsession->setProperty('support.write.last_content', $sContent);
     $umsession->setProperty('support.write.last_followup_a', $aFollowUpA);
     $sNature = $umsession->getProperty('support.write.last_nature', '');
     $captcha_enabled = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_CAPTCHA_ENABLED, 1);
     $captcha_session = $umsession->getProperty(UmScApp::SESSION_CAPTCHA, '***');
     // Subject is required if the field  is on the form
     if (isset($_POST['subject']) && empty($sSubject)) {
         $umsession->setProperty('support.write.last_error', 'A subject is required.');
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', UmPortalHelper::getCode(), 'contact', 'step2')));
         return;
     }
     // Sender and CAPTCHA required
     if (empty($sFrom) || $captcha_enabled && 0 != strcasecmp($sCaptcha, $captcha_session)) {
         if (empty($sFrom)) {
             $umsession->setProperty('support.write.last_error', 'Invalid e-mail address.');
         } else {
             $umsession->setProperty('support.write.last_error', 'What you typed did not match the image.');
         }
         // Need to report the captcha didn't match and redraw the form
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', UmPortalHelper::getCode(), 'contact', 'step2')));
         return;
     }
     // Dispatch
     $to = $default_from;
     $subject = 'Contact me: Other';
     $sDispatch = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_SITUATIONS, '');
     $dispatch = !empty($sDispatch) ? unserialize($sDispatch) : array();
     foreach ($dispatch as $k => $v) {
         if (md5($k) == $sNature) {
             $to = $v['to'];
             $subject = 'Contact me: ' . strip_tags($k);
             break;
         }
     }
     if (!empty($sSubject)) {
         $subject = $sSubject;
     }
     $fieldContent = '';
     if (!empty($aFollowUpQ)) {
         $fieldContent = "\r\n\r\n";
         $fieldContent .= "--------------------------------------------\r\n";
         if (!empty($sNature)) {
             $fieldContent .= $subject . "\r\n";
             $fieldContent .= "--------------------------------------------\r\n";
         }
         foreach ($aFollowUpQ as $idx => $q) {
             $answer = isset($aFollowUpA[$idx]) ? $aFollowUpA[$idx] : '';
             $fieldContent .= "Q) " . $q . "\r\n" . "A) " . $answer . "\r\n";
             if ($idx + 1 < count($aFollowUpQ)) {
                 $fieldContent .= "\r\n";
             }
         }
         $fieldContent .= "--------------------------------------------\r\n";
         "\r\n";
     }
     $message = new CerberusParserMessage();
     $message->headers['date'] = date('r');
     $message->headers['to'] = $to;
     $message->headers['subject'] = $subject;
     $message->headers['message-id'] = CerberusApplication::generateMessageId();
     $message->headers['x-cerberus-portal'] = 1;
     // Sender
     $fromList = imap_rfc822_parse_adrlist($sFrom, '');
     if (empty($fromList) || !is_array($fromList)) {
         return;
         // abort with message
     }
     $from = array_shift($fromList);
     $message->headers['from'] = $from->mailbox . '@' . $from->host;
     $message->body = 'IP: ' . $fingerprint['ip'] . "\r\n\r\n" . $sContent . $fieldContent;
     // Attachments
     $attachments_mode = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_ATTACHMENTS_MODE, 0);
     if (0 == $attachments_mode || 1 == $attachments_mode && !empty($active_user)) {
         if (is_array($_FILES) && !empty($_FILES)) {
             foreach ($_FILES as $name => $files) {
                 // field[]
                 if (is_array($files['name'])) {
                     foreach ($files['name'] as $idx => $name) {
                         $attach = new ParserFile();
                         $attach->setTempFile($files['tmp_name'][$idx], 'application/octet-stream');
                         $attach->file_size = filesize($files['tmp_name'][$idx]);
                         $message->files[$name] = $attach;
                     }
                 } else {
                     $attach = new ParserFile();
                     $attach->setTempFile($files['tmp_name'], 'application/octet-stream');
                     $attach->file_size = filesize($files['tmp_name']);
                     $message->files[$files['name']] = $attach;
                 }
             }
         }
     }
     // Custom Fields
     if (!empty($aFieldIds)) {
         foreach ($aFieldIds as $iIdx => $iFieldId) {
             if (!empty($iFieldId)) {
                 $field =& $fields[$iFieldId];
                 /* @var $field Model_CustomField */
                 $value = "";
                 switch ($field->type) {
                     case Model_CustomField::TYPE_SINGLE_LINE:
                     case Model_CustomField::TYPE_MULTI_LINE:
                     case Model_CustomField::TYPE_URL:
                         @($value = trim($aFollowUpA[$iIdx]));
                         break;
                     case Model_CustomField::TYPE_NUMBER:
                         @($value = $aFollowUpA[$iIdx]);
                         if (!is_numeric($value) || 0 == strlen($value)) {
                             $value = null;
                         }
                         break;
                     case Model_CustomField::TYPE_DATE:
                         if (false !== ($time = strtotime($aFollowUpA[$iIdx]))) {
                             @($value = intval($time));
                         }
                         break;
                     case Model_CustomField::TYPE_DROPDOWN:
                         @($value = $aFollowUpA[$iIdx]);
                         break;
                     case Model_CustomField::TYPE_MULTI_PICKLIST:
                         @($value = DevblocksPlatform::importGPC($_POST['followup_a_' . $iIdx], 'array', array()));
                         break;
                     case Model_CustomField::TYPE_CHECKBOX:
                         @($value = isset($aFollowUpA[$iIdx]) && !empty($aFollowUpA[$iIdx]) ? 1 : 0);
                         break;
                     case Model_CustomField::TYPE_MULTI_CHECKBOX:
                         @($value = DevblocksPlatform::importGPC($_POST['followup_a_' . $iIdx], 'array', array()));
                         break;
                     case Model_CustomField::TYPE_WORKER:
                         @($value = DevblocksPlatform::importGPC($_POST['followup_a_' . $iIdx], 'integer', 0));
                         break;
                 }
                 if (is_array($value) && !empty($value) || !is_array($value) && 0 != strlen($value)) {
                     $message->custom_fields[$iFieldId] = $value;
                 }
             }
         }
     }
     // Parse
     $ticket_id = CerberusParser::parseMessage($message);
     // It's possible for the parser to reject the message using pre-filters
     if (!empty($ticket_id) && null != ($ticket = DAO_Ticket::getTicket($ticket_id))) {
         $umsession->setProperty('support.write.last_opened', $ticket->mask);
     } else {
         $umsession->setProperty('support.write.last_opened', null);
     }
     // Clear any errors
     $umsession->setProperty('support.write.last_nature', null);
     $umsession->setProperty('support.write.last_nature_string', null);
     $umsession->setProperty('support.write.last_content', null);
     $umsession->setProperty('support.write.last_error', null);
     DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', UmPortalHelper::getCode(), 'contact', 'confirm')));
 }
Esempio n. 13
0
 /**
  * @param $instance Model_CommunityTool 
  */
 public function configure(Model_CommunityTool $instance)
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(__FILE__)) . '/templates/';
     $tpl->assign('config_path', $tpl_path);
     $logo_url = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_LOGO_URL, '');
     $tpl->assign('logo_url', $logo_url);
     $page_title = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_PAGE_TITLE, 'Support Center');
     $tpl->assign('page_title', $page_title);
     $style_css = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_STYLE_CSS, '');
     $tpl->assign('style_css', $style_css);
     $footer_html = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_FOOTER_HTML, '');
     $tpl->assign('footer_html', $footer_html);
     $allow_logins = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_ALLOW_LOGINS, 0);
     $tpl->assign('allow_logins', $allow_logins);
     $enabled_modules = DevblocksPlatform::parseCsvString(DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_ENABLED_MODULES, array()));
     $tpl->assign('enabled_modules', $enabled_modules);
     $all_modules = DevblocksPlatform::getExtensions('usermeet.sc.controller', true, true);
     $modules = array();
     // Sort the enabled modules first, in order.
     if (is_array($enabled_modules)) {
         foreach ($enabled_modules as $module_id) {
             if (!isset($all_modules[$module_id])) {
                 continue;
             }
             $module = $all_modules[$module_id];
             $modules[$module_id] = $module;
             unset($all_modules[$module_id]);
         }
     }
     // Append the unused modules
     if (is_array($all_modules)) {
         foreach ($all_modules as $module_id => $module) {
             $modules[$module_id] = $module;
             $modules = array_merge($modules, $all_modules);
         }
     }
     $tpl->assign('modules', $modules);
     $tpl->display("file:{$tpl_path}portal/sc/config/index.tpl");
 }