• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ArtefactType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ArtefactType的典型用法代码示例。如果您正苦于以下问题:PHP ArtefactType类的具体用法?PHP ArtefactType怎么用?PHP ArtefactType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ArtefactType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:16,代码来源:submit.php


示例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;
 }
开发者ID:vohung96,项目名称:mahara,代码行数:28,代码来源:lib.php


示例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');
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:42,代码来源:user.php


示例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();
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:16,代码来源:lib.php


示例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;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:40,代码来源:lib.php


示例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();
 }
开发者ID:kienv,项目名称:mahara,代码行数:59,代码来源:lib.php


示例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;
 }
开发者ID:edictdev,项目名称:flexifact,代码行数:18,代码来源:lib.php


示例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();
}
开发者ID:vohung96,项目名称:mahara,代码行数:64,代码来源:group.php


示例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 = '
开发者ID:sarahjcotton,项目名称:mahara,代码行数:31,代码来源:notes.php


示例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;
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:30,代码来源:lib.php


示例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;
 }
开发者ID:vohung96,项目名称:mahara,代码行数:40,代码来源:lib.php


示例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;
             }
         }
     }
 }
开发者ID:agwells,项目名称:Mahara-1,代码行数:29,代码来源:lib.php


示例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;
 }
开发者ID:banterweb,项目名称:mahara,代码行数:9,代码来源:lib.php


示例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;
 }
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:75,代码来源:lib.php


