public static function retrieveByCode($code, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $criteria = new Criteria(ClassAgendaFilePeer::DATABASE_NAME); $criteria->add(ClassAgendaFilePeer::ID, $code); $v = ClassAgendaFilePeer::doSelect($criteria, $con); return !empty($v) > 0 ? $v[0] : null; }
public function executeDeleteFile() { $code = $this->getRequestParameter('id'); $ca_file = ClassAgendaFilePeer::retrieveByCode($code); $this->forward404Unless($ca_file); $ca_file->delete(); return $this->redirect('class_agenda/edit?id=' . $this->getRequestParameter('class_agenda_id') . '&course_id=' . $this->getRequestParameter('course_id')); }
</p></td> </tr> <tr> <td style="vertical-align:middle;"><label ><?php echo __('File Upload'); ?> </label></td> <td width="2%" style="text-align:center; vertical-align:middle;">:</td> <td style="vertical-align:middle;"> <p class="detail"> <?php $c = new Criteria(); $c->add(ClassAgendaFilePeer::CLASS_AGENDA_ID, $class_agenda->getId()); $file = ClassAgendaFilePeer::doSelect($c); $count = ClassAgendaFilePeer::doCount($c); if ($file == null) { echo ' -'; } else { $file_dir = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'files'; if ($count == 2) { echo ' 1. '; echo link_to($file[0]->getFile(), 'class_agenda/download?filename=' . $file[0]->getFile(), 'target=_blank') . '<br>'; echo ' 2. '; echo link_to($file[1]->getFile(), 'class_agenda/download?filename=' . $file[1]->getFile(), 'target=_blank'); } elseif ($count == 3) { echo ' 1. '; echo link_to($file[0]->getFile(), 'class_agenda/download?filename=' . $file[0]->getFile(), 'target=_blank') . '<br>'; echo ' 2. '; echo link_to($file[1]->getFile(), 'class_agenda/download?filename=' . $file[1]->getFile(), 'target=_blank') . '<br>'; echo ' 3. ';
</td> </tr> <tr> <td style="vertical-align:top;"><label><?php echo __('File Upload'); ?> </label></td> <td style="text-align:center; vertical-align:top;">:</td> <td style="vertical-align:top;"> <?php if (isset($class_agenda) && $class_agenda->getId()) { $c = new Criteria(); $c->add(ClassAgendaFilePeer::CLASS_AGENDA_ID, $class_agenda->getId()); $count = ClassAgendaFilePeer::doCount($c); $file = ClassAgendaFilePeer::doSelect($c); if ($file != null) { if ($count == 2) { echo ' 1. '; echo link_to($file[0]->getFile(), 'class_agenda/download?filename=' . $file[0]->getFile(), 'target=_blank') . ' '; echo link_to_remote(image_tag('delete.gif', 'title=Hapus File Upload'), array('url' => 'class_agenda/deleteFile?id=' . $file[0]->getId() . '&class_agenda_id=' . $class_agenda->getId() . '&course_id=' . $course_schedule->getId(), 'confirm' => __('Are you sure?'), 'update' => 'content', 'script' => 'true')) . '<br>'; echo ' 2. '; echo link_to($file[1]->getFile(), 'class_agenda/download?filename=' . $file[1]->getFile(), 'target=_blank') . ' '; echo link_to_remote(image_tag('delete.gif', 'title=Hapus File Upload'), array('url' => 'class_agenda/deleteFile?id=' . $file[1]->getId() . '&class_agenda_id=' . $class_agenda->getId() . '&course_id=' . $course_schedule->getId(), 'confirm' => __('Are you sure?'), 'update' => 'content', 'script' => 'true')); } elseif ($count == 3) { echo ' 1. '; echo link_to($file[0]->getFile(), 'class_agenda/download?filename=' . $file[0]->getFile(), 'target=_blank') . ' '; echo link_to_remote(image_tag('delete.gif', 'title=Hapus File Upload'), array('url' => 'class_agenda/deleteFile?id=' . $file[0]->getId() . '&class_agenda_id=' . $class_agenda->getId() . '&course_id=' . $course_schedule->getId(), 'confirm' => __('Are you sure?'), 'update' => 'content', 'script' => 'true')) . '<br>'; echo ' 2. '; echo link_to($file[1]->getFile(), 'class_agenda/download?filename=' . $file[1]->getFile(), 'target=_blank') . ' '; echo link_to_remote(image_tag('delete.gif', 'title=Hapus File Upload'), array('url' => 'class_agenda/deleteFile?id=' . $file[1]->getId() . '&class_agenda_id=' . $class_agenda->getId() . '&course_id=' . $course_schedule->getId(), 'confirm' => __('Are you sure?'), 'update' => 'content', 'script' => 'true')) . '<br>';
protected static function doOnDeleteCascade(Criteria $criteria, Connection $con) { $affectedRows = 0; $objects = ClassAgendaPeer::doSelect($criteria, $con); foreach ($objects as $obj) { include_once 'lib/model/ClassAgendaFile.php'; $c = new Criteria(); $c->add(ClassAgendaFilePeer::CLASS_AGENDA_ID, $obj->getId()); $affectedRows += ClassAgendaFilePeer::doDelete($c, $con); } return $affectedRows; }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = ClassAgendaFilePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setClassAgendaId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setFile($arr[$keys[2]]); } }
public static function retrieveByPK($id, $class_agenda_id, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $criteria = new Criteria(); $criteria->add(ClassAgendaFilePeer::ID, $id); $criteria->add(ClassAgendaFilePeer::CLASS_AGENDA_ID, $class_agenda_id); $v = ClassAgendaFilePeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }
public function countClassAgendaFiles($criteria = null, $distinct = false, $con = null) { include_once 'lib/model/om/BaseClassAgendaFilePeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->add(ClassAgendaFilePeer::CLASS_AGENDA_ID, $this->getId()); return ClassAgendaFilePeer::doCount($criteria, $distinct, $con); }