Exemplo n.º 1
0
 public function create_user($userdata)
 {
     $password = \Arr::get($userdata, 'password', null);
     $email = \Arr::get($userdata, 'email', null);
     if (is_null($password) || is_null($email)) {
         Logger::instance()->log_log_in_attempt(Model_Log_In_Attempt::$ATTEMPT_BAD_CRIDENTIALS, $email);
         throw new LogInFailed(\Lang::get('ethanol.errors.loginInvalid'));
     }
     $user = Auth_Driver::get_core_user($email);
     $security = new Model_User_Security();
     //Generate a salt
     $security->salt = Hasher::instance()->hash(\Date::time(), Random::instance()->random());
     $security->password = Hasher::instance()->hash($password, $security->salt);
     if (\Config::get('ethanol.activate_emails', false)) {
         $keyLength = \Config::get('ethanol.activation_key_length');
         $security->activation_hash = Random::instance()->random($keyLength);
         $user->activated = 0;
         //Send email
         \Package::load('email');
         //Build an array of data that can be passed to the email template
         $emailData = array('email' => $user->email, 'activation_path' => \Str::tr(\Config::get('ethanol.activation_path'), array('key' => $security->activation_hash)));
         $email = \Email::forge()->from(\Config::get('ethanol.activation_email_from'))->to($user->email, $user->username)->subject(\Config::get('ethanol.activation_email_subject'))->html_body(\View::forge('ethanol/activation_email', $emailData))->send();
     } else {
         $user->activated = 1;
         $security->activation_hash = '';
     }
     $user->security = $security;
     $user->save();
     $user->clean_security();
     return $user;
 }
 private function main(\Orm\Model $obj)
 {
     if (!($datetime = $this->get_datetime_from_relational_model($obj))) {
         $datetime = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
     }
     $obj->{$this->_property} = $datetime;
 }
Exemplo n.º 3
0
 public static function get4slug($slug, $is_published = true)
 {
     $query = self::query()->where('slug', $slug);
     if ($is_published) {
         $query->where('is_published', 1);
         $query->where('published_at', '<', \Date::time()->format('mysql'));
     }
     return $query->get_one();
 }
Exemplo n.º 4
0
 public function before_update(\Orm\Model $obj)
 {
     if (\Util_Orm::check_is_updated($obj, $this->_check_properties, $this->_ignore_properties)) {
         if (!empty($obj->{$this->_property_from})) {
             $obj->{$this->_property} = $obj->{$this->_property_from};
         } else {
             $obj->{$this->_property} = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
         }
     }
 }
Exemplo n.º 5
0
 public function before_save(\Orm\Model $obj)
 {
     if ($this->_overwrite or empty($obj->{$this->_property})) {
         if ($obj->is_new()) {
             $obj->{$this->_property} = $obj->{$this->_property_from};
         } else {
             $obj->{$this->_property} = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
         }
     }
 }
Exemplo n.º 6
0
 function gc($max_life_time)
 {
     if ($max_life_time == 0) {
         return TRUE;
     }
     $exp_time = Date::time() - $max_life_time;
     $db = Database::factory($this->db_name);
     $ret = $db->query('DELETE FROM `_session` WHERE mtime < %d', $exp_time);
     return !is_null($ret);
 }
Exemplo n.º 7
0
 public static function check_is_passed($past_time, $intarval_time, $base_time = '', $is_time_format = true)
 {
     if (!$is_time_format) {
         $past_time = strtotime($past_time);
         if ($base_time) {
             $base_time = strtotime($base_time);
         }
     }
     if (!$base_time) {
         $base_time = Date::time()->get_timestamp();
     }
     return $base_time > $past_time + $intarval_time;
 }
