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


PHP CEvent::getRecurrentEventforPeriod方法代码示例

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


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

示例1: getEventsForPeriod

 /**
 * Utility function to return an array of events with a period
 * @param Date Start date of the period
 * @param Date End date of the period
 * @return array A list of events
 */
 function getEventsForPeriod($start_date, $end_date, $filter = 'all', $user_id = null, $project_id = 0)
 {
     global $AppUI;
     // the event times are stored as unix time stamps, just to be different
     // convert to default db time stamp
     $db_start = $start_date->format(FMT_DATETIME_MYSQL);
     $db_end = $end_date->format(FMT_DATETIME_MYSQL);
     if (!isset($user_id)) {
         $user_id = $AppUI->user_id;
     }
     $project =& new CProject();
     if ($project_id) {
         $p =& $AppUI->acl();
         if ($p->checkModuleItem('projects', 'view', $project_id, $user_id)) {
             $allowedProjects = array('p.project_id = ' . $project_id);
         } else {
             $allowedProjects = array('1=0');
         }
     } else {
         $allowedProjects = $project->getAllowedSQL($user_id, 'event_project');
     }
     //do similiar actions for recurring and non-recurring events
     $queries = array('q' => 'q', 'r' => 'r');
     foreach ($queries as $query_set) {
         ${$query_set} = new DBQuery();
         ${$query_set}->addTable('events', 'e');
         ${$query_set}->addQuery('e.*');
         ${$query_set}->addOrder('e.event_start_date, e.event_end_date ASC');
         ${$query_set}->addJoin('projects', 'p', 'p.project_id =  e.event_project');
         if ($AppUI->getState('CalIdxCompany')) {
             ${$query_set}->addWhere('project_company = ' . $AppUI->getState('CalIdxCompany'));
         }
         if (count($allowedProjects)) {
             ${$query_set}->addWhere('((' . implode(' AND ', $allowedProjects) . ') ' . ($AppUI->getState('CalIdxCompany') ? '' : $project_id ? '' : ' OR event_project = 0 ') . ')');
         }
         switch ($filter) {
             case 'my':
                 ${$query_set}->addJoin('user_events', 'ue', 'ue.event_id = e.event_id AND ue.user_id =' . $user_id);
                 ${$query_set}->addWhere('(ue.user_id = ' . $user_id . ') AND (event_private=0 OR event_owner=' . $user_id . ')');
                 break;
             case 'own':
                 ${$query_set}->addWhere('event_owner =' . $user_id);
                 break;
             case 'all':
                 ${$query_set}->addWhere('(event_private=0 OR event_owner=' . $user_id . ')');
                 break;
         }
         if ($query_set == 'q') {
             // assemble query for non-recursive events
             ${$query_set}->addWhere('(event_recurs <= 0)');
             // following line is only good for *non-recursive* events
             ${$query_set}->addWhere("(event_start_date <= '{$db_end}' AND event_end_date >= '{$db_start}' " . "OR event_start_date BETWEEN '{$db_start}' AND '{$db_end}')");
             $eventList = ${$query_set}->loadList();
         } else {
             if ($query_set == 'r') {
                 // assemble query for recursive events
                 ${$query_set}->addWhere('(event_recurs > 0)');
                 $eventListRec = ${$query_set}->loadList();
             }
         }
     }
     //Calculate the Length of Period (Daily, Weekly, Monthly View)
     setlocale(LC_TIME, 'en_AU');
     $periodLength = Date_Calc::dateDiff($start_date->getDay(), $start_date->getMonth(), $start_date->getYear(), $end_date->getDay(), $end_date->getMonth(), $end_date->getYear());
     setlocale(LC_ALL, $AppUI->user_lang);
     // AJD: Should this be going off the end of the array?  I don't think so.
     // If it should then a comment to that effect would be nice.
     // for ($i=0; $i < sizeof($eventListRec)+1;  $i++) {
     for ($i = 0, $sz = sizeof($eventListRec); $i < $sz; $i++) {
         //note from merlinyoda: j=0 is the original event according to getRecurrentEventforPeriod
         // So, since the event is *recurring* x times, the loop condition should be j <= x, not j < x.
         // This way the original and all recurrances are covered.
         //for ($j=0; $j < intval($eventListRec[$i]['event_times_recuring']); $j++) {
         for ($j = 0, $end = intval($eventListRec[$i]['event_times_recuring']); $j < $end; $j++) {
             if ($periodLength == 1) {
                 // Daily View: show all
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $eventListRec[$i]['event_start_date'], $eventListRec[$i]['event_end_date'], $eventListRec[$i]['event_recurs'], $eventListRec[$i]['event_times_recuring'], $j);
             } elseif ($periodLength > 1 && $eventListRec[$i]['event_recurs'] == 1 && $j == 0) {
                 // Weekly or Monthly View and Hourly Recurrent Events: show one time and add string 'hourly'
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $eventListRec[$i]['event_start_date'], $eventListRec[$i]['event_end_date'], $eventListRec[$i]['event_recurs'], $eventListRec[$i]['event_times_recuring'], $j);
                 $eventListRec[$i]['event_title'] = $eventListRec[$i]['event_title'] . ' (' . $AppUI->_('Hourly') . ')';
             } elseif ($periodLength > 1 && $eventListRec[$i]['event_recurs'] > 1) {
                 //Weekly and Monthly View and higher recurrence mode: show all events of recurrence > 1
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $eventListRec[$i]['event_start_date'], $eventListRec[$i]['event_end_date'], $eventListRec[$i]['event_recurs'], $eventListRec[$i]['event_times_recuring'], $j);
             }
             //add values to the eventsArray if check for recurrent event was positive
             if (sizeof($recEventDate) > 0) {
                 $eList[0] = $eventListRec[$i];
                 $eList[0]['event_start_date'] = $recEventDate[0]->format(FMT_DATETIME_MYSQL);
                 $eList[0]['event_end_date'] = $recEventDate[1]->format(FMT_DATETIME_MYSQL);
                 $eventList = array_merge($eventList, $eList);
             }
             // clear array of positive recurrent events for the case that next loop recEventDate is empty in order to avoid double display
             $recEventDate = array();
