$file = trim($file); if (sizeof($files) == 1 && $file == "") { break; } $tokens = explode(".", $file); $extension = array_pop($tokens); if (!in_array(strtolower($extension), array('jpg', 'png', 'gif', 'zip', 'doc', 'docx', 'pdf'))) { Message::register(new Message(Message::DANGER, i18n(array("en" => "Only file with extension jpg,png,gif,zip,doc,docx,pdf is allowed. Please restrict your files with these types.", "zh" => "上传文件仅支持jpg,png,gif,zip,doc,docx,pdf,请检查您的上传文件")))); $error_flag = true; break; } } } /// proceed submission // proceed for $name $object->setName($name); // proceed for $dob $object->setDob($dob); // proceed for $address $object->setAddress($address); // proceed for $postcode $object->setPostcode($postcode); // proceed for $phone $object->setPhone($phone); // proceed for $mobile $object->setMobile($mobile); // proceed for $qq $object->setQq($qq); // proceed for $email $object->setEmail($email); // proceed for $education
public static function update($values, $user) { $id = $values['id']; if ($id) { $q = new Doctrine_Query(); $q = $q->select('a.*')->from('Application a'); $q = $q->addWhere('id = ?', array($id)); if (!$user->getRole() == User::ADMIN) { $q = $q->addWhere('user_id = ?', array($user->getId())); } $application = $q->fetchOne(); } else { $application = new Application(); } if ($application) { $application->setName($values['name']); $application->setDescription($values['description']); $application->setSourceUrl($values['source_url']); if (!$application->getUserId()) { $application->setUserId($user->getId()); } $application->setApproved(false); $application->save(); $folderpath = $application->getFolderPath(); if (!is_dir($folderpath)) { mkdir($folderpath); } $screenshot = $values['screenshot']; if ($screenshot) { $screenshotpath = $folderpath . $application->getId() . $screenshot->getOriginalName(); $screenshot->save($screenshotpath); $smallThumb = new Thumbnail($screenshotpath); if ($smallThumb->getCurrentWidth() > 150 || $smallThumb->getCurrentHeight() > 150) { $smallThumb->resize(150, 150); } $smallThumb->show(100, $folderpath . 'smallthumb.png'); $bigThumb = new Thumbnail($screenshotpath); if ($bigThumb->getCurrentWidth() > 500 || $bigThumb->getCurrentHeight() > 500) { $bigThumb->resize(500, 500); } $bigThumb->show(100, $folderpath . 'bigthumb.png'); $screenshot = new Thumbnail($screenshotpath); $screenshot->show(100, $folderpath . 'screenshot.png'); unlink($screenshotpath); } return $application; } return null; }