コード例 #1
0
ファイル: ActivityStream.php プロジェクト: youprofit/casebox
 public function onSolrQuery(&$p)
 {
     $result =& $p['result'];
     $data =& $result['data'];
     $actionLogIds = array();
     $comments = new Objects\Plugins\Comments();
     //format ago date and collect log action ids
     foreach ($data as &$doc) {
         $la = Objects::getCachedObject($doc['id'])->getLastActionData();
         $la['agoText'] = Util\formatAgoTime($la['time']);
         $la['uids'] = array_reverse(array_keys($la['users']));
         $doc['lastAction'] = $la;
         $actionLogId = $la['users'][$la['uids'][0]];
         $doc['comments'] = $comments->getData($doc['id']);
         $actionLogIds[$actionLogId] =& $doc;
     }
     $logRecs = DM\Log::getRecords(array_keys($actionLogIds));
     foreach ($logRecs as $r) {
         $d = Util\jsonDecode($r['data']);
         $obj = Objects::getCachedObject($actionLogIds[$r['id']]['id']);
         $diff = $obj->getDiff($d);
         if (!empty($diff)) {
             $html = '';
             foreach ($diff as $fn => $fv) {
                 $html .= "<tr><th>{$fn}</th><td>{$fv}</td></tr>";
             }
             $actionLogIds[$r['id']]['diff'] = "<table class=\"as-diff\">{$html}</table>";
         }
     }
 }
コード例 #2
0
ファイル: ObjectProperties.php プロジェクト: sebbie42/casebox
 public function getData($id = false)
 {
     $rez = array('success' => true);
     parent::getData($id);
     $preview = Objects::getPreview($this->id);
     $obj = Objects::getCachedObject($this->id);
     if (empty($obj)) {
         return $rez;
     }
     $data = $obj->getData();
     if (!empty($preview)) {
         $rez['data'] = array('preview' => $preview);
     }
     if (!empty($data)) {
         if (!empty($data['pids'])) {
             $path = explode(',', $data['pids']);
             array_pop($path);
             $rez['data']['pids'] = $rez['data']['path'] = implode('/', $path);
             $arr = array(&$rez['data']);
             Search::setPaths($arr);
         }
         foreach ($data as $k => $v) {
             if (in_array($k, array('id', 'template_id', 'date_end', 'cid', 'uid', 'cdate', 'udate'))) {
                 if (in_array($k, array('date', 'date_end', 'cdate', 'udate'))) {
                     $v = Util\dateMysqlToISO($v);
                 }
                 $rez['data'][$k] = $v;
                 //add ago udate text
                 if (in_array($k, array('cdate', 'udate'))) {
                     $rez['data'][$k . '_ago_text'] = Util\formatAgoTime($v);
                 }
             }
         }
         $rez['data']['name'] = $obj->getName();
     }
     $rez['data']['can'] = $obj->getActionFlags();
     //set status info for tasks if not active
     if ($obj->getType() == 'task') {
         $d =& $rez['data'];
         $d['status'] = '';
         switch ($obj->getStatus()) {
             case Objects\Task::$STATUS_ACTIVE:
                 break;
             case Objects\Task::$STATUS_CLOSED:
                 //just add title css class and continue with default
                 $d['titleCls'] = 'task-completed';
                 // break;
             // break;
             default:
                 $d['status'] = $obj->getStatusText();
                 $d['statusCls'] = $obj->getStatusCSSClass();
         }
     }
     return $rez;
 }
コード例 #3
0
ファイル: Files.php プロジェクト: sebbie42/casebox
 public function getData($id = false)
 {
     $rez = array('success' => true, 'data' => array());
     if (empty(parent::getData($id))) {
         return $rez;
     }
     $params = array('pid' => $this->id, 'fq' => array('(template_type:file) OR (target_type:file)'), 'fl' => 'id,pid,name,template_id,size,cdate', 'sort' => 'cdate', 'dir' => 'desc');
     $s = new \CB\Search();
     $sr = $s->query($params);
     foreach ($sr['data'] as $d) {
         $d['ago_text'] = Util\formatAgoTime($d['cdate']);
         $rez['data'][] = $d;
     }
     return $rez;
 }
コード例 #4
0
 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;
 }
コード例 #5
0
ファイル: Versions.php プロジェクト: austinvernsonger/casebox
 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;
 }
コード例 #6
0
ファイル: Objects.php プロジェクト: youprofit/casebox
 /**
  * load object and return json responce
  * @param  array $p array containing id of object
  * @return json  responce
  */
 public function load($p)
 {
     $rez = array();
     // check if object id is numeric
     if (!is_numeric($p['id'])) {
         throw new \Exception(L\get('Wrong_input_data'));
     }
     $id = $p['id'];
     // Access check
     if (!Security::canRead($id)) {
         throw new \Exception(L\get('Access_denied'));
     }
     $object = $this->getCustomClassByObjectId($id) or die(L\get('Wrong_input_data'));
     $object->load();
     $objectData = $object->getData();
     $template = $object->getTemplate();
     $templateData = $template->getData();
     $resultData = array();
     /* select only required properties for result */
     $properties = array('id', 'pid', 'template_id', 'name', 'date', 'date_end', 'pids', 'path', 'cid', 'uid', 'cdate', 'udate', 'case_id', 'status', 'data', 'can');
     foreach ($properties as $property) {
         if (isset($objectData[$property])) {
             $resultData[$property] = $objectData[$property];
         }
     }
     /* rename some properties for gui */
     $resultData['date_start'] = @$resultData['date'];
     unset($resultData['date']);
     $arr = array(&$resultData);
     $pids = explode(',', $resultData['pids']);
     array_pop($pids);
     $resultData['pids'] = $resultData['path'] = implode('/', $pids);
     Search::setPaths($arr);
     // $resultData['pathtext'] = $resultData['path'];
     // $resultData['path'] = str_replace(',', '/', $resultData['pids']);
     // unset($resultData['pids']);
     $resultData['cdate_ago_text'] = Util\formatAgoTime($objectData['cdate']);
     $resultData['udate_ago_text'] = Util\formatAgoTime($objectData['udate']);
     // set type property from template
     $resultData['type'] = $templateData['type'];
     return array('success' => true, 'data' => $resultData, 'menu' => Browser\CreateMenu::getMenuForPath($p['id']));
 }
コード例 #7
0
ファイル: ContentItems.php プロジェクト: sebbie42/casebox
 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;
 }
コード例 #8
0
ファイル: Comments.php プロジェクト: sebbie42/casebox
 /**
  * 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']);
 }
コード例 #9
0
ファイル: SystemProperties.php プロジェクト: sebbie42/casebox
 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;
 }
コード例 #10
0
ファイル: Files.php プロジェクト: sebbie42/casebox
 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;
 }
コード例 #11
0
ファイル: Task.php プロジェクト: youprofit/casebox
 /**
  * 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;
 }
コード例 #12
0
ファイル: Files.php プロジェクト: austinvernsonger/casebox
 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;
 }