本文整理汇总了PHP中Project::setDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::setDescription方法的具体用法?PHP Project::setDescription怎么用?PHP Project::setDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project::setDescription方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addProject
/**
* Adds a new GOCDB project.
* @param array $values array containing name and description of the new project
* @param \user $user User making the change, only admin users may add projects
* @return \Project
* @throws \Exception
* @throws \org\gocdb\services\Exception
*/
public function addProject($values, \user $user = null)
{
//Check the portal is not in read only mode, throws exception if it is
$this->checkPortalIsNotReadOnlyOrUserIsAdmin($user);
//Throws exception if user is not an administrator
$this->checkUserIsAdmin($user);
//Check all the required values are present and validate the new values using the GOCDB schema file
$this->validate($values);
//check the name is unique
if (!$this->projectNameIsUnique($values['Name'])) {
throw new \Exception("Project names must be unique, '" . $values['Name'] . "' is already in use");
}
//Start transaction
$this->em->getConnection()->beginTransaction();
// suspend auto-commit
try {
//new project object
$project = new \Project($values['Name']);
//set description
$project->setDescription($values['Description']);
$this->em->persist($project);
$this->em->flush();
$this->em->getConnection()->commit();
} catch (\Exception $e) {
$this->em->getConnection()->rollback();
$this->em->close();
throw $e;
}
return $project;
}
示例2: testTpConfig
public function testTpConfig()
{
$project = new Project();
$project->setName('name');
$project->setDescription('description');
$project->setKeywords(['k1', 'k2']);
$project->setHomepage('http://homepage.com');
$project->addAuthor(new Author('author-name <author@email.com>'));
$project->addPackage($this->buildPackage('namespace1', ['path1.1', 'path1.2']));
$this->assertSame(['name' => 'name', 'description' => 'description', 'keywords' => ['k1', 'k2'], 'homepage' => 'http://homepage.com', 'authors' => [['name' => 'author-name', 'email' => 'author@email.com']], 'autoload' => ['psr-4' => ['namespace1\\' => ['path1.1', 'path1.2']]]], $project->toConfig());
}
示例3: processCreate
protected function processCreate(sfWebRequest $request, ProjectFormCustom $form)
{
$form->bind($request->getParameter($form->getName()));
if ($form->isValid()) {
$values = $form->getValues();
// Slugify name, and check if slug generated does not already exist and generate a new one if needed
if (empty($values['name_slug'])) {
$slug = MiscUtils::slugify($values['name']);
} else {
$slug = $values['name_slug'];
}
$size = 1;
while (Doctrine_Core::getTable("Project")->checkSlugForProject(NULL, $slug, true)) {
$slug = MiscUtils::slugify($values['name']) . substr(microtime(), -$size);
$size++;
}
// Create the project into database
$projectObject = new Project();
$projectObject->setName($values['name']);
$projectObject->setDescription($values['description']);
$projectObject->setUserId($values['user_id']);
$projectObject->setCreatedAt($values['created_at']);
$projectObject->setStatus($values['status']);
$projectObject->setSecurityLevel($values['security_level']);
$projectObject->setNameSlug($slug);
$projectObject->save();
// Get the project's id
$projectId = $projectObject->getId();
// Create a new relationship between projects, products and project groups for each checked form's product
foreach ($values['product'] as $product) {
$ptpObject = new ProjectToProduct();
$ptpObject->setProjectGroupId($values['group']);
$ptpObject->setProjectId($projectId);
$ptpObject->setProductId($product);
$ptpObject->save();
}
if ($request->hasParameter('_save_and_add')) {
$this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
$this->redirect('@project_new');
} else {
$this->getUser()->setFlash('notice', $notice);
$this->redirect(array('sf_route' => 'project_edit', 'sf_subject' => $projectObject));
}
} else {
$this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
}
}
示例4: setDescription
class Project
{
protected $description;
public function setDescription($description)
{
$this->description = $description;
return $this;
}
public function getDescription()
{
return $this->description;
}
}
$project_one = new Project();
$project_one->setDescription("This is my first test project");
echo $project_one->getDescription();
echo "<br>";
$project_two = $project_one;
// Copying by value?
echo $project_two->getDescription();
echo "<br>";
$project_two->setDescription("This is my second test project");
echo $project_two->getDescription();
echo "<br>";
echo $project_one->getDescription();
echo "<br>";
echo "Cloning..";
$project_three = clone $project_one;
echo $project_three->getDescription();
$project_three->setDescription("This is my third test project");
示例5: executeSaveNew
public function executeSaveNew()
{
$project = new Project();
$culture = $this->getUser()->getCulture();
// TODO: Implement multiple owners / project leads, if necessary
$project->setCreatedBy($this->getUser()->getGuardUser()->getId());
$project->setOwnerId($this->getUser()->getGuardUser()->getId());
$project->setDepartmentId($this->getRequestParameter('department_id') ? $this->getRequestParameter('department_id') : null);
$project->setTitle($this->getRequestParameter('title'));
$project->setDescription($this->getRequestParameter('description'));
$project->setNotes($this->getRequestParameter('notes'));
$project->setKeywords($this->getRequestParameter('tags_as_text'));
if ($this->getRequestParameter('begin')) {
list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('begin'), $this->getUser()->getCulture());
$project->setBegin("{$y}-{$m}-{$d}");
}
if ($this->getRequestParameter('finish')) {
list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('finish'), $this->getUser()->getCulture());
$project->setFinish("{$y}-{$m}-{$d}");
}
$this->logMessage('Dates Saved');
$project->setCampusId($this->getRequestParameter('campus'));
$project->setPublished($this->getRequestParameter('published', 0));
$project->save();
$this->logMessage('Project Saved');
$project->createDefaultPermissions();
return $this->redirect('project/awaitApproval');
}
示例6: executeSaveProject
/**
* Save Customer
* @param sfWebRequest $request
* @return unknown_type
*/
public function executeSaveProject(sfWebRequest $request)
{
$projectService = new ProjectService();
if ($request->isMethod('post')) {
$project = new Project();
$project->setCustomerId($request->getParameter('cmbCustomerId'));
$project->setName($request->getParameter('txtName'));
$project->setDescription($request->getParameter('txtDescription'));
$projectService->saveProject($project);
$this->setMessage('SUCCESS', array(TopLevelMessages::SAVE_SUCCESS));
$this->redirect('admin/listProject');
}
$customerService = new CustomerService();
$this->listCustomer = $customerService->getCustomerList();
}
示例7: find
function find($criteria = null, $order = null, $limit = 1000, $from = 0)
{
$result = $this->database->query($this->buildFindQuery($criteria, $order, $limit, $from));
if (!is_null($result->getError())) {
return $result->getError();
}
$projects = array();
while ($row = $result->fetchRow()) {
$project = new Project();
$value = $row[0];
$project->setId($value);
$value = $row[1];
$project->setName($value);
$value = $row[2];
$project->setDescription($value);
$value = $row[3];
$value = $this->database->toBoolean($value);
$project->setMove_more($value);
$value = $row[4];
$project->setCampaign($value);
$value = $row[5];
$project->setSuspending($value);
$value = $row[6];
$project->setEnding($value);
$value = $row[7];
$project->setOwner($value);
$value = $row[8];
$project->setCruid($value);
$value = $row[9];
$project->setPkey($value);
$value = $row[10];
$project->setRsskey($value);
$value = $row[11];
$project->setR_date($value);
$value = $row[12];
$project->setR_user($value);
if ($order != null) {
array_push($projects, $project);
} else {
$projects[$project->getId()] = $project;
}
}
return $projects;
}
示例8: add
public function add($name)
{
$this->view = null;
try {
$user = User::find(Session::uid());
if (!$user->getId() || !$user->getIs_admin()) {
throw new Exception('Action not allowed.');
}
if (!preg_match('/^\\d*[-a-zA-Z][-a-zA-Z0-9]*$/', $name)) {
throw new Exception('The name of the project can only contain alphanumeric characters plus dashes and must have 1 alpha character at least');
}
try {
$project = Project::find($name);
} catch (Exception $e) {
}
if (is_object($project) && $project->getProjectId($name)) {
throw new Exception('Project with the same name already exists!');
}
$file = new File();
$logo = '';
if (!empty($_POST['logo'])) {
$file->findFileById($_POST['logo']);
$logo = basename($file->getUrl());
}
$project = new Project();
$project->setName($name);
$project->setDescription($_POST['description']);
$project->setWebsite($_POST['website']);
$project->setContactInfo($user->getUsername());
$project->setOwnerId($user->getId());
$project->setActive(true);
$project->setInternal(true);
$project->setRequireSandbox(true);
$project->setLogo($logo);
$project->setRepo_type('git');
$project->setRepository($_POST['github_repo_url']);
$project->setGithubId($_POST['github_client_id']);
$project->setGithubSecret($_POST['github_client_secret']);
$project->save();
if ($file->getId()) {
$file->setProjectId($project->getProjectId());
$file->save();
}
$journal_message = '@' . $user->getNickname() . ' added project *' . $name . '*';
Utils::systemNotification($journal_message);
echo json_encode(array('success' => true, 'message' => $journal_message));
} catch (Exception $e) {
$error = $e->getMessage();
echo json_encode(array('success' => false, 'message' => $error));
}
}
示例9: approve
public function approve()
{
if (!$this->getIsApproved()) {
$this->setIsApproved(true);
$project = new Project();
$project->setCreatedBy($this->getCreatedBy());
$project->setOwnerId($this->getOwnerId());
$project->setDepartmentId($this->getDepartmentId());
$project->setCampusId($this->getCampusId());
$project->setTitle($this->getTitle());
$project->setDescription($this->getDescription());
$project->setNotes($this->getNotes());
$project->setBegin($this->getBegin());
$project->setFinish($this->getFinish());
$project->setMainForm('default');
$project->setPublished(true);
$project->setIsApproved(true);
$project->save();
}
}
示例10: actionSave
function actionSave($currentUser)
{
$backUrl = $this->context->getFlowScopeAttr("backUrl");
$oldRssKey = null;
$project = new Project();
$projectErrs = array();
$project->setId($this->context->getRequestAttr("id"));
if (!is_null($project->getId())) {
$oldProject = $this->projectDao->get($project->getId());
if (is_null($oldProject) || is_string($oldProject)) {
$this->context->setRequestScopeAttr("error", "error.dberror");
if (!is_null($backUrl)) {
header("Location: " . $backUrl);
return true;
}
return false;
}
}
$project->setName($this->context->getRequestAttr("name"));
if (!is_null($project->getName())) {
$project->setName(trim($project->getName()));
if (strlen($project->getName()) < 1) {
$project->setName(null);
}
}
if (is_null($project->getName())) {
$projectErrs["name"] = "field.error.empty";
}
$project->setDescription($this->context->getRequestAttr("description"));
if (!is_null($project->getDescription())) {
$project->setDescription(trim($project->getDescription()));
if (strlen($project->getDescription()) < 1) {
$project->setDescription(null);
}
}
$project->setCampaign($this->context->getRequestAttr("campaign"));
if (!is_null($project->getCampaign())) {
$project->setCampaign(trim($project->getCampaign()));
if (strlen($project->getCampaign()) < 1) {
$project->setCampaign(null);
}
}
$project->setSuspending($this->context->getRequestAttr("suspending"));
if (!is_null($project->getSuspending())) {
$project->setSuspending(trim($project->getSuspending()));
if (strlen($project->getSuspending()) < 1) {
$project->setSuspending(null);
}
}
$project->setEnding($this->context->getRequestAttr("ending"));
if (!is_null($project->getEnding())) {
$project->setEnding(trim($project->getEnding()));
if (strlen($project->getEnding()) < 1) {
$project->setEnding(null);
}
}
$move_more = $this->context->getRequestAttr("move_more");
$project->setMove_more($move_more == 1 ? true : false);
$timeZone = new DateTimeZone("Europe/Vilnius");
$time = new DateTime("now", $timeZone);
$project->setR_date($time->format("Y-m-d H:i:s"));
$project->setR_user($currentUser->getId());
if (is_null($project->getId())) {
$project->setOwner($currentUser->getId());
$project->setCruid($this->generateCode());
$project->setPkey($this->generateCode());
$project->setRsskey($this->generateCode());
} else {
$project->setCruid($oldProject->getCruid());
$project->setRsskey($oldProject->getRssKey());
}
$this->context->setFlashScopeAttr("project", $project);
$this->context->setFlashScopeAttr("projectErrs", $projectErrs);
if (count($projectErrs) >= 1) {
if (!is_null($backUrl)) {
header("Location: " . $backUrl);
return true;
}
return false;
}
$store = $this->storeProject($project);
if (!$store) {
if (!is_null($backUrl)) {
header("Location: " . $backUrl);
return true;
}
return false;
}
$rss = new Rss($project->getRsskey());
if (!$rss->storeProjectRssFile($project)) {
$this->context->setRequestScopeAttr("errortxt", "Nepavyko sukurti/atnaujinti RSS failo!");
}
/* Issaugom pasirinktas grupes */
$groups = $this->context->getRequestAttr("groups");
$selectedProjects = $this->context->getRequestAttr("selectedProjects");
if (is_null($selectedProjects) && !is_null($groups)) {
$this->saveProjectGroups($project->getId(), $groups);
}
if (!is_null($selectedProjects) && is_null($groups)) {
$this->removeProjectFromGroups($currentUser->getId(), $project->getId());
//.........这里部分代码省略.........
示例11: fValidationException
throw new fValidationException('Arrival date must be no earlier than today.');
}
// from < max
if (strtotime($_POST['from_date']) > strtotime("+{$maxStorageMonths} months")) {
throw new fValidationException('Arrival date must be in the next 6 months.');
}
// to > from
if (strtotime($_POST['to_date']) < strtotime($_POST['from_date'])) {
throw new fValidationException('Removal date must come after arrival date.');
}
// to < max
if (strtotime($_POST['to_date']) > strtotime("+{$maxStorageMonths} months", strtotime($_POST['from_date']))) {
throw new fValidationException('Removal date must be 6 months after arrival.');
}
$project->setName(filter_var($_POST['name'], FILTER_SANITIZE_STRING));
$project->setDescription(filter_var($_POST['description'], FILTER_SANITIZE_STRING));
if ($_POST['contact'] && $_POST['contact'] != '') {
$project->setContact(filter_var($_POST['contact'], FILTER_SANITIZE_EMAIL));
} else {
$project->setContact(null);
}
$project->setLocationId(filter_var($_POST['location_id'], FILTER_SANITIZE_STRING));
$project->setLocation(filter_var($_POST['location'], FILTER_SANITIZE_STRING));
$project->setFromDate(filter_var($_POST['from_date'], FILTER_SANITIZE_STRING));
$project->setToDate(filter_var($_POST['to_date'], FILTER_SANITIZE_STRING));
if (!$project->getId()) {
$auto = true;
$logDetails = "Request created";
$project->setState('Pending Approval');
$initial = true;
} else {
示例12: array
/**
*
* @param unknown_type $rs
*/
private static function &_getObject(Resultset $rs, array $options = array())
{
isset($options['loadUsers']) ?: ($options['loadUsers'] = true);
$ret = new Project();
$ret->setAvatar($rs->getAvatar());
$ret->setScmConnectorType($rs->getScmConnectorType());
$ret->setScmRemoteRepository($rs->getScmRemoteRepository());
$ret->setScmUsername($rs->getScmUsername());
$ret->setScmPassword($rs->getScmPassword());
$ret->setScmCheckChangesTimeout($rs->getScmCheckChangesTimeout());
$ret->setWorkDir($rs->getWorkDir());
$ret->setReleaseLabel($rs->getReleaseLabel());
$ret->setDateCreation($rs->getDateCreation());
$ret->setDateCheckedForChanges($rs->getDateCheckedForChanges());
$ret->setDescription($rs->getDescription());
$ret->setId($rs->getId());
$specialTasks = @unserialize($rs->getSpecialTasks());
if ($specialTasks === false) {
$specialTasks = array();
}
$ret->setSpecialTasks($specialTasks);
$ret->setStatsNumBuilds($rs->getStatsNumBuilds());
$ret->setStatus($rs->getStatus());
$ret->setTitle($rs->getTitle());
$ret->setVisits($rs->getVisits());
$ret->setOptionReleasePackage($rs->getOptionReleasePackage());
$ret->setScmEnvVars($rs->getScmEnvVars());
//
// Builders
//
//
// The following is a workaround on the fact that the translation of this
// serialized object to the database gets all broken, due to the fact of PHP
// introducing NULL bytes around the '*' that is prepended before protected
// variable members, in the serialized mode. This method replaces those
// problematic NULL bytes with an identifier string '~~NULL_BYTE~~',
// rendering serialization and unserialization of these specific kinds of
// object safe. Credits to travis@travishegner.com on:
// http://pt.php.net/manual/en/function.serialize.php#96504
//
$unsafeSerializedIntegrationBuilder = str_replace(CINTIENT_NULL_BYTE_TOKEN, "", $rs->getIntegrationBuilder());
if (($integrationBuilder = unserialize($unsafeSerializedIntegrationBuilder)) === false) {
SystemEvent::raise(SystemEvent::ERROR, "Couldn't unserialize integration builder for this project [PID={$ret->getId()}]");
$integrationBuilder = new Build_BuilderElement_Project();
}
$ret->setIntegrationBuilder($integrationBuilder);
$unsafeSerializedDeploymentBuilder = str_replace(CINTIENT_NULL_BYTE_TOKEN, "", $rs->getDeploymentBuilder());
if (($deploymentBuilder = unserialize($unsafeSerializedDeploymentBuilder)) === false) {
SystemEvent::raise(SystemEvent::ERROR, "Couldn't unserialize deployment builder for this project [PID={$ret->getId()}]");
$deploymentBuilder = new Build_BuilderElement_Project();
}
$ret->setDeploymentBuilder($deploymentBuilder);
if ($options['loadUsers']) {
$ret->loadUsers();
}
$ret->resetSignature();
return $ret;
}
示例13: create_user
//.........这里部分代码省略.........
$contact->setUserId($user->getId());
if ($contact->isTrashed()) {
$contact->untrash();
}
$contact->save();
}
}
}
$contact = $user->getContact();
if ($contact instanceof Contact) {
// update contact data with data entered for this user
$contact->setCompanyId($user->getCompanyId());
if ($contact->getEmail() != $user->getEmail()) {
// make user's email the contact's main email address
if ($contact->getEmail2() == $user->getEmail()) {
$contact->setEmail2($contact->getEmail());
} else {
if ($contact->getEmail3() == $user->getEmail()) {
$contact->setEmail3($contact->getEmail());
} else {
if ($contact->getEmail2() == "") {
$contact->setEmail2($contact->getEmail());
} else {
$contact->setEmail3($contact->getEmail());
}
}
}
}
$contact->setEmail($user->getEmail());
$contact->save();
}
if (!$user->isGuest()) {
/* create personal project or assing the selected*/
//if recived a personal project assing this
//project as personal project for this user
$new_project = null;
$personalProjectId = array_var($user_data, 'personal_project', 0);
$project = Projects::findById($personalProjectId);
if (!$project instanceof Project) {
$project = new Project();
$wname = new_personal_project_name($user->getUsername());
$project->setName($wname);
$wdesc = Localization::instance()->lang(lang('personal workspace description'));
if (!is_null($wdesc)) {
$project->setDescription($wdesc);
}
$project->setCreatedById($user->getId());
$project->save();
//Save to set an ID number
$project->setP1($project->getId());
//Set ID number to the first project
$project->save();
$new_project = $project;
}
$user->setPersonalProjectId($project->getId());
$project_user = new ProjectUser();
$project_user->setProjectId($project->getId());
$project_user->setUserId($user->getId());
$project_user->setCreatedById($user->getId());
$project_user->setAllPermissions(true);
$project_user->save();
/* end personal project */
}
$user->save();
ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_ADD);
//TODO - Make batch update of these permissions
if ($permissionsString && $permissionsString != '') {
$permissions = json_decode($permissionsString);
} else {
$permissions = null;
}
if (is_array($permissions) && (!logged_user() instanceof User || can_manage_security(logged_user()))) {
foreach ($permissions as $perm) {
if (ProjectUser::hasAnyPermissions($perm->pr, $perm->pc)) {
if (!$personalProjectId || $personalProjectId != $perm->wsid) {
$relation = new ProjectUser();
$relation->setProjectId($perm->wsid);
$relation->setUserId($user->getId());
$relation->setCheckboxPermissions($perm->pc, $user->isGuest() ? false : true);
$relation->setRadioPermissions($perm->pr, $user->isGuest() ? false : true);
$relation->save();
}
}
}
}
// if
if ($new_project instanceof Project && logged_user() instanceof User && logged_user()->isProjectUser($new_project)) {
evt_add("workspace added", array("id" => $new_project->getId(), "name" => $new_project->getName(), "color" => $new_project->getColor()));
}
// Send notification...
try {
if (array_var($user_data, 'send_email_notification')) {
Notifier::newUserAccount($user, $password);
}
// if
} catch (Exception $e) {
}
// try
return $user;
}
示例14: copy
/**
* Copy project
*
* @param void
* @return null
*/
function copy()
{
trace(__FILE__, "copy():begin");
if (!Project::canAdd(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectToReferer(get_url('dashboard'));
}
// if
$this->setTemplate('copy_project');
$this->setLayout('administration');
$project_data = array_var($_POST, 'project');
tpl_assign('project_data', $project_data);
// Submitted...
if (is_array($project_data)) {
$source = Projects::findById($project_data['source']);
if (!$source instanceof Project) {
flash_error(lang('project dnx'));
$this->redirectTo('administration', 'projects');
}
// if
try {
$shift_dates = isset($project_data['shift_dates']) ? $project_data['shift_dates'] == 'checked' : false;
$copy_details = isset($project_data['copy_details']) ? $project_data['copy_details'] == 'checked' : false;
$copy_tasks = isset($project_data['copy_tasks']) ? $project_data['copy_tasks'] == 'checked' : false;
$copy_milestones = isset($project_data['copy_milestones']) ? $project_data['copy_milestones'] == 'checked' : false;
$copy_messages = isset($project_data['copy_messages']) ? $project_data['copy_messages'] == 'checked' : false;
$copy_links = isset($project_data['copy_links']) ? $project_data['copy_links'] == 'checked' : false;
$copy_files = isset($project_data['copy_files']) ? $project_data['copy_files'] == 'checked' : false;
$copy_users = isset($project_data['copy_users']) ? $project_data['copy_users'] == 'checked' : false;
$copy_pages = isset($project_data['copy_pages']) ? $project_data['copy_pages'] == 'checked' : false;
DB::beginWork();
$project = new Project();
$new_name = lang('projects copy new name', $source->getName());
$new_name .= date(' z H:i:s');
$project->setName($new_name);
if ($copy_details) {
$project->setDescription($source->getDescription());
$project->setPriority($source->getPriority());
$project->setShowDescriptionInOverview($source->getShowDescriptionInOverview());
}
$project->save();
$project_id = $project->getId();
$add_seconds = 0;
if (isset($project_data['add_days'])) {
$add_days = 0 + trim($project_data['add_days']);
$add_seconds = $add_days * 24 * 60 * 60;
}
$source_created_on = $source->getCreatedOn();
//var_dump($source_created_on);
$milestone_map = array(0 => 0);
// project milestones
if ($copy_milestones) {
$source_milestones = $source->getAllMilestones();
if (is_array($source_milestones)) {
foreach ($source_milestones as $source_milestone) {
$milestone = new ProjectMilestone();
//$milestone->copy($source_milestone);
$milestone->setName($source_milestone->getName());
$milestone->setDescription($source_milestone->getDescription());
if ($shift_dates) {
trace(__FILE__, "copy():shift dates");
$milestone->setDueDate(DateTimeValueLib::now());
$seconds = $source_milestone->getDueDate()->difference($source_created_on);
$milestone->getDueDate()->advance($seconds);
} else {
$milestone->setDueDate($source_milestone->getDueDate());
}
$milestone->getDueDate()->advance($add_seconds);
$milestone->setIsPrivate($source_milestone->getIsPrivate());
$milestone->setAssignedToUserId($source_milestone->getAssignedToUserId());
$milestone->setAssignedToCompanyId($source_milestone->getAssignedToCompanyId());
$milestone->setProjectId($project_id);
$milestone->save();
$milestone_map[$source_milestone->getId()] = $milestone->getId();
}
// foreach
}
// if
}
// if
// project tasks
if ($copy_tasks) {
$source_task_lists = $source->getAllTaskLists();
if (is_array($source_task_lists)) {
foreach ($source_task_lists as $source_task_list) {
$task_list = new ProjectTaskList();
//$task_list->copy($source_milestone);
$task_list->setName($source_task_list->getName());
$task_list->setPriority($source_task_list->getPriority());
$task_list->setDescription($source_task_list->getDescription());
if ($copy_milestones) {
$task_list->setMilestoneId($milestone_map[$source_task_list->getMilestoneId()]);
}
$task_list->setDueDate($source_task_list->getDueDate());
//.........这里部分代码省略.........
示例15: die
/**
* Finish the installation - create owner company and administrator
*
* @param void
* @return null
*/
function complete_installation()
{
if (Companies::getOwnerCompany() instanceof Company) {
die('Owner company already exists');
// Somebody is trying to access this method even if the user already exists
}
// if
$form_data = array_var($_POST, 'form');
tpl_assign('form_data', $form_data);
if (array_var($form_data, 'submited') == 'submited') {
try {
$admin_password = trim(array_var($form_data, 'admin_password'));
$admin_password_a = trim(array_var($form_data, 'admin_password_a'));
if (trim($admin_password) == '') {
throw new Error(lang('password value required'));
}
// if
if ($admin_password != $admin_password_a) {
throw new Error(lang('passwords dont match'));
}
// if
DB::beginWork();
Users::delete();
// clear users table
Companies::delete();
// clear companies table
// Create the administrator user
$administrator = new User();
$administrator->setId(1);
$administrator->setCompanyId(1);
$administrator->setUsername(array_var($form_data, 'admin_username'));
$administrator->setEmail(array_var($form_data, 'admin_email'));
$administrator->setPassword($admin_password);
$administrator->setCanEditCompanyData(true);
$administrator->setCanManageConfiguration(true);
$administrator->setCanManageSecurity(true);
$administrator->setCanManageWorkspaces(true);
$administrator->setCanManageContacts(true);
$administrator->setCanManageTemplates(true);
$administrator->setCanManageReports(true);
$administrator->setCanManageTime(true);
$administrator->setCanAddMailAccounts(true);
$administrator->setAutoAssign(false);
$administrator->setPersonalProjectId(1);
$administrator->setType('admin');
$administrator->save();
$group = new Group();
$group->setName('administrators');
$group->setAllPermissions(true);
$group->setId(Group::CONST_ADMIN_GROUP_ID);
$group->save();
$group_user = new GroupUser();
$group_user->setGroupId(Group::CONST_ADMIN_GROUP_ID);
$group_user->setUserId($administrator->getId());
$group_user->save();
$project = new Project();
$project->setId(1);
$project->setP1(1);
$project->setName(new_personal_project_name($administrator->getUsername()));
$project->setDescription(lang('files'));
$project->setCreatedById($administrator->getId());
$project->save();
$project_user = new ProjectUser();
$project_user->setProjectId($project->getId());
$project_user->setUserId($administrator->getId());
$project_user->setCreatedById($administrator->getId());
$project_user->setAllPermissions(true);
$project_user->save();
// Create a company
$company = new Company();
$company->setId(1);
$company->setClientOfId(0);
$company->setName(array_var($form_data, 'company_name'));
$company->setCreatedById(1);
$company->save();
DB::commit();
$this->redirectTo('access', 'login');
} catch (Exception $e) {
tpl_assign('error', $e);
DB::rollback();
}
// try
}
// if
}