public static function render_instance(BlockInstance $instance, $editing = false) { require_once get_config('docroot') . 'artefact/lib.php'; $smarty = smarty_core(); $filter = param_alpha('filter', 'all'); $offset = param_integer('offset', 0); $limit = 1000; //get list online friend $result_friend_online_id = get_onlinefriends($limit, $offset); $str_eselma_online = implode(',', $result_friend_online_id['data']); if ($str_eselma_online) { $query_result_friend_online = "\n SELECT *\n FROM {usr}\n WHERE id in ({$str_eselma_online})\n "; $result_friend_online = get_records_sql_array($query_result_friend_online); } //get list offline friend $result_friend_offline_id = get_offlinefriends($limit, $offset); $str_eselma_offline = implode(',', $result_friend_offline_id['data']); if ($str_eselma_offline) { $query_result_friend_offline = "\n SELECT *\n FROM {usr}\n WHERE id in ({$str_eselma_offline})\n "; $result_friend_offline = get_records_sql_array($query_result_friend_offline); } $smarty->assign('eselma_get_online', $result_friend_online); $smarty->assign('eselma_get_offline', $result_friend_offline); $smarty->assign('lastminutes', floor(get_config('accessidletimeout') / 60)); $smarty->assign('eselma_count_online', $result_friend_online_id['count']); $smarty->assign('eselma_count_offline', $result_friend_offline_id['count']); return $smarty->fetch('blocktype:eselmaonoff:content.tpl'); }
function sendmessage_submit(Pieform $form, $values) { global $USER, $SESSION, $id; $user = get_record('usr', 'id', $id); send_user_message($user, $values['message']); $SESSION->add_ok_msg(get_string('messagesent', 'group')); switch (param_alpha('returnto', 'myfriends')) { case 'find': redirect('/user/find.php'); break; case 'view': redirect('/user/view.php?id=' . $id); break; default: redirect('/user/myfriends.php'); break; } }
function denyrequest_submit(Pieform $form, $values) { global $USER, $SESSION, $id; $loggedinid = $USER->get('id'); $user = get_record('usr', 'id', $id); // friend db record $f = new StdClass(); $f->ctime = db_format_timestamp(time()); // notification info $n = new StdClass(); $n->url = profile_url($USER, false); $n->users = array($user->id); $n->fromuser = $USER->get('id'); $lang = get_user_language($user->id); $displayname = display_name($USER, $user); $n->urltext = $displayname; delete_records('usr_friend_request', 'owner', $loggedinid, 'requester', $id); $n->subject = get_string_from_language($lang, 'friendrequestrejectedsubject', 'group'); if (isset($values['reason']) && !empty($values['reason'])) { $n->message = get_string_from_language($lang, 'friendrequestrejectedmessagereason', 'group', $displayname) . $values['reason']; } else { $n->message = get_string_from_language($lang, 'friendrequestrejectedmessage', 'group', $displayname); } require_once 'activity.php'; activity_occurred('maharamessage', $n); handle_event('removefriendrequest', array('owner' => $loggedinid, 'requester' => $id)); $SESSION->add_ok_msg(get_string('friendformrejectsuccess', 'group')); $offset = param_integer('offset', 0); switch (param_alpha('returnto', 'myfriends')) { case 'find': $goto = 'user/find.php'; break; case 'view': $goto = profile_url($user, false); break; default: $goto = 'user/myfriends.php'; break; } $goto .= strpos($goto, '?') ? '&offset=' . $offset : '?offset=' . $offset; $goto = get_config('wwwroot') . $goto; redirect($goto); }
public static function render_instance(BlockInstance $instance, $editing = false) { require_once get_config('docroot') . 'artefact/lib.php'; global $USER; $smarty = smarty_core(); $filter = param_alpha('filter', 'canjoin'); $query = param_variable('query', ''); // check that the filter is valid, if not default to 'all' if (in_array($filter, array('member', 'notmember', 'canjoin'))) { $type = $filter; } else { // all or some other text $filter = 'all'; $type = 'all'; } $filter_elements = array(); $filter_elements['query'] = array('title' => get_string('search'), 'defaultvalue' => $query); $filter_elements['filter'] = array('title' => get_string('filter'), 'options' => array('canjoin' => get_string('groupsicanjoin', 'group'), 'notmember' => get_string('groupsnotin', 'group'), 'member' => get_string('groupsimin', 'group'), 'all' => get_string('allgroups', 'group')), 'defaultvalue' => $filter); $filter_elements['search'] = array('type' => 'submit', 'value' => get_string('search')); $smarty->assign('filter_elements', $filter_elements); return $smarty->fetch('blocktype:eselmasearchgroup:content.tpl'); }
function requestfriendship_submit(Pieform $form, $values) { global $USER, $SESSION, $id; $loggedinid = $USER->get('id'); $user = get_record('usr', 'id', $id); // friend db record $f = new StdClass(); $f->ctime = db_format_timestamp(time()); // notification info $n = new StdClass(); $n->url = get_config('wwwroot') . 'user/view.php?id=' . $loggedinid; $n->users = array($user->id); $lang = get_user_language($user->id); $displayname = display_name($USER, $user); $f->owner = $id; $f->requester = $loggedinid; $f->message = $values['message']; insert_record('usr_friend_request', $f); $n->subject = get_string_from_language($lang, 'requestedfriendlistsubject', 'group'); if (isset($values['message']) && !empty($values['message'])) { $n->message = get_string_from_language($lang, 'requestedfriendlistmessagereason', 'group', $displayname) . $values['message']; } else { $n->message = get_string_from_language($lang, 'requestedfriendlistmessage', 'group', $displayname); } require_once 'activity.php'; activity_occurred('maharamessage', $n); $SESSION->add_ok_msg(get_string('friendformrequestsuccess', 'group', display_name($id))); switch (param_alpha('returnto', 'myfriends')) { case 'find': redirect('/user/find.php'); break; case 'view': redirect('/user/view.php?id=' . $id); break; default: redirect('/user/myfriends.php'); break; } }
<?php /** * * @package mahara * @subpackage core * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('JSON', 1); require dirname(dirname(__FILE__)) . '/init.php'; require_once 'searchlib.php'; $tag = param_variable('tag', null); $limit = param_integer('limit', 10); $offset = param_integer('offset', 0); $sort = param_alpha('sort', 'name'); $type = param_alpha('type', null); $owner = (object) array('type' => 'user', 'id' => $USER->get('id')); $data = get_portfolio_items_by_tag($tag, $owner, $limit, $offset, $sort, $type); build_portfolio_search_html($data); $data->tagdisplay = is_null($tag) ? get_string('alltags') : hsc(str_shorten_text($tag, 50)); $data->tagurl = urlencode($tag); json_reply(false, array('data' => $data));
* @subpackage skin * @author Gregor Anzelj * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * @copyright (C) 2010-2013 Gregor Anzelj <*****@*****.**> * */ define('INTERNAL', true); define('SECTION_PLUGINTYPE', 'core'); define('SECTION_PLUGINNAME', 'skin'); define('SECTION_PAGE', 'design'); require_once dirname(dirname(__FILE__)) . '/init.php'; require_once 'skin.php'; require_once 'pieforms/pieform.php'; safe_require('artefact', 'file'); $fieldset = param_alpha('fs', 'viewskin'); $designsiteskin = param_boolean('site', false); if (!can_use_skins(null, $designsiteskin)) { throw new FeatureNotEnabledException(); } if ($designsiteskin) { define('ADMIN', 1); if (!$USER->get('admin')) { $SESSION->add_error_msg(get_string('accessforbiddentoadminsection')); redirect(); } define('MENUITEM', 'configsite/siteskins'); $goto = '/admin/site/skins.php'; $redirect = '/admin/site/skins.php'; } else { define('MENUITEM', 'myportfolio/skins');
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package mahara * @subpackage core * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz * */ define('INTERNAL', 1); define('MENUITEM', 'groups'); require dirname(dirname(__FILE__)) . '/init.php'; require_once 'pieforms/pieform.php'; require 'group.php'; $groupid = param_integer('id'); $returnto = param_alpha('returnto', 'mygroups'); define('GROUP', $groupid); $group = group_current_group(); define('TITLE', $group->name); if (!group_user_access($group->id)) { throw new AccessDeniedException(get_string('notamember', 'group')); } if (!group_user_can_leave($group)) { throw new AccessDeniedException(get_string('cantleavegroup', 'group')); } $goto = get_config('wwwroot') . 'group/' . $returnto . '.php' . ($returnto == 'view' ? '?id=' . $groupid : ''); $views = count_records_sql('SELECT COUNT(*) FROM {view} v INNER JOIN {view_access_group} a ON a.group = ? AND a.view = v.id
* @package mahara * @subpackage core * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('MENUITEM', 'groups/members'); require dirname(dirname(__FILE__)) . '/init.php'; require_once 'group.php'; require_once get_config('docroot') . 'interaction/lib.php'; define('GROUP', param_integer('group')); $group = group_current_group(); $userid = param_integer('user'); $newrole = param_alpha('role', null); if (!($user = get_record('usr', 'id', $userid, 'deleted', 0))) { throw new UserNotFoundException("Couldn't find user with id {$userid}"); } $currentrole = group_user_access($group->id, $userid); if (!$currentrole) { throw new UserNotFoundException("Couldn't find user with id {$userid} in group {$group->id}"); } $role = group_user_access($group->id); if ($role != 'admin') { throw new AccessDeniedException(); } $roles = group_get_role_info($group->id); $rolechange_available = false; foreach ($roles as &$r) { $disabled = !group_can_change_role($group->id, $userid, $r->role);
function edit_interaction_submit(Pieform $form, $values) { safe_require('interaction', $values['plugin']); $classname = generate_interaction_instance_class_name($values['plugin']); $instance = new $classname($values['id']); $instance->set('creator', $values['creator']); $instance->set('title', $values['title']); $instance->set('description', $values['description']); if (empty($values['id'])) { $instance->set('group', $values['group']); } $instance->commit(); call_static_method(generate_class_name('interaction', $values['plugin']), 'instance_config_save', $instance, $values); global $SESSION; $SESSION->add_ok_msg(get_string('interactionsaved', 'group', get_string('name', 'interaction.' . $values['plugin']))); $returnto = param_alpha('returnto', 'view'); if ($returnto == 'index') { redirect('/interaction/' . $values['plugin'] . '/index.php?group=' . $instance->get('group')); } else { redirect('/interaction/' . $values['plugin'] . '/view.php?id=' . $instance->get('id')); } }
* @package mahara * @subpackage interaction * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz * */ define('INTERNAL', 1); define('MENUITEM', 'groups'); require dirname(dirname(__FILE__)) . '/init.php'; require_once get_config('docroot') . 'interaction/lib.php'; require_once 'pieforms/pieform.php'; require_once 'group.php'; $id = param_integer('id'); $instance = interaction_instance_from_id($id); define('GROUP', $instance->get('group')); $group = group_current_group(); $membership = group_user_access((int) $group->id); if ($membership != 'admin') { throw new AccessDeniedException(get_string('notallowedtodeleteinteractions', 'group')); } define('TITLE', get_string('deleteinteraction', 'group', get_string('name', 'interaction.' . $instance->get('plugin')), $instance->get('title'))); // submit handler in interaction/lib.php $returnto = param_alpha('returnto', 'view'); $form = pieform(array('name' => 'delete_interaction', 'renderer' => 'div', 'elements' => array('id' => array('type' => 'hidden', 'value' => $id), 'submit' => array('type' => 'submitcancel', 'value' => array(get_string('yes'), get_string('no')), 'goto' => get_config('wwwroot') . 'interaction/' . $instance->get('plugin') . ($returnto == 'index' ? '/index.php?group=' . $instance->get('group') : '/view.php?id=' . $instance->get('id')))))); $smarty = smarty(array('tablerenderer')); $smarty->assign('form', $form); $smarty->assign('heading', $group->name); $smarty->assign('subheading', TITLE); $smarty->assign('message', get_string('deleteinteractionsure', 'group')); $smarty->display('interaction/delete.tpl');
* @subpackage admin * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('INSTITUTIONALADMIN', 1); define('MENUITEM', 'managegroups/archives'); require dirname(dirname(dirname(__FILE__))) . '/init.php'; define('TITLE', get_string('archivedsubmissions', 'admin')); define('SECTION_PLUGINTYPE', 'core'); define('SECTION_PLUGINNAME', 'admin'); define('SECTION_PAGE', 'archives'); require_once 'searchlib.php'; $search = (object) array('query' => trim(param_variable('query', '')), 'sortby' => param_alpha('sortby', 'firstname'), 'sortdir' => param_alpha('sortdir', 'asc')); $offset = param_integer('offset', 0); $limit = param_integer('limit', 10); if ($USER->get('admin')) { $institutions = get_records_array('institution', '', '', 'displayname'); $search->institution = param_alphanum('institution', 'all'); } else { $institutionnames = array_keys($USER->get('admininstitutions')); $institutions = get_records_select_array('institution', 'suspended = 0 AND name IN (' . join(',', array_fill(0, count($institutionnames), '?')) . ')', $institutionnames, 'displayname'); } list($html, $columns, $pagination, $search) = build_admin_archived_submissions_results($search, $offset, $limit); $js = <<<EOF addLoadEvent(function() { var p = {$pagination['javascript']} new UserSearch(p);
function edittopic_submit(Pieform $form, $values) { global $SESSION, $USER, $topic; $topicid = param_integer('id'); $returnto = param_alpha('returnto', 'topic'); $groupid = get_field_sql("SELECT DISTINCT i.group FROM {interaction_instance} i\n INNER JOIN {interaction_forum_topic} t ON i.id = t.forum\n WHERE t.id =?", array($topicid)); db_begin(); // check the post content actually changed // otherwise topic could have been set as sticky/closed $postchanged = $values['subject'] != $topic->subject || $values['body'] != $topic->body; if ($postchanged) { $newbody = EmbeddedImage::prepare_embedded_images($values['body'], 'topic', $topicid, $groupid); update_record('interaction_forum_post', array('subject' => $values['subject'], 'body' => PluginInteractionForum::prepare_post_body($newbody, $values['post'])), array('id' => $values['post'])); } if ($values['editrecord'] && $postchanged) { insert_record('interaction_forum_edit', (object) array('user' => $USER->get('id'), 'post' => $values['post'], 'ctime' => db_format_timestamp(time()))); } if (isset($values['sticky'])) { update_record('interaction_forum_topic', array('sticky' => isset($values['sticky']) && $values['sticky'] == 1 ? 1 : 0, 'closed' => isset($values['closed']) && $values['closed'] == 1 ? 1 : 0), array('id' => $topicid)); } db_commit(); $SESSION->add_ok_msg(get_string('edittopicsuccess', 'interaction.forum')); if ($returnto == 'view') { redirect('/interaction/forum/view.php?id=' . $topic->forum); } else { redirect('/interaction/forum/topic.php?id=' . $topicid); } }
} define('TITLE', get_string('sendmessageto', 'module.multirecipientnotification')); $returnto = param_alpha('returnto', 'myfriends'); $offset = param_integer('offset', 0); switch ($returnto) { case 'find': $goto = 'user/find.php'; break; case 'view': $goto = profile_url($user, false); break; case 'inbox': $goto = 'account/activity'; break; case 'institution': $goto = ($inst = param_alpha('inst', null)) ? 'institution/index.php?institution=' . $inst : 'account/activity'; break; default: $goto = 'module/multirecipientnotification/outbox.php'; break; } if ($offset > 0) { $goto .= strpos($goto, '?') ? '&offset=' . $offset : '?offset=' . $offset; } $form = pieform(array('name' => 'sendmessage', 'autofocus' => false, 'validatecallback' => 'sendmessage_validate', 'elements' => array('recipients' => array('type' => 'autocomplete', 'title' => get_string('titlerecipient', 'module.multirecipientnotification'), 'defaultvalue' => $users, 'ajaxurl' => get_config('wwwroot') . 'module/multirecipientnotification/sendmessage.json.php', 'initfunction' => 'translate_ids_to_names', 'multiple' => true, 'ajaxextraparams' => array(), 'rules' => array('required' => true)), 'subject' => array('title' => get_string('titlesubject', 'module.multirecipientnotification'), 'type' => 'text', 'name' => 'subject', 'size' => '40', 'defaultvalue' => $subject, 'rules' => array('required' => true)), 'message' => array('type' => 'textarea', 'title' => $messages ? get_string('Reply', 'group') : get_string('message'), 'cols' => 80, 'rows' => 10, 'rules' => array('maxlength' => 65536, 'required' => true)), 'goto' => array('type' => 'hidden', 'value' => $goto), 'submit' => array('type' => 'submitcancel', 'class' => 'btn-success', 'value' => array($messages ? get_string('Reply', 'group') : get_string('sendmessage', 'group'), get_string('cancel')), 'goto' => get_config('wwwroot') . $goto)))); $javascripts = array('module/multirecipientnotification/js/sendmessage.js'); $smarty = smarty($javascripts); $smarty->assign('PAGEHEADING', TITLE); $smarty->assign('form', $form); $smarty->assign('user', $USER); $smarty->assign('messages', $messages);
require_once get_config('libroot') . 'view.php'; $query = param_variable('query', null); $tag = param_variable('tag', null); $limit = param_integer('limit', 10); $offset = param_integer('offset', 0); $queryparams = array(); if (!empty($tag)) { $queryparams['tag'] = $tag; $query = null; } else { if ($query != '') { $queryparams['query'] = $query; } } $sortoptions = array('lastchanged', 'mtime', 'ownername', 'title'); if (!in_array($sort = param_alpha('sort', 'lastchanged'), $sortoptions)) { $sort = 'lastchanged'; } if ($sort !== 'lastchanged') { $queryparams['sort'] = $sort; } $sortdir = $sort == 'lastchanged' || $sort == 'mtime' ? 'desc' : 'asc'; $shareoptions = array('user', 'friend', 'group', 'institution', 'loggedin', 'public'); $share = param_variable('share', array()); if (is_array($share)) { $share = $queryparams['share'] = array_intersect($share, $shareoptions); } else { $share = null; } $data = View::shared_to_user($query, $tag, $limit, $offset, $sort, $sortdir, $share); $pagination = build_pagination(array('id' => 'sharedviews_pagination', 'url' => get_config('wwwroot') . 'view/sharedviews.php' . (empty($queryparams) ? '' : '?' . http_build_query($queryparams)), 'jsonscript' => '/json/sharedviews.php', 'datatable' => 'sharedviewlist', 'count' => $data->count, 'limit' => $limit, 'offset' => $offset, 'setlimit' => true, 'jumplinks' => 8, 'numbersincludeprevnext' => 2));
* @subpackage admin * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('INSTITUTIONALADMIN', 1); define('MENUITEM', 'configusers/suspendedusers'); require dirname(dirname(dirname(__FILE__))) . '/init.php'; define('TITLE', get_string('suspendeduserstitle', 'admin')); define('SECTION_PLUGINTYPE', 'core'); define('SECTION_PLUGINNAME', 'admin'); define('SECTION_PAGE', 'suspendedusers'); require_once 'pieforms/pieform.php'; $type = param_alpha('type', 'suspended') == 'expired' ? 'expired' : 'suspended'; $enc_type = json_encode($type); $typeform = pieform(array('name' => 'usertype', 'class' => 'with-heading with-label-widthauto form-condensed', 'elements' => array('type' => array('type' => 'select', 'title' => get_string('show'), 'options' => array('suspended' => get_string('suspendedusers', 'admin'), 'expired' => get_string('expiredusers', 'admin')), 'defaultvalue' => $type), 'typesubmit' => array('type' => 'submit', 'class' => 'js-hidden', 'value' => get_string('change'))))); $smarty = smarty(array('tablerenderer')); setpageicon($smarty, 'icon-user-times'); $smarty->assign('typeform', $typeform); $smarty->assign('INLINEJAVASCRIPT', <<<EOF var suspendedlist = new TableRenderer( 'suspendedlist', 'suspended.json.php', [ 'name', function (r) { return TD(null, r.institutions ? map(partial(DIV, null), r.institutions) : null); }, function (r) {
* @package mahara * @subpackage core * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('STAFF', 1); define('JSON', 1); require dirname(dirname(__FILE__)) . '/init.php'; require get_config('libroot') . 'registration.php'; $limit = param_integer('limit', 10); $offset = param_integer('offset', 0); $extradata = json_decode(param_variable('extradata')); $type = param_alpha('type', 'users'); $subpages = array('users', 'groups', 'views', 'content', 'historical', 'institutions'); if (!in_array($type, $subpages)) { $type = 'users'; } if ($type == 'historical') { $field = isset($extradata->field) ? $extradata->field : 'count_usr'; } if ($type == 'institutions') { $sort = isset($extradata->sort) ? $extradata->sort : 'displayname'; $sortdesc = isset($extradata->sortdesc) ? $extradata->sortdesc : false; } switch ($type) { case 'institutions': $data = institution_comparison_stats_table($limit, $offset, $sort, $sortdesc); break;
* * @package mahara * @subpackage core * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('INSTITUTIONALADMIN', 1); define('JSON', 1); require dirname(dirname(dirname(__FILE__))) . '/init.php'; require_once 'pieforms/pieform.php'; $limit = param_integer('limit', 10); $offset = param_integer('offset', 0); $type = param_alpha('type', 'suspended'); // Filter for institutional admins: $instsql = $USER->get('admin') ? '' : ' AND ui.institution IN (' . join(',', array_map('db_quote', array_keys($USER->get('institutions')))) . ')'; $count = get_field_sql(' SELECT COUNT(*) FROM ( SELECT u.id FROM {usr} u LEFT OUTER JOIN {usr_institution} ui ON (ui.usr = u.id) WHERE ' . ($type == 'expired' ? 'u.expiry < current_timestamp' : 'suspendedcusr IS NOT NULL') . ' AND deleted = 0 ' . $instsql . ' GROUP BY u.id ) AS a'); $data = get_records_sql_assoc(' SELECT
<?php /** * * @package mahara * @subpackage core * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('JSON', 1); define('PUBLIC', 1); define('NOSESSKEY', 1); require dirname(dirname(__FILE__)) . '/init.php'; json_headers(); $plugintype = param_alpha('plugintype'); $pluginname = param_alpha('pluginname'); $page = param_alphanumext('page', null); $section = param_alphanumext('section', null); $form = param_alphanumext('form', null); $element = param_alphanumext('element', null); $data = get_helpfile($plugintype, $pluginname, $form, $element, $page, $section); if (empty($data)) { json_reply('local', get_string('nohelpfound')); } $json = array('error' => false, 'content' => $data); json_reply(false, $json);
* @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('ADMIN', 1); define('MENUITEM', 'configextensions/webservices/logs'); define('SECTION_PAGE', 'webservicelogs'); require dirname(dirname(dirname(__FILE__))) . '/init.php'; require_once 'webservicessearchlib.php'; define('TITLE', get_string('webservices_title', 'auth.webservice')); require_once 'pieforms/pieform.php'; $userquery = param_variable('userquery', null); $username = !empty($userquery) ? get_field('usr', 'username', 'id', $userquery) : ''; $functionquery = param_variable('functionquery', null); $functionname = !empty($functionquery) ? get_field('external_functions', 'name', 'id', $functionquery) : ''; $search = (object) array('userquery' => $username, 'functionquery' => $functionname, 'protocol' => trim(param_alphanumext('protocol', 'all')), 'authtype' => trim(param_alphanum('authtype', 'all')), 'onlyerrors' => 'on' == param_alphanum('onlyerrors', 'off') ? 1 : 0, 'sortby' => param_alpha('sortby', 'timelogged'), 'sortdir' => param_alpha('sortdir', 'desc'), 'offset' => param_integer('offset', 0), 'limit' => param_integer('limit', 10)); if ($USER->get('admin')) { $institutions = get_records_array('institution', '', '', 'displayname'); $search->institution = param_alphanum('institution', 'all'); } else { $institutions = get_records_select_array('institution', "name IN ('" . join("','", array_keys($USER->get('admininstitutions'))) . "')", null, 'displayname'); $search->institution_requested = param_alphanum('institution_requested', 'all'); } list($html, $columns, $searchurl, $pagination) = build_webservice_log_search_results($search); $institutionselect = ''; if (count($institutions) > 1) { $selecttype = $USER->get('admin') ? 'institution' : 'institution_requested'; $options = array('all' => get_string('All')); foreach ($institutions as $institution) { $options[$institution->name] = $institution->displayname; }
/** * Process view changes. This function is used both by the json stuff and * by normal posts */ public function process_changes($category = '', $new = 0) { global $SESSION, $USER; // Security // TODO this might need to be moved below the requestdata check below, to prevent non owners of the view being // rejected if (!$USER->can_edit_view($this)) { throw new AccessDeniedException(get_string('canteditdontown', 'view')); } if (!count($_POST) && count($_GET) < 3) { return; } $action = ''; foreach ($_POST as $key => $value) { if (substr($key, 0, 7) == 'action_') { $action = substr($key, 7); break; } else { if (substr($key, 0, 37) == 'cancel_action_configureblockinstance_' && param_integer('removeoncancel', 0)) { $action = 'removeblockinstance_' . substr($key, 37); break; } } } // TODO Scan GET for an action. The only action that is GETted is // confirming deletion of a blockinstance. It _should_ be a POST, but // that can be fixed later. if (!$action) { foreach ($_GET as $key => $value) { if (substr($key, 0, 7) == 'action_') { $action = substr($key, 7); } } } $viewtheme = param_variable('viewtheme', ''); if ($viewtheme && $viewtheme != $this->get('theme')) { $action = 'changetheme'; $values = array('theme' => $viewtheme); } if (empty($action)) { return; } form_validate(param_alphanum('sesskey', null)); if (!isset($values)) { $actionstring = $action; $action = substr($action, 0, strpos($action, '_')); $actionstring = substr($actionstring, strlen($action) + 1); // Actions from <input type="image"> buttons send an _x and _y if (substr($actionstring, -2) == '_x' || substr($actionstring, -2) == '_y') { $actionstring = substr($actionstring, 0, -2); } $values = self::get_values_for_action($actionstring); } $result = null; switch ($action) { // the view class method is the same as the action, // but I've left these here in case any additional // parameter handling has to be done. case 'addblocktype': // requires action_addblocktype (blocktype in separate parameter) $values['blocktype'] = param_alpha('blocktype', null); break; case 'removeblockinstance': // requires action_removeblockinstance_id_\d if (!defined('JSON')) { if (!($sure = param_boolean('sure'))) { $yesform = '<form action="' . get_config('wwwroot') . '/view/blocks.php" class="text-inline">' . '<input type="hidden" name="id" value="' . $this->get('id') . '">' . '<input type="hidden" name="c" value="file">' . '<input type="hidden" name="action_' . $action . '_' . $actionstring . '" value="1">' . '<input type="hidden" name="sure" value="1">' . '<input type="hidden" name="sesskey" value="' . $USER->get('sesskey') . '">' . '<input class="submit btn btn-primary" type="submit" name="removeblock_submit" value="' . get_string('yes') . '">' . '</form>'; $baselink = get_config('wwwroot') . 'view/blocks.php?id=' . $this->get('id') . '&c=' . $category . '&new=' . $new; $SESSION->add_info_msg(get_string('confirmdeleteblockinstance', 'view') . ' ' . $yesform . ' <a href="' . $baselink . '">' . get_string('no') . '</a>', false); redirect($baselink); exit; } } break; case 'configureblockinstance': // requires action_configureblockinstance_id_\d_column_\d_order_\d // requires action_configureblockinstance_id_\d_column_\d_order_\d case 'acsearch': // requires action_acsearch_id_\d if (!defined('JSON')) { $this->blockinstance_currently_being_configured = $values['id']; // And we're done here for now return; } case 'moveblockinstance': // requires action_moveblockinstance_id_\d_row_\d_column_\d_order_\d // requires action_moveblockinstance_id_\d_row_\d_column_\d_order_\d case 'addcolumn': // requires action_addcolumn_\d_row_\d_before_\d // requires action_addcolumn_\d_row_\d_before_\d case 'removecolumn': // requires action_removecolumn_\d_row_\d_column_\d // requires action_removecolumn_\d_row_\d_column_\d case 'changetheme': case 'updatecustomlayoutpreview': case 'addcustomlayout': break; default: throw new InvalidArgumentException(get_string('noviewcontrolaction', 'error', $action)); } $message = ''; $success = false; try { $values['returndata'] = defined('JSON'); $returndata = $this->{$action}($values); // Tell the watchlist that the view changed $data = (object) array('view' => $this->get('id')); if (!defined('JSON')) { $message = $this->get_viewcontrol_ok_string($action); } $success = true; } catch (Exception $e) { // if we're in ajax land, just throw it // the handler will deal with the message. if (defined('JSON')) { throw $e; } $message = $this->get_viewcontrol_err_string($action) . ': ' . $e->getMessage(); } if (!defined('JSON')) { // set stuff in the session and redirect $fun = 'add_ok_msg'; if (!$success) { $fun = 'add_error_msg'; } $SESSION->{$fun}($message); redirect('/view/blocks.php?id=' . $this->get('id') . '&c=' . $category . '&new=' . $new); } return array('message' => $message, 'data' => $returndata); }
* @subpackage artefact-internal * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('MENUITEM', 'content/profile'); define('SECTION_PLUGINTYPE', 'artefact'); define('SECTION_PLUGINNAME', 'internal'); define('SECTION_PAGE', 'index'); require dirname(dirname(dirname(__FILE__))) . '/init.php'; define('TITLE', get_string('profile', 'artefact.internal')); require_once 'pieforms/pieform.php'; safe_require('artefact', 'internal'); $fieldset = param_alpha('fs', 'aboutme'); $element_list = ArtefactTypeProfile::get_all_fields(); $element_data = ArtefactTypeProfile::get_field_element_data(); $element_required = ArtefactTypeProfile::get_mandatory_fields(); // load existing profile fields $profilefields = array(); $profile_data = get_records_select_array('artefact', "owner=? AND artefacttype IN (" . join(",", array_map(create_function('$a', 'return db_quote($a);'), array_keys($element_list))) . ")", array($USER->get('id'))); if ($profile_data) { foreach ($profile_data as $field) { $profilefields[$field->artefacttype] = $field->title; } } $lockedfields = locked_profile_fields(); $profilefields['email'] = array(); $profilefields['email']['all'] = get_records_array('artefact_internal_profile_email', 'owner', $USER->get('id')); $profilefields['email']['validated'] = array();
* @subpackage core * @author Stacey Walker * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('INSTITUTIONALADMIN', 1); require dirname(dirname(dirname(__FILE__))) . '/init.php'; define('SECTION_PLUGINTYPE', 'core'); define('SECTION_PLUGINNAME', 'admin'); define('SECTION_PAGE', 'actionregistration'); require_once 'pieforms/pieform.php'; require_once 'institution.php'; $id = param_integer('r'); $action = param_alpha('action'); if (!is_logged_in()) { throw new AccessDeniedException(); } if (!($registration = get_record_select('usr_registration', '"id" = ? AND pending = 1', array($id)))) { die_info(get_string('registrationnosuchid', 'auth.internal')); } if (!($inst = get_record('institution', 'name', $registration->institution))) { die_info(get_string('nosuchinstitution', 'admin')); } if ($action == 'approve') { $message = get_string('approveregistrationmessage', 'admin', $inst->displayname); $submitbtn = get_string('approve', 'admin'); define('TITLE', get_string('approveregistrationfor2', 'admin', $registration->firstname, $registration->lastname, $registration->email)); if ($registration->institution != 'mahara') { $elements['institutionstaff'] = array('type' => 'switchbox', 'title' => get_string('institutionstaff', 'admin'), 'description' => get_string('makeuserinstitutionstaff', 'admin'), 'defaultvalue' => 0);
* * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package mahara * @subpackage artefact-browse * @author Mike Kelly UAL m.f.kelly@arts.ac.uk / Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * */ define('INTERNAL', 1); define('JSON', 1); define('PUBLIC', 1); require dirname(dirname(dirname(__FILE__))) . '/init.php'; safe_require('artefact', 'browseprofiles'); $field = param_alpha('field', ''); $term = param_variable('term', ''); if (isset($field) && isset($term)) { $querytype = $field; $queryterm = $term; } $result = array(); $localenrolments = get_records_sql_array("SELECT DISTINCT course FROM usr_enrolment WHERE course != 'none'", array()); $localcourseids = array(); if ($localenrolments) { foreach ($localenrolments as $row) { $allcourses = explode(',', $row->course); foreach ($allcourses as $course) { if (!in_array($course, $localcourseids) && strlen($course)) { $localcourseids[] = $course; }
* @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('MENUITEM', 'groups/findfriends'); require dirname(dirname(__FILE__)) . '/init.php'; require_once 'pieforms/pieform.php'; $id = param_integer('id'); if (get_account_preference($id, 'friendscontrol') != 'auth' || $id == $USER->get('id') || !($user = get_record('usr', 'id', $id, 'deleted', 0))) { throw new AccessDeniedException(get_string('cantrequestfriendship', 'group')); } $user->introduction = get_field('artefact', 'title', 'artefacttype', 'introduction', 'owner', $id); define('TITLE', get_string('sendfriendshiprequest', 'group', display_name($id))); $returnto = param_alpha('returnto', 'myfriends'); $offset = param_integer('offset', 0); switch ($returnto) { case 'find': $goto = 'user/find.php'; break; case 'view': $goto = profile_url($user, false); break; default: $goto = 'user/myfriends.php'; } $goto .= strpos($goto, '?') ? '&offset=' . $offset : '?offset=' . $offset; $goto = get_config('wwwroot') . $goto; if (is_friend($id, $USER->get('id'))) { $SESSION->add_ok_msg(get_string('alreadyfriends', 'group', display_name($id)));
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz * */ define('INTERNAL', 1); define('INSTITUTIONALADMIN', 1); define('MENUITEM', 'manageinstitutions/institutionviews'); define('SECTION_PLUGINTYPE', 'core'); define('SECTION_PLUGINNAME', 'admin'); require dirname(dirname(__FILE__)) . '/init.php'; require_once get_config('libroot') . 'view.php'; require_once get_config('libroot') . 'institution.php'; require_once 'pieforms/pieform.php'; $limit = param_integer('limit', 5); $offset = param_integer('offset', 0); $institution = param_alpha('institution', false); if ($institution == 'mahara') { redirect('/admin/site/views.php'); } $s = institution_selector_for_page($institution, get_config('wwwroot') . 'view/institutionviews.php'); $institution = $s['institution']; $smarty = smarty(); if ($institution === false) { $smarty->display('admin/users/noinstitutions.tpl'); exit; } $title = get_string('institutionviews', 'view'); define('TITLE', $title); $smarty->assign('heading', $title); $data = View::get_myviews_data($limit, $offset, null, $institution); $pagination = build_pagination(array('url' => get_config('wwwroot') . 'view/institutionviews.php?institution=' . $institution, 'count' => $data->count, 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')));
* You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package mahara * @subpackage artefact-resume * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz * */ define('INTERNAL', 1); define('JSON', 1); require dirname(dirname(dirname(__FILE__))) . '/init.php'; safe_require('artefact', 'resume'); $limit = param_integer('limit', null); $offset = param_integer('offset', 0); $type = param_alpha('type'); $data = array(); $count = 0; $othertable = 'artefact_resume_' . $type; $owner = $USER->get('id'); $sql = 'SELECT ar.*, a.owner FROM {artefact} a JOIN {' . $othertable . '} ar ON ar.artefact = a.id WHERE a.owner = ? AND a.artefacttype = ? ORDER BY ar.displayorder'; if (!($data = get_records_sql_array($sql, array($owner, $type)))) { $data = array(); } $count = count_records('artefact', 'owner', $owner, 'artefacttype', $type); echo json_encode(array('data' => $data, 'limit' => $limit, 'offset' => $offset, 'count' => $count, 'type' => $type));
group_get_removeuser_form($member, $group->id); } // Search related stuff for member pager $query = trim(param_variable('query', '')); // pagination params $setlimit = true; //Enable choosing page size; list of page sizes has been predefined in function build_pagination() $offset = param_integer('offset', 0); $limit = param_integer('limit', 10); // Sort options index and list of sort options // ORDER BY statements defined in group_user_search function need to be matched $sortoptions = array('adminfirst' => get_string('adminfirst'), 'nameatoz' => get_string('nameatoz'), 'nameztoa' => get_string('nameztoa'), 'firstjoined' => get_string('firstjoined'), 'lastjoined' => get_string('lastjoined')); $sortoptionidx = param_alpha('sortoption', 'adminfirst'); if ($membershiptype == 'request') { array_shift($sortoptions); $sortoptionidx = param_alpha('sortoption', 'nameatoz'); } $results = get_group_user_search_results($group->id, $query, $offset, $limit, $membershiptype, null, null, $sortoptionidx); list($html, $pagination, $count, $offset, $membershiptype) = group_get_membersearch_data($results, $group->id, $query, $membershiptype, $setlimit, $sortoptionidx); // Type-specific instructions $instructions = ''; if ('admin' == $role) { $url = get_config('wwwroot') . 'group/inviteusers.php?id=' . GROUP; $instructions = get_string('invitemembersdescription', 'group', $url); if ('controlled' == $group->jointype) { $url = get_config('wwwroot') . 'group/addmembers.php?id=' . GROUP; $instructions .= ' ' . get_string('membersdescription:controlled', 'group', $url); } } $searchform = pieform(array('name' => 'search', 'checkdirtychange' => false, 'class' => 'search-views-form form-inline with-heading', 'elements' => array('id' => array('type' => 'hidden', 'value' => $group->id), 'membershiptype' => array('type' => 'hidden', 'value' => $membershiptype), 'setlimit' => array('type' => 'hidden', 'value' => $setlimit), 'inputgroup' => array('type' => 'fieldset', 'class' => 'input-group', 'elements' => array('query' => array('title' => get_string('search') . ': ', 'type' => 'text', 'class' => 'input-small', 'defaultvalue' => $query), 'sortoption' => array('type' => 'select', 'class' => 'sortoption input-small', 'title' => get_string('sortedby'), 'multiple' => false, 'size' => 1, 'defaultvalue' => $sortoptionidx, 'options' => $sortoptions), 'submit' => array('type' => 'button', 'usebuttontag' => true, 'class' => 'btn-primary no-label input-group-btn', 'value' => get_string('search'))))))); $js = <<<EOF
* @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz * */ // TODO fix title of this page // TODO check security of this page define('INTERNAL', 1); require_once dirname(dirname(__FILE__)) . '/init.php'; require_once 'pieforms/pieform.php'; require_once 'view.php'; require_once get_config('libroot') . 'group.php'; define('TITLE', get_string('changemyviewlayout', 'view')); $id = param_integer('id'); $new = param_boolean('new'); $category = param_alpha('c', ''); $view = new View($id); $numcolumns = $view->get('numcolumns'); $currentlayout = $view->get('layout'); $back = !$USER->get_account_preference('addremovecolumns'); $group = $view->get('group'); $institution = $view->get('institution'); View::set_nav($group, $institution); if (!$USER->can_edit_view($view)) { throw new AccessDeniedException(); } // if not set, use equal width layout for that number of columns if (!$currentlayout) { $currentlayout = $numcolumns == 2 ? 1 : ($numcolumns == 3 ? 4 : 7); } if ($numcolumns > 1 && $numcolumns < 5) {
public function instance_config_store(Pieform $form, $values) { global $SESSION, $USER; // Destroy form values we don't care about unset($values['sesskey']); unset($values['blockinstance']); unset($values['action_configureblockinstance_id_' . $this->get('id')]); unset($values['blockconfig']); unset($values['id']); unset($values['change']); unset($values['new']); if (isset($values['retractable'])) { switch ($values['retractable']) { case BlockInstance::RETRACTABLE_YES: $values['retractable'] = 1; $values['retractedonload'] = 0; break; case BlockInstance::RETRACTABLE_RETRACTED: $values['retractable'] = 1; $values['retractedonload'] = 1; break; case BlockInstance::RETRACTABLE_NO: default: $values['retractable'] = 0; $values['retractedonload'] = 0; break; } } // make sure that user is allowed to publish artefact. This is to stop // hacking of form value to attach other users private data. $badattachment = false; if (!empty($values['artefactid'])) { $badattachment = !$this->verify_attachment_permissions($values['artefactid']); } if (!empty($values['artefactids'])) { $badattachment = !$this->verify_attachment_permissions($values['artefactids']); } if ($badattachment) { $result['message'] = get_string('unrecoverableerror', 'error'); $form->set_error(null, $result['message']); $form->reply(PIEFORM_ERR, $result); exit; } $redirect = '/view/blocks.php?id=' . $this->get('view'); if (param_boolean('new', false)) { $redirect .= '&new=1'; } if ($category = param_alpha('c', '')) { $redirect .= '&c=' . $category; } $result = array('goto' => $redirect); if (is_callable(array(generate_class_name('blocktype', $this->get('blocktype')), 'instance_config_save'))) { try { $values = call_static_method(generate_class_name('blocktype', $this->get('blocktype')), 'instance_config_save', $values, $this); } catch (MaharaException $e) { $result['message'] = $e instanceof UserException ? $e->getMessage() : get_string('unrecoverableerror', 'error'); $form->set_error(null, $result['message']); $form->reply(PIEFORM_ERR, $result); } } $title = isset($values['title']) ? $values['title'] : ''; unset($values['title']); // A block may return a list of other blocks that need to be // redrawn after configuration of this block. $torender = !empty($values['_redrawblocks']) && $form->submitted_by_js() ? $values['_redrawblocks'] : array(); unset($values['_redrawblocks']); $this->set('configdata', $values); $this->set('title', $title); $this->commit(); try { $rendered = $this->render_editing(false, false, $form->submitted_by_js()); } catch (HTMLPurifier_Exception $e) { $message = get_string('blockconfigurationrenderingerror', 'view') . ' ' . $e->getMessage(); $form->reply(PIEFORM_ERR, array('message' => $message)); } $result = array('error' => false, 'message' => get_string('blockinstanceconfiguredsuccessfully', 'view'), 'data' => $rendered, 'blockid' => $this->get('id'), 'viewid' => $this->get('view'), 'goto' => $redirect); // Render all the other blocks in the torender list $result['otherblocks'] = array(); foreach ($torender as $blockid) { if ($blockid != $result['blockid']) { $otherblock = new BlockInstance($blockid); $result['otherblocks'][] = array('blockid' => $blockid, 'data' => $otherblock->render_editing(false, false, true)); } } $form->reply(PIEFORM_OK, $result); }