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


PHP Attachments::findbyids方法代码示例

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


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

示例1: mass_edit

 /**
  * Update multiple tickets
  *
  * @param void
  * @return null
  */
 function mass_edit()
 {
     if (!$this->request->isSubmitted()) {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
     $action = $this->request->post('with_selected');
     if (trim($action) == '') {
         flash_error('Please select what you want to do with selected tickets');
         $this->redirectToReferer($this->smarty->get_template_vars('files_url'));
     }
     // if
     $files_ids = $this->request->post('files');
     $object_types = $this->request->post('object_types');
     if ($object_types == 'files') {
         $files = Files::findByIds($files_ids, STATE_VISIBLE, $this->logged_user->getVisibility());
         $redirect_url = $this->smarty->get_template_vars('files_url');
     } else {
         if ($object_types == 'attachments') {
             $files = Attachments::findbyids($files_ids, STATE_VISIBLE, $this->logged_user->getVisibility());
             $redirect_url = $this->smarty->get_template_vars('attachments_url');
         } else {
             $files = array();
             $redirect_url = $this->smarty->get_template_vars('files_url');
         }
     }
     // if
     if (!is_foreachable($files)) {
         flash_error('Please select files that you would like to update');
         $this->redirectToReferer($this->smarty->get_template_vars('files_url'));
     }
     // if
     $updated = 0;
     if ($action == 'delete') {
         // delete attachments
         $message = lang(':count attachments deleted');
         foreach ($files as $file) {
             if ($file->canDelete($this->logged_user)) {
                 $delete = $file->delete();
                 if ($delete && !is_error($delete)) {
                     $updated++;
                 }
                 // if
             }
             // if
         }
         // foreach
     } else {
         if ($action == 'move_to_trash') {
             // move files to trash
             $message = lang(':count files moved to trash');
             foreach ($files as $file) {
                 if ($file->canDelete($this->logged_user)) {
                     $delete = $file->moveToTrash();
                     if ($delete && !is_error($delete)) {
                         $updated++;
                     }
                     // if
                 }
                 // if
             }
             // foreach
         } else {
             if (str_starts_with($action, 'move_to_category')) {
                 // chage files category
                 $message = lang(':count files updated');
                 if ($action == 'move_to_category') {
                     $category_id = 0;
                 } else {
                     $category_id = (int) substr($action, 17);
                 }
                 // if
                 $category = $category_id ? Categories::findById($category_id) : null;
                 foreach ($files as $file) {
                     if ($file->canEdit($this->logged_user)) {
                         $file->setParent($category, false);
                         $save = $file->save();
                         if ($save && !is_error($save)) {
                             $updated++;
                         }
                         // if
                     }
                 }
                 // foreach
             } else {
                 // invalid action
                 $this->httpError(HTTP_ERR_BAD_REQUEST);
             }
         }
     }
     flash_success($message, array('count' => $updated));
     $this->redirectToReferer($redirect_url);
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:99,代码来源:FilesController.class_RND.php


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