Exemplo n.º 1
0
 function _adminPageUpdate_Service($_REQUEST)
 {
     global $Language, $feedback;
     $group_id = (int) $_REQUEST['group_id'];
     switch ($_REQUEST['func']) {
         case 'pl_config_update':
             if (isset($_REQUEST['EnableProjectLink'])) {
                 user_set_preference("pl_GroupId_master", $group_id);
             } else {
                 user_del_preference("pl_GroupId_master");
             }
             $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_ok');
             break;
         case 'pl_link_delete':
             // delete project link
             $link_id = (int) $_REQUEST['link_id'];
             // NB: use group_id to defend against malicious use
             if (db_query("DELETE FROM plugin_projectlinks_relationship\n                            WHERE (master_group_id=" . db_ei($group_id) . ")\n                                AND (link_id=" . db_ei($link_id) . ");")) {
                 $feedback .= ' ' . $Language->getText('plugin_plinks', 'project_link_deleted_OK');
             } else {
                 $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_failed', db_error());
             }
             break;
         case 'pl_type_delete':
             // delete project link type and all links using the type
             $link_type_id = (int) $_REQUEST['link_type_id'];
             // delete project relationship instances
             // NB: use group_id to defend against malicious use
             if (!db_query("DELETE FROM plugin_projectlinks_relationship\n                    WHERE (master_group_id=" . db_ei($group_id) . ")\n                        AND (link_type_id=" . db_ei($link_type_id) . ");")) {
                 $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_failed', db_error());
             } else {
                 //delete the relationship type if no error deleting instances
                 if (!db_query("DELETE FROM plugin_projectlinks_link_type\n                        WHERE (group_id=" . db_ei($group_id) . ")\n                            AND (link_type_id=" . db_ei($link_type_id) . ");")) {
                     $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_failed', db_error());
                 } else {
                     $feedback .= ' ' . $Language->getText('plugin_plinks', 'project_link_deleted_OK');
                 }
                 if (user_get_preference("pl_GroupId_master") == $group_id) {
                     // switch off linking to this project - it would be better
                     // to check if no types left, but this works well
                     user_del_preference("pl_GroupId_master");
                 }
             }
             break;
         case 'pl_type_update':
             $q_name = "'" . db_es($_REQUEST['name']) . "'";
             $q_reverse_name = "'" . db_es(nz($_REQUEST['reverse_name'], $_REQUEST['name'])) . "'";
             $q_description = "'" . db_es($_REQUEST['description']) . "'";
             /** **1 commented out for now - until we can decide how to deal with project links functionality
                 $q_uri_plus = db_es($_REQUEST['uri_plus']);
                 **/
             $q_uri_plus = "'" . db_es('/projects/$projname/') . "'";
             // $link_type_id is not set when submitting a new link
             if (isset($_REQUEST['link_type_id'])) {
                 $link_type_id = (int) $_REQUEST['link_type_id'];
             } else {
                 $link_type_id = NULL;
             }
             // check the change would not create a duplicate
             $pfcheck = db_query("SELECT name\n                FROM plugin_projectlinks_link_type\n                WHERE (((name=" . $q_name . ")\n                        OR (reverse_name=" . $q_reverse_name . "))\n                    AND ((group_id=" . db_ei($group_id) . ")" . (is_null($link_type_id) ? "" : " AND (link_type_id<>" . db_ei($link_type_id) . ")") . ")\n                );");
             if (db_numrows($pfcheck) > 0) {
                 $feedback .= ' ' . $Language->getText('plugin_plinks', 'project_link_type_change_makes_duplicate');
             } elseif (update_database("plugin_projectlinks_link_type", array("name" => $q_name, "reverse_name" => $q_reverse_name, "description" => $q_description, "uri_plus" => $q_uri_plus, "group_id" => $group_id), is_null($link_type_id) ? NULL : "link_type_id={$link_type_id}")) {
                 $this->addWidgetOnSummaryPage($group_id);
                 $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_ok') . ' ';
             } else {
                 $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_failed', db_error());
             }
             break;
         case 'pl_link_update':
             $link_type_id = (int) $_REQUEST['link_type_id'];
             if (isset($_REQUEST['target_group_id'])) {
                 $target_group_id = (int) $_REQUEST['target_group_id'];
             } else {
                 $prjManager = ProjectManager::instance();
                 $trgProject = $prjManager->getProjectFromAutocompleter($_REQUEST['target_group']);
                 if ($trgProject !== false) {
                     $target_group_id = $trgProject->getId();
                 } else {
                     return;
                 }
             }
             $group_id = (int) $_REQUEST['group_id'];
             // NB: $link_id is not set when submitting a new link
             if (isset($_REQUEST['link_id'])) {
                 $link_id = (int) $_REQUEST['link_id'];
             } else {
                 $link_id = NULL;
                 // if this is a new link to a template:
                 //  add links to all projects already created from the template
                 $db_res = db_query("SELECT group_id\n                    FROM groups\n                    WHERE (built_from_template = " . db_ei($target_group_id) . ");");
                 while ($row = db_fetch_array($db_res)) {
                     $feedback .= ' ' . $this->_link_unique_update($group_id, $row['group_id'], $link_type_id);
                 }
             }
             $feedback .= ' ' . $this->_link_unique_update($group_id, $target_group_id, $link_type_id, $link_id);
             break;
         case 'template_sync_type_add':
             $template_type_id = (int) $_REQUEST['template_type_id'];
             $db_res = db_query("SELECT * FROM plugin_projectlinks_link_type\n                                WHERE (link_type_id = " . db_ei($template_type_id) . ");");
             if (db_numrows($db_res) == 1) {
                 $row = db_fetch_array($db_res);
                 if (db_query("INSERT INTO plugin_projectlinks_link_type (\n                        group_id,\n                        name,\n                        reverse_name,\n                        description,\n                        uri_plus\n                    ) VALUES (\n                    {$group_id},\n                        '" . db_es($row['name']) . "',\n                        '" . db_es($row['reverse_name']) . "',\n                        '" . db_es($row['description']) . "',\n                        '" . db_es($row['uri_plus']) . "'\n                    );")) {
                     $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_ok');
                 }
             }
             break;
         default:
             $feedback .= " not implemented: '{$_REQUEST['func']}'";
             break;
     }
 }
