function render() { $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->_TPL_PATH); $visit = CerberusApplication::getVisit(); $response = DevblocksPlatform::getHttpResponse(); $stack = $response->path; @array_shift($stack); // contacts @($selected_tab = array_shift($stack)); // orgs|addresses|* $tpl->assign('selected_tab', $selected_tab); // Allow a non-tab renderer switch ($selected_tab) { case 'import': switch (@array_shift($stack)) { case 'step2': $type = $visit->get('import.last.type', ''); switch ($type) { case 'orgs': $fields = DAO_ContactOrg::getFields(); $tpl->assign('fields', $fields); $custom_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Org::ID); $tpl->assign('custom_fields', $custom_fields); break; case 'addys': $fields = DAO_Address::getFields(); $tpl->assign('fields', $fields); $custom_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Address::ID); $tpl->assign('custom_fields', $custom_fields); break; } $tpl->display('file:' . $this->_TPL_PATH . 'contacts/import/mapping.tpl'); return; break; } break; // [TODO] The org display page should probably move to its own controller // [TODO] The org display page should probably move to its own controller case 'orgs': switch (@array_shift($stack)) { case 'display': $tab_manifests = DevblocksPlatform::getExtensions('cerberusweb.org.tab', false); $tpl->assign('tab_manifests', $tab_manifests); $id = array_shift($stack); $contact = DAO_ContactOrg::get($id); $tpl->assign('contact', $contact); $task_count = DAO_Task::getCountBySourceObjectId('cerberusweb.tasks.org', $contact->id); $tpl->assign('tasks_total', $task_count); $people_count = DAO_Address::getCountByOrgId($contact->id); $tpl->assign('people_total', $people_count); // Does a series exist? // [TODO] This is highly redundant if (null != ($series_info = $visit->get('ch_org_series', null))) { @($series = $series_info['series']); // Is this ID part of the series? If not, invalidate if (!isset($series[$contact->id])) { $visit->set('ch_org_series', null); } else { $series_stats = array('title' => $series_info['title'], 'total' => $series_info['total'], 'count' => count($series)); reset($series); $cur = 1; while ($pos = key($series)) { if (intval($pos) == intval($contact->id)) { $series_stats['cur'] = $cur; if (false !== prev($series)) { @($series_stats['prev'] = key($series)); next($series); // skip to current } else { reset($series); } next($series); // next @($series_stats['next'] = key($series)); break; } next($series); $cur++; } $tpl->assign('series_stats', $series_stats); } } $tpl->display('file:' . $this->_TPL_PATH . 'contacts/orgs/display.tpl'); return; break; // case 'orgs/display' } // switch (action) break; } // switch (tab) $tpl->display('file:' . $this->_TPL_PATH . 'contacts/index.tpl'); return; // case 'people': // $view = C4_AbstractViewLoader::getView('addybook_people'); // C4_AddressView::DEFAULT_ID // // if(null == $view) { // $view = new C4_AddressView(); // $view->id = 'addybook_people'; // $view->name = 'People'; // $view->params = array( // new DevblocksSearchCriteria(SearchFields_Address::CONTACT_ORG_ID,'!=',0), // ); // // C4_AbstractViewLoader::setView('addybook_people', $view); // } // // $tpl->assign('view', $view); // $tpl->assign('contacts_page', 'people'); // $tpl->assign('view_fields', C4_AddressView::getFields()); // $tpl->assign('view_searchable_fields', C4_AddressView::getSearchFields()); // $tpl->display('file:' . $this->_TPL_PATH . 'contacts/people/index.tpl'); // break; }
private function _putIdAction($path) { $xmlstr = $this->getPayload(); $xml_in = new SimpleXMLElement($xmlstr); $in_id = array_shift($path); if (empty($in_id)) { $this->_error("ID was not provided."); } if (null == ($address = DAO_Address::get($in_id))) { $this->_error("ID not valid."); } $fields = array(); $flds = DAO_Address::getFields(); unset($flds[DAO_Address::ID]); foreach ($flds as $idx => $f) { $idx_name = $this->translate($idx, true); if ($idx_name == null) { continue; } @($value = DevblocksPlatform::importGPC($xml_in->{$idx_name}, 'string')); if ($this->isValid($idx_name, $value)) { $fields[$idx] = $value; } } // [TODO] This referential integrity should really be up to DAO if (!empty($fields[DAO_Address::CONTACT_ORG_ID])) { $in_contact_org_id = intval($fields[DAO_Address::CONTACT_ORG_ID]); if (null == ($contact_org = DAO_ContactOrg::get($in_contact_org_id))) { unset($fields[DAO_Address::CONTACT_ORG_ID]); } } if (!empty($fields)) { DAO_Address::update($address->id, $fields); } // update password if requested @($password = DevblocksPlatform::importGPC($xml_in->password, 'string', '')); if (!empty($password)) { DAO_AddressAuth::update($in_id, array(DAO_AddressAuth::PASS => md5($password))); } // send confirmation if requested @($confirmation_link = DevblocksPlatform::importGPC($xml_in->send_confirmation, 'string', '')); if (!empty($confirmation_link)) { $this->_sendConfirmation($address->email, $confirmation_link); } $this->_getIdAction(array($address->id)); }