示例15: get_comments

 /**
  * Generates data object required for displaying comments on the page.
  *
  * @param  int $limit              The number of comments to display (set to
  *                                 0 for disabling pagination and showing all comments)
  * @param  int $offset             The offset of comments used for pagination
  * @param  int|string $showcomment Optionally show page with particular comment
  *                                 on it or the last page. $offset will be ignored.
  *                                 Specify either comment_id or 'last' respectively.
  *                                 Set to null to use $offset for pagination.
  * @param  object $view            The view object
  * @param  object $artefact        Optional artefact object
  * @param  bool   $export          Determines if comments are fetched for html export purposes
  * @return object $result          Comments data object
  */
 public static function get_comments($limit = 10, $offset = 0, $showcomment, &$view, &$artefact = null, $export = false)
 {
     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_moderate_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, 'export' => $export, '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 pagination is in use, see if we want to get a page with particular comment
         if ($limit) {
             if ($showcomment == 'last') {
                 // If we have limit (pagination is used) 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) {
                         // Add 1 because array index starts from 0 and therefore key value is offset by 1.
                         $rank = key($ids) + 1;
                         $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.mtime, a.description, a.group,
                 c.private, c.deletedby, c.requestpublic, c.rating, c.lastcontentupdate,
                 u.username, u.firstname, u.lastname, u.preferredname, u.email, u.staff, u.admin,
                 u.deleted, u.profileicon, u.urlid
             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);
     }
     // check to see if the feedback is to be displayed in a block instance
     // or the base of the page
     $result->position = 'base';
     $blocks = get_records_array('block_instance', 'view', $viewid);
     if (!empty($blocks)) {
         foreach ($blocks as $block) {
             if ($block->blocktype == 'comment') {
                 $result->position = 'blockinstance';
                 break;
//.........这里部分代码省略.........
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:101,代码来源:lib.php


示例16: get_comments


//.........这里部分代码省略.........
     if ($result->count > 0) {
         // Figure out sortorder
         if (!$threaded) {
             $orderby = 'a.ctime ' . ($sort == 'latest' ? 'DESC' : 'ASC');
         } else {
             if ($sort != 'latest') {
                 // Threaded ascending
                 $orderby = 'a.path ASC, a.ctime ASC, a.id';
             } else {
                 // Threaded & descending. Sort "root comments" by descending order, and the
                 // comments below them in ascending order. (This is the only sane way to do it.)
                 if (is_mysql()) {
                     $splitfunc = 'SUBSTRING_INDEX';
                 } else {
                     $splitfunc = 'SPLIT_PART';
                 }
                 $orderby = "{$splitfunc}(a.path, '/', 2) DESC, a.path ASC, a.ctime ASC, a.id";
             }
         }
         // If pagination is in use, see if we want to get a page with particular comment
         if ($limit) {
             if ($showcomment == 'last') {
                 // If we have limit (pagination is used) 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 and figure out which page $showcomment is in.
                     // 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
                             LEFT JOIN {artefact} p ON a.parent = p.id
                         WHERE ' . $where . '
                         ORDER BY ' . $orderby, array());
                     $found = false;
                     foreach ($ids as $k => $v) {
                         if ($v == $showcomment) {
                             $found = $k;
                             break;
                         }
                     }
                     if ($found !== false) {
                         // Add 1 because array index starts from 0 and therefore key value is offset by 1.
                         $rank = $found + 1;
                         $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.mtime, a.description, a.group,
                 c.private, c.deletedby, c.requestpublic, c.rating, c.lastcontentupdate,
                 u.username, u.firstname, u.lastname, u.preferredname, u.email, u.staff, u.admin,
                 u.deleted, u.profileicon, u.urlid, a.path, p.id AS parent, p.author AS parentauthor
             FROM {artefact} a
                 INNER JOIN {artefact_comment_comment} c ON a.id = c.artefact
                 LEFT JOIN {artefact} p
                     ON a.parent = p.id
                 LEFT JOIN {usr} u ON a.author = u.id
             WHERE ' . $where . '
             ORDER BY ' . $orderby, 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;
             }
         }
         // calculate the indent tabs for the comments
         $max_depth = $threaded ? get_config_plugin('artefact', 'comment', 'maxindent') : 1;
         $usercache = array($userid => $canedit);
         foreach ($comments as &$c) {
             // You can post a public reply to a comment if you can see it & the comment is not private
             $c->canpublicreply = (int) self::can_public_reply_to_comment($c->private, $c->deletedby);
             $c->canprivatereply = (int) self::can_private_reply_to_comment($c->private, $c->deletedby, $userid, $c->author, $c->parentauthor, $artefact, $view);
             $c->canreply = $threaded && ($c->canpublicreply || $c->canprivatereply) ? 1 : 0;
             $c->indent = $max_depth == 1 ? 1 : min($max_depth, substr_count($c->path, '/'));
             // Count indent levels starting from 0 instead of 1.
             $c->indent -= 1;
         }
         $result->data = array_values($comments);
     }
     // check to see if the feedback is to be displayed in a block instance
     // or the base of the page
     $result->position = 'base';
     $blocks = get_records_array('block_instance', 'view', $viewid);
     if (!empty($blocks)) {
         foreach ($blocks as $block) {
             if ($block->blocktype === 'comment') {
                 $result->position = 'blockinstance';
             }
         }
     }
     self::build_html($result, $onview);
     return $result;
 }
开发者ID:kienv,项目名称:mahara,代码行数:101,代码来源:lib.php


示例17: _db_submit

 /**
  * Lower-level function to handle all the DB changes that should occur when you submit a view or views
  *
  * @param array $viewids The views to submit. (Normally one view by itself, or all the views in a Collection)
  * @param object $submittedgroupobj An object holding information about the group submitting to. Should contain id and roles array
  * @param string $submittedhost Alternately, the name of the remote host the group is being submitted to (for MNet submission)
  * @param int $owner The ID of the owner of the view. Used mostly for verification purposes.
  */
 public static function _db_submit($viewids, $submittedgroupobj = null, $submittedhost = null, $owner = null)
 {
     global $USER;
     require_once get_config('docroot') . 'artefact/lib.php';
     $group = $submittedgroupobj;
     // Gotta provide some viewids and/or a remote username
     if (empty($viewids) || empty($group->id) && empty($submittedhost)) {
         return;
     }
     $idstr = join(',', array_map('intval', $viewids));
     $userid = $owner == null ? $USER->get('id') : $owner;
     $sql = 'UPDATE {view} SET submittedtime = current_timestamp, submittedstatus = ' . self::SUBMITTED;
     $params = array();
     if ($group) {
         $groupid = (int) $group->id;
         $sql .= ', submittedgroup = ? ';
         $params[] = $groupid;
     } else {
         $sql .= ', submittedhost = ? ';
         $params[] = $submittedhost;
     }
     $sql .= " WHERE id IN ({$idstr}) AND owner = ?";
     $params[] = $userid;
     db_begin();
     execute_sql($sql, $params);
     if ($group) {
         foreach ($group->roles as $role) {
             foreach ($viewids as $viewid) {
                 $accessrecord = (object) array('view' => $viewid, 'group' => $groupid, 'role' => $role, 'visible' => 0, 'allowcomments' => 1, 'approvecomments' => 0, 'ctime' => db_format_timestamp(time()));
                 ensure_record_exists('view_access', $accessrecord, $accessrecord);
             }
         }
     }
     ArtefactType::update_locked($userid);
     db_commit();
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:44,代码来源:view.php


示例18: release

 public function release($releaseuser = null)
 {
     require_once get_config('docroot') . 'artefact/lib.php';
     $submitinfo = $this->submitted_to();
     if (is_null($submitinfo)) {
         throw new ParameterException("View with id " . $this->get('id') . " has not been submitted");
     }
     $releaseuser = optional_userobj($releaseuser);
     db_begin();
     if ($submitinfo['type'] == 'group') {
         $group = $this->get('submittedgroup');
         $this->set('submittedgroup', null);
         if ($group) {
             // Remove hidden tutor view access records
             delete_records('view_access', 'view', $this->id, 'group', $group, 'visible', 0);
         }
     } else {
         if ($submitinfo['type'] == 'host') {
             $this->set('submittedhost', null);
         }
     }
     $this->set('submittedtime', null);
     $this->commit();
     ArtefactType::update_locked($this->owner);
     db_commit();
     $ownerlang = get_user_language($this->get('owner'));
     $url = get_config('wwwroot') . 'view/view.php?id=' . $this->get('id');
     require_once 'activity.php';
     activity_occurred('maharamessage', array('users' => array($this->get('owner')), 'subject' => get_string_from_language($ownerlang, 'viewreleasedsubject', 'group', $this->get('title'), $submitinfo['name'], display_name($releaseuser, $this->get_owner_object())), 'message' => get_string_from_language($ownerlang, 'viewreleasedmessage', 'group', $this->get('title'), $submitinfo['name'], display_name($releaseuser, $this->get_owner_object())), 'url' => $url, 'urltext' => $this->get('title')));
 }
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:30,代码来源:view.php


示例19: delete

 public function delete()
 {
     // ArtefactType::delete() deletes all the child artefacts one by one.
     // If the folder contains a lot of artefacts, it's too slow to do this
     // but for very small directories it seems to be slightly faster.
     $descendants = artefact_get_descendants(array($this->id));
     if (count($descendants) < 10) {
         parent::delete();
     } else {
         ArtefactType::delete_by_artefacttype($descendants);
     }
 }
开发者ID:vohung96,项目名称:mahara,代码行数:12,代码来源:lib.php



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ArtefactTypeComment类代码示例发布时间:2022-05-23
下一篇:
PHP Art类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap