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


PHP User::getId方法代码示例

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


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

示例1: updateParentFollowers

 /**
  * function to update parent followers when adding a comment
  * with this user and referenced users from comment
  * @return void
  */
 protected function updateParentFollowers()
 {
     $p =& $this->data;
     $po = $this->getParentObject();
     $posd = $po->getSysData();
     $newUserIds = array();
     $posd['lastComment'] = array('user_id' => User::getId(), 'date' => Util\dateMysqlToISO('now'));
     $wu = empty($posd['wu']) ? array() : $posd['wu'];
     $uid = User::getId();
     if (!in_array($uid, $wu)) {
         $newUserIds[] = intval($uid);
     }
     //analize comment text and get referenced users
     $this->lastMentionedUserIds = Util\getReferencedUsers($p['data']['_title']);
     foreach ($this->lastMentionedUserIds as $uid) {
         if (!in_array($uid, $wu)) {
             $newUserIds[] = $uid;
         }
     }
     //update only if new users added
     if (!empty($newUserIds)) {
         $wu = array_merge($wu, $newUserIds);
         $wu = Util\toNumericArray($wu);
         $posd['wu'] = array_unique($wu);
     }
     //always update sys_data to change lastComment date
     $po->updateSysData($posd);
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:33,代码来源:Comment.php

示例2: updateParentFollowers

 /**
  * function to update parent followers when adding a comment
  * with this user and referenced users from comment
  * @return void
  */
 protected function updateParentFollowers()
 {
     $p =& $this->data;
     $posd = $this->parentObj->getSysData();
     $newUserIds = array();
     $posd['lastComment'] = array('user_id' => User::getId(), 'date' => Util\dateMysqlToISO('now'));
     $fu = empty($posd['fu']) ? array() : $posd['fu'];
     $uid = User::getId();
     if (!in_array($uid, $fu)) {
         $newUserIds[] = intval($uid);
     }
     //analize comment text and get referenced users
     if (preg_match_all('/@([^@\\s,!\\?]+)/', $p['data']['_title'], $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             $uid = DM\User::getIdByName($match[1]);
             if (is_numeric($uid) && !in_array($uid, $fu) && !in_array($uid, $newUserIds)) {
                 $newUserIds[] = $uid;
             }
         }
     }
     //update only if new users added
     if (!empty($newUserIds)) {
         $fu = array_merge($fu, $newUserIds);
         $fu = Util\toNumericArray($fu);
         $posd['fu'] = array_unique($fu);
     }
     //always update sys_data to change lastComment date
     $this->parentObj->updateSysData($posd);
 }
开发者ID:ameliefranco,项目名称:casebox,代码行数:34,代码来源:Comment.php

示例3: deleteByNodeId

 public static function deleteByNodeId($nodeId, $userId = false)
 {
     if ($userId == false) {
         $userId = \CB\User::getId();
     }
     DB\dbQuery('DELETE FROM ' . static::getTableName() . ' WHERE user_id = $1 AND node_id = $2', array($userId, $nodeId)) or die(DB\dbQueryError());
     $rez = DB\dbAffectedRows() > 0;
     return $rez;
 }
开发者ID:youprofit,项目名称:casebox,代码行数:9,代码来源:Favorites.php

示例4: saveObjectAttachments

/**
 * save attachments array for a given object id
 * @param  int $objectId
 * @param  array &$attachments attachments array as from getMailContentAndAtachment
 * @return void
 */
function saveObjectAttachments($objectId, &$attachments)
{
    $filesApiObject = new \CB\Api\Files();
    foreach ($attachments as $d) {
        if (empty($d['attachment'])) {
            continue;
        }
        //safe content to a temporary file
        $tmpName = tempnam(sys_get_temp_dir(), 'cbMailAtt');
        file_put_contents($tmpName, $d['content']);
        //call the api method
        $filesApiObject->upload(array('pid' => $objectId, 'localFile' => $tmpName, 'oid' => \CB\User::getId(), 'filename' => $d['filename'], 'content-type' => $d['content-type'], 'fileExistAction' => 'autorename'));
    }
}
开发者ID:sebbie42,项目名称:casebox,代码行数:20,代码来源:mail_functions.php

示例5: setUserStatus

 /**
  * set complete or incomplete status for a task responsible user
  * @param array $p params
  */
 public function setUserStatus($p)
 {
     $rez = array('success' => true, 'id' => $p['id']);
     $obj = Objects::getCachedObject($p['id']);
     $data = $obj->getData();
     if (User::getId() != $data['cid'] && !Security::isAdmin()) {
         throw new \Exception(L\get('Access_denied'));
     }
     if ($obj->getUserStatus($p['user_id']) == Objects\Task::$USERSTATUS_NONE) {
         throw new \Exception(L\get('Wrong_id'));
     }
     $status = $p['status'] == 1 ? Objects\Task::$USERSTATUS_DONE : Objects\Task::$USERSTATUS_ONGOING;
     $obj->setUserStatus($status, $p['user_id']);
     // $obj->updateSysData();
     $this->afterUpdate($p['id']);
     return $rez;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:21,代码来源:Tasks.php

示例6: create

 public function create($p)
 {
     $rez = array('succes' => false, 'data' => array());
     if (empty($p['node_id']) || empty($p['data'])) {
         return $rez;
     }
     $data = array('name' => Purify::filename($p['data']['name']), 'path' => $p['data']['path'], 'pathText' => empty($p['data']['pathText']) ? '' : $p['data']['pathText']);
     if (is_numeric($p['node_id'])) {
         $data['template_id'] = Objects::getTemplateId($p['node_id']);
         $data['iconCls'] = Browser::getIcon($data);
     } elseif (!empty($p['data']['iconCls'])) {
         $data['iconCls'] = $p['data']['iconCls'];
     }
     $d = array('user_id' => User::getId(), 'node_id' => $p['node_id'], 'data' => Util\jsonEncode($data));
     $id = DM\Favorites::create($d);
     $rez = array('success' => true, 'data' => array('id' => $id, 'node_id' => $d['node_id'], 'data' => $data));
     return $rez;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:18,代码来源:Favorites.php

示例7: getData

 public function getData($id = false)
 {
     $rez = array('success' => true, 'data' => array());
     parent::getData($id);
     $obj = $this->getObjectClass();
     if (!is_object($obj)) {
         return $rez;
     }
     $data = $obj->getData();
     $rez['data'] = array_intersect_key($data, array('id' => 1, 'name' => 1, 'template_id' => 1, 'cid' => 1, 'cdate' => 1, 'uid' => 1, 'udate' => 1, 'dstatus' => 1, 'did' => 1, 'ddate' => 1, 'size' => 1));
     $d =& $rez['data'];
     $pids = Util\toNumericArray($data['pids']);
     array_pop($pids);
     $d['pids'] = $d['path'] = implode('/', $pids);
     $arr = array(&$d);
     Search::setPaths($arr);
     $d['template_name'] = Objects::getName($d['template_id']);
     $sd = $obj->getSysData();
     $userId = User::getId();
     $d['subscription'] = 'ignore';
     if (!empty($sd['fu']) && in_array($userId, $sd['fu'])) {
         $d['subscription'] = 'watch';
         //follow
     }
     if (!empty($sd['wu']) && in_array($userId, $sd['wu'])) {
         $d['subscription'] = 'watch';
     }
     $d['cid_text'] = User::getDisplayName($d['cid']);
     $d['cdate_ago_text'] = Util\formatAgoTime($d['cdate']);
     $d['cdate'] = Util\dateMysqlToISO($d['cdate']);
     $d['udate'] = Util\dateMysqlToISO($d['udate']);
     $d['uid_text'] = User::getDisplayName($d['uid']);
     $d['udate_ago_text'] = Util\formatAgoTime($d['udate']);
     if (!empty($d['dstatus'])) {
         $d['did_text'] = User::getDisplayName($d['did']);
         $d['ddate_text'] = Util\formatAgoTime($d['ddate']);
     }
     return $rez;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:39,代码来源:SystemProperties.php

示例8: setUserStatus

 /**
  * change user status for loaded task
  * @param  array   $p params
  * @return boolean
  */
 public function setUserStatus($status, $userId = false)
 {
     $rez = false;
     $action = '';
     $currentUserId = User::getId();
     if ($userId == false) {
         $userId = $currentUserId;
     }
     $d =& $this->data;
     $sd =& $d['sys_data'];
     switch ($status) {
         case static::$USERSTATUS_ONGOING:
             if (in_array($userId, $sd['task_u_done'])) {
                 $sd['task_u_done'] = array_diff($sd['task_u_done'], array($userId));
                 $sd['task_u_ongoing'][] = $userId;
                 unset($sd['task_u_d_closed'][$userId]);
                 $rez = true;
                 $action = $currentUserId == $userId ? 'reopen' : 'completion_decline';
             }
             break;
         case static::$USERSTATUS_DONE:
             if (in_array($userId, $sd['task_u_ongoing'])) {
                 $sd['task_u_ongoing'] = array_diff($sd['task_u_ongoing'], array($userId));
                 $sd['task_u_done'][] = $userId;
                 $sd['task_u_d_closed'][$userId] = date(DATE_ISO8601);
                 $rez = true;
                 $action = $currentUserId == $userId ? 'complete' : 'completion_on_behalf';
             }
             break;
     }
     if ($rez) {
         $this->checkAutoclose();
         $this->logAction($action, array('old' => &$this, 'forUserId' => $userId));
         // $this->updateSysData();
     }
     return $rez;
 }
开发者ID:youprofit,项目名称:casebox,代码行数:42,代码来源:Task.php

示例9: markAllAsRead

 /**
  * mark all unread user notifications  as read
  * @return json response
  */
 public function markAllAsRead()
 {
     DM\Notifications::markAllAsRead(User::getId());
     return array('success' => true);
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:9,代码来源:Notifications.php

示例10: setSubscription

 /**
  * set subscription to an object for current user
  * @param array $p
  *        [
  *            int objectId
  *            varchar type      (follow, watch, ignore)
  *        ]
  * return array     json responce
  */
 public function setSubscription($p)
 {
     //validate input params
     if (empty($p['objectId']) || !is_numeric($p['objectId']) || empty($p['type']) || !in_array($p['type'], array('follow', 'watch', 'ignore'))) {
         throw new \Exception(L\get('Wrong_input_data'));
     }
     //set subscription
     $userId = User::getId();
     $obj = $this->getCachedObject($p['objectId']);
     $sd = $obj->getSysData();
     $fu = empty($sd['fu']) ? array() : $sd['fu'];
     $wu = empty($sd['wu']) ? array() : $sd['wu'];
     switch ($p['type']) {
         case 'follow':
             $sd['wu'] = array_diff($wu, array($userId));
             $sd['fu'] = array_merge(array_diff($fu, array($userId)), array($userId));
             break;
         case 'watch':
             $sd['fu'] = array_diff($fu, array($userId));
             $sd['wu'] = array_merge(array_diff($wu, array($userId)), array($userId));
             break;
         case 'ignore':
             $sd['fu'] = array_diff($fu, array($userId));
             $sd['wu'] = array_diff($wu, array($userId));
             break;
     }
     $obj->updateSysData($sd);
     return array('success' => true);
 }
开发者ID:ameliefranco,项目名称:casebox,代码行数:38,代码来源:Objects.php

示例11: setUserConfig

 private static function setUserConfig($cfg, $userId = false)
 {
     if ($userId === false) {
         $userId = User::getId();
     }
     DM\Users::update(array('id' => $userId, 'cfg' => Util\jsonEncode($cfg)));
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:7,代码来源:User.php

示例12: isUsersOwner

 /**
  * Check if current loged user is owner for given user id
  *
  * @param  int     $userId
  * @return boolean
  */
 public static function isUsersOwner($userId)
 {
     return User::getId() == DM\User::getOwnerId($userId);
 }
开发者ID:ameliefranco,项目名称:casebox,代码行数:10,代码来源:Security.php

示例13: getGridViewState

 public static function getGridViewState($guid)
 {
     $rez = array();
     $res = DB\dbQuery('SELECT cfg
         FROM tree_user_config
         WHERE  user_id = $1 and guid = $2', array(User::getId(), $guid));
     if ($r = $res->fetch_assoc()) {
         $rez = Util\toJSONArray($r['cfg']);
     }
     $res->close();
     //backward compatibility to extjs3
     if (!empty($rez['sort']['field']) && empty($rez['sort']['property'])) {
         $rez['sort']['property'] = $rez['sort']['field'];
     }
     return $rez;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:16,代码来源:DBProvider.php

示例14: getActionFlags

 /**
  *  get action flags that a user can do to task
  * @param  int   $userId
  * @return array
  */
 public function getActionFlags($userId = false)
 {
     if ($userId === false) {
         $userId = User::getId();
     }
     $isAdmin = \CB\Security::isAdmin($userId);
     $isOwner = $this->isOwner($userId);
     $isClosed = $this->isClosed();
     $canEdit = !$isClosed && ($isAdmin || $isOwner);
     $rez = array('close' => $canEdit, 'reopen' => $isClosed && $isOwner, 'complete' => !$isClosed && $this->getUserStatus($userId) == static::$USERSTATUS_ONGOING);
     return $rez;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:17,代码来源:Task.php

示例15: logAction

 /**
  * add action to log
  * @param  varchar $type
  * @param  array   $params
  * @return void
  */
 protected function logAction($type, $params = array())
 {
     if (!Cache::get('disable_logs', false) && !Config::getFlag('disableActivityLog')) {
         $params['type'] = $type;
         $obj =& $this;
         if (empty($params['new'])) {
             $params['new'] =& $this;
         } else {
             $obj =& $params['new'];
         }
         $logActionId = Log::add($params);
         $uid = User::getId();
         //add action to object sys_data
         $data = $obj->getData();
         $lastAction = $obj->getLastActionData();
         if ($lastAction['type'] != $type) {
             $lastAction = array('type' => $type, 'time' => Util\dateMysqlToISO('now'), 'users' => array());
         }
         /*$sysData = empty($data['sys_data'])
                         ? $this->getSysData()
                         : $data['sys_data'];
         
                     $lastAction = array(
                         'type' => $type
                         ,'time' => Util\dateMysqlToISO('now')
                         ,'users' => array()
                     );
         
                     if (!empty($sysData['lastAction']) &&
                         ($sysData['lastAction']['type'] == $type)
                     ) {
                         $lastAction['users'] = $sysData['lastAction']['users'];
                     } /**/
         unset($lastAction['users'][$uid]);
         $lastAction['users'][$uid] = $logActionId;
         $obj->setSysDataProperty('lastAction', $lastAction);
     }
 }
开发者ID:ameliefranco,项目名称:casebox,代码行数:44,代码来源:Object.php


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