Exemplo n.º 8
0
 /**
  * Set the UpdatedAt property to the current time.
  *
  * @param  Model  Model object subject of this observer method
  */
 public function before_update(Model $obj)
 {
     // If there are any relations loop through and check if any of them have been changed
     $relation_changed = false;
     foreach ($this->_relations as $relation) {
         if ($this->relation_changed($obj, $relation)) {
             $relation_changed = true;
             break;
         }
     }
     if ($obj->is_changed() or $relation_changed) {
         $obj->{$this->_property} = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
     }
 }
 private function main(\Orm\Model $obj)
 {
     if (!\Util_Orm::check_is_updated($obj, $this->_check_properties, $this->_ignore_properties)) {
         return;
     }
     if (!($datetime = $this->get_datetime_from_relational_model($obj))) {
         if (!$obj->is_new() || !empty($obj->{$this->_property})) {
             return;
         }
         if (!empty($obj->{$this->_property_created_at})) {
             $datetime = $obj->{$this->_property_created_at};
         } else {
             $datetime = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
         }
     }
     $obj->{$this->_property} = $datetime;
 }
Exemplo n.º 10
0
 public function action_index()
 {
     $query = Model_WeatherList::query()->where('date', Date::time()->format("%Y-%m-%d"))->where('type', 'max_cold');
     $coldList = $query->get_one();
     if ($coldList != null) {
         $coldData = $coldList->weatherData;
     } else {
         $coldData = [];
     }
     $query = Model_WeatherList::query()->where('date', Date::time()->format("%Y-%m-%d"))->where('type', 'max_rain');
     $rainList = $query->get_one();
     if ($rainList != null) {
         $rainData = $coldList->weatherData;
     } else {
         $rainData = [];
     }
     $data = ['coldData' => $coldData, 'rainData' => $rainData];
     $this->template->title = '';
     $this->template->body = View::forge('measurements/index', $data);
 }
Exemplo n.º 11
0
Arquivo: date.php Projeto: pihizi/qf
 static function fuzzy($time, $detail = FALSE, $now = 0)
 {
     if (!$time) {
         return T('早些时候');
     }
     if (!$now) {
         $now = Date::time();
     }
     $diff = $now - $time;
     $nd = getdate($now);
     $td = getdate($time);
     if ($detail) {
         $time_format = Date::default_format('time');
         if ($diff > 0 && $diff < 86400 && $nd['yday'] == $td['yday']) {
             $rest = $diff % 3600;
             $hours = ($diff - $rest) / 3600;
             $seconds = $rest % 60;
             $minutes = ($rest - $seconds) / 60;
             if ($hours > 1) {
                 return Date::format($time, $time_format);
             } elseif ($hours == 1) {
                 return T('一个多小时前');
             }
             return T('几分钟前');
         } elseif (date('Y', $now) == date('Y', $time)) {
             return Date::format($time, 'm/d ' . $time_format);
         } else {
             return Date::format($time, 'Y/m/d ' . $time_format);
         }
     }
     if ($nd['year'] == $td['year']) {
         if ($nd['yday'] == $td['yday']) {
             return T('今天');
         } elseif ($nd['yday'] - 1 == $td['yday']) {
             return T('昨天');
         }
         return Date::format($time, 'm/d');
     }
     return Date::format($time, 'Y/m/d');
 }
Exemplo n.º 12
0
 public function before_insert(Model $obj)
 {
     $obj->{static::$property} = static::$mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
 }
Exemplo n.º 13
0
 /**
  * generic driver initialisation
  *
  * @access	public
  * @return	void
  */
 public function init()
 {
     // get a time object
     $this->time = \Date::time();
 }
Exemplo n.º 14
0
 public function before_save(Model $obj)
 {
     if ($obj->is_new() or $obj->is_changed()) {
         $obj->{static::$property} = static::$mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
     }
 }
Exemplo n.º 15
0
 /**
  * Set account lock information.
  *
  * @return  bool
  */
 private function countup_account_lock_count($email)
 {
     if (!\Config::get('uzuraauth.accountLock.isEnabled')) {
         return;
     }
     $login_failed_info = \Session::get('login_failed', array());
     $login_failed_count_current = isset($login_failed_info[$email]['count']) ? $login_failed_info[$email]['count'] : 0;
     $login_failed_count_current++;
     \Session::set('login_failed', array($email => array('count' => $login_failed_count_current, 'last_execute_time' => \Date::time()->get_timestamp())));
     if ($login_failed_count_current >= \Config::get('uzuraauth.accountLock.loginFailAcceptCount')) {
         if (\Config::get('uzuraauth.accountLock.isLogging')) {
             \Util_Toolkit::log_error('account_lock: ' . $email);
         }
         $this->sent_noticication_mail($email);
     }
     return $login_failed_count_current;
 }
