本文整理匯總了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);
}