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; }