$template->assign("users", $users); $template->assign("projects", $projects); $template->assign("roles", $roles); $template->display("adminusers.tpl"); } elseif ($action == "adduser") { // Get the system locale and set it as the default locale for the new user $sysloc = $settings["locale"]; // Add the user $newid = $user->add($name, $email, $company, $pass, $sysloc, $tags, $rate); //user has been created successfully if ($newid) { //are there projects the userd should be assigned to if (!empty($assignto)) { // Assign the user to all selected projects foreach ($assignto as $proj) { $project->assign($newid, $proj); } } $roleobj = (object) new roles(); $roleobj->assign($role, $newid); if ($settings["mailnotify"]) { if (!empty($email)) { $subject = $langfile["profileaddedsubject"] . ' (' . $langfile['by'] . ' ' . $username . ')'; $mailcontent = $langfile["hello"] . ",<br /><br/>" . $langfile["profileaddedtext"] . "<br /><br />" . $langfile["profileusername"] . ": " . "{$name}<br />" . $langfile["profilepass"] . ": " . "{$pass}<br /><br />" . "<a href = \"{$url}\">{$url}</a>"; // send email $themail = new emailer($settings); $themail->send_mail($email, $subject, $mailcontent); } } header("Location: admin.php?action=users&mode=added"); } else {
private function addProjects($projectsArray) { $addProject = new project(); foreach ($projectsArray->project as $project) { $name = $project->{'name'}; $desc = $name; $start = $project->{'created-on'}; //TODO das muss in nen loop mit assign, damit wirklich alle user assigned werden $uid = $project->{'participants'}->{'person'}; $user = $this->peopleHash["{$uid}"]; $status = 1; if ($project->{'status'} != "active") { $status = 0; } $project_id = $addProject->AddFromBasecamp($name, $desc, $start, $status); if ($project_id) { $addProject->assign($user, $project_id); if (isset($_SESSION["userid"])) { $addProject->assign($_SESSION["userid"], $project_id); } $milestonesHash = $this->addMilestones($project_id, $project->{'milestones'}); $this->addTasks($project_id, $milestonesHash, $project->{'todo-lists'}); $this->addMessages($project_id, $project->{'posts'}); ++$this->projectCount; } } }
function addProjectFromExcel($inputFileName) { include "./include/PHPExcel/IOFactory.php"; $objReader = new PHPExcel_Reader_Excel2007(); $objPHPExcel = $objReader->load($inputFileName); $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); $limiter = "#"; $projectObj = new project(); $userObj = new user(); $milestoneObj = new milestone(); $tasklistObj = new tasklist(); $taskObj = new task(); $companyObj = new company(); $projectname = $sheetData[2]["A"]; $projectdescription = $sheetData[3]["A"]; $projectdue = $sheetData[4]["A"]; $projectbudget = $sheetData[5]["A"]; $projectcustomer = $sheetData[6]["A"]; $projectpriority = $sheetData[7]["A"]; $projectId = $projectObj->add($projectname, $projectdescription, $projectdue, $projectbudget, $projectpriority); $customer = $companyObj->getCompanyByName($projectcustomer); if ($customer) { $companyObj->assign($customer["ID"], $projectId); } // USERS for ($i = 1; $i < count($sheetData); $i++) { $username = $sheetData[$i]["B"]; if ($username) { $user = $userObj->getUserByName($username); if ($user) { $projectObj->assign($user["ID"], $projectId); } } else { break; } } // MILESTONES for ($i = 1; $i < count($sheetData); $i++) { $milestone = explode($limiter, $sheetData[$i]["C"]); if ($milestone) { $milestoneObj->add($projectId, $milestone[0], $milestone[1], $milestone[2], $milestone[3]); } else { break; } } // TASK LISTS for ($i = 1; $i < count($sheetData); $i++) { $tasklist = explode($limiter, $sheetData[$i]["D"]); if ($tasklist) { if ($tasklist[3]) { $milestone = $milestoneObj->getMilestoneByName($tasklist[3]); if ($milestone) { $tasklistObj->add_liste($projectId, $tasklist[0], $tasklist[1], $tasklist[2], 0, $milestone["ID"]); } } else { $tasklistObj->add_liste($projectId, $tasklist[0], $tasklist[1], $tasklist[2]); } } else { break; } } // TASKS for ($i = 1; $i < count($sheetData); $i++) { $task = explode($limiter, $sheetData[$i]["E"]); if ($task) { $tasklist = $tasklistObj->getTasklistByName($task[5]); $taskid = $taskObj->add($task[2], $task[3], $task[0], $task[4], $tasklist["ID"], $projectId, $task[6], $task[7]); $user = $userObj->getUserByName($task[1]); if ($taskid) { if ($user) { $taskObj->assign($taskid, $user["ID"]); } } } else { break; } } return $projectId; }