示例#1
0
 /**
  * Create an object, it's table, files and rights
  *
  * @since 2.1.5
  * @param name object short name
  * @param itemtype object class name
  * @param options create options :
  *    - add_table : add the object table (default is no)
  *    - create_default_profile : add default right (default is no) for current user profile
  *    - add_injection_file : add file to integrate itemtype into the datainjection plugin
  *    - add_language_file : create a default language for the itemtype
  * @return none
  */
 static function addNewObject($name, $itemtype, $options = array())
 {
     $params['add_table'] = false;
     $params['create_default_profile'] = false;
     $params['add_injection_file'] = false;
     $params['add_language_file'] = true;
     foreach ($options as $key => $value) {
         $params[$key] = $value;
     }
     if ($params['add_table']) {
         self::addTable($itemtype);
     }
     //Write object class on the filesystem
     self::addClassFile($name, $itemtype);
     //Write the form on the filesystem
     self::addFormFile($name, $itemtype);
     self::addSearchFile($name, $itemtype);
     //Add language file
     if ($params['add_injection_file']) {
         self::addLocales($name, $itemtype);
     }
     //Add file needed by datainjectin plugin
     if ($params['add_injection_file']) {
         self::addDatainjectionFile($name);
     }
     if ($params['create_default_profile']) {
         //Create rights for this new object
         PluginGenericobjectProfile::createAccess($_SESSION["glpiactiveprofile"]["id"], true);
         //Reload profiles
         PluginGenericobjectProfile::changeProfile();
     }
 }
示例#2
0
function plugin_genericobject_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/genericobject/inc/object.class.php";
    include_once GLPI_ROOT . "/plugins/genericobject/inc/type.class.php";
    $migration = new Migration('2.4.0');
    foreach (array('PluginGenericobjectField', 'PluginGenericobjectCommonDropdown', 'PluginGenericobjectCommonTreeDropdown', 'PluginGenericobjectProfile', 'PluginGenericobjectType', 'PluginGenericobjectTypeFamily') as $itemtype) {
        if ($plug = isPluginItemType($itemtype)) {
            $plugname = strtolower($plug['plugin']);
            $dir = GLPI_ROOT . "/plugins/{$plugname}/inc/";
            $item = strtolower($plug['class']);
            if (file_exists("{$dir}{$item}.class.php")) {
                include_once "{$dir}{$item}.class.php";
                if (method_exists($itemtype, 'install')) {
                    $itemtype::install($migration);
                }
            }
        }
    }
    if (!is_dir(GENERICOBJECT_CLASS_PATH)) {
        @mkdir(GENERICOBJECT_CLASS_PATH, 0777, true) or die("Can't create folder " . GENERICOBJECT_CLASS_PATH);
    }
    //Init plugin & types
    plugin_init_genericobject();
    //Init profiles
    PluginGenericobjectProfile::changeProfile();
    return true;
}
示例#3
0
function plugin_genericobject_install()
{
    global $DB;
    //check directories rights
    if (!check_directories()) {
        return false;
    }
    $migration = new Migration('2.1.0');
    foreach (array('PluginGenericobjectField', 'PluginGenericobjectType', 'PluginGenericobjectProfile', 'PluginGenericobjectTypeFamily') as $itemtype) {
        if ($plug = isPluginItemType($itemtype)) {
            $plugname = strtolower($plug['plugin']);
            $dir = GLPI_ROOT . "/plugins/{$plugname}/inc/";
            $item = strtolower($plug['class']);
            if (file_exists("{$dir}{$item}.class.php")) {
                include_once "{$dir}{$item}.class.php";
                $itemtype::install($migration);
            }
        }
    }
    if (!is_dir(GENERICOBJECT_CLASS_PATH)) {
        @mkdir(GENERICOBJECT_CLASS_PATH, 0777, true) or die("Can't create folder " . GENERICOBJECT_CLASS_PATH);
    }
    //Init plugin & types
    plugin_init_genericobject();
    //Init profiles
    PluginGenericobjectProfile::changeProfile();
    return true;
}
示例#4
0
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Genericobject. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
 @package   genericobject
 @author    the genericobject plugin team
 @copyright Copyright (c) 2010-2011 Order plugin team
 @license   GPLv2+
            http://www.gnu.org/licenses/gpl.txt
 @link      https://forge.indepnet.net/projects/genericobject
 @link      http://www.glpi-project.org/
 @since     2009
 ---------------------------------------------------------------------- */
include "../../../inc/includes.php";
Session::checkRight("profile", "r");
$prof = new PluginGenericobjectProfile();
/* save profile */
if (isset($_POST['update_user_profile'])) {
    $prof->saveProfileToDB($_POST);
    PluginGenericobjectProfile::changeProfile();
} elseif (isset($_POST['update_all_rights']) && isset($_POST['profiles'])) {
    foreach ($_POST['profiles'] as $id => $values) {
        $values['id'] = $id;
        $prof->update($values);
    }
    PluginGenericobjectProfile::changeProfile();
}
Html::redirect($_SERVER['HTTP_REFERER']);