/** Get the selected ProfileTemplate object * @param $user_prefix A identifier provided by the programmer to recognise it's generated form * @return the ProfileTemplate object or null */ static function processLinkedProfileTemplateUI($user_prefix, $link_table, $link_table_obj_key_col, $link_table_obj_key) { $db = AbstractDb::getObject(); $link_table = $db->escapeString($link_table); $link_table_obj_key_col = $db->escapeString($link_table_obj_key_col); $link_table_obj_key = $db->escapeString($link_table_obj_key); // Profile templates already linked $current_content_sql = "SELECT * FROM {$link_table} WHERE {$link_table_obj_key_col}='{$link_table_obj_key}'"; $rows = null; $db->execSql($current_content_sql, $rows, false); if ($rows) { foreach ($rows as $row) { $profile_template = ProfileTemplate::getObject($row['profile_template_id']); $profile_template_id = $db->escapeString($profile_template->getId()); $name = "{$user_prefix}_" . $profile_template->GetId() . "_erase"; if (!empty($_REQUEST[$name])) { $sql = "DELETE FROM {$link_table} WHERE {$link_table_obj_key_col}='{$link_table_obj_key}' AND profile_template_id = '{$profile_template_id}';\n"; $db->execSqlUpdate($sql, false); } } } // Link an existing profile template $name = "{$user_prefix}_new_existing_add"; if (!empty($_REQUEST[$name])) { $name = "{$user_prefix}_new_existing"; $profile_template = ProfileTemplate::processSelectProfileTemplateUI($name); if ($profile_template) { $profile_template_id = $db->escapeString($profile_template->getId()); $sql = "INSERT INTO {$link_table} (profile_template_id, {$link_table_obj_key_col}) VALUES ('{$profile_template_id}', '{$link_table_obj_key}');\n"; $db->execSqlUpdate($sql, false); } } }
function getAllProfileTemplates() { $db = AbstractDb::getObject(); $retval = array(); $profile_template_rows = null; $sql = "SELECT profile_template_id FROM network_has_profile_templates WHERE network_id='{$this->_id}'"; $db->execSql($sql, $profile_template_rows, false); if ($profile_template_rows != null) { foreach ($profile_template_rows as $profile_template_row) { $retval[] = ProfileTemplate::getObject($profile_template_row['profile_template_id']); } } return $retval; }
/** * Retrieves the associated profile template * * @return ProfileTemplate object * * @access public */ public function getTemplate() { $retval = ProfileTemplate::getObject($this->_row['profile_template_id']); return $retval; }