public function getName($id = false) { $rez = 'no name'; if ($id === false) { $id = $this->id; } if (!empty($id) && is_numeric($id)) { $facetConfig = $this->getFacetFieldConfig($this->getClassDepth() - 1); switch (@$facetConfig['type']) { case 'users': $rez = User::getDisplayName($id); break; case 'varchar': $rez = $id; break; default: $rez = Objects::getName($id); } } else { switch ($id) { case 'root': $rez = parent::getName('root'); break; } } return $rez; }
public function getName($id = false) { if ($id === false) { $id = $this->id; } switch ($id) { case 'tasks': return L\get('MyTasks'); case 2: return L\get('AssignedToMe'); case 3: return L\get('CreatedByMe'); case 4: return lcfirst(L\get('Overdue')); case 5: return lcfirst(L\get('Ongoing')); case 6: return lcfirst(L\get('Closed')); case 'assignee': return lcfirst(L\get('Assignee')); default: if (substr($id, 0, 3) == 'au_') { return \CB\User::getDisplayName(substr($id, 3)); } } return 'none'; }
public function getClientData() { $rez = array('f' => $this->field, 'title' => $this->getTitle(), 'items' => array()); foreach ($this->solrData as $k => $v) { $rez['items'][$k] = array('name' => User::getDisplayName($k), 'count' => $v); } return $rez; }
public function beforeLock($path, \Sabre\DAV\Locks\LockInfo $lock) { $path = $path; //dummy codacy assignment $lock->owner = \CB\User::getDisplayName($_SESSION['user']['id']); // error_log('beforeLock: ' . $lock->owner); return true; }
public function getClientData($options = array()) { $rez = array('f' => $this->field, 'title' => $this->getTitle(), 'items' => array()); // $colors = empty($options['colors']) // ? array() // : Users::getColors(); foreach ($this->solrData as $k => $v) { $rez['items'][$k] = array('name' => User::getDisplayName($k), 'count' => $v); if (!empty($options['colors'])) { $rez['items'][$k]['cls'] = 'user-color-' . $k; } } return $rez; }
public function getData($id = false) { $rez = array('success' => true); parent::getData($id); $o = Objects::getCachedObject($this->id); $data = $o->getData(); //show current version only if have more other versions if (!empty($data['versions'])) { $data['ago_text'] = Util\formatAgoTime($data['cdate']); $data['user'] = User::getDisplayName($data['oid'], true); $data['cls'] = 'sel'; $rez['data'] = array($data); } return $rez; }
public function getName($id = false) { if ($id == false) { $id = $this->id; } $rez = 'no name'; switch ($id) { case 'users': $rez = L\get('Users'); break; default: $rez = \CB\User::getDisplayName($id); } return $rez; }
public function getData($id = false) { $rez = array('success' => true); parent::getData($id); // echo $this->id.'!!'; $o = Objects::getCachedObject($this->id); $data = $o->getData(); if (!empty($data['versions'])) { $rez['data'] = $data['versions']; foreach ($rez['data'] as &$version) { $version['ago_text'] = Util\formatAgoTime($version['cdate']); $version['user'] = User::getDisplayName($version['cid'], true); } } return $rez; }
public function getData($id = false) { $rez = array('success' => true); if (empty(parent::getData($id))) { return $rez; } $params = array('pid' => $this->id, 'fq' => array('(template_type:task) OR (target_type:task)'), 'fl' => 'id,pid,name,template_id,date,date_end,cid,cdate,status', 'sort' => 'cdate', 'dir' => 'desc'); $s = new \CB\Search(); $sr = $s->query($params); foreach ($sr['data'] as $d) { $d['ago_text'] = @Util\formatDateTimePeriod($d['date'], null, @$_SESSION['user']['cfg']['timezone']); $d['user'] = User::getDisplayName($d['cid'], true); \CB\Tasks::setTaskActionFlags($d); $rez['data'][] = $d; } return $rez; }
public function getData($id = false) { $rez = array('success' => true); if (empty(parent::getData($id))) { return $rez; } $params = array('pid' => $this->id, 'fq' => array('(template_type:object) OR (target_type:object)'), 'fl' => 'id,pid,name,template_id,cdate,cid', 'sort' => 'cdate', 'dir' => 'desc'); $folderTemplates = \CB\Config::get('folder_templates'); if (!empty($folderTemplates)) { $params['fq'][] = '!template_id:(' . implode(' OR ', Util\toNumericArray($folderTemplates)) . ')'; } $s = new \CB\Search(); $sr = $s->query($params); foreach ($sr['data'] as $d) { $d['ago_text'] = Util\formatAgoTime($d['cdate']); $d['user'] = @User::getDisplayName($d['cid']); $rez['data'][] = $d; } return $rez; }
/** * load a single comment by id * used for add/update operations on comments * @param int $id * @return json response */ public static function loadComment($id) { $rez = array('success' => true, 'data' => array()); if (empty($id)) { return $rez; } $params = array('system' => '[0 TO 2]', 'fq' => array('id:' . intval($id)), 'fl' => 'id,pid,template_id,cid,cdate,content', 'rows' => 1); $s = new \CB\Search(); $sr = $s->query($params); foreach ($sr['data'] as $d) { $d['cdate_text'] = Util\formatAgoTime($d['cdate']); $d['user'] = User::getDisplayName($d['cid'], true); //data in solr has already encoded html special chars // so we need to decode it and to format the message (where the chars will be encoded again) $d['content'] = htmlspecialchars_decode($d['content'], ENT_COMPAT); $d['content'] = \CB\Objects\Comment::processAndFormatMessage($d['content']); array_unshift($rez['data'], $d); } static::addAttachmentLinks($rez); return @array_shift($rez['data']); }
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; }
public function getName($id = false) { $rez = 'no name'; if ($id === false) { $id = $this->id; } if (!empty($id) && is_numeric($id)) { $facetConfig = $this->getFacetFieldConfig($this->getClassDepth() - 1); switch (@$facetConfig['type']) { case 'users': $rez = User::getDisplayName($id); break; default: $rez = Objects::getName($id); } } else { switch ($id) { case 'root': $cfg =& $this->config; $l = Config::get('user_language'); if (empty($cfg['title_' . $l])) { $l = Config::get('language'); if (empty($cfg['title_' . $l])) { if (!empty($cfg['title'])) { $rez = $cfg['title']; } } else { $rez = $cfg['title_' . $l]; } } else { $rez = $cfg['title_' . $l]; } break; } } return $rez; }
public function getExistentFilenames($F, $pid) { //if no filenames already exists in target then the result will be an empty array $rez = array(); $userLanguageIndex = Config::get('user_language_index'); foreach ($F as $fk => $f) { if ($this->fileExists($pid, $f['name'], @$f['dir'])) { $rez[] = $f; } } switch (sizeof($rez)) { case 0: break; case 1: //single match: retreive match info for content //(if matches with current version or to an older version) $existentFileId = $this->getFileId($pid, $rez[0]['name'], @$rez[0]['dir']); $rez[0]['existentFileId'] = $existentFileId; $md5 = $this->getFileMD5($rez[0]); $res = DB\dbQuery('SELECT f.cid ,f.cdate FROM files f JOIN files_content c ON f.content_id = c.id AND c.md5 = $2 WHERE f.id = $1', array($existentFileId, $md5)) or die(DB\dbQueryError()); if ($r = $res->fetch_assoc()) { $r['user'] = User::getDisplayName($r['cid']); $agoTime = Util\formatAgoTime($r['cdate']); $rez[0]['msg'] = str_replace(array('{timeAgo}', '{user}'), array($agoTime, $r['user']), L\get('FileContentsIdentical')); } $res->close(); if (empty($rez[0]['msg'])) { $res = DB\dbQuery('SELECT f.cid ,f.cdate FROM files_versions f JOIN files_content c ON f.content_id = c.id AND c.md5 = $2 WHERE f.file_id = $1', array($existentFileId, $md5)) or die(DB\dbQueryError()); if ($r = $res->fetch_assoc()) { $r['user'] = User::getDisplayName($r['cid']); $agoTime = Util\formatAgoTime($r['cdate']); $rez[0]['msg'] = str_replace(array('{timeAgo}', '{user}'), array($agoTime, $r['user']), L\get('FileContentsIdenticalToAVersion')); } } /* suggested new filename */ $subdirId = $pid; if (!empty($rez[0]['dir'])) { $subdirId = $this->getFileId($pid, '', $rez[0]['dir']); } $rez[0]['suggestedFilename'] = Objects::getAvailableName($subdirId, $rez[0]['name']); /* end of suggested new filename */ break; default: // multiple files match break; } return $rez; }
/** * method to analize grouping params and add group column to result * @param array $p search params * @return void */ protected function analizeGrouping(&$p) { if (empty($p['result']['view']['group']['property'])) { return; } //sync grouping sort direction with sorting if same column $result =& $p['result']; $view =& $result['view']; $group =& $view['group']; if (!empty($view['sort'])) { if (@$group['property'] == $view['sort']['property']) { $group['direction'] = $view['sort']['direction']; } else { $group['direction'] = 'ASC'; } } //end of sync $field = $group['property']; $data =& $p['result']['data']; $count = sizeof($data); for ($i = 0; $i < $count; $i++) { $d =& $data[$i]; $v = @$d[$field]; switch ($field) { case 'cid': case 'uid': case 'oid': if (empty($v)) { $d['group'] = ''; $d['groupText'] = 'none'; } else { $d['group'] = $v; $d['groupText'] = User::getDisplayName($d[$field]); } break; case 'date': case 'date_end': case 'cdate': case 'udate': case 'ddate': case 'task_d_closed': if (empty($v)) { $d['group'] = 'empty'; $d['groupText'] = 'empty'; } else { $d['group'] = substr($v, 0, 7) . '-01T00:00:00Z'; $d['groupText'] = Util\formatMysqlDate($d['group'], 'Y, F'); } break; case 'size': if (empty($v)) { $d['group'] = 'up to 1 MB'; } else { $t = Util\formatFileSize($v); $d['size'] .= ' - ' . $t; $t = explode(' ', $t); if (@$t[1] == 'KB' || $t[0] <= 1) { $t = 1; } else { $q = floor($t[0] / 10) * 10; $t = $t[0] > $q ? $q + 10 : $q; } $d['size'] .= ' - ' . $t; $d['group'] = $t < 1 ? 'up to 1 MB' : 'up to ' . $t . ' MB'; } break; default: if (empty($d[$field])) { $d['group'] = 'empty'; } else { //split values by comma and duplicate records if multivalued $values = is_array($d[$field]) ? $d[$field] : explode(',', $d[$field]); $d['group'] = trim(array_shift($values)); for ($j = 0; $j < sizeof($values); $j++) { $newRecord = $d; $newRecord['group'] = trim($values[$j]); array_push($data, $newRecord); } } } } }
protected function getData($p) { $rez = array(); if (empty($p)) { return $rez; } // form columns L\initTranslations(); $defaultColumns = Config::getDefaultGridColumnConfigs(); $columns = $defaultColumns; // retreive data $p['start'] = 0; $p['rows'] = 500; $sr = new \CB\BrowserView(); $results = $sr->getChildren($p); if (!empty($results['DC'])) { $columns = array(); foreach ($results['DC'] as $colName => $col) { if (@$col['hidden'] !== true) { $columns[$colName] = $col; } } } $colTitles = array(); foreach ($columns as $name => &$col) { $colTitles[] = empty($defaultColumns[$name]) ? @Util\coalesce($col['title'], $name) : $defaultColumns[$name]['title']; } //insert header $rez[] = $colTitles; while (!empty($results['data'])) { foreach ($results['data'] as $r) { $record = array(); foreach ($columns as $colName => $col) { if (@$col['xtype'] == 'datecolumn') { $value = Util\dateISOToMysql(@$r[$colName]); if (!empty($col['format'])) { $value = Util\formatMysqlTime($value, $col['format']); } else { $value = Util\formatMysqlTime($value); $tmp = explode(' ', $value); if (!empty($tmp[1]) && $tmp[1] == '00:00') { $value = $tmp[0]; } } $record[] = $value; } elseif (strpos($colName, 'date') === false) { if (in_array($colName, array('oid', 'cid', 'uid')) && !empty($r[$colName])) { $record[] = User::getDisplayName($r[$colName]); } else { $record[] = @$r[$colName]; } } } $rez[] = $record; } if ($p['start'] + $p['rows'] < $results['total']) { $p['start'] += $p['rows']; $results = $sr->getChildren($p); } else { $results['data'] = array(); } } return $rez; }
/** * send recovery password email for given user id * so that the user can set new password and enter the system * @param int $userId * @return boolean */ public static function sendResetPasswordMail($userId, $template = 'recover') { if (!is_numeric($userId) || User::isLoged() && !Security::canEditUser($userId)) { return false; } $mail = ''; $subject = ''; switch ($template) { case 'invite': $mail = System::getEmailTemplate('email_invite'); $subject = L\get('MailInviteSubject'); break; case 'recover': $mail = System::getEmailTemplate('password_recovery_email'); $subject = L\get('MailRecoverSubject'); break; default: return false; } if (empty($mail)) { return false; } $userData = User::getPreferences($userId); $userEmail = User::getEmail($userData); if (empty($userEmail)) { return false; } /* generating invite hash and sending mail */ $hash = User::generateRecoveryHash($userId, $userId . $userEmail . date(DATE_ISO8601)); $href = Util\getCoreHost() . 'recover/reset-password/?h=' . $hash; /* replacing placeholders in template and subject */ $replacements = array('{projectTitle}' => Config::getProjectName(), '{fullName}' => User::getDisplayName($userData), '{username}' => User::getUsername($userData), '{userEmail}' => $userEmail, '{creatorFullName}' => User::getDisplayName(), '{creatorUsername}' => User::getUsername(), '{creatorEmail}' => User::getEmail(), '{href}' => $href, '{link}' => '<a href="' . $href . '" >' . $href . '</a>'); $search = array_keys($replacements); $replace = array_values($replacements); $mail = str_replace($search, $replace, $mail); $subject = str_replace($search, $replace, $subject); return @System::sendMail($userEmail, $subject, $mail); }
public function getExistentFilenames($F, $pid) { //if no filenames already exists in target then the result will be an empty array $rez = array(); foreach ($F as $f) { if ($this->fileExists($pid, $f['name'], @$f['dir'])) { $rez[] = $f; } } switch (sizeof($rez)) { case 0: break; case 1: //single match: retreive match info for content //(if matches with current version or to an older version) $existentFileId = $this->getFileId($pid, $rez[0]['name'], @$rez[0]['dir']); $rez[0]['existentFileId'] = $existentFileId; $file = DM\Files::read($existentFileId); $content = DM\FilesContent::read($file['content_id']); $md5 = $this->getFileMD5($rez[0]); $data = array(); if ($md5 == $content['md5']) { $data = $file; $data['text'] = L\get('FileContentsIdentical'); } if (empty($rez[0]['msg'])) { $version = DM\FilesVersions::getVersionByMD5($existentFileId, $md5); if (!empty($version)) { $data = $version; $data['text'] = L\get('FileContentsIdenticalToAVersion'); } } if (!empty($data)) { $user = User::getDisplayName($data['cid']); $agoTime = Util\formatAgoTime($data['cdate']); $rez[0]['msg'] = str_replace(array('{timeAgo}', '{user}'), array($agoTime, $user), $data['text']); } /* suggested new filename */ $subdirId = $pid; if (!empty($rez[0]['dir'])) { $subdirId = $this->getFileId($pid, '', $rez[0]['dir']); } $rez[0]['suggestedFilename'] = Objects::getAvailableName($subdirId, $rez[0]['name']); /* end of suggested new filename */ break; default: // multiple files match break; } return $rez; }
/** * generate html preview for a task * @param int $id task id * @return array */ public function getPreviewBlocks() { $pb = parent::getPreviewBlocks(); $data = $this->getData(); $sd =& $data['sys_data']; $template = $this->getTemplate(); $actionsLine = 'Actions<hr />'; $dateLines = ''; $ownerRow = ''; $assigneeRow = ''; $contentRow = ''; //create actions line $flags = $this->getActionFlags(); $actions = array(); if (!empty($flags['complete'])) { $actions[] = '<a action="complete" class="task-action ib-done">' . L\get('Complete') . '</a>'; } if (!empty($flags['close'])) { $actions[] = '<a action="close" class="task-action ib-done-all">' . L\get('Close') . '</a>'; } if (!empty($flags['reopen'])) { $actions[] = '<a action="reopen" class="task-action ib-repeat">' . L\get('Reopen') . '</a>'; } $actionsLine = '<div class="task-actions">' . implode(' ', $actions) . '</div>'; //create date and status row $ed = $this->getEndDate(); $status = $this->getStatus(); if (!empty($ed)) { $endDate = Util\formatTaskTime($ed, !$sd['task_allday']); // $endDate = empty($sd['task_allday']) // ? Util\formatDateTimePeriod($ed, null, @$_SESSION['user']['cfg']['timezone']) // : Util\formatDatePeriod($ed, null, @$_SESSION['user']['cfg']['timezone']); $dateLines = '<tr><td class="prop-key">' . L\get('Due') . ':</td><td>' . $endDate . '</td></tr>'; // $dateLine .= '<div class="date">' . $endDate . '</div>'; } if (!empty($sd['task_d_closed'])) { $dateLines .= '<tr><td class="prop-key">' . L\get('Completed') . ':</td><td>' . Util\formatAgoTime($sd['task_d_closed']) . '</td></tr>'; } //create owner row $v = $this->getOwner(); if (!empty($v)) { $cn = User::getDisplayName($v); $cdt = Util\formatAgoTime($data['cdate']); $cd = Util\formatDateTimePeriod($data['cdate'], null, @$_SESSION['user']['cfg']['timezone']); $ownerRow = '<tr><td class="prop-key">' . L\get('Owner') . ':</td><td>' . '<table class="prop-val people"><tbody>' . '<tr><td class="user"><img class="photo32" src="photo/' . $v . '.jpg?32=' . User::getPhotoParam($v) . '" style="width:32px; height: 32px" alt="' . $cn . '" title="' . $cn . '"></td>' . '<td><b>' . $cn . '</b><p class="gr">' . L\get('Created') . ': ' . '<span class="dttm" title="' . $cd . '">' . $cdt . '</span></p></td></tr></tbody></table>' . '</td></tr>'; } //create assignee row $v = $this->getFieldValue('assigned', 0); if (!empty($v['value'])) { $isOwner = $this->isOwner(); $assigneeRow .= '<tr><td class="prop-key">' . L\get('TaskAssigned') . ':</td><td><table class="prop-val people"><tbody>'; $v = Util\toNumericArray($v['value']); $dateFormat = \CB\getOption('long_date_format') . ' H:i:s'; foreach ($v as $id) { $un = User::getDisplayName($id); $completed = $this->getUserStatus($id) == static::$USERSTATUS_DONE; $flags = $this->getActionFlags($id); $cdt = ''; //completed date title $dateText = ''; if ($completed && !empty($sd['task_u_d_closed'][$id])) { $cdt = Util\formatMysqlDate($sd['task_u_d_closed'][$id], $dateFormat); $dateText = ': ' . Util\formatAgoTime($sd['task_u_d_closed'][$id]); } $assigneeRow .= '<tr><td class="user"><div style="position: relative">' . '<img class="photo32" src="photo/' . $id . '.jpg?32=' . User::getPhotoParam($id) . '" style="width:32px; height: 32px" alt="' . $un . '" title="' . $un . '">' . ($completed ? '<img class="done icon icon-tick-circle" src="/css/i/s.gif" />' : "") . '</div></td><td><b>' . $un . '</b>' . '<p class="gr" title="' . $cdt . '">' . ($completed ? L\get('Completed') . $dateText . ($isOwner ? ' <a class="bt task-action click" action="markincomplete" uid="' . $id . '">' . L\get('revoke') . '</a>' : '') : L\get('waitingForAction') . ($isOwner ? ' <a class="bt task-action click" action="markcomplete" uid="' . $id . '">' . L\get('complete') . '</a>' : '')) . '</p></td></tr>'; } $assigneeRow .= '</tbody></table></td></tr>'; } //create description row $v = $this->getFieldValue('description', 0); if (!empty($v['value'])) { $tf = $template->getField('description'); $v = $template->formatValueForDisplay($tf, $v); $contentRow = '<tr><td class="prop-val" colspan="2">' . $v . '</td></tr>'; } //insert rows $p = $pb[0]; $pos = strrpos($p, '<tbody>'); $p = substr($p, $pos + 7); $pos = strrpos($p, '</tbody>'); if ($pos !== false) { $p = substr($p, 0, $pos); } $pb[0] = $actionsLine . '<table class="obj-preview"><tbody>' . $dateLines . $p . $ownerRow . $assigneeRow . $contentRow . '<tbody></table>'; return $pb; }
/** * get the sender formated string * @param int $userId * @return varchar */ public static function getSender($userId = false) { $coreName = Config::get('core_name'); $commentsEmail = Config::get('comments_email'); $senderMail = empty($commentsEmail) ? Config::get('sender_email') : $commentsEmail; $rez = '"' . mb_encode_mimeheader(str_replace('"', '\'\'', html_entity_decode(User::getDisplayName($userId) . " (" . $coreName . ")", ENT_QUOTES, 'UTF-8')), 'UTF-8', 'B') . "\" <" . $senderMail . '>'; return $rez; }
/** * formats a value for display according to it's field definition * @param array | int $field array of field properties or field id * @param variant $value field value to be formated * @param boolean $html default true - format for html, otherwise format for text display * @return varchar formated value */ public static function formatValueForDisplay($field, $value, $html = true) { $cacheVarName = ''; if (is_numeric($field)) { $field = $this->data->fields[$field]; } //condition is specified for values from search templates $condition = null; if (is_array($value)) { if (isset($value['cond'])) { $condition = Template::formatConditionForDisplay($field, $value['cond'], $html) . ' '; } if (isset($value['value'])) { $value = $value['value']; } else { $value = null; } } //we'll cache scalar by default, but will exclude textual fields $cacheValue = is_scalar($value); if ($cacheValue) { $fid = empty($field['id']) ? $field['name'] : $field['id']; $cacheVarName = 'dv' . $html . '_' . $fid . '_' . $value; //check if value is in cache and return if (Cache::exist($cacheVarName)) { return Cache::get($cacheVarName); } } /*check if field is not rezerved field for usernames (cid, oid, uid, did)*/ if (!empty($field['name']) && in_array($field['name'], array('cid', 'oid', 'uid', 'did'))) { $value = Util\toNumericArray($value); for ($i = 0; $i < sizeof($value); $i++) { $value[$i] = User::getDisplayName($value[$i]); } $value = implode(', ', $value); } else { switch ($field['type']) { case 'boolean': case 'checkbox': $value = empty($value) ? '' : ($value < 0 ? L\get('no') : L\get('yes')); break; case '_sex': switch ($value) { case 'm': $value = L\get('male'); break; case 'f': $value = L\get('female'); break; default: $value = ''; } break; case '_language': @($value = @\CB\Config::get('language_settings')[\CB\Config::get('languages')[$value - 1]][0]); break; case 'combo': case '_objects': if (empty($value)) { $value = ''; break; } $ids = Util\toNumericArray($value); if (empty($ids)) { if (empty($field['cfg']['source']) || !is_array($field['cfg']['source'])) { $value = ''; } break; } $value = array(); if (in_array(@$field['cfg']['source'], array('users', 'groups', 'usersgroups'))) { $udp = UsersGroups::getDisplayData($ids); foreach ($ids as $id) { if (empty($udp[$id])) { continue; } $r =& $udp[$id]; $label = @htmlspecialchars(Util\coalesce($r['title'], $r['name']), ENT_COMPAT); if ($html) { switch (@$field['cfg']['renderer']) { case 'listGreenIcons': $label = '<li class="icon-padding icon-element">' . $label . '</li>'; break; // case 'listObjIcons': // case 'listObjIcons': default: $icon = empty($r['iconCls']) ? 'icon-none' : $r['iconCls']; $label = '<li class="icon-padding ' . $icon . '">' . $label . '</li>'; break; } } $value[] = $label; } } else { $objects = \CB\Objects::getCachedObjects($ids); foreach ($ids as $id) { if (empty($objects[$id])) { continue; } $obj =& $objects[$id]; $d = $obj->getData(); $label = $obj->getHtmlSafeName(); $pids = $d['pids']; if ($html && !empty($pids)) { $pids = str_replace(',', '/', $pids); $linkType = empty($field['cfg']['linkType']) ? '' : 'link-type-' . $field['cfg']['linkType']; $label = '<a class="click ' . $linkType . '" template_id="' . $d['template_id'] . '" path="' . $pids . '" nid="' . $id . '">' . $label . '</a>'; } switch (@$field['cfg']['renderer']) { case 'listGreenIcons': $value[] = $html ? '<li class="icon-padding icon-element">' . $label . '</li>' : $label; break; // case 'listObjIcons': // case 'listObjIcons': default: $icon = \CB\Browser::getIcon($d); if (empty($icon)) { $icon = 'icon-none'; } $value[] = $html ? '<li class="icon-padding ' . $icon . '">' . $label . '</li>' : $label; break; } } } $value = $html ? '<ul class="clean">' . implode('', $value) . '</ul>' : implode(', ', $value); break; case '_fieldTypesCombo': $value = L\get(@static::$fieldTypeNames[$value]); break; case 'date': $value = Util\formatMysqlDate(Util\dateISOToMysql($value)); break; case 'datetime': $value = Util\UTCTimeToUserTimezone($value); break; case 'time': if (empty($value)) { continue; } $format = empty($field['format']) ? 'H:i' : $field['format']; if (is_numeric($value)) { $s = $value % 60; $value = floor($value / 60); $m = $value % 60; $value = floor($value / 60); if (strlen($value) < 2) { $value = '0' . $value; } if (strlen($m) < 2) { $m = '0' . $m; } $value .= ':' . $m; if (!empty($s)) { if (strlen($s) < 2) { $s = '0' . $s; } $value .= ':' . $s; } } else { $date = \DateTime::createFromFormat($format, $value); if (is_object($date)) { $value = $date->format($format); } } break; case 'html': $cacheValue = false; // $value = trim(strip_tags($value)); // $value = nl2br($value); break; case 'varchar': case 'memo': case 'text': $cacheValue = false; $renderers = ''; if (!empty($field['cfg']['linkRenderers'])) { $renderers = $field['cfg']['linkRenderers']; } elseif (!empty($field['cfg']['text_renderer'])) { $renderers = $field['cfg']['text_renderer']; } $value = empty($renderers) ? nl2br(htmlspecialchars($value, ENT_COMPAT)) : nl2br(Comment::processAndFormatMessage($value), $renderers); break; default: if (is_array($value)) { $cacheValue = false; $value = Util\jsonEncode($value); } else { $value = htmlspecialchars($value, ENT_COMPAT); } } } if ($cacheValue) { Cache::set($cacheVarName, $condition . $value); } return $condition . $value; }
/** * Get the list of active users with basic data * @return array */ public static function getActiveUsers() { $rez = array('success' => true, 'data' => array()); // $photosPath = Config::get('photos_path'); $users = DM\UsersGroups::getAvailableUsers(); foreach ($users as $r) { $r['user'] = $r['name']; $r['name'] = User::getDisplayName($r); $r['photo'] = User::getPhotoParam($r); $rez['data'][] = $r; } return $rez; }
/** * process a message: * - replace urls with links * - replace object references with links * @param varchar $message */ public static function processAndFormatMessage($message, $replacements = 'user,object,url') { if (empty($message)) { return $message; } $replacements = Util\toTrimmedArray($replacements); // replace urls with links if (in_array('url', $replacements)) { $message = \Kwi\UrlLinker::getInstance()->linkUrlsAndEscapeHtml($message); } //replace object references with links if (in_array('object', $replacements) && preg_match_all('/(.?)#(\\d+)(.?)/', $message, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { // check if not a html code if ($match[1] == '&' && $match[3] == ';') { continue; } $templateId = Objects::getTemplateId($match[2]); $name = Objects::getName($match[2]); $name = strlen($name) > 30 ? mb_substr($name, 0, 30) . '…' : $name; $message = str_replace($match[0], $match[1] . '<a class="click obj-ref" itemid="' . $match[2] . '" templateid= "' . $templateId . '" title="' . $name . '"' . '>#' . $match[2] . '</a>' . $match[3], $message); } } //replace users with their names if (in_array('user', $replacements) && preg_match_all('/@([\\w\\.\\-]+[\\w])/', $message, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $userId = DM\User::getIdByName($match[1]); if (is_numeric($userId)) { $userName = $match[1]; $message = str_replace($match[0], '<span class="cDB user-ref" title="' . User::getDisplayName($userId) . '">@' . $userName . '</span>', $message); } } } return $message; }
public function getLogRecords() { $s = Log::getSolrLogConnection(); $this->requestParams['sort'] = array('action_date desc'); $p = array('rows' => 50, 'fl' => 'id,action_id,user_id,object_id,object_pid,object_data', 'fq' => $this->fq, 'strictSort' => 'action_date desc'); $id = substr($this->lastNode->id, 1); switch (substr($this->lastNode->id, 0, 1)) { case 'd': $p['fq'][] = 'action_date:["' . $id . 'T00:00:00Z" TO "' . $id . 'T23:59:99Z"]'; break; case 'm': $p['fq'][] = 'action_date:["' . date('Y-m') . '-01T00:00:00Z" TO *]'; break; case 't': $p['fq'][] = 'action_type:' . $id; break; case 'u': $p['fq'][] = 'user_id:' . $id; break; case 't': $p['fq'][] = 'action_type:' . $id; break; } $rez = $s->query($p); foreach ($rez['data'] as &$doc) { $k = @$doc['action_id']; $data = Util\toJSONArray($doc['object_data']); $doc['id'] = $this->getId($k); $doc['pid'] = @$doc['object_pid']; unset($doc['object_pid']); $doc['name'] = Util\coalesce($data['name'], $doc['object_data']); $doc['iconCls'] = $data['iconCls']; $doc['path'] = $data['path']; // $doc['template_id'] = $data['template_id']; $doc['case_id'] = $data['case_id']; if ($data['date']) { $doc['date'] = $data['date']; } $doc['size'] = $data['size']; $doc['cid'] = @$data['cid']; $doc['oid'] = @$data['oid']; $doc['uid'] = @$data['uid']; $doc['cdate'] = $data['cdate']; $doc['udate'] = $data['udate']; $doc['user'] = User::getDisplayName($doc['user_id'], true); $doc['has_childs'] = false; } return $rez; }
function beforeLock($path, \Sabre\DAV\Locks\LockInfo $lock) { $lock->owner = \CB\User::getDisplayName($_SESSION['user']['id']); // error_log('beforeLock: ' . $lock->owner); return true; }