コード例 #1
0
 /**
  * Show and process edit attachment form
  *
  * @param void
  * @return null
  */
 function edit()
 {
     $this->wireframe->print_button = false;
     if ($this->active_attachment->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $parent = $this->active_attachment->getParent();
     if (!instance_of($parent, 'ProjectObject')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $attachment_data = $this->request->post('attachment');
     if (!is_array($attachment_data)) {
         $attachment_data = array('name' => $this->active_attachment->getName());
     }
     // if
     $this->smarty->assign('attachment_data', $attachment_data);
     if ($this->request->isSubmitted()) {
         db_begin_work();
         $old_name = $this->active_attachment->getName();
         $this->active_attachment->setName(array_var($attachment_data, 'name'));
         $save = $this->active_attachment->save();
         if ($save && !is_error($save)) {
             db_commit();
             $this->active_attachment->ready();
             if ($this->request->getFormat() == FORMAT_HTML) {
                 flash_success('File :filename has been updated', array('filename' => $old_name));
                 $this->redirectToUrl($parent->getViewUrl());
             } else {
                 $this->serveData($this->active_attachment);
             }
             // if
         } else {
             db_rollback();
             if ($this->request->getFormat() == FORMAT_HTML) {
                 flash_error('Failed to update :filename', array('filename' => $old_name));
                 $this->redirectToUrl($parent->getViewUrl());
             } else {
                 $this->serveData($save);
             }
             // if
         }
         // if
     }
     // if
 }
コード例 #2
0
ファイル: Connection.php プロジェクト: stingmu/youtrack
 /**
  * @param string $issueId The issue id
  * @param Attachment $attachment The attachment
  * @return array
  */
 public function createAttachmentFromAttachment($issueId, Attachment $attachment)
 {
     $params = $this->getAttachmentParams($attachment->getName(), $attachment->getAuthorLogin(), $attachment->getCreated(), $attachment->getGroup());
     return $this->request('POST', '/issue/' . rawurlencode($issueId) . '/attachment?' . http_build_query($params), $attachment->getUrl());
 }
コード例 #3
0
ファイル: AttachmentTest.php プロジェクト: fuelphp/email
 /**
  * @covers ::__construct
  * @group  Email
  */
 public function testContstruct()
 {
     $name = 'name';
     $contents = 'Test content';
     $mime = 'text/plain';
     $object = new Attachment($name, $contents, $mime);
     $this->assertEquals($name, $object->getName());
     $this->assertEquals($contents, $object->getContents());
     $this->assertEquals($mime, $object->getMime());
     $this->assertEquals(md5($name), $object->getCid());
     $this->assertFalse($object->isInline());
 }