/** * Returns a new chart object given the specified chart id * * @param integer $chartId * @return ProjectChart */ function loadChart($chartId){ $chart = ProjectCharts::findById($chartId); $res = $this->getChart($chart->getTypeId()); $res->setFromAttributes($chart->getAcceptableAttributes()); $res->setDisplayId($chart->getDisplayId()); $res->setTypeId($chart->getTypeId()); $res->setTitle($chart->getTitle()); $res->setNew(false); $res->setId($chart->getId()); $res->setProject($chart->getProject()); $res->setCreatedById($chart->getCreatedById()); $res->setCreatedOn($chart->getCreatedOn()); $res->setDeleted($chart->isDeleted()); $res->setTags($chart->getTags()); $res->setUpdatedById($chart->getUpdatedById()); $res->setUpdatedOn($chart->getUpdatedOn()); return $res; }
function delete_chart() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $chart = ProjectCharts::findById(get_id()); if (!$chart instanceof ProjectChart) { flash_error(lang('chart dnx')); ajx_current("empty"); return; } // if if (!$chart->canDelete(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if try { DB::beginWork(); $chart->trash(); ApplicationLogs::createLog($chart, $chart->getWorkspaces(), ApplicationLogs::ACTION_TRASH); DB::commit(); flash_success(lang('success deleted chart', $chart->getTitle())); ajx_current("back"); } catch (Exception $e) { DB::rollback(); flash_error(lang('error delete chart')); ajx_current("empty"); } // try }