$socialnetworkoptions = array(); foreach (ArtefactTypeSocialprofile::$socialnetworks as $socialnetwork) { $socialnetworkoptions[$socialnetwork] = get_string($socialnetwork . '.input', 'artefact.internal'); } $editform = array('name' => 'editprofileform', 'class' => 'form-editprofile', 'plugintype' => 'artefact', 'pluginname' => 'internal', 'elements' => array('id' => array('type' => 'hidden', 'value' => $id), 'profiletype' => array('type' => 'select', 'class' => 'select-with-input', 'title' => get_string('profiletype', 'artefact.internal'), 'options' => $socialnetworkoptions, 'allowother' => true, 'defaultvalue' => $note, 'width' => 171, 'rules' => array('required' => true)), 'profileurl' => array('type' => 'text', 'title' => get_string('profileurl', 'artefact.internal'), 'description' => get_string('profileurldesc', 'artefact.internal'), 'defaultvalue' => $title, 'size' => 40, 'rules' => array('required' => true)), 'submit' => array('type' => 'submitcancel', 'class' => 'btn-success', 'value' => array(get_string('save'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'artefact/internal/index.php?fs=social'))); $form = pieform($editform); $message = null; if ($id > 0) { $subheading = get_string('editthisprofile', 'artefact.internal', $toedit->get('description')); } else { $subheading = get_string('newsocialprofile', 'artefact.internal'); } } $smarty = smarty(); $smarty->assign('PAGEHEADING', TITLE); $smarty->assign('navtabs', PluginArtefactInternal::submenu_items()); $smarty->assign('subheading', $subheading); $smarty->assign('form', $form); $smarty->assign('message', $message); $smarty->display('artefact:internal:socialprofile.tpl'); // Delete social profile function deleteprofileform_submit(Pieform $form, $values) { global $SESSION, $todelete; $todelete->delete(); $SESSION->add_ok_msg(get_string('profiledeletedsuccessfully', 'artefact.internal')); redirect(get_config('wwwroot') . 'artefact/internal/index.php?fs=social'); } function editprofileform_validate(Pieform $form, $values) { global $USER;
/** * Sister method to export_blockinstance_config_leap (creates block * instance based of what that method exports) * * @param array $biconfig The block instance config * @param array $viewconfig The view config * @return BlockInstance The newly made block instance */ public static function import_create_blockinstance_leap(array $biconfig, array $viewconfig) { return PluginArtefactInternal::import_create_blockinstance_leap($biconfig, $viewconfig); }
public static function rewrite_blockinstance_config(View $view, $configdata) { if ($view->get('owner') !== null) { $artefacttypes = array_diff(PluginArtefactInternal::get_contactinfo_artefact_types(), array('email')); $artefactids = get_column_sql(' SELECT id FROM {artefact} WHERE owner = ? AND artefacttype IN (' . join(',', array_map('db_quote', $artefacttypes)) . ')', array($view->get('owner'))); $configdata['artefactids'] = $artefactids; if (isset($configdata['email'])) { if ($newemail = get_field('artefact_internal_profile_email', 'artefact', 'principal', 1, 'owner', $view->get('owner'))) { $configdata['email'] = $newemail; } else { unset($configdata['email']); } } } else { $configdata['artefactids'] = array(); } return $configdata; }
/** * Given a query string and limits, return an array of matching objects * owned by the current user. Possible return types are ... * - artefact * - view * * Implementations of this search should search across tags for artefacts * and views at a minimum. Ideally the search would also index * title/description and other metadata for these objects. * * NOTE: This implementation of internal search only does artefacts, and * badly at that. See the bug tracker for more information. * * @param string The query string * @param integer How many results to return * @param integer What result to start at (0 == first result) * @param string Type to search for (either 'all' or one of the types above). * */ public static function self_search($querystring, $limit, $offset, $type = 'all') { global $USER; if (trim($querystring) == '') { return false; } // Tokenise the search $querydata = self::search_parse_query($querystring); $sql = "\n SELECT\n a.id, a.artefacttype, a.title, a.description\n FROM\n {artefact} a\n LEFT JOIN {artefact_tag} at ON (at.artefact = a.id)\n WHERE\n a.owner = ?\n AND (\n ({$querydata['0']})\n OR\n (LOWER(at.tag) = ?)\n )"; $count_sql = "\n SELECT\n COUNT(*)\n FROM\n {artefact} a\n LEFT JOIN {artefact_tag} at ON (at.artefact = a.id)\n WHERE\n a.owner = ?\n AND (\n ({$querydata['0']})\n OR\n (LOWER(at.tag) = ?)\n )"; array_unshift($querydata[1], $USER->get('id')); array_push($querydata[1], strtolower($querystring)); $results = array('data' => get_records_sql_array($sql, $querydata[1], $offset, $limit), 'offset' => $offset, 'limit' => $limit, 'count' => get_field_sql($count_sql, $querydata[1])); if ($results['data']) { require_once get_config('docroot') . 'artefact/lib.php'; foreach ($results['data'] as &$result) { $newresult = array(); foreach ($result as $key => &$value) { if ($key == 'id' || $key == 'artefacttype' || $key == 'title' || $key == 'description') { $newresult[$key] = $value; } } $newresult['type'] = 'artefact'; $artefact = artefact_instance_from_id($newresult['id']); $artefactplugin = $artefact->get_plugin_name(); if ($artefactplugin == 'internal' && in_array($artefact->get('artefacttype'), PluginArtefactInternal::get_profile_artefact_types())) { // Profile artefact $newresult['summary'] = $newresult['title']; $newresult['title'] = get_string($artefact->get('artefacttype'), 'artefact.' . $artefactplugin); } else { $newresult['summary'] = $newresult['description']; } $newresult['summary'] = clean_html($newresult['summary']); $result = $newresult; } self::self_search_make_links($results); } return $results; }
$socialnetworkoptions = array(); foreach (ArtefactTypeSocialprofile::$socialnetworks as $socialnetwork) { $socialnetworkoptions[$socialnetwork] = get_string($socialnetwork . '.input', 'artefact.internal'); } $editform = array('name' => 'editprofileform', 'plugintype' => 'artefact', 'pluginname' => 'internal', 'elements' => array('id' => array('type' => 'hidden', 'value' => $id), 'profiletype' => array('type' => 'select', 'title' => get_string('profiletype', 'artefact.internal'), 'options' => $socialnetworkoptions, 'allowother' => true, 'defaultvalue' => $note, 'width' => 171, 'rules' => array('required' => true)), 'profileurl' => array('type' => 'text', 'title' => get_string('profileurl', 'artefact.internal'), 'description' => get_string('profileurldesc', 'artefact.internal'), 'defaultvalue' => $title, 'size' => 40, 'rules' => array('required' => true)), 'submit' => array('type' => 'submitcancel', 'value' => array(get_string('save'), get_string('cancel')), 'goto' => get_config('wwwroot') . '/artefact/internal/index.php?fs=social'))); $form = pieform($editform); $message = null; if ($id > 0) { $subheading = get_string('editthisprofile', 'artefact.internal', $toedit->get('description')); } else { $subheading = get_string('newsocialprofile', 'artefact.internal'); } } $smarty = smarty(); $smarty->assign('PAGEHEADING', TITLE); $smarty->assign('SUBPAGENAV', PluginArtefactInternal::submenu_items()); $smarty->assign('subheading', $subheading); $smarty->assign('form', $form); $smarty->assign('message', $message); $smarty->display('artefact:internal:socialprofile.tpl'); // Delete social profile function deleteprofileform_submit(Pieform $form, $values) { global $SESSION, $todelete; $todelete->delete(); $SESSION->add_ok_msg(get_string('profiledeletedsuccessfully', 'artefact.internal')); redirect('/artefact/internal/index.php?fs=social'); } function editprofileform_validate(Pieform $form, $values) { global $USER;