noalyss  Version-6.7.2
Public Member Functions | Static Public Member Functions
Extension Class Reference

manage the extension, it involves the table extension More...

Inheritance diagram for Extension:
Menu_Ref_sql

Public Member Functions

 can_request ($p_login)
 return 1 if the user given in parameter can access this extension otherwise returns 0
 check_xml (SimpleXMLElement $xml)
 Check that the xml contains all the needed information to change them into a extension, the exception code is 0 if the element is optional.
 insert_plugin ()
 Insert a plugin into the given profile, by default always insert into EXT.
 insert_profile_menu ($p_id=1, $p_module='EXT')
 insert into the table profile_menu for the given profile id and depending of the module $p_module type $cn
 remove_from_profile_menu ($p_id)
 remove_plugin ()
 search ($p_what)
 search a extension, the what is the column (extends_code
 update_plugin ()
 verify ()

Static Public Member Functions

static check_plugin_version ()
static check_version ($i)
static clean (Database $p_cn)
 remove all the schema from the plugins
static make_array ($cn)
 make an array of the available plugin for the current user
static read_definition ($p_file)
 Parse a XML file to complete an array of extension objects.

Detailed Description

manage the extension, it involves the table extension

Data member

Definition at line 43 of file class_extension.php.


Member Function Documentation

Extension::can_request ( p_login)

return 1 if the user given in parameter can access this extension otherwise returns 0

Parameters:
$p_loginthe user login
Returns:
1 has access, 0 has no access

Definition at line 66 of file class_extension.php.

References cn.

    {
                $cnt=$this->cn->get_value("select count(*) from menu_ref
                                                                                join profile_menu using (me_code)
                                                                                join profile_user using (p_id)
                                                                                where
                                                                                me_code=$1
                                                                                and user_name=$2",
                                                                array($this->me_code,$p_login));
                if ( $cnt > 0)        return 1;
                return 0;
    }
static Extension::check_plugin_version ( ) [static]

Definition at line 210 of file class_extension.php.

References $g_user, and echo.

Referenced by check_version().

        {
            global $g_user,$version_plugin;
            if ($g_user->Admin() == 1)
            {
                if (SITE_UPDATE_PLUGIN != "")
                {
                    $update = @file_get_contents(SITE_UPDATE_PLUGIN);
                    if ($update > $version_plugin)
                    {
                        echo '<div class="inner_box" style="position:absolute;zindex:2;top:5px;left:360px">';
                        echo '<p class="notice">';
                        echo "Mise à jour disponible des plugins pour NOALYSS, version actuelle : $update votre version $version_plugin";
                        echo '</p>';
                        echo '</div>';
                    }
                }
            }
        }
static Extension::check_version ( i) [static]

Definition at line 91 of file class_extension.php.

References $version_noalyss, alert(), and check_plugin_version().

    {
        global $version_noalyss;
        if ( ! isset ($version_noalyss) || $version_noalyss < $i )
        {
            alert('Cette extension ne fonctionne pas sur cette version de NOALYSS'.
                  ' Veuillez mettre votre programme a jour. Version minimum '.$i);
            return;
        }
        Extension::check_plugin_version();
    }
Extension::check_xml ( SimpleXMLElement $  xml)

Check that the xml contains all the needed information to change them into a extension, the exception code is 0 if the element is optional.

Check XML.

Parameters:
SimpleXMLElement$xml
Exceptions:
Exception

Definition at line 236 of file class_extension.php.

References $ex, and $nb_plugin.

        {
            try {
                if ( !isset ($xml->plugin)) throw new Exception(_('Manque plugin'),1);
                $nb_plugin=count($xml->plugin);
            
                for ($i=0;$i<$nb_plugin;$i++)
                {
                    if ( !isset ($xml->plugin[$i]->name)) throw new Exception(_('Manque nom'),1);
                    if ( !isset ($xml->plugin[$i]->description)) throw new Exception(_('Manque description'),0);
                    if ( !isset ($xml->plugin[$i]->code)) throw new Exception(_('Manque code'),1);
                    if ( !isset ($xml->plugin[$i]->author)) throw new Exception(_('Manque auteur'),0);
                    if ( !isset ($xml->plugin[$i]->root)) throw new Exception(_('Manque répertoire racine'),1);
                    if ( !isset ($xml->plugin[$i]->file)) throw new Exception(_('Manque fichier à inclure'),1);
                }
            } catch (Exception $ex) {
                throw $ex;
            }
        }
static Extension::clean ( Database p_cn) [static]

remove all the schema from the plugins

Parameters:
Database$p_cn

Definition at line 201 of file class_extension.php.

References Database\exec_sql(), and Database\exist_schema().

        {
                $a_ext=array("tva_belge","amortissement","impdol","coprop","importbank");
                for($i=0;$i<count($a_ext);$i++){
                        if ($p_cn->exist_schema($a_ext[$i])) {
                                $p_cn->exec_sql("drop schema ".$a_ext[$i]." cascade");
                        }
                }
        }

Insert a plugin into the given profile, by default always insert into EXT.

Parameters:
type$p_idprofile.p_id
Exceptions:
Exceptionif duplicate or error db

Definition at line 149 of file class_extension.php.

References $count, alert(), cn, echo, and verify().

        {
                try
                {
                        $this->cn->start();
                        $this->verify();
                        // check if duplicate
                        $this->me_code = strtoupper($this->me_code);
                        $count = $this->cn->get_value("select count(*) from menu_ref where me_code=$1", array($this->me_code));
                        if ($count != 0)
                                throw new Exception("Doublon");
                        $this->me_type = 'PL';
                        $this->insert();
                        $this->cn->commit();
                }
                catch (Exception $exc)
                {
                        echo alert($exc->getMessage());
                }
        }
Extension::insert_profile_menu ( p_id = 1,
p_module = 'EXT' 
)

insert into the table profile_menu for the given profile id and depending of the module $p_module type $cn

Parameters:
type$p_idprofile.p_id
type$p_modulemenu_ref.me_code
Exceptions:
Exception10 : profile absent 20 module absent

Definition at line 110 of file class_extension.php.

References $cn, $module, and $profile.

    {
        global $cn;
        //profile exists ?
        $profile=new Profile_sql($cn,$p_id);
        if ( $profile->p_id != $p_id) {
                throw new Exception(_('Profil inexistant'),10);
        }
        // Menu exists
        $module=new Menu_Ref($cn,$p_module);
        if ($module->me_code==null) {
                throw new Exception(_('Module inexistant'),20);
        }
        
        $profil_menu=new Profile_Menu($cn);
        $profil_menu->me_code=$this->me_code;
        $profil_menu->me_code_dep=$p_module;
        $profil_menu->p_type_display='S';
        $profil_menu->p_id=$p_id;
        $cnt=$profil_menu->count(' where p_id=$1 and me_code = $2',array($p_id,$this->me_code));
        if ( $cnt==0) {
            $profil_menu->insert();
        }

        
    }
static Extension::make_array ( cn) [static]

make an array of the available plugin for the current user

Returns:
an array
See also:
ISelect

Definition at line 82 of file class_extension.php.

References $a, $cn, and $sql.

    {
        $sql="select DISTINCT me_code as value, me_menu as label from ".
             " menu_ref join profile_menu using (me_code)
                                 join profile_user using (p_id) where ".
             " user_name=$1 and me_type='PL' ORDER BY ME_MENU";
        $a=$cn->get_array($sql,array($_SESSION['g_user']));
        return $a;
    }
static Extension::read_definition ( p_file) [static]

Parse a XML file to complete an array of extension objects.

Create extension from XML.

Parameters:
type$p_filefilename
Returns:
array of Extension

Definition at line 261 of file class_extension.php.

References $cn, $e, $ex, $nb_plugin, $xml, echo_warning(), and trim().

        {
            global $cn;
            $dom=new DomDocument('1.0');
            $dom->load($p_file);
            $xml=simplexml_import_dom($dom);
            $nb_plugin=count($xml->plugin);
            $a_extension=array();
            for ($i=0;$i<$nb_plugin;$i++)
            {
                
                $extension=new Extension($cn);
                try {
                        $extension->check_xml($xml);
                } catch (Exception $ex) {
                    echo_warning($e->getMessage());
                    if ( $ex->getCode()==1) {
                        continue;
                    }
                    
                }
                $extension->me_file=trim($xml->plugin[$i]->root).'/'.trim($xml->plugin[$i]->file);
                $extension->me_code=trim($xml->plugin[$i]->code);
                $extension->me_description=(isset ($xml->plugin[$i]->description))?$xml->plugin[$i]->description:"";
                $extension->me_description_etendue=($xml->plugin[$i]->author)?$xml->plugin[$i]->author:"";
                $extension->me_type='PL';
                $extension->me_menu=$xml->plugin[$i]->name;
                $extension->me_parameter='plugin_code='.trim($xml->plugin[$i]->code);
                $a_extension[]=clone $extension;
            }
            return $a_extension;
        }

Definition at line 136 of file class_extension.php.

References $cn.

    {
        global $cn;
       
         $cn->exec_sql('delete from profile_menu  where (me_code = $1 or me_code in (select me_code from menu_ref where me_file=$2)) and p_id=$3',array($this->me_code,$this->me_file,$p_id));
        
    }

Definition at line 184 of file class_extension.php.

References alert(), cn, and echo.

        {
                try
                {
                        $this->cn->start();
                        $this->delete();
                        $this->cn->commit();
                }
                catch (Exception $exc)
                {
                        echo alert($exc->getMessage());
                }
        }
Extension::search ( p_what)

search a extension, the what is the column (extends_code

Definition at line 55 of file class_extension.php.

    {
                $this->me_code=strtoupper($p_what);
                if ( $this->load() == -1) return null;
                return 1;
    }

Definition at line 169 of file class_extension.php.

References alert(), cn, echo, and verify().

        {
                try
                {
                        $this->cn->start();
                        $this->verify();
                        $this->me_type = 'PL';
                        $this->update();
                        $this->cn->commit();
                }
                catch (Exception $exc)
                {
                        echo alert($exc->getMessage());
                }
        }

Definition at line 45 of file class_extension.php.

References trim().

Referenced by insert_plugin(), and update_plugin().

    {
        // Verify that the elt we want to add is correct
        if (trim($this->me_code)=="") throw new Exception('Le code ne peut pas être vide');
        if (trim($this->me_menu)=="") throw new Exception('Le nom ne peut pas être vide');
        if (trim($this->me_file)=="") throw new Exception('Chemin incorrect');
        if (file_exists('..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'ext'.DIRECTORY_SEPARATOR.$this->me_file) == false)
            throw new Exception ('Extension non trouvée, le chemin est-il correct?');
    }

The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations