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


PHP DateTimeValue::now方法代码示例

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


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

示例1: save

 /**
  * Save into database
  * 
  * @return boolean
  */
 function save()
 {
     if ($this->isNew()) {
         $this->setTicketId(Tickets::findNextTicketIdByProject($this->getProjectId()));
     }
     // if
     $changes = null;
     if ($this->isLoaded()) {
         $log_fields = array('project_id', 'milestone_id', 'parent_id', 'name', 'body', 'priority', 'due_on', 'completed_on');
         $changes = new TicketChange();
         $changes->setTicketId($this->getId());
         $changes->setVersion($this->getVersion());
         $changes->setCreatedOn(DateTimeValue::now());
         $changes->setCreatedBy(get_logged_user());
         if ($this->new_assignees !== false) {
             list($old_assignees, $old_owner_id) = $this->getAssignmentData();
             if (is_array($this->new_assignees) && isset($this->new_assignees[0]) && isset($this->new_assignees[1])) {
                 $new_assignees = $this->new_assignees[0];
                 $new_owner_id = $this->new_assignees[1];
             } else {
                 $new_assignees = array();
                 $new_owner_id = 0;
             }
             // if
             if ($new_owner_id != $old_owner_id) {
                 $changes->addChange('owner', $old_owner_id, $new_owner_id);
             }
             // if
             sort($new_assignees);
             sort($old_assignees);
             if ($new_assignees != $old_assignees) {
                 $changes->addChange('assignees', $old_assignees, $new_assignees);
             }
             // if
         }
         // if
         foreach ($this->modified_fields as $field) {
             if (!in_array($field, $log_fields)) {
                 continue;
             }
             // if
             $old_value = array_var($this->old_values, $field);
             $new_value = array_var($this->values, $field);
             if ($old_value != $new_value) {
                 $changes->addChange($field, $old_value, $new_value);
             }
             // if
         }
         // foreach
     }
     // if
     $save = parent::save();
     if ($save && !is_error($save)) {
         if (instance_of($changes, 'TicketChange') && count($changes->changes)) {
             $this->changes = false;
             $changes->save();
         }
         // if
     }
     // if
     return $save;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:67,代码来源:Ticket.class.php

示例2: add

 /**
  * Show and process add page form
  *
  * @param void
  * @return null
  */
 function add()
 {
     $this->wireframe->print_button = false;
     if (!Page::canAdd($this->logged_user, $this->active_project)) {
         $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
     }
     // if
     $parent_id = (int) $this->request->get('parent_id');
     $page_data = $this->request->post('page');
     if (!is_array($page_data)) {
         $page_data = array('parent_id' => $this->request->get('parent_id'), 'milestone_id' => $this->request->get('milestone_id'), 'visibility' => $this->active_project->getDefaultVisibility());
     }
     // if
     $this->smarty->assign('page_data', $page_data);
     if ($this->request->isSubmitted()) {
         db_begin_work();
         $this->active_page = new Page();
         attach_from_files($this->active_page, $this->logged_user);
         $this->active_page->setAttributes($page_data);
         $this->active_page->setProjectId($this->active_project->getId());
         if (trim($this->active_page->getCreatedByName()) == '' || trim($this->active_page->getCreatedByEmail()) == '') {
             $this->active_page->setCreatedBy($this->logged_user);
         }
         // if
         $this->active_page->setUpdatedOn(DateTimeValue::now());
         $this->active_page->setUpdatedBy($this->logged_user);
         $this->active_page->setState(STATE_VISIBLE);
         $save = $this->active_page->save();
         if ($save && !is_error($save)) {
             $subscribers = array($this->logged_user->getId());
             if (is_foreachable($this->request->post('notify_users'))) {
                 $subscribers = array_merge($subscribers, $this->request->post('notify_users'));
             } else {
                 $subscribers[] = $this->active_project->getLeaderId();
             }
             // if
             if (!in_array($this->active_project->getLeaderId(), $subscribers)) {
                 $subscribers[] = $this->active_project->getLeaderId();
             }
             // if
             Subscriptions::subscribeUsers($subscribers, $this->active_page);
             db_commit();
             $this->active_page->ready();
             //BOF: mod
             $this->active_page->register_departments(!empty($page_data['departments']) ? $page_data['departments'] : array());
             //EOF: mod
             //BOF:mod 20110614
             $assignees_flag_data = $this->request->post('assignee');
             $this->active_page->register_assignees_flag($assignees_flag_data, true);
             //EOF:20110614
             if ($this->request->isApiCall()) {
                 $this->serveData($this->active_page, 'page');
             } else {
                 flash_success('Page ":name" has been created', array('name' => $this->active_page->getName()));
                 $this->redirectToUrl($this->active_page->getViewUrl());
             }
             // if
         } else {
             db_rollback();
             if ($this->request->isApiCall()) {
                 $this->serveData($save);
             } else {
                 $this->smarty->assign('errors', $save);
             }
             // if
         }
         // if
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:76,代码来源:PagesController.class.php

示例3: getEstimateFromChilds

 /**
  * Prende le stime dei figli, le somma e ne genera una singola
  */
 function getEstimateFromChilds()
 {
     // Prendo tutti i figli della milestone corrente
     $tasks = Tasks::findByMilestone($this->object, STATE_VISIBLE);
     // Scorro tutti i figli e ne salvo le stime
     $estimates = array();
     $estimates_sum = 0;
     if (is_foreachable($tasks)) {
         foreach ($tasks as $task) {
             $estimate = Estimates::findLatestByParent($task);
             // Se non è stata impostata la stima ritorna nullo, quindi bisogna controllare che effettivamente l'oggetto esista
             if ($estimate && $estimate instanceof Estimate) {
                 $estimates[] = $estimate;
                 $estimates_sum += $estimate->getValue();
             }
         }
     }
     // FIXME: seconda parte dell'if inutile
     if ($this->object instanceof Milestone || $this->object instanceof RemediaMilestone) {
         $estimate = new Estimate();
         $estimate->setParent($this->object);
         $estimate->setValue($estimates_sum);
         $estimate->setJobType(JobTypes::findById(1));
         // TODO: ho preso un job a caso, chissene
         $estimate->setComment('Stima generata automaticamente');
         $estimate->setCreatedBy($this->object->assignees()->getAssignee());
         // Assegno come creatore un tizio tra gli assegnatari
         $estimate->setCreatedOn(DateTimeValue::now());
     }
     return $estimate;
 }
开发者ID:NaszvadiG,项目名称:ACModules,代码行数:34,代码来源:IMilestoneTrackingImplementation.class.php

示例4: isUpcoming

 /**
  * Returns true if this object is due in future
  *
  * @param void
  * @return boolean
  */
 function isUpcoming()
 {
     $now = DateTimeValue::now();
     $due_on = $this->getDueOn();
     if (instance_of($due_on, 'DateTimeValue')) {
         return $due_on->getTimestamp() > $now->getTimestamp() && !$this->isToday();
     }
     // if
     return false;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:16,代码来源:ProjectObject.class.php

示例5: mark_all_read

 /**
  * Mark all items as read (update users last visit timestamp)
  *
  * @param void
  * @return null
  */
 function mark_all_read()
 {
     if ($this->request->isSubmitted()) {
         $this->logged_user->setLastVisitOn(DateTimeValue::now());
         $save = $this->logged_user->save();
         if ($save && !is_error($save)) {
             if ($this->request->isAsyncCall()) {
                 $this->httpOk();
             } else {
                 flash_success('All new items are marked as read');
             }
             // if
         } else {
             $message = lang('Failed to mark new items as read');
             if ($this->request->isAsyncCall()) {
                 $this->httpError(HTTP_ERR_OPERATION_FAILED, $message);
                 die;
             } else {
                 flash_success($message);
             }
             // if
         }
         // if
         $this->redirectToReferer(assemble_url('dashboard'));
     } else {
         $this->httpError(HTTP_BAD_REQUEST);
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:35,代码来源:DashboardController.class.php


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