break; case 'createfolder': $filter->cleanData('int', array('catparent' => $_POST['catparent'], 'catinherit' => $_POST['catinherit'])); $filter->cleanData('text', array('catname' => $_POST['catname'], 'catdesc' => $_POST['catdesc'])); $_CLEAN = $filter->getDbData(); $catpid = $_CLEAN['int']['catparent']; $catname = $_CLEAN['text']['catname']; $catdesc = $_CLEAN['text']['catdesc']; $catinherit = $_CLEAN['int']['catinherit']; if (empty($catname)) { $data['errmsg'] = 'Empty Folder Name'; $data['retcode'] = 500; } elseif (fm_getPermission($catpid, 'admin')) { $test = PLG_itemPreSave('nexfile_folder_create', $_CLEAN); if (empty($test)) { $catresult = fm_createCategory($catpid, $catname, $catdesc); if ($catresult['0'] > 0) { $newcid = $catresult['0']; if ($autonotify == 1) { // Version 3.0 -- not presently being used DB_query("UPDATE {$_TABLES['nxfile_categories']} set auto_create_notifications='1' WHERE cid='{$newcid}'"); } PLG_itemSaved($newcid, 'nexfile_folder_create'); fm_updateAuditLog("New Category: {$newcid} created"); $data['retcode'] = 200; $data['cid'] = $newcid; if ($catpid == 0) { $data['displaycid'] = $newcid; } else { $data['displaycid'] = $catpid; }
/** * Plugin postinstall * * We're inserting our default data here since it depends on other stuff that * has to happen first ... * * @return boolean true = proceed with install, false = an error occured * */ function plugin_postinstall_nexproject($pi_name) { global $_DB_dbms, $_CONF, $_DB_table_prefix, $_TABLES; require_once $_CONF['path'] . 'plugins/nexproject/nexproject.php'; // fix nexproject block group ownership $blockAdminGroup = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Block Admin'"); if ($blockAdminGroup > 0) { // set the block's permissions $A = array(); SEC_setDefaultPermissions($A, $_CONF['default_permissions_block']); // ... and make it the last block on the right side $result = DB_query("SELECT MAX(blockorder) FROM {$_TABLES['blocks']} WHERE onleft = 0"); list($order) = DB_fetchArray($result); $order += 10; DB_query("UPDATE {$_TABLES['blocks']} SET group_id = {$blockAdminGroup}, blockorder = {$order}, perm_owner = {$A['perm_owner']}, perm_group = {$A['perm_group']}, perm_members = {$A['perm_members']}, perm_anon = {$A['perm_anon']} WHERE (type = 'phpblock') AND (phpblockfn = 'phpblock_nexproject')"); } $nexfile = true; if (!function_exists("fm_createCategory")) { //COM_errorLog ('The nexFile plugin is not installed. Please install it before continuing', 1); //echo COM_refresh ($_CONF['site_admin_url'] . '/plugins.php?msg=2&plugin='.$pi_name); //exit(0); $nexfile = false; } $forum = true; if (!function_exists("forum_addForum")) { //COM_errorLog ('The forum plugin is not installed. Please install it before continuing', 1); //echo COM_refresh ($_CONF['site_admin_url'] . '/plugins.php?msg=4&plugin='.$pi_name); //exit(0); $forum = false; } //And now, install the lookup lists and add nxprj config values to house the nexlist items $sql = "insert into {$_TABLES['nexlist']} (plugin, category, name, description, listfields, edit_perms, view_perms, active)\r\n values ( 'all','nexPro', 'Locations', 'List of locations', 1, 1, 2, 1);"; $res = DB_query($sql); $locID = DB_insertId(); $sql = "insert into {$_TABLES['nexlist']} (plugin, category, name, description, listfields, edit_perms, view_perms, active)\r\n values ('all','nexPro','Departments','List of Departments', 1, 1, 2, 1);"; $res = DB_query($sql); $deptID = DB_insertId(); $sql = "insert into {$_TABLES['nexlist']} (plugin, category, name, description, listfields, edit_perms, view_perms, active)\r\n values ('all','nexPro', 'Categories','List of Categories', 1, 1, 2, 1);"; $res = DB_query($sql); $catID = DB_insertId(); $sql = "INSERT INTO {$_TABLES['nexlist']} (plugin, category, name, description, listfields, edit_perms, view_perms, active)\r\n VALUES ('all', 'nexPro', 'Objectives', 'List of Project Objectives', 1, 1, 2, 1);"; $res = DB_query($sql); $objID = DB_insertId(); /* create lookuplist Fields for list definitions */ $_PRJSQL[] = "insert into {$_TABLES['nexlistfields']} (lid, fieldname) values('{$locID}','Location' )"; $_PRJSQL[] = "insert into {$_TABLES['nexlistfields']} (lid, fieldname) values('{$deptID}','Department' )"; $_PRJSQL[] = "insert into {$_TABLES['nexlistfields']} (lid, fieldname) values('{$catID}','Department' )"; $_PRJSQL[] = "insert into {$_TABLES['nexlistfields']} (lid, fieldname) values('{$objID}','Objective' )"; /* create lookuplist list records for each definition */ $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 10, 'Toronto',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 20, 'Hong Kong',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 30, 'Brisbane',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 40, 'Tokyo',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 50, 'New York',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 60, 'San Fransisco',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 70, 'London',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 10, 'Sales',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 20, 'Information Technology',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 30, 'Marketing',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 40, 'Finance',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 50, 'Operations',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 60, 'Legal',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 70, 'Revenue',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 10, 'Revenue',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 20, 'Safety',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 30, 'Environment',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 40, 'Training',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 50, 'Product Development',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 60, 'Branding',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 70, 'Investment',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 80, 'Capital Expenditure',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) VALUES ('{$objID}', 90, 'Business Growth', 1);"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) VALUES ('{$objID}', 100, 'Product Development', 1);"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) VALUES ('{$objID}', 110, 'Objective 3', 1);"; foreach ($_PRJSQL as $sql) { DB_query($sql); if (DB_error()) { $err = 1; } } $c = config::get_instance(); $c->add('prj_list', NULL, 'fieldset', 0, 1, NULL, 0, true, 'nexproject'); $c->add('nexlist_locations', $locID, 'text', 0, 1, 0, 150, true, 'nexproject'); $c->add('nexlist_departments', $deptID, 'text', 0, 1, 0, 160, true, 'nexproject'); $c->add('nexlist_category', $catID, 'text', 0, 1, 0, 170, true, 'nexproject'); $c->add('nexlist_objective', $objID, 'text', 0, 1, 0, 180, true, 'nexproject'); //we are assuming that nexfile and the forum are installed here. We cannot get this far if they werent! //the first thing we do is create a new nexFile category which will be used as the base category ID to dump files into for projects if ($nexfile) { $arr = fm_createCategory(0, 'nexProject Category', 'This base category is used by the nexProject plugin to create document repositories for each project.', true); //config parms for this $c->add('prj_file', NULL, 'fieldset', 0, 2, NULL, 0, true, 'nexproject'); $c->add('nexfile_parent', $arr[0], 'text', 0, 2, 0, 190, true, 'nexproject'); } else { //config parms for this $c->add('prj_file', NULL, 'fieldset', 0, 2, NULL, 0, true, 'nexproject'); $c->add('nexfile_parent', 0, 'text', 0, 2, 0, 190, true, 'nexproject'); } //and now, we create a new forum category and dump that into the config database if ($forum) { $sql = "INSERT INTO {$_TABLES['gf_categories']} (cat_order,cat_name,cat_dscp) values (0,'nexProject Category','This base category is used by the nexProject plugin to create forum repositories for each project.') "; DB_query($sql); $catid = DB_insertId(); $c->add('prj_forum', NULL, 'fieldset', 0, 3, NULL, 0, true, 'nexproject'); $c->add('forum_parent', $catid, 'text', 0, 3, 0, 200, true, 'nexproject'); } else { $c->add('prj_forum', NULL, 'fieldset', 0, 3, NULL, 0, true, 'nexproject'); $c->add('forum_parent', 0, 'text', 0, 3, 0, 200, true, 'nexproject'); } return true; }
$sql .= "'0',"; //fullaccess $sql .= "'0'"; //seedetails $sql .= ")"; DB_query($sql); } } } if (is_array($_CLEAN['category'])) { for ($i = 0; $i < count($_CLEAN['category']); $i++) { DB_query("INSERT INTO {$_TABLES['prj_category']} (pid, category_id) VALUES ({$lastid}, {$_CLEAN['category'][$i]})"); } } if ($_CLEAN['document'] == 'Y') { $retchk = fm_createCategory($_PRJCONF['nexfile_parent'], $_CLEAN['name'], $_CLEAN['description'], true); $catid = $retchk[0]; $retmsg = $retchk[1]; DB_query("UPDATE {$_TABLES['prj_projects']} SET cid='{$catid}' WHERE pid='{$lastid}'"); $logentry = "Project ID-{$lastid}, nexfile Folder created ID: {$catid}. Msg: {$retmsg}"; prg_updateAuditLog($logentry); $uid = $_USER['uid']; DB_query("INSERT INTO {$_TABLES['nxfile_access']} (catid,uid,view, upload, upload_direct, upload_ver, approval, admin) VALUES ('{$catid}','{$uid}','1','1','1','1','1','1')"); if ($_POST['private'] == 'N') { DB_query("INSERT INTO {$_TABLES['nxfile_access']} (catid,grp_id, view, upload, upload_direct, upload_ver, approval, admin) VALUES ('{$catid}','2','1','0','0','0','0','0')"); } } if ($_CLEAN['forum'] == 'Y') { $forumid = forum_addForum($_CLEAN['name'], $_PRJCONF['forum_parent'], $_CLEAN['description'], 0); DB_query("UPDATE {$_TABLES['prj_projects']} SET fid={$forumid} WHERE pid={$lastid}"); $logentry = "Project ID-{$lastid}, FORUM created ID: {$forumid}";