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


PHP Tasks::findById方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * @param Request $request
  * @return TasksController
  */
 function __construct($request)
 {
     parent::__construct($request);
     $task_id = $this->request->getId('task_id');
     if ($task_id) {
         $this->active_task = Tasks::findById($task_id);
     }
     // if
     if (instance_of($this->active_task, 'Task')) {
         $this->active_task_parent = $this->active_task->getParent();
         if (instance_of($this->active_task_parent, 'ProjectObject')) {
             $this->active_task_parent->prepareProjectSectionBreadcrumb($this->wireframe);
         }
         // if
     } else {
         $this->active_task = new Task();
         $parent_id = $this->request->getId('parent_id');
         if ($parent_id) {
             $parent = ProjectObjects::findById($parent_id);
             if (instance_of($parent, 'ProjectObject')) {
                 $this->active_task_parent = $parent;
                 $this->active_task_parent->prepareProjectSectionBreadcrumb($this->wireframe);
             }
             // if
         }
         // if
     }
     // if
     if (instance_of($this->active_task_parent, 'ProjectObject')) {
         $this->wireframe->addBreadCrumb($this->active_task_parent->getName(), $this->active_task_parent->getViewUrl());
     } else {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $this->smarty->assign(array('active_task' => $this->active_task, 'active_task_parent' => $this->active_task_parent, 'page_tab' => $this->active_task->getProjectTab()));
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:42,代码来源:TasksController.class.php

示例2: analyze_message

 /**
  * Find project objects in commit message, make them links and
  * save the relations to database
  *
  * @param string $commit_message
  * @param string $commit_author
  * @param integer $revision
  * @param Repository $repository
  * @param Project $project
  * @return string
  */
 function analyze_message($commit_message, $commit_author, $revision, $repository, $project)
 {
     if (define('PURIFY_HTML') && PURIFY_HTML) {
         $commit_message = purify_html($commit_message);
         // Clean!
     }
     // if
     $pattern = '/((complete[d]*)[\\s]+)?(ticket|milestone|discussion|task)[s]*[\\s]+[#]*\\d+/i';
     if (preg_match_all($pattern, $commit_message, $matches)) {
         $i = 0;
         $search = array();
         $replace = array();
         $matches_unique = array_unique($matches['0']);
         foreach ($matches_unique as $key => $match) {
             $match_data = preg_split('/[\\s,]+/', $match, null, PREG_SPLIT_NO_EMPTY);
             // check if the object got completed by this commit
             $object_completed = false;
             if (strpos(strtolower($match_data['0']), 'complete') !== false) {
                 $object_completed = true;
                 unset($match_data['0']);
                 $match_data = array_values($match_data);
             }
             // if
             $object_class_name = $match_data['0'];
             $module_name = Inflector::pluralize($object_class_name);
             $object_id = trim($match_data['1'], '#');
             $search[$i] = $match;
             if (class_exists($module_name) && class_exists($object_class_name)) {
                 $object = null;
                 switch (strtolower($module_name)) {
                     case 'tickets':
                         $object = Tickets::findByTicketId($project, $object_id);
                         break;
                     case 'discussions':
                         $object = Discussions::findById($object_id);
                         break;
                     case 'milestones':
                         $object = Milestones::findById($object_id);
                         break;
                     case 'tasks':
                         $object = Tasks::findById($object_id);
                         break;
                 }
                 // switch
                 if (instance_of($object, $object_class_name)) {
                     $link_already_created = CommitProjectObjects::count("object_id = '" . $object->getId() . "' AND revision = '{$revision}'") > 0;
                     if (!$link_already_created) {
                         $comit_project_object = new CommitProjectObject();
                         $comit_project_object->setProjectId($object->getProjectId());
                         $comit_project_object->setObjectId($object->getId());
                         $comit_project_object->setObjectType(ucfirst($object_class_name));
                         $comit_project_object->setRepositoryId($repository->getId());
                         $comit_project_object->setRevision($revision);
                         db_begin_work();
                         $save = $comit_project_object->save();
                         if ($save && !is_error($save)) {
                             db_commit();
                         } else {
                             db_rollback();
                         }
                         // if save
                     }
                     // if
                     $replace[$i] = ($object_completed ? 'Completed ' : '') . '<a href="' . $object->getViewUrl() . '">' . $match_data['0'] . ' ' . $match_data['1'] . '</a>';
                     // set the object as completed
                     if ($object_completed && !instance_of($object, 'Discussion')) {
                         $completed_by = $repository->getMappedUser($commit_author);
                         $object->complete($completed_by);
                     }
                     // if
                 } else {
                     $replace[$i] = ($object_completed ? 'Completed ' : '') . '<a href="#" class="project_object_missing" title="' . lang('Project object does not exist in this project') . '">' . $match_data['0'] . ' ' . $match_data['1'] . '</a>';
                 }
                 // if instance_of
                 $i++;
             }
             // if module loaded
         }
         // foreach
         return str_ireplace($search, $replace, htmlspecialchars($commit_message));
         // linkify
     }
     // if preg_match
     return $commit_message;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:96,代码来源:Commit.class.php

示例3: analyzeCommitMessage

 /**
  * Add AC object links to commit messages
  *
  * @param string
  * @return string
  **/
 private function analyzeCommitMessage($commit_message)
 {
     $pattern = '/(ticket|milestone|discussion|task)[s]*[\\s]+[#]*(\\d+)/i';
     if (preg_match_all($pattern, $commit_message, $matches)) {
         $i = 0;
         $search = array();
         $replace = array();
         $matches_unique = array_unique($matches['0']);
         foreach ($matches_unique as $key => $match) {
             $match_data = preg_split('/[\\s,]+/', $match, null, PREG_SPLIT_NO_EMPTY);
             $object_class_name = $match_data['0'];
             $module_name = Inflector::pluralize($object_class_name);
             $object_id = trim($match_data['1'], '#');
             $search[$i] = $match;
             if (class_exists($module_name) && class_exists($object_class_name)) {
                 $object = null;
                 switch (strtolower($module_name)) {
                     case 'tickets':
                         $object = Tickets::findByTicketId($this->active_project, $object_id);
                         break;
                     case 'discussions':
                         $object = Discussions::findById($object_id);
                         break;
                     case 'milestones':
                         $object = Milestones::findById($object_id);
                         break;
                     case 'tasks':
                         $object = Tasks::findById($object_id);
                         break;
                 }
                 // switch
                 if (instance_of($object, $object_class_name)) {
                     $replace[$i] = '<a href="' . $object->getViewUrl() . '">' . $match_data['0'] . ' ' . $match_data['1'] . '</a>';
                 } else {
                     $replace[$i] = '<a href="#" class="project_object_missing" title="' . lang('Project object does not exist in this project') . '">' . $match_data['0'] . ' ' . $match_data['1'] . '</a>';
                 }
                 // if instance_of
                 $i++;
             }
             // if module loaded
         }
         // foreach
         return str_ireplace($search, $replace, htmlspecialchars($commit_message));
         // linkify
     }
     // if preg_match
     return $commit_message;
 }
开发者ID:hutbert,项目名称:ActiveCollab-Github-Module,代码行数:54,代码来源:GithubController.class.php

示例4: resources_handle_on_project_object_copied

/**
 * Hnalde on_project_object_copied event
 *
 * @param ProjectObject $original
 * @param ProjectObject $copy
 * @param Project $destination
 * @param mixed $cascade
 * @return null
 */
function resources_handle_on_project_object_copied(&$original, &$copy, &$destination, $cascade)
{
    if ($original->can_have_subscribers) {
        $subscribers = $original->getSubscribers();
        if (is_foreachable($subscribers)) {
            foreach ($subscribers as $subscriber) {
                if ($subscriber->isProjectMember($destination)) {
                    Subscriptions::subscribe($subscriber, $copy);
                }
                // if
            }
            // foreach
        }
        // if
    }
    // if
    if ($original->can_have_assignees) {
        Assignments::cloneAssignments($original, $copy);
    }
    // if
    if ($original->can_have_attachments) {
        Attachments::cloneAttachments($original, $copy);
    }
    // if
    // Copy child objects
    if ($cascade === true || is_foreachable($cascade)) {
        if ($cascade === true) {
            $rows = db_execute_all('SELECT * FROM ' . TABLE_PREFIX . 'project_objects WHERE parent_id = ?', $original->getId());
        } else {
            $rows = db_execute_all('SELECT * FROM ' . TABLE_PREFIX . 'project_objects WHERE parent_id = ? AND type IN (?)', $original->getId(), $cascade);
        }
        // if
        if (is_foreachable($rows)) {
            // We'll remember original and copy tasks ID-s here so we can move
            // assignments later on, when we have both instances
            $tasks = array();
            foreach ($rows as $row) {
                $subobject_original_id = $row['id'];
                $subobject_original_type = strtolower($row['type']);
                unset($row['id']);
                $row['project_id'] = $destination->getId();
                $row['parent_id'] = $copy->getId();
                $row['milestone_id'] = 0;
                // Copy file
                if ($subobject_original_type == 'attachment') {
                    $path = UPLOAD_PATH . '/' . $row['varchar_field_1'];
                    if (is_file($path)) {
                        $destination_file = get_available_uploads_filename();
                        if (copy($path, $destination_file)) {
                            $row['varchar_field_1'] = basename($destination_file);
                        }
                        // if
                    }
                    // if
                }
                // if
                // Escape values
                foreach ($row as $k => $v) {
                    $row[$k] = db_escape($v);
                }
                // foreach
                db_execute('INSERT INTO ' . TABLE_PREFIX . 'project_objects (' . implode(', ', array_keys($row)) . ') VALUES (' . implode(', ', $row) . ')');
                if ($subobject_original_type == 'task') {
                    $tasks[$subobject_original_id] = db_last_insert_id();
                }
                // if
            }
            // foraech
            if (instance_of($copy, 'Discussion')) {
                $last_comment = $copy->getLastComment();
                $last_comment_datetime = instance_of($last_comment, 'Comment') ? $last_comment->getCreatedOn() : null;
                $copy->setLastCommentOn($last_comment_datetime);
                $copy->save();
            }
            // if
            // Lets move task assinments if we have any tasks
            if (is_foreachable($tasks)) {
                foreach ($tasks as $task_original_id => $task_copy_id) {
                    $task_original = Tasks::findById($task_original_id);
                    $task_copy = Tasks::findById($task_copy_id);
                    if (instance_of($task_original, 'Task') && instance_of($task_copy, 'Task')) {
                        Assignments::cloneAssignments($task_original, $task_copy);
                        Subscriptions::cloneSubscriptions($task_original, $task_copy);
                    }
                    // if
                }
                // foreach
            }
            // if
        }
        // if
//.........这里部分代码省略.........
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:101,代码来源:on_project_object_copied.php


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