Esempio n. 1
0
 /**
  * read objects data in bulk manner
  * @param  array $ids
  * @return array
  */
 public static function read($ids)
 {
     $rez = array();
     $ids = Util\toNumericArray($ids);
     if (!empty($ids)) {
         $sql = 'SELECT t.*
                 ,ti.pids
                 ,ti.path
                 ,ti.case_id
                 ,ti.acl_count
                 ,ti.security_set_id
                 ,o.data
                 ,o.sys_data
             FROM tree t
             JOIN tree_info ti
                 ON t.id = ti.id
             LEFT JOIN objects o
                 ON t.id = o.id
             WHERE t.id in (' . implode(',', $ids) . ')';
         $res = DB\dbQuery($sql) or die(DB\dbQueryError());
         while ($r = $res->fetch_assoc()) {
             $r['data'] = Util\jsonDecode($r['data']);
             $r['sys_data'] = Util\jsonDecode($r['sys_data']);
             $rez[] = $r;
         }
         $res->close();
     }
     return $rez;
 }
Esempio n. 2
0
 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>";
         }
     }
 }
Esempio n. 3
0
 /**
  * get notifications that was not sent by mail yet
  *
  * @param  int   $userId optional
  * @return array
  */
 public static function getUnsent($userId = false)
 {
     $rez = array();
     //validate params
     \CB\raiseErrorIf($userId !== false && !is_numeric($userId), 'ErroneousInputData');
     $sql = 'SELECT
         n.id
         ,n.object_id
         ,n.action_type
         ,n.user_id `to_user_id`
         ,n.`from_user_id`
         ,l.object_pid
         ,l.action_time
         ,l.data
         ,l.activity_data_db
     FROM `' . static::getTableName() . '` n
         JOIN action_log l
             ON n.action_id = l.id
     WHERE n.email_sent = 0 ' . ($userId == false ? '' : ' AND user_id = $1 ') . 'ORDER BY n.user_id
        ,l.`action_time` DESC';
     $res = DB\dbQuery($sql, $userId) or die(DB\dbQueryError());
     while ($r = $res->fetch_assoc()) {
         $r['data'] = Util\jsonDecode($r['data']);
         $r['activity_data_db'] = Util\jsonDecode($r['activity_data_db']);
         $rez[] = $r;
     }
     $res->close();
     return $rez;
 }
Esempio n. 4
0
$isForm = false;
$isUpload = false;
if (!(php_sapi_name() == "cli")) {
    header('Content-Type: application/json; charset=UTF-8');
}
if (isset($_POST['extAction'])) {
    // form post
    $isForm = true;
    $isUpload = $_POST['extUpload'] == 'true';
    $data = array('action' => $_POST['extAction'], 'method' => $_POST['extMethod'], 'tid' => isset($_POST['extTID']) ? intval($_POST['extTID']) : null, 'data' => array($_POST, $_FILES));
} elseif (isset($postdata)) {
    $data = Util\jsonDecode($postdata);
} else {
    $postdata = file_get_contents("php://input");
    if (!empty($postdata)) {
        $data = Util\jsonDecode($postdata);
    }
}
if (empty($data)) {
    die('Invalid request.');
}
\CB\Cache::set('ExtDirectData', $data);
$response = null;
if (empty($data['action'])) {
    $response = array();
    foreach ($data as $d) {
        $response[] = doRpc(sanitizeParams($d));
    }
} else {
    $response = doRpc(sanitizeParams($data));
}
Esempio n. 5
0
 public function request($action, $method, $data = array())
 {
     $this->flush();
     $this->buildPostBody(array('action' => $action, 'method' => $method, 'data' => $data));
     $this->execute();
     $rez = $this->getResponseBody();
     $rez = Util\jsonDecode($rez);
     return $rez;
 }