1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: /**
13: * avatars module
14: *
15: * @copyright XOOPS Project (http://xoops.org)
16: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
17: * @package avatar
18: * @since 2.6.0
19: * @author Mage Gregory (AKA Mage)
20: * @version $Id$
21: */
22:
23: /**
24: * xoops_module_install_avatars - install supplement for avatars module
25: *
26: * @param object &$module module object
27: *
28: * @return boolean true on success
29: */
30: function xoops_module_install_avatars(&$module)
31: {
32: /* This is all upgrade related, not install.
33: TODO: Add to upgrade script and remove from here
34:
35: global $xoopsDB;
36: // delete avatar_allow_upload, avatar_width, avatar_height, avatar_maxsize and avatar_minposts
37: $xoops = Xoops::getInstance();
38: $sql = "DELETE FROM " . $xoopsDB->prefix("config") . " WHERE `conf_name` IN "
39: . " ('avatar_allow_upload', 'avatar_width', 'avatar_height', 'avatar_maxsize', 'avatar_minposts') ";
40: $xoopsDB->queryF($sql);
41:
42: $dbManager = new XoopsDatabaseManager();
43: $map = array(
44: 'avatar_id' => 'avatar_id',
45: 'avatar_file' => 'avatar_file',
46: 'avatar_name' => 'avatar_name',
47: 'avatar_mimetype' => 'avatar_mimetype',
48: 'avatar_created' => 'avatar_created',
49: 'avatar_display' => 'avatar_display',
50: 'avatar_weight' => 'avatar_weight',
51: 'avatar_type' => 'avatar_type',
52: );
53: $dbManager->copyFields($map, 'avatar', 'avatars_avatar', false);
54:
55: $map = array(
56: 'avatar_id' => 'avatar_id',
57: 'user_id' => 'user_id',
58: );
59: $dbManager->copyFields($map, 'avatar_user_link', 'avatars_user_link', false);
60: */
61:
62: $xoops_root_path = \XoopsBaseConfig::get('root-path');
63:
64: // create folder "avatars"
65: $dir = $xoops_root_path . "/uploads/avatars";
66: if (!is_dir($dir)) {
67: mkdir($dir, 0777);
68: chmod($dir, 0777);
69: }
70: //Copy index.html
71: $file = $xoops_root_path . "/uploads/avatars/index.html";
72: if (!is_file($file)) {
73: copy($xoops_root_path . "/modules/avatars/images/index.html", $file);
74: }
75: //Copy blank.gif
76: $file = $xoops_root_path . "/uploads/avatars/blank.gif";
77: if (!is_file($file)) {
78: copy($xoops_root_path . "/modules/avatars/images/blank.gif", $file);
79: }
80: //Copy .htaccess
81: $file = $xoops_root_path . "/uploads/avatars/.htaccess";
82: if (!is_file($file)) {
83: copy($xoops_root_path . "/uploads/.htaccess", $file);
84: }
85: return true;
86: }
87: