Beispiel #1
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;
 }
Beispiel #2
0
 /**
  * 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']));
 }
Beispiel #3
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;
 }