Ejemplo n.º 1
0
 /**
  * handle overview request
  */
 private function handleUnsubscribeGet()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $email = $request->getValue(self::KEY_UNSUBSCRIBE);
     if (!$email) {
         return;
     }
     // retrieve tags that are linked to this plugin
     $taglist = $this->plugin->getTagList();
     if (!$taglist) {
         return;
     }
     $objSettings = $this->plugin->getObject(NewsLetter::TYPE_SETTINGS);
     $objGroup = $this->plugin->getObject(NewsLetter::TYPE_GROUP);
     foreach ($taglist as $tag) {
         $settings = $objSettings->getSettings($tag['tree_id'], $tag['tag']);
         $searchcriteria = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag'], 'email' => $email, 'activated' => true);
         if ($this->exists($searchcriteria)) {
             $sqlParser = clone $this->sqlParser;
             $sqlParser->parseCriteria($searchcriteria, false);
             $this->parseCriteria($sqlParser, $searchcriteria, false);
             $sqlParser->setFieldValue('unsubscribe_date', 'now()', false);
             $query = $sqlParser->getSql(SqlParser::MOD_UPDATE_FIELDS);
             $db = $this->getDb();
             $res = $db->query($query);
             if ($db->isError($res)) {
                 throw new Exception($res->getDebugInfo());
             }
         }
         $location = $settings['del_tree_id'] ? $this->director->tree->getPath($settings['del_tree_id']) : '/';
         header("Location: {$location}");
         exit;
     }
 }
Ejemplo n.º 2
0
 /**
  * handle detail request
  */
 private function handleDetail()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     // it makes no sense to have multiple tags for this plugin.
     // if someone did it, you get strange results and he probably can figure out why.. no multiple detail stuff in 1 page supported!
     // so take a shot and get the first tag to set the content
     $taglist = $this->plugin->getTagList(array('plugin_type' => NewsLetter::TYPE_ARCHIVE));
     if (!$taglist) {
         return;
     }
     $taginfo = current($taglist);
     // process attachments
     $attachment = $this->plugin->getObject(NewsLetter::TYPE_ATTACHMENT);
     $attachment->handleHttpGetRequest();
     // clear subtitle
     $view->setName('');
     if (!$request->exists('id')) {
         continue;
     }
     $id = intval($request->getValue('id'));
     $key = array('id' => $id, 'active' => true);
     $overview = $this->getNewsLetterOverview();
     if (!$overview->exists($key)) {
         throw new HttpException('404');
     }
     $detail = $overview->getDetail($key);
     // check if tree node of newsLetter item is accessable
     $tree = $this->director->tree;
     if (!$tree->exists($detail['tree_id'])) {
         throw new HttpException('404');
     }
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $template->setPostfix($detail['tag']);
     // disable cache because we want to count visits
     $template->setCacheable(false);
     Cache::disableCache();
     // update view counter
     $overview->updateCount($key);
     // overwrite default naming
     $template->setVariable('pageTitle', $detail['name'], false);
     $template->setVariable('newsLetter', $detail, false);
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter($view->getUrlId(), ViewManager::OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     $breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     $this->template[$taginfo['tag']] = $template;
 }
Ejemplo n.º 3
0
 /**
  * handle overview request
  */
 private function handleOverviewGet()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $values = $request->getRequest(Request::POST);
     // retrieve tags that are linked to this plugin
     $taglist = $this->plugin->getTagList(array('plugin_type' => NewsLetter::TYPE_DEFAULT));
     if (!$taglist) {
         return;
     }
     $objSettings = $this->plugin->getObject(NewsLetter::TYPE_SETTINGS);
     $objUser = $this->plugin->getObject(NewsLetter::TYPE_USER);
     $objGroup = $this->plugin->getObject(NewsLetter::TYPE_GROUP);
     $group = is_array($request->getValue('group')) ? array_keys($request->getValue('group')) : array();
     foreach ($taglist as $tag) {
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $template->setPostfix($tag['tag']);
         $template->setCacheable(true);
         // check if template is in cache
         if (!$template->isCached()) {
             // get settings
             $globalSettings = $this->plugin->getSettings();
             $settings = array_merge($globalSettings, $objSettings->getSettings($tag['tree_id'], $tag['tag']));
             $template->setVariable('settings', $settings);
             $searchcriteria = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag']);
             $groupList = $objGroup->getList($searchcriteria);
             $template->setVariable('groupList', $groupList);
             $template->setVariable('cbo_gender', $groupList);
             $template->setVariable('cbo_gender', Utils::getHtmlCombo($objUser->getGenderTypeList(), array_key_exists('gender', $values) ? $values['gender'] : ''));
             $template->setVariable('name', array_key_exists('name', $values) ? $values['name'] : '');
             $template->setVariable('email', array_key_exists('email', $values) ? $values['email'] : '');
             $template->setVariable($searchcriteria);
         }
         $template->setVariable('group', $group);
         $this->template[$tag['tag']] = $template;
     }
 }