예제 #1
0
 /**
  * handle tree overview
  */
 private function handleTreeOverview()
 {
     $pagesize = 20;
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(Calendar::VIEW_COMMENT_OVERVIEW);
     $page = $this->getPage();
     if (!$request->exists('cal_id')) {
         throw new Exception('Nieuwsbericht ontbreekt.');
     }
     if (!$request->exists('tree_id')) {
         throw new Exception('Node ontbreekt.');
     }
     if (!$request->exists('tag')) {
         throw new Exception('Tag ontbreekt.');
     }
     $cal_id = intval($request->getValue('cal_id'));
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $key = array('cal_id' => $cal_id);
     $this->pagerUrl->addParameters($key);
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     // handle searchcriteria
     $search = new SearchManager();
     $search->setUrl($this->pagerUrl);
     $search->setExclude($this->pagerKey);
     $search->setParameter('search');
     $search->saveList();
     $searchcriteria = $search->getSearchParameterList();
     $searchcriteria = array_merge($searchcriteria, $key);
     // add breadcrumb item
     $this->director->theme->handleAdminLinks($template);
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter('cal_id', $cal_id);
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     // create urls
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), Calendar::VIEW_COMMENT_EDIT);
     $url_del = clone $url;
     $url_del->setParameter($view->getUrlId(), Calendar::VIEW_COMMENT_DELETE);
     $list = $this->getList($searchcriteria, $pagesize, $page);
     foreach ($list['data'] as &$item) {
         $url_edit->setParameter('id', $item['id']);
         $url_del->setParameter('id', $item['id']);
         $item['href_edit'] = $url_edit->getUrl(true);
         $item['href_del'] = $url_del->getUrl(true);
     }
     $template->setVariable('list', $list, false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
예제 #2
0
 private function handlePluginSelect($tag, $parameters)
 {
     $pagesize = 20;
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $page = $this->getPage();
     $searchcriteria = isset($parameters) && array_key_exists('searchcriteria', $parameters) ? $parameters['searchcriteria'] : array();
     $keys = isset($parameters) && array_key_exists('keys', $parameters) ? $parameters['keys'] : array();
     $this->pagerUrl->addParameters($searchcriteria);
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     // handle searchcriteria
     $search = new SearchManager();
     $search->setUrl($this->pagerUrl);
     $search->setExclude($this->pagerKey);
     $search->setParameter('search');
     $search->saveList();
     $searchcriteria = $search->getSearchParameterList();
     //$searchcriteria = array_merge($searchcriteria, $key);
     $rangeKeys = array();
     $list = $this->getList($searchcriteria, $pagesize, $page);
     foreach ($list['data'] as &$item) {
         $rangeKeys[] = $item['id'];
         $item['selected'] = in_array($item['id'], $keys);
         if ($item['thumbnail']) {
             $img = new Image($item['thumbnail'], $this->plugin->getContentPath(true));
             $item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
         }
     }
     $template->setVariable('list', $list);
     $template->setVariable('searchparam', $search->getMandatoryParameterList());
     $template->setVariable('searchcriteria', $searchcriteria);
     $template->setVariable('rangeKeys', $rangeKeys);
     $this->template[$tag] = $template;
 }
예제 #3
0
 /**
  * handle overview request
  */
 private function handleOverview()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $page = $this->getPage();
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     $view->setType(self::VIEW_OVERVIEW);
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $template->setVariable('pageTitle', $this->description);
     if (!$request->exists('ext_id')) {
         throw new Exception('Extension is missing.');
     }
     $ext_id = intval($request->getValue('ext_id'));
     // handle searchcriteria
     $search = new SearchManager();
     $search->setUrl($this->pagerUrl);
     $search->setExclude($this->pagerKey);
     $search->setParameter('search');
     $search->setParameter('ext_id', $ext_id);
     $search->saveList();
     $searchcriteria = $search->getSearchParameterList();
     $url = new Url(true);
     $url->clearParameter('ip');
     $url->setParameter('ext_id', $ext_id);
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), self::VIEW_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true));
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), self::VIEW_EDIT);
     $url_del = clone $url;
     $url_del->setParameter($view->getUrlId(), self::VIEW_DELETE);
     $list = $this->getList($searchcriteria, $this->pagesize, $page);
     foreach ($list['data'] as &$item) {
         $url_edit->setParameter('ip', $item['ip']);
         $url_del->setParameter('ip', $item['ip']);
         $item['href_edit'] = $url_edit->getUrl(true);
         $item['href_del'] = $url_del->getUrl(true);
         if ($item['suspect']) {
             $item['state'] = 'suspect';
         } elseif (!$item['activated']) {
             $item['state'] = 'expired';
         } else {
             $item['state'] = 'intruder';
         }
     }
     $template->setVariable('list', $list);
     $template->setVariable('searchparam', $search->getMandatoryParameterList());
     $template->setVariable('searchcriteria', $searchcriteria);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