Exemplo n.º 2
0
<?php

require_once 'pre.php';
$valid = new Valid_UInt('tracker_id');
$valid->required();
if ($request->valid($valid)) {
    if (user_get_preference('tracker_comment_invertorder_' . $request->get('tracker_id'))) {
        user_del_preference('tracker_comment_invertorder_' . $request->get('tracker_id'));
    } else {
        user_set_preference('tracker_comment_invertorder_' . $request->get('tracker_id'), '1');
    }
}
 function request()
 {
     if ($this->request->exist('action') && ($this->request->get('action') == 'plugin_docman_approval_reviewer' || $this->request->get('action') == 'plugin_docman_approval_requester')) {
         if ($this->request->get('hide')) {
             user_set_preference('hide_' . $this->request->get('action'), 1);
         } else {
             user_del_preference('hide_' . $this->request->get('action'));
         }
         exit;
     }
     if (!$this->request->exist('group_id')) {
         $this->feedback->log('error', 'Project is missing.');
         $this->_setView('Error');
     } else {
         $_groupId = (int) $this->request->get('group_id');
         $pm = ProjectManager::instance();
         $project = $pm->getProject($_groupId);
         if ($project == false) {
             $this->feedback->log('error', 'Project is missing.');
             $this->_setView('Error');
             return;
         }
         // Browser alert
         $this->_checkBrowserCompliance();
         //token for redirection
         $tok =& new Docman_Token();
         $this->_viewParams['docman'] =& $this;
         $this->_viewParams['user'] =& $this->getUser();
         $this->_viewParams['token'] = $tok->getToken();
         $this->_viewParams['default_url'] = $this->getDefaultUrl();
         $this->_viewParams['theme_path'] = $this->getThemePath();
         $this->_viewParams['group_id'] = (int) $this->request->get('group_id');
         if ($this->request->exist('version_number')) {
             $this->_viewParams['version_number'] = (int) $this->request->get('version_number');
         }
         if ($this->request->exist('section')) {
             $this->_viewParams['section'] = $this->request->get('section');
         } else {
             if ($this->request->get('action') == 'permissions') {
                 $this->_viewParams['section'] = 'permissions';
             }
         }
         $view = $this->request->exist('action') ? $this->request->get('action') : 'show';
         $this->_viewParams['action'] = $view;
         // Start is used by Table view (like LIMIT start,offset)
         if ($this->request->exist('start')) {
             $this->_viewParams['start'] = (int) $this->request->get('start');
         }
         if ($this->request->exist('pv')) {
             $this->_viewParams['pv'] = (int) $this->request->get('pv');
         }
         if ($this->request->exist('report')) {
             $this->_viewParams['report'] = $this->request->get('report');
             $views = Docman_View_Browse::getDefaultViews();
             $validator = new Valid_WhiteList('report', $views);
             $views_keys = array_keys($views);
             $default_view = $views[$views_keys[0]];
             $this->_viewParams['report'] = $this->request->getValidated('report', $validator, $default_view);
         }
         $item_factory =& $this->_getItemFactory();
         $root =& $item_factory->getRoot($this->request->get('group_id'));
         if (!$root) {
             // Install
             $_gid = (int) $this->request->get('group_id');
             $pm = ProjectManager::instance();
             $project = $pm->getProject($_gid);
             $tmplGroupId = (int) $project->getTemplate();
             $this->_cloneDocman($tmplGroupId, $_gid, false);
             if (!$item_factory->getRoot($_gid)) {
                 $item_factory->createRoot($_gid, 'roottitle_lbl_key');
             }
             $this->_viewParams['redirect_to'] = $_SERVER['REQUEST_URI'];
             $this->view = 'Redirect';
         } else {
             $id = $this->request->get('id');
             if (!$id && $this->request->exist('item')) {
                 $i = $this->request->get('item');
                 if (isset($i['id'])) {
                     $id = $i['id'];
                 }
             }
             if ($id) {
                 $item =& $item_factory->getItemFromDb($id);
                 if (!$item) {
                     $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_item_deleted'));
                     $this->_setView('DocmanError');
                 }
             } else {
                 $item =& $root;
             }
             if ($item) {
                 // Load report
                 // If the item (folder) defined in the report is not the
                 // same than the current one, replace it.
                 $this->_initReport($item);
                 if ($this->_viewParams['filter'] !== null && $this->_viewParams['filter']->getItemId() !== null && $this->_viewParams['filter']->getItemId() != $item->getId()) {
                     $reportItem = $item_factory->getItemFromDb($this->_viewParams['filter']->getItemId());
                     // If item defined in the report exists, use it
                     // otherwise raise an error
                     if (!$reportItem) {
                         $this->feedback->log('warning', $GLOBALS['Language']->getText('plugin_docman', 'error_report_baditemid'));
                     } else {
                         unset($item);
                         $item = $reportItem;
                     }
                 }
                 if ($this->request->get('action') == 'ajax_reference_tooltip') {
                     $this->groupId = $item->getGroupId();
                 }
                 if ($item->getGroupId() != $this->getGroupId()) {
                     $pm = ProjectManager::instance();
                     $g = $pm->getProject($this->getGroupId());
                     $this->_set_doesnot_belong_to_project_error($item, $g);
                 } else {
                     $user = $this->getUser();
                     $dpm = $this->_getPermissionsManager();
                     $can_read = $dpm->userCanAccess($user, $item->getId());
                     $folder_or_document = is_a($item, 'Docman_Folder') ? 'folder' : 'document';
                     if (!$can_read) {
                         if ($this->request->get('action') == 'ajax_reference_tooltip') {
                             $this->_setView('AjaxReferenceTooltipError');
                         } else {
                             $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_view'));
                             $this->_setView('PermissionDeniedError');
                         }
                     } else {
                         $mdFactory = new Docman_MetadataFactory($this->_viewParams['group_id']);
                         $mdFactory->appendItemMetadataList($item);
                         $get_show_view =& new Docman_View_GetShowViewVisitor();
                         $this->_viewParams['item'] =& $item;
                         if (strpos($view, 'admin') === 0 && !$this->userCanAdmin()) {
                             $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_admin'));
                             $this->view = $item->accept($get_show_view, $this->request->get('report'));
                         } else {
                             if ($item->isObsolete()) {
                                 $this->feedback->log('warning', $this->txt('warning_obsolete'));
                             }
                             $this->_dispatch($view, $item, $root, $get_show_view);
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 function delCopyPreference()
 {
     user_del_preference(PLUGIN_DOCMAN_PREF . '_item_copy');
 }
 /**
  * Set a collapse preference for given folder for current (logged)
  * user. Stricly speaking, we should pass user in argument but there is no
  * existing function that handle prefences in this way.
  *
  * @param Folder
  */
 function collapse($folder)
 {
     user_del_preference(PLUGIN_DOCMAN_EXPAND_FOLDER_PREF . '_' . $folder->getGroupId() . '_' . $folder->getId());
 }
Exemplo n.º 6
0
    if (!$request->exist('report_id')) {
        $report_id = user_get_preference('artifact_browse_report' . $atid);
        if ($report_id == "") {
            // Default value
            $arf = new ArtifactReportFactory();
            $report_id = $arf->getDefaultReport($atid);
            if ($report_id == null) {
                $report_id = 100;
            }
        }
    } else {
        $report_id = $request->get('report_id');
        if ($report_id != user_get_preference('artifact_browse_report' . $atid)) {
            user_set_preference('artifact_browse_report' . $atid, $report_id);
            user_del_preference('artifact_browse_order' . $atid);
            user_del_preference('artifact_brow_cust' . $atid);
            $GLOBALS['Response']->redirect('?atid=' . $atid . '&group_id=' . $group_id);
        }
    }
} else {
    if (!$request->exist('report_id')) {
        $arf = new ArtifactReportFactory();
        $report_id = $arf->getDefaultReport($atid);
    } else {
        $report_id = $request->get('report_id');
    }
}
// Number of artifacts displayed on screen in one chunk.
// Default 50
$chunksz = (int) $request->get('chunksz');
if (!$chunksz) {
Exemplo n.º 7
0
<?php

require_once 'pre.php';
if (user_get_preference('tracker_comment_invertorder')) {
    user_del_preference('tracker_comment_invertorder');
} else {
    user_set_preference('tracker_comment_invertorder', '1');
}