/** * create an object with specified params * @param array $p object properties * @return int created id */ public function create($p = false) { if ($p !== false) { if (array_key_exists('id', $p)) { if (is_numeric($p['id'])) { $this->id = $p['id']; } else { $this->id = null; unset($p['id']); } } $this->data = $p; unset($this->linearData); $this->template = null; if (!empty($this->data['template_id']) && $this->loadTemplate) { $this->template = \CB\Templates\SingletonCollection::getInstance()->getTemplate($this->data['template_id']); } } //check if there is defaultPid specified in template config if (!empty($this->template)) { $templateData = $this->template->getData(); if (!empty($templateData['cfg']['defaultPid'])) { $this->data['pid'] = $templateData['cfg']['defaultPid']; } } \CB\fireEvent('beforeNodeDbCreate', $this); $p =& $this->data; if (!Security::canCreateActions($p['pid'])) { throw new \Exception(L\get('Access_denied')); } // check input params if (!isset($p['pid'])) { throw new \Exception("No pid specified for object creation", 1); } if (empty($p['name'])) { throw new \Exception("No name specified for object creation", 1); } // we admit object creation without template id // if (empty($p['template_id']) || !is_numeric($p['template_id'])) { // throw new \Exception("No template_id specified for object creation", 1); // } $this->id = DM\Tree::create($this->collectModelData()); if (!isset($this->id) || !(intval($this->id) > 0)) { trigger_error('Error on create object : ' . \CB\Cache::get('lastSql'), E_USER_ERROR); } $p['id'] = $this->id; $this->createCustomData(); $this->checkDraftChilds(); //load the object from db to have all its created data $this->load(); //fire create event \CB\fireEvent('nodeDbCreate', $this); $this->logAction('create', array('mentioned' => $this->lastMentionedUserIds)); return $this->id; }
public function getName($id = false) { if ($id === false) { $id = $this->id; } switch ($id) { case 1: return L\get('MyCalendar'); } return 'none'; }
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; }
/** * add a record * @param array $p associative array with table field values * @return int created id */ public static function create($p) { parent::create($p); if (empty($p['name'])) { trigger_error(L\get('ErroneousInputData') . ' Empty name for GUID.', E_USER_ERROR); } //prepare params //add database record $sql = 'INSERT INTO ' . \CB\PREFIX . '_casebox.guids (`name`) VALUES ($1)'; DB\dbQuery($sql, $p['name']) or die(DB\dbQueryError()); $rez = DB\dbLastInsertId(); return $rez; }
public function getName($id = false) { if ($id == false) { $id = $this->id; } switch ($id) { case 1: return lcfirst(L\get('Overdue')); case 2: return lcfirst(L\get('Ongoing')); case 3: return lcfirst(L\get('Closed')); } return 'none'; }
public function getName($id = false) { if ($id === false) { $id = $this->id; } $rez = $id; switch ($id) { case 'recycleBin': return L\get('RecycleBin'); default: if (!empty($id) && is_numeric($id)) { $rez = \CB\Objects::getName($id); } break; } return $rez; }
public function getName($id = false) { if ($id == false) { $id = $this->id; } switch ($id) { case 1: return L\get('Manager'); case 2: return L\get('Lead'); case 3: return L\get('Support'); case 4: return L\get('AllMyCases'); } return Objects::getName($id); }
public function getName($id = false) { if ($id === false) { $id = $this->id; } $rez = $id; switch ($id) { case 'recent': case 'commented': case 'modified': case 'added': return L\get(ucfirst($id)); default: $rez = Objects::getName($id); break; } return $rez; }
public function getName($id = false) { if ($id === false) { $id = $this->id; } $rez = $id; switch ($id) { case 'favorites': return L\get('Favorites'); default: /*if (!empty($id) && is_numeric($id)) { $d = DM\Favorites::read($id); $rez = Util\toJSONArray($d['data'])['name']; }/**/ break; } return $rez; }
public function getName($id = false) { if ($id === false) { $id = $this->id; } $rez = $id; switch (substr($id, 0, 1)) { case 'a': $rez = L\get('ActionLog'); break; case 'd': $rez = Util\formatAgoDate(substr($id, 1, 10)); break; case 'm': $rez = L\get('CurrentMonth'); break; case 'g': $rez = L\get('Users'); break; case 'q': $rez = L\get('Type'); break; case 'u': $rez = User::getDisplayName(substr($id, 1)); break; case 't': $rez = Util\coalesce(L\get('at' . substr($id, 1)), substr($id, 1)); break; default: if (!empty($id) && is_numeric($id)) { $res = DB\dbQuery('SELECT data FROM action_log WHERE id = $1', $id) or die(DB\dbQueryError()); if ($r = $res->fetch_assoc()) { $j = Util\toJSONArray($r['data']); $rez = Util\coalesce($j['name'], 'unknown'); } $res->close(); } break; } return $rez; }
public function getName($id = false) { if ($id === false) { $id = $this->id; } $rez = $id; switch (substr($id, 0, 1)) { case 'a': $rez = L\get('ActionLog'); break; case 'd': $rez = Util\formatAgoDate(substr($id, 1, 10)); break; case 'm': $rez = L\get('CurrentMonth'); break; case 'g': $rez = L\get('Users'); break; case 'q': $rez = L\get('Type'); break; case 'u': $rez = User::getDisplayName(substr($id, 1)); break; case 't': $rez = Util\coalesce(L\get('at' . substr($id, 1)), substr($id, 1)); break; default: if (!empty($id) && is_numeric($id)) { $r = DM\Log::read($id); if (!empty($r)) { $rez = Util\coalesce($r['data']['name'], 'unknown'); } } break; } return $rez; }
public function getTitle() { $rez = 'Facet'; $coreLanguage = \CB\Config::get('language'); $userLanguage = \CB\Config::get('user_language'); if (!empty($this->config['title'])) { $t =& $this->config['title']; if (is_scalar($t)) { $rez = $t; if ($t[0] == '[') { $rez = L\get(substr($t, 1, strlen($t) - 2)); if (empty($rez)) { $rez = $t; } } } elseif (!empty($t[$userLanguage])) { $rez = $t[$userLanguage]; } elseif (!empty($t[$coreLanguage])) { $rez = $t[$coreLanguage]; } } 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; }
/** * change status for a task * @param int $status * @param int $id * @return json response */ protected function changeStatus($id, $status) { $obj = Objects::getCachedObject($id); $data = $obj->getData(); //status change for task is allowed only for owner or admin if (!$obj->isOwner() && !Security::isAdmin()) { return array('success' => false, 'msg' => L\get('No_access_for_this_action')); } switch ($status) { case Objects\Task::$STATUS_ACTIVE: $obj->setActive(); break; case Objects\Task::$STATUS_CLOSED: $obj->setClosed(); break; default: return array('success' => false, 'id' => $id); } $this->afterUpdate($id); return array('success' => true, 'id' => $id); }
protected function getDepthChildren3() { $userId = User::getId(); $p = $this->requestParams; $p['fq'] = $this->fq; if ($this->lastNode->id == 2) { $p['fq'][] = 'task_u_ongoing:' . $userId; } else { $p['fq'][] = 'cid:' . $userId; } $rez = array(); if (@$this->requestParams['from'] == 'tree') { $s = new \CB\Search(); $sr = $s->query(array('rows' => 0, 'fq' => $p['fq'], 'facet' => true, 'facet.field' => array('{!ex=task_status key=0task_status}task_status'))); $rez = array('data' => array()); if (!empty($sr['facets']->facet_fields->{'0task_status'}->{'1'})) { $rez['data'][] = array('name' => lcfirst(L\get('Overdue')) . $this->renderCount($sr['facets']->facet_fields->{'0task_status'}->{'1'}), 'id' => $this->getId(4), 'iconCls' => 'icon-task'); } if (!empty($sr['facets']->facet_fields->{'0task_status'}->{'2'})) { $rez['data'][] = array('name' => lcfirst(L\get('Ongoing')) . $this->renderCount($sr['facets']->facet_fields->{'0task_status'}->{'2'}), 'id' => $this->getId(5), 'iconCls' => 'icon-task'); } if (!empty($sr['facets']->facet_fields->{'0task_status'}->{'3'})) { $rez['data'][] = array('name' => lcfirst(L\get('Closed')) . $this->renderCount($sr['facets']->facet_fields->{'0task_status'}->{'3'}), 'id' => $this->getId(6), 'iconCls' => 'icon-task'); } // Add assignee node if there are any created tasks already added to result if ($this->lastNode->id == 3 && !empty($rez['data'])) { $rez['data'][] = array('name' => lcfirst(L\get('Assignee')), 'id' => $this->getId('assignee'), 'iconCls' => 'icon-task', 'has_childs' => true); } } else { $p['fq'][] = 'task_status:(1 OR 2)'; $s = new \CB\Search(); $rez = $s->query($p); foreach ($rez['data'] as &$n) { $n['has_childs'] = true; } } return $rez; }
public function getName($id = false) { if ($id == false) { $id = $this->id; } $rez = 'no name'; if ($id == 'cases') { return L\get('Cases'); } $res = DB\dbQuery('SELECT name FROM tree WHERE id = $1', $id) or die(DB\dbQueryError()); if ($r = $res->fetch_assoc()) { $rez = $r['name']; } $res->close(); return $rez; }
/** * validate param types * @param array $p * @param array $fields - default is $tableFields * @return void | throws an exception on error */ protected static function validateParamTypes($p, $fields = false) { if ($fields === false) { $fields = static::$tableFields; } foreach ($fields as $fn => $ft) { $valid = true; if (!isset($p[$fn]) || is_null($p[$fn])) { continue; } switch ($ft) { case 'int': case 'float': $valid = is_numeric($p[$fn]); break; case 'bool': $valid = is_bool($p[$fn]); break; case 'char': $valid = is_string($p[$fn]) && mb_strlen($p[$fn]) < 2; break; case 'enum': case 'varchar': case 'text': $valid = is_string($p[$fn]); break; case 'time': case 'timestamp': case 'date': $dt = explode(' ', $p[$fn]); $valid = sizeof($dt) < 3; if ($valid) { $d = explode('-', $dt[0]); $valid = sizeof($dt) == 3; if ($valid) { $valid = is_numeric($d[0]) && is_numeric($d[1]) && is_numeric($d[2]); } } if ($valid && !empty($dt[1])) { $t = explode(':', $dt[1]); $valid = sizeof($dt) < 4; if ($valid) { $valid = is_numeric($t[0]) && is_numeric($t[1]) && (empty($t[2]) || is_numeric($t[2])); } } break; } if (!$valid) { trigger_error(L\get('ErroneousInputData') . ' Invalid value for field "' . $fn . '"', E_USER_ERROR); } } }
public function getClientData() { $rez = array('f' => $this->field, 'title' => $this->getTitle(), 'items' => array()); $cfg =& $this->config; if (!empty($cfg['manualPeriod'])) { $rez['manualPeriod'] = true; } foreach ($cfg['queries'] as $key => $query) { $qk = $cfg['name'] . '_' . $key; if (!empty($this->solrData[$query])) { $name = L\get($query); if (empty($name)) { $name = $query; } $rez['items'][$query] = array('name' => $name, 'count' => $this->solrData[$query]); } } return $rez; }
/** * create an object with specified params * @param array $p object properties * @return int created id */ public function create($p = false) { if ($p !== false) { if (array_key_exists('id', $p)) { if (is_numeric($p['id'])) { $this->id = $p['id']; } else { $this->id = null; unset($p['id']); } } $this->data = $p; unset($this->linearData); $this->template = null; if (!empty($this->data['template_id']) && $this->loadTemplate) { $this->template = \CB\Templates\SingletonCollection::getInstance()->getTemplate($this->data['template_id']); } } //check if there is defaultPid specified in template config if (!empty($this->template)) { $templateData = $this->template->getData(); if (!empty($templateData['cfg']['defaultPid'])) { $this->data['pid'] = $templateData['cfg']['defaultPid']; } } \CB\fireEvent('beforeNodeDbCreate', $this); $p =& $this->data; if (!Security::canCreateActions($p['pid'])) { throw new \Exception(L\get('Access_denied')); } // check input params if (!isset($p['pid'])) { throw new \Exception("No pid specified for object creation", 1); } if (empty($p['name'])) { throw new \Exception("No name specified for object creation", 1); } // we admit object creation without template id // if (empty($p['template_id']) || !is_numeric($p['template_id'])) { // throw new \Exception("No template_id specified for object creation", 1); // } if (empty($p['pid'])) { $p['pid'] = null; } $draftPid = empty($p['draftPid']) ? null : $p['draftPid']; $isDraft = intval(!empty($draftPid) || !empty($p['draft'])); if (empty($p['date_end'])) { $p['date_end'] = null; } if (empty($p['tag_id'])) { $p['tag_id'] = null; } if (empty($p['cid'])) { $p['cid'] = $_SESSION['user']['id']; } if (empty($p['oid'])) { $p['oid'] = $p['cid']; } if (empty($p['cdate'])) { $p['cdate'] = null; } DB\dbQuery('INSERT INTO tree ( id ,pid ,draft ,draft_pid ,template_id ,tag_id ,target_id ,name ,date ,date_end ,size ,cfg ,cid ,oid ,cdate ,`system` ,updated ) VALUES ( $1 ,$2 ,$3 ,$4 ,$5 ,$6 ,$7 ,$8 ,$9 ,$10 ,$11 ,$12 ,$13 ,$14 ,COALESCE($15, CURRENT_TIMESTAMP) ,$16 ,1 )', array($this->id, $p['pid'], $isDraft, $draftPid, $p['template_id'], $p['tag_id'], @$p['target_id'], $p['name'], @$p['date'], @$p['date_end'], @$p['size'], @Util\jsonEncode($p['cfg']), @$p['cid'], @$p['oid'], @$p['cdate'], @intval($p['system']))) or die(DB\dbQueryError()); $this->id = DB\dbLastInsertId(); $p['id'] = $this->id; $this->createCustomData(); $this->checkDraftChilds(); //load the object from db to have all its created data $this->load(); //fire create event \CB\fireEvent('nodeDbCreate', $this); $this->logAction('create'); return $this->id; }
/** * 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; }
function formatLeftDays($days_difference) { if ($days_difference == 0) { return L\get('today'); } if ($days_difference < 0) { return ''; } elseif ($days_difference == 1) { return L\get('tomorow'); } elseif ($days_difference < 21) { return $days_difference . ' ' . L\get('ofDays'); } return ''; }
/** * create shorcut(s) * @param object $p input params * @return json responce */ public function shortcut($p) { if (!$this->validateParams($p)) { return array('success' => false, 'msg' => L\get('ErroneousInputData')); } /* security checks */ foreach ($p['sourceIds'] as $sourceId) { if (!\CB\Security::canRead($sourceId)) { return array('success' => false, 'msg' => L\get('Access_denied')); } } if (!\CB\Security::canWrite($p['targetId'])) { return array('success' => false, 'msg' => L\get('Access_denied')); } $rez = array('success' => true, 'targetId' => $p['targetId'], 'processedIds' => array()); $shortcutObject = new Objects\Shortcut(); foreach ($p['sourceIds'] as $id) { $rez['processedIds'][] = $shortcutObject->create(array('id' => null, 'pid' => $p['targetId'], 'target_id' => $id)); } Solr\Client::runCron(); return $rez; }
/** * get actions html row for preview * @return array */ public function getPreviewActionsRow() { $rez = array(); $flags = $this->getActionFlags(); foreach ($flags as $k => $v) { if (!empty($v)) { $rez[] = "<a action=\"{$k}\" class=\"item-action ib-{$k}\">" . L\get(ucfirst($k)) . '</a>'; } } $rez = empty($rez) ? '' : '<div class="task-actions">' . implode(' ', $rez) . '</div>'; return $rez; }