mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
Implement pe_status, set_status() and delete()
This commit is contained in:
parent
f8be81e17f
commit
e5b93acc4f
@ -10,7 +10,8 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Link;
|
||||
use EGroupware\Api\Acl;
|
||||
|
||||
include_once(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.datasource.inc.php');
|
||||
|
||||
@ -107,6 +108,10 @@ class calendar_datasource extends datasource
|
||||
// if we have multiple participants we have to multiply the time by the number of participants to get the total time
|
||||
$ds['pe_planned_time'] *= count($ds['pe_resources']);
|
||||
|
||||
if($data['deleted'])
|
||||
{
|
||||
$ds['pe_status'] = 'deleted';
|
||||
}
|
||||
/*
|
||||
// ToDO: this does not change automatically after the event is over,
|
||||
// maybe we need a flag for that in egw_pm_elements
|
||||
@ -122,4 +127,45 @@ class calendar_datasource extends datasource
|
||||
}
|
||||
return $ds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the datasource of a project element
|
||||
*
|
||||
* @param int $id
|
||||
* @return boolean true on success, false on error
|
||||
*/
|
||||
function delete($id)
|
||||
{
|
||||
// dont delete entries which are linked to elements other than their project
|
||||
if (count(Link::get_links('calendar',$id)) > 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$bo = new calendar_boupdate();
|
||||
return $bo->delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the status of an entry according to the project status
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $status
|
||||
* @return boolean true if status changed, false otherwise
|
||||
*/
|
||||
function change_status($id,$status)
|
||||
{
|
||||
$bo = new calendar_boupdate();
|
||||
if (($entry = $bo->read($id)) && (
|
||||
$bo->check_perms(Acl::EDIT,$entry)
|
||||
))
|
||||
{
|
||||
// Restore from deleted
|
||||
if ($status == 'active' && $entry['deleted'])
|
||||
{
|
||||
$entry['deleted'] = null;
|
||||
return (boolean)$bo->update($entry, true);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -71,8 +71,11 @@ class infolog_datasource extends datasource
|
||||
{
|
||||
$data =& $data_id;
|
||||
}
|
||||
$status = null;
|
||||
|
||||
return array(
|
||||
'pe_title' => $this->infolog_bo->link_title($data),
|
||||
'pe_status' => $data['info_status'],
|
||||
'pe_completion' => $data['info_percent'],
|
||||
'pe_planned_start'=> $data['info_startdate'] ? $data['info_startdate'] : null,
|
||||
'pe_planned_end' => $data['info_enddate'] ? $data['info_enddate'] : null,
|
||||
|
@ -9,6 +9,8 @@
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
use EGroupware\Api\Link;
|
||||
use EGroupware\Api\Acl;
|
||||
|
||||
include_once(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.datasource.inc.php');
|
||||
|
||||
@ -52,8 +54,20 @@ class timesheet_datasource extends datasource
|
||||
{
|
||||
$data =& $data_id;
|
||||
}
|
||||
$status = null;
|
||||
switch($data['ts_status'])
|
||||
{
|
||||
case timesheet_bo::DELETED_STATUS:
|
||||
$status = 'deleted';
|
||||
break;
|
||||
case '':
|
||||
default:
|
||||
$status = 'ignore';
|
||||
break;
|
||||
}
|
||||
$ds = array(
|
||||
'pe_title' => $GLOBALS['timesheet_bo']->link_title($data),
|
||||
'pe_status' => $status,
|
||||
'pe_real_start' => $data['ts_start'],
|
||||
'pe_resources' => array($data['ts_owner']),
|
||||
'pe_details' => $data['ts_description'] ? nl2br($data['ts_description']) : '',
|
||||
@ -98,14 +112,49 @@ class timesheet_datasource extends datasource
|
||||
* @param int $id
|
||||
* @return boolean true on success, false on error
|
||||
*/
|
||||
/* removed deleting, as it might not be always wanted, maybe we make it configurable later on
|
||||
function delete($id)
|
||||
{
|
||||
if (!is_object($GLOBALS['timesheet_bo']))
|
||||
{
|
||||
$GLOBALS['timesheet_bo'] = new timesheet_boo();
|
||||
$GLOBALS['timesheet_bo'] = new timesheet_bo();
|
||||
}
|
||||
// dont delete entries which are linked to elements other than their project
|
||||
if (count(Link::get_links('timesheet',$id)) > 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return $GLOBALS['timesheet_bo']->delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the status of an entry according to the project status
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $status
|
||||
* @return boolean true if status changed, false otherwise
|
||||
*/
|
||||
function change_status($id,$status)
|
||||
{
|
||||
if (!is_object($GLOBALS['timesheet_bo']))
|
||||
{
|
||||
$GLOBALS['timesheet_bo'] = new timesheet_bo();
|
||||
}
|
||||
if (($entry = $GLOBALS['timesheet_bo']->read($id)) && (
|
||||
$GLOBALS['timesheet_bo']->check_acl(Acl::EDIT,$entry)
|
||||
))
|
||||
{
|
||||
if (in_array($status, $GLOBALS['timesheet_bo']->status_labels))
|
||||
{
|
||||
$GLOBALS['timesheet_bo']->set_status($id, $status);
|
||||
return true;
|
||||
}
|
||||
// Restore from deleted
|
||||
else if ($status == 'active' && $entry['ts_status'] == timesheet_bo::DELETED_STATUS)
|
||||
{
|
||||
$GLOBALS['timesheet_bo']->set_status($id, '');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user