00001 <?php 00006 include_once("core/system/JBaseObject.class.php"); 00007 include_once("core/db/dbjames.class.php"); 00008 include_once("core/system/JSystemError.class.php"); 00009 00013 class Module extends JBaseObject 00014 { 00015 00016 var $data; 00017 var $modinfo; 00018 var $idPerms; 00019 00020 00027 function Module ($idM) 00028 { 00029 $dbObj = new DBJames(); 00030 00031 $query = "SELECT * FROM Modules "; 00032 $query .= "WHERE idM = " . $idM; 00033 00034 $dbObj->Query($query); 00035 00036 if ($dbObj->numRows == 1) 00037 { 00038 $this->data = $dbObj->row; 00039 } 00040 else 00041 { 00042 $this->data = NULL; 00043 $this->RaiseConstructorError(new JSystemError(ERROR_MODULE_NOT_FOUND)); 00044 } 00045 } 00046 00051 function GetRelativePath() 00052 { 00053 $path = "/modules"; 00054 $path .= "/" . $this->GetName(); 00055 00056 return $path; 00057 } 00058 00063 function _GetInfoFilePath() 00064 { 00065 $jpath = JSystem::GetConfig("JamesDir"); 00066 00067 $fpath = $jpath . $this->GetRelativePath() . "/config.xml"; 00068 if (!file_exists($fpath)) 00069 $fpath = $jpath.$this->GetRelativePath()."/config.inc"; 00070 00071 return $fpath; 00072 } 00073 00074 00079 function &_GetPermissions() 00080 { 00081 if (! isset($this->idPerms)) 00082 { 00083 $dbObj = new DBJames(); 00084 00085 $query = " SELECT * FROM Permissions "; 00086 $query .= " WHERE idM = ". $this->GetId(); 00087 00088 $dbObj->Query($query); 00089 00090 $this->idPerms = array(); 00091 00092 while(! $dbObj->EOF) 00093 { 00094 $this->idPerms[$dbObj->row["name"]] = $dbObj->row["idP"]; 00095 $dbObj->Next(); 00096 } 00097 } 00098 return $this->idPerms; 00099 } 00100 00105 function GetId() 00106 { 00107 return $this->data["idM"]; 00108 } 00109 00114 function GetName() 00115 { 00116 return $this->data["name"]; 00117 } 00118 00125 function &GetInformation() 00126 { 00127 include_once("core/modules/moduleinformation/ModuleInfo.class.php"); 00128 00129 if (! isset($this->modinfo)) 00130 { 00131 $path = $this->_GetInfoFilePath(); 00132 $this->modinfo =& ModuleInfo::GetInformation( 00133 "file", $path); 00134 } 00135 00136 return $this->modinfo; 00137 } 00138 00139 00145 function GetPermissionId($name) 00146 { 00147 $perms =& $this->_GetPermissions(); 00148 return $perms[$name]; 00149 } 00150 00151 00157 function GetConfig($key) 00158 { 00159 $config = JConfig::GetInstance(CONFIG_MODULE_SCOPE, 00160 $this->GetId()); 00161 00162 return $config->GetValue($key); 00163 } 00164 00172 function SetConfig($keys, $user=true, $group=false) 00173 { 00174 $config =& JConfig::GetInstance(CONFIG_MODULE_SCOPE, 00175 $this->GetId()); 00176 return $config->SetValue($keys, $user, $group); 00177 } 00178 00183 function GetAllModulesId() 00184 { 00185 $dbObj = new DBJames(); 00186 $query = " SELECT * FROM Modules "; 00187 $dbObj->Query($query); 00188 00189 return $dbObj; 00190 } 00191 } 00192 00193 ?>