当前位置: 首页>>代码示例>>PHP>>正文


PHP ProjectMilestones::copyTasks方法代码示例

本文整理汇总了PHP中ProjectMilestones::copyTasks方法的典型用法代码示例。如果您正苦于以下问题:PHP ProjectMilestones::copyTasks方法的具体用法?PHP ProjectMilestones::copyTasks怎么用?PHP ProjectMilestones::copyTasks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectMilestones的用法示例。


在下文中一共展示了ProjectMilestones::copyTasks方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addObject

 /**
  * 
  * @author Ignacio Vazquez - elpepe.uy@gmail.com
  * @param ProjectTask $object
  */
 function addObject($object)
 {
     if ($this->hasObject($object)) {
         return;
     }
     if (!$object->isTemplate() && $object->canBeTemplate()) {
         // the object isn't a template but can be, create a template copy
         $copy = $object->copy();
         $copy->setColumnValue('is_template', true);
         if ($copy instanceof ProjectTask) {
             // don't copy milestone and parent task
             $copy->setMilestoneId(0);
             $copy->setParentId(0);
         }
         $copy->save();
         //Also copy members..
         // 			$memberIds = json_decode(array_var($_POST, 'members'));
         // 			$controller  = new ObjectController() ;
         // 			$controller->add_to_members($copy, $memberIds);
         // copy subtasks
         if ($copy instanceof ProjectTask) {
             ProjectTasks::copySubTasks($object, $copy, true);
         } else {
             if ($copy instanceof ProjectMilestone) {
                 ProjectMilestones::copyTasks($object, $copy, true);
             }
         }
         // copy custom properties
         $copy->copyCustomPropertiesFrom($object);
         // copy linked objects
         $linked_objects = $object->getAllLinkedObjects();
         if (is_array($linked_objects)) {
             foreach ($linked_objects as $lo) {
                 $copy->linkObject($lo);
             }
         }
         // copy reminders
         $reminders = ObjectReminders::getByObject($object);
         foreach ($reminders as $reminder) {
             $copy_reminder = new ObjectReminder();
             $copy_reminder->setContext($reminder->getContext());
             $copy_reminder->setDate(EMPTY_DATETIME);
             $copy_reminder->setMinutesBefore($reminder->getMinutesBefore());
             $copy_reminder->setObject($copy);
             $copy_reminder->setType($reminder->getType());
             // $copy_reminder->setContactId($reminder->getContactId()); //TODO Feng 2 -  No  anda
             $copy_reminder->save();
         }
         $template = $copy;
     } else {
         // the object is already a template or can't be one, use it as it is
         $template = $object;
     }
     $to = new TemplateObject();
     $to->setObject($template);
     $to->setTemplate($this);
     $to->save();
     return $template->getObjectId();
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:64,代码来源:COTemplate.class.php

示例2: instantiate

 function instantiate()
 {
     $selected_members = array();
     $id = get_id();
     $template = COTemplates::findById($id);
     if (!$template instanceof COTemplate) {
         flash_error(lang("template dnx"));
         ajx_current("empty");
         return;
     }
     $parameters = TemplateParameters::getParametersByTemplate($id);
     $parameterValues = array_var($_POST, 'parameterValues');
     if (count($parameters) > 0 && !isset($parameterValues)) {
         ajx_current("back");
         return;
     }
     if (array_var($_POST, 'members')) {
         $selected_members = json_decode(array_var($_POST, 'members'));
     } else {
         $context = active_context();
         foreach ($context as $selection) {
             if ($selection instanceof Member) {
                 $selected_members[] = $selection->getId();
             }
         }
     }
     $objects = $template->getObjects();
     $controller = new ObjectController();
     if (count($selected_members > 0)) {
         $selected_members_instances = Members::findAll(array('conditions' => 'id IN (' . implode($selected_members) . ')'));
     } else {
         $selected_members_instances = array();
     }
     DB::beginWork();
     $active_context = active_context();
     foreach ($objects as $object) {
         if (!$object instanceof ContentDataObject) {
             continue;
         }
         // copy object
         $copy = $object->copy();
         if ($copy->columnExists('is_template')) {
             $copy->setColumnValue('is_template', false);
         }
         if ($copy instanceof ProjectTask) {
             // don't copy parent task and milestone
             $copy->setMilestoneId(0);
             $copy->setParentId(0);
         }
         $copy->save();
         /*		if (!can_write(logged_user(), $selected_members_instances, $copy->getObjectTypeId()) ) {
         				flash_error(lang('no context permissions to add', $copy instanceof ProjectTask ? lang("tasks") : ($copy instanceof ProjectMilestone ? lang('milestones') : '')));
         				DB::rollback();
         				ajx_current("empty");
         				return;
         			}*/
         // Copy members from origial object, if it doesn't have then use active context members
         /*	$template_object_members = $object->getMemberIds();
         			if (count($template_object_members) == 0) {
         				$object_member_ids = active_context_members(false);
         				if (count($object_member_ids) > 0) {
         					$template_object_members = Members::findAll(array("id" => true, "conditions" => "id IN (".implode(",", $object_member_ids).")"));
         				}
         			}*/
         /* Set instantiated object members:
          * foreach dimension:
          * 		if no member is active then the instantiated object is put in the same members as the original for current dimension
          * 		if a member is selected in current dimension then the instantiated object will be put in that member  
          */
         $template_object_members = $object->getMembers();
         $object_members = array();
         foreach ($active_context as $selection) {
             if ($selection instanceof Member) {
                 // member selected
                 $object_members[] = $selection->getId();
             } else {
                 if ($selection instanceof Dimension) {
                     // no member selected
                     foreach ($template_object_members as $tom) {
                         if ($tom->getDimensionId() == $selection->getId()) {
                             $object_members[] = $tom->getId();
                         }
                     }
                 }
             }
         }
         $controller->add_to_members($copy, $object_members);
         // copy linked objects
         $copy->copyLinkedObjectsFrom($object);
         // copy subtasks if applicable
         if ($copy instanceof ProjectTask) {
             ProjectTasks::copySubTasks($object, $copy, false);
             foreach ($copy->getOpenSubTasks(false) as $m_task) {
                 $controller->add_to_members($m_task, $object_members);
             }
             $manager = $copy->manager();
         } else {
             if ($copy instanceof ProjectMilestone) {
                 ProjectMilestones::copyTasks($object, $copy, false);
                 foreach ($copy->getTasks(false) as $m_task) {
//.........这里部分代码省略.........
开发者ID:rorteg,项目名称:fengoffice,代码行数:101,代码来源:TemplateController.class.php

示例3: add

 /**
  * Show and process add milestone form
  *
  * @access public
  * @param void
  * @return null
  */
 function add()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $this->setTemplate('add_milestone');
     if (!ProjectMilestone::canAdd(logged_user(), active_or_personal_project())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $milestone_data = array_var($_POST, 'milestone');
     $now = DateTimeValueLib::now();
     $due_date = DateTimeValueLib::make(0, 0, 0, array_var($_GET, 'due_month', $now->getMonth()), array_var($_GET, 'due_day', $now->getDay()), array_var($_GET, 'due_year', $now->getYear()));
     if (!is_array($milestone_data)) {
         $milestone_data = array('due_date' => $due_date, 'name' => array_var($_GET, 'name', ''), 'assigned_to' => array_var($_GET, 'assigned_to', '0:0'), 'is_template' => array_var($_GET, "is_template", false));
         // array
     }
     // if
     $milestone = new ProjectMilestone();
     tpl_assign('milestone_data', $milestone_data);
     tpl_assign('milestone', $milestone);
     if (is_array(array_var($_POST, 'milestone'))) {
         $milestone_data['due_date'] = getDateValue(array_var($milestone_data, 'due_date_value'), DateTimeValueLib::now()->beginningOfDay());
         $assigned_to = explode(':', array_var($milestone_data, 'assigned_to', ''));
         $milestone->setIsPrivate(false);
         //Mandatory to set
         $milestone->setFromAttributes($milestone_data);
         $urgent = array_var($milestone_data, 'is_urgent') == 'checked';
         $milestone->setIsUrgent($urgent);
         if (!logged_user()->isMemberOfOwnerCompany()) {
             $milestone->setIsPrivate(false);
         }
         $project = Projects::findById(array_var($_POST, 'ws_ids', 0));
         if (!$project instanceof Project && !ProjectMilestone::canAdd(logged_user(), $project)) {
             flash_error(lang('no access permissions'));
             ajx_current("empty");
             return;
         }
         // if
         $milestone->setAssignedToCompanyId(array_var($assigned_to, 0, 0));
         $milestone->setAssignedToUserId(array_var($assigned_to, 1, 0));
         try {
             DB::beginWork();
             $milestone->save();
             $milestone->setTagsFromCSV(array_var($milestone_data, 'tags'));
             $object_controller = new ObjectController();
             $object_controller->add_to_workspaces($milestone);
             $object_controller->link_to_new_object($milestone);
             $object_controller->add_subscribers($milestone);
             $object_controller->add_custom_properties($milestone);
             $object_controller->add_reminders($milestone);
             if (array_var($_GET, 'copyId', 0) > 0) {
                 // copy remaining stuff from the milestone with id copyId
                 $toCopy = ProjectMilestones::findById(array_var($_GET, 'copyId'));
                 if ($toCopy instanceof ProjectMilestone) {
                     ProjectMilestones::copyTasks($toCopy, $milestone, array_var($milestone_data, 'is_template', false));
                 }
             }
             ApplicationLogs::createLog($milestone, $milestone->getWorkspaces(), ApplicationLogs::ACTION_ADD);
             DB::commit();
             // Send notification
             try {
                 if (!$milestone->getIsTemplate() && array_var($milestone_data, 'send_notification') == 'checked') {
                     Notifier::milestoneAssigned($milestone);
                     // send notification
                 }
                 // if
             } catch (Exception $e) {
             }
             // try
             if ($milestone->getIsTemplate()) {
                 flash_success(lang('success add template', $milestone->getName()));
             } else {
                 flash_success(lang('success add milestone', $milestone->getName()));
             }
             ajx_current("back");
         } catch (Exception $e) {
             DB::rollback();
             flash_error($e->getMessage());
             ajx_current("empty");
         }
         // try
     }
     // if
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:96,代码来源:MilestoneController.class.php

示例4: add

	/**
	 * Show and process add milestone form
	 *
	 * @access public
	 * @param void
	 * @return null
	 */
	function add() {
		if (logged_user()->isGuest()) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		}
		$this->setTemplate('add_milestone');
		
		$notAllowedMember = '' ;
		if(!ProjectMilestone::canAdd(logged_user(), active_context(), $notAllowedMember)) {
			if (str_starts_with($notAllowedMember, '-- req dim --')) flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in)));
			else flash_error(lang('no context permissions to add',lang("milestones"),$notAllowedMember));
			ajx_current("empty");
			return;
		} 

		$milestone_data = array_var($_POST, 'milestone');
		$now = DateTimeValueLib::now();
		$due_date = DateTimeValueLib::make(0, 0, 0, array_var($_GET, 'due_month', $now->getMonth()), array_var($_GET, 'due_day', $now->getDay()), array_var($_GET, 'due_year', $now->getYear()));
		if(!is_array($milestone_data)) {
			$milestone_data = array(
				'due_date' => $due_date,
				'name' => array_var($_GET, 'name', ''),
				'assigned_to' => array_var($_GET, 'assigned_to', '0'),
				'is_template' => array_var($_GET, "is_template", false)
			); // array
		} // if
		$milestone = new ProjectMilestone();
		tpl_assign('milestone_data', $milestone_data);
		tpl_assign('milestone', $milestone);

		if (is_array(array_var($_POST, 'milestone'))) {
			$milestone_data['due_date'] = getDateValue(array_var($milestone_data, 'due_date_value'),DateTimeValueLib::now()->beginningOfDay());
			$milestone_data['object_type_id'] = $milestone->getObjectTypeId();
			
			$milestone->setFromAttributes($milestone_data);
			
			$urgent = array_var($milestone_data, 'is_urgent') == 'checked';
			$milestone->setIsUrgent($urgent);

			try {
				$member_ids = json_decode(array_var($_POST, 'members'));
				
				DB::beginWork();

				$milestone->save();
				$object_controller = new ObjectController();
			    $object_controller->add_to_members($milestone, $member_ids);
			    $object_controller->add_subscribers($milestone);
			    $object_controller->link_to_new_object($milestone);
				$object_controller->add_custom_properties($milestone);
				$object_controller->add_reminders($milestone);

				if (array_var($_GET, 'copyId', 0) > 0) {
					// copy remaining stuff from the milestone with id copyId
					$toCopy = ProjectMilestones::findById(array_var($_GET, 'copyId'));
					if ($toCopy instanceof ProjectMilestone) {
						ProjectMilestones::copyTasks($toCopy, $milestone, array_var($milestone_data, 'is_template', false));
					}
				}
				
				ApplicationLogs::createLog($milestone, ApplicationLogs::ACTION_ADD);
				
				DB::commit();

				// Send notification
				try {
					if(!$milestone->getIsTemplate() && array_var($milestone_data, 'send_notification') == 'checked') {
						Notifier::milestoneAssigned($milestone); // send notification
					} // if
				} catch(Exception $e) {

				} // try

				if ($milestone->getIsTemplate()) {
					flash_success(lang('success add template', $milestone->getObjectName()));
				} else {
					flash_success(lang('success add milestone', $milestone->getObjectName()));
				}
				ajx_current("back");

			} catch(Exception $e) {
				DB::rollback();
				flash_error($e->getMessage());
				ajx_current("empty");
			} // try
		} // if
	} // add
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:95,代码来源:MilestoneController.class.php

示例5: instantiate

 function instantiate()
 {
     $id = get_id();
     $template = COTemplates::findById($id);
     if (!$template instanceof COTemplate) {
         flash_error(lang("template dnx"));
         ajx_current("empty");
         return;
     }
     $parameters = TemplateParameters::getParametersByTemplate($id);
     $parameterValues = array_var($_POST, 'parameterValues');
     if (count($parameters) > 0 && !isset($parameterValues)) {
         ajx_current("back");
         return;
     }
     $objects = $template->getObjects();
     foreach ($objects as $object) {
         if (!$object instanceof ProjectDataObject) {
             continue;
         }
         // copy object
         $copy = $object->copy();
         if ($copy->columnExists('is_template')) {
             $copy->setColumnValue('is_template', false);
         }
         if ($copy instanceof ProjectTask) {
             // don't copy parent task and milestone
             $copy->setMilestoneId(0);
             $copy->setParentId(0);
         }
         $copy->save();
         $wsId = array_var($_POST, 'project_id', active_or_personal_project()->getId());
         // if specified, set workspace
         $workspace = Projects::findById($wsId);
         if (!$workspace instanceof Project) {
             $workspace = active_or_personal_project();
         }
         $copy->addToWorkspace($workspace);
         // add object tags and specified tags
         $tags = implode(',', $object->getTagNames());
         $copy->setTagsFromCSV($tags . "," . array_var($_POST, 'tags'));
         // copy linked objects
         $copy->copyLinkedObjectsFrom($object);
         // copy subtasks if applicable
         if ($copy instanceof ProjectTask) {
             ProjectTasks::copySubTasks($object, $copy, false);
             $manager = new ProjectTask();
         } else {
             if ($copy instanceof ProjectMilestone) {
                 ProjectMilestones::copyTasks($object, $copy, false);
                 $manager = new ProjectMilestone();
             }
         }
         // copy custom properties
         $copy->copyCustomPropertiesFrom($object);
         // set property values as defined in template
         $objProp = TemplateObjectProperties::getPropertiesByTemplateObject($id, $object->getId());
         foreach ($objProp as $property) {
             $propName = $property->getProperty();
             $value = $property->getValue();
             if ($manager->getColumnType($propName) == DATA_TYPE_STRING) {
                 if (is_array($parameterValues)) {
                     foreach ($parameterValues as $param => $val) {
                         $value = str_replace('{' . $param . '}', $val, $value);
                     }
                 }
             } else {
                 if ($manager->getColumnType($propName) == DATA_TYPE_DATE || $manager->getColumnType($propName) == DATA_TYPE_DATETIME) {
                     $operator = '+';
                     if (strpos($value, '+') === false) {
                         $operator = '-';
                     }
                     $opPos = strpos($value, $operator);
                     if ($opPos !== false) {
                         $dateParam = substr($value, 1, strpos($value, '}') - 1);
                         $dateUnit = substr($value, strlen($value) - 1);
                         // d, w or m (for days, weeks or months)
                         if ($dateUnit == 'm') {
                             $dateUnit = 'M';
                             // make month unit uppercase to call DateTimeValue::add with correct parameter
                         }
                         $dateNum = (int) substr($value, strpos($value, $operator), strlen($value) - 2);
                         $date = $parameterValues[$dateParam];
                         $date = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $date);
                         $value = $date->add($dateUnit, $dateNum);
                     }
                 } else {
                     if ($manager->getColumnType($propName) == DATA_TYPE_INTEGER) {
                         if (is_array($parameterValues)) {
                             foreach ($parameterValues as $param => $val) {
                                 $value = str_replace('{' . $param . '}', $val, $value);
                             }
                         }
                     }
                 }
             }
             if ($value != '') {
                 $copy->setColumnValue($propName, $value);
                 $copy->save();
             }
//.........这里部分代码省略.........
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:TemplateController.class.php

示例6: add

 /**
  * Show and process add milestone form
  *
  * @access public
  * @param void
  * @return null
  */
 function add()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $this->setTemplate('add_milestone');
     $notAllowedMember = '';
     if (!ProjectMilestone::canAdd(logged_user(), active_context(), $notAllowedMember)) {
         if (str_starts_with($notAllowedMember, '-- req dim --')) {
             flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in)));
         } else {
             trim($notAllowedMember) == "" ? flash_error(lang('you must select where to keep', lang('the milestone'))) : flash_error(lang('no context permissions to add', lang("milestones"), $notAllowedMember));
         }
         ajx_current("empty");
         return;
     }
     $milestone_data = array_var($_POST, 'milestone');
     if (!is_array($milestone_data)) {
         // set layout for modal form
         if (array_var($_REQUEST, 'modal')) {
             $this->setLayout("json");
             tpl_assign('modal', true);
         }
         $milestone_data = array('due_date' => '', 'name' => array_var($_GET, 'name', ''), 'assigned_to' => array_var($_GET, 'assigned_to', '0'), 'is_template' => array_var($_GET, "is_template", false));
         // array
     }
     // if
     //is template milestone?
     if (array_var($_REQUEST, 'template_milestone') == true) {
         $milestone = new TemplateMilestone();
         $this->setTemplate(get_template_path('add_template_milestone', 'template_milestone'));
     } else {
         $milestone = new ProjectMilestone();
     }
     tpl_assign('milestone_data', $milestone_data);
     tpl_assign('milestone', $milestone);
     if (is_array(array_var($_POST, 'milestone'))) {
         $milestone_data['due_date'] = getDateValue(array_var($milestone_data, 'due_date_value'), DateTimeValueLib::now()->beginningOfDay());
         $milestone_data['object_type_id'] = $milestone->getObjectTypeId();
         $milestone->setFromAttributes($milestone_data);
         $urgent = array_var($milestone_data, 'is_urgent');
         $milestone->setIsUrgent($urgent);
         try {
             $member_ids = json_decode(array_var($_POST, 'members'));
             if ($milestone instanceof TemplateMilestone) {
                 $milestone->setSessionId(logged_user()->getId());
             }
             DB::beginWork();
             $milestone->save();
             $object_controller = new ObjectController();
             $object_controller->add_to_members($milestone, $member_ids);
             $object_controller->add_subscribers($milestone);
             $object_controller->link_to_new_object($milestone);
             $object_controller->add_custom_properties($milestone);
             $object_controller->add_reminders($milestone);
             if (array_var($_GET, 'copyId', 0) > 0) {
                 // copy remaining stuff from the milestone with id copyId
                 $toCopy = ProjectMilestones::findById(array_var($_GET, 'copyId'));
                 if ($toCopy instanceof ProjectMilestone) {
                     ProjectMilestones::copyTasks($toCopy, $milestone, array_var($milestone_data, 'is_template', false));
                 }
             }
             DB::commit();
             ApplicationLogs::createLog($milestone, ApplicationLogs::ACTION_ADD);
             //Send Template milestone to view
             if ($milestone instanceof TemplateMilestone) {
                 $object = array("action" => "add", "object_id" => $milestone->getObjectId(), "type" => $milestone->getObjectTypeName(), "id" => $milestone->getId(), "name" => $milestone->getObjectName(), "ico" => "ico-milestone", "manager" => get_class($milestone->manager()));
                 evt_add("template object added", array('object' => $object));
             }
             // Send notification
             try {
                 if (!$milestone instanceof TemplateMilestone && array_var($milestone_data, 'send_notification')) {
                     Notifier::milestoneAssigned($milestone);
                     // send notification
                 }
                 // if
             } catch (Exception $e) {
             }
             // try
             $is_template = $milestone instanceof TemplateMilestone;
             if (array_var($_REQUEST, 'modal')) {
                 ajx_current("empty");
                 $this->setLayout("json");
                 $this->setTemplate(get_template_path("empty"));
                 // reload milestone info because plugins may have updated some task info (for example: name prefix)
                 if ($is_template) {
                     $milestone = TemplateMilestones::findById($milestone->getId());
                     $params = array('msg' => lang('success add milestone', $milestone->getObjectName()), 'milestone' => $milestone->getArrayInfo(), 'reload' => array_var($_REQUEST, 'reload'));
                     if ($milestone instanceof TemplateMilestone) {
                         $params = $object;
                     }
//.........这里部分代码省略.........
开发者ID:abhinay100,项目名称:feng_app,代码行数:101,代码来源:MilestoneController.class.php


注:本文中的ProjectMilestones::copyTasks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。