How to validate something before installing local plugin in moodle - moodle

I have developed a local plugin and before installation i want to check if a certain plugin i.e. mod_attendance exists in the moodle, if it exists i want to continue with the normal installation else if the mod_attendance doesn't exist i want to return a error message and exit installation. My local plugin works on top of the mod_attendace plugin so i want to check if this plugin exists or not.
I don't know which files to add or edit in my local plugin to add validations before installation.
Your help is appreciated.

In your plugin's version.php, just declare that mod_attendance is a dependency for your plugin, then Moodle will take care of preventing it being installed without it.
$plugin->dependencies = ['mod_attendance' => ANY_VERSION];
See https://docs.moodle.org/dev/version.php for more details.

Related

Upgrade is not working at all, installing another version of application (Wixsharp, custom Bootstrapper)

I'm new to wix/wixsharp and bootstrapper. I created an installer and providing ProductID, UpgradeCode and version. Installer is working fine but when I'm creating new installer and giving different version it is simply allowing user to install the another version of application and bot can be seen in program files.
If I use the same file that was used earlier to install, it gives option to uninstall as expected but when I use the upgraded file it does not give upgrade or repair option.
Can anybody help me with this. Here is the code I'm using
project.UpgradeCode = new Guid("9fa9fcf6-e807-404d-a67a-d66f1a60ca53");
project.ProductId = new Guid("0b2d7210-32ce-4095-9c46-aaccb1bf0733");
project.Version= new Version("1.0.209.10040");
project.MajorUpgrade = new MajorUpgrade
{
Schedule = UpgradeSchedule.afterInstallInitialize,
DowngradeErrorMessage = "A later version of [ProductName] is already installed. Setup will now exit."
};
In 2nd build I'm just changing Version("1.1.209.10040") keeping everything else same.
Please let me know if any other part of code is required as I'm really new I'm not sure I shared all the necessary information.
If you're trying to do a major upgrade you will need to change the ProductCode. Whenever you're building an upgrade you should refer to the Windows installer Upgrade page that MS publishes. I don't know if there is a specific one for WiX but the same concepts still apply.
This worked for me. I changed ProductId and then I am able to auto-upgrade my Product based on version# (first three parts).
project.ProductId = Guid.NewGuid();

Stuck on Plugins Check

I tried to install without realising an older plugin than what was already installed. It errored with the install however now I cant get past the check plugins screen to fix my issue.
Reload just reloads the page, update does nothing. If I click Upgrade I get this:
I cant do anything else. If I try to reload Moodle with just http://moodle (Internal URL) I get redirected straight back to this page. If I clear my cookies I get taken to the login page, but after logging in it is straight back to the "Plugins Check" page again.
Do you have administrative access to the server running Moodle?
You should be able to download the version of the plugin you need and unzip it directly into Moodle's directory structure, and then log back in to the Web UI.
In my moodle installation, this is here:
/var/www/html/moodle/course/format/singleactivity
You should be able to get the correct files from the installation package you used. Just make a backup of the existing folder in your Moodle environment, move it to a safe location, and drop the complete folder for the new version in its place. Then reload the web client.

Create upgrade setup using installshield 2010 primier

I want to create an upgrade setup. I have an old setup with for example version 1.0.1.43 and my new setup will has version of 1.0.1.45
I have created a new basic MSI project in installshield. I set version to 1.0.1.45 I copied both product code and upgrade code of old setup into upgrade setup. I also added all of new files in setup that should be replaced with files of old setup. I selected all files and then right clicked on them and in properties checked always overwrite option. then in Media section I added a major upgrade with upgrade code of my old setup. then I build the setup.
when I run this setup it shows me that you have installed this application do you want to upgrade it or not? then I choose yes to upgrade. after installing this setup I figured it out that in add/or remove programs version of my application has changed to 1.0.1.45, that means it has been upgraded. but when I check files I see that none of new files has been replaced with new one.
Where am I wrong that this setup ignore all of my new files to replace? I want this setup find old path of old setup and after removing all files, add new files to that path?
thanks
As you are saying, you have created new MSI installer for upgrade. So in this case the component ID of components in which your files are present, got change. So you need to set values of Component ID with the component IDs of your installer 1.0.1.45. Or you need to create different components with the same target path.
Also you can validate your upgrade build 1.0.1.46 with the main build 1.0.1.45 with following steps.
Build Menu -> Validate -> Upgrade Validation Wizard
Then give path of your main installer (msi/exe) and your upgrade installer (msi/exe). And check what differences both builds are having.

How to set plugin update status for custom plugins in wordpress?

