本文整理汇总了PHP中Attachments::setBindId方法的典型用法代码示例。如果您正苦于以下问题:PHP Attachments::setBindId方法的具体用法?PHP Attachments::setBindId怎么用?PHP Attachments::setBindId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attachments
的用法示例。
在下文中一共展示了Attachments::setBindId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeUpload
public function executeUpload(sfWebRequest $request)
{
$file = $request->getFiles();
$filename = mt_rand(111111, 999999) . '-' . $file['Filedata']['name'];
if (move_uploaded_file($file['Filedata']['tmp_name'], sfConfig::get('sf_upload_dir') . '/attachments/' . $filename)) {
$bind_id = $request->getParameter('bind_id');
if ((int) $bind_id == 0) {
$bind_id = -$this->getUser()->getAttribute('id');
}
$a = new Attachments();
$a->setFile($filename);
$a->setBindType($request->getParameter('bind_type'));
$a->setBindId($bind_id);
$a->save();
}
exit;
}
示例2: setValues
public static function setValues($fields, $bind_id, $bind_type, $sf_user, $request)
{
$extra_fields = ExtraFieldsList::getFieldsByType($bind_type, $sf_user, false, array('all' => true));
foreach ($extra_fields as $ef) {
//escape view only fields
if (in_array($sf_user->getAttribute('users_group_id'), explode(',', $ef['view_only_access']))) {
continue;
}
if (isset($fields[$ef['id']])) {
$v = $fields[$ef['id']];
} else {
$v = '';
}
$v = app::strip_tags($v);
if ($ef['type'] == 'file') {
$files = $request->getFiles();
if ($extra_fields_files_delete = $request->getParameter('extra_fields_files_delete')) {
if (isset($extra_fields_files_delete[$ef['id']])) {
if ($a = Doctrine_Core::getTable('Attachments')->find($extra_fields_files_delete[$ef['id']])) {
if (is_file($file_path = sfConfig::get('sf_upload_dir') . '/attachments/' . $a->getFile())) {
unlink($file_path);
}
$a->delete();
}
}
}
if ($extra_fields_files = $request->getParameter('extra_fields_files')) {
if (isset($extra_fields_files[$ef['id']])) {
$v = $extra_fields_files[$ef['id']];
}
}
if (strlen($files['extra_fields'][$ef['id']]['name']) > 0) {
if ($v > 0) {
if ($a = Doctrine_Core::getTable('Attachments')->find($v)) {
if (is_file($file_path = sfConfig::get('sf_upload_dir') . '/attachments/' . $a->getFile())) {
unlink($file_path);
}
$a->delete();
}
}
$file = $files['extra_fields'][$ef['id']];
$filename = rand(111111, 999999) . '-' . $file['name'];
move_uploaded_file($file['tmp_name'], sfConfig::get('sf_upload_dir') . '/attachments/' . $filename);
$a = new Attachments();
$a->setFile($filename);
$a->setBindType('extra_fields');
$a->setBindId($ef['id']);
$a->save();
$v = $a->getId();
}
} elseif ($ef['type'] == 'date_dropdown') {
$v = implode('-', $v);
} elseif ($ef['type'] == 'date_range') {
$v = implode('|', $v);
} elseif ($ef['type'] == 'checkbox' and is_array($v)) {
$v = implode("\n", $v);
} elseif (is_array($v)) {
$v = implode(',', $v);
}
$f = Doctrine_Core::getTable('ExtraFieldsList')->createQuery()->addWhere('bind_id=?', $bind_id)->addWhere('extra_fields_id=?', $ef['id'])->fetchOne();
if ($f) {
$f->setValue($v);
$f->save();
} else {
$f = new ExtraFieldsList();
$f->setBindId($bind_id);
$f->setExtraFieldsId($ef['id']);
$f->setValue($v);
$f->save();
}
}
}
示例3: executeCopyAttachments
public function executeCopyAttachments(sfWebRequest $request)
{
if (count($attachments_ids = explode(',', $request->getParameter('attachments'))) > 0) {
$attachments = Doctrine_Core::getTable('Attachments')->createQuery()->whereIn('id', $attachments_ids)->execute();
foreach ($attachments as $a) {
if (Doctrine_Core::getTable('Attachments')->createQuery()->addWhere('SUBSTRING(file,8)=?', substr($a->getFile(), 7))->addWhere('bind_type=?', $request->getParameter('to'))->addWhere('bind_id=?', -$this->getUser()->getAttribute('id'))->count() == 0) {
$new_filename = rand(111111, 999999) . '-' . substr($a->getFile(), 7);
copy(sfConfig::get('sf_upload_dir') . '/attachments/' . $a->getFile(), sfConfig::get('sf_upload_dir') . '/attachments/' . $new_filename);
$aa = new Attachments();
$aa->setFile($new_filename);
$aa->setInfo($a->getInfo());
$aa->setBindType($request->getParameter('to'));
$aa->setBindId(-$this->getUser()->getAttribute('id'));
$aa->save();
}
}
}
exit;
}