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


PHP Task::getById方法代码示例

本文整理汇总了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();
 }
开发者ID:xamin123,项目名称:code-example,代码行数:7,代码来源:JobBroker.php

示例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');
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:29,代码来源:ActivitiesObserverTest.php

示例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>";
}
开发者ID:Bremaweb,项目名称:streber-1,代码行数:33,代码来源:items_remove_many_preview.inc.php

示例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);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:25,代码来源:KanbanItemTest.php

示例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();
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:11,代码来源:DefaultController.php

示例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')));
 }
开发者ID:Bremaweb,项目名称:streber-1,代码行数:50,代码来源:list_taskfolders.inc.php

示例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());
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:20,代码来源:ActivityCopyModelUtilTest.php

示例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;
 }
开发者ID:Bremaweb,项目名称:streber-1,代码行数:14,代码来源:class_task.inc.php

示例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;
 }
开发者ID:KulturedKitsch,项目名称:kulturedkitsch.info,代码行数:14,代码来源:DefaultController.php

示例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);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:16,代码来源:TaskTest.php

示例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();
}
开发者ID:Bremaweb,项目名称:streber-1,代码行数:89,代码来源:item_ajax.inc.php

示例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>";
 }
开发者ID:Bremaweb,项目名称:streber-1,代码行数:11,代码来源:list_efforts.inc.php

示例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);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:20,代码来源:TasksUtilTest.php

示例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);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:28,代码来源:ContactLatestActivityDateTimeObserverTest.php


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