function showDoclink() { $assets = JURI::root() . "components/com_docman/assets"; // add styles and scripts $doc =& JFactory::getDocument(); JHTML::_('behavior.mootools'); $doc->addStyleSheet($assets . '/css/doclink.css'); $doc->addScript($assets . '/js/dlutils.js'); $doc->addScript($assets . '/js/popup.js'); $doc->addScript($assets . '/js/dialog.js'); $rows = DOCMAN_utils::categoryArray(); HTML_DMDoclink::showDoclink($rows); }
function showDoclink() { $user = JFactory::getUser(); if (!$user->authorize('com_content', 'add', 'content', 'all')) { JError::raiseError(403, JText::_("ALERTNOTAUTH")); } $assets = JURI::root() . "components/com_docman/assets"; // add styles and scripts $doc =& JFactory::getDocument(); JHTML::_('behavior.mootools'); $doc->addStyleSheet($assets . '/css/doclink.css'); $doc->addScript($assets . '/js/dlutils.js'); $doc->addScript($assets . '/js/popup.js'); $doc->addScript($assets . '/js/dialog.js'); $rows = DOCMAN_utils::categoryArray(); HTML_DMDoclink::showDoclink($rows); }
function categoryParentList($id, $action, $options = array()) { global $_DOCMAN; $database = JFactory::getDBO(); require_once $_DOCMAN->getPath('classes', 'utils'); $list = DOCMAN_utils::categoryArray(); // using getInstance for performance // $cat = new mosDMCategory($database); // $cat->load($id); $cat =& mosDMCategory::getInstance($id); $this_treename = ''; foreach ($list as $item) { if ($this_treename) { if ($item->id != $cat->id && strpos($item->treename, $this_treename) === false) { $options[] = JHTML::_('select.option', $item->id, $item->treename); } } else { if ($item->id != $cat->id) { $options[] = JHTML::_('select.option', $item->id, $item->treename); } else { $this_treename = "{$item->treename}/"; } } } $parent = JHTML::_('select.genericlist', $options, 'parent_id', 'class="inputbox" size="1"', 'value', 'text', $cat->parent_id); return $parent; }
function showDocuments($pend, $sort, $view_type) { global $_DOCMAN; require_once $_DOCMAN->getPath('classes', 'utils'); global $option, $section; global $section, $menutype; $database = JFactory::getDBO(); $mainframe = JFactory::getApplication(); $limit = $mainframe->getCfg('list_limit'); $catid = $mainframe->getUserStateFromRequest("catidarc{option}{$section}", 'catid', 0); $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $limit); $limitstart = $mainframe->getUserStateFromRequest("view{$option}{$section}limitstart", 'limitstart', 0); $levellimit = $mainframe->getUserStateFromRequest("view{$option}{$section}limit", 'levellimit', 10); $search = $mainframe->getUserStateFromRequest("searcharc{$option}{$section}", 'search', ''); $search = $database->getEscaped(trim(strtolower($search))); $where = array(); if ($catid > 0) { $where[] = "a.catid={$catid}"; } if ($search) { $where[] = "LOWER(a.dmname) LIKE '%{$search}%'"; } if ($pend == 'yes') { $where[] = "a.approved LIKE '0'"; } // get the total number of records $query = "SELECT count(*) " . "\n FROM #__docman AS a" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : ""); $database->setQuery($query); $total = $database->loadResult(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } // $where[] = "a.catid=cc.id"; if ($sort == 'filename') { $sorttemp = "a.dmfilename"; } else { if ($sort == 'name') { $sorttemp = "a.dmname"; } else { if ($sort == 'date') { $sorttemp = "a.dmdate_published"; } else { $sorttemp = "a.catid,a.dmname"; } } } $query = "SELECT a.*, cc.name AS category, u.name AS editor" . "\n FROM #__docman AS a" . "\n LEFT JOIN #__users AS u ON u.id = a.checked_out" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : "") . "\n ORDER BY " . $sorttemp . " ASC"; $database->setQuery($query); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } $pageNav = new DOCMAN_Pagination($total, $limitstart, $limit); // slice out elements based on limits $rows = array_slice($rows, $pageNav->limitstart, $pageNav->limit); // add category name $list = DOCMAN_utils::categoryArray(); for ($i = 0, $n = count($rows); $i < $n; $i++) { $row =& $rows[$i]; $row->treename = array_key_exists($row->catid, $list) ? $list[$row->catid]->treename : '(orphan)'; } // get list of categories $options = array(); $options[] = JHTML::_('select.option', '0', _DML_SELECT_CAT); $options[] = JHTML::_('select.option', '-1', _DML_ALL_CATS); $lists['catid'] = dmHTML::categoryList($catid, "document.adminForm.submit();", $options); // get unpublished documents $database->setQuery("SELECT count(*) FROM #__docman WHERE approved=0"); $number_pending = $database->loadResult(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } // get pending documents $database->setQuery("SELECT count(*) FROM #__docman WHERE published=0"); $number_unpublished = $database->loadResult(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } HTML_DMDocuments::showDocuments($rows, $lists, $search, $pageNav, $number_pending, $number_unpublished, $view_type); }
function saveConfig() { DOCMAN_token::check() or die('Invalid Token'); global $_DOCMAN, $task; $mainframe = JFactory::getApplication(); $_POST = DOCMAN_Utils::stripslashes($_POST); $docmanMax = DOCMAN_Utils::text2number($_POST['maxAllowed']); $_POST['maxAllowed'] = $docmanMax; $max = DOCMAN_utils::getMaxUploadSize(); if ($docmanMax < 0) { $mainframe->redirect("index.php?option=com_docman§ion=config", _DML_CONFIG_ERROR_UPLOAD); } $override_edit = _DM_ASSIGN_NONE; $author = JRequest::getBool('assign_edit_author', 0, 'post'); $editor = JRequest::getBool('assign_edit_editor', 0, 'post'); if ($author) { $override_edit = _DM_ASSIGN_BY_AUTHOR; } if ($editor) { $override_edit = _DM_ASSIGN_BY_EDITOR; } if ($author && $editor) { $override_edit = _DM_ASSIGN_BY_AUTHOR_EDITOR; } $_POST['editor_assign'] = $override_edit; unset($_POST['assign_edit_author']); unset($_POST['assign_edit_editor']); $override_down = _DM_ASSIGN_NONE; $author = JRequest::getBool('assign_download_author', 0, 'post'); $editor = JRequest::getBool('assign_download_editor', 0, 'post'); if ($author) { $override_down = _DM_ASSIGN_BY_AUTHOR; } if ($editor) { $override_down = _DM_ASSIGN_BY_EDITOR; } if ($author && $editor) { $override_down = _DM_ASSIGN_BY_AUTHOR_EDITOR; } $_POST['reader_assign'] = $override_down; unset($_POST['assign_download_author']); unset($_POST['assign_download_editor']); foreach ($_POST as $key => $value) { $_DOCMAN->setCfg($key, $value); } if ($_DOCMAN->saveConfig()) { if ($max < $docmanMax) { $mainframe->redirect("index.php?option=com_docman§ion=config", _DML_CONFIG_WARNING . DOCMAN_UTILS::number2text($max)); } else { $section = $task == 'apply' ? '§ion=config' : ''; $mainframe->redirect('index.php?option=com_docman' . $section, _DML_CONFIG_UPDATED); } } else { $mainframe->redirect("index.php?option=com_docman§ion=config", _DML_CONFIG_ERROR); } }