コード例 #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
ファイル: Objects.php プロジェクト: ameliefranco/casebox
 /**
  * update own comment
  * @param array $p input params (id, msg)
  */
 public function updateComment($p)
 {
     $rez = array('success' => false);
     if (empty($p['id']) || !is_numeric($p['id']) || empty($p['text'])) {
         $rez['msg'] = L\get('Wrong_input_data');
         return $rez;
     }
     $comment = static::getCustomClassByObjectId($p['id']);
     $commentData = $comment->load();
     if ($commentData['cid'] == $_SESSION['user']['id']) {
         $commentData['data']['_title'] = $p['text'];
         $comment->update($commentData);
         Solr\Client::runCron();
         $rez = array('success' => true, 'data' => \CB\Objects\Plugins\Comments::loadComment($commentData['id']));
     }
     return $rez;
 }