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


PHP c::user方法代码示例

本文整理汇总了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;
 }
开发者ID:arzynik,项目名称:cana,代码行数:13,代码来源:App.php

示例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;
 }
开发者ID:arzynik,项目名称:cana,代码行数:67,代码来源:Changeset.php


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