本文整理汇总了PHP中generate_artefact_class_name函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_artefact_class_name函数的具体用法?PHP generate_artefact_class_name怎么用?PHP generate_artefact_class_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_artefact_class_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
require_once get_config('docroot') . 'artefact/lib.php';
$configdata = $instance->get('configdata');
$viewid = $instance->get('view');
$wwwroot = get_config('wwwroot');
$files = array();
if (isset($configdata['artefactids']) && is_array($configdata['artefactids'])) {
foreach ($configdata['artefactids'] as $artefactid) {
try {
$artefact = $instance->get_artefact_instance($artefactid);
} catch (ArtefactNotFoundException $e) {
continue;
}
$file = array('id' => $artefactid, 'title' => $artefact->get('title'), 'description' => $artefact->get('description'), 'size' => $artefact->get('size'), 'ctime' => $artefact->get('ctime'), 'artefacttype' => $artefact->get('artefacttype'), 'iconsrc' => call_static_method(generate_artefact_class_name($artefact->get('artefacttype')), 'get_icon', array('id' => $artefactid, 'viewid' => $viewid)), 'downloadurl' => $wwwroot);
if ($artefact instanceof ArtefactTypeProfileIcon) {
$file['downloadurl'] .= 'thumb.php?type=profileiconbyid&id=' . $artefactid;
} else {
if ($artefact instanceof ArtefactTypeFile) {
$file['downloadurl'] .= 'artefact/file/download.php?file=' . $artefactid . '&view=' . $viewid;
}
}
$file['is_image'] = $artefact instanceof ArtefactTypeImage ? true : false;
$files[] = $file;
}
}
$smarty = smarty_core();
$smarty->assign('viewid', $instance->get('view'));
$smarty->assign('files', $files);
return $smarty->fetch('blocktype:filedownload:filedownload.tpl');
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:31,代码来源:lib.php
示例2: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$userid = $instance->get_view()->get('owner');
if (!$userid) {
return '';
}
$smarty = smarty_core();
// Get viewable views
$views = array();
if ($allviews = get_records_select_array('view', "\"owner\" = ? AND type NOT IN ('profile', 'dashboard')", array($userid))) {
foreach ($allviews as $view) {
if (can_view_view($view->id)) {
$views[$view->id] = $view;
$view->artefacts = array();
}
}
}
if ($views) {
$viewidlist = implode(', ', array_map(create_function('$a', 'return (int)$a->id;'), $views));
$artefacts = get_records_sql_array('SELECT va.view, va.artefact, a.title, a.artefacttype, t.plugin
FROM {view_artefact} va
INNER JOIN {artefact} a ON va.artefact = a.id
INNER JOIN {artefact_installed_type} t ON a.artefacttype = t.name
WHERE va.view IN (' . $viewidlist . ')
GROUP BY 1, 2, 3, 4, 5
ORDER BY a.title, va.artefact', '');
if ($artefacts) {
foreach ($artefacts as $artefactrec) {
safe_require('artefact', $artefactrec->plugin);
// Perhaps I shouldn't have to construct the entire
// artefact object to render the name properly.
$classname = generate_artefact_class_name($artefactrec->artefacttype);
$artefactobj = new $classname(0, array('title' => $artefactrec->title));
$artefactobj->set('dirty', false);
if (!$artefactobj->in_view_list()) {
continue;
}
$artname = $artefactobj->display_title(30);
if (strlen($artname)) {
$views[$artefactrec->view]->artefacts[] = array('id' => $artefactrec->artefact, 'title' => $artname);
}
}
}
$tags = get_records_select_array('view_tag', 'view IN (' . $viewidlist . ')');
if ($tags) {
foreach ($tags as &$tag) {
$views[$tag->view]->tags[] = $tag->tag;
}
}
}
$smarty->assign('VIEWS', $views);
return $smarty->fetch('blocktype:myviews:myviews.tpl');
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:53,代码来源:lib.php
示例3: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
require_once get_config('docroot') . 'artefact/lib.php';
$configdata = $instance->get('configdata');
$result = '';
if (isset($configdata['artefactids']) && is_array($configdata['artefactids'])) {
foreach ($configdata['artefactids'] as $artefactid) {
try {
$artefact = $instance->get_artefact_instance($artefactid);
} catch (ArtefactNotFoundException $e) {
continue;
}
$icondata = array('id' => $artefactid, 'viewid' => $instance->get('view'));
$detailsurl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $artefactid . '&view=' . $instance->get('view');
if ($artefact instanceof ArtefactTypeProfileIcon) {
require_once 'file.php';
$downloadurl = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $artefactid;
$size = filesize(get_dataroot_image_path('artefact/file/profileicons/', $artefactid));
} else {
if ($artefact instanceof ArtefactTypeFile) {
$downloadurl = get_config('wwwroot') . 'artefact/file/download.php?file=' . $artefactid . '&view=' . $icondata['viewid'];
$size = $artefact->get('size');
}
}
$result .= '<div title="' . hsc($artefact->get('title')) . '">';
$result .= '<div class="fl"><a href="' . hsc($downloadurl) . '">';
$result .= '<img src="' . hsc(call_static_method(generate_artefact_class_name($artefact->get('artefacttype')), 'get_icon', $icondata)) . '" alt=""></a></div>';
$result .= '<div style="margin-left: 30px;">';
$result .= '<h4><a href="' . hsc($detailsurl) . '">' . str_shorten_text($artefact->get('title'), 20) . '</a></h4>';
$description = $artefact->get('description');
if ($description) {
$result .= '<p style="margin: 0;"><strong>' . hsc($description) . '</strong></p>';
}
$result .= '' . display_size($size) . ' | ' . strftime(get_string('strftimedaydate'), $artefact->get('ctime'));
$result .= '</div>';
$result .= '</div>';
}
}
return $result;
}
开发者ID:Br3nda,项目名称:mahara,代码行数:40,代码来源:lib.php
示例4: set_profile_field
function set_profile_field($userid, $field, $value)
{
safe_require('artefact', 'internal');
// this is a special case that replaces the primary email address with the
// specified one
if ($field == 'email') {
try {
$email = artefact_instance_from_type('email', $userid);
} catch (ArtefactNotFoundException $e) {
$email = new ArtefactTypeEmail();
$email->set('owner', $userid);
}
$email->set('title', $value);
$email->commit();
} else {
$classname = generate_artefact_class_name($field);
$profile = new $classname(0, array('owner' => $userid));
$profile->set('title', $value);
$profile->commit();
}
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:21,代码来源:user.php
示例5: copy_for_new_owner
public function copy_for_new_owner($user, $group, $institution)
{
$data = $this->copy_data();
$data->owner = $user;
$data->group = $group;
$data->institution = $institution;
$data->parent = null;
$classname = generate_artefact_class_name($data->artefacttype);
safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $data->artefacttype));
$copy = new $classname(0, (object) $data);
$this->copy_extra($copy);
$copy->commit();
return $copy->get('id');
}
开发者ID:kienv,项目名称:mahara,代码行数:14,代码来源:lib.php
示例6: artefactchooser_get_element_data
/**
* Optional method. If specified, allows the blocktype class to munge the
* artefactchooser element data before it's templated
*/
public static function artefactchooser_get_element_data($artefact)
{
$folderdata = ArtefactTypeFileBase::artefactchooser_folder_data($artefact);
$artefact->icon = call_static_method(generate_artefact_class_name($artefact->artefacttype), 'get_icon', array('id' => $artefact->id));
$artefact->hovertitle = $artefact->description;
$path = $artefact->parent ? ArtefactTypeFileBase::get_full_path($artefact->parent, $folderdata->data) : '';
$artefact->description = str_shorten_text($folderdata->ownername . $path . $artefact->title, 30);
return $artefact;
}
开发者ID:agwells,项目名称:Mahara-1,代码行数:13,代码来源:lib.php
示例7: get_goals_and_skills
public function get_goals_and_skills($type = '')
{
global $USER;
switch ($type) {
case 'goals':
$artefacts = array('personalgoal', 'academicgoal', 'careergoal');
break;
case 'skills':
$artefacts = array('personalskill', 'academicskill', 'workskill');
break;
default:
$artefacts = array('personalgoal', 'academicgoal', 'careergoal', 'personalskill', 'academicskill', 'workskill');
}
$data = array();
foreach ($artefacts as $artefact) {
$record = get_record('artefact', 'artefacttype', $artefact, 'owner', $USER->get('id'));
if ($record) {
$record->exists = 1;
// Add attachments
$files = ArtefactType::attachments_from_id_list(array($record->id));
if ($files) {
safe_require('artefact', 'file');
foreach ($files as &$file) {
$file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', array('id' => $file->attachment));
$record->files[] = $file;
}
$record->count = count($files);
} else {
$record->count = 0;
}
} else {
$record = new stdClass();
$record->artefacttype = $artefact;
$record->exists = 0;
$record->count = 0;
}
$data[] = $record;
}
return $data;
}
开发者ID:vohung96,项目名称:mahara,代码行数:40,代码来源:lib.php
示例8: artefactchooser_get_element_data
public static function artefactchooser_get_element_data($artefact)
{
$artefact->icon = call_static_method(generate_artefact_class_name($artefact->artefacttype), 'get_icon', array('id' => $artefact->id));
return $artefact;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:5,代码来源:lib.php
示例9: get_forms
static function get_forms(array $compositetypes)
{
require_once get_config('libroot') . 'pieforms/pieform.php';
$compositeforms = array();
foreach ($compositetypes as $compositetype) {
$elements = call_static_method(generate_artefact_class_name($compositetype), 'get_addform_elements');
$elements['submit'] = array('type' => 'submit', 'value' => get_string('save'));
$elements['compositetype'] = array('type' => 'hidden', 'value' => $compositetype);
$cform = array('name' => 'add' . $compositetype, 'plugintype' => 'artefact', 'pluginname' => 'resume', 'elements' => $elements, 'jsform' => true, 'successcallback' => 'compositeform_submit', 'jssuccesscallback' => 'compositeSaveCallback');
$compositeforms[$compositetype] = pieform($cform);
}
return $compositeforms;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:13,代码来源:lib.php
示例10: get_posts
/**
* This function returns a list of posts in a given blog.
*
* @param integer
* @param integer
* @param integer
* @param array
*/
public static function get_posts($id, $limit, $offset, $viewoptions = null)
{
$results = array('limit' => $limit, 'offset' => $offset);
// If viewoptions is null, we're getting posts for the my blogs area,
// and we should get all posts & show drafts first. Otherwise it's a
// blog in a view, and we should only get published posts.
$from = "\n FROM {artefact} a LEFT JOIN {artefact_blog_blogpost} bp ON a.id = bp.blogpost\n WHERE a.artefacttype = 'blogpost' AND a.parent = ?";
if (!is_null($viewoptions)) {
if (isset($viewoptions['before'])) {
$from .= " AND a.ctime < '{$viewoptions['before']}'";
}
$from .= ' AND bp.published = 1';
}
$results['count'] = count_records_sql('SELECT COUNT(*) ' . $from, array($id));
$data = get_records_sql_assoc('
SELECT
a.id, a.title, a.description, a.author, a.authorname, ' . db_format_tsfield('a.ctime', 'ctime') . ', ' . db_format_tsfield('a.mtime', 'mtime') . ',
a.locked, bp.published, a.allowcomments ' . $from . '
ORDER BY bp.published ASC, a.ctime DESC, a.id DESC', array($id), $offset, $limit);
if (!$data) {
$results['data'] = array();
return $results;
}
// Get the attached files.
$postids = array_map(create_function('$a', 'return $a->id;'), $data);
$files = ArtefactType::attachments_from_id_list($postids);
if ($files) {
safe_require('artefact', 'file');
foreach ($files as &$file) {
$params = array('id' => $file->attachment);
if (!empty($viewoptions['viewid'])) {
$params['viewid'] = $viewoptions['viewid'];
}
$file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', $params);
$data[$file->artefact]->files[] = $file;
}
}
if ($tags = ArtefactType::tags_from_id_list($postids)) {
foreach ($tags as &$at) {
$data[$at->artefact]->tags[] = $at->tag;
}
}
foreach ($data as &$post) {
// Format dates properly
if (is_null($viewoptions)) {
// My Blogs area: create forms for changing post status & deleting posts.
$post->changepoststatus = ArtefactTypeBlogpost::changepoststatus_form($post->id, $post->published);
$post->delete = ArtefactTypeBlogpost::delete_form($post->id, $post->title);
} else {
$by = $post->author ? display_default_name($post->author) : $post->authorname;
$post->postedby = get_string('postedbyon', 'artefact.blog', $by, format_date($post->ctime));
// Get comment counts
if (!empty($viewoptions['countcomments'])) {
safe_require('artefact', 'comment');
require_once get_config('docroot') . 'lib/view.php';
$view = new View($viewoptions['viewid']);
$artefact = artefact_instance_from_id($post->id);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, null, false);
$post->commentcount = $commentcount;
$post->comments = $comments;
}
}
$post->ctime = format_date($post->ctime, 'strftimedaydatetime');
$post->mtime = format_date($post->mtime);
// Ensure images in the post have the right viewid associated with them
if (!empty($viewoptions['viewid'])) {
safe_require('artefact', 'file');
$post->description = ArtefactTypeFolder::append_view_url($post->description, $viewoptions['viewid']);
}
}
$results['data'] = array_values($data);
return $results;
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:81,代码来源:lib.php
示例11: artefact_instance_from_id
$a = artefact_instance_from_id($artefact);
$type = $a->get('artefacttype');
// Set correct redirect when user clicks Cancel button...
if ($type == 'languagediploma' || $type == 'languageexperience') {
// Find language diploma's or linguistic experience's parent for redirect...
$sql = 'SELECT aeo.id, aeo.artefact
FROM {artefact_europass_otherlanguage} aeo
JOIN {artefact_europass_' . $type . '} ar ON ar.languageid = aeo.id
WHERE ar.id = ? AND ar.artefact = ?';
$parent = get_record_sql($sql, array($id, $artefact));
$goto = 'viewcomposite.php?id=' . $parent->id . '&artefact=' . $parent->artefact;
} else {
$goto = 'languages.php';
}
$tabs = PluginArtefactEuropass::composite_tabs();
define('EUROPASS_SUBPAGE', $tabs[$type]);
if ($a->get('owner') != $USER->get('id')) {
throw new AccessDeniedException(get_string('notartefactowner', 'error'));
}
$elements = call_static_method(generate_artefact_class_name($type), 'get_addform_elements');
$elements['submit'] = array('type' => 'submitcancel', 'value' => array(get_string('save'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'artefact/europass/' . $goto);
$elements['compositetype'] = array('type' => 'hidden', 'value' => $type);
$cform = array('name' => 'add' . $type, 'plugintype' => 'artefact', 'pluginname' => 'europass', 'elements' => $elements, 'successcallback' => 'langcompositeformedit_submit');
$a->populate_form($cform, $id, $type);
$compositeform = pieform($cform);
$smarty = smarty();
$smarty->assign('compositeform', $compositeform);
$smarty->assign('composite', $type);
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('SUBPAGENAV', PluginArtefactEuropass::submenu_items());
$smarty->display('artefact:europass:editcomposite.tpl');
开发者ID:povsod,项目名称:mahara-artefact-europass,代码行数:31,代码来源:editcomposite.php
示例12: foreach
}
}
foreach ($data as $id => $n) {
$n->deleteform = pieform(deletenote_form($id, $n));
}
}
// Get the attached files.
$noteids = array();
if ($data) {
$noteids = array_keys($data);
}
$files = ArtefactType::attachments_from_id_list($noteids);
if ($files) {
safe_require('artefact', 'file');
foreach ($files as $file) {
$file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', array('id' => $file->attachment));
$data[$file->artefact]->files[] = $file;
}
}
// Add Attachments count for each Note
if ($data) {
foreach ($data as $item) {
$item->count = isset($item->files) ? count($item->files) : 0;
}
}
$pagination = build_pagination(array('id' => 'notes_pagination', 'url' => $baseurl, 'datatable' => 'notes', 'count' => $count, 'limit' => $limit, 'offset' => $offset));
$js = '
jQuery(function($) {
$("a.notetitle").click(function(e) {
e.preventDefault();
$("#" + this.id + "_desc").toggleClass("hidden");
开发者ID:sarahjcotton,项目名称:mahara,代码行数:31,代码来源:notes.php
示例13: self_search_make_links
protected static function self_search_make_links($data)
{
$wwwroot = get_config('wwwroot');
if ($data['count']) {
foreach ($data['data'] as &$result) {
switch ($result['type']) {
case 'artefact':
safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $result['artefacttype']));
$result['links'] = call_static_method(generate_artefact_class_name($result['artefacttype']), 'get_links', $result['id']);
break;
case 'view':
$result['links'] = array('_default' => $wwwroot . 'view/view.php?id=' . $result['id'], get_string('editviewinformation') => $wwwroot . 'view/editmetadata.php?viewid=' . $result['id'], get_string('editview') => $wwwroot . 'view/edit.php?viewid=' . $result['id'], get_string('editaccess') => $wwwroot . 'view/editaccess.php?viewid=' . $result['id']);
break;
default:
break;
}
}
}
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:19,代码来源:lib.php
示例14: get_forms
static function get_forms(array $compositetypes, $languageid = 0)
{
require_once get_config('libroot') . 'pieforms/pieform.php';
$compositeforms = array();
foreach ($compositetypes as $compositetype) {
$elements = call_static_method(generate_artefact_class_name($compositetype), 'get_addform_elements');
$elements['submit'] = array('type' => 'submit', 'value' => get_string('save'));
$elements['compositetype'] = array('type' => 'hidden', 'value' => $compositetype);
// Set language for language diploma(s) or linguistic experience(s)...
if ($languageid > 0) {
$elements['languageid'] = array('type' => 'hidden', 'value' => $languageid);
}
$cform = array('name' => 'add' . $compositetype, 'plugintype' => 'artefact', 'pluginname' => 'europass', 'elements' => $elements, 'jsform' => true, 'successcallback' => 'langcompositeform_submit', 'jssuccesscallback' => 'compositeSaveCallback');
$compositeforms[$compositetype] = pieform($cform);
}
return $compositeforms;
}
开发者ID:povsod,项目名称:mahara-artefact-europass,代码行数:17,代码来源:lib.php
示例15: add_import_entry_request
/**
* Add an import request of an interactive import entry as an Mahara view+collection or artefact.
* For view import
* If the entry is for Profile or Dashboard page, the decision is APPEND(default), IGNORE or REPLACE
* If there is a duplicated view (same title and description), the decision is APPEND(default), IGNORE, REPLACE, or ADDNEW
* If else, the decision is IGNORE, or ADDNEW(default)
* For artefact import
* If there are duplicated artefacts, the decision is IGNORE
* If ELSE If there is $entrytype NOT is_singular, e.g. an user may have up to 5 email addresses
* the decision is ADDNEW(default) or IGNORE
* If there is $entrytype is_singular,
* the decision is REPLACE(default) or APPEND
* Also update the list of
* - duplicated artefacts which have same artefacttype and content
* - existing artefacts which have same artefacttype but the content may be different to the entry data
*
* @param string $importid ID of the import
* @param string $entryid ID of the entry
* @param string $strategy Strategy of entry import
* @param string $plugin
* @param array $entrydata Data the entry including the following fields:
* owner ID of the user who imports the entry (required)
* type (required)
* parent ID of the parent entry (e.g. the blog entryid of the blogpost entry).
* content (required)
* - title (required)
* @return updated DB table 'import_entry_requests'
*/
public static function add_import_entry_request($importid, $entryid, $strategy, $plugin, $entrydata)
{
$duplicatedartefactids = array();
$existingartefactids = array();
$title = $entrydata['content']['title'];
if ($plugin === 'core') {
// For view import
$decision = PluginImport::DECISION_ADDNEW;
} else {
safe_require('artefact', $plugin);
$classname = generate_artefact_class_name($entrydata['type']);
if ($duplicatedartefactids = call_static_method($classname, 'get_duplicated_artefacts', $entrydata)) {
$decision = PluginImport::DECISION_IGNORE;
} else {
if (isset($entrydata['defaultdecision'])) {
$decision = $entrydata['defaultdecision'];
} else {
$existingartefactids = call_static_method($classname, 'get_existing_artefacts', $entrydata);
if (call_static_method($classname, 'is_singular') && !empty($existingartefactids)) {
if ($entrydata['type'] == 'email') {
$decision = PluginImport::DECISION_ADDNEW;
} else {
$decision = PluginImport::DECISION_REPLACE;
}
} else {
$decision = PluginImport::DECISION_ADDNEW;
}
}
}
}
// Update DB table
if (!record_exists_select('import_entry_requests', 'importid = ? AND entryid = ? AND ownerid = ? AND entrytype = ? AND entrytitle = ?', array($importid, $entryid, $entrydata['owner'], $entrydata['type'], $title))) {
return insert_record('import_entry_requests', (object) array('importid' => $importid, 'entryid' => $entryid, 'strategy' => $strategy, 'plugin' => $plugin, 'ownerid' => $entrydata['owner'], 'entrytype' => $entrydata['type'], 'entryparent' => isset($entrydata['parent']) ? $entrydata['parent'] : null, 'entrytitle' => $title, 'entrycontent' => serialize($entrydata['content']), 'duplicateditemids' => serialize($duplicatedartefactids), 'existingitemids' => serialize($existingartefactids), 'decision' => $decision));
}
return false;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:64,代码来源:lib.php
示例16: create_artefact_from_request
/**
* Create a new artefact from import entry requests as a Mahara artefact
*
* @param object $entry_request The entry request
* @param int $parent The ID of parent artefact
* @return int The ID of new artefact
* =0 if no artefact is created
*/
public static function create_artefact_from_request($importer, $entry_request, $parent = null)
{
$aid = 0;
switch ($entry_request->decision) {
case PluginImport::DECISION_IGNORE:
$duplicatedids = unserialize($entry_request->duplicateditemids);
if (!empty($duplicatedids)) {
$aid = $duplicatedids[0];
}
break;
case PluginImport::DECISION_REPLACE:
$existingids = unserialize($entry_request->existingitemids);
if (!empty($existingids)) {
$aid = self::replace_artefact_content_from_request($entry_request, $existingids[0]);
}
break;
case PluginImport::DECISION_APPEND:
$existingids = unserialize($entry_request->existingitemids);
if (!empty($existingids)) {
$aid = self::append_artefact_content_from_request($entry_request, $existingids[0]);
}
break;
case PluginImport::DECISION_ADDNEW:
default:
$classname = generate_artefact_class_name($entry_request->entrytype);
$content = unserialize($entry_request->entrycontent);
$content['owner'] = $entry_request->ownerid;
if (isset($parent)) {
$content['parent'] = $parent;
}
$a = new $classname(0, $content);
$a->commit();
$aid = $a->get('id');
break;
}
if ($aid) {
$importer->add_artefactmapping($entry_request->entryid, $aid);
}
return $aid;
}
开发者ID:agwells,项目名称:Mahara-1,代码行数:48,代码来源:lib.php
示例17: get_form
/**
* Gets the new/edit activities pieform
*
*/
public static function get_form($parent, $activity = null)
{
require_once get_config('libroot') . 'pieforms/pieform.php';
$elements = call_static_method(generate_artefact_class_name('activity'), 'get_activityform_elements', $parent, $activity);
$elements['submit'] = array('type' => 'submitcancel', 'class' => 'btn-primary', 'value' => array(get_string('saveactivity', 'artefact.cpds'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'artefact/cpds/cpd.php?id=' . (int) $parent);
$activityform = array('name' => empty($activity) ? 'addactivities' : 'editactivity', 'plugintype' => 'artefact', 'pluginname' => 'activity', 'validatecallback' => array(generate_artefact_class_name('activity'), 'validate'), 'successcallback' => array(generate_artefact_class_name('activity'), 'submit'), 'elements' => $elements);
return pieform($activityform);
}
开发者ID:ngson2000,项目名称:mahara-artefact_cpds,代码行数:12,代码来源:lib.php
示例18: get_form
/**
* Gets the new/edit tasks pieform
*
*/
public static function get_form($parent, $task = null)
{
require_once get_config('libroot') . 'pieforms/pieform.php';
require_once 'license.php';
$elements = call_static_method(generate_artefact_class_name('task'), 'get_taskform_elements', $parent, $task);
$elements['submit'] = array('type' => 'submitcancel', 'value' => array(get_string('savetask', 'artefact.plans'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'artefact/plans/plan.php?id=' . $parent);
$taskform = array('name' => empty($task) ? 'addtasks' : 'edittask', 'plugintype' => 'artefact', 'pluginname' => 'task', 'validatecallback' => array(generate_artefact_class_name('task'), 'validate'), 'successcallback' => array(generate_artefact_class_name('task'), 'submit'), 'elements' => $elements);
return pieform($taskform);
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:13,代码来源:lib.php
示例19: profileform_submit
function profileform_submit(Pieform $form, $values)
{
global $SESSION;
global $USER;
global $element_list;
global $profilefields;
require_once 'embeddedimage.php';
db_begin();
$now = db_format_timestamp(time());
$email_errors = array();
$lockedfields = locked_profile_fields();
foreach ($element_list as $element => $type) {
if (isset($lockedfields[$element]) && !$USER->get('admin')) {
continue;
}
if ($element == 'email') {
if (!isset($values['email']['unsent'])) {
$values['email']['unsent'] = array();
}
// find new addresses
foreach ($values['email']['unsent'] as $email) {
if (in_array($email, $profilefields['email']['validated']) || in_array($email, $profilefields['email']['unvalidated'])) {
continue;
}
$key = get_random_key();
$key_url = get_config('wwwroot') . 'artefact/internal/validate.php?email=' . rawurlencode($email) . '&key=' . $key;
$key_url_decline = $key_url . '&decline=1';
try {
$sitename = get_config('sitename');
email_user((object) array('id' => $USER->get('id'), 'username' => $USER->get('username'), 'firstname' => $USER->get('firstname'), 'lastname' => $USER->get('lastname'), 'preferredname' => $USER->get('preferredname'), 'admin' => $USER->get('admin'), 'staff' => $USER->get('staff'), 'email' => $email), null, get_string('emailvalidation_subject', 'artefact.internal'), get_string('emailvalidation_body1', 'artefact.internal', $USER->get('firstname'), $email, $sitename, $key_url, $sitename, $key_url_decline));
} catch (EmailException $e) {
$email_errors[] = $email;
}
insert_record('artefact_internal_profile_email', (object) array('owner' => $USER->get('id'), 'email' => $email, 'verified' => 0, 'key' => $key, 'expiry' => db_format_timestamp(time() + 86400)));
}
// remove old addresses
foreach ($profilefields['email']['validated'] as $email) {
if (in_array($email, $values['email']['validated'])) {
continue;
}
if (!empty($values['email']['unvalidated']) && in_array($email, $values['email']['unvalidated'])) {
continue;
}
$artefact_id = get_field('artefact_internal_profile_email', 'artefact', 'email', $email, 'owner', $USER->get('id'));
delete_records('artefact_internal_profile_email', 'email', $email, 'owner', $USER->get('id'));
if ($artefact_id) {
$artefact = new ArtefactTypeEmail($artefact_id);
$artefact->delete();
// this is unset here to force the destructor to run now,
// rather than script exit time where it doesn't like
// throwing exceptions properly
unset($artefact);
}
}
foreach ($profilefields['email']['unvalidated'] as $email) {
if (in_array($email, $values['email']['validated']) || isset($values['email']['unvalidated']) && in_array($email, $values['email']['unvalidated'])) {
continue;
}
delete_records('artefact_internal_profile_email', 'email', $email, 'owner', $USER->get('id'));
}
if ($profilefields['email']['default'] != $values['email']['default']) {
update_record('artefact_internal_profile_email', (object) array('principal' => 0), (object) array('owner' => $USER->get('id'), 'email' => $profilefields['email']['default']));
update_record('artefact_internal_profile_email', (object) array('principal' => 1), (object) array('owner' => $USER->get('id'), 'email' => $values['email']['default']));
update_record('usr', (object) array('email' => $values['email']['default']), (object) array('id' => $USER->get('id')));
$USER->email = $values['email']['default'];
$USER->commit();
}
} else {
if ($element == 'maildisabled') {
continue;
} else {
if ($element == 'socialprofile') {
continue;
} else {
if (!isset($profilefields[$element]) || $values[$element] != $profilefields[$element]) {
if ($element == 'introduction') {
$newintroduction = EmbeddedImage::prepare_embedded_images($values[$element], 'profileintrotext', $USER->get('id'));
$values[$element] = $newintroduction;
}
$classname = generate_artefact_class_name($element);
$profile = new $classname(0, array('owner' => $USER->get('id')));
$profile->set('title', $values[$element]);
$profile->commit();
}
}
}
}
}
try {
db_commit();
} catch (Exception $e) {
profileform_reply($form, PIEFORM_ERR, get_string('profilefailedsaved', 'artefact.internal'));
}
handle_event('updateuser', $USER->get('id'));
if (count($email_errors)) {
profileform_reply($form, PIEFORM_ERR, array('message' => get_string('emailingfailed', 'artefact.internal', join(', ', $email_errors))));
}
profileform_reply($form, PIEFORM_OK, get_string('profilesaved', 'artefact.internal'));
}
开发者ID:patkira,项目名称:mahara,代码行数:99,代码来源:index.php
示例20: get_extra_view_info
public static function get_extra_view_info(&$viewdata, $getartefacts = true)
{
if ($viewdata) {
// Get view owner details for display
$owners = array();
$groups = array();
$institutions = array();
foreach ($viewdata as $v) {
if ($v->owner && !isset($owners[$v->owner])) {
$owners[$v->owner] = (int) $v->owner;
} else {
if ($v->group && !isset($groups[$v->group])) {
$groups[$v->group] = (int) $v->group;
} else {
if (strlen($v->institution) && !isset($institutions[$v->institution])) {
$institutions[$v->institution] = $v->institution;
}
}
}
}
$viewidlist = join(',', array_map('intval', array_keys($viewdata)));
if ($getartefacts) {
$artefacts = get_records_sql_array('SELECT va.view, va.artefact, a.title, a.artefacttype, t.plugin
FROM {view_artefact} va
INNER JOIN {artefact} a ON va.artefact = a.id
INNER JOIN {artefact_installed_type} t ON a.artefacttype = t.name
WHERE va.view IN (' . $viewidlist . ')
GROUP BY va.view, va.artefact, a.title, a.artefacttype, t.plugin
ORDER BY a.title, va.artefact', '');
if ($artefacts) {
foreach ($artefacts as $artefactrec) {
safe_require('artefact', $artefactrec->plugin);
$classname = generate_artefact_class_name($artefactrec->artefacttype);
$artefactobj = new $classname(0, array('title' => $artefactrec->title));
$artefactobj->set('dirty', false);
if (!$artefactobj->in_view_list()) {
continue;
}
$artname = $artefactobj->display_title(30);
if (strlen($artname)) {
$viewdata[$artefactrec->view]->artefacts[] = array('id' => $artefactrec->artefact, 'title' => $artname);
}
}
}
}
|
请发表评论