//.........这里部分代码省略.........
开发者ID:klr2003,项目名称:sourceread,代码行数:101,代码来源:calendar.class.php

示例2: getEventsForPeriod

 /**
  * Utility function to return an array of events with a period
  * @param Date Start date of the period
  * @param Date End date of the period
  * @return array A list of events
  */
 public function getEventsForPeriod($start_date, $end_date, $filter = 'all', $user_id = null, $project_id = 0, $company_id = 0)
 {
     global $AppUI;
     // convert to default db time stamp
     $db_start = $start_date->format(FMT_DATETIME_MYSQL);
     $db_start = $AppUI->convertToSystemTZ($db_start);
     $db_end = $end_date->format(FMT_DATETIME_MYSQL);
     $db_end = $AppUI->convertToSystemTZ($db_end);
     if (!isset($user_id)) {
         $user_id = $AppUI->user_id;
     }
     $project = new CProject();
     if ($project_id) {
         $p =& $AppUI->acl();
         if ($p->checkModuleItem('projects', 'view', $project_id, $user_id)) {
             $allowedProjects = array('p.project_id = ' . (int) $project_id);
         } else {
             $allowedProjects = array('1=0');
         }
     } else {
         $allowedProjects = $project->getAllowedSQL($user_id ? $user_id : $AppUI->user_id, 'event_project');
     }
     //do similiar actions for recurring and non-recurring events
     $queries = array('q' => 'q', 'r' => 'r');
     foreach ($queries as $query_set) {
         ${$query_set} = new w2p_Database_Query();
         ${$query_set}->addTable('events', 'e');
         ${$query_set}->addQuery('e.*');
         ${$query_set}->addOrder('e.event_start_date, e.event_end_date ASC');
         ${$query_set}->leftJoin('projects', 'p', 'p.project_id =  e.event_project');
         ${$query_set}->leftJoin('project_departments', 'project_departments', 'p.project_id = project_departments.project_id OR project_departments.project_id IS NULL');
         ${$query_set}->leftJoin('departments', 'departments', 'departments.dept_id = project_departments.department_id OR dept_id IS NULL');
         if ($company_id) {
             ${$query_set}->addWhere('project_company = ' . (int) $company_id);
         } else {
             if ($AppUI->getState('CalIdxCompany')) {
                 ${$query_set}->addWhere('project_company = ' . $AppUI->getState('CalIdxCompany'));
             }
         }
         if (count($allowedProjects)) {
             ${$query_set}->addWhere('( ( ' . implode(' AND ', $allowedProjects) . ' ) ' . ($AppUI->getState('CalIdxCompany') ? '' : ($project_id ? '' : ' OR event_project = 0 ')) . ')');
         }
         switch ($filter) {
             case 'my':
                 ${$query_set}->addJoin('user_events', 'ue', 'ue.event_id = e.event_id AND ue.user_id =' . $user_id);
                 ${$query_set}->addWhere('(ue.user_id = ' . (int) $user_id . ') AND (event_private = 0 OR event_owner=' . (int) $user_id . ')');
                 break;
             case 'own':
                 ${$query_set}->addWhere('event_owner =' . (int) $user_id);
                 break;
             case 'all':
                 ${$query_set}->addWhere('(event_private = 0 OR event_owner=' . (int) $user_id . ')');
                 break;
             default:
                 ${$query_set}->addWhere('(event_private = 0 OR event_owner=' . (int) $user_id . ')');
         }
         if ($query_set == 'q') {
             // assemble query for non-recursive events
             ${$query_set}->addWhere('(event_recurs <= 0)');
             // following line is only good for *non-recursive* events
             ${$query_set}->addWhere('(event_start_date <= \'' . $db_end . '\' AND event_end_date >= \'' . $db_start . '\' OR event_start_date BETWEEN \'' . $db_start . '\' AND \'' . $db_end . '\')');
             $eventList = ${$query_set}->loadList();
         } elseif ($query_set == 'r') {
             // assemble query for recursive events
             ${$query_set}->addWhere('(event_recurs > 0)');
             $eventListRec = ${$query_set}->loadList();
         }
     }
     //Calculate the Length of Period (Daily, Weekly, Monthly View)
     setlocale(LC_TIME, 'en');
     $periodLength = Date_Calc::dateDiff($start_date->getDay(), $start_date->getMonth(), $start_date->getYear(), $end_date->getDay(), $end_date->getMonth(), $end_date->getYear());
     setlocale(LC_ALL, $AppUI->user_lang);
     // AJD: Should this be going off the end of the array?  I don't think so.
     // If it should then a comment to that effect would be nice.
     for ($i = 0, $i_cmp = sizeof($eventListRec); $i < $i_cmp; $i++) {
         //note from merlinyoda: j=0 is the original event according to getRecurrentEventforPeriod
         // So, since the event is *recurring* x times, the loop condition should be j <= x, not j < x.
         // This way the original and all recurrances are covered.
         for ($j = 0, $j_cmp = intval($eventListRec[$i]['event_times_recuring']); $j <= $j_cmp; $j++) {
             //Daily View
             //show all
             if ($periodLength <= 1) {
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $eventListRec[$i]['event_start_date'], $eventListRec[$i]['event_end_date'], $eventListRec[$i]['event_recurs'], $eventListRec[$i]['event_times_recuring'], $j);
             } elseif ($periodLength > 1 && $eventListRec[$i]['event_recurs'] == 1 && $j == 0) {
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $eventListRec[$i]['event_start_date'], $eventListRec[$i]['event_end_date'], $eventListRec[$i]['event_recurs'], $eventListRec[$i]['event_times_recuring'], $j);
                 $eventListRec[$i]['event_title'] = $eventListRec[$i]['event_title'] . ' (' . $AppUI->_('Hourly') . ')';
             } elseif ($periodLength > 1 && $eventListRec[$i]['event_recurs'] > 1) {
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $eventListRec[$i]['event_start_date'], $eventListRec[$i]['event_end_date'], $eventListRec[$i]['event_recurs'], $eventListRec[$i]['event_times_recuring'], $j);
             }
             //add values to the eventsArray if check for recurrent event was positive
             if (sizeof($recEventDate) > 0) {
                 $eList[0] = $eventListRec[$i];
                 $eList[0]['event_start_date'] = $recEventDate[0]->format(FMT_DATETIME_MYSQL);
                 $eList[0]['event_end_date'] = $recEventDate[1]->format(FMT_DATETIME_MYSQL);
//.........这里部分代码省略.........
开发者ID:viniciusbudines,项目名称:sisnuss,代码行数:101,代码来源:calendar.class.php

示例3: getEventsForPeriod

 /**
 * Utility function to return an array of events with a period
 * @param Date Start date of the period
 * @param Date End date of the period
 * @return array A list of events
 */
 function getEventsForPeriod($start_date, $end_date, $filter = 'all', $user_id = null)
 {
     global $AppUI;
     // the event times are stored as unix time stamps, just to be different
     // convert to default db time stamp
     $db_start = $start_date->format(FMT_DATETIME_MYSQL);
     $db_end = $end_date->format(FMT_DATETIME_MYSQL);
     if (!isset($user_id)) {
         $user_id = $AppUI->user_id;
     }
     $project =& new CProject();
     $allowedProjects = $project->getAllowedSQL($user_id, 'event_project');
     $q = new DBQuery();
     $q->addTable('events', 'e');
     $q->addQuery('e.*');
     if (count($allowedProjects)) {
         $q->addWhere('( ( ' . implode(' AND ', $allowedProjects) . ") OR event_project = 0 )");
         $q->addJoin('projects', 'p', 'p.project_id = e.event_project');
     }
     switch ($filter) {
         case 'my':
             $q->addJoin('user_events', 'ue', 'ue.event_id = e.event_id AND ue.user_id =' . $user_id);
             $q->addWhere("( ( event_private = 0 AND ue.user_id = {$user_id} )\n\t\t\t\t\t\tOR event_owner={$user_id} )");
             break;
         case 'own':
             $q->addWhere("( event_owner = {$user_id} )");
             break;
         case 'all':
             $q->addWhere("( event_private=0 OR (event_private=1 AND event_owner={$user_id}) )");
             break;
     }
     $q->addWhere("( event_start_date <= '{$db_end}' AND event_end_date >= '{$db_start}'\n\t\t\t\tOR event_start_date BETWEEN '{$db_start}' AND '{$db_end}')");
     // duplicate query object for recursive events;
     $r = $q;
     // assemble query for non-recursive events
     $q->addWhere('( event_recurs <= 0 )');
     $eventList = $q->loadList();
     // assemble query for recursive events
     $r->addWhere('( event_recurs > 0 )');
     $eventListRec = $r->loadList();
     //Calculate the Length of Period (Daily, Weekly, Monthly View)
     $periodLength = Date_Calc::dateDiff($start_date->getDay(), $start_date->getMonth(), $start_date->getYear(), $end_date->getDay(), $end_date->getMonth(), $end_date->getYear());
     // AJD: Should this be going off the end of the array?  I don't think so.
     // If it should then a comment to that effect would be nice.
     // for ($i=0; $i < sizeof($eventListRec)+1;  $i++) {
     for ($i = 0; $i < sizeof($eventListRec); $i++) {
         for ($j = 0; $j < intval($eventListRec[$i]['event_times_recuring']); $j++) {
             //Daily View
             //show all
             if ($periodLength == 1) {
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $eventListRec[$i]['event_start_date'], $eventListRec[$i]['event_end_date'], $eventListRec[$i]['event_recurs'], $eventListRec[$i]['event_times_recuring'], $j);
             } elseif ($periodLength > 1 && $eventListRec[$i]['event_recurs'] == 1 && $j == 0) {
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $eventListRec[$i]['event_start_date'], $eventListRec[$i]['event_end_date'], $eventListRec[$i]['event_recurs'], $eventListRec[$i]['event_times_recuring'], $j);
                 $eventListRec[$i]['event_title'] = $eventListRec[$i]['event_title'] . " (" . $AppUI->_('Hourly') . ")";
             } elseif ($periodLength > 1 && $eventListRec[$i]['event_recurs'] > 1) {
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $eventListRec[$i]['event_start_date'], $eventListRec[$i]['event_end_date'], $eventListRec[$i]['event_recurs'], $eventListRec[$i]['event_times_recuring'], $j);
             }
             //add values to the eventsArray if check for recurrent event was positive
             if (sizeof($recEventDate) > 0) {
                 $eList[0] = $eventListRec[$i];
                 $eList[0]['event_start_date'] = $recEventDate[0]->format(FMT_DATETIME_MYSQL);
                 $eList[0]['event_end_date'] = $recEventDate[1]->format(FMT_DATETIME_MYSQL);
                 $eventList = array_merge($eventList, $eList);
             }
             // clear array of positive recurrent events for the case that next loop recEventDate is empty in order to avoid double display
             $recEventDate = array();
         }
     }
     //return a list of non-recurrent and recurrent events
     return $eventList;
 }
