protected function processForm(sfWebRequest $request, ProjectForm $form) { $form->bind($request->getParameter($form->getName())); if ($form->isValid()) { $object = $form->save(); $redirectTo = array('sf_route' => 'project_edit', 'sf_subject' => $object); if ($request->getParameter('save_and_add')) { $redirectTo = '@project_new'; } $this->redirect($redirectTo); } }
function form_my_tasks_dropdown() { echo '<li class="header"><a href="' . get_url('form', 'index') . '">' . lang('forms') . '</a></li>'; if (ProjectForm::canAdd(logged_user(), active_project())) { echo '<li><a href="' . get_url('form', 'add') . '">' . lang('add form') . '</a></li>'; } // if }
/** * Configures the form fields */ public function configure() { $this->widgetSchema['users_list'] = new sfWidgetFormDoctrineChoiceMany(array('model' => 'Profile', 'query' => $this->retriveAllButSuperAdmin())); $this->validatorSchema['name'] = new sfValidatorString(array('max_length' => 64, 'min_length' => 3, 'required' => true), array('max_length' => 'Project name %value% is too long (max %max_length% chars).', 'min_length' => 'Project name %value% is too short (min 3 chars).', 'required' => 'Project name is required')); $this->validatorSchema['description'] = new sfValidatorString(array('max_length' => 512, 'required' => false), array('max_length' => 'Project description is too long (max %max_length% chars).')); $this->validatorSchema['is_public'] = new sfValidatorBoolean(array('required' => false), array('invalid' => 'invalid')); $this->validatorSchema['users_list'] = new sfValidatorDoctrineChoiceMany(array('model' => 'Profile', 'alias' => '', 'required' => false, 'query' => $this->retriveAllButSuperAdmin())); parent::configure(); }
/** * Delete specific project form * * @param void * @return null */ function delete() { $project_form = ProjectForms::findById(get_id()); if (!$project_form instanceof ProjectForm) { flash_error(lang('project form dnx')); if (ProjectForm::canAdd(logged_user(), active_project())) { $this->redirectTo('form'); } else { $this->redirectToUrl(active_project()->getOverviewUrl()); } // if } // if if (!$project_form->canDelete(logged_user())) { flash_error(lang('no access permissions')); if (ProjectForm::canAdd(logged_user(), active_project())) { $this->redirectTo('form'); } else { $this->redirectToUrl(active_project()->getOverviewUrl()); } // if } // if if ($project_form->delete()) { ApplicationLogs::createLog($project_form, active_project(), ApplicationLogs::ACTION_DELETE, true); flash_success(lang('success delete project form', $project_form->getName())); } else { flash_error(lang('error delete project form')); } // if $this->redirectTo('form'); }
<?php set_page_title(lang('forms')); project_tabbed_navigation(PROJECT_TAB_FORMS); project_crumbs(lang('forms')); if (ProjectForm::canAdd(logged_user(), active_project())) { add_page_action(lang('add form'), get_url('form', 'add')); } // if if (isset($forms) && is_array($forms) && count($forms)) { ?> <div id="projectForms"> <?php foreach ($forms as $form) { ?> <div class="block"> <div class="header"><?php echo clean($form->getName()); ?> </div> <div class="content"> <?php if (trim($form->getDescription())) { ?> <div class="description"><?php echo do_textile($form->getDescription()); ?> </div> <?php } // if
public function setDefaultForm($title, $form = "default") { sfContext::getInstance()->getLogger()->info("Setting defaults for form [" . $title . "], setting form to (" . $form . ")"); // TODO: Going to sleep now, but seems like we need to prepend the title of the form before the form - "main_default" insted of just "default" // TODO: Maybe it's lack of sleep, but title<->form are mixed up, it seems $setting = ProjectSettingPeer::retrieveByProjectIdTitle($this->getId(), $title); if ($setting == null) { sfContext::getInstance()->getLogger()->info("Setting not found when setting default (normal behavior)"); $setting = new ProjectSetting(); $setting->setProjectId($this->getId()); $setting->setTitle('form_' . $title); $setting->setSetting($form); $setting->save(); } $new_form = ProjectFormPeer::retrieveByProjectIdTitle($this->getId(), $setting->getSetting()); if ($new_form == null) { sfContext::getInstance()->getLogger()->info("Form not found (normal behavior)"); $new_form = new ProjectForm(); $new_form->setProjectId($this->getId()); $new_form->setTitle($form); $new_form->save(); } sfContext::getInstance()->getLogger()->info("Form created, setting assigned. "); return $form; }
/** * 淘宝项目 */ public function actionTaobao() { $this->layout = "//layouts/member_html5"; $error = ""; if (isset($_POST['title'])) { //发布项目处理 $_POST['type'] = 3; $_POST['low_account'] = 50; $va_param = $_POST; unset($va_param['publis_submit']); unset($va_param['picname']); Yii::import("application.models.form.ProjectForm", true); //形象图片处理 $attch = CUploadedFile::getInstanceByName("picname"); $error = ""; if ($attch == null) { $name = Yii::app()->theme->baseUrl . "/images/projectdefault.png"; } elseif ($attch->size > 1024 * 1024) { $error = "形象图片不超过1M"; } elseif (!in_array(strtolower($attch->extensionName), array("jpeg", "jpg", "gif", "png"))) { $error = "上传的图片格式不正确"; } else { $filename = "user_" . Yii::app()->user->getId() . "_" . time() . "." . strtolower($attch->extensionName); $path = "/data/upload/project/" . date("Y-m-d") . "/"; $filepath = Yii::getPathOfAlias('webroot') . $path . $filename; $name = $path . $filename; if (BaseTool::createFolder($path)) { if (!$attch->saveAs($filepath)) { $error = "形象图片上传出错"; } } } if (empty($error)) { $va_param['litt_pic'] = $name; $oneProjectForm = new ProjectForm(); $oneProjectForm->scenario = 'taobao'; $oneProjectForm->setAttributes($va_param); if ($oneProjectForm->validate()) { $va_param['account'] = $va_param['account_one'] * $va_param['choutimes']; $result = $oneProjectForm->taobaoSave($va_param); if ($result === true) { $this->redirect("/member/projects/publishing.html"); Yii::app()->end(); } else { $errorarray = $oneProjectForm->getErrors(); $error = current(current($errorarray)); } } else { $errorarray = $oneProjectForm->getErrors(); $error = current(current($errorarray)); } } } $this->pageTitle = "发布项目-" . Yii::app()->name; $this->render('taobao', array("publish_error" => $error)); }
public function addProjectForm(ProjectForm $l) { $this->collProjectForms[] = $l; $l->setProject($this); }