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


PHP CTimeHelper::timeIntervalDifference方法代码示例

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


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

示例1: photosWallEdit

 public static function photosWallEdit($userid, $asset, $wall_obj)
 {
     // @rule: We only allow editing of wall in 15 minutes
     $viewer = CFactory::getUser($userid);
     $now = JFactory::getDate();
     $interval = CTimeHelper::timeIntervalDifference($wall_obj->date, $now->toSql());
     $interval = abs($interval);
     // Only owner and site admin can edit
     if (COwnerHelper::isCommunityAdmin() || $viewer->id == $wall_obj->post_by) {
         return true;
     }
     return false;
 }
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:13,代码来源:photos.php

示例2: editPhotoWall

 public function editPhotoWall($wallId)
 {
     CFactory::load('helpers', 'owner');
     CFactory::load('helpers', 'time');
     $my = CFactory::getUser();
     $wall =& JTable::getInstance('Wall', 'CTable');
     $wall->load($wallId);
     // @rule: We only allow editing of wall in 15 minutes
     $now = JFactory::getDate();
     $interval = CTimeHelper::timeIntervalDifference($wall->date, $now->toMySQL());
     $interval = abs($interval);
     if ((COwnerHelper::isCommunityAdmin() || $my->id == $wall->post_by) && COMMUNITY_WALLS_EDIT_INTERVAL > $interval) {
         return true;
     }
     return false;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:16,代码来源:photos.php

示例3: _getWallHTML

 function _getWallHTML($wall, $wallComments, $appType, $isOwner, $processFunc, $templateFile)
 {
     CFactory::load('helpers', 'url');
     CFactory::load('helpers', 'user');
     CFactory::load('helpers', 'videos');
     CFactory::load('libraries', 'comment');
     CFactory::load('helpers', 'owner');
     CFactory::load('helpers', 'time');
     $user = CFactory::getUser($wall->post_by);
     $date = CTimeHelper::getDate($wall->date);
     $config = CFactory::getConfig();
     // @rule: for site super administrators we want to allow them to view the remove link
     $isOwner = COwnerHelper::isCommunityAdmin() ? true : $isOwner;
     $isEditable = CWall::isEditable($processFunc, $wall->id);
     // Apply any post processing on the content
     $wall->comment = CWallLibrary::_processWallContent($wall->comment);
     $commentsHTML = '';
     $comment = new CComment();
     // If the wall post is a user wall post (in profile pages), we
     // add wall comment feature
     if ($appType == 'user' || $appType == 'groups' || $appType == 'events') {
         $commentsHTML = $comment->getHTML($wallComments, 'wall-cmt-' . $wall->id, CWall::canComment($wall->type, $wall->contentid));
     }
     $avatarHTML = CUserHelper::getThumb($wall->post_by, 'avatar');
     //var_dump($avatarHTML);exit;
     // @rule: We only allow editing of wall in 15 minutes
     $now = JFactory::getDate();
     $interval = CTimeHelper::timeIntervalDifference($wall->date, $now->toMySQL());
     $interval = COMMUNITY_WALLS_EDIT_INTERVAL - abs($interval);
     $editInterval = round($interval / 60);
     // Create new instance of the template
     $tmpl = new CTemplate();
     $tmpl->set('id', $wall->id);
     $tmpl->set('author', $user->getDisplayName());
     $tmpl->set('avatarHTML', $avatarHTML);
     $tmpl->set('authorLink', CUrlHelper::userLink($user->id));
     $tmpl->set('created', $date->toFormat(JText::_('DATE_FORMAT_LC2')));
     $tmpl->set('content', $wall->comment);
     $tmpl->set('commentsHTML', $commentsHTML);
     $tmpl->set('avatar', $user->getThumbAvatar());
     $tmpl->set('isMine', $isOwner);
     $tmpl->set('isEditable', $isEditable);
     $tmpl->set('editInterval', $editInterval);
     $tmpl->set('processFunc', $processFunc);
     $tmpl->set('config', $config);
     return $tmpl->fetch($templateFile);
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:47,代码来源:wall.php

示例4: cTimeIntervalDiff

/**
 * Deprecated since 1.8
 * Use CTimeHelper::timeIntervalDifference instead. 
 */
function cTimeIntervalDiff($start, $end)
{
    return CTimeHelper::timeIntervalDifference($start, $end);
}
开发者ID:Simarpreet05,项目名称:joomla,代码行数:8,代码来源:time.php

示例5: save

 /**
  * Method to save the group
  * @return false if create fail, return the group id if create is successful
  **/
 public function save(&$event)
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN'));
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $viewName = JRequest::getCmd('view', $this->getName());
     $view = $this->getView($viewName, '', $viewType);
     if (JString::strtoupper(JRequest::getMethod()) != 'POST') {
         $view->addWarning(JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING'));
         return false;
     }
     // Get my current data.
     $my = CFactory::getUser();
     $validated = true;
     $model = $this->getModel('events');
     $eventId = JRequest::getInt('eventid', '0');
     $isNew = $eventId == '0' ? true : false;
     $postData = JRequest::get('post');
     //format startdate and eendate with time before we bind into event object
     $this->_formatStartEndDate($postData);
     //		if( !empty($postData['coordinate']) )
     //		{
     //			$coord	= explode( ',', $postData['coordinate'] );
     //			$postData['latitude']	=   trim($coord[0]);
     //			$postData['longitude']	=   trim($coord[1]);
     //		}
     $event->load($eventId);
     $event->bind($postData);
     if (!array_key_exists('permission', $postData)) {
         $event->permission = 0;
     }
     if (!array_key_exists('allowinvite', $postData)) {
         $event->allowinvite = 0;
     } elseif (isset($postData['endtime-ampm']) && $postData['endtime-ampm'] == 'AM' && $postData['endtime-hour'] == 12) {
         $postData['endtime-hour'] = 00;
     }
     $inputFilter = CFactory::getInputFilter(true);
     // Despite the bind, we would still need to capture RAW description
     $event->description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $event->description = $inputFilter->clean($event->description);
     // @rule: Test for emptyness
     if (empty($event->title)) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_TITLE_ERROR'), 'error');
     }
     if (empty($event->location)) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_LOCATION_ERR0R'), 'error');
     }
     // @rule: Test if the event is exists
     if ($model->isEventExist($event->title, $event->location, $event->startdate, $event->enddate, $eventId)) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_TAKEN_ERROR'), 'error');
     }
     // @rule: Description cannot be empty
     /*if( empty( $event->description ) )
     		{
     			$validated = false;
     			$mainframe->enqueueMessage( JText::_('COM_COMMUNITY_EVENTS_TAKEN_ERROR'), 'error');
     		}*/
     // @rule: Start date cannot be empty
     if (empty($event->startdate)) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_STARTDATE_ERROR'), 'error');
     }
     // @rule: End date cannot be empty
     if (empty($event->enddate)) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_ENDDATE_ERROR'), 'error');
     }
     // @rule: Number of ticket must at least be 0
     if (Jstring::strlen($event->ticket) <= 0) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_TICKET_EMPTY_ERROR'), 'error');
     }
     require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'time.php';
     if (CTimeHelper::timeIntervalDifference($event->startdate, $event->enddate) > 0) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_STARTDATE_GREATER_ERROR'), 'error');
     }
     // @rule: Event must not end in the past
     $now = CTimeHelper::getLocaleDate();
     if (CTimeHelper::timeIntervalDifference($now->toMySQL(true), $event->enddate) > 0) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_ENDDATE_GREATER_ERROR'), 'error');
     }
     if ($validated) {
         // If show event timezone is disabled, we need to set the event offset to 0.
         $config = CFactory::getConfig();
         if (!$config->get('eventshowtimezone')) {
             $event->offset = 0;
         }
         // Set the default thumbnail and avatar for the event just in case
         // the user decides to skip this
//.........这里部分代码省略.........
开发者ID:Simarpreet05,项目名称:joomla,代码行数:101,代码来源:events.php

示例6: editDiscussionWall

 public function editDiscussionWall($wallId)
 {
     CFactory::load('helpers', 'owner');
     CFactory::load('helpers', 'time');
     $wall =& JTable::getInstance('Wall', 'CTable');
     $wall->load($wallId);
     $discussion =& JTable::getInstance('Discussion', 'CTable');
     $discussion->load($wall->contentid);
     $group =& JTable::getInstance('Group', 'CTable');
     $group->load($discussion->groupid);
     $model = CFactory::getModel('Groups');
     $my = CFactory::getUser();
     // @rule: We only allow editing of wall in 15 minutes
     $now = JFactory::getDate();
     $interval = CTimeHelper::timeIntervalDifference($wall->date, $now->toMySQL());
     $interval = abs($interval);
     if (($model->isAdmin($my->id, $group->id) || COwnerHelper::isCommunityAdmin() || $my->id == $wall->post_by) && COMMUNITY_WALLS_EDIT_INTERVAL > $interval) {
         return true;
     }
     return false;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:21,代码来源:groups.php

示例7: _generateRepeatList

 private function _generateRepeatList($event, $postData = '')
 {
     $day = 0;
     $month = 0;
     $eventList = array();
     $limit = isset($postData['limit']) ? (int) $postData['limit'] : 0;
     $defaultLimit = 0;
     $count = 0;
     // Repeat option.
     switch ($event->repeat) {
         case 'daily':
             $day = 1;
             $defaultLimit = COMMUNITY_EVENT_RECURRING_LIMIT_DAILY;
             break;
         case 'weekly':
             $day = 7;
             $defaultLimit = COMMUNITY_EVENT_RECURRING_LIMIT_WEEKLY;
             break;
         case 'monthly':
             $month = 1;
             $defaultLimit = COMMUNITY_EVENT_RECURRING_LIMIT_MONTHLY;
             break;
         default:
             break;
     }
     $strstartdate = strtotime($event->startdate);
     $starttime = date('H', $strstartdate) . ':' . date('i', $strstartdate) . ':' . date('s', $strstartdate);
     $strenddate = strtotime($event->enddate);
     $endtime = date('H', $strenddate) . ':' . date('i', $strenddate) . ':' . date('s', $strenddate);
     $startdate = date('Y-m-d', $strstartdate);
     $enddate = date('Y-m-d', $strenddate);
     $start = strtotime($event->startdate);
     $end = strtotime($event->enddate);
     // if repeatend is empty, generate dummy date to make it valid.
     if ($event->repeatend == '') {
         $repeatend = $event->enddate;
         // if both repeat end and limit never been set, use default limit.
         $limit = $limit == 0 ? $defaultLimit : $limit;
     } else {
         $repeatend = $event->repeatend;
     }
     $addDay = 0;
     $addMonth = 0;
     // Generate list of event childs in given date.
     while (CTimeHelper::timeIntervalDifference($repeatend, $enddate) >= 0 || $count < $limit) {
         // Add event child as new array item.
         $eventList[] = array('startdate' => $startdate . ' ' . $starttime, 'enddate' => $enddate . ' ' . $endtime);
         // Compute the next event child.
         $addDay += $day;
         $addMonth += $month;
         $startdate = date('Y-m-d', mktime(0, 0, 0, date('m', $start) + $addMonth, date('d', $start) + $addDay, date('Y', $start)));
         $enddate = date('Y-m-d', mktime(0, 0, 0, date('m', $end) + $addMonth, date('d', $end) + $addDay, date('Y', $end)));
         $count++;
         // To avoid unnecessary loop.
         if ($count > $defaultLimit) {
             break;
         }
     }
     // SET repeat end date for empty data from import page
     if ($event->repeatend == '') {
         $event->repeatend = $enddate;
     }
     return $eventList;
 }
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:64,代码来源:events.php

示例8: editDiscussionWall

 public function editDiscussionWall($wallId)
 {
     CFactory::load('helpers', 'owner');
     CFactory::load('helpers', 'time');
     $wall =& JTable::getInstance('Wall', 'CTable');
     $wall->load($wallId);
     $discussion =& JTable::getInstance('Discussion', 'CTable');
     $discussion->load($wall->contentid);
     $my = CFactory::getUser();
     // @rule: We only allow editing of wall in 15 minutes
     $now = JFactory::getDate();
     $interval = CTimeHelper::timeIntervalDifference($wall->date, $now->toMySQL());
     $interval = abs($interval);
     if ($my->authorise('community.edit', 'groups.discussion.' . $discussion->groupid, $wall) && COMMUNITY_WALLS_EDIT_INTERVAL > $interval) {
         return true;
     }
     return false;
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:18,代码来源:groups.php

示例9: save

 /**
  * Method to save the group
  * @return false if create fail, return the group id if create is successful
  **/
 public function save(&$event)
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit(JText::_('CC INVALID TOKEN'));
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $viewName = JRequest::getCmd('view', $this->getName());
     $view = $this->getView($viewName, '', $viewType);
     if (JString::strtoupper(JRequest::getMethod()) != 'POST') {
         $view->addWarning(JText::_('CC PERMISSION DENIED'));
         return false;
     }
     // Get my current data.
     $my = CFactory::getUser();
     $validated = true;
     $model = $this->getModel('events');
     $eventId = JRequest::getInt('eventid', '0');
     $isNew = $eventId == '0' ? true : false;
     $postData = JRequest::get('post');
     //format startdate and eendate with time before we bind into event object
     if (isset($postData['starttime-ampm']) && $postData['starttime-ampm'] == 'PM' && $postData['starttime-hour'] != 12) {
         $postData['starttime-hour'] = $postData['starttime-hour'] + 12;
     }
     if (isset($postData['endtime-ampm']) && $postData['endtime-ampm'] == 'PM' && $postData['endtime-hour'] != 12) {
         $postData['endtime-hour'] = $postData['endtime-hour'] + 12;
     }
     $postData['startdate'] = $postData['startdate'] . ' ' . $postData['starttime-hour'] . ':' . $postData['starttime-min'] . ':00';
     $postData['enddate'] = $postData['enddate'] . ' ' . $postData['endtime-hour'] . ':' . $postData['endtime-min'] . ':00';
     unset($postData['startdatetime']);
     unset($postData['enddatetime']);
     unset($postData['starttime-hour']);
     unset($postData['starttime-min']);
     unset($postData['starttime-ampm']);
     unset($postData['endtime-hour']);
     unset($postData['endtime-min']);
     unset($postData['endtime-ampm']);
     $event->load($eventId);
     $event->bind($postData);
     $inputFilter = CFactory::getInputFilter(true);
     // Despite the bind, we would still need to capture RAW description
     $event->description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $event->description = $inputFilter->clean($event->description);
     // @rule: Test for emptyness
     if (empty($event->title)) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('CC EVENTS TITLE CANNOT BE EMPTY'), 'error');
     }
     if (empty($event->location)) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('CC EVENTS LOCATION CANNOT BE EMPTY'), 'error');
     }
     // @rule: Test if group exists
     if ($model->isEventExist($event->title, $event->location, $eventId)) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('CC EVENTS TAKEN'), 'error');
     }
     // @rule: Description cannot be empty
     if (empty($event->description)) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('CC EVENTS DESCRIPTION CANNOT BE EMPTY'), 'error');
     }
     // @rule: Start date cannot be empty
     if (empty($event->startdate)) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('CC STARTDATE CANNOT BE EMPTY'), 'error');
     }
     // @rule: End date cannot be empty
     if (empty($event->enddate)) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('CC ENDATE CANNOT BE EMPTY'), 'error');
     }
     // @rule: Number of ticket must at least be 0
     if (Jstring::strlen($event->ticket) <= 0) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('CC EVENTS TICKET CANNOT BE EMPTY'), 'error');
     }
     require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'time.php';
     if (CTimeHelper::timeIntervalDifference($event->startdate, $event->enddate) > 0) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('CC EVENT STARTDATE GREATER THAN ENDDATE'), 'error');
     }
     // @rule: Event must not end in the past
     $now = new JDate();
     $jConfig = JFactory::getConfig();
     $now->setOffset($jConfig->getValue('offset') + -COMMUNITY_DAY_HOURS);
     if (CTimeHelper::timeIntervalDifference($now->toMySQL(true), $event->enddate) > 0) {
         $validated = false;
         $mainframe->enqueueMessage(JText::_('CC EVENT ENDDATE GREATER THAN NOW'), 'error');
     }
     if ($validated) {
         // If event offset is disabled, we need to set it to 0.
         if ($event->offset == null) {
             $event->offset = 0;
         }
         // Set the default thumbnail and avatar for the event just in case
//.........这里部分代码省略.........
开发者ID:bizanto,项目名称:Hooked,代码行数:101,代码来源:events.php


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