public function prepareDefaultFieldValues($data, $defaultObj = '') { if (!$defaultObj) { $defaultObj = new Iati_WEP_AccountDefaultFieldValues(); } //set provided data. if ($data['default_language']) { $defaultObj->setLanguage($data['default_language']); } if ($data['default_currency']) { $defaultObj->setCurrency($data['default_currency']); } if ($data['default_reporting_org']) { $defaultObj->setReportingOrg($data['default_reporting_org']); } if ($data['hierarchy']) { $defaultObj->setHierarchy($data['hierarchy']); } if ($data['linked_data_default']) { $defaultObj->setLinkedDataDefault($data['linked_data_default']); } if ($data['reporting_org_ref']) { $defaultObj->setReportingOrgRef($data['reporting_org_ref']); } if ($data['reporting_org_type']) { $defaultObj->setReportingOrgType($data['reporting_org_type']); } if ($data['reporting_org_lang']) { $defaultObj->setReportingOrgLang($data['reporting_org_lang']); } if ($data['default_collaboration_type']) { $defaultObj->setCollaborationType($data['default_collaboration_type']); } if ($data['default_flow_type']) { $defaultObj->setFlowType($data['default_flow_type']); } if ($data['default_finance_type']) { $defaultObj->setFinanceType($data['default_finance_type']); } if ($data['default_aid_type']) { $defaultObj->setAidType($data['default_aid_type']); } if ($data['default_tied_status']) { $defaultObj->setTiedStatus($data['default_tied_status']); } $fieldString = serialize($defaultObj); return $fieldString; }
/** * Function to register an organisation by Superadmin */ public function registerAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $is_admin = false; $identity = $auth->getIdentity(); if ($identity->role == "superadmin") { $this->view->blockManager()->disable('partial/primarymenu.phtml'); $this->view->blockManager()->disable('partial/add-activity-menu.phtml'); $this->view->blockManager()->disable('partial/usermgmtmenu.phtml'); $this->view->blockManager()->disable('partial/published-list.phtml'); $this->view->blockManager()->enable('partial/superadmin-menu.phtml'); $this->view->blockManager()->enable('partial/dashboard.phtml'); $is_admin = true; } } $defaultFieldsValues = new Iati_WEP_AccountDefaultFieldValues(); $default['field_values'] = $defaultFieldsValues->getDefaultFields(); $defaultFieldGroup = new Iati_WEP_AccountDisplayFieldGroup(); $default['fields'] = $defaultFieldGroup->getProperties(); $form = new Form_Wep_Accountregister(); $form->add($default); if ($this->getRequest()->isPost()) { try { $data = $this->getRequest()->getPost(); $model = new Model_Wep(); if (!$form->isValid($data)) { $form->populate($data); } else { //Save Account Info $account['name'] = $data['organisation_name']; $account['address'] = $data['organisation_address']; $account['username'] = $data['organisation_username']; $account['uniqid'] = md5(date('Y-m-d H:i:s')); $account_id = $model->insertRowsToTable('account', $account); //Save User Info $user['user_name'] = trim($data['organisation_username']) . "_admin"; $user['password'] = md5($data['password']); $user['role_id'] = 1; $user['email'] = $data['email']; $user['account_id'] = $account_id; $user['status'] = 1; $user_id = $model->insertRowsToTable('user', $user); //Save User Profile $admin['first_name'] = $data['first_name']; $admin['middle_name'] = $data['middle_name']; $admin['last_name'] = $data['last_name']; $admin['user_id'] = $user_id; $admin_id = $model->insertRowsToTable('profile', $admin); //Save Default Fields $default = new Model_Defaults(); $default->createDefaults($data, $account_id); $privilegeFields['resource'] = serialize($defaultKey); $privilegeFields['owner_id'] = $account_id; $privilegeFieldId = $model->insertRowsToTable('Privilege', $privilegeFields); //Send notification $data['user_name'] = $user['user_name']; $notification = new Model_Notification(); $notification->sendRegistrationNotifications($data); $this->_helper->FlashMessenger->addMessage(array('message' => "Account successfully registered.")); $this->_redirect('admin/list-organisation'); } } catch (Exception $e) { print $e->getMessage(); } } // Populate form with basic recommended default groups. $basic['default_fields'] = Iati_WEP_AccountDisplayFieldGroup::$defaults; $form->populate($basic); $this->view->form = $form; $this->view->blockManager()->disable('partial/primarymenu.phtml'); }