I have created a custom plugin(version 1.0) which is already installed in the site.
Now, If i have developed its next version i.e. 1.1.
So, How can I display notification like 'There is a new version of custom-plugin available. View version 1.1 details or update now.', at plugin page in wordpress admin panel.
Would anyone please help me on this?
Thanks in advance !
First of all you have to upload your plugin to the https://wordpress.org/plugins/ using (SVN), You can read about
Subversion.
When you're ready to release a new version of the Plugin:
Make sure everything is committed and the new version actually works.
Pay attention to all WordPress versions your Plugin supports and try to test it with all of them. Don't just test the new features; also make sure you didn't accidentally break some older functionality of the Plugin.
Change the version number in the header comment of the main PHP file to the new version number (in the trunk folder).
Change the version number in the 'Stable tag' field of the readme.txt file (in the trunk folder).
Add a new sub-section in the 'changelog' section of the readme.txt file, briefly describing what changed compared to the last release. This will be listed on the 'Changelog' tab of the Plugin page.
Commit these changes.
Create a new SVN tag as a copy of trunk, following This Guide
Give the system a couple of minutes to work, and then check the wordpress.org Plugin page and a WordPress installation with your Plugin to see if everything updated correctly and the WordPress installation shows an update for your Plugin (the update checks might be cached, so this could take some time -- try visiting the 'available updates' page in your WordPress installation).
The other answer is only correct if you are a major shop. You do not have to use the wordpress repos for your plugins, in fact, if you're not a major shop, DON'T as it pollutes the ecosystem with unmaintained plugins as solos move on.
I use this to ensure that my plugin dependencies are met or show a warning using the update notice.
if ( !defined('MY_MAIN_PLUGIN_IS_ACTIVE') ) {
$file = basename( __FILE__ );
$folder = basename( dirname( __FILE__ ) );
$hook = "in_plugin_update_message-$folder/$file";
add_action( $hook,
function ( $plugin_data, $r ){
echo 'Must activate Main Plugin to use this plugin';
},
10,
2
);
return;
};

How to validate an upgrade before installation

We have an eclipse feature that is licensed and the license is handled by our own code. The user can go in on our update-site and upgrade his feature. The problem we face is when the user's license needs to be updated before he can use the new upgrade.
What I want to do is to validate the feature version against the users license and warn the user that his license needs to be updated before he install.
I thought I would do this using a custom eclipse p2 touchPoint action validateLicense.
Example:
My code is called, where I validate the version against the user's license. If it fails I warn the user and he can then cancel the installation.
So my first question is:
Do I get this right, or is it some other way to do this?
My second question is pretty basic:
Where do I tell eclipse to run my code?
I have looked here at eclipse help where they explain what it is. But I don't understand where to put the information to run my code? Is it in the feature.xml.
Lastly:
Is there an example how to create and use p2 touchPonts?
I implemented a custom action as shown here and I have a system that seems to work. I left out "touchpoint" extension as it's unnecessary in my case, but the rest is the same.
My action is executed during install phase of my feature (instructions.install) but maybe configure phase could work too. Collect phase did not work.
The action is executed during installation process, after the download was already performed. Ideally it would be before the download but it's not a big issue for me. Returning an error status from the action cancels the install. It leaves some downloaded files around but they do not get activated and are probably removed later by p2's garbage collector.
I also managed to do some more interesting things. My actions plugin has a dependency (optional and non-greedy) on my main plugin. So the install works like this:
Actions plugin is downloaded
Custom action is executed
The action detects whether my main plugin is already installed and if yes, it calls into it to retrieve licensing info. The main plugin has to expose an API for the action. The action also checks main plugin's version to detect whether the API is there or not.
The action now can decide whether to proceed or cancel the install. It can even interact with the user using Display#syncExec (this is what the code in checkTrust phase does so I think it's safe). If needed, the action could also detect whether the install is headless.
Some gotchas:
Action itself must be versioned. It's the version you declare in plugin.xml and p2.inf files and it's different from plugin's version. I just replace 1.0.0 with the same version my plugin has. This way the latest version of the action plugin is always downloaded before being executed. This is great because now any problem changes to licensing rules can be implemented in actions plugin.
Actions API changed between Eclipse 3.5 and 3.6. I will probably drop support for 3.5 as it's pretty old anyway.
Actions plugin should probably be signed. It's the case in my case. The system seems almost too powerful to me as just pointing Eclipse to an update site gets it to execute downloaded code.
I still need to test how this works with different versions of Eclipse and other IDEs. I saw a strange (non-blocking) error with 3.6. However the results are promising and it looks like the system might actually work.
Touchpoints are executed at installation time, which means that the resolution (validation) has already happened. I'm not sure they would help. What about creating an Installable Unit (IU) (or Eclipse Feature) that represents the license the user has installed. Then you would put a dependency from your product to that license.
For example, create an IU called com.mycompany.license (1.0.0). You would create another one called com.mycompany.license (2.0.0). When you installed a license, the appropriate IU would be added to the profile.
Now, when you go to install you product, the new version of the product would require license version 2.0.0. If this license was not installed, the resolution would fail.
Does this make sense? Do you think this would help?