Skip to content

Instantly share code, notes, and snippets.

@Viper-7
Forked from oojacoboo/actions.class.php
Created December 16, 2012 05:28

Revisions

  1. Viper-7 revised this gist Dec 16, 2012. 1 changed file with 40 additions and 24 deletions.
    64 changes: 40 additions & 24 deletions actions.class.php
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,40 @@
    $json['title'] = "Documents JSON";
    $json['description'] = "All the documents per company";
    $json['generator'] = "https://xxxxx.com/";

    $json['documents'] = array();
    foreach($docs as $doc) {
    Debug::toLog($doc->getId());

    $json['documents'][$doc->getId()]['id'] = $doc->getId();
    $json['documents'][$doc->getId()]['groupId'] = $doc->getDocumentGroupId();
    $json['documents'][$doc->getId()]['groupName'] = $doc->getDocumentGroup()->getName();
    $json['documents'][$doc->getId()]['updatedAt'] = $this->getUser()->getProfile()->toUserTimezone($doc->getUpdatedAt("U"), "M. j, Y");
    $json['documents'][$doc->getId()]['nickname'] = $doc->getNickname();
    $json['documents'][$doc->getId()]['filesize'] = $doc->getFilesize();
    $json['documents'][$doc->getId()]['icon'] = $doc->getIcon("small");
    }

    $json['docGroups'] = array();
    foreach($docGroups as $docGroup) {
    $json['docGroups'][$docGroup->getId()]['id'] = $docGroup->getId();
    $json['docGroups'][$docGroup->getId()]['name'] = $docGroup->getName();
    }

    return $this->renderText(json_encode($json));
    <?php
    $json['title'] = "Documents JSON";
    $json['description'] = "All the documents per company";
    $json['generator'] = "https://xxxxx.com/";



    $json['documents'] = array();

    foreach($docs as $doc) {
    Debug::toLog($doc->getId());

    $item = array();

    $item['id'] = $doc->getId();
    $item['groupId'] = $doc->getDocumentGroupId();
    $item['groupName'] = $doc->getDocumentGroup()->getName();
    $item['updatedAt'] = $this->getUser()->getProfile()->toUserTimezone($doc->getUpdatedAt("U"), "M. j, Y");
    $item['nickname'] = $doc->getNickname();
    $item['filesize'] = $doc->getFilesize();
    $item['icon'] = $doc->getIcon("small");

    $json['documents'][] = $item;
    }



    $json['docGroups'] = array();

    foreach($docGroups as $docGroup) {
    $item = array();
    $item['id'] = $docGroup->getId();
    $item['name'] = $docGroup->getName();

    $json['docGroups'][] = $item;
    }



    return $this->renderText(json_encode($json));
  2. Jacob Thomason created this gist Dec 16, 2012.
    24 changes: 24 additions & 0 deletions actions.class.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    $json['title'] = "Documents JSON";
    $json['description'] = "All the documents per company";
    $json['generator'] = "https://xxxxx.com/";

    $json['documents'] = array();
    foreach($docs as $doc) {
    Debug::toLog($doc->getId());

    $json['documents'][$doc->getId()]['id'] = $doc->getId();
    $json['documents'][$doc->getId()]['groupId'] = $doc->getDocumentGroupId();
    $json['documents'][$doc->getId()]['groupName'] = $doc->getDocumentGroup()->getName();
    $json['documents'][$doc->getId()]['updatedAt'] = $this->getUser()->getProfile()->toUserTimezone($doc->getUpdatedAt("U"), "M. j, Y");
    $json['documents'][$doc->getId()]['nickname'] = $doc->getNickname();
    $json['documents'][$doc->getId()]['filesize'] = $doc->getFilesize();
    $json['documents'][$doc->getId()]['icon'] = $doc->getIcon("small");
    }

    $json['docGroups'] = array();
    foreach($docGroups as $docGroup) {
    $json['docGroups'][$docGroup->getId()]['id'] = $docGroup->getId();
    $json['docGroups'][$docGroup->getId()]['name'] = $docGroup->getName();
    }

    return $this->renderText(json_encode($json));