开发者ID:juliogallardo1326,项目名称:proc,代码行数:77,代码来源:calendar.class.php

示例4: getEventsForPeriod

 /**
  * Utility function to return an array of events with a period
  * @param Date Start date of the period
  * @param Date End date of the period
  * @return array A list of events
  */
 function getEventsForPeriod($start_date, $end_date, $filter = 'all', $user_id = null, $project_id = 0)
 {
     global $AppUI;
     // the event times are stored as unix time stamps, just to be different
     // convert to default db time stamp
     $db_start = $start_date->format(FMT_DATETIME_MYSQL);
     $db_end = $end_date->format(FMT_DATETIME_MYSQL);
     if (!isset($user_id)) {
         $user_id = $AppUI->user_id;
     }
     $project = new CProject();
     if ($project_id) {
         $p =& $AppUI->acl();
         if ($p->checkModuleItem('projects', 'view', $project_id, $user_id)) {
             $allowedProjects = array('p.project_id = ' . $project_id);
         } else {
             $allowedProjects = array('1=0');
         }
     } else {
         $allowedProjects = $project->getAllowedSQL($user_id, 'event_project');
     }
     //do similiar actions for recurring and non-recurring events
     $queries = array('q' => 'q', 'r' => 'r');
     foreach ($queries as $query_set) {
         ${$query_set} = new DBQuery();
         ${$query_set}->addTable('events', 'e');
         ${$query_set}->addQuery('DISTINCT e.*');
         ${$query_set}->addOrder('e.event_start_date, e.event_end_date ASC');
         ${$query_set}->addJoin('projects', 'p', 'p.project_id =  e.event_project');
         if ($AppUI->getState('CalIdxCompany')) {
             ${$query_set}->addWhere('p.project_company = ' . $AppUI->getState('CalIdxCompany'));
         }
         if (count($allowedProjects)) {
             ${$query_set}->addWhere('((' . implode(' AND ', $allowedProjects) . ') ' . ($AppUI->getState('CalIdxCompany') || $project_id ? '' : ' OR event_project = 0 ') . ')');
         }
         switch ($filter) {
             case 'my':
                 ${$query_set}->addJoin('user_events', 'ue', 'ue.event_id = e.event_id AND ue.user_id =' . $user_id);
                 ${$query_set}->addWhere('(ue.user_id = ' . $user_id . ') AND (event_private=0 OR event_owner=' . $user_id . ')');
                 break;
             case 'own':
                 ${$query_set}->addWhere('e.event_owner =' . $user_id);
                 break;
             case 'all':
                 ${$query_set}->addWhere('(e.event_private=0 OR e.event_owner=' . $user_id . ')');
                 break;
         }
         if ($query_set == 'q') {
             // assemble query for non-recursive events
             // following line is only good for *non-recursive* events
             ${$query_set}->addWhere('(event_recurs <= 0)');
             ${$query_set}->addWhere("(event_start_date < '{$db_end}'" . " AND event_end_date > '{$db_start}')");
             $eventList = ${$query_set}->loadList();
         } else {
             if ($query_set == 'r') {
                 // assemble query for recursive events
                 ${$query_set}->addWhere('(event_recurs > 0)');
                 $eventListRec = ${$query_set}->loadList();
             }
         }
     }
     //Calculate the Length of Period (Daily, Weekly, Monthly View)
     setlocale(LC_ALL, 'en_AU' . ($locale_char_set ? '.' . $locale_char_set : '.utf8'));
     $periodLength = Date_Calc::dateDiff($end_date->getDay(), $end_date->getMonth(), $end_date->getYear(), $start_date->getDay(), $start_date->getMonth(), $start_date->getYear());
     setlocale(LC_ALL, $AppUI->user_lang);
     foreach ($eventListRec as $key => $ia) {
         $end = intval($ia['event_times_recuring']);
         for ($j = 0; $j < $end; $j++) {
             $recEventDate = array();
             if ($periodLength <= 1) {
                 // Daily View or clash check: show all
                 $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $ia['event_start_date'], $ia['event_end_date'], $ia['event_recurs'], $ia['event_times_recuring'], $j);
             } else {
                 if ($ia['event_recurs'] == 1 && $j == 0) {
                     // Weekly or Monthly View and Hourly Recurrent Events
                     //show one time and add string 'hourly'
                     $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $ia['event_start_date'], $ia['event_end_date'], $ia['event_recurs'], $ia['event_times_recuring'], $j);
                     $eventListRec[$key]['event_title'] = $ia['event_title'] . ' (' . $AppUI->_('Hourly') . ')';
                 } else {
                     if ($ia['event_recurs'] > 1) {
                         //Weekly and Monthly View and higher recurrence mode
                         //show all events of recurrence > 1
                         $recEventDate = CEvent::getRecurrentEventforPeriod($start_date, $end_date, $ia['event_start_date'], $ia['event_end_date'], $ia['event_recurs'], $ia['event_times_recuring'], $j);
                     }
                 }
             }
             //add values to the eventsArray if check for recurrent event was positive
             if (!empty($recEventDate)) {
                 $display_start = $recEventDate[0]->format(FMT_DATETIME_MYSQL);
                 $display_end = $recEventDate[1]->format(FMT_DATETIME_MYSQL);
                 $eventListRec[$key]['event_start_date'] = $display_start;
                 $eventListRec[$key]['event_end_date'] = $display_end;
                 $eventList = array_merge($eventList, array($eventListRec[$key]));
             }
//.........这里部分代码省略.........
开发者ID:hoodoogurus,项目名称:dotprojecteap,代码行数:101,代码来源:calendar.class.php


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