当前位置: 首页>>代码示例>>PHP>>正文


PHP Attachments::findLastByObject方法代码示例

本文整理汇总了PHP中Attachments::findLastByObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Attachments::findLastByObject方法的具体用法?PHP Attachments::findLastByObject怎么用?PHP Attachments::findLastByObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Attachments的用法示例。


在下文中一共展示了Attachments::findLastByObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: attachments

 /**
  * List all attachments, and manage attachments
  *
  * @param void
  * @return null
  */
 function attachments()
 {
     if (!$this->active_object->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
     }
     // if
     $attachemts = $this->active_object->getAttachments();
     $this->smarty->assign(array('attachments' => $attachemts));
     if ($this->request->isSubmitted()) {
         $async = (bool) $this->request->get('async');
         db_begin_work();
         $file = array_shift($_FILES);
         $this->active_object->attachUploadedFile($file, $this->logged_user);
         $save = $this->active_object->save();
         if ($save && !is_error($save)) {
             $attachment = Attachments::findLastByObject($this->active_object);
             if (instance_of($attachment, 'Attachment')) {
                 db_commit();
                 if ($async) {
                     $this->smarty->assign(array('_attachment' => $attachment, '_object_attachments_cycle_name' => 'object_attachments_cycle_' . $attachment->getId()));
                     // jQuery acts a bit weird here. Insted of providing response as
                     // a string it tries to append it to the BODY so some markup
                     // (tr, td) gets discarded. That is why we need to use temp table
                     // in order to get properly marked-up row
                     die('<table style="display: none">' . $this->smarty->fetch(get_template_path('_object_attachments_row', 'attachments', RESOURCES_MODULE))) . '</table>';
                 } elseif ($this->request->isApiCall()) {
                     $this->serveData($attachment, 'attachment');
                 } else {
                     flash_success('File ":file" has been added', array('file' => $file['name']));
                     $this->redirectToUrl($this->active_object->getAttachmentsUrl());
                 }
                 // if
             }
             // if
         }
         // if
         db_rollback();
         if ($async) {
             $this->httpError(HTTP_ERR_OPERATION_FAILED);
         } elseif ($this->request->isApiCall()) {
             $this->httpError(HTTP_ERR_OPERATION_FAILED, null, true, true);
         } else {
             flash_error('File ":file" has not been added', array('file' => $file['name']));
             $this->redirectToUrl($this->active_object->getAttachmentsUrl());
         }
         // if
     } else {
         if ($this->request->isApiCall()) {
             $this->serveData($attachemts, 'attachments');
         }
         // if
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:60,代码来源:ProjectObjectsController.class.php


注:本文中的Attachments::findLastByObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。