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


PHP Date::toUnix方法代码示例

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


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

示例1: Render


//.........这里部分代码省略.........
         switch ($rec_data['type']) {
             case EV_RECUR_WEEKLY:
                 // sequential days
                 $weekdays = array();
                 if (is_array($rec_data['listdays'])) {
                     foreach ($rec_data['listdays'] as $daynum) {
                         $weekdays[] = $LANG_WEEK[$daynum];
                     }
                     $days_text = implode(', ', $weekdays);
                 } else {
                     $days_text = '';
                 }
                 $rec_string .= ' ' . sprintf($LANG_EVLIST['on_days'], $days_text);
                 break;
             case EV_RECUR_DOM:
                 $days = array();
                 foreach ($rec_data['interval'] as $key => $day) {
                     $days[] = $LANG_EVLIST['rec_intervals'][$day];
                 }
                 $days_text = implode(', ', $days) . ' ' . $LANG_WEEK[$rec_data['weekday']];
                 $rec_string .= ' ' . sprintf($LANG_EVLIST['on_the_days'], $days_text);
                 break;
         }
         if ($this->Event->rec_data['stop'] != '' && $this->Event->rec_data['stop'] < EV_MAX_DATE) {
             $rec_string .= ' ' . sprintf($LANG_EVLIST['recur_stop_desc'], EVLIST_formattedDate($this->Event->rec_data['stop']));
         }
     } else {
         $rec_string = '';
     }
     $T->set_var(array('pi_url' => EVLIST_URL, 'webcal_url' => preg_replace('/^https?/', 'webcal', EVLIST_URL), 'rp_id' => $this->rp_id, 'ev_id' => $this->ev_id, 'title' => $title, 'summary' => $summary, 'full_description' => $fulldescription, 'can_edit' => $this->isAdmin ? 'true' : '', 'start_time1' => $time_start1, 'end_time1' => $time_end1, 'start_time2' => $time_start2, 'end_time2' => $time_end2, 'start_date' => $date_start, 'end_date' => $date_end, 'start_datetime1' => $date_start . $time_start, 'end_datetime1' => $date_end . $time_end, 'allday_event' => $this->Event->allday == 1 ? 'true' : '', 'is_recurring' => $this->Event->recurring, 'can_subscribe' => $this->Event->Calendar->cal_ena_ical, 'recurring_event' => $rec_string, 'owner_id' => $this->Event->owner_id, 'cal_name' => $this->Event->Calendar->cal_name, 'cal_id' => $this->Event->cal_id, 'site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'more_info_link' => sprintf($LANG_EVLIST['click_here'], $url)));
     if ($_EV_CONF['enable_rsvp'] == 1 && $this->Event->options['use_rsvp'] > 0) {
         if ($this->Event->options['rsvp_cutoff'] > 0) {
             $dt = new Date($this->event->date_start1 . ' ' . $this->Event->time_start1, $_CONF['timezone']);
             if (time() > $dt->toUnix() - $this->Event->options['rsvp_cutoff'] * 86400) {
                 $past_cutoff = false;
             } else {
                 $past_cutoff = true;
             }
         }
         if (COM_isAnonUser()) {
             // Just show a must-log-in message
             $T->set_var('login_to_register', 'true');
         } elseif (!$past_cutoff) {
             $num_free_tickets = $this->isRegistered(0, true);
             $total_tickets = $this->isRegistered(0, false);
             if ($num_free_tickets > 0) {
                 // If the user is already registered for any free tickets,
                 // show the cancel link
                 $T->set_var(array('unregister_link' => 'true', 'num_free_reg' => $num_free_tickets));
             }
             // Show the registration link
             if (($this->Event->options['max_rsvp'] == 0 || $this->Event->options['rsvp_waitlist'] == 1 || $this->Event->options['max_rsvp'] > $this->TotalRegistrations()) && ($this->Event->options['max_user_rsvp'] == 0 || $total_tickets < $this->Event->options['max_user_rsvp'])) {
                 USES_evlist_class_tickettype();
                 $Ticks = evTicketType::GetTicketTypes();
                 if ($this->Event->options['max_user_rsvp'] > 0) {
                     $T->set_block('event', 'tickCntBlk', 'tcBlk');
                     $T->set_var('register_multi', true);
                     //$rsvp_user_count = '';
                     $avail_tickets = $this->Event->options['max_user_rsvp'] - $total_tickets;
                     for ($i = 1; $i <= $avail_tickets; $i++) {
                         $T->set_var('tick_cnt', $i);
                         $T->parse('tcBlk', 'tickCntBlk', true);
                         //$rsvp_user_count .= '<option value="'.$i.'">'.$i.
                         //        '</option>'.LB;
                     }
                     //$T->set_var('register_multi', $rsvp_user_count);
开发者ID:NewRoute,项目名称:evlist,代码行数:67,代码来源:evRepeat.class.php

示例2: getStatusDate

 /**
  * Get status date
  *
  * @param      object $row
  * @return     string HTML
  */
 public function getStatusDate($row = NULL)
 {
     if ($row === NULL) {
         $row = $this->version;
     }
     $status = $row && isset($row->state) ? $row->state : $this->get('state');
     switch ($status) {
         case 0:
             $date = strtolower(Lang::txt('COM_PUBLICATIONS_UNPUBLISHED')) . ' ' . Date::of($row->published_down)->toLocal(Lang::txt('DATE_FORMAT_HZ1'));
             break;
         case 1:
             $date = Date::of($row->published_up)->toUnix() > Date::toUnix() ? Lang::txt('to be') . ' ' : '';
             $date .= strtolower(Lang::txt('COM_PUBLICATIONS_RELEASED')) . ' ' . Date::of($row->published_up)->toLocal(Lang::txt('DATE_FORMAT_HZ1'));
             break;
         case 3:
         case 4:
         default:
             $date = strtolower(Lang::txt('COM_PUBLICATIONS_STARTED')) . ' ' . Date::of($row->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1'));
             break;
         case 5:
         case 7:
             $date = strtolower(Lang::txt('COM_PUBLICATIONS_SUBMITTED')) . ' ' . Date::of($row->submitted)->toLocal(Lang::txt('DATE_FORMAT_HZ1'));
             break;
     }
     return $date;
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:32,代码来源:publication.php

示例3: MG_saveMediaEdit

function MG_saveMediaEdit($album_id, $media_id, $actionURL)
{
    global $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $_POST, $_FILES;
    $back = COM_applyFilter($_POST['rpath']);
    if ($back != '') {
        $sLength = strlen($_CONF['site_url']);
        if (substr($back, 0, $sLength) != $_CONF['site_url']) {
            $back = $_CONF['site_url'];
        }
        $actionURL = $back;
    }
    $queue = COM_applyFilter($_POST['queue'], true);
    if (isset($_POST['replacefile'])) {
        $replacefile = COM_applyFilter($_POST['replacefile']);
    } else {
        $replacefile = 0;
    }
    if ($replacefile == 1) {
        require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-upload.php';
        $repfilename = $_FILES['repfilename'];
        $filename = $repfilename['name'];
        $file = $repfilename['tmp_name'];
        list($rc, $msg) = MG_getFile($file, $filename, $album_id, '', '', 1, 0, '', 0, '', '', 0, 0, $media_id);
        COM_errorLog($msg);
    }
    // see if we had an attached thumbnail before...
    $thumb = $_FILES['attthumb'];
    $thumbnail = $thumb['tmp_name'];
    $att = isset($_POST['attachtn']) ? COM_applyFilter($_POST['attachtn'], true) : 0;
    if ($att == 1) {
        $attachtn = 1;
    } else {
        $attachtn = 0;
    }
    if ($queue) {
        $old_attached_tn = DB_getItem($_TABLES['mg_mediaqueue'], 'media_tn_attached', 'media_id="' . DB_escapeString($media_id) . '"');
    } else {
        $old_attached_tn = DB_getItem($_TABLES['mg_media'], 'media_tn_attached', 'media_id="' . DB_escapeString($media_id) . '"');
    }
    if ($old_attached_tn == 0 && $att == 1 && $thumbnail == '') {
        $attachtn = 0;
    }
    if ($old_attached_tn == 1 && $attachtn == 0) {
        $remove_old_tn = 1;
    } else {
        $remove_old_tn = 0;
    }
    if ($queue) {
        $remote_media = DB_getItem($_TABLES['mg_mediaqueue'], 'remote_media', 'media_id="' . DB_escapeString($media_id) . '"');
    } else {
        $remote_media = DB_getItem($_TABLES['mg_media'], 'remote_media', 'media_id="' . DB_escapeString($media_id) . '"');
    }
    if ($remote_media) {
        $remote_url = isset($_POST['remoteurl']) ? DB_escapeString($_POST['remoteurl']) : '';
    } else {
        $remote_url = '';
    }
    if ($_MG_CONF['htmlallowed']) {
        $media_title = COM_checkWords($_POST['media_title']);
        $media_desc = COM_checkWords($_POST['media_desc']);
    } else {
        $media_title = htmlspecialchars(strip_tags(COM_checkWords($_POST['media_title'])));
        $media_desc = htmlspecialchars(strip_tags(COM_checkWords($_POST['media_desc'])));
    }
    $media_time_month = COM_applyFilter($_POST['media_month']);
    $media_time_day = COM_applyFilter($_POST['media_day']);
    $media_time_year = COM_applyFilter($_POST['media_year']);
    $media_time_hour = COM_applyFilter($_POST['media_hour']);
    $media_time_minute = COM_applyFilter($_POST['media_minute']);
    $original_filename = COM_applyFilter($_POST['original_filename']);
    if ($replacefile == 1) {
        $original_filename = $filename;
    }
    $cat_id = COM_applyFilter($_POST['cat_id'], true);
    $media_keywords = $_POST['media_keywords'];
    $media_keywords_safe = substr($media_keywords, 0, 254);
    $media_keywords = DB_escapeString(htmlspecialchars(strip_tags(COM_checkWords($media_keywords_safe))));
    $artist = isset($_POST['artist']) ? DB_escapeString(COM_applyFilter($_POST['artist'])) : '';
    $musicalbum = isset($_POST['musicalbum']) ? DB_escapeString(COM_applyFilter($_POST['musicalbum'])) : '';
    $genre = isset($_POST['genre']) ? DB_escapeString(COM_applyFilter($_POST['genre'])) : '';
    $dtObject = new Date('now', $_USER['tzid']);
    $dtObject->setDateTimestamp($media_time_year, $media_time_month, $media_time_day, $media_time_hour, $media_time_minute, 0);
    $media_time = $dtObject->toUnix();
    if (isset($_POST['owner_name'])) {
        $owner_id = COM_applyFilter($_POST['owner_name'], true);
        $owner_sql = ',media_user_id=' . $owner_id . ' ';
    } else {
        $owner_sql = '';
    }
    $sql = "UPDATE " . ($queue ? $_TABLES['mg_mediaqueue'] : $_TABLES['mg_media']) . "\n            SET media_title='" . DB_escapeString($media_title) . "',\n            media_desc='" . DB_escapeString($media_desc) . "',\n            media_original_filename='" . DB_escapeString($original_filename) . "',\n            media_time=" . $media_time . ",\n            media_tn_attached=" . $attachtn . ",\n            media_category=" . intval($cat_id) . ",\n            media_keywords='" . $media_keywords . "',\n            artist='" . $artist . "',\n            album='" . $musicalbum . "',\n            genre='" . $genre . "',\n            remote_url='" . $remote_url . "' " . $owner_sql . "WHERE media_id='" . DB_escapeString($media_id) . "'";
    DB_query($sql);
    if (DB_error() != 0) {
        echo COM_errorLog("Media Gallery: ERROR Updating image in media database");
    }
    PLG_itemSaved($media_id, 'mediagallery');
    $media_id_db = DB_escapeString($media_id);
    // process playback options if any...
    if (isset($_POST['autostart'])) {
        // asf
        $playback_option['autostart'] = intval(COM_applyFilter($_POST['autostart'], true));
//.........这里部分代码省略.........
开发者ID:NewRoute,项目名称:glfusion,代码行数:101,代码来源:mediamanage.php

示例4: EVLIST_weekview

/**
*   Create a weekly view.
*
*   @param  integer $year   Year to display, default is current year
*   @param  integer $month  Starting month
*   @param  integer $day    Starting day
*   @param  integer $cat    Event category
*   @param  integer $cal    Calendar to show
*   @return string          HTML for calendar page
*/
function EVLIST_weekview($year = 0, $month = 0, $day = 0, $cat = 0, $cal = 0, $opt = '')
{
    global $_CONF, $_EV_CONF, $LANG_MONTH, $LANG_EVLIST;
    USES_class_date();
    EVLIST_setViewSession('week', $year, $month, $day);
    $retval = '';
    list($currentyear, $currentmonth, $currentday) = explode('-', $_EV_CONF['_today']);
    // Default to the current month
    if ($year == 0) {
        $year = $currentyear;
    }
    if ($month == 0) {
        $month = $currentmonth;
    }
    if ($day == 0) {
        $day = $currentday;
    }
    $cat = (int) $cat;
    $cal = (int) $cal;
    // Get the events
    $calendarView = Date_Calc::getCalendarWeek($day, $month, $year, '%Y-%m-%d');
    $start_date = $calendarView[0];
    $end_date = $calendarView[6];
    $calendars_used = array();
    $dtStart = new Date(strtotime($start_date), $_CONF['timezone']);
    $dtToday = $dtStart;
    // used to update date strings each day
    $week_secs = 86400 * 7;
    $dtPrev = new Date($dtStart->toUnix() - $week_secs, $_CONF['timezone']);
    $dtNext = new Date($dtStart->toUnix() + $week_secs, $_CONF['timezone']);
    // Set up next and previous week links
    list($sYear, $sMonth, $sDay) = explode('-', $start_date);
    $tpl = 'weekview';
    $T = new Template(EVLIST_PI_PATH . '/templates/weekview');
    if ($opt == 'print') {
        $tpl .= '_print';
    } elseif ($_EV_CONF['cal_tmpl'] == 'json') {
        $tpl .= '_json';
    }
    $T->set_file(array('week' => $tpl . '.thtml'));
    $daynames = EVLIST_getDayNames();
    $events = EVLIST_getEvents($start_date, $end_date, array('cat' => $cat, 'cal' => $cal));
    $start_mname = $LANG_MONTH[(int) $sMonth];
    $last_date = getdate($dtStart->toUnix() + 86400 * 6);
    $end_mname = $LANG_MONTH[$last_date['mon']];
    $end_ynum = $last_date['year'];
    $end_dnum = sprintf('%02d', $last_date['mday']);
    $date_range = $start_mname . ' ' . $sDay;
    if ($year != $end_ynum) {
        $date_range .= ', ' . $year . ' - ';
    } else {
        $date_range .= ' - ';
    }
    if ($start_mname != $end_mname) {
        $date_range .= $end_mname . ' ';
    }
    $date_range .= "{$end_dnum}, {$end_ynum}";
    $T->set_var('date_range', $date_range);
    $T->set_block('week', 'dayBlock', 'dBlk');
    foreach ($calendarView as $idx => $weekData) {
        list($curyear, $curmonth, $curday) = explode('-', $weekData);
        $dtToday->setDateTimestamp($curyear, $curmonth, $curday, 0, 0, 0);
        $T->clear_var('eBlk');
        if ($weekData == $_EV_CONF['_today']) {
            $T->set_var('dayclass', 'weekview-curday');
        } else {
            $T->set_var('dayclass', 'weekview-offday');
        }
        $monthname = $LANG_MONTH[(int) $curmonth];
        $T->set_var('dayinfo', $daynames[$idx] . ', ' . COM_createLink($dtToday->format($_CONF['shortdate']), EVLIST_URL . "/index.php?view=day&amp;day={$curday}" . "&amp;cat={$cat}&amp;cal={$cal}" . "&amp;month={$curmonth}&amp;year={$curyear}"));
        if ($_EV_CONF['_can_add']) {
            $T->set_var(array('can_add' => 'true', 'curday' => $curday, 'curmonth' => $curmonth, 'curyear' => $curyear));
        }
        if (!isset($events[$weekData])) {
            // Make sure it's a valid but empty array if no events today
            $events[$weekData] = array();
        }
        $T->set_block('week', 'eventBlock', 'eBlk');
        foreach ($events[$weekData] as $A) {
            //$fgstyle = 'color:' . $A['fgcolor'].';';
            if ($A['allday'] == 1 || $A['rp_date_start'] < $weekData && $A['rp_date_end'] > $weekData) {
                $event_time = $LANG_EVLIST['allday'];
                /*$event_div = '<div class="monthview_allday" 
                  style="background-color:'. $event['bgcolor'].';">';*/
            } else {
                if ($A['rp_date_start'] == $weekData) {
                    $startstamp = strtotime($weekData . ' ' . $A['rp_time_start1']);
                    $starttime = date('g:i a', $startstamp);
                } else {
                    $starttime = ' ... ';
//.........这里部分代码省略.........
开发者ID:matrox66,项目名称:evlist,代码行数:101,代码来源:evlist_views.inc.php

示例5: register

 /**
  * Register View for Event
  *
  * @return     string
  */
 private function register()
 {
     //create the view
     $view = $this->view('register', 'calendar');
     //get request varse
     $eventId = Request::getVar('event_id', '');
     //load event data
     $view->event = new \Components\Events\Models\Event($eventId);
     //get registrants count
     $eventsRespondent = new \Components\Events\Tables\Respondent(array('id' => $eventId));
     $view->registrants = $eventsRespondent->getCount();
     //do we have a registration deadline
     if ($view->event->get('registerby') == '' || $view->event->get('registerby') == '0000-00-00 00:00:00') {
         App::redirect(Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=calendar&action=details&event_id=' . $view->event->get('id')), Lang::txt('This event does not have registration.'), 'warning');
         return;
     }
     //make sure registration is open
     $now = Date::toUnix();
     $registerby = Date::of($view->event->get('registerby'))->toUnix();
     if ($registerby >= $now) {
         //get the password
         $password = Request::getVar('passwrd', '', 'post');
         //is the event restricted
         if ($view->event->get('restricted') != '' && $view->event->get('restricted') != $password && !isset($this->register)) {
             //if we entered a password and it was bad lets tell the user
             if (isset($password) && $password != '') {
                 $this->setError('The password entered is incorrect.');
             }
             $view->setLayout('register_restricted');
         }
     } else {
         $view->setLayout('register_closed');
     }
     //push some vars to the view
     $view->month = $this->month;
     $view->year = $this->year;
     $view->group = $this->group;
     $view->option = $this->option;
     $view->authorized = $this->authorized;
     $view->user = $this->user;
     $view->register = isset($this->register) ? $this->register : null;
     $view->arrival = isset($this->arrival) ? $this->arrival : null;
     $view->departure = isset($this->departure) ? $this->departure : null;
     $view->dietary = isset($this->dietary) ? $this->dietary : null;
     $view->dinner = isset($this->dinner) ? $this->dinner : null;
     $view->disability = isset($this->disability) ? $this->disability : null;
     $view->race = isset($this->race) ? $this->race : null;
     //add params to view
     $view->params = new \Hubzero\Config\Registry($view->event->get('params'));
     if (!$this->user->get('guest')) {
         $profile = new \Hubzero\User\Profile();
         $profile->load($this->user->get('id'));
         $view->register['first_name'] = $profile->get('givenName');
         $view->register['last_name'] = $profile->get('surname');
         $view->register['affiliation'] = $profile->get('organization');
         $view->register['email'] = $profile->get('email');
         $view->register['telephone'] = $profile->get('phone');
         $view->register['website'] = $profile->get('url');
     }
     //get any errors if there are any
     foreach ($this->getErrors() as $error) {
         $view->setError($error);
     }
     //load the view
     return $view->loadTemplate();
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:71,代码来源:calendar.php

示例6: saveTask


//.........这里部分代码省略.........
                 $this->model->version->state = 1;
                 // Is service enabled? - Issue/update a DOI
                 if ($doiService->on()) {
                     if ($this->model->version->doi && preg_match("/" . $doiService->_configs->shoulder . "/", $this->model->version->doi)) {
                         // Update
                         $doiService->update($this->model->version->doi, true);
                         if ($doiService->getError()) {
                             $this->setError($doiService->getError());
                         }
                     } elseif ($requireDoi) {
                         // Register
                         $doi = $doiService->register(true);
                         if (!$doi) {
                             App::redirect($url, Lang::txt('COM_PUBLICATIONS_ERROR_DOI') . ' ' . $doiService->getError(), 'error');
                             return;
                         } else {
                             $this->model->version->doi = $doi;
                         }
                     }
                 }
                 // Save date accepted
                 if ($action == 'publish') {
                     $this->model->version->accepted = Date::toSql();
                     $this->model->version->published_up = $published_up ? Date::of($published_up, Config::get('offset'))->toSql() : Date::toSql();
                     // Get and save manifest and its version
                     $versionNumber = $this->model->_curationModel->checkCurationVersion();
                     $this->model->version->set('curation', json_encode($this->model->_curationModel->_manifest));
                     $this->model->version->set('curation_version_id', $versionNumber);
                     // Check if publication is within grace period (published status)
                     $gracePeriod = $this->config->get('graceperiod', 0);
                     $allowArchive = $gracePeriod ? false : true;
                     if ($allowArchive && $this->model->version->accepted && $this->model->version->accepted != '0000-00-00 00:00:00') {
                         $monthFrom = Date::of($this->model->version->accepted . '+1 month')->toSql();
                         if (strtotime($monthFrom) < Date::toUnix()) {
                             $allowArchive = true;
                         }
                     }
                     // Run mkAIP if no grace period set or passed
                     if (!$this->getError() && $this->model->version->doi && $allowArchive == true && (!$this->model->version->archived || $this->model->version->archived == '0000-00-00 00:00:00') && Helpers\Utilities::mkAip($this->model->version)) {
                         $this->model->version->archived = Date::toSql();
                     }
                 }
                 if (!$this->getError()) {
                     $output .= ' ' . Lang::txt('COM_PUBLICATIONS_ITEM') . ' ';
                     $output .= $action == 'publish' ? Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_PUBLISHED') : Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_REPUBLISHED');
                 }
                 break;
             case 'revert':
                 // What is this? This sets it to the state it's alreayd in.
                 //$this->model->version->state = $state ? $state : 4;
                 $this->model->version->state = 3;
                 $activity = Lang::txt('COM_PUBLICATIONS_ACTIVITY_ADMIN_REVERTED');
                 $subject .= Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_REVERTED');
                 $output .= ' ' . Lang::txt('COM_PUBLICATIONS_ITEM') . ' ';
                 $output .= Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_REVERTED');
                 break;
             case 'unpublish':
                 $this->model->version->state = 0;
                 $this->model->version->published_down = Date::toSql();
                 $activity = Lang::txt('COM_PUBLICATIONS_ACTIVITY_ADMIN_UNPUBLISHED');
                 $subject .= Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_UNPUBLISHED');
                 $output .= ' ' . Lang::txt('COM_PUBLICATIONS_ITEM') . ' ';
                 $output .= Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_UNPUBLISHED');
                 break;
             case 'wip':
                 $activity = Lang::txt('COM_PUBLICATIONS_ACTIVITY_ADMIN_REQUESTED_CHANGES');
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:67,代码来源:items.php

示例7:

$status = $this->pub->getStatusName();
$class = $this->pub->getStatusCss();
// Is draft ready?
$complete = $this->pub->curation('complete');
$showCitations = $this->pub->_category->_params->get('show_citations', 1);
$allowUnpublish = $this->pub->_category->_params->get('option_unpublish', 0);
// We also need a citations block
$blockActive = $this->pub->curation()->blockExists('citations');
$showCitations = $blockActive ? $showCitations : 0;
// Check if publication is within grace period (published status)
$allowArchive = \Components\Publications\Helpers\Utilities::archiveOn();
$archiveDate = $this->pub->futureArchivalDate();
$revertAllowed = $this->pub->config('graceperiod');
if ($revertAllowed && $this->pub->accepted()) {
    $monthFrom = Date::of($this->pub->accepted() . '+1 month')->toSql();
    if (strtotime($monthFrom) < Date::toUnix()) {
        $revertAllowed = 0;
    }
}
?>

<form action="<?php 
echo Route::url($this->pub->link('edit'));
?>
" method="post" id="plg-form" enctype="multipart/form-data">
	<?php 
echo \Components\Publications\Helpers\Html::showPubTitle($this->pub, $this->title);
?>

		<fieldset>
			<input type="hidden" name="id" value="<?php 
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:31,代码来源:default.php

示例8: MG_getUserDateTimeFormat

function MG_getUserDateTimeFormat($date = 'now')
{
    global $_TABLES, $_CONF, $_USER, $_MG_CONF, $_SYSTEM;
    if ($date == '99') {
        return '';
    }
    // Get display format for time
    $dfid = $_MG_CONF['dfid'];
    if ($dfid == '0') {
        $dateformat = $_CONF['date'];
    } else {
        $dateformat = $_MG_CONF['dateformat'][$dfid];
    }
    $dtObject = new Date($date, $_USER['tzid']);
    if (empty($date) || $date == 'now') {
        // Date is empty, get current date/time
        $stamp = time();
    } else {
        if (is_numeric($date)) {
            // This is a timestamp
            $stamp = $date;
        } else {
            // This is a string representation of a date/time
            $stamp = $dtObject->toUnix();
        }
    }
    $date = $dtObject->format($dateformat, true);
    return array($date, $stamp);
}
开发者ID:spacequad,项目名称:glfusion,代码行数:29,代码来源:init.php

示例9: isActive

 /**
  * Takes a user's session identifier and session expiry
  * timestamp and checks to see if they represent a currently
  * active session.  Note: This method does not verify that
  * $session_id is a valid session identifier, but rather
  * expects these values to have come from a database source
  * and hence be validated prior to this method being called.
  * If the $session_id value is empty however, it will return
  * false.  Compares $expires against the current time to
  * determine if the session has expired or not.
  * 
  * @access	public
  * @param	string	$session_id
  * @param	integer	$expires
  * @return	boolean
  * 
  */
 function isActive($session_id, $expires)
 {
     if (empty($session_id)) {
         return false;
     }
     global $loader;
     $loader->import('saf.Date');
     if (Date::compare($expires, Date::toUnix()) >= 0) {
         return false;
     }
     return true;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:29,代码来源:Workspace.php

示例10: SitewikiEditForm

$form = new SitewikiEditForm();
if ($form->editable && !isset($cgi->editing)) {
    if (!session_valid()) {
        global $session;
        $session->username = '';
    }
    if (lock_exists('sitewiki_page', $cgi->page)) {
        if ($cgi->break_lock == 1) {
            lock_remove('sitewiki_page', $cgi->page);
            if (!session_valid()) {
                $session->username = 'anonymous';
            }
            lock_add('sitewiki_page', $cgi->page);
        } else {
            $info = lock_info('sitewiki_page', $cgi->page);
            loader_import('saf.Date');
            $now = time();
            $then = Date::toUnix($info->expires) - 3600;
            $diff = $now - $then;
            $info->min = round($diff / 60);
            echo template_simple('locked.spt', $info);
            return;
        }
    } else {
        if (!session_valid()) {
            $session->username = 'anonymous';
        }
        lock_add('sitewiki_page', $cgi->page);
    }
}
echo $form->run();
开发者ID:vojtajina,项目名称:sitellite,代码行数:31,代码来源:index.php

示例11: subtract

 /**
  * Subtracts from the specified date and returns the finished
  * calculation. $date is in the format Y-m-d, and $amount can be either
  * '# year', '# month', '# week', or '# day', where # is any number.
  * 
  * @access	public
  * @param	string	$date
  * @param	string	$amount
  * @return	string
  * 
  */
 function subtract($date, $amount)
 {
     //$stamp = Date::format ($date, 'U');
     if (strpos($date, ' ') === false) {
         $date .= ' 05:05:05';
     }
     $stamp = Date::toUnix($date);
     $amounts = array('year' => 31536000, 'month' => 0, 'week' => 604800, 'day' => 86400);
     if (preg_match('/^([0-9]+) ?(' . join('|', array_keys($amounts)) . ')s?$/', $amount, $regs)) {
         if ($regs[2] == 'month') {
             $hour = date('H', $stamp);
             $minute = date('i', $stamp);
             $second = date('s', $stamp);
             $year = date('Y', $stamp);
             $month = date('m', $stamp);
             $day = date('d', $stamp);
             $month -= $regs[1];
             //$month--;
             $stamp = mktime($hour, $minute, $second, $month, $day, $year);
             return date('Y-m-d', $stamp);
         } elseif ($regs[2] == 'year') {
             $hour = date('H', $stamp);
             $minute = date('i', $stamp);
             $second = date('s', $stamp);
             $year = date('Y', $stamp);
             $month = date('m', $stamp);
             $day = date('d', $stamp);
             $year -= $regs[1];
             //$year--;
             $stamp = mktime($hour, $minute, $second, $month, $day, $year);
             return date('Y-m-d', $stamp);
         } else {
             return date('Y-m-d', $stamp - $regs[1] * $amounts[$regs[2]]);
         }
     } else {
         return false;
     }
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:49,代码来源:Date.php

示例12: FF_saveTopic

function FF_saveTopic($forumData, $postData, $action)
{
    global $_CONF, $_TABLES, $_FF_CONF, $_USER, $LANG03, $LANG_GF01, $LANG_GF02;
    $retval = '';
    $uploadErrors = '';
    $msg = '';
    $errorMessages = '';
    $email = '';
    $forumfiles = array();
    $okToSave = true;
    $dt = new Date('now', $_USER['tzid']);
    $date = $dt->toUnix();
    $REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
    if (COM_isAnonUser()) {
        $uid = 1;
    } else {
        $uid = $_USER['uid'];
    }
    // verify postmode is allowed
    if (strtolower($postData['postmode']) == 'html') {
        if ($_FF_CONF['allow_html'] || SEC_inGroup('Root') || SEC_hasRights('forum.html')) {
            $postData['postmode'] = 'html';
        } else {
            $postData['postmode'] = 'text';
        }
    }
    // is forum readonly?
    if ($forumData['is_readonly'] == 1) {
        // Check if this user has moderation rights now to allow a post to a locked topic
        if (!forum_modPermission($forumData['forum'], $uid, 'mod_edit')) {
            _ff_accessError();
        }
    }
    if ($action == 'saveedit') {
        // does the forum match the forum id of the posted data?
        if ($forumData['forum'] != 0 && $forumData['forum'] != $postData['forum']) {
            _ff_accessError();
        }
        $editid = COM_applyFilter($postData['editid'], true);
        $forum = COM_applyFilter($postData['forum'], true);
        $editAllowed = false;
        if (forum_modPermission($forumData['forum'], $_USER['uid'], 'mod_edit')) {
            $editAllowed = true;
        } else {
            if ($_FF_CONF['allowed_editwindow'] > 0) {
                $t1 = DB_getItem($_TABLES['ff_topic'], 'date', "id=" . (int) $postData['id']);
                $t2 = $_FF_CONF['allowed_editwindow'];
                $time = time();
                if (time() - $t2 < $t1) {
                    $editAllowed = true;
                }
            } else {
                $editAllowed = true;
            }
        }
        if ($postData['editpid'] < 1 && trim($postData['subject']) == '') {
            $retval .= FF_BlockMessage('', $LANG_GF02['msg18'], false);
            $okToSave = false;
        } elseif (!$editAllowed) {
            $link = $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . (int) $postData['$id'];
            $retval .= _ff_alertMessage('', $LANG_GF02['msg189'], sprintf($LANG_GF02['msg187'], $link));
            $okToSave = false;
        }
    } else {
        if (!COM_isAnonUser() && $_FF_CONF['use_sfs']) {
            $email = isset($_USER['email']) ? $_USER['email'] : '';
        }
    }
    if (isset($postData['name']) && $postData['name'] != '') {
        $name = _ff_preparefordb(@htmlspecialchars(strip_tags(trim(COM_checkWords(USER_sanitizeName($postData['name'])))), ENT_QUOTES, COM_getEncodingt()), 'text');
        $name = urldecode($name);
    } else {
        $okToSave = false;
        $errorMessages .= $LANG_GF02['invalid_name'] . '<br />';
    }
    // speed limit check
    if (!SEC_hasRights('forum.edit')) {
        COM_clearSpeedlimit($_FF_CONF['post_speedlimit'], 'forum');
        $last = COM_checkSpeedlimit('forum');
        if ($last > 0) {
            $errorMessages .= sprintf($LANG_GF01['SPEEDLIMIT'], $last, $_FF_CONF['post_speedlimit']) . '<br/>';
            $okToSave = false;
        }
    }
    // standard edit checks
    if (strlen(trim($postData['name'])) < $_FF_CONF['min_username_length'] || strlen(trim($postData['subject'])) < $_FF_CONF['min_subject_length'] || strlen(trim($postData['comment'])) < $_FF_CONF['min_comment_length']) {
        $errorMessages .= $LANG_GF02['msg18'] . '<br/>';
        $okToSave = false;
    }
    // CAPTCHA check
    if (function_exists('plugin_itemPreSave_captcha') && $okToSave == true) {
        if (!isset($postData['captcha'])) {
            $postData['captcha'] = '';
        }
        $msg = plugin_itemPreSave_captcha('forum', $postData['captcha']);
        if ($msg != '') {
            $errorMessages .= $msg . '<br/>';
            $okToSave = false;
        }
    }
//.........这里部分代码省略.........
开发者ID:NewRoute,项目名称:glfusion,代码行数:101,代码来源:createtopic.php

示例13: foreach

 /**
  * Loads the basic details of an article into the internal
  * variables, cleaning them up nicely.
  * @access Private
  * @param $array Array of POST/GET data (by ref).
  * @return Nothing.
  */
 function _loadBasics(&$array)
 {
     global $_CONF, $_USER;
     /* For the really, really basic stuff, we can very easily load them
      * based on an array that defines how to COM_applyFilter them.
      */
     foreach ($this->_postFields as $key => $value) {
         $vartype = $value[0];
         $varname = $value[1];
         // If we have a value
         if (array_key_exists($key, $array)) {
             // And it's alphanumeric or numeric, filter it and use it.
             if ($vartype == STORY_AL_ALPHANUM || $vartype == STORY_AL_NUMERIC) {
                 $this->{$varname} = COM_applyFilter($array[$key], $vartype);
             } elseif ($array[$key] === 'on' || $array[$key] === 1) {
                 // If it's a checkbox that is on
                 $this->{$varname} = 1;
             } else {
                 // Otherwise, it must be a checkbox that is off:
                 $this->{$varname} = 0;
             }
         } elseif ($vartype == STORY_AL_NUMERIC || $vartype == STORY_AL_CHECKBOX) {
             // If we don't have a value, and have a numeric or text box, default to 0
             $this->{$varname} = 0;
         }
     }
     // SID's are a special case:
     $sid = COM_sanitizeID($array['sid']);
     if (isset($array['old_sid'])) {
         $oldsid = COM_sanitizeID($array['old_sid'], false);
     } else {
         $oldsid = '';
     }
     if (empty($sid)) {
         $sid = $oldsid;
     }
     if (empty($sid)) {
         $sid = COM_makeSid();
     }
     $this->_sid = $sid;
     $this->_originalSid = $oldsid;
     /* Need to deal with the postdate and expiry date stuff */
     $publish_ampm = '';
     if (isset($array['publish_ampm'])) {
         $publish_ampm = COM_applyFilter($array['publish_ampm']);
     }
     $publish_hour = 0;
     if (isset($array['publish_hour'])) {
         $publish_hour = COM_applyFilter($array['publish_hour'], true);
     }
     $publish_minute = 0;
     if (isset($array['publish_minute'])) {
         $publish_minute = COM_applyFilter($array['publish_minute'], true);
     }
     $publish_second = 0;
     if (isset($array['publish_second'])) {
         $publish_second = COM_applyFilter($array['publish_second'], true);
     }
     if ($publish_ampm == 'pm') {
         if ($publish_hour < 12) {
             $publish_hour = $publish_hour + 12;
         }
     }
     if ($publish_ampm == 'am' and $publish_hour == 12) {
         $publish_hour = '00';
     }
     $publish_year = 0;
     if (isset($array['publish_year'])) {
         $publish_year = COM_applyFilter($array['publish_year'], true);
     }
     $publish_month = 0;
     if (isset($array['publish_month'])) {
         $publish_month = COM_applyFilter($array['publish_month'], true);
     }
     $publish_day = 0;
     if (isset($array['publish_day'])) {
         $publish_day = COM_applyFilter($array['publish_day'], true);
     }
     $dtPublish = new Date('now', $_USER['tzid']);
     $dtPublish->setDateTimestamp($publish_year, $publish_month, $publish_day, $publish_hour, $publish_minute, $publish_second);
     $this->_date = $dtPublish->toUnix();
     $archiveflag = 0;
     if (isset($array['archiveflag'])) {
         $archiveflag = COM_applyFilter($array['archiveflag'], true);
     }
     /* Override status code if no archive flag is set: */
     if ($archiveflag != 1) {
         $this->_statuscode = 0;
     }
     $dtExpire = new Date('now', $_USER['tzid']);
     if (array_key_exists('expire_ampm', $array)) {
         $expire_ampm = COM_applyFilter($array['expire_ampm']);
         $expire_hour = COM_applyFilter($array['expire_hour'], true);
//.........这里部分代码省略.........
开发者ID:NewRoute,项目名称:glfusion,代码行数:101,代码来源:story.class.php

示例14: COM_getUserDateTimeFormat

/**
* Returns formatted date/time for user
*
* This function COM_takes a date in either unixtimestamp or in english and
* formats it to the users preference.  If the user didn't specify a format
* the format in the config file is used.  This returns an array where array[0]
* is the formatted date and array[1] is the unixtimestamp
*
* @param        string      $date       date to format, otherwise we format current date/time
* @return   array   array[0] is the formatted date and array[1] is the unixtimestamp.
*/
function COM_getUserDateTimeFormat($date = 'now')
{
    global $_TABLES, $_USER, $_CONF, $_SYSTEM;
    $dtObject = new Date($date, $_USER['tzid']);
    // Get display format for time
    if (!COM_isAnonUser()) {
        if (empty($_USER['format'])) {
            $dateformat = $_CONF['date'];
        } else {
            $dateformat = $_USER['format'];
        }
    } else {
        $dateformat = $_CONF['date'];
    }
    if (empty($date) || $date == 'now') {
        // Date is empty, get current date/time
        $stamp = time();
    } else {
        if (is_numeric($date)) {
            // This is a timestamp
            $stamp = $date;
        } else {
            // This is a string representation of a date/time
            $stamp = $dtObject->toUnix();
        }
    }
    $date = $dtObject->format($dateformat, true);
    return array($date, $stamp);
}
开发者ID:NewRoute,项目名称:glfusion,代码行数:40,代码来源:lib-common.php

示例15: onSendMessage

 /**
  * Send a message to one or more users
  *
  * @param      string  $type        Message type (maps to #__xmessage_component table)
  * @param      string  $subject     Message subject
  * @param      string  $message     Message to send
  * @param      array   $from        Message 'from' data (e.g., name, address)
  * @param      array   $to          List of user IDs
  * @param      string  $component   Component name
  * @param      integer $element     ID of object that needs an action item
  * @param      string  $description Action item description
  * @param      integer $group_id    Parameter description (if any) ...
  * @return     mixed   True if no errors else error message
  */
 public function onSendMessage($type, $subject, $message, $from = array(), $to = array(), $component = '', $element = null, $description = '', $group_id = 0, $bypassGroupsCheck = false)
 {
     // Do we have a message?
     if (!$message) {
         return false;
     }
     $database = App::get('db');
     // Create the message object
     $xmessage = Hubzero\Message\Message::blank();
     if ($type == 'member_message') {
         $time_limit = intval($this->params->get('time_limit', 30));
         $daily_limit = intval($this->params->get('daily_limit', 100));
         // First, let's see if they've surpassed their daily limit for sending messages
         $filters = array('created_by' => User::get('id'), 'daily_limit' => $daily_limit);
         $number_sent = $xmessage->getSentMessagesCount($filters);
         if ($number_sent >= $daily_limit) {
             return false;
         }
         // Next, we see if they've passed the time limit for sending consecutive messages
         $filters['limit'] = 1;
         $filters['start'] = 0;
         $sent = $xmessage->getSentMessages($filters);
         if ($sent->count() > 0) {
             $last_sent = $sent->first();
             $last_time = 0;
             if ($last_sent->created) {
                 $last_time = Date::of($last_sent->created)->toUnix();
             }
             $time_difference = Date::toUnix() + $time_limit - $last_time;
             if ($time_difference < $time_limit) {
                 return false;
             }
         }
     }
     // Store the message in the database
     $xmessage->set('message', is_array($message) && isset($message['plaintext']) ? $message['plaintext'] : $message);
     // Do we have a subject line? If not, create it from the message
     if (!$subject && $xmessage->get('message')) {
         $subject = substr($xmessage->get('message'), 0, 70);
         if (strlen($subject) >= 70) {
             $subject .= '...';
         }
     }
     $xmessage->set('subject', $subject);
     $xmessage->set('created', Date::toSql());
     $xmessage->set('created_by', User::get('id'));
     $xmessage->set('component', $component);
     $xmessage->set('type', $type);
     $xmessage->set('group_id', $group_id);
     if (!$xmessage->save()) {
         return $xmessage->getError();
     }
     if (is_array($message)) {
         $xmessage->set('message', $message);
     }
     // Do we have any recipients?
     if (count($to) > 0) {
         $mconfig = Component::params('com_members');
         // Get all the sender's groups
         if ($mconfig->get('user_messaging', 1) == 1 && !$bypassGroupsCheck) {
             $xgroups = User::groups('all');
             $usersgroups = array();
             if (!empty($xgroups)) {
                 foreach ($xgroups as $group) {
                     if ($group->regconfirmed) {
                         $usersgroups[] = $group->cn;
                     }
                 }
             }
         }
         // Loop through each recipient
         foreach ($to as $uid) {
             // Create a recipient object that ties a user to a message
             $recipient = Hubzero\Message\Recipient::blank();
             $recipient->set('uid', $uid);
             $recipient->set('mid', $xmessage->get('id'));
             $recipient->set('created', Date::toSql());
             $recipient->set('expires', Date::of(time() + 168 * 24 * 60 * 60)->toSql());
             $recipient->set('actionid', 0);
             //(is_object($action)) ? $action->id : 0; [zooley] Phasing out action items
             // Get the user's methods for being notified
             $notify = Hubzero\Message\Notify::blank();
             $methods = $notify->getRecords($uid, $type);
             $user = User::getInstance($uid);
             if (!is_object($user) || !$user->get('username')) {
                 continue;
//.........这里部分代码省略.........
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:101,代码来源:handler.php


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