Example #1
0
 /**
  * Update a local resource with data.
  */
 public function updateResource($slug, $updateInfo)
 {
     global $wpdb;
     $data = $updateInfo->getData();
     $binaryDataFileName = $updateInfo->getBinaryDataFileName();
     //error_log("update with binary in h5p: ".$binaryDataFileName);
     if ($updateInfo->isCreate()) {
         remotesync\H5pUtil::insertH5p($slug, $binaryDataFileName, $data["title"]);
     } else {
         remotesync\H5pUtil::updateH5p($slug, $binaryDataFileName, $data["title"]);
     }
     $localId = remotesync\H5pUtil::getIdBySlug($slug);
     $q = $wpdb->prepare("UPDATE  {$wpdb->prefix}h5p_contents " . "SET     disable=%s " . "WHERE   id=%s", $data["disable"], $localId);
     $wpdb->query($q);
     if ($wpdb->last_error) {
         throw new Exception($wpdb->last_error);
     }
 }
Example #2
0
 /**
  * Save a H5P content onto the system. If a content with
  * the same slug already exists, it will be replaced.
  */
 static function saveH5p($slug, $h5pFileName, $title)
 {
     if (H5pUtil::h5pExists($slug)) {
         H5pUtil::updateH5p($slug, $h5pFileName, $title);
     } else {
         H5pUtil::insertH5p($slug, $h5pFileName, $title);
     }
 }