Exemplo n.º 16
0
 /**
  * Fills the calendar based on an optional SQL query, some
  * related database information, and templates for the cells
  * and items.  Also initializes the $topBlock and $bottomBlock
  * cells if $showPeriod is 'month' (these refer to the empty space
  * at the top and bottom of the monthly calendar), and sets aliases
  * to each cell which can be referenced as $calendar_object->_1st,
  * $calendar_object->_2nd, $calendar_object->_3rd, etc., or
  * $calendar_object->_1200am, $calendar_object->_1230am,
  * $calendar_object->_100am, etc. if the $showPeriod is 'day'.
  * 
  * @access	public
  * @param	string	$sql
  * @param	string	$dateColumn
  * @param	string	$itemTemplate
  * @param	string	$cellTemplate
  * @param	string	$timeColumn
  * @return	boolean
  * 
  */
 function fillCalendar($sql = '', $dateColumn = 'date', $itemTemplate = '', $cellTemplate = '{day}<br />', $timeColumn = 'time')
 {
     if (empty($cellTemplate)) {
         $cellTemplate = $this->cellTemplate;
     }
     global $db, $simple, $loader;
     $loader->inc('saf.Date');
     if ($this->showPeriod == 'day') {
         $hours = array(0 => array('12:00AM', '12:30'), 1 => array('1:00', '1:30'), 2 => array('2:00', '2:30'), 3 => array('3:00', '3:30'), 4 => array('4:00', '4:30'), 5 => array('5:00', '5:30'), 6 => array('6:00', '6:30'), 7 => array('7:00', '7:30'), 8 => array('8:00', '8:30'), 9 => array('9:00', '9:30'), 10 => array('10:00', '10:30'), 11 => array('11:00', '11:30'), 12 => array('12:00PM', '12:30'), 13 => array('1:00', '1:30'), 14 => array('2:00', '2:30'), 15 => array('3:00', '3:30'), 16 => array('4:00', '4:30'), 17 => array('5:00', '5:30'), 18 => array('6:00', '6:30'), 19 => array('7:00', '7:30'), 20 => array('8:00', '8:30'), 21 => array('9:00', '9:30'), 22 => array('10:00', '10:30'), 23 => array('11:00', '11:30'));
         $timeLayout =& $this->sub('a2', 2, ($this->showToHour - ($this->showFromHour - 1)) * 2);
         $num = 1;
         if ($cellTemplate == '{day}<br />') {
             $cellTemplate = '{hour}';
         }
         for ($hr = $this->showFromHour; $hr <= $this->showToHour; $hr++) {
             $obj = new StdClass();
             $obj->date = $this->currentDay;
             $obj->stamp = Date::format($this->currentDay, 'U');
             $obj->day = date('j', $obj->stamp);
             $obj->time = $this->makeTime($hr, $hours[$hr][0]);
             $obj->hour = $hours[$hr][0];
             $timeLayout->assign('a' . $num, $simple->fill($cellTemplate, $obj));
             //$timeLayout->assign ('a' . $num, $hours[$hr][0]);
             $timeLayout->set('a' . $num, 'width', '10%');
             $timeLayout->set('a' . $num, 'valign', 'top');
             $timeLayout->set('b' . $num, 'width', '90%');
             if ($hr == 0) {
                 $short = '_1200am';
             } elseif ($hr < 12) {
                 $short = '_' . $hr . '00am';
             } elseif ($hr == 12) {
                 $short = '_' . $hr . '00pm';
             } else {
                 $short = '_' . ($hr - 12) . '00pm';
             }
             $this->{$short} =& $timeLayout->{'b' . $num};
             $num++;
             $obj = new StdClass();
             $obj->date = $this->currentDay;
             $obj->stamp = Date::format($this->currentDay, 'U');
             $obj->day = date('j', $obj->stamp);
             $obj->time = $this->makeTime($hr, $hours[$hr][1]);
             $obj->hour = $hours[$hr][1];
             $timeLayout->assign('a' . $num, $simple->fill($cellTemplate, $obj));
             //$timeLayout->assign ('a' . $num, $hours[$hr][1]);
             if ($hr == 0) {
                 $short = '_1230am';
             } elseif ($hr < 12) {
                 $short = '_' . $hr . '30am';
             } elseif ($hr == 12) {
                 $short = '_' . $hr . '30pm';
             } else {
                 $short = '_' . ($hr - 12) . '30pm';
             }
             $this->{$short} =& $timeLayout->{'b' . $num};
             $num++;
         }
         $timeLayout->table = $this->table;
         $timeLayout->table['border'] = '0';
         $timeLayout->table['style'] .= '; border: 0px none';
         $timeLayout->row = $this->row;
         $timeLayout->cell = $this->cell;
         $timeLayout->cell['style'] .= '; border: 0px none; border-bottom: 1px solid';
         $this->table['style'] .= '; border-bottom: 0px none';
         if (!empty($sql)) {
             $q = $db->query($sql);
             if ($q->execute()) {
                 while ($row = $q->fetch()) {
                     if (isset($this->activeCells[$row->{$dateColumn}])) {
                         if (isset($this->{'_' . Date::time(Date::roundTime($row->{$timeColumn}, 30), 'gia')})) {
                             $this->append('_' . Date::time(Date::roundTime($row->{$timeColumn}, 30), 'gia'), $simple->fill($itemTemplate, $row));
                             //unset ($ac[$this->activeCells[$row->{$dateColumn}]]);
                         }
                         //echo '_' . Date::time (Date::roundTime ($row->{$timeColumn}, 30), 'gia') . '<br />';
                     }
                 }
                 $q->free();
             } else {
                 $this->error = $q->error();
                 return false;
             }
         }
     } else {
         foreach ($this->activeCells as $date => $cell) {
             $obj = new StdClass();
             $obj->date = $date;
             $obj->stamp = Date::format($date, 'U');
             $obj->day = date('j', $obj->stamp);
             $this->assign($cell, $simple->fill($cellTemplate, $obj));
             $this->{date('_jS', $obj->stamp)} =& $this->{$cell};
         }
         if ($this->activeCells[$this->firstDay] != 'a3' && $this->activeCells[$this->firstDay] != 'b3') {
             $col = $this->activeCells[$this->firstDay][0];
             if ($col == 'c') {
                 $this->spanCols('a3', 2);
             } elseif ($col == 'd') {
                 $this->spanCols('a3', 3);
             } elseif ($col == 'e') {
                 $this->spanCols('a3', 4);
             } elseif ($col == 'f') {
                 $this->spanCols('a3', 5);
             } elseif ($col == 'g') {
                 $this->spanCols('a3', 6);
             }
             $this->topBlock =& $this->a3;
         } elseif ($this->activeCells[$this->firstDay] == 'b3') {
             $this->topBlock =& $this->a3;
         }
         if ($this->activeCells[$this->lastDay] != 'g3') {
             list($col, $row) = $this->translate($this->activeCells[$this->lastDay]);
             // get rid of empty rows at the bottom
             if ($row <= 6) {
                 array_pop($this->matrix[0]);
                 array_pop($this->matrix[1]);
                 array_pop($this->matrix[2]);
                 array_pop($this->matrix[3]);
                 array_pop($this->matrix[4]);
                 array_pop($this->matrix[5]);
                 array_pop($this->matrix[6]);
             }
             if ($row == 5) {
                 array_pop($this->matrix[0]);
                 array_pop($this->matrix[1]);
                 array_pop($this->matrix[2]);
                 array_pop($this->matrix[3]);
                 array_pop($this->matrix[4]);
                 array_pop($this->matrix[5]);
                 array_pop($this->matrix[6]);
             }
             if ($row == 6 && $col == 0) {
                 $this->spanCols(array(1, 6), 6);
                 $this->bottomBlock =& $this->{$this->translate(1, 6)};
             } elseif ($row == 6 && $col == 1) {
                 $this->spanCols(array(2, 6), 5);
                 $this->bottomBlock =& $this->{$this->translate(2, 6)};
             } elseif ($row == 6 && $col == 2) {
                 $this->spanCols(array(3, 6), 4);
                 $this->bottomBlock =& $this->{$this->translate(3, 6)};
             } elseif ($row == 6 && $col == 3) {
                 $this->spanCols(array(4, 6), 3);
                 $this->bottomBlock =& $this->{$this->translate(4, 6)};
             } elseif ($row == 6 && $col == 4) {
                 $this->spanCols(array(5, 6), 2);
                 $this->bottomBlock =& $this->{$this->translate(5, 6)};
             } elseif ($row == 6 && $col == 5) {
                 $this->bottomBlock =& $this->{$this->translate(6, 6)};
             } elseif ($row == 7 && $col == 0) {
                 $this->spanCols(array(1, 7), 6);
                 $this->bottomBlock =& $this->{$this->translate(1, 7)};
             } elseif ($row == 7 && $col == 1) {
                 $this->spanCols(array(2, 7), 5);
                 $this->bottomBlock =& $this->{$this->translate(2, 7)};
             }
         }
         if (!empty($sql)) {
             $q = $db->query($sql);
             if ($q->execute()) {
                 while ($row = $q->fetch()) {
                     if (isset($this->activeCells[$row->{$dateColumn}])) {
                         $this->append($this->activeCells[$row->{$dateColumn}], $simple->fill($itemTemplate, $row));
                         unset($ac[$this->activeCells[$row->{$dateColumn}]]);
                     }
                 }
                 $q->free();
             } else {
                 $this->error = $q->error();
                 return false;
             }
         }
     }
     // calender is drawn with $this->render ();
     return true;
 }
