Example #1
0
 public function executeGetPhoto()
 {
     $this->setTemplate('blank');
     $photo_dir = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'photos' . DIRECTORY_SEPARATOR;
     $test_applicant_id = $this->getRequestParameter('id');
     $c = new Criteria();
     $c->add(TestApplicantPhotoPeer::TEST_APPLICANT_ID, $test_applicant_id);
     $photo = TestApplicantPhotoPeer::doSelectOne($c);
     $this->getResponse()->setHttpHeader('Content-Type', 'image/png');
     $contents = "";
     if ($photo != null && $photo->getThumbnail()->getContents()) {
         $contents = imagecreatefromstring(base64_decode($photo->getThumbnail()->getContents()));
     } else {
         $contents = imagecreatefrompng($photo_dir . 'no_photo.png');
     }
     return imagepng($contents);
 }
Example #2
0
 public function executeRun()
 {
     $this->applicant = $this->applicant;
     $this->error = false;
     $this->upload = false;
     $tmp_dir = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'photos' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR;
     //$fileRenameTo = $this->getRequestParameter('fileRenameTo');
     $fileRenameTo = 'test';
     $fileName = $this->getRequest()->getFileName('photo');
     $filePath = $this->getRequest()->getFilePath('photo');
     $this->orig_filename = $fileName;
     if ($fileName != null && $fileName != '') {
         $this->upload = true;
         $exif_type = exif_imagetype($filePath);
         if ($exif_type == IMAGETYPE_GIF || $exif_type == IMAGETYPE_JPEG || $exif_type == IMAGETYPE_PNG) {
             $content = file_get_contents($filePath);
             $im = imagecreatefromstring($content);
             list($w, $h) = getimagesize($filePath);
             // generate photo
             $photo = imagecreatetruecolor(150, 195);
             imagecopyresized($photo, $im, 0, 0, 0, 0, 150, 195, $w, $h);
             // generate thumbnail
             $thumb = imagecreatetruecolor(100, 130);
             imagecopyresized($thumb, $im, 0, 0, 0, 0, 100, 130, $w, $h);
             $c = new Criteria();
             $c->add(TestApplicantPhotoPeer::TEST_APPLICANT_ID, $this->applicant->getId());
             $applicant_photo = TestApplicantPhotoPeer::doSelectOne($c);
             if ($applicant_photo == null) {
                 $applicant_photo = new TestApplicantPhoto();
                 $applicant_photo->setTestApplicantId($this->applicant->getId());
             }
             // save photo
             imagepng($photo, $filePath);
             $applicant_photo->setPhoto(base64_encode(file_get_contents($filePath)));
             imagepng($thumb, $filePath);
             $applicant_photo->setThumbnail(base64_encode(file_get_contents($filePath)));
             try {
                 $applicant_photo->save();
             } catch (exception $e) {
                 $this->error = true;
             }
         } else {
             $this->error = true;
         }
     }
 }
Example #3
0
 public function executeUpdateFoto()
 {
     $user_id = $this->getContext()->getUser()->getAttribute('user_id', null, 'bo');
     $applicant = TestApplicantPeer::retrieveByPk($user_id);
     $this->forward404Unless($applicant);
     $applicant_detail = $applicant->getTestApplicantDetail();
     // save photo
     $photo_dir = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'photos' . DIRECTORY_SEPARATOR;
     if ($this->hasRequestParameter('photoFile') && $this->getRequestParameter('photoFile') != '' && $this->getRequestParameter('photoFile') != null) {
         // get photo content
         $photo_file = $photo_dir . 'tmp' . DIRECTORY_SEPARATOR . $this->getRequestParameter('photoFile');
         $content = file_get_contents($photo_file);
         $im = imagecreatefromstring($content);
         list($w, $h) = getimagesize($photo_file);
         // generate photo
         $photo = imagecreatetruecolor(150, 195);
         imagecopyresized($photo, $im, 0, 0, 0, 0, 150, 195, $w, $h);
         // generate thumbnail
         $thumb = imagecreatetruecolor(100, 130);
         imagecopyresized($thumb, $im, 0, 0, 0, 0, 100, 130, $w, $h);
         // get photo record
         $c = new Criteria();
         $c->add(TestApplicantPhotoPeer::TEST_APPLICANT_ID, $applicant->getId());
         $applicant_photo = TestApplicantPhotoPeer::doSelectOne($c);
         if ($applicant_photo == null) {
             $applicant_photo = new TestApplicantPhoto();
             $applicant_photo->setTestApplicant($applicant);
         }
         // save photo
         imagepng($photo, $photo_file);
         $applicant_photo->setPhoto(base64_encode(file_get_contents($photo_file)));
         imagepng($thumb, $photo_file);
         $applicant_photo->setThumbnail(base64_encode(file_get_contents($photo_file)));
         $applicant_photo->save();
         unlink($photo_dir . 'tmp' . DIRECTORY_SEPARATOR . $this->getRequestParameter('photoFile'));
     }
     return $this->redirect('auth/index');
 }
Example #4
0
        if ($applicant->getRegTestPeriod1() == null) {
            echo link_to_remote(_('Tentukan Periode Test'), array('url' => 'auth/test?id=' . $applicant_id, 'update' => 'content', 'script' => 'true'));
        } else {
            echo link_to_remote(_('Informasi Detail Pendaftar'), array('url' => 'auth/test?id=' . $applicant_id, 'update' => 'content', 'script' => 'true'));
        }
        ?>
        </li>
</ul>
</td></tr>
</table>
<br />
<?php 
    } elseif ($title == 'periode') {
        $c = new Criteria();
        $c->add(TestApplicantPhotoPeer::TEST_APPLICANT_ID, $applicant_id);
        $applicant_photo = TestApplicantPhotoPeer::doSelectOne($c);
        $applicant = TestApplicantPeer::retrieveByPK($applicant_id);
        ?>
<table width="500px" border="0" cellpadding="0" cellspacing="0">
<tr><td>
<ul id="breadcrumb">
        <li><?php 
        echo link_to(image_tag('home.png', array('title' => __('Home'))), '/auth', 'style=padding-top: 7px;');
        ?>
</li>
        <li><?php 
        echo link_to_remote(_('Biodata Pendaftar'), array('url' => 'auth/detail?id=' . $applicant_id, 'update' => 'content', 'script' => 'true'));
        ?>
</li>
        <li>
        <?php 
Example #5
0
 public function countTestApplicantPhotos($criteria = null, $distinct = false, $con = null)
 {
     include_once 'lib/model/om/BaseTestApplicantPhotoPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(TestApplicantPhotoPeer::TEST_APPLICANT_ID, $this->getId());
     return TestApplicantPhotoPeer::doCount($criteria, $distinct, $con);
 }
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(TestApplicantPhotoPeer::ID, $pks, Criteria::IN);
         $objs = TestApplicantPhotoPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = TestApplicantPhotoPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setTestApplicantId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setPhoto($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setThumbnail($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setFilename($arr[$keys[4]]);
     }
 }