本文整理汇总了PHP中c::user方法的典型用法代码示例。如果您正苦于以下问题:PHP c::user方法的具体用法?PHP c::user怎么用?PHP c::user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c
的用法示例。
在下文中一共展示了c::user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEnv
public function getEnv($d = true)
{
if (c::user()->debug) {
$env = 'dev';
} elseif (c::env() == 'live' || c::env() == 'crondb') {
$env = 'live';
} elseif ($d === true) {
$env = 'dev';
} else {
$env = c::env();
}
return $env;
}
示例2: save
public static function save($object, $options = array())
{
$objectType = get_class($object);
Cana::config()->cache->object = false;
$current = new $objectType($object->{$object->idVar()});
Cana::config()->cache->object = true;
$oldVals = array();
$newVals = array();
foreach ($current->properties() as $var => $val) {
if (isset($object->{$var})) {
if ($object->{$var} != $current->{$var}) {
$oldVals[$var] = $current->{$var};
$newVals[$var] = $object->{$var};
}
}
}
if (isset($options['custom'])) {
foreach ($options['custom'] as $key => $customOption) {
$oldVals[$key] = $customOption['old'];
$newVals[$key] = $customOption['new'];
}
}
$time = isset($options['timestamp']) ? $options['timestamp'] : date('Y-m-d H:i:s');
// set
$set = Cana_Table::fromTable(isset($options['set']['table']) ? $options['set']['table'] : $object->table() . '_change_set', isset($options['set']['id']) ? $options['set']['id'] : $object->idVar() . '_change_set', $object->db());
$set->strip();
$set->timestamp = $time;
if (isset($options['author_id'])) {
$authorVar = $options['author_id'];
} elseif (c::admin()->id_admin) {
$authorVar = 'id_admin';
} elseif (c::user()->id_user) {
$authorVar = 'id_user';
} elseif (isset($options['id_admin'])) {
$authorVar = 'id_admin';
}
if ($authorVar) {
if (isset($options['author'])) {
$author = $options['author'];
} elseif (c::admin()->id_admin) {
$author = c::admin()->id_admin;
} elseif (c::user()->id_user) {
$author = c::user()->id_user;
// there is some case where the change is made by a cron task
} elseif (isset($options['id_admin'])) {
$author = $options['id_admin'];
}
if ($author) {
$set->{$authorVar} = $author;
}
}
$set->{$object->idVar()} = $object->{$object->idVar()};
// changes. only save set if theres at least one change
if (count($oldVals)) {
$set->save();
foreach ($oldVals as $field => $oldVal) {
$change = Cana_Table::fromTable(isset($options['change']['table']) ? $options['change']['table'] : $object->table() . '_change', isset($options['change']['id']) ? $options['change']['id'] : $object->{$object->idVar()} . '_change', $object->db());
$change->strip();
$change->{$set->idVar()} = $set->{$set->idVar()};
$change->field = $field;
$change->new_value = $newVals[$field];
$change->old_value = $oldVals[$field];
$change->save();
}
}
return $set;
}