Exemplo n.º 17
0
<?php

$cal->dayLinks = '{site/prefix}/index/siteevent-app/view.day/day.{date}';
$list = $e->getMonthly($parameters['simplecal'], $parameters['category'], $parameters['audience'], $parameters['user'], 'id, title, short_title, date, time, until_date, until_time, priority, recurring');
$list =& siteevent_translate($list);
foreach (array_keys($list) as $k) {
    $item =& $list[$k];
    $title = !empty($item->short_title) ? $item->short_title : $item->title;
    $priority = $item->priority == 'high' ? true : false;
    $alt = $item->title;
    if ($item->time > '00:00:00') {
        $alt .= ' - ' . Date::time($item->time, 'g:i A');
    }
    if ($item->end_time > '00:00:00') {
        $alt .= ' - ' . Date::time($item->end_time, 'g:i A');
    }
    if ($item->time == '00:00:00') {
        $item->time = '';
    } else {
        list($h, $m, $s) = split(':', $item->time);
        $t = $item->time;
        $item->time = ltrim(strftime('%I:%M %p', mktime($h, $m, $s, $d, $mm, $y)), '0');
        if ($item->until_time > $t) {
            $item->time .= ' - ';
            list($h, $m, $s) = split(':', $item->until_time);
            $item->time .= ltrim(strftime('%I:%M %p', mktime($h, $m, $s, $d, $mm, $y)), '0');
        }
    }
    $item->time = str_replace(':00', '', $item->time);
    if (substr_count($item->time, 'AM') > 1) {
        $item->time = str_replace(' AM ', ' ', $item->time);
Exemplo n.º 18
0
 /**
  * Set the CreatedAt property to the current time.
  *
  * @param  Model  Model object subject of this observer method
  */
 public function before_insert(Model $obj)
 {
     if ($this->_overwrite or empty($obj->{$this->_property})) {
         $obj->{$this->_property} = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
     }
 }
Exemplo n.º 19
0
 protected static function get_shot_at_for_insert($file_shot_at = null, $shot_at_time = null, $shot_at = null)
 {
     if (!empty($shot_at)) {
         return $shot_at;
     } elseif (!empty($shot_at_time)) {
         return $shot_at_time . ':00';
     } elseif (!empty($file_shot_at)) {
         return $file_shot_at;
     }
     return \Date::time()->format('mysql');
 }
Exemplo n.º 20
0
 static function make_timeout($token, $timeout = 0)
 {
     if ($timeout > 0) {
         $_SESSION['@TIMEOUT'][$token] = array(Date::time(), (int) $timeout);
     } else {
         unset($_SESSION['@TIMEOUT'][$token]);
     }
 }
Exemplo n.º 21
0
 public function save_with_relations($member_id, $values, $file_tmps = null, $album_images = array(), $files = array())
 {
     if (!empty($this->member_id) && $this->member_id != $member_id) {
         throw new \InvalidArgumentException('Parameter member_id is invalid.');
     }
     $is_new = $this->_is_new;
     $this->member_id = $member_id;
     if (isset($values['title'])) {
         $this->title = $values['title'];
     }
     if (isset($values['body'])) {
         $this->body = $values['body'];
     }
     if (isset($values['public_flag'])) {
         $this->public_flag = $values['public_flag'];
     }
     $is_changed_public_flag = $this->is_changed('public_flag');
     if (!$this->is_published) {
         if (!empty($values['is_published'])) {
             $this->is_published = 1;
         } elseif (empty($values['is_draft'])) {
             $this->is_published = 1;
         }
     }
     $is_published = $this->is_changed('is_published') && $this->is_published;
     if (!empty($values['published_at_time'])) {
         if (!\Util_Date::check_is_same_minute($values['published_at_time'], $this->published_at)) {
             $this->published_at = $values['published_at_time'] . ':00';
         }
     } elseif (!$this->published_at && $is_published) {
         $this->published_at = \Date::time()->format('mysql');
     }
     $is_changed = $this->is_changed();
     if ($is_changed) {
         $this->save();
     }
     $moved_files = array();
     if (is_enabled('album')) {
         $image_public_flag = $this->is_published ? $this->public_flag : FBD_PUBLIC_FLAG_PRIVATE;
         if ($file_tmps) {
             $album_id = \Album\Model_Album::get_id_for_foreign_table($member_id, 'note');
             list($moved_files, $album_image_ids) = \Site_FileTmp::save_images($file_tmps, $album_id, 'album_id', 'album_image', $image_public_flag);
             \Note\Model_NoteAlbumImage::save_multiple($this->id, $album_image_ids);
         }
         // フォーム編集時
         if ($album_images && $files) {
             \Site_Upload::update_image_objs4file_objects($album_images, $files, $image_public_flag);
         } elseif ($is_published && ($saved_album_images = Model_NoteAlbumImage::get_album_image4note_id($this->id))) {
             foreach ($saved_album_images as $saved_album_image) {
                 $saved_album_image->update_public_flag($this->public_flag, true);
             }
         }
     }
     if (is_enabled('timeline')) {
         if ($is_published) {
             // timeline 投稿
             \Timeline\Site_Model::save_timeline($member_id, $this->public_flag, 'note', $this->id, $this->updated_at);
         } elseif (!$is_new && $is_changed_public_flag) {
             // timeline の public_flag の更新
             \Timeline\Model_Timeline::update_public_flag4foreign_table_and_foreign_id($this->public_flag, 'note', $this->id, \Config::get('timeline.types.note'));
         }
     }
     return array($is_changed, $is_published, $moved_files);
 }
Exemplo n.º 22
0
 protected function getTimestamp()
 {
     return floor(\Date::time()->get_timestamp() / $this->timestep);
 }
Exemplo n.º 23
0
/**
 * @package CMS
 */
function cms_filter_time($date)
{
    return Date::time($date, appconf('format_time'));
}
Exemplo n.º 24
0
 public function before_save(Model $obj)
 {
     $obj->updated_on = \Date::time()->get_timestamp();
 }
Exemplo n.º 25
0
 public static function all_activities_day()
 {
     $activies_today = Model_Activity::count(array('where' => array('created_at' => Date::time())));
     return $activies_today;
 }
Exemplo n.º 26
0
 public static function save_timeline($member_id, $public_flag = null, $type_key = null, $foreign_id = null, $save_datetime = null, $body = null, Model_Timeline $timeline = null, $child_foreign_ids = array())
 {
     if (!Site_Util::check_type_enabled($type_key)) {
         return;
     }
     list($type, $foreign_table, $child_foreign_table) = Site_Util::get_timeline_save_values($type_key);
     if (!$timeline) {
         $timeline = Site_Util::get_timeline_object($type_key, $foreign_id);
     }
     $is_new = empty($timeline->id);
     if (!is_null($body)) {
         $timeline->body = $body;
     }
     if ($is_new) {
         $timeline->member_id = $member_id;
         $timeline->type = $type;
         $timeline->public_flag = is_null($public_flag) ? conf('public_flag.default') : $public_flag;
         $timeline->foreign_table = $foreign_table;
         $timeline->foreign_id = $foreign_id;
         $timeline->created_at = $save_datetime ?: \Date::time()->format('mysql');
     } else {
         if (\Site_Util::check_is_expanded_public_flag_range($timeline->public_flag, $public_flag)) {
             $timeline->public_flag = $public_flag;
         }
         if ($child_foreign_ids) {
             $timeline->sort_datetime = $save_datetime ?: \Date::time()->format('mysql');
         }
         if ($timeline->is_changed() && $save_datetime) {
             $timeline->updated_at = $save_datetime;
         }
     }
     $timeline->save();
     if ($child_foreign_ids) {
         Model_TimelineChildData::save_multiple($timeline->id, $child_foreign_table, $child_foreign_ids);
     }
     return $timeline;
 }
Exemplo n.º 27
0
 /**
  * Set the UpdatedAt property to the current time.
  *
  * @param
  *        	Model Model object subject of this observer method
  */
 public function before_update(Model $obj)
 {
     if ($obj->is_changed()) {
         $obj->{$this->_property} = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
     }
 }
Exemplo n.º 28
0
Arquivo: email.php Projeto: pihizi/qf
 private function _make_boundary()
 {
     $this->_boundary = $this->_boundary ?: 'GENEE-' . md5(Date::time());
 }
Exemplo n.º 29
0
 /**
  * 
  * @param string $Table
  * @param array $values
  * @return array
  */
 public static function format_values($Table, array $values = null)
 {
     if (is_null($values)) {
         return $values;
     } else {
         foreach ($values as $key => $value) {
             if (is_null($value)) {
                 $values[$key] = '';
             }
         }
     }
     $infoTable = self::getTableInfo($Table);
     $result = [];
     foreach ($infoTable as $info) {
         $field = $info['Field'];
         # Verificando campo
         if (isset($values[$field])) {
             # Valor passado
             $value = $values[$field];
             # Tipo de dado
             $type = strtolower(current(explode('(', $info['Type'])));
             # Formatando tipos de valores
             if (trim($value) !== '') {
                 switch ($type) {
                     case 'date':
                         $value = Date::data($value);
                         break;
                     case 'tinyint':
                     case 'smallint':
                     case 'mediumint':
                     case 'bigint':
                     case 'int':
                         $value = Number::int($value);
                         break;
                     case 'decimal':
                     case 'float':
                     case 'double':
                     case 'real':
                         $value = Number::float($value);
                         break;
                     case 'datetime':
                     case 'timestamp':
                         $value = Date::timestamp($value);
                         break;
                     case 'time':
                         $value = Date::time($value);
                         break;
                 }
             } else {
                 if ($info['Null'] == 'NO') {
                     $value = '';
                 } else {
                     if ($info['Null'] == 'YES') {
                         $value = null;
                     }
                 }
             }
             # Setando valor na array
             $result[$field] = $value;
         }
     }
     return $result;
 }
Exemplo n.º 30
0
 /**
  * Lock a user setting it's locked_at to actual time.
  *
  * @return bool
  */
 public function lock_access()
 {
     $this->locked_at = \Date::time('UTC')->format('mysql');
     if ($this->is_unlock_strategy_enabled('email')) {
         $this->generate_unlock_token();
     }
     // Revoke authentication token
     $this->authentication_token = null;
     // Save and make sure session is destroyed completely
     if ($this->save(false) && Warden::logout(true)) {
         // Only send instructions after token was saved successfully
         if ($this->is_unlock_strategy_enabled('email')) {
             return $this->send_unlock_instructions();
         }
         return true;
     }
     return false;
 }