merging 6.7.8 changes and bug fixes
This commit is contained in:
parent
4bd429bcac
commit
fdfb9bf5ae
8 changed files with 95 additions and 58 deletions
|
|
@ -13,6 +13,7 @@ package Hourly::ArchiveOldPosts;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Asset::Post;
|
||||
use WebGUI::Asset::Wobject::Collaboration;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
|
@ -20,15 +21,18 @@ use WebGUI::SQL;
|
|||
#-----------------------------------------
|
||||
sub process {
|
||||
my $epoch = WebGUI::DateTime::time();
|
||||
my $a = WebGUI::SQL->read("select asset.lineage,Collaboration.archiveAfter from Collaboration left join asset on Collaboration.assetId=asset.assetId");
|
||||
while (my ($lineage, $archiveAfter) = $a->array) {
|
||||
my $archiveDate = $epoch - $archiveAfter;
|
||||
my $sql = "select asset.assetId,asset.className, max(assetData.revisionDate) from Post left join asset on Post.assetId=asset.assetId
|
||||
left join assetData on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate
|
||||
where Post.dateUpdated<$archiveDate and assetData.status='approved' and asset.lineage like ".quote($lineage."%")." group by asset.assetId";
|
||||
my $a = WebGUI::SQL->read("select assetId from asset where className='WebGUI::Asset::Wobject::Collaboration'");
|
||||
while (my ($assetId) = $a->array) {
|
||||
my $cs = WebGUI::Asset::Wobject::Collaboration->new($assetId);
|
||||
my $archiveDate = $epoch - $cs->get("archiveAfter");
|
||||
my $sql = "select asset.assetId, assetData.revisionDate from Post left join asset on asset.assetId=Post.assetId
|
||||
left join assetData on Post.assetId=assetData.assetId and Post.revisionDate=assetData.revisionDate
|
||||
where Post.dateUpdated<$archiveDate and assetData.status='approved' and asset.state='published'
|
||||
and asset.lineage like ".quote($cs->get("lineage").'%');
|
||||
my $b = WebGUI::SQL->read($sql);
|
||||
while (my ($id, $class, $version) = $b->array) {
|
||||
WebGUI::Asset::Post->new($id,$class,$version)->setStatusArchived;
|
||||
while (my ($id, $version) = $b->array) {
|
||||
my $post = WebGUI::Asset::Post->new($id,undef,$version);
|
||||
$post->setStatusArchived if (defined $post && $post->get("dateUpdated") < $archiveDate);
|
||||
}
|
||||
$b->finish;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,14 @@ use strict;
|
|||
use WebGUI::Asset;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::DateTime;
|
||||
|
||||
#-----------------------------------------
|
||||
sub process {
|
||||
if ($session{config}{DeleteExpiredRevisions_offset} ne "") {
|
||||
my $hour = WebGUI::DateTime::epochToHuman(time(),"%H");
|
||||
my $dow = WebGUI::DateTime::epochToHuman(time(),"%W");
|
||||
return unless ($hour == 3 && $dow eq "Sun");
|
||||
my $expireDate = (time()-(86400*$session{config}{DeleteExpiredRevisions_offset}));
|
||||
my $sth = WebGUI::SQL->read("select assetData.assetId,asset.className,assetData.revisionDate from asset left join assetData on asset.assetId=assetData.assetId where assetData.revisionDate<".$expireDate." order by assetData.revisionDate asc");
|
||||
while (my ($id, $class, $version) = $sth->array) {
|
||||
|
|
|
|||
|
|
@ -1,41 +1,44 @@
|
|||
package Hourly::SyncProfilesToLDAP;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#------------------------------------------------------ -------------
|
||||
# WebGUI is Copyright 2001-2005 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
#------------------------------------------------------ -------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
#------------------------------------------------------ -------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------ -------------
|
||||
|
||||
use Net::LDAP;
|
||||
use strict;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Auth;
|
||||
use WebGUI::User;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#------------------------------------------------------ -------------
|
||||
sub _alias {
|
||||
my %alias = (
|
||||
firstName=>"givenname",
|
||||
lastName=>"sn",
|
||||
email=>"mail",
|
||||
companyName=>"o"
|
||||
);
|
||||
firstName=>"givenname",
|
||||
lastName=>"sn",
|
||||
email=>"mail",
|
||||
companyName=>"o"
|
||||
);
|
||||
return $alias{$_[0]} || $_[0];
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#------------------------------------------------------ -------------
|
||||
sub process {
|
||||
my (@date, $userId, $u, $userData, $uri, $port, %args, $fieldName, $ldap, $search, $a, $b);
|
||||
@date = WebGUI::DateTime::localtime(WebGUI::DateTime::time());
|
||||
if ($date[3] == $session{config}{SyncProfilesToLDAP_hour}) {
|
||||
if ($date[3] == $session{config}{SyncProfilesToLDAP_hour}) {
|
||||
$a = WebGUI::SQL->read("select userId from users where authMethod='LDAP'");
|
||||
while (($userId) = $a->array) {
|
||||
$u = WebGUI::User->new($userId);
|
||||
$userData = WebGUI::Authentication::getParams($userId, 'LDAP');
|
||||
my $auth = WebGUI::Auth->new("LDAP",$userId);
|
||||
$userData = $auth->getParams;
|
||||
$uri = URI->new($userData->{ldapUrl});
|
||||
if ($uri->port < 1) {
|
||||
$port = 389;
|
||||
|
|
@ -48,15 +51,11 @@ sub process {
|
|||
$ldap->bind;
|
||||
$search = $ldap->search (base => $uri->dn, filter => $userData->{connectDN});
|
||||
if (defined $search->entry(0)) {
|
||||
my $user = WebGUI::User->new($userId);
|
||||
$b = WebGUI::SQL->read("select fieldName from userProfileField where profileCategoryId<>4");
|
||||
while (($fieldName) = $b->array) {
|
||||
if ($search->entry(0)->get_value(_alias($fieldName)) ne "") {
|
||||
WebGUI::SQL->write("replace into userProfileData
|
||||
(userId,fieldName,fieldData) values ("
|
||||
.$userId.","
|
||||
.quote($fieldName).","
|
||||
.quote($search->entry(0)->get_value(_alias($fieldName)))
|
||||
.")");
|
||||
$user->profileField($fieldName,$search->entry(0)->get_value(_alias($fieldName)));
|
||||
}
|
||||
}
|
||||
$b->finish;
|
||||
|
|
@ -71,4 +70,3 @@ sub process {
|
|||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,9 @@ sub checkModule {
|
|||
unless (defined $afterinstall) { $afterinstall = 0; }
|
||||
printTest("Checking for module $module");
|
||||
my $statement = "require ".$module.";";
|
||||
if (eval($statement)) {
|
||||
if ($afterinstall == 1) {
|
||||
failAndExit("Install of $module failed!");
|
||||
} elsif (eval($statement)) {
|
||||
$statement = '$'.$module."::VERSION";
|
||||
my $currentVersion = eval($statement);
|
||||
if ($currentVersion >= $version) {
|
||||
|
|
@ -179,8 +181,6 @@ sub checkModule {
|
|||
failAndExit("Aborting test, not all modules available, and you're not root so I can't install them.");
|
||||
}
|
||||
}
|
||||
} elsif ($afterinstall == 1) {
|
||||
failAndExit("Install of $module failed!");
|
||||
} else {
|
||||
printResult("Not Installed");
|
||||
return if $skipInstall;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue