Beispiel #1
0
 /**
  * updateShare
  * Update the description and/or expiration date for an existing share.
  * Takes the share id to update with optional description and expires parameters.
  * Not supported.
  */
 public static function updateshare($input)
 {
     self::check_version($input, "1.6.0");
     $id = self::check_parameter($input, 'id');
     $description = $input['description'];
     if (AmpConfig::get('share')) {
         $share = new Share($id);
         if ($share->id > 0) {
             $expires = $share->expire_days;
             if (isset($input['expires'])) {
                 // Parse as a string to work on 32-bit computers
                 $expires = $input['expires'];
                 if (strlen($expires) > 3) {
                     $expires = intval(substr($expires, 0, -3));
                 }
                 if ($expires > 0) {
                     $expires = ($expires - $share->creation_date) / 86400;
                     $expires = ceil($expires);
                 }
             }
             $data = array('max_counter' => $share->max_counter, 'expire' => $expires, 'allow_stream' => $share->allow_stream, 'allow_download' => $share->allow_download, 'description' => $description ?: $share->description);
             if ($share->update($data)) {
                 $r = Subsonic_XML_Data::createSuccessResponse();
             } else {
                 $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_UNAUTHORIZED);
             }
         } else {
             $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_DATA_NOTFOUND);
         }
     } else {
         $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_UNAUTHORIZED);
     }
     self::apiOutput($input, $r);
 }