controller/pagecontroller.php
/**
	 * XHR request endpoint for getting publish command
	 * @NoAdminRequired
	 */
XHR request endpoint for getting publish command
@NoAdminRequired
XHR request endpoint for getting publish command @NoAdminRequired
public function publish(){
		$param = $this->request->getParams();
		if(!is_array($param)){
			return new DataResponse(["error"=>"expected array"]);
		}
		if(!array_key_exists('id', $param)){
			return new DataResponse(["error"=>"no `id` present"]);
		}
		$id = (int) $param['id'];
		if(!is_int($id)){
			return new DataResponse(["error"=>"expected integer"]);
		}
		$userId = \OC::$server->getUserSession()->getUser()->getUID();
		if(strlen($userId) <= 0){
			return new DataResponse(["error"=>"no `userId` present"]);
		}
		$job = new \OCA\MyApp\Transfer();
		$fcStatus = new FilecacheStatus();
		$fcStatus->setFileid($id);
		$fcStatus->setStatus("new");
		$fcStatus->setCreatedAt(time());
		$fcStatus->setUpdatedAt(time());
		$this->mapper->insert($fcStatus);
		\OC::$server->getJobList()->add($job, ["fileId" => $id, "userId" => $userId, "requestDate" => time()]);
		return new DataResponse(["publish" => ["name" => ""]]);
	}
public function publish ( ) { $ param = $ this -> request -> getParams ( ) ; if ( ! is_array ( $ param ) ) { return new DataResponse ( [ " error " => " expected array " ] ) ; } if ( ! array_key_exists ( 'id' , $ param ) ) { return new DataResponse ( [ " error " => " no `id` present " ] ) ; } $ id = ( int ) $ param [ 'id' ] ; if ( ! is_int ( $ id ) ) { return new DataResponse ( [ " error " => " expected integer " ] ) ; } $ userId = \ OC :: $ server -> getUserSession ( ) -> getUser ( ) -> getUID ( ) ; if ( strlen ( $ userId ) <= 0 ) { return new DataResponse ( [ " error " => " no `userId` present " ] ) ; } $ job = new \ OCA \ MyApp \ Transfer ( ) ; $ fcStatus = new FilecacheStatus ( ) ; $ fcStatus -> setFileid ( $ id ) ; $ fcStatus -> setStatus ( " new " ) ; $ fcStatus -> setCreatedAt ( time ( ) ) ; $ fcStatus -> setUpdatedAt ( time ( ) ) ; $ this -> mapper -> insert ( $ fcStatus ) ; \ OC :: $ server -> getJobList ( ) -> add ( $ job , [ " fileId " => $ id , " userId " => $ userId , " requestDate " => time ( ) ] ) ; return new DataResponse ( [ " publish " => [ " name " => " " ] ] ) ; }
XHR request endpoint for getting publish command
 @NoAdminRequired
XHR request endpoint for getting publish command @NoAdminRequired
// create new publish job //TODO: perhaps we should add a duplicate publish check here! // register transfer job // TODO: respond with success