本文整理汇总了PHP中Task::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::getById方法的具体用法?PHP Task::getById怎么用?PHP Task::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task::getById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addJob
public function addJob(JobInterface $job, $routingKey = self::DEFAULT_ROUTING_KEY)
{
$model = \Task::getById($job->getId());
$model->broker_name = $this->name;
$model->routing_key = $routingKey;
return $model->save();
}
示例2: testProperlyDeletingActivityItems
public function testProperlyDeletingActivityItems()
{
Yii::app()->user->userModel = User::getByUsername('super');
$count = ZurmoRedBean::getRow('select count(*) count from activity_item');
$this->assertEquals(0, $count['count']);
$account = AccountTestHelper::createAccountByNameForOwner('anAccount', Yii::app()->user->userModel);
$deleted = $account->delete();
$this->assertTrue($deleted);
$count = ZurmoRedBean::getRow('select count(*) count from activity_item');
$this->assertEquals(0, $count['count']);
$account2 = AccountTestHelper::createAccountByNameForOwner('anAccount2', Yii::app()->user->userModel);
$opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('anOpp', Yii::app()->user->userModel);
$task = TaskTestHelper::createTaskWithOwnerAndRelatedAccount('aTask', Yii::app()->user->userModel, $account2);
$task->activityItems->add($opportunity);
$this->assertTrue($task->save());
$taskId = $task->id;
$task->forget();
RedBeansCache::forgetAll();
$count = ZurmoRedBean::getRow('select count(*) count from activity_item');
$this->assertEquals(2, $count['count']);
$deleted = $account2->delete();
$this->assertTrue($deleted);
$account2->forget();
$count = ZurmoRedBean::getRow('select count(*) count from activity_item');
$this->assertEquals(1, $count['count']);
RedBeansCache::forgetAll();
//Make sure things render ok even with the account deleted.
$content = ActivitiesUtil::renderSummaryContent(Task::getById($taskId), 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_ALL, 'HomeModule');
}
示例3: renderPreviewList
function renderPreviewList()
{
$options = array('date_min' => getDateTimeFieldValue('time_start'), 'date_max' => getDateTimeFieldValue('time_end'));
### author
if (intval(get('person'))) {
$options['modified_by'] = get('person');
}
### Object types
$types = array();
if (get('type_task') || get('type_topic')) {
$types[] = ITEM_TASK;
}
if (get('type_comment')) {
$types[] = ITEM_COMMENT;
}
$options['type'] = $types;
$items = DbProjectItem::getAll($options);
echo "<ol>";
foreach ($items as $item) {
if ($item->type == ITEM_COMMENT) {
$comment = Comment::getById($item->id);
if (get('only_spam_comments') && !isSpam($comment->name . " " . $comment->description)) {
continue;
}
renderRemovalPreviewComment($comment);
}
if ($item->type == ITEM_TASK) {
$task = Task::getById($item->id);
renderRemovalPreviewTask($task);
}
}
echo "</ol>";
}
示例4: testKanbanItemSave
public function testKanbanItemSave()
{
$accounts = Account::getByName('anAccount');
$user = UserTestHelper::createBasicUser('Billy');
$task = new Task();
$task->name = 'MyTask';
$task->owner = $user;
$task->requestedByUser = $user;
$task->description = 'my test description';
$taskCheckListItem = new TaskCheckListItem();
$taskCheckListItem->name = 'Test Check List Item';
$task->checkListItems->add($taskCheckListItem);
$task->activityItems->add($accounts[0]);
$task->status = Task::STATUS_IN_PROGRESS;
$this->assertTrue($task->save());
$this->assertEquals(1, KanbanItem::getCount());
$id = $task->id;
unset($task);
$task = Task::getById($id);
//KanbanItem is created after saving Task
$kanbanItems = KanbanItem::getAll();
$this->assertCount(1, $kanbanItems);
$kanbanItem = $kanbanItems[0];
$this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem->type);
}
示例5: actionCloseTask
public function actionCloseTask($id)
{
$task = Task::getById(intval($id));
ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($task);
$task->completedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
$task->completed = true;
$saved = $task->save();
if (!$saved) {
throw new NotSupportedException();
}
}
示例6: __construct
/**
* constructor
*/
public function __construct(Project $project)
{
parent::__construct();
$this->title = __('Folders');
if (!$project) {
trigger_error("ListBlock_taskfolders() needs project-object as argument", E_USER_WARNING);
}
$this->task_folders = $project->getFolders();
#--- render nothing if no folders ---
if (!count($this->task_folders)) {
$this->hidden = true;
}
#--- in taskView highlight current task ---
global $PH;
if ($PH->cur_page_id == 'taskView') {
$task_id = get('tsk');
$cur_task = Task::getById($task_id);
if (!$cur_task) {
$PH->abortWarning("invalid task-id");
#@@@ not good inside lists / render Exception might be more appropriate
return;
}
#--- use parent, if not a folder for itself ------
if (!$cur_task->category == TCATEGORY_FOLDER) {
$cur_task = Task::getById($cur_task->parent_task);
}
if ($cur_task && is_object($cur_task)) {
$this->cur_task_id = $cur_task->id;
}
}
#--- create task for project-root---
$task_none = new Task(array('name' => "..none::"));
$task_none->id = 0;
$task_none->project = $project->id;
array_unshift($this->task_folders, $task_none);
#--- add columns --------------------------------------------------------
$this->add_col(new ListBlockColSelect());
$this->add_col(new ListBlockCol_TaskName(array('use_short_names' => true, 'indention' => true, 'use_collapsed' => true, 'show_toggles' => false)));
$this->add_col(new ListBlockColMethod(array('name' => __("Tasks"), 'tooltip' => __("Number of subtasks"), 'sort' => 0, 'func' => 'getNumSubtasks', 'style' => 'right')));
#$this->add_col( new ListBlockCol_TaskSumEfforts());
#--- functions ----------------------------------------
### functions ###
$this->add_function(new ListFunction(array('target' => $PH->getPage('taskEdit')->id, 'name' => __('Edit'), 'id' => 'taskEdit', 'icon' => 'edit', 'context_menu' => 'submit')));
$this->add_function(new ListFunction(array('target' => $PH->getPage('taskNewFolder')->id, 'name' => __('New'), 'id' => 'taskNewFolder', 'icon' => 'new', 'tooltip' => __('Create new folder under selected task'))));
$this->add_function(new ListFunction(array('target' => $PH->getPage('tasksMoveToFolder')->id, 'name' => __('Move selected to folder'), 'id' => 'tasksMoveToFolder', 'context_menu' => 'submit', 'dropdown_menu' => 0)));
$this->add_function(new ListFunction(array('target' => $PH->getPage('effortNew')->id, 'name' => __('Log hours for select tasks'), 'id' => 'effortNew', 'icon' => 'loghours', 'context_menu' => 'submit')));
}
示例7: testUpdateLatestActivityDateTimeWhenATaskIsCompleted
public function testUpdateLatestActivityDateTimeWhenATaskIsCompleted()
{
$taskIdAndAccountId = $this->createTaskWithRelatedAccount('account1', 'task1');
$task = Task::getById($taskIdAndAccountId[0]);
//update task status to STATUS_AWAITING_ACCEPTANCE, it should not update related account
$task->status = Task::STATUS_AWAITING_ACCEPTANCE;
$this->assertTrue($task->save());
$account = Account::getById($taskIdAndAccountId[0]);
$this->assertNull($account->latestActivityDateTime);
//update task status to STATUS_COMPLETED, now it should update the related account
$task->status = Task::STATUS_COMPLETED;
$this->assertTrue($task->save());
$account = Account::getById($taskIdAndAccountId[0]);
$this->assertNotNull($account->latestActivityDateTime);
$dateTimeAMinuteAgo = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60);
$dateTimeAMinuteFromNow = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 60);
$this->assertTrue($account->latestActivityDateTime > $dateTimeAMinuteAgo);
$this->assertTrue($account->latestActivityDateTime < $dateTimeAMinuteFromNow);
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:19,代码来源:AccountLatestActivityDateTimeDocumentationTest.php
示例8: testCopy
public function testCopy()
{
Yii::app()->user->userModel = User::getByUsername('super');
$accounts = Account::getByName('anAccount');
$task = new Task();
$task->name = 'My Task';
$task->owner = Yii::app()->user->userModel;
$task->completedDateTime = '0000-00-00 00:00:00';
$task->activityItems->add($accounts[0]);
$saved = $task->save();
$this->assertTrue($saved);
$taskId = $task->id;
$task->forget();
unset($task);
$task = Task::getById($taskId);
$copyToTask = new Task();
ActivityCopyModelUtil::copy($task, $copyToTask);
$this->assertEquals('My Task', $copyToTask->name);
$this->assertEquals(1, $copyToTask->activityItems->count());
}
示例9: getEditableById
/**
* query if editable for current user
*/
static function getEditableById($id)
{
if ($t = Task::getById($id)) {
if ($p = Project::getById($t->project)) {
if ($p->validateEditItem($t, false)) {
return $t;
}
}
}
return NULL;
}
示例10: processTaskCopy
/**
* Process task copy
* @param string $id
* @return Task
*/
private function processTaskCopy($id)
{
$copyToTask = new Task();
$task = Task::getById(intval($id));
ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($task);
TaskActivityCopyModelUtil::copy($task, $copyToTask);
$copyToTask = $this->attemptToSaveModelFromPost($copyToTask, null, false);
return $copyToTask;
}
示例11: testAddCommentsToTask
public function testAddCommentsToTask()
{
Yii::app()->user->userModel = User::getByUsername('super');
$task = new Task();
$task->name = 'MyTest2';
$nowStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
$this->assertTrue($task->save());
$comment = new Comment();
$comment->description = 'My Description';
$task->comments->add($comment);
$this->assertTrue($task->save());
$task = Task::getById($task->id);
$this->assertEquals(1, $task->comments->count());
$fetchedComment = $task->comments[0];
$this->assertEquals('My Description', $fetchedComment->description);
}
示例12: itemSaveField
/**
* save field value of an item which has been edited inplace
* and return formatted html code.
*
* If only a chapter has been edited, number defined in "chapter"
*/
function itemSaveField()
{
header("Content-type: text/html; charset=utf-8");
### disable page caching ###
header("Expires: -1");
header("Cache-Control: post-check=0, pre-check=0");
header("Pragma: no-cache");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
$value = get('value');
if (is_null($value)) {
return;
}
if (!($item_id = get('item'))) {
print "Failure";
return;
}
global $g_wiki_project;
if (!($item = DbProjectItem::getEditableById($item_id))) {
print "Failure";
return;
}
if (!($object = DbProjectItem::getObjectById($item_id))) {
print "Failure";
return;
}
if ($item->type == ITEM_PROJECT) {
if (!($project = Project::getVisibleById($item->id))) {
print "Failure getting project";
return;
}
} else {
if (!($project = Project::getVisibleById($item->project))) {
print "Failure getting project";
return;
}
}
$g_wiki_project = $project;
$field_name = 'description';
if (get('field')) {
$field_name = asCleanString(get('field'));
}
if (!isset($object->fields[$field_name])) {
return NULL;
}
require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php';
$chapter = intVal(get('chapter'));
### replace complete field ###
if (is_null($chapter)) {
$object->{$field_name} = $value;
} else {
require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php';
/**
* split originial wiki block into chapters
* start with headline and belonging text
*/
$org = $object->{$field_name};
if ($object->type == ITEM_TASK) {
global $g_wiki_task;
$g_wiki_task = $object;
}
$parts = getWikiChapters($org);
### replace last line return (added by textarea) ###
if (!preg_match("/\n\$/", $value)) {
$value .= "\n";
}
#$value= str_replace("\\'", "'", $value);
#$value= str_replace('\\"', "\"", $value);
$parts[$chapter] = $value;
$new_wiki_text = implode('', $parts);
$object->{$field_name} = $new_wiki_text;
}
### update
$object->update(array($field_name));
### mark parent of comment as changes
if ($item->type == ITEM_COMMENT) {
if ($parent_task = Task::getById($object->task)) {
print "calling now changed by user";
$parent_task->nowChangedByUser();
}
}
print wiki2purehtml($object->{$field_name});
$item->nowChangedByUser();
}
示例13: render_tr
function render_tr(&$obj, $style = "")
{
global $PH;
$str = "";
if (isset($obj->task)) {
if ($task = Task::getById($obj->task)) {
$str = $PH->getLink('taskView', $task->getShort(), array('tsk' => $task->id));
}
}
print "<td><nobr>{$str}</nobr></td>";
}
示例14: testResolveAndRenderTaskCardDetailsSubscribersContent
/**
* @covers resolveAndRenderTaskCardDetailsSubscribersContent
*/
public function testResolveAndRenderTaskCardDetailsSubscribersContent()
{
$hellodear = UserTestHelper::createBasicUser('hellodear');
$task = new Task();
$task->name = 'MyCardTest';
$task->owner = $hellodear;
$this->assertTrue($task->save());
$task = Task::getById($task->id);
$user = Yii::app()->user->userModel;
TasksUtil::addSubscriber($hellodear, $task);
$this->assertTrue($task->save());
$content = TasksUtil::resolveAndRenderTaskCardDetailsSubscribersContent($task);
$this->assertContains('gravatar', $content);
$this->assertContains('users/default/details', $content);
$this->assertContains('hellodear', $content);
$this->assertContains('task-owner', $content);
}
示例15: testResolveRelatedContactsAndSetLatestActivityDateTime
public function testResolveRelatedContactsAndSetLatestActivityDateTime()
{
$contact = ContactTestHelper::createContactByNameForOwner('contact2', Yii::app()->user->userModel);
$this->assertNull($contact->latestActivityDateTime);
$contact2 = ContactTestHelper::createContactByNameForOwner('contact3', Yii::app()->user->userModel);
$this->assertNull($contact2->latestActivityDateTime);
$task = TaskTestHelper::createTaskByNameForOwner('task3', Yii::app()->user->userModel);
$task->activityItems->add($contact);
$task->activityItems->add($contact2);
$this->assertTrue($task->save());
$this->assertNull($task->activityItems[0]->latestActivityDateTime);
$this->assertNull($task->activityItems[1]->latestActivityDateTime);
$taskId = $task->id;
$contactId = $contact->id;
$contact2Id = $contact2->id;
$task->forget();
$contact->forget();
$contact2->forget();
//Retrieve the task, so the related activity item is an Item and needs to be casted down
$task = Task::getById($taskId);
$dateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
ContactLatestActivityDateTimeObserver::resolveRelatedModelsAndSetLatestActivityDateTime($task->activityItems, $dateTime, 'Contact');
$task->forget();
$contact = Contact::getById($contactId);
$this->assertEquals($dateTime, $contact->latestActivityDateTime);
$contact2 = Contact::getById($contact2Id);
$this->assertEquals($dateTime, $contact2->latestActivityDateTime);
}