/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new State(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['State'])) { $model->attributes = $_POST['State']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function actionCreateOrg() { $org = Organization::model()->count(); if ($org == 0) { $this->layout = 'installation_layout'; $model = new Organization(); $user = new User(); $auth_assign = new AuthAssignment(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['Organization']['organization_name']) && !empty($_POST['Organization']['phone']) && !empty($_POST['Organization']['email'])) { $country_model = new Country(); $country_model->name = $_POST['Organization']['country']; $country_model->save(); $state_model = new State(); $state_model->state_name = $_POST['Organization']['state']; $state_model->country_id = $country_model->id; $state_model->save(); $city_model = new City(); $city_model->city_name = $_POST['Organization']['city']; $city_model->country_id = $country_model->id; $city_model->state_id = $state_model->state_id; $city_model->save(); $model->attributes = $_POST['Organization']; $model->organization_created_by = 1; $model->organization_creation_date = new CDbExpression('NOW()'); $model->city = $city_model->city_id; $model->state = $state_model->state_id; $model->country = $country_model->id; if ($model->save(false)) { $user->user_organization_email_id = $model->email; $user->user_password = md5($model->email . $model->email); $user->user_type = 'admin'; $user->user_created_by = 1; $user->user_creation_date = new CDbExpression('NOW()'); $user->user_organization_id = $model->organization_id; $user->save(); $auth_assign->itemname = 'SuperAdmin'; $auth_assign->userid = $user->user_id; $auth_assign->save(false); $this->redirect(array('redirectLogin')); } } $this->render('create_org', array('model' => $model)); } else { Yii::app()->user->logout(); $this->redirect(array('login')); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new State(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['State'])) { $model->attributes = $_POST['State']; $model->created_on = date('Y-m-d'); $model->created_by = Yii::app()->user->id; if ($model->save()) { Yii::app()->user->setFlash('success', 'Saved successfully'); $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function save($id = null) { if ($this->perm->can_create == 'y') { if ($_POST) { $save = new State(); if ($_POST['id'] == '') { $_POST['created_by'] = $this->user->id; } else { $_POST['updated_by'] = $this->user->id; } $save->from_array($_POST); $save->save(); $action = $_POST['id'] > 0 ? 'UPDATE' : 'CREATE'; save_logs($this->menu_id, $action, @$save->id, $action . ' ' . $save->state_name . ' State Detail'); } } redirect("admin/" . $this->modules_name); }
public function agregar() { $data = array(); if ($_POST) { $provincia = new State(elements(array('provincia', 'country_id'), $_POST)); if ($provincia->is_valid()) { $provincia->save(); $this->session->set_flashdata('msg', '<div class="success">El provincia se guardó correctamente.</div>'); redirect('provincias'); } else { $data['errors'] = $provincia->errors; } } $data['paises'] = Country::all(); $data['titulo'] = "Agregar Provincia"; $data['action'] = "provincias/agregar"; $this->template->write_view('content', 'provincias/agregar', $data); $this->template->render(); }
<?php include 'admin-config.php'; $state_id = $country_id = $state_name = $state_status = $error = ""; if (strlen(Request::post("submit"))) { $state_id = Request::post("state_id"); $country_id = Request::post("country_id"); $state_name = Request::post("state_name"); $state_status = Validation::getStautsTinyVal(Request::post("active")); $stateObj = new State(); $stateObj->set("state_id", $state_id); $stateObj->set("country_id", $country_id); $stateObj->set("state_name", $state_name); $stateObj->set("state_status", $state_status); if ($stateObj->save()) { General::redirectUrl("state.php"); } else { $error = "State Name alreday exist !"; } } ?> <?php include 'header.php'; include 'sitebar.php'; ?> <div class="ch-container"> <div class="row"> <div id="content" class="col-lg-10 col-sm-10"> <!-- content starts -->
public function actionNewstate() { if (isset($_POST['State'])) { $obj = new State(); $obj->attributes = $_POST['State']; $obj->active = 1; $obj->sort_order = 10; if ($obj->validate()) { if ($obj->save()) { echo "success"; } else { echo print_r($obj->getErrors, true); } } else { echo print_r($obj->getErrors, true); } } }
public function createState($country, $name) { $tmp = new State(); $tmp->name = $name; $tmp->Country = $country; $tmp->save(); return $tmp; }
public function setCommentAsLiked($comment, $user, $send = false) { if ($send) { $this->data['new']['comments'][] = $comment->id; if (!isset($this->data['posts'][$comment->post_id])) { $this->data['posts'][$comment->post_id] = array('post_id' => $comment->post_id); } if (!isset($this->data['posts'][$comment->post_id]['comments'][$comment->id])) { $this->data['posts'][$comment->post_id]['comments'][$comment->id] = array('comment_id' => $comment->id); } if (isset($this->data['posts'][$comment->post_id]['comments'][$comment->id]['liked'])) { $count = isset($this->data['posts'][$comment->post_id]['comments'][$comment->id]['liked']['count']) ? $this->data['posts'][$comment->post_id]['comments'][$comment->id]['liked']['count'] : 1; $this->data['posts'][$comment->post_id]['comments'][$comment->id]['liked'] = array('count' => ++$count); } else { $this->data['posts'][$comment->post_id]['comments'][$comment->id]['liked'] = array('user' => $user->name); } } else { $state = new State(); $state->object = 'comment'; $state->object_id = $comment->id; $state->event = 'liked'; $state->user_id = $user->id; $state->owner_id = $comment->user_id; $state->save(); $state->timestamp = DB::raw('NOW()'); $state->save(); } return $this; }
function createNewState($id_country, $iso_country, $state_code_name) { $newstate = new State(); $newstate->id = 0; $newstate->id_country = $id_country; $newstate->id_zone = Country::getIdZone($id_country); $newstate->name = $state_code_name; if (strlen($state_code_name) > 2) { $newstate->iso_code = $iso_country . substr($state_code_name, 0, 2); } else { $newstate->iso_code = $iso_country . $state_code_name; } $newstate->tax_behavior = 0; $newstate->active = 1; $newstate->save(); return $newstate->id; }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aState !== null) { if ($this->aState->isModified() || $this->aState->isNew()) { $affectedRows += $this->aState->save($con); } $this->setState($this->aState); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } if ($this->usersScheduledForDeletion !== null) { if (!$this->usersScheduledForDeletion->isEmpty()) { foreach ($this->usersScheduledForDeletion as $user) { // need to save related object because we set the relation to null $user->save($con); } $this->usersScheduledForDeletion = null; } } if ($this->collUsers !== null) { foreach ($this->collUsers as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
public function handleRequest() { /* Check if it is time to insert more terms into DB */ if (Term::isTimeToUpdate()) { Term::doTermUpdate(); } // Fetch the action from the REQUEST. if (!isset($_REQUEST['action'])) { $req = ""; } else { $req = $_REQUEST['action']; } // Show requested page. switch ($req) { case 'example_form': header('Content-type: application/pdf'); readfile(PHPWS_SOURCE_DIR . 'mod/intern/pdf/Internship_Example.pdf'); exit; break; case 'edit_internship': PHPWS_Core::initModClass('intern', 'UI/InternshipUI.php'); $view = new InternshipUI(); $this->content = $view->display(); break; case 'add_internship': PHPWS_Core::initModClass('intern', 'command/SaveInternship.php'); $ctrl = new SaveInternship(); $ctrl->execute(); test('finished execute', 1); break; case 'search': PHPWS_Core::initModClass('intern', 'UI/SearchUI.php'); $view = new SearchUI(); $this->content = $view->display(); break; case 'results': PHPWS_Core::initModClass('intern', 'UI/ResultsUI.php'); $view = new ResultsUI(); $this->content = $view->display(); break; case DEPT_EDIT: PHPWS_Core::initModClass('intern', 'UI/DepartmentUI.php'); PHPWS_Core::initModClass('intern', 'Department.php'); if (isset($_REQUEST['add'])) { /* Add department with the name in REQUEST */ if (isset($_REQUEST['name'])) { Department::add($_REQUEST['name']); } else { NQ::simple('intern', INTERN_ERROR, "Department must have name."); } } else { if (isset($_REQUEST['rename'])) { /* Rename dept with ID to new name that was passed in REQUEST */ if (isset($_REQUEST['id'])) { $d = new Department($_REQUEST['id']); $d->rename($_REQUEST['rename']); } else { NQ::simple('intern', INTERN_ERROR, "No ID given. Cannot rename department."); } } else { if (isset($_REQUEST['hide'])) { /* Hide/Show department with ID passed in REQUEST. */ if (isset($_REQUEST['id'])) { $d = new Department($_REQUEST['id']); $d->hide($_REQUEST['hide'] == 1); } else { NQ::simple('intern', INTERN_ERROR, "No ID given. Cannot hide department."); } } else { if (isset($_REQUEST['del'])) { /* Delete department with same ID passed in REQUEST. */ if (isset($_REQUEST['id'])) { $d = new Department($_REQUEST['id']); $d->del(); } else { NQ::simple('intern', INTERN_ERROR, "No ID given. Cannot delete department."); } } else { if (isset($_REQUEST['fDel'])) { /** for now... */ NQ::simple('intern', INTERN_WARNING, 'Sorry, cannot forcefully delete a department.'); } } } } } $view = new DepartmentUI(); $this->content = $view->display(); break; case GRAD_PROG_EDIT: PHPWS_Core::initModClass('intern', 'GradProgram.php'); PHPWS_Core::initModClass('intern', 'UI/GradProgramUI.php'); if (isset($_REQUEST['add'])) { /* Add grad program with the name in REQUEST */ if (isset($_REQUEST['name'])) { GradProgram::add($_REQUEST['name']); } else { NQ::simple('intern', INTERN_ERROR, "Grad Program must have name."); } } else { if (isset($_REQUEST['rename'])) { /* Rename program with ID to new name that was passed in REQUEST */ if (isset($_REQUEST['id'])) { $g = new GradProgram($_REQUEST['id']); $g->rename($_REQUEST['rename']); } else { NQ::simple('intern', INTERN_ERROR, "No ID given. Cannot rename graduate program."); } } else { if (isset($_REQUEST['hide'])) { /* Hide/Show program with ID passed in REQUEST. */ if (isset($_REQUEST['id'])) { $g = new GradProgram($_REQUEST['id']); $g->hide($_REQUEST['hide'] == 1); } else { NQ::simple('intern', INTERN_ERROR, "No ID given. Cannot hide graduate program."); } } else { if (isset($_REQUEST['del'])) { /* Delete program with same ID passed in REQUEST. */ if (isset($_REQUEST['id'])) { $g = new GradProgram($_REQUEST['id']); $g->del(); } else { NQ::simple('intern', INTERN_ERROR, "No ID given. Cannot delete graduate program."); } } } } } $view = new GradProgramUI(); $this->content = $view->display(); break; case MAJOR_EDIT: PHPWS_Core::initModClass('intern', 'UI/MajorUI.php'); if (isset($_REQUEST['add'])) { /* Add major with the name passed in REQUEST. */ if (isset($_REQUEST['name'])) { Major::add($_REQUEST['name']); } else { NQ::simple('intern', INTERN_ERROR, "Major must have name."); } } else { if (isset($_REQUEST['rename'])) { /* Rename major with ID to new name that was passed in REQUEST */ if (isset($_REQUEST['id'])) { $m = new Major($_REQUEST['id']); $m->rename($_REQUEST['rename']); } else { NQ::simple('intern', INTERN_ERROR, "No ID given. Cannot rename major."); } } else { if (isset($_REQUEST['hide'])) { /* Hide major with ID passed in REQUEST. */ if (isset($_REQUEST['id'])) { $m = new Major($_REQUEST['id']); $m->hide($_REQUEST['hide'] == 1); } else { NQ::simple('intern', INTERN_ERROR, "No ID given. Cannot hide major."); } } else { if (isset($_REQUEST['del'])) { /* Delete major with same ID passed in REQUEST. */ if (isset($_REQUEST['id'])) { $m = new Major($_REQUEST['id']); $m->del(); } else { NQ::simple('intern', INTERN_ERROR, "No ID given. Cannot delete major."); } } } } } $view = new MajorUI(); $this->content = $view->display(); break; /** * Matt additions! */ /** * Matt additions! */ case 'add_state': if (!Current_User::allow('intern', 'edit_state')) { disallow(); } PHPWS_Core::initModClass('intern', 'State.php'); $state = new State($_GET['abbr']); $state->setActive(true); $state->save(); exit; break; case 'remove_state': if (!Current_User::allow('intern', 'edit_state')) { disallow(); } PHPWS_Core::initModClass('intern', 'State.php'); $state = new State($_GET['abbr']); $state->setActive(false); $state->save(); exit; break; case STATE_EDIT: if (!Current_User::allow('intern', 'edit_state')) { disallow(); } PHPWS_Core::initModClass('intern', 'UI/StateUI.php'); $view = new StateUI(); $this->content = $view->display(); break; case 'edit_admins': PHPWS_Core::initModClass('intern', 'UI/AdminUI.php'); PHPWS_Core::initModClass('intern', 'Admin.php'); PHPWS_Core::initModClass('intern', 'Department.php'); if (isset($_REQUEST['add'])) { // Add user in REQUEST to administrator list for the department in REQUEST. Admin::add($_REQUEST['username'], $_REQUEST['department_id']); } else { if (isset($_REQUEST['del'])) { // Delete the user in REQUEST from department in REQUEST. Admin::del($_REQUEST['username'], $_REQUEST['department_id']); } else { if (isset($_REQUEST['user_complete'])) { $users = Admin::searchUsers($_REQUEST['term']); echo json_encode($users); exit; } } } $view = new AdminUI(); $this->content = $view->display(); break; case 'pdf': PHPWS_Core::initModClass('intern', 'InternshipFactory.php'); PHPWS_Core::initModClass('intern', 'InternshipContractPdfView.php'); PHPWS_Core::initModClass('intern', 'EmergencyContactFactory.php'); $i = InternshipFactory::getInternshipById($_REQUEST['id']); $emgContacts = EmergencyContactFactory::getContactsForInternship($i); $pdfView = new InternshipContractPdfView($i, $emgContacts); $pdf = $pdfView->getPdf(); $pdf->output(); exit; case 'upload_document_form': PHPWS_Core::initModClass('intern', 'Intern_Document_Manager.php'); $docManager = new Intern_Document_Manager(); echo $docManager->edit(); exit; break; case 'post_document_upload': PHPWS_Core::initModClass('intern', 'Intern_Document_Manager.php'); $docManager = new Intern_Document_Manager(); $docManager->postDocumentUpload(); break; case 'delete_document': PHPWS_Core::initModClass('intern', 'Intern_Document.php'); $doc = new Intern_Document($_REQUEST['doc_id']); $doc->delete(); NQ::simple('intern', INTERN_SUCCESS, 'Document deleted.'); NQ::close(); PHPWS_Core::goBack(); break; case 'addEmergencyContact': PHPWS_Core::initModClass('intern', 'command/AddEmergencyContact.php'); $ctrl = new AddEmergencyContact(); $ctrl->execute(); break; case 'removeEmergencyContact': PHPWS_Core::initModClass('intern', 'command/RemoveEmergencyContact.php'); $ctrl = new RemoveEmergencyContact(); $ctrl->execute(); break; case 'edit_faculty': PHPWS_Core::initModClass('intern', 'FacultyUI.php'); $facultyUI = new FacultyUI(); $this->content = $facultyUI->display(); break; case 'getFacultyListForDept': PHPWS_Core::initModClass('intern', 'command/GetFacultyListForDept.php'); $ctrl = new GetFacultyListForDept(); $ctrl->execute(); break; case 'restFacultyById': PHPWS_Core::initModClass('intern', 'command/RestFacultyById.php'); $ctrl = new RestFacultyById(); $ctrl->execute(); break; case 'facultyDeptRest': PHPWS_Core::initModClass('intern', 'command/FacultyDeptRest.php'); $ctrl = new FacultyDeptRest(); $ctrl->execute(); break; default: PHPWS_Core::initModClass('intern', 'UI/InternMenu.php'); $menu = new InternMenu(); $this->content = $menu->display(); break; } }
public function actionCreateOrg() { $reg_details = Registration::model()->count(); if ($reg_details == 0) { $this->redirect(array('registration/create')); } $this->layout = 'select_company_main'; $model = new Organization(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['Organization']['organization_name']) && !empty($_POST['Organization']['address_line1']) && !empty($_POST['Organization']['city']) && !empty($_POST['Organization']['state']) && !empty($_POST['Organization']['country']) && !empty($_POST['Organization']['pin']) && !empty($_POST['Organization']['phone']) && !empty($_POST['Organization']['no_of_semester']) && !empty($_POST['Organization']['email'])) { $country_model = new Country(); $country_model->name = $_POST['Organization']['country']; $country_model->save(); $state_model = new State(); $state_model->state_name = $_POST['Organization']['state']; $state_model->country_id = $country_model->id; $state_model->save(); $city_model = new City(); $city_model->city_name = $_POST['Organization']['city']; $city_model->country_id = $country_model->id; $city_model->state_id = $state_model->state_id; $city_model->save(); $model->attributes = $_POST['Organization']; $model->organization_created_by = 1; $model->organization_creation_date = new CDbExpression('NOW()'); if (!empty($_FILES['Organization']['tmp_name']['logo'])) { $file = CUploadedFile::getInstance($model, 'logo'); //$model->filename = $file->name; $model->file_type = $file->type; $fp = fopen($file->tempName, 'r'); $content = fread($fp, filesize($file->tempName)); fclose($fp); $model->logo = $content; } $model->city = $city_model->city_id; $model->state = $state_model->state_id; $model->country = $country_model->id; if ($model->save(false)) { $this->redirect(array('site/redirectLogin')); } } $this->render('create_org', array('model' => $model)); }
public function saveState(State $state) { // make sure that such state doesn't exist already $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('State', 'countryID'), $state->countryID->get())); $f->mergeCondition(new EqualsCond(new ARFieldHandle('State', 'code'), $state->code->get())); if (!ActiveRecordModel::getRecordCount('State', $f)) { return $state->save(); } }
private static function createStates() { $ps_state_iso_code_max_length = 7; if (version_compare(_PS_VERSION_, '1.5', '<')) { $ps_state_iso_code_max_length = 4; } foreach (SeurLib::$baleares_states as $iso_code => $state_name) { if (Tools::strlen($iso_code) > $ps_state_iso_code_max_length) { $tmpArray = explode('-', $iso_code); $iso_code = $tmpArray[0]; if (count($tmpArray) > 0) { $iso_code = 'E' . $tmpArray[1]; } } $exists_id = State::getIdByIso($iso_code); if (isset($exists_id) && !empty($exists_id)) { $state = new State($exists_id); $state->active = true; $state->id_zone = self::$baleares->id; if (!$state->update()) { return false; } } else { $state = new State(); $state->name = $state_name; $state->id_country = self::$spain->id; $state->id_zone = self::$baleares->id; $state->iso_code = $iso_code; $state->active = true; if (!$state->save()) { return false; } } } foreach (SeurLib::$canarias_states as $iso_code => $state_name) { if (Tools::strlen($iso_code) > $ps_state_iso_code_max_length) { $tmpArray = explode('-', $iso_code); $iso_code = $tmpArray[0]; if (count($tmpArray) > 0) { $iso_code = 'E' . $tmpArray[1]; } } $exists_id = State::getIdByIso($iso_code); if (isset($exists_id) && !empty($exists_id)) { $state = new State($exists_id); $state->active = true; $state->id_zone = self::$canarias->id; if (!$state->update()) { return false; } } else { $state = new State(); $state->name = $state_name; $state->id_country = self::$spain->id; $state->id_zone = self::$canarias->id; $state->iso_code = $iso_code; $state->active = true; if (!$state->save()) { return false; } } } foreach (SeurLib::$ceuta_melilla_states as $iso_code => $state_name) { if (Tools::strlen($iso_code) > $ps_state_iso_code_max_length) { $tmpArray = explode('-', $iso_code); $iso_code = $tmpArray[0]; if (count($tmpArray) > 0) { $iso_code = 'E' . $tmpArray[1]; } } $exists_id = State::getIdByIso($iso_code); if (isset($exists_id) && !empty($exists_id)) { $state = new State($exists_id); $state->id_zone = self::$ceuta_melilla->id; $state->active = true; if (!$state->update()) { return false; } } else { $state = new State(); $state->name = $state_name; $state->id_country = self::$spain->id; $state->id_zone = self::$ceuta_melilla->id; $state->iso_code = $iso_code; $state->active = true; if (!$state->save()) { return false; } } } foreach (SeurLib::$spain_states as $iso_code => $state_name) { if (Tools::strlen($iso_code) > $ps_state_iso_code_max_length) { $tmpArray = explode('-', $iso_code); $iso_code = $tmpArray[0]; if (count($tmpArray) > 0) { $iso_code = 'E' . $tmpArray[1]; } } $exists_id = State::getIdByIso($iso_code); if (isset($exists_id) && !empty($exists_id)) { $state = new State($exists_id); $state->active = true; if (Tools::strtoupper($state_name) == Tools::strtoupper(SeurLib::getMerchantField('state'))) { $state->id_zone = self::$provincia->id; } else { $state->id_zone = self::$peninsula->id; } if (!$state->update()) { return false; } } else { $state = new State(); $state->name = $state_name; $state->id_country = self::$spain->id; if (Tools::strtoupper($state_name) == Tools::strtoupper(SeurLib::getMerchantField('state'))) { $state->id_zone = self::$provincia->id; } else { $state->id_zone = self::$peninsula->id; } $state->iso_code = $iso_code; $state->active = true; if (!$state->save()) { return false; } } } return true; }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aOffer !== null) { if ($this->aOffer->isModified() || $this->aOffer->isNew()) { $affectedRows += $this->aOffer->save($con); } $this->setOffer($this->aOffer); } if ($this->aType !== null) { if ($this->aType->isModified() || $this->aType->isNew()) { $affectedRows += $this->aType->save($con); } $this->setType($this->aType); } if ($this->aTypology !== null) { if ($this->aTypology->isModified() || $this->aTypology->isNew()) { $affectedRows += $this->aTypology->save($con); } $this->setTypology($this->aTypology); } if ($this->aState !== null) { if ($this->aState->isModified() || $this->aState->isNew()) { $affectedRows += $this->aState->save($con); } $this->setState($this->aState); } if ($this->aKitchen !== null) { if ($this->aKitchen->isModified() || $this->aKitchen->isNew()) { $affectedRows += $this->aKitchen->save($con); } $this->setKitchen($this->aKitchen); } if ($this->asfAssetFolder !== null) { if ($this->asfAssetFolder->isModified() || $this->asfAssetFolder->isNew()) { $affectedRows += $this->asfAssetFolder->save($con); } $this->setsfAssetFolder($this->asfAssetFolder); } if ($this->isNew()) { $this->modifiedColumns[] = PropertyPeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = PropertyPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += PropertyPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
public function handleRequest() { /* Check if it is time to insert more terms into DB */ if (Term::isTimeToUpdate()) { Term::doTermUpdate(); } // Fetch the action from the REQUEST. if (!isset($_REQUEST['action'])) { $req = ""; } else { $req = $_REQUEST['action']; } // Show requested page. switch ($req) { case 'example_form': header('Content-type: application/pdf'); readfile(\PHPWS_SOURCE_DIR . 'mod/intern/pdf/Internship_Example.pdf'); exit; break; case 'ShowInternship': $ctrl = new Command\ShowInternship(); $this->content = $ctrl->execute(); break; case 'ShowAddInternship': $ctrl = new Command\ShowAddInternship(); $this->content = $ctrl->execute()->getView()->render(); break; case 'AddInternship': $ctrl = new Command\AddInternship(); $ctrl->execute(); break; case 'SaveInternship': $ctrl = new Command\SaveInternship(); $ctrl->execute(); break; case 'search': $view = new UI\SearchUI(); $this->content = $view->display(); break; case 'results': $view = new UI\ResultsUI(); $this->content = $view->display(); break; case 'showEditDept': $view = new UI\DepartmentUI(); $this->content = $view->display(); break; case 'edit_dept': if (isset($_REQUEST['add'])) { /* Add department with the name in REQUEST */ if (isset($_REQUEST['name'])) { Department::add($_REQUEST['name']); } else { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "Department must have name."); } } else { if (isset($_REQUEST['rename'])) { /* Rename dept with ID to new name that was passed in REQUEST */ if (isset($_REQUEST['id'])) { $d = new Department($_REQUEST['id']); $d->rename($_REQUEST['rename']); } else { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "No ID given. Cannot rename department."); } } else { if (isset($_REQUEST['hide'])) { /* Hide/Show department with ID passed in REQUEST. */ if (isset($_REQUEST['id'])) { $d = new Department($_REQUEST['id']); $d->hide($_REQUEST['hide'] == 1); } else { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "No ID given. Cannot hide department."); } } else { if (isset($_REQUEST['del'])) { /* Delete department with same ID passed in REQUEST. */ if (isset($_REQUEST['id'])) { $d = new Department($_REQUEST['id']); $d->del(); } else { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "No ID given. Cannot delete department."); } } } } } \PHPWS_Core::reroute('index.php?module=intern&action=showEditDept'); break; case 'showEditGradProgs': $view = new UI\GradProgramUI(); $this->content = $view->display(); break; case 'edit_grad': //TODO Separate these into their own controllers if (isset($_REQUEST['add'])) { /* Add grad program with the name in REQUEST */ if (isset($_REQUEST['name'])) { GradProgram::add($_REQUEST['name']); } else { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "Grad Program must have name."); } } else { if (isset($_REQUEST['rename'])) { /* Rename program with ID to new name that was passed in REQUEST */ if (isset($_REQUEST['id'])) { $g = new GradProgram($_REQUEST['id']); $g->rename($_REQUEST['rename']); } else { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "No ID given. Cannot rename graduate program."); } } else { if (isset($_REQUEST['hide'])) { /* Hide/Show program with ID passed in REQUEST. */ if (isset($_REQUEST['id'])) { $g = new GradProgram($_REQUEST['id']); $g->hide($_REQUEST['hide'] == 1); } else { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "No ID given. Cannot hide graduate program."); } } else { if (isset($_REQUEST['del'])) { /* Delete program with same ID passed in REQUEST. */ if (isset($_REQUEST['id'])) { $g = new GradProgram($_REQUEST['id']); $g->del(); } else { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "No ID given. Cannot delete graduate program."); } } } } } \PHPWS_Core::reroute('index.php?module=intern&action=showEditGradProgs'); break; case 'showEditMajors': $view = new UI\MajorUI(); $this->content = $view->display(); break; case 'edit_major': // TODO: Break these into their own commands if (isset($_REQUEST['add'])) { /* Add major with the name passed in REQUEST. */ if (isset($_REQUEST['name'])) { Major::add($_REQUEST['name']); } else { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "Major must have name."); } } else { if (isset($_REQUEST['rename'])) { /* Rename major with ID to new name that was passed in REQUEST */ if (isset($_REQUEST['id'])) { $m = new Major($_REQUEST['id']); $m->rename($_REQUEST['rename']); } else { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "No ID given. Cannot rename major."); } } else { if (isset($_REQUEST['hide'])) { /* Hide major with ID passed in REQUEST. */ if (isset($_REQUEST['id'])) { $m = new Major($_REQUEST['id']); $m->hide($_REQUEST['hide'] == 1); } else { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "No ID given. Cannot hide major."); } } else { if (isset($_REQUEST['del'])) { /* Delete major with same ID passed in REQUEST. */ if (isset($_REQUEST['id'])) { $m = new Major($_REQUEST['id']); $m->del(); } else { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "No ID given. Cannot delete major."); } } } } } \PHPWS_Core::reroute('index.php?module=intern&action=showEditMajors'); break; /** * Matt additions! */ /** * Matt additions! */ case 'add_state': if (!Current_User::allow('intern', 'edit_state')) { disallow(); } $state = new State($_GET['abbr']); $state->setActive(true); $state->save(); exit; break; case 'remove_state': if (!Current_User::allow('intern', 'edit_state')) { disallow(); } $state = new State($_GET['abbr']); $state->setActive(false); $state->save(); exit; break; case 'edit_states': if (!Current_User::allow('intern', 'edit_state')) { disallow(); } $view = new StateUI(); $this->content = $view->display(); break; case 'showEditAdmins': $view = new UI\AdminUI(); $this->content = $view->display(); break; case 'edit_admins': if (isset($_REQUEST['add'])) { // Add user in REQUEST to administrator list for the department in REQUEST. Admin::add($_REQUEST['username'], $_REQUEST['department_id']); } else { if (isset($_REQUEST['del'])) { // Delete the user in REQUEST from department in REQUEST. Admin::del($_REQUEST['username'], $_REQUEST['department_id']); } else { if (isset($_REQUEST['user_complete'])) { $users = Admin::searchUsers($_REQUEST['term']); echo json_encode($users); exit; } } } $view = new UI\AdminUI(); $this->content = $view->display(); break; case 'pdf': $i = InternshipFactory::getInternshipById($_REQUEST['internship_id']); $emgContacts = EmergencyContactFactory::getContactsForInternship($i); $pdfView = new InternshipContractPdfView($i, $emgContacts); $pdf = $pdfView->getPdf(); $pdf->output(); exit; case 'upload_document_form': $docManager = new DocumentManager(); echo $docManager->edit(); exit; break; case 'post_document_upload': $docManager = new DocumentManager(); $docManager->postDocumentUpload(); break; case 'delete_document': $doc = new InternDocument($_REQUEST['doc_id']); $doc->delete(); \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, 'Document deleted.'); \NQ::close(); \PHPWS_Core::goBack(); break; case 'addEmergencyContact': $ctrl = new Command\AddEmergencyContact(); $ctrl->execute(); break; case 'removeEmergencyContact': $ctrl = new Command\RemoveEmergencyContact(); $ctrl->execute(); break; case 'edit_faculty': $facultyUI = new UI\FacultyUI(); $this->content = $facultyUI->display(); break; case 'getFacultyListForDept': $ctrl = new Command\GetFacultyListForDept(); $ctrl->execute(); break; case 'restFacultyById': $ctrl = new Command\RestFacultyById(); $ctrl->execute(); break; case 'facultyDeptRest': $ctrl = new Command\FacultyDeptRest(); $ctrl->execute(); break; case 'GetSearchSuggestions': $ctrl = new Command\GetSearchSuggestions(); $ctrl->execute(); break; case 'GetAvailableStates': $ctrl = new Command\GetAvailableStates(); $ctrl->execute(); break; case 'GetAvailableCountries': $ctrl = new Command\GetAvailableCountries(); $ctrl->execute(); break; case 'GetDepartments': $ctrl = new Command\GetDepartments(); $ctrl->execute(); break; case 'GetAvailableTerms': $ctrl = new Command\GetAvailableTerms(); $ctrl->execute(); break; default: $menu = new UI\InternMenu(); $this->content = $menu->display(); break; } }