本文整理汇总了PHP中ProjectTasks类的典型用法代码示例。如果您正苦于以下问题:PHP ProjectTasks类的具体用法?PHP ProjectTasks怎么用?PHP ProjectTasks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProjectTasks类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ExecuteQuery
function ExecuteQuery()
{
$this->data = array();
$date = new DateTimeValue(Time());
$notYet = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND ( due_date = \'0000-00-00 00:00:00\' OR due_date > \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "')"));
$today = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND due_date = \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "'"));
$past = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND due_date > \'1900-01-01 00:00:00\' AND due_date < \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "'"));
$value = 0;
if (isset($past)) {
$value = count($past);
}
$this->data['values'][0]['labels'][] = 'Overdue';
$this->data['values'][0]['values'][] = $value;
$value = 0;
if (isset($notYet)) {
$value = count($notYet);
}
$this->data['values'][0]['labels'][] = 'Not yet due';
$this->data['values'][0]['values'][] = $value;
$value = 0;
if (isset($today)) {
$value = count($today);
}
$this->data['values'][0]['labels'][] = 'Due today';
$this->data['values'][0]['values'][] = $value;
}
示例2: 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();
}
示例3: getPreviousTasks
static function getPreviousTasks($task_id)
{
$previous_tasks = array();
$deps = self::getDependenciesForTask($task_id);
foreach ($deps as $dep) {
/* @var $dep ProjectTaskDependency */
$task = ProjectTasks::findById($dep->getPreviousTaskId());
if ($task instanceof ProjectTask) {
$previous_tasks[] = $task;
}
}
return $previous_tasks;
}
示例4: findByTaskAndRelated
function findByTaskAndRelated($task_id,$original_task_id) {
return ProjectTasks::findAll(array('conditions' => array('(`original_task_id` = ? OR `object_id` = ?) AND `object_id` <> ?', $original_task_id,$original_task_id,$task_id)));
}
示例5: paginate
/**
* This function will return paginated result. Result is an array where first element is
* array of returned object and second populated pagination object that can be used for
* obtaining and rendering pagination data using various helpers.
*
* Items and pagination array vars are indexed with 0 for items and 1 for pagination
* because you can't use associative indexing with list() construct
*
* @access public
* @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
* @param integer $items_per_page Number of items per page
* @param integer $current_page Current page number
* @return array
*/
function paginate($arguments = null, $items_per_page = 10, $current_page = 1)
{
if (isset($this) && instance_of($this, 'ProjectTasks')) {
return parent::paginate($arguments, $items_per_page, $current_page);
} else {
return ProjectTasks::instance()->paginate($arguments, $items_per_page, $current_page);
//$instance =& ProjectTasks::instance();
//return $instance->paginate($arguments, $items_per_page, $current_page);
}
// if
}
示例6: change_start_due_date
function change_start_due_date()
{
$task = ProjectTasks::findById(get_id());
if (!$task->canEdit(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$tochange = array_var($_GET, 'tochange', '');
if (($tochange == 'both' || $tochange == 'due') && $task->getDueDate() instanceof DateTimeValue) {
$year = array_var($_GET, 'year', $task->getDueDate()->getYear());
$month = array_var($_GET, 'month', $task->getDueDate()->getMonth());
$day = array_var($_GET, 'day', $task->getDueDate()->getDay());
$new_date = new DateTimeValue(mktime(0, 0, 0, $month, $day, $year));
$task->setDueDate($new_date);
}
if (($tochange == 'both' || $tochange == 'start') && $task->getStartDate() instanceof DateTimeValue) {
$year = array_var($_GET, 'year', $task->getStartDate()->getYear());
$month = array_var($_GET, 'month', $task->getStartDate()->getMonth());
$day = array_var($_GET, 'day', $task->getStartDate()->getDay());
$new_date = new DateTimeValue(mktime(0, 0, 0, $month, $day, $year));
$task->setStartDate($new_date);
}
try {
DB::beginWork();
$task->save();
DB::commit();
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error change date'));
}
// try
ajx_current("empty");
}
示例7: total_task_times_by_task_print
function total_task_times_by_task_print()
{
$this->setLayout("html");
$task = ProjectTasks::findById(get_id());
$st = DateTimeValueLib::make(0, 0, 0, 1, 1, 1900);
$et = DateTimeValueLib::make(23, 59, 59, 12, 31, 2036);
$timeslotsArray = Timeslots::getTaskTimeslots(active_context(), null, null, $st, $et, get_id());
tpl_assign('columns', array());
tpl_assign('user', array());
tpl_assign('group_by', array());
tpl_assign('grouped_timeslots', array());
tpl_assign('template_name', 'total_task_times');
tpl_assign('estimate', $task->getTimeEstimate());
tpl_assign('timeslotsArray', $timeslotsArray);
tpl_assign('title', lang('task time report'));
tpl_assign('task_title', $task->getTitle());
tpl_assign('start_time', $st);
tpl_assign('end_time', $et);
$this->setTemplate('report_printer');
}
示例8: stylesheet_tag
}
echo stylesheet_tag('event/day.css');
$today = DateTimeValueLib::now();
$today->add('h', logged_user()->getTimezone());
$currentday = $today->format("j");
$currentmonth = $today->format("n");
$currentyear = $today->format("Y");
$drawHourLine = $day == $currentday && $month == $currentmonth && $year == $currentyear;
$dtv = DateTimeValueLib::make(0, 0, 0, $month, $day, $year);
$result = ProjectEvents::getDayProjectEvents($dtv, $tags, active_project(), $user_filter, $status_filter);
if (!$result) {
$result = array();
}
$alldayevents = array();
$milestones = ProjectMilestones::getRangeMilestonesByUser($dtv, $dtv, $user_filter != -1 ? $user : null, $tags, active_project());
$tasks = ProjectTasks::getRangeTasksByUser($dtv, $dtv, $user_filter != -1 ? $user : null, $tags, active_project());
$birthdays = Contacts::instance()->getRangeContactsByBirthday($dtv, $dtv);
foreach ($result as $key => $event) {
if ($event->getTypeId() > 1) {
$alldayevents[] = $event;
unset($result[$key]);
}
}
if ($milestones) {
$alldayevents = array_merge($alldayevents, $milestones);
}
if ($tasks) {
$tmp_tasks = array();
$dtv_end = new DateTimeValue($dtv->getTimestamp() + 60 * 60 * 24);
foreach ($tasks as $task) {
$tmp_tasks = array_merge($tmp_tasks, replicateRepetitiveTaskForCalendar($task, $dtv, $dtv_end));
示例9: copyTasks
/**
* Copies tasks from milestoneFrom to milestoneTo.
*
* @param ProjectMilestone $milestoneFrom
* @param ProjectMilestone $milestoneTo
*/
function copyTasks(ProjectMilestone $milestoneFrom, ProjectMilestone $milestoneTo, $as_template = false)
{
//FIXME
foreach ($milestoneFrom->getTasks($as_template) as $sub) {
if ($sub->getParentId() != 0) {
continue;
}
$new = ProjectTasks::createTaskCopy($sub);
$new->setMilestoneId($milestoneTo->getId());
$new->save();
$object_controller = new ObjectController();
$members = $milestoneFrom->getMemberIds();
if (count($members)) {
$object_controller->add_to_members($new, $members);
}
/*
foreach ($sub->getWorkspaces() as $workspace) {
if (ProjectTask::canAdd(logged_user(), $workspace)) {
$new->addToWorkspace($workspace);
}
}
if (!$as_template && active_project() instanceof Project && ProjectTask::canAdd(logged_user(), active_project())) {
$new->removeFromAllWorkspaces();
$new->addToWorkspace(active_project());
}
*/
$new->copyCustomPropertiesFrom($sub);
$new->copyLinkedObjectsFrom($sub);
ProjectTasks::copySubTasks($sub, $new, $as_template);
}
}
示例10: DateTimeValue
<th width="14%"></th>
<th width="15%"></th>
<?php
if (user_config_option("start_monday")) {
?>
<th width='15%'></th>
<?php
}
?>
<th id="ie_scrollbar_adjust" style="display:none;width:15px;padding:0px;margin:0px;"></th>
</tr>
<?php
$date_start = new DateTimeValue(mktime(0, 0, 0, $month - 1, $firstday, $year));
$date_end = new DateTimeValue(mktime(0, 0, 0, $month + 1, $lastday, $year));
$milestones = ProjectMilestones::getRangeMilestonesByUser($date_start, $date_end, $user_filter != -1 ? $user : null, $tags, active_project());
$tasks = ProjectTasks::getRangeTasksByUser($date_start, $date_end, $user_filter != -1 ? $user : null, $tags, active_project());
$birthdays = Contacts::instance()->getRangeContactsByBirthday($date_start, $date_end);
$result = array();
if ($milestones) {
$result = array_merge($result, $milestones);
}
if ($tasks) {
foreach ($tasks as $task) {
$result = array_merge($result, replicateRepetitiveTaskForCalendar($task, $date_start, $date_end));
}
}
if ($birthdays) {
$result = array_merge($result, $birthdays);
}
// Loop to render the calendar
for ($week_index = 0;; $week_index++) {
示例11: check_related_task
function check_related_task()
{
ajx_current("empty");
//I find all those related to the task to find out if the original
$task_related = ProjectTasks::findByRelated(array_var($_REQUEST, 'related_id'));
if (!$task_related) {
$task_related = ProjectTasks::findById(array_var($_REQUEST, 'related_id'));
//is not the original as the original look plus other related
if ($task_related->getOriginalTaskId() != "0") {
ajx_extra_data(array("status" => true));
} else {
ajx_extra_data(array("status" => false));
}
} else {
ajx_extra_data(array("status" => true));
}
}
示例12: _findAllowed
/**
* @deprecated
* @author Ignacio Vazquez - elpepe.uy@gmail.com
*/
static function _findAllowed()
{
//1. Find members where user can add tasks
//$sqlMembers = "
$sql = "\n\t\t\tSELECT distinct(id) AS id\n\t\t\tFROM " . TABLE_PREFIX . "object_members om\n\t\t\tINNER JOIN " . TABLE_PREFIX . "templates t ON t.object_id = om.object_id\n\t\t\tINNER JOIN " . TABLE_PREFIX . "objects o ON om.object_id = o.id\n\t\t\tWHERE\n\t\t\t member_id IN ( \n\t\t\t \tSELECT distinct(member_id) \n\t\t\t\t\tFROM " . TABLE_PREFIX . "contact_member_permissions o \n\t\t\t\t\tWHERE object_type_id = " . ProjectTasks::instance()->getObjectTypeId() . " \n\t\t\t\t\tAND permission_group_id IN ( " . ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId()) . " ) AND can_write= 1 \n\t\t\t\t)\n\t\t\t\tAND is_optimization = 0\n\t\t\tGROUP BY om.object_id\t\t\n\t\t";
$res = DB::execute($sql);
$tpls = array();
// Iterate on the results and make som filtering
while ($row = $res->fetchRow()) {
$tpl = COTemplates::instance()->findById($row['id']);
$tpls[] = $tpl;
}
return $tpls;
}
示例13: 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) {
//.........这里部分代码省略.........
示例14: edit_score
/**
* Reopen completed project task
*
* @access public
* @param void
* @return null
*/
function edit_score()
{
$task = ProjectTasks::findById(get_id());
if (!$task instanceof ProjectTask) {
flash_error(lang('task dnx'));
//$this->redirectTo('task');
}
// if
include '../views/editscore.html';
}
示例15: allowed_users_to_assign_all_mobile
function allowed_users_to_assign_all_mobile($member_id = null) {
if ($member_id == null) {
$context = active_context();
}else{
$member = Members::findById($member_id);
if ($member instanceof Member){
$context[] = $member;
}
}
// only companies with users
$companies = Contacts::findAll(array("conditions" => "is_company = 1 AND object_id IN (SELECT company_id FROM ".TABLE_PREFIX."contacts WHERE user_type>0 AND disabled=0)", "order" => "first_name ASC"));
$comp_ids = array("0");
$comp_array = array("0" => array('id' => "0", 'name' => lang('without company'), 'users' => array() ));
foreach ($companies as $company) {
$comp_ids[] = $company->getId();
$comp_array[$company->getId()] = array('id' => $company->getId(), 'name' => $company->getObjectName(), 'users' => array() );
}
if(!can_manage_tasks(logged_user()) && can_task_assignee(logged_user())) {
$contacts = array(logged_user());
} else if (can_manage_tasks(logged_user())) {
$contacts = allowed_users_in_context(ProjectTasks::instance()->getObjectTypeId(), $context, ACCESS_LEVEL_READ, "AND `is_company`=0 AND `company_id` IN (".implode(",", $comp_ids).")");
} else {
$contacts = array();
}
foreach ($contacts as $contact) { /* @var $contact Contact */
if ( TabPanelPermissions::instance()->count( array( "conditions" => "permission_group_id = ".$contact->getPermissionGroupId(). " AND tab_panel_id = 'tasks-panel' " ))){
$comp_array[$contact->getCompanyId()]['users'][] = array('id' => $contact->getId(), 'name' => $contact->getObjectName(), 'isCurrent' => $contact->getId() == logged_user()->getId());
}
}
foreach ($comp_array as $company_id => &$comp_data) {
if (count($comp_data['users']) == 0) {
unset($comp_array[$company_id]);
}
}
return array_values($comp_array);
}