本文整理汇总了PHP中ArtefactType类的典型用法代码示例。如果您正苦于以下问题:PHP ArtefactType类的具体用法?PHP ArtefactType怎么用?PHP ArtefactType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArtefactType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submitview_submit
function submitview_submit(Pieform $form, $values)
{
global $SESSION, $USER, $viewid, $groupid, $group;
db_begin();
update_record('view', array('submittedgroup' => $groupid, 'submittedtime' => db_format_timestamp(time())), array('id' => $viewid));
$roles = get_column('grouptype_roles', 'role', 'grouptype', $group->grouptype, 'see_submitted_views', 1);
foreach ($roles as $role) {
$accessrecord = (object) array('view' => $viewid, 'group' => $groupid, 'role' => $role, 'visible' => 0, 'allowcomments' => 1, 'approvecomments' => 0);
ensure_record_exists('view_access', $accessrecord, $accessrecord);
}
ArtefactType::update_locked($USER->get('id'));
activity_occurred('groupmessage', array('subject' => get_string('viewsubmitted', 'view'), 'message' => get_string('viewsubmitted', 'view'), 'submittedview' => $viewid, 'viewowner' => $USER->get('id'), 'group' => $groupid, 'roles' => $roles, 'strings' => (object) array('urltext' => (object) array('key' => 'view'))));
db_commit();
$SESSION->add_ok_msg(get_string('viewsubmitted', 'view'));
redirect('/' . returnto());
}
示例2: get_allfacts
public static function get_allfacts($blockid, $offset = 0, $limit = 3)
{
$get_user = "\n SELECT owner\n FROM block_instance as a\n JOIN view as b\n ON b.id = a.view\n WHERE a.id = ?";
$result_user = get_records_sql_array($get_user, array($blockid));
$id_user = intval($result_user[0]->owner);
$datenow = time();
// time now to use for formatting facts by completion
($results = get_records_sql_array("\n SELECT a.id, at.artefact AS fact, at.completed, " . db_format_tsfield('completiondate') . ",\n a.title, a.description, a.parent, a.owner\n FROM {artefact} a\n JOIN {artefact_milestones_fact} at ON at.artefact = a.id\n WHERE a.artefacttype = 'fact'\n AND a.owner = ?\n ORDER BY at.completiondate ASC, a.id", array($id_user))) || ($results = array());
$count_records = count($results);
$results = array_slice($results, $offset, $limit + $offset);
// format the date and setup completed for display if fact is incomplete
if (!empty($results)) {
foreach ($results as $result) {
if (!empty($result->completiondate)) {
// if record hasn't been completed and completiondate has passed mark as such for display
if ($result->completiondate < $datenow && !$result->completed) {
$result->completed = -1;
}
$result->completiondate = format_date($result->completiondate, 'strftimedate');
}
$result->description = '<p>' . preg_replace('/\\n\\n/', '</p><p>', $result->description) . '</p>';
$result->tags = ArtefactType::artefact_get_tags($result->id);
}
}
$dateFormat = get_string('dateFormat', 'blocktype.milestones/allfacts');
$result = array('count' => $count_records, 'data' => $results, 'offset' => $offset, 'limit' => $limit, 'id' => $blockid, 'dateFormat' => $dateFormat);
return $result;
}
示例3: can_publish_artefact
/**
* Indicates whether the user has permission to use the artefact in their own Pages. The name
* refers to the "publish" permission for group files.
*
* If a user has "publish" permission on an artefact, it is assumed the also have "edit" and
* "view" permission (i.e. can view it in the artefact chooser -- see $USER->can_view_artefact())
*
* @param ArtefactType $a
* @return boolean
*/
public function can_publish_artefact($a)
{
$parent = $a->get_parent_instance();
if ($parent) {
if (!$this->can_view_artefact($parent)) {
return false;
}
}
if ($this->get('id') and $this->get('id') == $a->get('owner')) {
return true;
}
if ($i = $a->get('institution')) {
if ($i == 'mahara') {
return $this->get('admin');
}
return $this->in_institution($i) || $this->can_edit_institution($i);
}
if (!($group = $a->get('group'))) {
return false;
}
require_once 'group.php';
if (!($role = group_user_access($group, $this->id))) {
return false;
}
if ($role == 'admin') {
return true;
}
if ($this->id == $a->get('author')) {
return true;
}
return $a->role_has_permission($role, 'republish');
}
示例4: delete
/**
* This function extends ArtefactType::delete() by deleting embedded images
*/
public function delete()
{
if (empty($this->id)) {
return;
}
db_begin();
// Delete embedded images in the note
require_once 'embeddedimage.php';
EmbeddedImage::delete_embedded_images('textbox', $this->id);
// Delete the artefact and all children.
parent::delete();
db_commit();
}
示例5: data_mapping
public function data_mapping(ArtefactType $artefact)
{
$artefacttype = $artefact->get('artefacttype');
$artefactnote = $artefact->get('note');
// Mapping shouldn't contain 'socialprofile' artefacttype
// which is handled separately...
static $mapping = array('firstname' => 'legal_given_name', 'lastname' => 'legal_family_name', 'preferredname' => 'preferred_given_name', 'email' => 'email', 'blogaddress' => 'website', 'personalwebsite' => 'website', 'officialwebsite' => 'website', 'mobilenumber' => 'mobile', 'businessnumber' => 'workphone', 'homenumber' => 'homephone', 'faxnumber' => 'fax');
static $spacialmapping = array('country' => 'country', 'city' => 'addressline', 'town' => 'addressline', 'address' => 'addressline');
if (array_key_exists($artefacttype, $mapping)) {
return array('field' => $mapping[$artefacttype]);
}
if ($artefacttype == 'socialprofile') {
if (in_array($artefactnote, ArtefactTypeSocialprofile::$socialnetworks)) {
// Export old messaging system accounts as
// persondata fields with leap:field="id".
return array('field' => 'id', 'service' => $artefactnote);
} else {
// Export new social site profiles as persondata fields
// with leap:field="website" (what they basically are).
return array('field' => 'website');
}
}
if (array_key_exists($artefacttype, $spacialmapping)) {
$result = array('spacial' => true, 'type' => $spacialmapping[$artefacttype]);
if ($artefacttype == 'country') {
require_once 'country.php';
$result['countrycode'] = Country::iso3166_1alpha2_to_iso3166_1alpha3($artefact->get('title'));
}
return $result;
}
if ($artefacttype == 'studentid') {
return array('field' => 'other', 'label' => 'Student ID');
}
/*
'industry // not part of persondata
'occupation // not part of persondata
'introduction // not part of persondata
*/
return false;
}
示例6: __construct
/**
* Constructor.
* If an id is supplied, will query the database
* to build up the basic information about the object.
* If an id is not supplied, we just create an empty
* artefact, ready to be filled up.
* If the $new parameter is true, we can skip the query
* because we know the artefact is new.
*
* @param int $id artefact.id
* @param mixed $data optional data supplied for artefact
* @param bool $new
*/
public function __construct($id = 0, $data = null, $new = FALSE)
{
if (!empty($id)) {
if (empty($data)) {
if (!($data = get_record('artefact', 'id', $id))) {
throw new ArtefactNotFoundException(get_string('artefactnotfound', 'error', $id));
}
}
$this->id = $id;
} else {
$this->ctime = $this->mtime = time();
$this->dirty = true;
}
if (empty($data)) {
$data = array();
}
foreach ((array) $data as $field => $value) {
if (property_exists($this, $field)) {
if (in_array($field, array('atime', 'ctime', 'mtime'))) {
$value = strtotime($value);
}
if ($field == 'tags' && !is_array($value)) {
$value = preg_split("/\\s*,\\s*/", trim($value));
}
$this->{$field} = $value;
}
}
if (!empty($this->parent)) {
$this->oldparent = $this->parent;
}
$this->artefacttype = $this->get_artefact_type();
if (!empty($data->artefacttype)) {
if ($this->artefacttype != $data->artefacttype) {
throw new SystemException(get_string('artefacttypemismatch', 'error', $data->artefacttype, $this->artefacttype));
}
}
// load tags
if ($this->id) {
$this->tags = ArtefactType::artefact_get_tags($this->id);
}
// load group permissions
if ($this->group && !is_array($this->rolepermissions)) {
$this->load_rolepermissions();
}
$this->atime = time();
}
示例7: commit
/**
* This method extends ArtefactType::commit() by adding additional data
* into the artefact_plans_task table.
*
*/
public function commit()
{
if (empty($this->dirty)) {
return;
}
// Return whether or not the commit worked
$success = FALSE;
db_begin();
parent::commit();
db_commit();
$this->dirty = $success ? FALSE : TRUE;
return $success;
}
示例8: group_delete
/**
* Deletes a group.
*
* All group deleting should be done through this function, even though it is
* simple. What is required to perform group deletion may change over time.
*
* @param int $groupid The group to delete
* @param string $shortname shortname of the group
* @param string $institution institution of the group
*
* {{@internal Maybe later we can have a group_can_be_deleted function if
* necessary}}
*/
function group_delete($groupid, $shortname = null, $institution = null, $notifymembers = true)
{
if (empty($groupid) && !empty($institution) && !is_null($shortname) && strlen($shortname)) {
// External call to delete a group, check permission of $USER.
global $USER;
if (!$USER->can_edit_institution($institution)) {
throw new AccessDeniedException("group_delete: cannot delete a group in this institution");
}
$group = get_record('group', 'shortname', $shortname, 'institution', $institution);
} else {
$groupid = group_param_groupid($groupid);
$group = get_record('group', 'id', $groupid);
}
db_begin();
// Leave the group_member table alone, it's needed for the deleted
// group notification that's about to happen on cron.
delete_records('group_member_invite', 'group', $group->id);
delete_records('group_member_request', 'group', $group->id);
delete_records('view_access', 'group', $group->id);
// Delete views owned by the group
require_once get_config('libroot') . 'view.php';
foreach (get_column('view', 'id', 'group', $group->id) as $viewid) {
$view = new View($viewid);
$view->delete();
}
// Release views submitted to the group
foreach (get_column('view', 'id', 'submittedgroup', $group->id) as $viewid) {
$view = new View($viewid);
$view->release();
}
// Delete artefacts
require_once get_config('docroot') . 'artefact/lib.php';
ArtefactType::delete_by_artefacttype(get_column('artefact', 'id', 'group', $group->id));
// Delete forums
require_once get_config('docroot') . 'interaction/lib.php';
foreach (get_column('interaction_instance', 'id', 'group', $group->id) as $forumid) {
$forum = interaction_instance_from_id($forumid);
$forum->delete();
}
if ($notifymembers) {
require_once 'activity.php';
activity_occurred('groupmessage', array('group' => $group->id, 'deletedgroup' => true, 'strings' => (object) array('subject' => (object) array('key' => 'deletegroupnotificationsubject', 'section' => 'group', 'args' => array(hsc($group->name))), 'message' => (object) array('key' => 'deletegroupnotificationmessage', 'section' => 'group', 'args' => array(hsc($group->name), get_config('sitename'))))));
}
// make sure the group name + deleted suffix will fit within 128 chars
$delete_name = $group->name;
if (strlen($delete_name) > 100) {
$delete_name = substr($delete_name, 0, 100) . '(...)';
}
update_record('group', array('deleted' => 1, 'name' => $delete_name . '.deleted.' . time(), 'shortname' => null, 'institution' => null, 'category' => null, 'urlid' => null), array('id' => $group->id));
db_commit();
}
示例9: foreach
}
if (!isset($data[$b->artefact]->tags)) {
$data[$b->artefact]->tags = ArtefactType::artefact_get_tags($b->artefact);
}
}
}
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 = '
示例10: data_mapping
public function data_mapping(ArtefactType $artefact)
{
$artefacttype = $artefact->get('artefacttype');
static $mapping = array('firstname' => 'legal_given_name', 'lastname' => 'legal_family_name', 'preferredname' => 'preferred_given_name', 'email' => 'email', 'blogaddress' => 'website', 'personalwebsite' => 'website', 'officialwebsite' => 'website', 'mobilenumber' => 'mobile', 'businessnumber' => 'workphone', 'homenumber' => 'homephone', 'faxnumber' => 'fax');
static $idmapping = array('jabberusername' => 'jabber', 'skypeusername' => 'skype', 'yahoochat' => 'yahoo', 'aimscreenname' => 'aim', 'msnnumber' => 'msn', 'icqnumber' => 'icq');
static $spacialmapping = array('country' => 'country', 'city' => 'addressline', 'town' => 'addressline', 'address' => 'addressline');
if (array_key_exists($artefacttype, $mapping)) {
return array('field' => $mapping[$artefacttype]);
}
if (array_key_exists($artefacttype, $idmapping)) {
return array('field' => 'id', 'service' => $idmapping[$artefacttype]);
}
if (array_key_exists($artefacttype, $spacialmapping)) {
$result = array('spacial' => true, 'type' => $spacialmapping[$artefacttype]);
if ($artefacttype == 'country') {
require_once 'country.php';
$result['countrycode'] = Country::iso3166_1alpha2_to_iso3166_1alpha3($artefact->get('title'));
}
return $result;
}
if ($artefacttype == 'studentid') {
return array('field' => 'other', 'label' => 'Student ID');
}
/*
'industry // not part of persondata
'occupation // not part of persondata
'introduction // not part of persondata
*/
return false;
}
示例11: 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;
}
示例12: create_attachment
/**
* helper function to create attachments between entries.
* The 2010-07 version of leap2a says that linked *entries* should use related relation,
* and directly linked files (attachments) should use enclosures.
* However, for BC we should support both.
* This function supports both and additionally creates the File artefacts for attachments, then links them.
*
* @param SimpleXMLElement $entry the entry we want to attach things *to*
* @param SimpleXMLElement $link the link to inspect
* @param ArtefactType $artefact the artefact that has been created from the entry.
*
* @return void|int the id of a *newly created* attached artefact
*/
public function create_attachment(SimpleXMLElement $entry, SimpleXMLElement $link, ArtefactType &$artefact)
{
if (($this->curie_equals($link['rel'], '', 'enclosure') || $this->curie_equals($link['rel'], '', 'related')) && isset($link['href'])) {
$this->trace("Attaching file {$link['href']} to comment {$entry->id}", PluginImportLeap::LOG_LEVEL_VERBOSE);
$artefactids = $this->get_artefactids_imported_by_entryid((string) $link['href']);
if (isset($artefactids[0])) {
$artefact->attach($artefactids[0]);
} else {
// it may be just an attached file, with no Leap2A element in its own right ....
if ($id = $this->create_linked_file($entry, $link)) {
$artefact->attach($id);
return $id;
}
}
}
}
示例13: artefactchooser_get_element_data
public static function artefactchooser_get_element_data($artefact)
{
require_once 'license.php';
$artefactobj = artefact_instance_from_id($artefact->id);
$artefact->safelicense = render_license($artefactobj);
$artefact->tags = ArtefactType::artefact_get_tags($artefact->id);
$artefact->safetags = is_array($artefact->tags) ? hsc(join(', ', $artefact->tags)) : '';
return $artefact;
}
示例14: get_comments
public static function get_comments($limit = 10, $offset = 0, $showcomment = null, &$view = null, &$artefact = null)
{
global $USER;
$userid = $USER->get('id');
$viewid = $view->get('id');
if (!empty($artefact)) {
$canedit = $USER->can_edit_artefact($artefact);
$owner = $artefact->get('owner');
$isowner = $userid && $userid == $owner;
$artefactid = $artefact->get('id');
} else {
$canedit = $USER->can_edit_view($view);
$owner = $view->get('owner');
$isowner = $userid && $userid == $owner;
$artefactid = null;
}
$result = (object) array('limit' => $limit, 'offset' => $offset, 'view' => $viewid, 'artefact' => $artefactid, 'canedit' => $canedit, 'owner' => $owner, 'isowner' => $isowner, 'data' => array());
if (!empty($artefactid)) {
$where = 'c.onartefact = ' . (int) $artefactid;
} else {
$where = 'c.onview = ' . (int) $viewid;
}
if (!$canedit) {
$where .= ' AND (c.private = 0 OR a.author = ' . (int) $userid . ')';
}
$result->count = count_records_sql('
SELECT COUNT(*)
FROM {artefact} a JOIN {artefact_comment_comment} c ON a.id = c.artefact
WHERE ' . $where);
if ($result->count > 0) {
if ($showcomment == 'last') {
// Ignore $offset and just get the last page of feedback
$result->forceoffset = $offset = (ceil($result->count / $limit) - 1) * $limit;
} else {
if (is_numeric($showcomment)) {
// Ignore $offset and get the page that has the comment
// with id $showcomment on it.
// Fetch everything up to $showcomment to get its rank
// This will get ugly if there are 1000s of comments
$ids = get_column_sql('
SELECT a.id
FROM {artefact} a JOIN {artefact_comment_comment} c ON a.id = c.artefact
WHERE ' . $where . ' AND a.id <= ?
ORDER BY a.ctime', array($showcomment));
$last = end($ids);
if ($last == $showcomment) {
$rank = key($ids);
$result->forceoffset = $offset = (ceil($rank / $limit) - 1) * $limit;
$result->showcomment = $showcomment;
}
}
}
$comments = get_records_sql_assoc('
SELECT
a.id, a.author, a.authorname, a.ctime, a.description,
c.private, c.deletedby, c.requestpublic,
u.username, u.firstname, u.lastname, u.preferredname, u.email, u.staff, u.admin,
u.deleted, u.profileicon
FROM {artefact} a
INNER JOIN {artefact_comment_comment} c ON a.id = c.artefact
LEFT JOIN {usr} u ON a.author = u.id
WHERE ' . $where . '
ORDER BY a.ctime', array(), $offset, $limit);
$files = ArtefactType::attachments_from_id_list(array_keys($comments));
if ($files) {
safe_require('artefact', 'file');
foreach ($files as &$file) {
$comments[$file->artefact]->attachments[] = $file;
}
}
$result->data = array_values($comments);
}
self::build_html($result);
return $result;
}
示例15: __construct
public function __construct($id = 0, $data = array())
{
if (empty($id)) {
$data['title'] = get_string($this->get_artefact_type(), 'artefact.europass');
}
parent::__construct($id, $data);
}