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


PHP ProjectTasks::populateTimeslots方法代码示例

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


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

示例1: index

 function index()
 {
     $tasksUserId = array_var($_GET, 'tu');
     if (is_null($tasksUserId)) {
         $tasksUserId = user_config_option('TM tasks user filter', logged_user()->getId());
     } else {
         if (user_config_option('TM tasks user filter') != $tasksUserId) {
             set_user_config_option('TM tasks user filter', $tasksUserId, logged_user()->getId());
         }
     }
     $timeslotsUserId = array_var($_GET, 'tsu');
     if (is_null($timeslotsUserId)) {
         $timeslotsUserId = user_config_option('TM user filter', 0);
     } else {
         if (user_config_option('TM user filter') != $timeslotsUserId) {
             set_user_config_option('TM user filter', $timeslotsUserId, logged_user()->getId());
         }
     }
     $showTimeType = array_var($_GET, 'stt');
     if (is_null($showTimeType)) {
         $showTimeType = user_config_option('TM show time type', 0);
     } else {
         if (user_config_option('TM show time type') != $showTimeType) {
             set_user_config_option('TM show time type', $showTimeType, logged_user()->getId());
         }
     }
     $start = array_var($_GET, 'start', 0);
     $limit = 20;
     $tasksUser = Contacts::findById($tasksUserId);
     $timeslotsUser = Contacts::findById($timeslotsUserId);
     //Active tasks view
     $open_timeslots = Timeslots::instance()->listing(array("extra_conditions" => " AND end_time = '" . EMPTY_DATETIME . "' AND contact_id = " . $tasksUserId))->objects;
     $tasks = array();
     foreach ($open_timeslots as $open_timeslot) {
         $task = ProjectTasks::findById($open_timeslot->getRelObjectId());
         if ($task instanceof ProjectTask && !$task->isCompleted() && !$task->isTrashed() && !$task->isArchived()) {
             $tasks[] = $task;
         }
     }
     ProjectTasks::populateTimeslots($tasks);
     //Timeslots view
     $total = 0;
     switch ($showTimeType) {
         case 0:
             //Show only timeslots added through the time panel
             $result = Timeslots::getGeneralTimeslots(active_context(), $timeslotsUser, $start, $limit);
             $timeslots = $result->objects;
             $total = $result->total;
             break;
         default:
             throw new Error('Unrecognised TM show time type: ' . $showTimeType);
     }
     //Get Users Info
     $users = array();
     $context = active_context();
     if (!can_manage_time(logged_user())) {
         if (can_add(logged_user(), $context, Timeslots::instance()->getObjectTypeId())) {
             $users = array(logged_user());
         }
     } else {
         if (logged_user()->isMemberOfOwnerCompany()) {
             $users = Contacts::getAllUsers();
         } else {
             $users = logged_user()->getCompanyId() > 0 ? Contacts::getAllUsers(" AND `company_id` = " . logged_user()->getCompanyId()) : array(logged_user());
         }
         $tmp_users = array();
         foreach ($users as $user) {
             if (can_add($user, $context, Timeslots::instance()->getObjectTypeId())) {
                 $tmp_users[] = $user;
             }
         }
         $users = $tmp_users;
     }
     //Get Companies Info
     if (logged_user()->isMemberOfOwnerCompany() || logged_user()->isAdminGroup()) {
         $companies = Contacts::getCompaniesWithUsers();
     } else {
         $companies = array();
         if (logged_user()->getCompanyId() > 0) {
             $companies[] = logged_user()->getCompany();
         }
     }
     $required_dimensions = DimensionObjectTypeContents::getRequiredDimensions(Timeslots::instance()->getObjectTypeId());
     $draw_inputs = !$required_dimensions || count($required_dimensions) == 0;
     if (!$draw_inputs) {
         $ts_ots = DimensionObjectTypeContents::getDimensionObjectTypesforObject(Timeslots::instance()->getObjectTypeId());
         $context = active_context();
         foreach ($context as $sel) {
             if ($sel instanceof Member) {
                 foreach ($ts_ots as $ts_ot) {
                     if ($sel->getDimensionId() == $ts_ot->getDimensionId() && $sel->getObjectTypeId() == $ts_ot->getDimensionObjectTypeId()) {
                         $draw_inputs = true;
                         break;
                     }
                 }
                 if ($draw_inputs) {
                     break;
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:rorteg,项目名称:fengoffice,代码行数:101,代码来源:TimeController.class.php


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