예제 #4
0
 /**
  * handle tree overview
  */
 private function handleTreeOverview()
 {
     $pagesize = 20;
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_OVERVIEW);
     $page = $this->getPage();
     if (!$request->exists('tree_id')) {
         throw new Exception('Node is missing.');
     }
     if (!$request->exists('tag')) {
         throw new Exception('Tag is missing.');
     }
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $key = array('tree_id' => $tree_id, 'tag' => $tag);
     $this->pagerUrl->addParameters($key);
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     // handle searchcriteria
     $search = new SearchManager();
     $search->setUrl($this->pagerUrl);
     $search->setExclude($this->pagerKey);
     $search->setParameter('search');
     $search->saveList();
     $searchcriteria = $search->getSearchParameterList();
     $searchcriteria = array_merge($searchcriteria, $key);
     // add breadcrumb item
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     // create urls
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true), false);
     $url_conf = clone $url;
     $url_conf->setParameter($view->getUrlId(), Links::VIEW_CONFIG);
     $template->setVariable('href_conf', $url_conf->getUrl(true), false);
     $url_import = clone $url;
     $url_import->setParameter($view->getUrlId(), Links::VIEW_IMPORT);
     $template->setVariable('href_import', $url_import->getUrl(true), false);
     $url_resize = clone $url;
     $url_resize->setParameter($view->getUrlId(), Links::VIEW_RESIZE);
     $template->setVariable('href_resize', $url_resize->getUrl(true), false);
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     $url_mv_prev = clone $url;
     $url_mv_prev->setParameter($view->getUrlId(), Links::VIEW_MV_PREC);
     $url_mv_next = clone $url;
     $url_mv_next->setParameter($view->getUrlId(), Links::VIEW_MV_FOL);
     $url_del = clone $url;
     $url_del->setParameter($view->getUrlId(), ViewManager::TREE_DELETE);
     $counter = 0;
     $list = $this->getList($searchcriteria, $pagesize, $page);
     $maxcount = $list['totalItems'];
     foreach ($list['data'] as &$item) {
         $counter++;
         $url_edit->setParameter('id', $item['id']);
         $url_del->setParameter('id', $item['id']);
         $url_mv_prev->setParameter('id', $item['id']);
         $url_mv_next->setParameter('id', $item['id']);
         $item['href_edit'] = $url_edit->getUrl(true);
         $item['href_del'] = $url_del->getUrl(true);
         if ($counter > 1) {
             $item['href_mv_prev'] = $url_mv_prev->getUrl(true);
         }
         if ($counter < $maxcount) {
             $item['href_mv_next'] = $url_mv_next->getUrl(true);
         }
         if ($item['url']) {
             $item['link'] = $item['url'];
         } elseif ($item['ref_tree_id']) {
             $item['link'] = $this->director->tree->getPath($item['ref_tree_id']);
         } else {
             $item['link'] = "link detailed page";
         }
         if ($item['thumbnail']) {
             $img = new Image($item['thumbnail'], $this->getContentPath(true));
             $item['thumbnail'] = array('src' => $this->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
         }
     }
     $template->setVariable('list', $list, false);
     $template->setVariable('searchparam', $search->getMandatoryParameterList(), false);
     $template->setVariable('searchcriteria', $searchcriteria, false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
예제 #5
0
 /**
  * handle tree overview
  */
 private function handleTreeOverview()
 {
     $pagesize = 20;
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_OVERVIEW);
     $page = $this->getPage();
     if (!$request->exists('tree_id')) {
         throw new Exception('Node is missing.');
     }
     if (!$request->exists('tag')) {
         throw new Exception('Tag is missing.');
     }
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $key = array('tree_id' => $tree_id, 'tag' => $tag);
     $this->pagerUrl->addParameters($key);
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     // handle searchcriteria
     $search = new SearchManager();
     $search->setUrl($this->pagerUrl);
     $search->setExclude($this->pagerKey);
     $search->setParameter('search');
     $search->saveList();
     $searchcriteria = $search->getSearchParameterList();
     $searchcriteria = array_merge($searchcriteria, $key);
     $url = new Url(true);
     $url->clearParameter('id');
     $url->clearParameter('poll_id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     // create urls
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true), false);
     $url_conf = clone $url;
     $url_conf->setParameter($view->getUrlId(), Poll::VIEW_CONFIG);
     $template->setVariable('href_conf', $url_conf->getUrl(true), false);
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     $url_del = clone $url;
     $url_del->setParameter($view->getUrlId(), ViewManager::TREE_DELETE);
     $url_item = clone $url;
     $url_item->setParameter($view->getUrlId(), Poll::VIEW_ITEM_OVERVIEW);
     $list = $this->getList($searchcriteria, $pagesize, $page);
     foreach ($list['data'] as &$item) {
         $url_edit->setParameter('id', $item['id']);
         $url_del->setParameter('id', $item['id']);
         $url_item->setParameter('poll_id', $item['id']);
         $item['href_edit'] = $url_edit->getUrl(true);
         $item['href_del'] = $url_del->getUrl(true);
         $item['href_item'] = $url_item->getUrl(true);
     }
     $template->setVariable('list', $list, false);
     $template->setVariable('searchparam', $search->getMandatoryParameterList(), false);
     $template->setVariable('searchcriteria', $searchcriteria, false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
예제 #6
0
파일: User.php 프로젝트: rverbrugge/dif
 /**
  * handle export 
  */
 private function handleExport()
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $cache = Cache::getInstance();
     $filename = strtolower($this->getClassName()) . ".csv";
     $csvContent = '';
     if (!$cache->isCached($filename)) {
         require_once DIF_ROOT . "utils/CsvFile.php";
         // handle searchcriteria
         $search = new SearchManager();
         $search->setUrl($this->pagerUrl);
         $search->setExclude($this->pagerKey);
         $search->setParameter('search');
         $search->saveList();
         $searchcriteria = $search->getSearchParameterList();
         $exportlist = array();
         $list = $this->getList($searchcriteria);
         foreach ($list['data'] as $item) {
             $row = array_intersect_key($item, $this->exportColumns);
             $row['password'] = '';
             $row['role'] = $this->getRoleDesc($row['role']);
             $exportlist[] = $row;
         }
         $csvFile = new CsvFile();
         $csvContent = join("\n", $csvFile->array2csv($exportlist));
         $cache->save($csvContent, $filename);
     } else {
         $csvContent = $cache->getCache($filename);
     }
     header("Content-type: text/csv");
     header("Content-Disposition: attachment; filename=\"{$filename}\"");
     echo $csvContent;
     exit;
 }
예제 #7
0
 /**
  * handle tree overview
  */
 private function handleTreeOverview()
 {
     $pagesize = 10;
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $record = $this->plugin->getObject(Form::TYPE_RECORD);
     $recordItem = $this->plugin->getObject(Form::TYPE_RECORD_ITEM);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_OVERVIEW);
     $page = $this->getPage();
     if (!$request->exists('tree_id')) {
         throw new Exception('Node ontbreekt.');
     }
     if (!$request->exists('tag')) {
         throw new Exception('Tag ontbreekt.');
     }
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $key = array('tree_id' => $tree_id, 'tag' => $tag);
     $template->setVariable($key);
     $this->pagerUrl->addParameters($key);
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     // store updated pager url to record object
     $record->setPagerUrl($this->pagerUrl);
     // handle searchcriteria
     $search = new SearchManager();
     $search->setUrl($this->pagerUrl);
     $search->setExclude($this->pagerKey);
     $search->setParameter('search');
     $search->saveList();
     $searchcriteria = $search->getSearchParameterList();
     $searchcriteria = array_merge($searchcriteria, $key);
     $url = new Url(true);
     $url->clearParameter('id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     // create urls
     $url_conf = clone $url;
     $url_conf->setParameter($view->getUrlId(), Form::VIEW_CONFIG);
     $template->setVariable('href_conf', $url_conf->getUrl(true), false);
     $url_elem = clone $url;
     $url_elem->setParameter($view->getUrlId(), Form::VIEW_ELEMENT_OVERVIEW);
     $template->setVariable('href_elem', $url_elem->getUrl(true), false);
     $url_del_all = clone $url;
     $url_del_all->setParameter($view->getUrlId(), Form::VIEW_RECORD_DEL_ALL);
     $template->setVariable('href_del_all', $url_del_all->getUrl(true), false);
     $url_export = clone $url;
     $url_export->setParameter($view->getUrlId(), Form::VIEW_RECORD_EXPORT);
     $template->setVariable('href_export', $url_export->getUrl(true), false);
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true), false);
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     // get columns and create template column list because not every record may have all the columns.
     $recordTemplate = array();
     $columns = $recordItem->getColumns($tree_id, $tag);
     $columns[] = 'timestamp';
     $columns[] = 'host';
     foreach ($columns as $column) {
         $recordTemplate[$column] = '';
     }
     $template->setVariable('columns', $columns);
     $themeVars = $this->director->theme->getFileVars();
     $img_edit = $themeVars['img_edit'];
     $editString = '<a href="%s">' . sprintf('<img class="noborder" src="%s" width="%s" height="%s" alt="edit" title="edit" /></a>', $img_edit['src'], $img_edit['width'], $img_edit['height']);
     $delString = '<input type="checkbox" name="id[]" value="%d" class="noborder" />';
     // retrieve all records within this tree node
     // array[record id] => timestamp
     $searchcriteria = array_merge($searchcriteria, $key);
     $searchcriteria['optin'] = '';
     $recordlist = array();
     $records = $record->getList($searchcriteria, $pagesize, $page);
     foreach ($records['data'] as $item) {
         $recordlist[$item['id']] = $item;
     }
     $template->setVariable('records', $records);
     $recordItemListFinal = array();
     if ($recordlist) {
         // search for all form elements within the specified records
         $elemsearch = array('rcd_id' => array_keys($recordlist));
         $recordItemList = $recordItem->getItems($elemsearch);
         foreach ($recordItemList as $rcd_id => $recordElement) {
             // set values to all the columns
             $element = $recordTemplate;
             foreach ($recordElement as $recordColumn) {
                 // columnames are forced to lowercase, do the same for this result to merge case sensitive versions of columns
                 $element[strtolower($recordColumn['name'])] = $recordColumn['value'];
             }
             $element['timestamp'] = strftime('%c', $recordlist[$rcd_id]['createdate']);
             $element['host'] = $recordlist[$rcd_id]['host'];
             $url_edit->setParameter('rcd_id', $rcd_id);
             $urls = array();
             $urls[] = sprintf($delString, $rcd_id);
             $urls[] = sprintf($editString, $url_edit->getUrl(true));
             array_unshift($element, join('', $urls));
             $recordItemListFinal[] = $element;
         }
     }
     $template->setVariable('list', $recordItemListFinal);
     $template->setVariable('searchparam', $search->getMandatoryParameterList(), false);
     $template->setVariable('searchcriteria', $searchcriteria, false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
예제 #8
0
 /**
  * handle tree overview
  */
 private function handleTreeOverview()
 {
     $pagesize = 20;
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $view->setType(ViewManager::TREE_OVERVIEW);
     $page = $this->getPage();
     if (!$request->exists('tree_id')) {
         throw new Exception('Node is missing.');
     }
     if (!$request->exists('tag')) {
         throw new Exception('Tag is missing.');
     }
     $tree_id = intval($request->getValue('tree_id'));
     $tag = $request->getValue('tag');
     $key = array('tree_id' => $tree_id, 'tag' => $tag);
     $this->pagerUrl->addParameters($key);
     $this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
     // handle searchcriteria
     $search = new SearchManager();
     $search->setUrl($this->pagerUrl);
     $search->setExclude($this->pagerKey);
     $search->setParameter('search');
     $search->saveList();
     $searchcriteria = $search->getSearchParameterList();
     $searchcriteria = array_merge($searchcriteria, $key);
     $url = new Url(true);
     $url->clearParameter('id');
     $url->clearParameter('nl_id');
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     // create urls
     $url_new = clone $url;
     $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW);
     $template->setVariable('href_new', $url_new->getUrl(true), false);
     $url_conf = clone $url;
     $url_conf->setParameter($view->getUrlId(), NewsLetter::VIEW_CONFIG);
     $template->setVariable('href_conf', $url_conf->getUrl(true), false);
     $url_user = clone $url;
     $url_user->setParameter($view->getUrlId(), NewsLetter::VIEW_USER_OVERVIEW);
     $template->setVariable('href_user', $url_user->getUrl(true), false);
     $url_group = clone $url;
     $url_group->setParameter($view->getUrlId(), NewsLetter::VIEW_GROUP_OVERVIEW);
     $template->setVariable('href_group', $url_group->getUrl(true), false);
     $url_edit = clone $url;
     $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     $url_del = clone $url;
     $url_del->setParameter($view->getUrlId(), ViewManager::TREE_DELETE);
     $url_att = clone $url;
     $url_att->setParameter($view->getUrlId(), NewsLetter::VIEW_FILE_OVERVIEW);
     $url_preview = clone $url;
     $url_preview->setParameter($view->getUrlId(), NewsLetter::VIEW_PREVIEW);
     $url_send = clone $url;
     $url_send->setParameter($view->getUrlId(), NewsLetter::VIEW_SEND);
     $url_plugin = clone $url;
     $url_plugin->setParameter($view->getUrlId(), NewsLetter::VIEW_PLUGIN_OVERVIEW);
     $list = $this->getList($searchcriteria, $pagesize, $page);
     foreach ($list['data'] as &$item) {
         $url_edit->setParameter('id', $item['id']);
         $url_del->setParameter('id', $item['id']);
         $url_att->setParameter('nl_id', $item['id']);
         $url_plugin->setParameter('nl_id', $item['id']);
         $url_preview->setParameter('nl_id', $item['id']);
         $url_send->setParameter('nl_id', $item['id']);
         $item['href_edit'] = $url_edit->getUrl(true);
         $item['href_del'] = $url_del->getUrl(true);
         $item['href_att'] = $url_att->getUrl(true);
         $item['href_plugin'] = $url_plugin->getUrl(true);
         $item['href_preview'] = $url_preview->getUrl(true);
         $item['href_send'] = $url_send->getUrl(true);
         if ($item['thumbnail']) {
             $img = new Image($item['thumbnail'], $this->plugin->getContentPath(true));
             $item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
         }
     }
     $template->setVariable('list', $list, false);
     $template->setVariable('searchparam', $search->getMandatoryParameterList(), false);
     $template->setVariable('searchcriteria', $searchcriteria, false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }