14 public $Version =
"1.0";
15 public $OnUserCreate = NULL;
16 public $OnUserUpdate = NULL;
17 public $OnUserDelete = NULL;
18 public $OnUserCustomDataOutput = NULL;
19 public $OnUserProcessOutput = NULL;
20 public $OnUserLogout = NULL;
23 private $Properties = array();
24 private $AdminMenu = array();
25 private $BlockedUpdateUserCustomData = array();
28 $this->Folder = $folder;
29 if (substr($this->Folder, -1) !=
"/") {
41 if (file_exists(ADDONS_FOLDER)) {
42 $handle = opendir(ADDONS_FOLDER);
44 while ($handle &&
false !== ($entry = readdir($handle))) {
46 if (!is_dir(ADDONS_FOLDER .
"/" . $entry)) {
50 if ($entry ==
"." || $entry ==
"..") {
54 $addon = self::LoadAddon(ADDONS_FOLDER .
"/" . $entry);
56 $addon->Id = count($addons) + 1;
68 private static function LoadAddon($folder) {
70 $addon_file = $folder .
"/addon.php";
71 $disabled_file = $folder .
"/.disabled";
72 if (file_exists($addon_file) && !file_exists($disabled_file)) {
75 $addon =
new self($folder);
77 include_once $addon_file;
79 }
catch (Exception $ex) {
81 AppLog::Error(
"Error trying to load add-on " . basename($folder) .
": " . $ex->getMessage());
95 foreach ($Addons as $addon) {
96 if ($addon->Name == $addonName)
107 return $this->Folder;
116 if (substr($fileRelativePath, 0, 1) ==
"/")
117 $fileRelativePath = substr($fileRelativePath, 1);
118 return $this->Folder . $fileRelativePath;
127 return URL_ROOT .
"admin/addon-load.php?addon=" . urlencode($this->Name) .
"&menu=" . $menu;
135 return $this->Name .
" " . $this->Version;
143 return $this->Properties;
152 if (array_key_exists($name, $this->Properties))
153 return $this->Properties[$name];
163 $this->Properties[$name] = $value;
172 if ($displayText && $url)
173 $this->AdminMenu[] = array(
"Display" => $displayText,
"Url" => $url );
181 return $this->AdminMenu;
189 if (!array_key_exists($dataKey, $this->BlockedUpdateUserCustomData))
190 $this->BlockedUpdateUserCustomData[] = $dataKey;
201 foreach ($Addons as $addon) {
202 if (in_array($dataKey, $addon->BlockedUpdateUserCustomData))
217 foreach ($Addons as $addon) {
218 if ($addon->OnUserCustomDataOutput)
219 eval ($addon->OnUserCustomDataOutput .
"(\$user, \$customData);");
232 foreach ($Addons as $addon) {
233 if ($addon->OnUserProcessOutput)
234 eval ($addon->OnUserProcessOutput .
"(\$userData);");
245 foreach ($Addons as $addon) {
246 if ($addon->OnUserCreate)
247 eval ($addon->OnUserCreate .
"(\$user);");
258 foreach ($Addons as $addon) {
259 if ($addon->OnUserUpdate)
260 eval ($addon->OnUserUpdate .
"(\$user);");
271 foreach ($Addons as $addon) {
272 if ($addon->OnUserDelete)
273 eval ($addon->OnUserDelete .
"(\$user);");
284 foreach ($Addons as $addon) {
285 if ($addon->OnUserLogout)
286 eval ($addon->OnUserLogout .
"(\$user);");
SetProperty($name, $value)
AddAdminMenu($displayText, $url)
static NotifyUserLogout($user)
static ProcessOutputUserCustomData($user, &$customData)
static IsBlockedUpdateUserCustomData($dataKey)
static NotifyUserUpdate($user)
BlockUpdateUserCustomData($dataKey)
static NotifyUserDelete($user)
static NotifyUserCreate($user)
GetFile($fileRelativePath)
static ProcessOutputUser(&$userData)
static GetAddon($addonName)