// update dataProvider
                    $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $startTimestamp);
                    $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $endTimestamp);
                    $indicator = new LoadPerUserIndicator($pluginDataProvider);
                    // override plugin settings with current attributes
                    $indicator->setPluginSettings(array(LoadPerUserIndicator::OPTION_SHOW_SIDETASKS => $showSidetasks));
                    $indicator->execute();
                    $data = $indicator->getSmartyVariablesForAjax();
                    // construct the html table
                    foreach ($data as $smartyKey => $smartyVariable) {
                        $smartyHelper->assign($smartyKey, $smartyVariable);
                        #$logger->debug("key $smartyKey = ".var_export($smartyVariable, true));
                    }
                    $html = $smartyHelper->fetch(LoadPerUserIndicator::getSmartySubFilename());
                    $data['loadPerUser_htmlContent'] = $html;
                    // return html & chart data
                    $jsonData = json_encode($data);
                    echo $jsonData;
                } else {
                    Tools::sendBadRequest("PluginDataProvider unserialize error");
                }
            } else {
                Tools::sendBadRequest("PluginDataProvider not set");
            }
        } else {
            Tools::sendNotFoundAccess();
        }
    }
} else {
    Tools::sendUnauthorizedAccess();
}
require '../../path.inc.php';
// Note: i18n is included by the Controler class, but Ajax dos not use it...
require_once 'i18n/i18n.inc.php';
if (Tools::isConnectedUser() && filter_input(INPUT_GET, 'action')) {
    $teamid = isset($_SESSION['teamid']) ? $_SESSION['teamid'] : 0;
    $logger = Logger::getLogger("LoadPerUserIndicator_ajax");
    $action = Tools::getSecureGETStringValue('action');
    $dashboardId = Tools::getSecureGETStringValue('dashboardId');
    if (!isset($_SESSION[PluginDataProviderInterface::SESSION_ID . $dashboardId])) {
        $logger->error("PluginDataProvider not set (dashboardId = {$dashboardId}");
        Tools::sendBadRequest("PluginDataProvider not set");
    }
    $pluginDataProvider = unserialize($_SESSION[PluginDataProviderInterface::SESSION_ID . $dashboardId]);
    if (FALSE == $pluginDataProvider) {
        $logger->error("PluginDataProvider unserialize error (dashboardId = {$dashboardId}");
        Tools::sendBadRequest("PluginDataProvider unserialize error");
    }
    $smartyHelper = new SmartyHelper();
    if ('getLoadPerUserIndicator' == $action) {
        // TODO do not log exception if date = 01-01-1970
        $startTimestamp = Tools::date2timestamp(Tools::getSecureGETStringValue("loadPerUser_startdate"));
        $endTimestamp = Tools::date2timestamp(Tools::getSecureGETStringValue("loadPerUser_enddate"));
        $attributesJsonStr = Tools::getSecureGETStringValue('attributesJsonStr');
        $attributesArray = json_decode(stripslashes($attributesJsonStr), true);
        $showSidetasks = 'on' != $attributesArray[LoadPerUserIndicator::OPTION_SHOW_SIDETASKS] ? false : true;
        //$logger->error("showSidetasks = ".var_export($showSidetasks, true).' attr '.$attributesArray[LoadPerUserIndicator::OPTION_SHOW_SIDETASKS]);
        // update dataProvider
        $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $startTimestamp);
        $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $endTimestamp);
        $indicator = new LoadPerUserIndicator($pluginDataProvider);
        // override plugin settings with current attributes
                $userid = $_SESSION['userid'];
                $issueNote->markAsRead($userid);
                $data = 'OK';
            } else {
                $data = 'ERROR';
                // TODO return ERROR
                Tools::sendBadRequest("Could not mark as read.");
            }
            // return data
            echo $data;
        } else {
            if ($_POST['action'] == 'deleteNote') {
                $userid = $_SESSION['userid'];
                $bugid = Tools::getSecurePOSTIntValue('bugid');
                $bugnoteid = Tools::getSecurePOSTIntValue('bugnote_id');
                $retCode = IssueNote::delete($bugnoteid, $bugid, $userid);
                if ($retCode) {
                    $data = 'OK';
                } else {
                    $data = 'ERROR';
                    // TODO return ERROR
                    Tools::sendBadRequest("Could not delete note.");
                }
                // return data
                echo $data;
            }
        }
    }
} else {
    Tools::sendUnauthorizedAccess();
}
Example #4
0
                        $team = TeamCache::getInstance()->getTeam($teamid);
                        $prjList = $team->getProjects();
                        if (!$user->isTeamManager($teamid)) {
                            $logger->error("addToCmd: NOT_MANAGER user={$userid} issue={$bugid} cmd={$cmdid}");
                            $jsonData = json_encode(array('statusMsg' => T_('Sorry, only managers can add tasks to commands')));
                        } else {
                            if (!array_key_exists($issue->getProjectId(), $prjList)) {
                                $jsonData = json_encode(array('statusMsg' => T_("Sorry, this task is not in your team's projects")));
                            } else {
                                if ($teamid != $cmd->getTeamid()) {
                                    Tools::sendBadRequest("Error: addToCmd bad cmdid: user={$userid} teamid={$teamid} cmd={$cmdid}");
                                } else {
                                    $cmd->addIssue($bugid, true);
                                    $jsonData = json_encode(array('statusMsg' => 'SUCCESS', 'cmdid' => $cmdid, 'cmdName' => $cmd->getName()));
                                }
                            }
                        }
                        // return ajax data
                        echo $jsonData;
                    } catch (Exception $e) {
                        Tools::sendBadRequest("Error: addToCmd bad values: user={$userid} issue={$bugid} cmd={$cmdid}");
                    }
                } else {
                    Tools::sendNotFoundAccess();
                }
            }
        }
    }
} else {
    Tools::sendUnauthorizedAccess();
}
Example #5
0
                        $team = TeamCache::getInstance()->getTeam($teamid);
                        $prjList = $team->getProjects();
                        if (!$user->isTeamManager($teamid)) {
                            $logger->error("removeFromCmd: NOT_MANAGER user={$userid} issue={$bugid} cmd={$cmdid}");
                            $jsonData = json_encode(array('statusMsg' => T_('Sorry, only managers can remove tasks from commands')));
                        } else {
                            if (!array_key_exists($issue->getProjectId(), $prjList)) {
                                $jsonData = json_encode(array('statusMsg' => T_("Sorry, this task is not in your team's projects")));
                            } else {
                                if ($teamid != $cmd->getTeamid()) {
                                    Tools::sendBadRequest("Error: removeFromCmd bad cmdid: user={$userid} teamid={$teamid} cmd={$cmdid}");
                                } else {
                                    $cmd->addIssue($bugid, true);
                                    $jsonData = json_encode(array('statusMsg' => 'SUCCESS', 'cmdid' => $cmdid, 'cmdName' => $cmd->getName()));
                                }
                            }
                        }
                        // return ajax data
                        echo $jsonData;
                    } catch (Exception $e) {
                        Tools::sendBadRequest("Error: removeFromCmd bad values: user={$userid} issue={$bugid} cmd={$cmdid}");
                    }
                } else {
                    Tools::sendNotFoundAccess();
                }
            }
        }
    }
} else {
    Tools::sendUnauthorizedAccess();
}
Example #6
0
                    if ($selectedTooltips != NULL) {
                        $tooltips = explode(',', $selectedTooltips);
                    }
                    $project = ProjectCache::getInstance()->getProject($projectid);
                    $project->setIssueTooltipFields($tooltips, $teamid);
                    $formattedFields = array();
                    if ($tooltips != NULL) {
                        foreach ($tooltips as $f) {
                            $formattedFields[] = Tools::getTooltipFieldDisplayName($f);
                        }
                    }
                    $strFields = implode(', ', $formattedFields);
                    // return row to add/replace in issueTooltipsTable
                    $response = array();
                    $response['projectid'] = $projectid;
                    $response['projectName'] = $project->getName();
                    $response['tooltipFields'] = $strFields;
                    // json encode
                    $jsonResponse = Tools::array2json($response);
                    echo "{$jsonResponse}";
                } catch (Exception $e) {
                    Tools::sendBadRequest($e->getMessage());
                }
            } else {
                Tools::sendNotFoundAccess();
            }
        }
    }
} else {
    Tools::sendUnauthorizedAccess();
}
Example #7
0
                    try {
                        // save Provision changes
                        foreach ($provisions as $provid => $isInCheckBudget) {
                            $prov = new CommandProvision($provid);
                            // securityCheck: does provid belong to this command ?
                            if ($cmdid == $prov->getCommandId()) {
                                $prov->setIsInCheckBudget($isInCheckBudget);
                            } else {
                                // LOG SECURITY ERROR !!
                                Tools::sendBadRequest("Provision {$provid} does not belong to Command {$cmdid} !");
                            }
                        }
                    } catch (Exception $e) {
                        Tools::sendBadRequest(T_("Provisions updated FAILED !"));
                    }
                    // write in 'data'
                    echo 'SUCCESS';
                } else {
                    Tools::sendBadRequest("Invalid CommandId: 0");
                }
            } else {
                Tools::sendBadRequest("Command not set");
            }
        } else {
            Tools::sendNotFoundAccess();
        }
    }
} else {
    // send 'Forbidden' caught by ajax: function(jqXHR, textStatus, errorThrown)
    Tools::sendUnauthorizedAccess();
}