當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。