예제 #1
0
 /**
  * load next set of comments (not all are loaded by default)
  * @param  array $p
  * @return json  response
  */
 public function loadMore($p)
 {
     $rez = array('success' => true, 'data' => array());
     if (empty(parent::getData($p['id']))) {
         return $rez;
     }
     $commentTemplateIds = DM\Templates::getIdsByType('comment');
     if (empty($commentTemplateIds)) {
         return $rez;
     }
     $limit = empty($p['beforeId']) ? 4 : 10;
     $limit = Config::get('max_load_comments', $limit);
     $params = array('pid' => $this->id, 'system' => '[0 TO 2]', 'fq' => array('template_id:(' . implode(' OR ', $commentTemplateIds) . ')'), 'fl' => 'id,pid,template_id,cid,cdate,content', 'strictSort' => 'cdate desc', 'rows' => $limit);
     if (!empty($p['beforeId']) && is_numeric($p['beforeId'])) {
         $params['fq'][] = 'id:[* TO ' . ($p['beforeId'] - 1) . ']';
     }
     $s = new \CB\Search();
     $sr = $s->query($params);
     if (empty($p['beforeId'])) {
         $rez['total'] = $sr['total'];
     }
     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 $rez;
 }
예제 #2
0
파일: Thumb.php 프로젝트: sebbie42/casebox
 protected function getObjectClass()
 {
     $rez = parent::getObjectClass();
     if (!empty($rez)) {
         $rez->load();
     }
     return $rez;
 }
예제 #3
0
 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;
 }
예제 #4
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;
 }
예제 #5
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;
 }
예제 #6
0
 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;
 }
예제 #7
0
파일: Tasks.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: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;
 }
예제 #8
0
 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;
 }
예제 #9
0
 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;
 }