当前位置: 首页>>代码示例>>PHP>>正文


PHP ArtefactType::attachments_from_id_list方法代码示例

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


在下文中一共展示了ArtefactType::attachments_from_id_list方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: get_posts

 /**
  * This function returns a list of the current user's blog posts, for the
  * given blog.
  *
  * @param User
  * @param integer
  * @param integer
  */
 public static function get_posts(User $user, $id, $limit = self::pagination, $offset = 0)
 {
     ($result = get_records_sql_assoc("\n         SELECT a.id, a.title, a.description, " . db_format_tsfield('a.ctime', 'ctime') . ', ' . db_format_tsfield('a.mtime', 'mtime') . ", bp.published\n         FROM {artefact} a\n          LEFT OUTER JOIN {artefact_blog_blogpost} bp\n           ON a.id = bp.blogpost\n         WHERE a.parent = ?\n          AND a.artefacttype = 'blogpost'\n          AND a.owner = ?\n         ORDER BY bp.published ASC, a.ctime DESC\n         LIMIT ? OFFSET ?;", array($id, $user->get('id'), $limit, $offset))) || ($result = array());
     $count = (int) get_field('artefact', 'COUNT(*)', 'owner', $user->get('id'), 'artefacttype', 'blogpost', 'parent', $id);
     if (count($result) > 0) {
         // Get the attached files.
         $files = ArtefactType::attachments_from_id_list(array_map(create_function('$a', 'return $a->id;'), $result));
         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));
                 $result[$file->artefact]->files[] = $file;
             }
         }
         // Format dates properly
         foreach ($result as &$post) {
             $post->ctime = format_date($post->ctime, 'strftimedaydatetime');
             $post->mtime = format_date($post->mtime);
             $post->description = clean_html($post->description);
         }
     }
     return array($count, array_values($result));
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:31,代码来源:lib.php


注:本文中的ArtefactType::attachments_from_id_list方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。