function _ops_delete($OID = 0, $CID = 0) { $OID = max(0, intval($OID)); $CID = max(0, intval($CID)); $msg = ''; loginRequireMgmt(); if (!loginCheckPermission(USER::MGMT_TEAM)) { redirect("errors/401"); } $itemName = "Team"; $urlPrefix = "mgmt_team"; $object = new Team($OID, $CID); if (!$object->exists()) { $msg = "{$itemName} not found!"; } else { transactionBegin(); if ($object->delete()) { transactionCommit(); $msg = "{$itemName} deleted!"; } else { TransactionRollback(); $msg = "{$itemName} delete failed!"; } } redirect("{$urlPrefix}/manage", $msg); }
function delete() { $this->is_loggedin(); global $runtime; $to_trash = new Team($runtime['ident']); $to_trash->delete(); redirect('teams/all'); }
$agn = $T_INJS_REV[strtoupper($inj)]; while ($p->{$inj}-- > 0) { $status2 &= Match::ImportEntry($pid, array_merge(array_fill_keys(array_merge($T_PMD_ACH, $T_PMD_IR), 0), array_combine($T_PMD_INJ, array($pstatus, $agn, $p->{$inj}-- > 0 ? $agn : NONE)))); } } # Set player achievements $status2 &= Match::ImportEntry($pid, array_merge(array_intersect_key((array) $p, array_fill_keys($T_PMD_ACH, null)), array_combine($T_PMD_INJ, array($pstatus, NONE, NONE)), array_fill_keys($T_PMD_IR, 0))); status($status2, "Added to '{$t->name}' player '{$p->name}'"); } # Set correct treasury. $team->dtreasury($t->treasury * 1000 - $team->treasury); // $t->treasury + $delta = XML value $team->postImportSync(); } if ($ROLLBACK) { status($team->delete(), 'Successfully deleted new team due to error.'); } } } title($lng->getTrn('menu/admin_menu/import')); ?> This page allows you to create a customized team for an existing coach.<br> This is useful if you and your league wish to avoid starting from scratch in order to use OBBLM.<br> <br> <b>Note</b>: If you discover errors after having imported your team, you can either repair the errors<br> via the admin tools in the coach corner, or simply delete the team and import a new.<br> <br> <b>Note</b>: The team import feature is <b>not</b> meant to be a way for you to import the entire state of your league, with stats, into OBBLM.<br> It's meant to be an easy way of getting your existing teams into OBBLM without having to re-create the teams from scratch ie. buying players, buying team stuff, selecting player skills etc..<br> The fact that you may specify won, lost and draw games etc. for a imported team is merely to make the team pages of imported teams reflect the actual team progress - it does not allow you to integreate the imported team's stats with the future collected stats via OBBLM in, for example, the standings tables.
protected function display() { if (Tools::isConnectedUser()) { $teamList = NULL; // leadedTeams only, except Admins: they can edit all teams if ($this->session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) { $teamList = Team::getTeams(true); } else { $teamList = $this->session_user->getLeadedTeamList(true); } if (count($teamList) > 0) { if (isset($_POST['deletedteam'])) { $teamidToDelete = Tools::getSecurePOSTIntValue("deletedteam"); if (array_key_exists($teamidToDelete, $teamList)) { $retCode = Team::delete($teamidToDelete); if (!$retCode) { $this->smartyHelper->assign('error', T_("Couldn't delete the team")); } else { if ($teamidToDelete == $_SESSION['teamid']) { unset($_SESSION['teamid']); $this->updateTeamSelector(); } unset($teamList[$teamidToDelete]); } } } // use the teamid set in the form, if not defined (first page call) use session teamid if (isset($_POST['displayed_teamid'])) { $displayed_teamid = Tools::getSecurePOSTIntValue('displayed_teamid'); } else { if (isset($_SESSION['teamid']) && array_key_exists($_SESSION['teamid'], $teamList)) { $displayed_teamid = $_SESSION['teamid']; } else { $teamIds = array_keys($teamList); if (count($teamIds) > 0) { $displayed_teamid = $teamIds[0]; } else { $displayed_teamid = 0; } } } $this->smartyHelper->assign('availableTeams', SmartyTools::getSmartyArray($teamList, $displayed_teamid)); if (array_key_exists($displayed_teamid, $teamList)) { $team = TeamCache::getInstance()->getTeam($displayed_teamid); if ($displayed_teamid != Config::getInstance()->getValue(Config::id_adminTeamId)) { $this->smartyHelper->assign('allowDeleteTeam', 1); } // ----------- actions ---------- $action = isset($_POST['action']) ? $_POST['action'] : ''; if ($action == "updateTeamLeader") { $teamleader_id = Tools::getSecurePOSTIntValue('leaderid'); if (!$team->setLeader($teamleader_id)) { $this->smartyHelper->assign('error', T_("Couldn't update the team leader")); } else { // --- add teamLeader as Mantis manager of the SideTaskProject //$leader = UserCache::getInstance()->getUser($teamleader_id); //$access_level = 70; // TODO mantis manager //$leader->setProjectAccessLevel($stproj_id, $access_level); } } elseif ($action == "updateTeamCreationDate") { $formatedDate = Tools::getSecurePOSTStringValue("date_createTeam"); $date_create = Tools::date2timestamp($formatedDate); if (!$team->setCreationDate($date_create)) { $this->smartyHelper->assign('error', T_("Couldn't update the creation date")); } } elseif ($action == "setTeamEnabled") { $isTeamEnabled = 0 == Tools::getSecurePOSTIntValue("isTeamEnabled") ? false : true; if (!$team->setEnabled($isTeamEnabled)) { $this->smartyHelper->assign('error', T_("Couldn't enable/disable team")); } } elseif ($action == "addTeamMember") { $memberid = Tools::getSecurePOSTIntValue('memberid'); $memberAccess = Tools::getSecurePOSTIntValue('member_access'); $formatedDate = Tools::getSecurePOSTStringValue("date1"); $arrivalTimestamp = Tools::date2timestamp($formatedDate); try { // save to DB $team->addMember($memberid, $arrivalTimestamp, $memberAccess); // CodevTT administrators can manage ExternalTasksProject in Mantis if (Config::getInstance()->getValue(Config::id_adminTeamId) == $team->getId()) { $newUser = UserCache::getInstance()->getUser($memberid); $extProjId = Config::getInstance()->getValue(Config::id_externalTasksProject); $access_level = 70; // TODO mantis manager $newUser->setProjectAccessLevel($extProjId, $access_level); } } catch (Exception $e) { $this->smartyHelper->assign('error', "Couldn't add user {$memberid} to the team"); } } elseif ($action == "setMemberDepartureDate") { $formatedDate = Tools::getSecurePOSTStringValue("date2"); $departureTimestamp = Tools::date2timestamp($formatedDate); $memberid = Tools::getSecurePOSTIntValue('memberid'); $team->setMemberDepartureDate($memberid, $departureTimestamp); } elseif ($action == 'addMembersFrom') { $src_teamid = Tools::getSecurePOSTIntValue('f_src_teamid'); // add all members declared in Team $src_teamid (same dates, same access) // except if already declared $team->addMembersFrom($src_teamid); } elseif ($action == 'removeIssueTooltip') { $projectid = Tools::getSecurePOSTIntValue('projectid'); $project = ProjectCache::getInstance()->getProject($projectid); $project->setIssueTooltipFields(NULL, $displayed_teamid); } elseif ($action == 'setConsistencyCheck') { $keyvalue = Tools::getSecurePOSTStringValue('checkItems'); $checkList = Tools::doubleExplode(':', ',', $keyvalue); $team->setConsistencyCheckList($checkList); } elseif ($action == 'setGeneralPrefs') { $keyvalue = Tools::getSecurePOSTStringValue('checkItems'); $checkList = Tools::doubleExplode(':', ',', $keyvalue); $team->setGeneralPrefsList($checkList); } elseif ($action == 'createSideTaskProject') { $stprojName = Tools::getSecurePOSTStringValue('stprojName'); $stproj_id = $team->createSideTaskProject($stprojName); if ($stproj_id > 0) { $stproj = ProjectCache::getInstance()->getProject($stproj_id); // add teamLeader as Mantis manager of the SideTaskProject $leader = UserCache::getInstance()->getUser($team->getLeaderId()); $access_level = 70; // TODO mantis manager $leader->setProjectAccessLevel($stproj_id, $access_level); // add SideTaskProject Categories $stproj->addCategoryProjManagement(T_("Project Management")); $stproj->addCategoryInactivity(T_("Inactivity")); $stproj->addCategoryIncident(T_("Incident")); $stproj->addCategoryTools(T_("Tools")); $stproj->addCategoryWorkshop(T_("Team Workshop")); } } elseif (isset($_POST["deleteValue"])) { $duration = TimeTrackingTools::getDurationList($displayed_teamid); $duration_value = Tools::getSecurePOSTStringValue('deleteValue'); unset($duration[$duration_value]); if (count($duration) == 0) { Config::deleteValue(Config::id_durationList, array(0, 0, $displayed_teamid, 0, 0, 0)); } else { Config::setValue(Config::id_durationList, Tools::doubleImplode(":", ",", $duration), Config::configType_keyValue, NULL, 0, 0, $displayed_teamid); } } elseif (isset($_POST["addValue"])) { $duration = TimeTrackingTools::getDurationList($displayed_teamid); $duration_value = Tools::getSecurePOSTStringValue('addValue'); $duration_display = Tools::getSecurePOSTStringValue('addDisplay'); $duration[$duration_value] = $duration_display; Config::setValue(Config::id_durationList, Tools::doubleImplode(":", ",", $duration), Config::configType_keyValue, NULL, 0, 0, $displayed_teamid); } elseif (isset($_POST["updateValue"])) { $duration = TimeTrackingTools::getDurationList($displayed_teamid); $duration_value = Tools::getSecurePOSTStringValue('updateValue'); $duration_display = Tools::getSecurePOSTStringValue('updateDisplay'); $duration[$duration_value] = $duration_display; Config::setValue(Config::id_durationList, Tools::doubleImplode(":", ",", $duration), Config::configType_keyValue, NULL, 0, 0, $displayed_teamid); } elseif (isset($_POST["deletememberid"])) { $memberid = Tools::getSecurePOSTIntValue('deletememberid'); $query = "DELETE FROM `codev_team_user_table` WHERE id = {$memberid};"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { $this->smartyHelper->assign('error', T_("Couldn't delete the member of the team")); } } elseif (isset($_POST['addedprojectid'])) { $projectid = Tools::getSecurePOSTIntValue('addedprojectid'); if (0 != $projectid) { $projecttype = Tools::getSecurePOSTIntValue('project_type'); try { // prepare Project to CoDev (associate with CoDev customFields if needed) // WARN: Project constructor cannot be used in here. Project::prepareProjectToCodev($projectid); // save to DB if (!$team->addProject($projectid, $projecttype)) { $this->smartyHelper->assign('error', T_("Couldn't add the project to the team")); } } catch (Exception $e) { $this->smartyHelper->assign('error', T_("Couldn't add the project to the team")); } } } elseif (isset($_POST['deletedprojectid'])) { $projectid = Tools::getSecurePOSTIntValue('deletedprojectid'); if (!$team->removeProject($projectid)) { $this->smartyHelper->assign('error', T_("Could NOT remove the project from the team")); } } elseif (isset($_POST['addedastreinte_id'])) { $onduty_id = Tools::getSecurePOSTIntValue('addedastreinte_id'); if (0 != $onduty_id) { $team->addOnDutyTask($onduty_id); } } elseif (isset($_POST['deletedastreinte_id'])) { $onduty_id = Tools::getSecurePOSTIntValue('deletedastreinte_id'); $team->removeOnDutyTask($onduty_id); } $this->smartyHelper->assign('team', $team); $smartyUserList = array(); $userList = User::getUsers(); $selectedUserid = $team->getLeaderId(); foreach ($userList as $id => $name) { $u = UserCache::getInstance()->getUser($id); $uname = $u->getRealname(); if (empty($uname)) { $uname = $name; } $smartyUserList[$id] = array('id' => $id, 'name' => $uname, 'selected' => $id == $selectedUserid); } $this->smartyHelper->assign('users', $smartyUserList); $this->smartyHelper->assign('date', date("Y-m-d", $team->getDate())); $this->smartyHelper->assign('accessLevel', Team::$accessLevelNames); $this->smartyHelper->assign('arrivalDate', date("Y-m-d", time())); $this->smartyHelper->assign('departureDate', date("Y-m-d", time())); $this->smartyHelper->assign('teamMembers', $this->getTeamMembers($displayed_teamid)); $this->smartyHelper->assign('teamEnabled', $team->isEnabled()); $this->smartyHelper->assign('otherProjects', $team->getOtherProjects()); $this->smartyHelper->assign('typeNames', Project::$typeNames); $this->smartyHelper->assign('teamProjects', $this->getTeamProjects($displayed_teamid)); $this->smartyHelper->assign('onDutyCandidates', $this->getOnDutyCandidates($team, $team->getTrueProjects())); $this->smartyHelper->assign('onDutyTasks', $this->getOnDutyTasks($team)); $this->smartyHelper->assign('duration', TimeTrackingTools::getDurationList($displayed_teamid)); $projectList = $this->getTooltipProjectCandidates($team); $this->smartyHelper->assign('tooltipProjectCandidates', $projectList); $this->smartyHelper->assign('issueTooltips', $this->getIssueTooltips($projectList, $displayed_teamid)); $this->smartyHelper->assign('itemSelection_openDialogBtLabel', T_('Configure Tooltips')); $consistencyChecks = $this->getConsistencyChecks($team); $this->smartyHelper->assign('consistencyChecks', $consistencyChecks); $teamGeneralPrefs = $this->getTeamGeneralPrefs($team); $this->smartyHelper->assign('teamGeneralPrefs', $teamGeneralPrefs); } } } }
<?php require_once "/etc/apache2/capstone-mysql/encrypted-config.php"; require_once "your-class-file.php"; $pdo = connectToEncryptedMySQL("/etc/apache2/data-design/dfontaine1.ini"); // now procede to PDO normally $team = new Team(null, 1, "this is from PHP"); $team->insert($pdo); $team->setTeamContent("now I change the message"); $team->update($pdo); $team->delete($pdo);