Userbase-programmers
Threads by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
April 2011
- 2 participants
- 41 discussions
29 Apr '11
Author: cwalker
Date: 2011-04-29 13:21:40 -0500 (Fri, 29 Apr 2011)
New Revision: 76
Modified:
core/db/clsDB_mysql.php
domains/ci/domain_init.php
modules/identity/identity.php
modules/identity/identityaddress.php
modules/mysql/resource.php
Log:
The ResourceAccount action handler needed to match the class name, which it wasn't, so the event_script autoform wouldn't populate events
Also fixed the infinate recursion issue with the identityaddress edit and add methods
Modified: core/db/clsDB_mysql.php
===================================================================
--- core/db/clsDB_mysql.php 2011-04-29 17:15:48 UTC (rev 75)
+++ core/db/clsDB_mysql.php 2011-04-29 18:21:40 UTC (rev 76)
@@ -250,13 +250,13 @@
}
$log_text = "";
- if(strlen($error_str)==0 && $num_rows==0)
+ if(strlen($error_str)==0 && $num_rows>0)
{
$objDBLog->Log("[{$this->dbname}]($num_rows) $sql",KLogger::DEBUG);
}
elseif(strlen($error_str)==0 && $num_rows==0)
{
- $objDBLog->Log("EMPTY:[{$this->dbname}] $sql",KLogger::INFO);
+ $objDBLog->Log("[{$this->dbname}]($num_rows) $sql",KLogger::INFO);
}
if(strlen($error_str)>0)
{
Modified: domains/ci/domain_init.php
===================================================================
--- domains/ci/domain_init.php 2011-04-29 17:15:48 UTC (rev 75)
+++ domains/ci/domain_init.php 2011-04-29 18:21:40 UTC (rev 76)
@@ -46,6 +46,6 @@
$objActionHandler->AddHandler("ci_affiliation", new CI_clsAffiliationActions());
$objActionHandler->AddHandler("ci_identityaffiliation", new CI_clsIdentityAffiliationActions());
$objActionHandler->AddHandler("ci_account", new CI_clsAccountActions());
- $objActionHandler->AddHandler("ci_resacct", new CI_clsResourceAccountActions());
+ $objActionHandler->AddHandler("ci_resourceaccount", new CI_clsResourceAccountActions());
$objActionHandler->AddHandler("ci_accountresourcecredential", new CI_clsAccountResourceCredentialActions());
clsDDLManager::ValidateTables();
\ No newline at end of file
Modified: modules/identity/identity.php
===================================================================
--- modules/identity/identity.php 2011-04-29 17:15:48 UTC (rev 75)
+++ modules/identity/identity.php 2011-04-29 18:21:40 UTC (rev 76)
@@ -898,10 +898,11 @@
$api = getApiObject("identityaddress");
if($AddressId)
{
- $a = $api->edit($data);
+ $a = $api->edit($this->get("id"), $data);
}
else
- $a = $api->add($data);
+ $a = $api->add($this->get("id"), $data);
+ return $a;
}
else
{
Modified: modules/identity/identityaddress.php
===================================================================
--- modules/identity/identityaddress.php 2011-04-29 17:15:48 UTC (rev 75)
+++ modules/identity/identityaddress.php 2011-04-29 18:21:40 UTC (rev 76)
@@ -137,8 +137,8 @@
{
if(count($data)>0)
{
- $objIdentityActions = $objIdentityActions = getApiObject("identity"); // new clsIdentityActions();
- return $objIdentityActions->address($IdentityId,$data);
+ $data["identity_id"] = $IdentityId;
+ return parent::add($data);
}
}
return false;
Modified: modules/mysql/resource.php
===================================================================
--- modules/mysql/resource.php 2011-04-29 17:15:48 UTC (rev 75)
+++ modules/mysql/resource.php 2011-04-29 18:21:40 UTC (rev 76)
@@ -11,7 +11,6 @@
abstract public function Credentials($ListType="all");
abstract public function ResourceGroups();
abstract public function RemoveFromResourceGroup($r);
- abstract public function HandleRequestUpdate($objRequest);
abstract public function IsCredentialAccepted($objCredential);
function __construct($id=null)
1
0
29 Apr '11
Author: cwalker
Date: 2011-04-29 12:15:48 -0500 (Fri, 29 Apr 2011)
New Revision: 75
Modified:
core/loader.php
domains/ci/account_resource_credential.php
domains/ci/bin/ci_import.php
domains/ci/resource.php
domains/ci/resource_account.php
modules/core/clsUserbaseActionHandler.php
modules/mysql/account.php
modules/mysql/account_resource_credential.php
modules/mysql/resource.php
modules/mysql/resource_account.php
Log:
added activate and disable api methods to the AccountResource object. These events are the primary events to work with the outside world as far as resource assignment goes.
Also added code in the base edit() method to check for a state field, and if it exists, see if it changed.. If it did change, the method will fire off the appropriate API event
CI import also now uses the title attribute to determine if the account is perm, annual or student. If the title attribute exists, the account is set to perm, otherwise annual. (Student has not been used yet)
Modified: core/loader.php
===================================================================
--- core/loader.php 2011-04-28 22:21:25 UTC (rev 74)
+++ core/loader.php 2011-04-29 17:15:48 UTC (rev 75)
@@ -101,7 +101,7 @@
include_once("db/clsCategoryItems.php");
//include_once("clsMixedItemCollection.php");
include_once("clsCategoryBase.php");
-
+ include_once("ssh2.php");
include_once("sessions.php");
$objSession = new clsSession();
$objSession->ClearExpired();
Modified: domains/ci/account_resource_credential.php
===================================================================
--- domains/ci/account_resource_credential.php 2011-04-28 22:21:25 UTC (rev 74)
+++ domains/ci/account_resource_credential.php 2011-04-29 17:15:48 UTC (rev 75)
@@ -113,13 +113,13 @@
}
}
-class CI_clsAccountResourceCredentialActions extends clsUserbaseMysqlActionHandler
+class CI_clsAccountResourceCredentialActions extends MySQL_clsAccountResourceCredentialActions
{
function __construct()
{
parent::__construct("CI_clsAccountResourceCredentialList","CI_AccountResourceCredential","Account Credential","Account Credentials");
}
-
+
public function remove_credential($ItemId=null)
{
$objItem = false;
@@ -140,6 +140,8 @@
return false;
}
+
+
}
?>
\ No newline at end of file
Modified: domains/ci/bin/ci_import.php
===================================================================
--- domains/ci/bin/ci_import.php 2011-04-28 22:21:25 UTC (rev 74)
+++ domains/ci/bin/ci_import.php 2011-04-29 17:15:48 UTC (rev 75)
@@ -224,6 +224,14 @@
$acct["state"] = "active";
$acct["shell"] = $shell;
}
+ $ldap_title = $objLdap->GetResultAttribute($rec,"title");
+ if(strlen($ldap_title)>0)
+ {
+ $acct["account_type"] = 'perm';
+ }
+ else
+ $acct['account_type'] = 'annual';
+
$objAccount = $objIdentityAPI->account($objIdentity->get("id"),null,$acct);
if($objOptions->GetValue("default_passwords"))
{
Modified: domains/ci/resource.php
===================================================================
--- domains/ci/resource.php 2011-04-28 22:21:25 UTC (rev 74)
+++ domains/ci/resource.php 2011-04-29 17:15:48 UTC (rev 75)
@@ -299,28 +299,7 @@
$this->commit();
}
- public function HandleRequestUpdate($objRequest)
- {
- switch($objRequest->get("state"))
- {
- case 'denied':
- $this->set("state","denied");
- break;
- case 'deleted':
- $this->set("state","deleted");
- break;
- case "approved":
- if($objRequest->get("foreign_state")=='approved' || $objRequest->get("foreign_state")=='none')
- {
- $this->Activate();
- $this->AddToIdentity($objRequest->get("identity_id"));
- }
- break;
- case "expired":
- $this->Expire();
- break;
- }
- }
+
}
Modified: domains/ci/resource_account.php
===================================================================
--- domains/ci/resource_account.php 2011-04-28 22:21:25 UTC (rev 74)
+++ domains/ci/resource_account.php 2011-04-29 17:15:48 UTC (rev 75)
@@ -75,6 +75,11 @@
$this->UpdateState('inactive');
}
+ public function Disable()
+ {
+ $this->UpdateState('inactive');
+ }
+
public function GetDefaultText()
{
return $this->NamedRelationObject("Account")->GetDefaultText()." : ".$this->NamedRelationObject("Resource")->GetDefaultText();
Modified: modules/core/clsUserbaseActionHandler.php
===================================================================
--- modules/core/clsUserbaseActionHandler.php 2011-04-28 22:21:25 UTC (rev 74)
+++ modules/core/clsUserbaseActionHandler.php 2011-04-29 17:15:48 UTC (rev 75)
@@ -100,6 +100,33 @@
);
}
+ public function edit($ItemId=null,$data=null)
+ {
+ $item = new $this->ItemClassName();
+ if(pageHasContext())
+ $item->SetContext(GetArrayValue($_GET,"Context",""),GetArrayValue($_GET,"ContextValue",0));
+ $item->fetch($ItemId);
+ $ret = parent::edit($ItemId,$data);
+ if(GetArrayValue($data,"state","") != $item->get("state"))
+ {
+ switch($data["state"])
+ {
+ case "active":
+ $this->MyAPI()->activate($item);
+ break;
+ case "inactive":
+ $this->MyAPI()->disable($item);
+ break;
+ case "expire":
+ $this->MyAPI()->expire($item);
+ break;
+ case "denied":
+ $this->MyAPI()->deny($item);
+ break;
+ }
+ }
+ }
+
protected function MyAPI()
{
global $objActionHandler;
Modified: modules/mysql/account.php
===================================================================
--- modules/mysql/account.php 2011-04-28 22:21:25 UTC (rev 74)
+++ modules/mysql/account.php 2011-04-29 17:15:48 UTC (rev 75)
@@ -14,6 +14,7 @@
abstract public function fetchByUsername($username);
abstract public function RequestAccept();
abstract public function Activate();
+ abstract public function Deactivate();
abstract public function Deny();
public function __construct($id=null)
@@ -191,7 +192,7 @@
class MySQL_clsAccountActions extends clsUserbaseMysqlActionHandler implements iAccountAPI
{
-
+
public function activate($account)
{
if(!is_object($account))
@@ -222,6 +223,21 @@
}
}
+ public function disable($account)
+ {
+ if(!is_object($account))
+ {
+ $objAccount = getDomainObject("Account",$account);
+ }
+ else
+ $objAccount = $account;
+
+ if(is_object($objAccount))
+ {
+ $objAccount->Deactivate();
+ }
+ }
+
public function expire($account)
{
if(!is_object($account))
Modified: modules/mysql/account_resource_credential.php
===================================================================
--- modules/mysql/account_resource_credential.php 2011-04-28 22:21:25 UTC (rev 74)
+++ modules/mysql/account_resource_credential.php 2011-04-29 17:15:48 UTC (rev 75)
@@ -90,5 +90,33 @@
}
+class MySQL_clsAccountResourceCredentialActions extends clsUserbaseMysqlActionHandler
+{
+ function __construct()
+ {
+ parent::__construct("CI_clsAccountResourceCredentialList","CI_AccountResourceCredential","Account Credential","Account Credentials");
+ }
+ public function remove_credential($ItemId=null)
+ {
+ $objItem = false;
+ if(is_numeric($ItemId))
+ {
+ $objItem = getDomainObject("AccountResourceCredential");
+ }
+ elseif(is_object($ItemId))
+ {
+ $objItem = $ItemId;
+ }
+ if(is_object($objItem))
+ {
+ $objItem->delete();
+ return $objItem;
+ }
+
+ return false;
+ }
+
+}
+
?>
\ No newline at end of file
Modified: modules/mysql/resource.php
===================================================================
--- modules/mysql/resource.php 2011-04-28 22:21:25 UTC (rev 74)
+++ modules/mysql/resource.php 2011-04-29 17:15:48 UTC (rev 75)
@@ -273,6 +273,7 @@
$grp = getDomainObject("ResourceGroup",$GroupId);
$grp->AddResource($r);
}
+
return $r;
}
}
@@ -290,7 +291,8 @@
{
$data = $this->getFormData($this->ItemClassName);
}
- return parent::edit($ResourceId,$data);
+ $ret = parent::edit($ResourceId,$data);
+ return $ret;
}
public function credential_assign($account=null,$resource=null,$arrIdentityCredentials=null)
@@ -618,6 +620,28 @@
return $res;
}
+
+ public function HandleRequestUpdate($obj,$objRequest)
+ {
+ switch($objRequest->get("state"))
+ {
+ case 'denied':
+ $this->set("state","denied");
+ break;
+ case 'deleted':
+ $this->set("state","deleted");
+ break;
+ case "approved":
+ if($objRequest->get("foreign_state")=='approved' || $objRequest->get("foreign_state")=='none')
+ {
+ $this->MyAPI()->activate($obj);
+ }
+ break;
+ case "expired":
+ $this->Expire();
+ break;
+ }
+ }
}
?>
\ No newline at end of file
Modified: modules/mysql/resource_account.php
===================================================================
--- modules/mysql/resource_account.php 2011-04-28 22:21:25 UTC (rev 74)
+++ modules/mysql/resource_account.php 2011-04-29 17:15:48 UTC (rev 75)
@@ -44,4 +44,105 @@
class MySQL_clsResourceAccountActions extends clsUserbaseMysqlActionHandler
{
+ public function activate($item=null)
+ {
+ if(is_object($item))
+ {
+ $objItem = $item;
+ }
+ elseif(is_numeric($item))
+ {
+ $objItem = getDomainObject("ResourceAccount",$item);
+ }
+ else
+ {
+ $item = getItemId();
+ if($item)
+ $objItem = getDomainObject("ResourceAccount",$item);
+ }
+ $objItem->Activate();
+ return $objItem;
+ }
+
+ public function disable($item=null)
+ {
+ if(is_object($item))
+ {
+ $objItem = $item;
+ }
+ elseif(is_numeric($item))
+ {
+ $objItem = getDomainObject("ResourceAccount",$item);
+ }
+ else
+ {
+ $item = getItemId();
+ if($item)
+ $objItem = getDomainObject("ResourceAccount",$item);
+ }
+ $objItem->Activate();
+ return $objItem;
+ }
+
+ public function deny($item=null)
+ {
+ if(is_object($item))
+ {
+ $objItem = $item;
+ }
+ elseif(is_numeric($item))
+ {
+ $objItem = getDomainObject("ResourceAccount",$item);
+ }
+ else
+ {
+ $item = getItemId();
+ if($item)
+ $objItem = getDomainObject("ResourceAccount",$item);
+ }
+ $objItem->Deny();
+ return $objItem;
+ }
+
+ public function expire($item=null)
+ {
+ if(is_object($item))
+ {
+ $objItem = $item;
+ }
+ elseif(is_numeric($item))
+ {
+ $objItem = getDomainObject("ResourceAccount",$item);
+ }
+ else
+ {
+ $item = getItemId();
+ if($item)
+ $objItem = getDomainObject("ResourceAccount",$item);
+ }
+ $objItem->Expire();
+ return $objItem;
+ }
+
+ public function HandleRequestUpdate($obj,$objRequest)
+ {
+ switch($objRequest->get("state"))
+ {
+ case 'denied':
+ $this->MyAPI()->deny($obj);
+ break;
+ case 'deleted':
+ $this->MyAPI()->delete($obj);
+ break;
+ case "approved":
+ if($objRequest->get("foreign_state")=='approved' || $objRequest->get("foreign_state")=='none')
+ {
+ $this->MyAPI()->activate($obj);
+ }
+ break;
+ case "expired":
+ $this->expire($obj);
+ break;
+ }
+ }
}
\ No newline at end of file
1
0
28 Apr '11
Author: cwalker
Date: 2011-04-28 17:21:25 -0500 (Thu, 28 Apr 2011)
New Revision: 74
Added:
domains/ci/bin/ldap_remove_attribute.php
domains/ci/bin/ldap_update_attribute.php
Modified:
domains/ci/account.php
domains/ci/bin/add_to_netgroup.php
domains/ci/bin/remove_from_netgroup.php
domains/ci/resource.php
modules/core/clsEventManager.php
modules/core/event_script.php
modules/identity/identity.php
Log:
Added support for remote scripts, added generic scripts to update ldap attributes, updated the netgroup scripts
Modified: domains/ci/account.php
===================================================================
--- domains/ci/account.php 2011-04-28 20:06:25 UTC (rev 73)
+++ domains/ci/account.php 2011-04-28 22:21:25 UTC (rev 74)
@@ -20,15 +20,14 @@
'label'=>array('datatype'=>VARCHAR,'datasize'=>255,'label'=>"Account Label",'section'=>"Account Information",'display_order'=>1),
'shell'=>array('datatype'=>ENUM,'datasize'=>array('/bin/bash','/bin/csh','/bin/tcsh','/bin/zsh'),'label'=>"Shell",'section'=>"Account Information",'display_order'=>3),
'state'=>array('datatype'=>ENUM,'datasize'=>array('requested','denied','active','suspended','inactive','deleted'),'label'=>"State",'section'=>"Account Information",'display_order'=>3),
+ 'account_type'=>array('datatype'=>ENUM,'datasize'=>array('perm','annual','student'),'label'=>"Account Type",'section'=>"Account Information",'display_order'=>4),
'updated'=>array('datatype'=>BOOL,'datasize'=>array('No','Yes'),'label'=>"Updated"),
'uid'=>array('datatype'=>INTEGER,'datasize'=>4,'label'=>"uid",'section'=>"Unix Account Information",'display_order'=>4),
'home_dir'=>array('datatype'=>VARCHAR,'datasize'=>64,'label'=>"Home Directory",'section'=>"Account Information",'display_order'=>10),
'default_group_id'=>array('datatype'=>INTEGER,'datasize'=>4,'label'=>"Default GID",'section'=>"Unix Account Information",'display_order'=>5),
- 'sambaSID'=>array('datatype'=>VARCHAR,'datasize'=>255)
-
+ 'sambaSID'=>array('datatype'=>VARCHAR,'datasize'=>255)
);
-
-
+
$this->Relations = array (
new clsRelation("CI_ResourceAccount","id","account_id","ResourceAccount","clsResourceAccountList"),
new clsRelation("CI_ResourceGroup","id","id","ResourceGroup","clsResourceGroupList","account_resourcegroup","account_id","resourcegroup_id"),
Modified: domains/ci/bin/add_to_netgroup.php
===================================================================
--- domains/ci/bin/add_to_netgroup.php 2011-04-28 20:06:25 UTC (rev 73)
+++ domains/ci/bin/add_to_netgroup.php 2011-04-28 22:21:25 UTC (rev 74)
@@ -60,11 +60,6 @@
if(strlen($domain)==0)
die('No Domain Provided');
-if(strlen($netgroup)==0)
-{
- exit(0);
-}
-
$objDomain = new clsDomainBase();
$objDomain->fetchByName($domain);
@@ -116,47 +111,68 @@
$objAccount = getDomainObject("Account");
$objAccount->fetchByUsername($account_username);
-echo "Adding Account {$objAccount->GetDefaultText()} to netgroup $netgroup\n";
+if(!$objAccount->IsActive())
+{
+ echo "Account {$objAccount->GetDefaultText()} not active";
+ exit(0);
+}
-echo "Searching for cn=$netgroup,ou=netgroups,$ldap_basedn\n";
-$result = $objLdap->GetDN("cn=$netgroup,ou=netgroups,".$ldap_basedn);
-if(!$result)
+if(strlen($netgroup))
{
- $data=array();
- $data['objectClass']='nisNetgroup';
- //$data['objectClass']='top';
- //$data['cn']=$netgroup;
- $data['nisNetgroupTriple']=",$account_username,";
-
- $objLdap->AddDN("cn=$netgroup,ou=netgroups,$ldap_basedn",$data);
+ $netgroups = array($netgroup);
}
else
{
- print_r($result);
- $members = GetArrayValue($result,"nisNetgroupTriple",array());
- if(!is_array($members))
- $members = array($members);
- $bMatched = false;
- foreach($members as $m)
+ $objResourceList = $objAccount->Resources("active");
+ if($objResourceList->NumItems()>0)
{
- $ma = explode(",",$m);
- $um = @$ma[1];
- if($um==$account_username)
- {
- $bMatched=true;
- }
+ foreach($objResourceList->Items as $r)
+ {
+ if(strlen($r->get("ldap_netgroup"))>0)
+ {
+ $netgroups[] = $r->get("ldap_netgroup");
+ }
+ }
}
- if(!$bMatched)
+}
+
+foreach($netgroups as $netgroup)
+{
+ $result = $objLdap->GetDN("cn=$netgroup,ou=netgroups,".$ldap_basedn);
+ if(!$result)
{
- if(count($members)==0)
+ $data=array();
+ $data['objectClass']='nisNetgroup';
+ $data['nisNetgroupTriple']=",$account_username,";
+
+ $objLdap->AddDN("cn=$netgroup,ou=netgroups,$ldap_basedn",$data);
+ }
+ else
+ {
+ $members = GetArrayValue($result,"nisNetgroupTriple",array());
+ if(!is_array($members))
+ $members = array($members);
+ $bMatched = false;
+ foreach($members as $m)
{
- $objLdap->AddAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>",$account_username,"));
+ $ma = explode(",",$m);
+ $um = @$ma[1];
+ if($um==$account_username)
+ {
+ $bMatched=true;
+ }
}
- else
+ if(!$bMatched)
{
- $members[]=",$account_username,";
- $objLdap->ReplaceAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>$members));
-
+ if(count($members)==0)
+ {
+ $objLdap->AddAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>",$account_username,"));
+ }
+ else
+ {
+ $members[]=",$account_username,";
+ $objLdap->ReplaceAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>$members));
+ }
}
- }
-}
+ }
+}
\ No newline at end of file
Added: domains/ci/bin/ldap_remove_attribute.php
===================================================================
--- domains/ci/bin/ldap_remove_attribute.php (rev 0)
+++ domains/ci/bin/ldap_remove_attribute.php 2011-04-28 22:21:25 UTC (rev 74)
@@ -0,0 +1,148 @@
+#!/usr/bin/php -q
+<?php
+
+$f = "/etc/userbase2.conf";
+
+if(file_exists($f))
+{
+ $Config = parse_ini_file($f);
+}
+
+$pathtoroot = $Config['pathtoroot'];
+/* define STDIN in case we need it for user input */
+
+if(!defined("STDIN")) {
+define("STDIN", fopen('php://stdin','r'));
+}
+
+require_once($pathtoroot."bin/include/core_options.php");
+
+/* add script specific options */
+$objOptions->AddOption("ldap_host","H","ldaphost",true,false,"LDAP Hostname","LDAP");
+$objOptions->AddOption("ldap_authdn","a","ldapauth",true,false,"LDAP Auth DN","LDAP");
+$objOptions->AddOption("ldap_basedn","B","ldapbase",true,false,"LDAP Base DN","LDAP");
+$objOptions->AddOption("ldap_uidfield","U","ldapuid",true,false,"LDAP uid field name","LDAP");
+$objOptions->AddOption("ldap_bind_user","","ldapuser",true,false,"LDAP Bind User","LDAP");
+$objOptions->AddOption("ldap_bind_pass","","ldappass",true,true,"LDAP Bind Password","LDAP");
+
+$objOptions->AddOption("attribute","","attribute",true,true,"Attribute Name");
+$objOptions->AddOption("value","","value",true,true,"Attribute Value");
+
+/*read command line options */
+$objOptions->ParseOptions();
+
+/* bootstrap the platform */
+include_once($pathtoroot."bin/include/cli_loader.php");
+
+$username = $objOptions->GetValue("username");
+
+/* default to the shell user, if set */
+if(!strlen($username))
+{
+ $username = GetArrayValue($_SERVER,"user","");
+ if(strlen($username))
+ {
+ $objOptions->SetValue("username",$username);
+ }
+}
+$domain = $objOptions->GetValue("domain");
+$objOptions->GetInteractiveValues($domain);
+
+$username = $objOptions->GetValue("username");
+$password = $objOptions->GetValue("password");
+$ldap_host = $objOptions->GetValue("ldap_host");
+$ldap_authdn = $objOptions->GetValue("ldap_authdn");
+$ldap_basedn = $objOptions->GetValue("ldap_basedn");
+$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
+$attrbute = $objOptions->GetValue("attribute","");
+$value = $objOptions->GetValue("value","");
+
+if(strlen($domain)==0)
+{
+ echo "Domain not provided";
+ exit(1);
+}
+
+if(strlen($attribute)==0)
+{
+ echo "Attribute not provided";
+ exit(1);
+}
+
+$objDomain = new clsDomainBase();
+$objDomain->fetchByName($domain);
+
+$objUserAccount = null;
+$objCurrentUser = null;
+
+if($objDomain->get("id")>0)
+{
+ $objDomain->setAsCurrent();
+ $objUserAccount = getDomainObject("Account");
+ $objUserAccount->fetchByUsername($username);
+ if($objDomain->AuthenticateUser($objUserAccount,$password))
+ {
+ $objCurrentUser = setCurrentAccountUser($objUserAccount);
+ }
+ else
+ $objCurrentUser = false;
+}
+
+if(!is_object($objCurrentUser))
+{
+ $u = new clsUser();
+ $u->fetchByValue(array("username"=>$username,"domain_id",0));
+ if($u->get("id")>0)
+ {
+ $objSession->SetUser($u->get("id"));
+ $objCurrentUser = $u;
+ }
+}
+
+if(strlen($ldap_host)==0)
+{
+ $ldap_host = $objDomain->GetLDAPServer();
+}
+
+$objIdentityList = new clsIdentityList();
+$objIdentityAPI = getApiObject("identity"); //new clsIdentityActions();
+
+$objLdap = new clsLdapServer($ldap_host,"",$ldap_authdn);
+$objLdap->uid_field = $uidfield;
+
+
+if(!$objLdap->Authenticate($objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
+{
+ echo "Unable to bind {$ldap_authdn} to ldap server $ldap_host\n";
+ exit(1);
+}
+
+function filter_members($var)
+{
+ global $value;
+ return ($var != $value);
+}
+
+
+$result = $objLdap->GetDN($ldap_basedn);
+if($result)
+{
+ $members = GetArrayValue($result,$attribute,array());
+ if(!is_array($members))
+ $members = array($members);
+ $bMatched = false;
+ if(!strlen($value))
+ {
+ $m = array();
+ }
+ else
+ $m = array_values(array_filter($members,"filter_members"));
+ if(count($m)>0)
+ {
+ $objLdap->ReplaceAttribute($ldap_basedn,array($attribute=>$m));
+ }
+ else
+ {
+ $objLdap->DeleteAttribute($ldap_basedn,array($attribute=>array()));
+ }
+}
Added: domains/ci/bin/ldap_update_attribute.php
===================================================================
--- domains/ci/bin/ldap_update_attribute.php (rev 0)
+++ domains/ci/bin/ldap_update_attribute.php 2011-04-28 22:21:25 UTC (rev 74)
@@ -0,0 +1,157 @@
+#!/usr/bin/php -q
+<?php
+
+$f = "/etc/userbase2.conf";
+
+if(file_exists($f))
+{
+ $Config = parse_ini_file($f);
+}
+
+$pathtoroot = $Config['pathtoroot'];
+/* define STDIN in case we need it for user input */
+
+if(!defined("STDIN")) {
+define("STDIN", fopen('php://stdin','r'));
+}
+
+require_once($pathtoroot."bin/include/core_options.php");
+
+/* add script specific options */
+$objOptions->AddOption("ldap_host","H","ldaphost",true,false,"LDAP Hostname","LDAP");
+$objOptions->AddOption("ldap_authdn","a","ldapauth",true,false,"LDAP Auth DN","LDAP");
+$objOptions->AddOption("ldap_basedn","B","ldapbase",true,false,"LDAP Base DN","LDAP");
+$objOptions->AddOption("ldap_uidfield","U","ldapuid",true,false,"LDAP uid field name","LDAP");
+$objOptions->AddOption("ldap_bind_user","","ldapuser",true,false,"LDAP Bind User","LDAP");
+$objOptions->AddOption("ldap_bind_pass","","ldappass",true,true,"LDAP Bind Password","LDAP");
+
+$objOptions->AddOption("attribute","","attribute",true,true,"Attribute Name");
+$objOptions->AddOption("value","","value",true,true,"Attribute Value");
+
+/*read command line options */
+$objOptions->ParseOptions();
+
+/* bootstrap the platform */
+include_once($pathtoroot."bin/include/cli_loader.php");
+
+$username = $objOptions->GetValue("username");
+
+/* default to the shell user, if set */
+if(!strlen($username))
+{
+ $username = GetArrayValue($_SERVER,"user","");
+ if(strlen($username))
+ {
+ $objOptions->SetValue("username",$username);
+ }
+}
+$domain = $objOptions->GetValue("domain");
+$objOptions->GetInteractiveValues($domain);
+
+$username = $objOptions->GetValue("username");
+$password = $objOptions->GetValue("password");
+$ldap_host = $objOptions->GetValue("ldap_host");
+$ldap_authdn = $objOptions->GetValue("ldap_authdn");
+$ldap_basedn = $objOptions->GetValue("ldap_basedn");
+$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
+$attrbute = $objOptions->GetValue("attribute","");
+$value = $objOptions->GetValue("value","");
+
+if(strlen($domain)==0)
+{
+ echo "Domain not provided";
+ exit(1);
+}
+
+if(strlen($attribute)==0)
+{
+ echo "Attribute not provided";
+ exit(1);
+}
+
+$objDomain = new clsDomainBase();
+$objDomain->fetchByName($domain);
+
+$objUserAccount = null;
+$objCurrentUser = null;
+
+if($objDomain->get("id")>0)
+{
+ $objDomain->setAsCurrent();
+ $objUserAccount = getDomainObject("Account");
+ $objUserAccount->fetchByUsername($username);
+ if($objDomain->AuthenticateUser($objUserAccount,$password))
+ {
+ $objCurrentUser = setCurrentAccountUser($objUserAccount);
+ }
+ else
+ $objCurrentUser = false;
+}
+
+if(!is_object($objCurrentUser))
+{
+ $u = new clsUser();
+ $u->fetchByValue(array("username"=>$username,"domain_id",0));
+ if($u->get("id")>0)
+ {
+ $objSession->SetUser($u->get("id"));
+ $objCurrentUser = $u;
+ }
+}
+
+if(strlen($ldap_host)==0)
+{
+ $ldap_host = $objDomain->GetLDAPServer();
+}
+
+$objIdentityList = new clsIdentityList();
+$objIdentityAPI = getApiObject("identity"); //new clsIdentityActions();
+
+$objLdap = new clsLdapServer($ldap_host,"",$ldap_authdn);
+$objLdap->uid_field = $uidfield;
+
+
+if(!$objLdap->Authenticate($objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
+{
+ echo "Unable to bind {$ldap_authdn} to ldap server $ldap_host\n";
+ exit(1);
+}
+
+$objAccount = getDomainObject("Account");
+$objAccount->fetchByUsername($account_username);
+
+
+$result = $objLdap->GetDN($ldap_basedn);
+if(!$result)
+{
+ echo "Unable to find $ldap_basedn";
+ exit(1);
+}
+else
+{
+ $members = GetArrayValue($result,$attribute,array());
+ if(!is_array($members))
+ $members = array($members);
+ $bMatched = false;
+ foreach($members as $m)
+ {
+ $ma = explode(",",$m);
+ $um = @$ma[1];
+ if($um==$value)
+ {
+ $bMatched=true;
+ }
+ }
+ if(!$bMatched)
+ {
+ if(count($members)==0)
+ {
+ $objLdap->AddAttribute($ldap_basedn,array($attrbute=>$value));
+ }
+ else
+ {
+ $members[]=$value;
+ $objLdap->ReplaceAttribute($ldap_basedn,array($attribute=>$members));
+ }
+ }
+}
\ No newline at end of file
Modified: domains/ci/bin/remove_from_netgroup.php
===================================================================
--- domains/ci/bin/remove_from_netgroup.php 2011-04-28 20:06:25 UTC (rev 73)
+++ domains/ci/bin/remove_from_netgroup.php 2011-04-28 22:21:25 UTC (rev 74)
@@ -60,11 +60,6 @@
$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
$account_username = $objOptions->GetValue("account",0);
$netgroup = $objOptions->GetValue("netgroup","");
-
-if(strlen($netgroup)==0)
-{
- exit(0);
-}
$objDomain = new clsDomainBase();
$objDomain->fetchByName($domain);
@@ -75,7 +70,6 @@
if($objDomain->get("id")>0)
{
$objDomain->setAsCurrent();
- echo $objDomain->get("name")." Set As Current Domain\n";
$objUserAccount = getDomainObject("Account");
$objUserAccount->fetchByUsername($username);
if($objDomain->AuthenticateUser($objUserAccount,$password))
@@ -117,31 +111,49 @@
$objAccount = getDomainObject("Account");
$objAccount->fetchByUsername($account_username);
-echo "Removing Account {$objAccount->GetDefaultText()} from netgroup $netgroup\n";
+if(strlen($netgroup))
+{
+ $netgroups = array($netgroup);
+}
+else
+{
+ $objResourceList = $objAccount->Resources("active");
+ if($objResourceList->NumItems()>0)
+ {
+ foreach($objResourceList->Items as $r)
+ {
+ if(strlen($r->get("ldap_netgroup"))>0)
+ {
+ $netgroups[] = $r->get("ldap_netgroup");
+ }
+ }
+ }
+}
-echo "Searching for cn=$netgroup,ou=netgroups,$ldap_basedn\n";
-
function filter_members($var)
{
global $account_username;
return ($var != ",$account_username,");
}
-$result = $objLdap->GetDN("cn=$netgroup,ou=netgroups,".$ldap_basedn);
-if($result)
+foreach($netgroups as $netgroup)
{
- $members = GetArrayValue($result,"nisNetgroupTriple",array());
- if(!is_array($members))
- $members = array($members);
- $bMatched = false;
- $val = ",$account_username,";
- $m = array_values(array_filter($members,"filter_members"));
- if(count($m)>0)
+ $result = $objLdap->GetDN("cn=$netgroup,ou=netgroups,".$ldap_basedn);
+ if($result)
{
- $objLdap->ReplaceAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>$m));
- }
- else
- {
- $objLdap->DeleteAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>array()));
+ $members = GetArrayValue($result,"nisNetgroupTriple",array());
+ if(!is_array($members))
+ $members = array($members);
+ $bMatched = false;
+ $val = ",$account_username,";
+ $m = array_values(array_filter($members,"filter_members"));
+ if(count($m)>0)
+ {
+ $objLdap->ReplaceAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>$m));
+ }
+ else
+ {
+ $objLdap->DeleteAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>array()));
+ }
}
-}
+}
Modified: domains/ci/resource.php
===================================================================
--- domains/ci/resource.php 2011-04-28 20:06:25 UTC (rev 73)
+++ domains/ci/resource.php 2011-04-28 22:21:25 UTC (rev 74)
@@ -13,6 +13,8 @@
'name'=>array('datatype'=>VARCHAR,'datasize'=>64,'label'=>"Name",'section'=>"General",'display_order'=>1),
'url'=>array('datatype'=>VARCHAR,'datasize'=>255,'label'=>"URL",'section'=>"General",'display_order'=>2),
'ldap_netgroup'=>array('datatype'=>VARCHAR,'datasize'=>255,'label'=>"LDAP Netgroup",'section'=>"General",'display_order'=>2),
+ 'mailing_list'=>array('datatype'=>VARCHAR,'datasize'=>255,'label'=>"Mailing List Name",'section'=>"General",'display_order'=>3),
+
'public'=>array('datatype'=>BOOL,'datasize'=>array('No','Yes'),'label'=>"Public",'section'=>"General",'display_order'=>3),
'requires_accounts'=>array('datatype'=>BOOL,'datasize'=>array('No','Yes'),'label'=>"Requires User Accounts",'section'=>"General",'display_order'=>3),
'accepts_domain_pw'=>array('datatype'=>BOOL,'datasize'=>array('No','Yes'),'label'=>"Accepts Domain Password",'section'=>"General",'display_order'=>3),
Modified: modules/core/clsEventManager.php
===================================================================
--- modules/core/clsEventManager.php 2011-04-28 20:06:25 UTC (rev 73)
+++ modules/core/clsEventManager.php 2011-04-28 22:21:25 UTC (rev 74)
@@ -111,7 +111,28 @@
private function RunRemote($args)
{
+ $start_time = libDateTime::dbdate_timestamp(time());
+ $objScript = $this->NamedRelationObject("EventScript");
+ $remote_host = $objScript->get("script_host");
+ $remote_user = $objScript->get("script_user");
+ $pubkey = $objScript->get("script_pubkey");
+ $privkey = $objScript->get("script_privatekey");
+ $ssh = new SSH2($remote_host);
+ if($ssh->isConnected())
+ {
+ if($ssh->loginWithKey($remote_iser,$remote_user, $pubkey, $privkey))
+ {
+ $cmd = escapeshellcmd($this->get("executable")." ".$args);
+ $output = $ssh->execCommandBlocking($cmd, true, null, array(), true);
+ $end_time = libDateTime::dbdate_timestamp(time());
+
+ $return_val = 0;
+ $this->StoreScriptRun($cmd, $start_time,$end_time,$output,$return_val);
+ return $return_val;
+ }
+ }
+ return false;
}
private function RunLocal($args)
@@ -120,7 +141,7 @@
$cmd = escapeshellcmd($this->get("executable")." ".$args);
$result = array();
$return_val = null;
- echo $cmd."\n";
+ //echo $cmd."\n";
exec($cmd,$result,$return_val);
$end_time = libDateTime::dbdate_timestamp(time());
$this->StoreScriptRun($cmd, $start_time,$end_time,implode("\n",$result),$return_val);
Modified: modules/core/event_script.php
===================================================================
--- modules/core/event_script.php 2011-04-28 20:06:25 UTC (rev 73)
+++ modules/core/event_script.php 2011-04-28 22:21:25 UTC (rev 74)
@@ -19,8 +19,11 @@
'event_name'=>array('datatype'=>VARCHAR,'datasize'=>255,'label'=>"Event Name",'section'=>"General",'display_order'=>2),
'description'=>array('datatype'=>TEXT,'datasize'=>0,'label'=>"Description",'section'=>"General",'display_order'=>7),
- 'script_host'=>array('datatype'=>VARCHAR,'datasize'=>64,'label'=>"Host",'section'=>"General",'display_order'=>3),
- 'script_user'=>array('datatype'=>VARCHAR,'datasize'=>10,'label'=>"Script User",'section'=>"General",'display_order'=>4),
+ 'script_host'=>array('datatype'=>VARCHAR,'datasize'=>64,'label'=>"Host",'section'=>"Remote Execution",'display_order'=>3),
+ 'script_user'=>array('datatype'=>VARCHAR,'datasize'=>10,'label'=>"Script User",'section'=>"Remote Execution",'display_order'=>4),
+ 'script_pubkey'=>array('datatype'=>TEXT,'datasize'=>0,'label'=>"Public Key File",'section'=>"Remote Execution",'display_order'=>5),
+ 'script_privatekey'=>array('datatype'=>TEXT,'datasize'=>0,'label'=>"Private Key File",'section'=>"Remote Execution",'display_order'=>6),
+
'script_path'=>array('datatype'=>TEXT,'datasize'=>0,'label'=>"Full Path",'section'=>"General",'display_order'=>5),
'script_arguments'=>array('datatype'=>TEXT,'datasize'=>0,'label'=>"Script Arguments",'section'=>"General",'display_order'=>6),
'failure_notify'=>array('datatype'=>VARCHAR,'datasize'=>64,'label'=>"Notify on Failure",'section'=>"General",'display_order'=>10),
Modified: modules/identity/identity.php
===================================================================
--- modules/identity/identity.php 2011-04-28 20:06:25 UTC (rev 73)
+++ modules/identity/identity.php 2011-04-28 22:21:25 UTC (rev 74)
@@ -596,6 +596,26 @@
}
}
+ protected function _email_list($attribs,$extra_attribs)
+ {
+ $ret = array();
+ $emails = $this->EmailAddrsses();
+ foreach($emails as $e)
+ {
+ $ret[] = $e->get("email");
+ }
+ return implode(GetArrayValue($attribs,"_separator"," "),$ret);
+ }
+
+ protected function _primary_email($attribs,$extra_attribs)
+ {
+ $ret ="";
+ $e = $this->GetPrimaryEmail();
+ if(is_object($e))
+ $ret = $this->get("email");
+ return $ret;
+ }
+
protected function _status_link($attribs,$extra_attribs)
{
$ret = "";
@@ -875,17 +895,13 @@
{
if(count($data)>0)
{
- $ac = $this->NamedRelationClassName("Address");
- $a = new $ac($AddressId);
- $a->fillFromArray($data);
- $a->set("identity_id",$this->get("id"));
- $a->commit();
- if($a->get("id")>0)
- {
- return $a;
- }
- else
- return false;
+ $api = getApiObject("identityaddress");
+ if($AddressId)
+ {
+ $a = $api->edit($data);
+ }
+ else
+ $a = $api->add($data);
}
else
{
@@ -920,7 +936,7 @@
$api = getApiObject("account");
if(!$AccountId)
{
- $a=$api->add($data);
+ $a = $api->add($data);
}
else
{
@@ -1468,7 +1484,7 @@
}
if(is_object($objAccount))
{
- $api = getDomainObject("clsAccountActions");
+ $api = getApiObject("Account"); // getDomainObject("clsAccountActions");
if($objAccount->IsIdentity($IdentityId))
{
foreach($arrCredentials as $cred_id)
1
0
Author: cwalker
Date: 2011-04-28 15:06:25 -0500 (Thu, 28 Apr 2011)
New Revision: 73
Modified:
domains/ci/bin/add_to_netgroup.php
domains/ci/bin/ldap_update_user.php
domains/ci/bin/remove_from_netgroup.php
Log:
domain config support
Modified: domains/ci/bin/add_to_netgroup.php
===================================================================
--- domains/ci/bin/add_to_netgroup.php 2011-04-28 16:08:02 UTC (rev 72)
+++ domains/ci/bin/add_to_netgroup.php 2011-04-28 20:06:25 UTC (rev 73)
@@ -45,12 +45,11 @@
$objOptions->SetValue("username",$username);
}
}
+$domain = $objOptions->GetValue("domain");
+$objOptions->GetInteractiveValues($domain);
-$objOptions->GetInteractiveValues();
-
$username = $objOptions->GetValue("username");
$password = $objOptions->GetValue("password");
-$domain = $objOptions->GetValue("domain");
$ldap_host = $objOptions->GetValue("ldap_host");
$ldap_authdn = $objOptions->GetValue("ldap_authdn");
$ldap_basedn = $objOptions->GetValue("ldap_basedn");
@@ -62,8 +61,10 @@
die('No Domain Provided');
if(strlen($netgroup)==0)
- die("Netgroup not provided");
-
+{
+ exit(0);
+}
+
$objDomain = new clsDomainBase();
$objDomain->fetchByName($domain);
Modified: domains/ci/bin/ldap_update_user.php
===================================================================
--- domains/ci/bin/ldap_update_user.php 2011-04-28 16:08:02 UTC (rev 72)
+++ domains/ci/bin/ldap_update_user.php 2011-04-28 20:06:25 UTC (rev 73)
@@ -24,10 +24,6 @@
/*read command line options */
$objOptions->ParseOptions();
-/*DEBUG*/
-$objOptions->SetValue("ldap_bind_user","admin");
-$objOptions->SetValue("ldap_bind_pass","secret");
-
/* bootstrap the platform */
include_once($pathtoroot."bin/include/cli_loader.php");
@@ -48,11 +44,20 @@
}
}
-$objOptions->GetInteractiveValues();
+$domain = "CI";
+$objDomain = new clsDomainBase();
+$objDomain->fetchByName($domain);
+if($objDomain->get("id")>0)
+{
+ $objDomain->setAsCurrent();
+ getCurrentDomain();
+}
+
+$objOptions->GetInteractiveValues($domain);
+
$username = $objOptions->GetValue("username");
$password = $objOptions->GetValue("password");
-$domain = $objOptions->GetValue("domain");
$ldap_host = $objOptions->GetValue("ldap_host");
$ldap_base = $objOptions->GetValue("ldap_basedn");
$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
@@ -62,17 +67,12 @@
if(strlen($domain)==0)
die('No Domain Provided');
-
-$objDomain = new clsDomainBase();
-$objDomain->fetchByName($domain);
-
$objUserAccount = null;
$objCurrentUser = null;
if($objDomain->get("id")>0)
{
- $objDomain->setAsCurrent();
- echo $objDomain->get("name")." Set As Current Domain\n";
+ //echo $objDomain->get("name")." Set As Current Domain\n";
$objUserAccount = getDomainObject("Account");
$objUserAccount->fetchByUsername($username);
if($objDomain->AuthenticateUser($objUserAccount,$password))
@@ -129,7 +129,7 @@
$objAccountList->AddObject($o);
}
-echo "Updating Idenity {$objIdentity->GetDefaultText()}\n";
+//echo "Updating Idenity {$objIdentity->GetDefaultText()}\n";
foreach($objAccountList->Items as $objAccount)
{
@@ -215,7 +215,7 @@
{
$dn = "uid={$objAccount->get("username")},".$objDomain->GetInactiveUserDN();
}
- echo "Editing/Creating LDAP Entry $dn\n";
+// echo "Editing/Creating LDAP Entry $dn\n";
$ldif = array();
foreach($rec as $attr=>$value)
@@ -229,9 +229,6 @@
$ldif[$attr] = $value;
}
}
- echo "-------------------------\n";
- $r = $objLdap->EditDN($dn,$ldif);
- echo "-------------------------\n";
if($r)
{
exit(0);
Modified: domains/ci/bin/remove_from_netgroup.php
===================================================================
--- domains/ci/bin/remove_from_netgroup.php 2011-04-28 16:08:02 UTC (rev 72)
+++ domains/ci/bin/remove_from_netgroup.php 2011-04-28 20:06:25 UTC (rev 73)
@@ -46,11 +46,14 @@
}
}
-$objOptions->GetInteractiveValues();
+$domain = $objOptions->GetValue("domain");
+if(strlen($domain)==0)
+ die('No Domain Provided');
+$objOptions->GetInteractiveValues($domain);
+
$username = $objOptions->GetValue("username");
$password = $objOptions->GetValue("password");
-$domain = $objOptions->GetValue("domain");
$ldap_host = $objOptions->GetValue("ldap_host");
$ldap_authdn = $objOptions->GetValue("ldap_authdn");
$ldap_basedn = $objOptions->GetValue("ldap_basedn");
@@ -58,11 +61,10 @@
$account_username = $objOptions->GetValue("account",0);
$netgroup = $objOptions->GetValue("netgroup","");
-if(strlen($domain)==0)
- die('No Domain Provided');
-
if(strlen($netgroup)==0)
- die("Netgroup not provided");
+{
+ exit(0);
+}
$objDomain = new clsDomainBase();
$objDomain->fetchByName($domain);
1
0
r72 - core domains/ci modules/autoform modules/autoform/delegates modules/core modules/identity modules/mysql www www/css www/js/events www/tpl/admin/item www/tpl/wizards/account_credential
by cwalker@mcs.anl.gov 28 Apr '11
by cwalker@mcs.anl.gov 28 Apr '11
28 Apr '11
Author: cwalker
Date: 2011-04-28 11:08:02 -0500 (Thu, 28 Apr 2011)
New Revision: 72
Added:
www/next_uid.php
Modified:
core/clsActionHandler.php
domains/ci/account.php
domains/ci/account_resource_credential.php
domains/ci/resource.php
domains/ci/resource_account.php
modules/autoform/clsFieldParser.php
modules/autoform/delegates/item_autoform.php
modules/core/clsFieldDisplay.php
modules/core/clsUsedUID.php
modules/core/clsUserbaseActionHandler.php
modules/core/event_script.php
modules/identity/identity.php
modules/identity/identityphone.php
modules/mysql/account.php
modules/mysql/account_resource_credential.php
modules/mysql/resource.php
www/css/autoform_fields.css
www/js/events/dialog_boxes.js
www/tpl/admin/item/field_item.tpl
www/tpl/wizards/account_credential/select_credential.tpl
Log:
Refactored much of the account and resource API to allow better granularity of event handling. This involved create a "MyAPI" method in clsUserBaseActionHandler which returns an API wrapper object for the current action handler class. This ensures that when an API method invokes another API method in the same object, all events fire as normal.
Much of the account and resource API now stacks calls, which should allow for smaller, more general purpose (and as such more easily maintained) scripts.
Also added a feature to the FieldDisplay object which allows for a link to be placed next to the field allowing for an ajax helper call. Clicking this link will fire off the ajax call and put whatever is returned in the field. This was implemented for things like the "get available UID" feature, which is now on the account dialog.
Modified: core/clsActionHandler.php
===================================================================
--- core/clsActionHandler.php 2011-04-27 19:47:06 UTC (rev 71)
+++ core/clsActionHandler.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -34,15 +34,39 @@
function GetObjectHandler($obj)
{
+ if(is_object($obj))
+ {
+ $class_name = $obj->className;
+ }
+ else
+ $class_name = $obj;
foreach($this->Handlers as $prefix=>$handler)
{
- if($obj->className == $handler->ItemClassName)
+ if($class_name == $handler->ItemClassName)
{
return $handler;
}
}
return false;
}
+
+ function GetObjectHandlerPrefix($obj)
+ {
+ if(is_object($obj))
+ {
+ $class_name = $obj->className;
+ }
+ else
+ $class_name = $obj;
+ foreach($this->Handlers as $prefix=>$handler)
+ {
+ if($class_name == $handler->ItemClassName)
+ {
+ return $prefix;
+ }
+ }
+ return false;
+ }
}
abstract class clsItemActionHandler
Modified: domains/ci/account.php
===================================================================
--- domains/ci/account.php 2011-04-27 19:47:06 UTC (rev 71)
+++ domains/ci/account.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -68,9 +68,9 @@
protected function SetUID()
{
$objUIDs = new clsUsedUIDList();
- $next_id = $objUIDs->getNextUID();
+ $next_id = $objUIDs->getNextUID($this->get("username"),$this->get("identity_id"),getCurrentDomainId());
$this->set("uid",$next_id);
- $objUIDs->StoreUID($next_id,getCurrentDomainId());
+ $objUIDs->StoreUID($next_id,$this->get("username"),$this->get("identity_id"),getCurrentDomainId());
}
protected function SetSambaUID()
@@ -242,7 +242,7 @@
if(!is_object(GetArrayValue($this->available_res_credentials,$ResourceId,null)))
{
$arc = $d->getDomainObjectList("AccountResourceCredential");
- $arc->LoadAccountResourceCrdentials($this->get("id"),$ResourceId);
+ $arc->LoadAccountResourceCredentials($this->get("id"),$ResourceId);
$res = $d->getDomainObject("Resource",$ResourceId);
//$ResourceCredentials = $res->Credentials();
Modified: domains/ci/account_resource_credential.php
===================================================================
--- domains/ci/account_resource_credential.php 2011-04-27 19:47:06 UTC (rev 71)
+++ domains/ci/account_resource_credential.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -37,7 +37,7 @@
$this->SearchFields["admin"] = array();
}
- public function LoadAccountResourceCrdentials($AccountId,$ResourceId)
+ public function LoadAccountResourceCredentials($AccountId,$ResourceId)
{
$sql = "select * FROM {$this->table} WHERE account_id=$AccountId AND resource_id=$ResourceId";
return $this->fetchBySelect($sql);
@@ -51,13 +51,13 @@
}
else
$resource_id = $Resource;
- if(is_object($Acct))
+ if(is_object($Account))
{
- $account_id = $Acct->get("id");
+ $account_id = $Account->get("id");
}
else
- $account_id = $Acct;
- if($this->LoadAccountResourceCredentials($AccountId,$ResourceId)>0)
+ $account_id = $Account;
+ if($this->LoadAccountResourceCredentials($account_id,$resource_id)>0)
{
foreach($this->Items as $i)
{
@@ -120,6 +120,25 @@
parent::__construct("CI_clsAccountResourceCredentialList","CI_AccountResourceCredential","Account Credential","Account Credentials");
}
+ public function remove_credential($ItemId=null)
+ {
+ $objItem = false;
+ if(is_numeric($ItemId))
+ {
+ $objItem = getDomainObject("AccountResourceCredential");
+ }
+ elseif(is_object($ItemId))
+ {
+ $objItem = $ItemId;
+ }
+ if(is_object($objItem))
+ {
+ $objItem->delete();
+ return $objItem;
+ }
+
+ return false;
+ }
}
Modified: domains/ci/resource.php
===================================================================
--- domains/ci/resource.php 2011-04-27 19:47:06 UTC (rev 71)
+++ domains/ci/resource.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -64,6 +64,18 @@
return $this->get("name");
}
+ public function delete()
+ {
+ if($this->get("state"=="requested"))
+ {
+ return parent::delete();
+ }
+ else
+ {
+ $this->set("state","deleted");
+ $this->commit();
+ }
+ }
public function RemoveFromResourceGroup($r)
{
@@ -78,17 +90,6 @@
public function RemoveFromIdentity($IdentityId)
{
- $account_list = $this->Accounts("all",$IdentityId);
- if(is_object($account_list))
- {
- if($account_list->NumItems()>0)
- {
- foreach($account_list->Items as $a)
- {
- $this->RemoveAccount($a);
- }
- }
- }
$sql = "delete from identity_resource where resource_id={$this->get("id")} and identity_id=$IdentityId";
$this->doSQL($sql);
}
@@ -137,27 +138,15 @@
public function RemoveAccountCredentials($acct,$IdentityCredential)
{
- global $objDomains;
- $d = $objDomains->getCurrentDomain();
-
-
- if($IdentityCredential=="all")
- {
- $lst = $d->GetDomainListObject("AccountResourceCredential");
- $lst->RemoveResourceAccountCredentials($this,$acct);
- }
- else
- {
- $aic = $d->GetDomainObject("AccountResourceCredential");
+ $aic = getDomainObject("AccountResourceCredential");
$aic->fetchCredential($this,$acct,$IdentityCredential);
$aic->delete();
- }
+
+ return $aic;
}
public function RemoveAccount($a)
- {
- global $objDomains;
- $d = $objDomains->getCurrentDomain();
+ {
if(is_object($a))
{
$account_id = $a->get("id");
@@ -165,19 +154,16 @@
else
{
$account_id = $a;
- $a = $d->GetDomainObject("Account",$account_id);
+ $a = getDomainObject("Account",$account_id);
}
- $acctres = $d->GetDomainObject("ResourceAccount");
+ $acctres = getDomainObject("ResourceAccount");
$acctres->fetchResourceAccount($this->get("id"),$account_id);
- $acctres->set("state","deleted");
- $acctres->commit();
- $this->RemoveAccountCredentials($a,"all");
+ $acctres->delete();
+ return $acctres;
}
public function ActivateAccount($a)
{
- global $objDomains;
- $d = $objDomains->getCurrentDomain();
if(is_object($a))
{
$account_id = $a->get("id");
@@ -185,9 +171,9 @@
else
{
$account_id = $a;
- $a = $d->GetDomainObject("Account",$account_id);
+ $a = getDomainObject("Account",$account_id);
}
- $acctres = $d->GetDomainObject("ResourceAccount");
+ $acctres = getDomainObject("ResourceAccount");
$acctres->fetchResourceAccount($this->get("id"),$account_id);
$ar->SetResourceAccount($this->get("id"),$a->get("id"),'active');
$acctres->commit();
@@ -195,8 +181,6 @@
public function DeactivateAccount($a)
{
- global $objDomains;
- $d = $objDomains->getCurrentDomain();
if(is_object($a))
{
$account_id = $a->get("id");
@@ -204,9 +188,9 @@
else
{
$account_id = $a;
- $a = $d->GetDomainObject("Account",$account_id);
+ $a = getDomainObject("Account",$account_id);
}
- $acctres = $d->GetDomainObject("ResourceAccount");
+ $acctres = getDomainObject("ResourceAccount");
$acctres->fetchResourceAccount($this->get("id"),$account_id);
$ar->SetResourceAccount($this->get("id"),$a->get("id"),'inactive');
$acctres->commit();
@@ -219,10 +203,7 @@
public function CompatibleAccounts($ListType="",$IdentityId="")
{
- global $objDomains;
- $d = $objDomains->getCurrentDomain();
-
- $lst = $d->getDomainObjectList("Account");
+ $lst = getDomainObjectList("Account");
if(is_object($lst))
{
$id = (int)$IdentityId;
Modified: domains/ci/resource_account.php
===================================================================
--- domains/ci/resource_account.php 2011-04-27 19:47:06 UTC (rev 71)
+++ domains/ci/resource_account.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -33,6 +33,12 @@
}
+ public function delete()
+ {
+ $this->set("state","deleted");
+ $this->commit();
+ }
+
public function fetchResourceAccount($ResourceId,$AccountId)
{
$this->fetchByValue(array("account_id"=>$AccountId,"resource_id"=>$ResourceId));
Modified: modules/autoform/clsFieldParser.php
===================================================================
--- modules/autoform/clsFieldParser.php 2011-04-27 19:47:06 UTC (rev 71)
+++ modules/autoform/clsFieldParser.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -6,8 +6,9 @@
private $objectName;
private $DisplayOptions;
private $tpl_type;
+ private $object;
- function __construct($objField,$rel=null,$objectName="")
+ function __construct($objField,$rel=null,$objectName="",$object=null)
{
$this->className="clsFieldParser";
$this->tagPrefix = "field";
@@ -42,7 +43,13 @@
$this->set("display_order",$objField->display_order);
$this->field=$objField;
$this->rel = $rel;
- $this->objectName = $objectName;
+ if(!is_null($object))
+ {
+ $this->object = $object;
+ $this->objectName = $object->className;
+ }
+ else
+ $this->objectName = $objectName;
$this->DisplayOptions = null;
$this->tpl_type="front";
}
@@ -131,7 +138,38 @@
$ret = GetArrayValue($attributes,"_emptytext","");
return $ret;
}
+
+ protected function _ajax_widget_url($attributes,$exttra_attribs="")
+ {
+ $ret = "";
+ $d = $this->GetDisplayOptions();
+ if(strlen($d->get("ajax_widget_url")))
+ {
+ $parser = $d->get("ajax_widget_url");
+ if(is_object($this->object))
+ {
+ $ret = $this->object->ItemURL($parser);
+ }
+ else
+ {
+ $ret = SiteURL($parser);
+ }
+ }
+ return $ret;
+ }
+ protected function _ajax_widget_label($attributes,$exttra_attribs="")
+ {
+ $ret = "";
+ $d = $this->GetDisplayOptions();
+ if(strlen($d->get("ajax_widget_label")))
+ {
+ $ret = $d->get("ajax_widget_label");
+ }
+ else
+ $ret = GetArrayValue($attributes,"_default","");
+ return $ret;
+ }
protected function _form_element($attributes,$extra_attribs="")
{
Modified: modules/autoform/delegates/item_autoform.php
===================================================================
--- modules/autoform/delegates/item_autoform.php 2011-04-27 19:47:06 UTC (rev 71)
+++ modules/autoform/delegates/item_autoform.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -140,7 +140,7 @@
}
if(is_object($fo))
{
- $p = new clsFieldParser($fo,null,$obj->className);
+ $p = new clsFieldParser($fo,null,$obj->className,$obj);
$p->SetTemplateType(GetArrayValue($attribs,"_templatetype","front"));
if(strlen($ret)==0 && strlen($header_tpl)>0)
$ret = $p->ParseTemplate($header_tpl);
Modified: modules/core/clsFieldDisplay.php
===================================================================
--- modules/core/clsFieldDisplay.php 2011-04-27 19:47:06 UTC (rev 71)
+++ modules/core/clsFieldDisplay.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -73,7 +73,17 @@
'datasize'=>array('No','Yes'),
'label'=>"Admin Read-only",
'section'=>"General",
- 'display_order'=>6),
+ 'display_order'=>6),
+ 'ajax_widget_label'=>array('datatype'=>VARCHAR,
+ 'datasize'=>255,
+ 'label'=>"AJAX Widget Label",
+ 'section'=>"General",
+ 'display_order'=>7),
+ 'ajax_widget_url'=>array('datatype'=>VARCHAR,
+ 'datasize'=>255,
+ 'label'=>"AJAX Widget URL",
+ 'section'=>"General",
+ 'display_order'=>8)
);
$this->ItemName = "Field Display Option";
$this->ItemPlural = "Field Display Options";
Modified: modules/core/clsUsedUID.php
===================================================================
--- modules/core/clsUsedUID.php 2011-04-27 19:47:06 UTC (rev 71)
+++ modules/core/clsUsedUID.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -10,6 +10,8 @@
$this->fieldDefs = array(
'id' => array('datatype'=>INTEGER,'datasize'=>4),
'uid' => array('datatype'=>INTEGER,'datasize'=>4),
+ 'username'=>array('datatype'=>VARCHAR,'datasize'=>255),
+ 'identity_id'=>array('datatype'=>INTEGER,'datasize'=>4),
'domain_id' =>array('datatype'=>INTEGER,'datasize'=>4)
);
@@ -52,24 +54,66 @@
$this->SearchFields["admin"] = array();
}
- function getNextUID()
+ private function getIdentityUIDs($identity_id,$domain_id)
{
- $ret = 0;
- $sql = "select max(uid) as u FROM {$this->table} WHERE uid < 10000";
+ $ret = array();
+ $sql = "select uid FROM {$this->table} WHERE identity_id=$identity_id WHERE domain_id != $domain_id ORDER BY uid ASC";
$rs = $this->doSelectSQL($sql);
if($rs)
{
- $ret = $rs[0]['u']+1;
+ foreach($rs as $r)
+ $ret[] = $r['uid'];
}
+ return $ret;
+ }
+
+ public function isUIDTaken($uid,$domain_id)
+ {
+ $ret = false;
+ $sql = "select count(*) as c FROM {$this->table} WHERE uid=$uid AND domain_id=$domain_id";
+ $rs = $this->doSelectSQL($sql);
+ if($rs)
+ {
+ $ret = ($rs[0]['c'] > 0);
+ }
return $ret;
}
- function StoreUID($uid,$domain_id)
+ function getNextUID($username,$identity_id,$domain_id)
{
+ $ret = 0;
+ $identity_ids = $this->getIdentityUIDs($identity_id,$domain_id);
+ if(count($identity_ids)>0)
+ {
+ foreach($identity_id as $uid)
+ {
+ if(!$this->isUIDTaken($uid,$domain_id))
+ {
+ $ret = $uid;
+ break;
+ }
+ }
+ }
+ if(!$ret)
+ {
+ $sql = "select max(uid) as u FROM {$this->table} WHERE uid < 10000";
+ $rs = $this->doSelectSQL($sql);
+ if($rs)
+ {
+ $ret = $rs[0]['u']+1;
+ }
+ }
+ return $ret;
+ }
+
+ function StoreUID($uid,$username,$identity_id,$domain_id)
+ {
$c = new clsUsedUID();
$c->fetchUID($uid,$domain_id);
$c->set("uid",$uid);
$c->set("domain_id",$domain_id);
+ $c->set("username",$username);
+ $c->set("identity_id",$identity_id);
$c->commit();
}
Modified: modules/core/clsUserbaseActionHandler.php
===================================================================
--- modules/core/clsUserbaseActionHandler.php 2011-04-27 19:47:06 UTC (rev 71)
+++ modules/core/clsUserbaseActionHandler.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -37,6 +37,7 @@
}
}
+
public function __call($name, $params)
{
$obj = call_user_func_array(array($this->Handler, $name), $params);
@@ -99,6 +100,15 @@
);
}
+ protected function MyAPI()
+ {
+ global $objActionHandler;
+
+
+ $prefix = $objActionHandler->GetObjectHandlerPrefix($this->ItemClassName);
+ return getApiObject($prefix);
+ }
+
public function IsHiddenEvent($n)
{
return(in_array($n,$this->hidden_events));
Modified: modules/core/event_script.php
===================================================================
--- modules/core/event_script.php 2011-04-27 19:47:06 UTC (rev 71)
+++ modules/core/event_script.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -34,7 +34,7 @@
parent::__construct($id);
$this->SetFieldDefaultValue("state","inactive");
$this->SetFieldExtraDef("id","AUTO_INCREMENT");
- $this->fields["event_name"]->form_element = new clsFormElement("select",null,"","",null,&$this,"GetObjectSelectValues");
+ $this->fields["event_name"]->form_element = new clsFormElement("select",null,"","",null,$this,"GetObjectSelectValues");
$this->bClassFilePath = true; //include the class name & id in file paths
clsDDLManager::RegisterObject($this);
if($id)
Modified: modules/identity/identity.php
===================================================================
--- modules/identity/identity.php 2011-04-27 19:47:06 UTC (rev 71)
+++ modules/identity/identity.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -82,7 +82,7 @@
'state'=>array('datatype'=>ENUM,
'datasize'=>array('requested','denied','active','suspended','inactive','deleted','duplicate'),
'label'=>"State",
- 'section'=>"General",
+ 'section'=>"System",
'display_order'=>7),
'notification_style'=>array('datatype'=>ENUM,
'datasize'=>array('always','once','never'),
Modified: modules/identity/identityphone.php
===================================================================
--- modules/identity/identityphone.php 2011-04-27 19:47:06 UTC (rev 71)
+++ modules/identity/identityphone.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -10,9 +10,9 @@
$this->fieldDefs = array(
'id' => array('datatype'=>INTEGER,'datasize'=>4),
'identity_id'=>array('datatype'=>INTEGER,'datasize'=>4),
- 'number_type'=>array('datatype'=>ENUM,'datasize'=>array('Home','Cell','Work',"Other"),'label'=>"Type","section"=>"General","display_order"=>3),
- 'phone'=>array('datatype'=>VARCHAR,'datasize'=>255,'label'=>"Phone Number",'section'=>"Phone Number",'display_order'=>1),
- 'primary'=>array('datatype'=>BOOL,'datasize'=>array('No','Yes'),'label'=>"Primary Number",'section'=>"General",'display_order'=>2)
+ 'number_type'=>array('datatype'=>ENUM,'datasize'=>array('Home','Cell','Work',"Other"),'label'=>"Type","section"=>"Phone Number","display_order"=>3),
+ 'phone'=>array('datatype'=>VARCHAR,'datasize'=>255,'label'=>"Phone Number",'section'=>"Phone Number",'display_order'=>2),
+ 'primary'=>array('datatype'=>BOOL,'datasize'=>array('No','Yes'),'label'=>"Primary Number",'section'=>"Phone Number",'display_order'=>3)
);
$this->table = $this->className;
@@ -101,7 +101,7 @@
{
$data = $this->getFormData();
$objIdentityActions = $objIdentityActions = getApiObject("identity");// new clsIdentityActions();
- $objIdentityActions->email($objSession->GetUser()->get("identity_id"),$data);
+ $objIdentityActions->phone($objSession->GetUser()->get("identity_id"),$data);
}
}
Modified: modules/mysql/account.php
===================================================================
--- modules/mysql/account.php 2011-04-27 19:47:06 UTC (rev 71)
+++ modules/mysql/account.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -356,10 +356,8 @@
{
foreach($data as $iid)
{
- $i = getDomainObject("IdentityCredential",$iid);
- $acct->AddCredential($i);
+ $this->MyAPI()->credential($acct->get("id"),$iid);
setUserFeedback("Credential ".$i->GetDefaultText()." Added to account {$acct->GetDefaultText()}.");
- unset($i);
}
}
}
Modified: modules/mysql/account_resource_credential.php
===================================================================
--- modules/mysql/account_resource_credential.php 2011-04-27 19:47:06 UTC (rev 71)
+++ modules/mysql/account_resource_credential.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -11,14 +11,22 @@
'id' => array('datatype'=>INTEGER,'datasize'=>4),
'account_id' => array('datatype'=>INTEGER,'datasize'=>4),
'resource_id' => array('datatype'=>INTEGER,'datasize'=>4),
+ 'state'=> array('datatype'=>ENUM,'datasize'=>array('active','inactive','deleted')),
'identity_credential_id' => array('datatype'=>INTEGER,'datasize'=>4)
);
}
$this->SetFieldExtraDef("id","AUTO_INCREMENT");
$this->AddRelation("IdentityCredential","identity_credential_id","id","IdentityCredential");
parent::__construct($id);
+ clsDDLManager::RegisterObject($this);
+
}
+ public function delete()
+ {
+ $this->set("state","deleted");
+ }
+
public function SetAccount($account)
{
if(is_object($account))
Modified: modules/mysql/resource.php
===================================================================
--- modules/mysql/resource.php 2011-04-27 19:47:06 UTC (rev 71)
+++ modules/mysql/resource.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -293,22 +293,112 @@
return parent::edit($ResourceId,$data);
}
+ public function credential_assign($account=null,$resource=null,$arrIdentityCredentials=null)
+ {
+ if(is_numeric($account))
+ {
+ $objAccount = getDomainObject("Account",$account);
+ }
+ elseif(is_object($account))
+ {
+ $objAccount = $account;
+ }
+ if(is_numeric($resource))
+ {
+ $objResource = getDomainObject("Resource",$resource);
+ }
+ elseif(is_object($resource))
+ {
+ $objResource = $resource;
+ }
+
+ if(is_object($objAccount) && is_object($objResource))
+ {
+ $arrCredentials = array();
+ if(is_array($arrIdentityCredentials))
+ {
+
+ if(count($arrIdentityCredentials)>0)
+ {
+ foreach($arrIdentityCredentials as $idc)
+ {
+ $this->MyAPI()->credential_assign($objAccount,$objResource,$idc);
+ }
+ }
+ }
+ else
+ {
+ if(is_numeric($arrIdentityCredentials))
+ {
+ $idc = getDomainObject("IdentityCredential",$arrIdentityCredentials);
+ }
+ elseif(is_object($arrIdentityCredentials))
+ {
+ $idc = $arrIdentityCredentials;
+ }
+ $objCredential = $idc->NamedRelationObject("Credential");
+ if($objResource->IsCredentialAccepted($objCredential) && $objAccount->IsIdentity($idc->get("identity_id")))
+ {
+ $ac = getDomainObject("AccountResourceCredential");
+ $ac->SetIdentityCredential($idc->get("id"));
+ $ac->SetAccount($objAccount);
+ $ac->SetResource($objResource);
+ $ac->commit();
+ return $ac;
+ }
+ }
+
+ }
+ }
+
+ public function account_assign($account=null,$resource=null,$arrIdentityCredentials=null)
+ {
+ $ret = false;
+ if(is_numeric($account))
+ {
+ $objAccount = getDomainObject("Account",$account);
+ }
+ elseif(is_object($account))
+ {
+ $objAccount = $account;
+ }
+ if(is_numeric($resource))
+ {
+ $objResource = getDomainObject("Resource",$resource);
+ }
+ elseif(is_object($resource))
+ {
+ $objResource = $resource;
+ }
+
+ if(is_object($objAccount) && is_object($objResource))
+ {
+ $ret = $objResource->AddAccount($objAccount,'active');
+ if(!is_null($arrIdentityCredentials))
+ {
+ $this->MyAPI()->credential_assign($objAccount,$objResource,$arrIdentityCredentials);
+ }
+ }
+
+ return $ret;
+ }
+
public function identity_assign($identity = null,$resource=null,$account=null,$arrIdentityCredentials=null )
{
- global $obbjFactory;
+ global $objFactory;
$objResource = false;
if(is_null($identity))
{
- if(is_null($IdentityId) && GetArrayValue($_GET,"Context","")=="Identity")
+ if(is_null($identity) && GetArrayValue($_GET,"Context","")=="Identity")
{
- $IdentityId = GetArrayValue($_GET,"ContextValue",0);
- $objIdentity = $objFactory->GetObject("Identity",$IdentityId);
+ $identity = GetArrayValue($_GET,"ContextValue",0);
+ $objIdentity = $objFactory->GetObject("Identity",$identity);
}
}
elseif(is_numeric($identity))
{
- $objIdentity = $objFactory->GetObject("Identity",$IdentityId);
+ $objIdentity = $objFactory->GetObject("Identity",$identity);
}
elseif(is_object($identity))
$objIdentity = $identity;
@@ -333,42 +423,77 @@
$ret = false;
if(is_object($objIdentity))
{
- $arrCredentials = array();
- if(count($arrIdentityCredentials)>0)
+ if($objAccount->IsIdentity($objIdentity->get("id")))
{
- foreach($arrIdentityCredentials as $idc)
- {
- $objCredential = $idc->NamedRelationObject("Credential");
- if($objResource->IsCredentialAccepted($objCredential))
- {
- $ac = getDomainObject("AccountResourceCredential");
- $ac->SetIdentityCredential($idc->get("id"));
- if(is_object($objAccount))
- {
- $ac->SetAccount($objAccount);
- }
- $arrCredentials[] = $ac;
- }
- }
+ $objResource->AddToIdentity($objIdentity->get("id"));
+ $ret = $this->MyAPI()->account_assign($objAccount,$objResource,$arrIdentityCredentials);
+ setUserFeedback("Added resource {$objResource->getDefaultText()} to {$objIdentity->getDefaultText()}");
}
- if($objID->get("id")>0 && is_object($objResource))
+ }
+ return $ret;
+ }
+
+ public function account_credential_remove($ResourceId,$AccountId,$CredentialId)
+ {
+ if($IdentityCredential=="all")
+ {
+ $lst = getDomainObjectList("AccountResourceCredential");
+ $lst->LoadAccountResourceCredentials($AccountId,$ResourceId);
+ if($lst->NumItems()>0)
{
- $objResource->AddToIdentity($objID->get("id"));
- if(is_object($objAccount))
+ foreach($lst->Items as $acr)
{
- $ret = $objResource->AddAccount($objAccount,'active');
- if(count($arrCredentials)>0)
- {
- $objResource->AddAccountIdentityCredential($arrCredentials);
- $count = count($arrCredentials);
- }
+ $this->MyAPI()->account_credential_remove($ResourceId,$AccountId,$acr->get("id"));
}
- setUserFeedback("Added resource {$objResource->getDefaultText()} to {$objID->getDefaultText()}");
- }
+ }
}
- return $ret;
+ else
+ {
+ if(is_numeric($ResourceId))
+ {
+ $objResource = getDomainObject("Resource",$ResourceId);
+ }
+ elseif(is_object($ResourceId))
+ {
+ $objResource = $ResourceId;
+ }
+ if(is_object($objResource))
+ {
+ return $objResource->RemoveAccountCredentials($AccountId,$CredentialId);
+ }
+ }
+ return false;
}
+ public function account_remove($AccountId=null,$ResourceId=null)
+ {
+ if(is_numeric($ResourceId))
+ {
+ $objResource = getDomainObject("Resource",$ResourceId);
+ }
+ elseif(is_object($ResourceId))
+ {
+ $objResource = $ResourceId;
+ }
+
+ if(is_numeric($AccountId))
+ {
+ $objAccount = getDomainObject("Resource",$AccountId);
+ }
+ elseif(is_object($AccountId))
+ {
+ $objAccount = $AccountId;
+ }
+
+ if(is_object($objResource))
+ {
+ $this->MyAPI()->account_credential_remove($objAccount,$objResource,"all");
+ return $objResource->RemoveAccount($objAccount);
+ }
+
+ return false;
+ }
+
public function identity_remove($IdentityId=null,$ResourceId=null)
{
if(is_null($IdentityId) && GetArrayValue($_GET,"Context","")=="Identity")
@@ -385,7 +510,17 @@
{
$r = getDomainObject("Resource",$ResourceId);
$r->RemoveFromIdentity($IdentityId);
- $objID = new Identity($IdentityId);
+ $account_list = $r->Accounts("all",$IdentityId);
+ if(is_object($account_list))
+ {
+ if($account_list->NumItems()>0)
+ {
+ foreach($account_list->Items as $a)
+ {
+ $this->MyAPI()->account_remove($a,$r);
+ }
+ }
+ }
setUserFeedback("Resource {$r->getDefaultText()} removed from Identity {$objID->getDefaultText()}");
return $r;
}
Modified: www/css/autoform_fields.css
===================================================================
--- www/css/autoform_fields.css 2011-04-27 19:47:06 UTC (rev 71)
+++ www/css/autoform_fields.css 2011-04-28 16:08:02 UTC (rev 72)
@@ -5,4 +5,10 @@
.autoform_eventscript_description_admin
{
width: 90%;
+}
+
+.ajax_widget
+{
+ display: inline;
+ width: auto;
}
\ No newline at end of file
Modified: www/js/events/dialog_boxes.js
===================================================================
--- www/js/events/dialog_boxes.js 2011-04-27 19:47:06 UTC (rev 71)
+++ www/js/events/dialog_boxes.js 2011-04-28 16:08:02 UTC (rev 72)
@@ -204,4 +204,17 @@
event.preventDefault();
addNewEventAction($(this).closest('table.item_events'));
});
+
+ //event handler for ajax helpers
+ $('div.ajax_widget a').live('click',function(event)
+ {
+ event.preventDefault();
+ var widget_target_element = $(this).closest('div.autoFormField').find('.autoform').attr('id');
+ $.ajax({
+ url: $(this).attr('href'),
+ success: function(data) {
+ $('#'+widget_target_element).val(data);
+ }
+ });
+ });
});
\ No newline at end of file
Added: www/next_uid.php
===================================================================
--- www/next_uid.php (rev 0)
+++ www/next_uid.php 2011-04-28 16:08:02 UTC (rev 72)
@@ -0,0 +1,78 @@
+<?php
+
+$objCurrentCategory = new clsCategory(getCurrentCategory());
+
+/*this project uses default templates for each user group, and the default template is stored in the custom field for the group */
+$DefaultTemplate = "";
+
+if((int)$objCurrentCategory->get("id")==0)
+{
+ //$objSession->SetSessionVar("category",1);
+ $objCurrentCategory = new clsCategory(getCurrentCategory());
+}
+
+$obj = GetArrayValue($_GET,"obj","");
+$id = GetArrayValue($_GET,"id",0);
+
+if(strlen($obj)>0)
+{
+ $d = $objDomains->getCurrentDomain();
+ if(is_object($d))
+ {
+ $objCurrentObject = $d->getDomainObject($obj,0);
+ $objCurrentItem = $d->getDomainObject($obj);
+
+ if(is_object($objCurrentItem))
+ {
+ $objCurrentItem->SetContext(GetArrayValue($_GET,"Context",""),GetArrayValue($_GET,"ContextValue",""));
+ $objCurrentItem->fetch($id);
+ if((int)$objCurrentItem->getPK() != $id)
+ {
+ if(GetArrayValue($_GET,"response_type","")!="xml")
+ {
+ header("404/not found");
+ die();
+ }
+ }
+ }
+ }
+ elseif(class_exists($obj))
+ {
+ $objCurrentItem = new $obj();
+ $objCurrentItem->SetContext(GetArrayValue($_GET,"Context",""),GetArrayValue($_GET,"ContextValue",""));
+ $objCurrentItem->fetch($id);
+ if((int)$objCurrentItem->get("id") != (int)$id)
+ {
+ if(GetArrayValue($_GET,"response_type","")!="xml")
+ {
+ header("404/not found");
+ die();
+ }
+ }
+ }
+}
+
+$domain_id = getCurrentDomain();
+if(is_object($objCurrentItem))
+{
+ $username = $objCurrentItem->get("username");
+ $identity_id = $objCurrentItem->get("identity_id");
+ if(!$identity_id && GetArrayValue($_GET,"Context")=="Identity")
+ {
+ $identity_id = GetArrayValue($_GET,"ContextValue",0);
+ }
+}
+else
+{
+ $username="";
+ if(GetArrayValue($_GET,"Context")=="Identity")
+ {
+ $identity_id = GetArrayValue($_GET,"ContextValue",0);
+ }
+}
+
+$objUIDs = new clsUsedUIDList();
+$next_id = $objUIDs->getNextUID($username,$identity_id,getCurrentDomainId());
+
+echo $next_id;
+
Modified: www/tpl/admin/item/field_item.tpl
===================================================================
--- www/tpl/admin/item/field_item.tpl 2011-04-27 19:47:06 UTC (rev 71)
+++ www/tpl/admin/item/field_item.tpl 2011-04-28 16:08:02 UTC (rev 72)
@@ -2,5 +2,10 @@
<div class="autoFormPrompt"><item:field _Field="label" /></div>
<div class="autoFormField">
<item:field _Field="form_element" class="autoForm" />
- </div>
+ <item:field _field="ajax_widget_url">
+ <div class="ajax_widget">
+ <a href="<item:field _Field="ajax_widget_url" />"><item:field _Field="ajax_widget_label" _Default=".." /></a>
+ </div>
+ </item:field>
+ </div>
</div>
\ No newline at end of file
Modified: www/tpl/wizards/account_credential/select_credential.tpl
===================================================================
--- www/tpl/wizards/account_credential/select_credential.tpl 2011-04-27 19:47:06 UTC (rev 71)
+++ www/tpl/wizards/account_credential/select_credential.tpl 2011-04-28 16:08:02 UTC (rev 72)
@@ -1,5 +1,5 @@
- <div class="wizard_next_callback" style="display: none;">account_credential_select()</div>
- <div class="wizard_next_pane" style="display: none;"><sys:thispage _Parser="item.php" _Template="wizards/autoform_fields.tpl" />&obj=IdentityCredential&id=&Context=Account&ContextValue=</div>
+ <div class="wizard_next_callback" style="display: none;"></div>
+ <div class="wizard_next_pane" style="display: none;"></div>
<div class="picker">
<div class="list-node">
<div class="list-node_header"></div>
1
0
r71 - core core/itembase domains/ci/bin modules/core modules/identity modules/mysql
by cwalker@mcs.anl.gov 27 Apr '11
by cwalker@mcs.anl.gov 27 Apr '11
27 Apr '11
Author: cwalker
Date: 2011-04-27 14:47:06 -0500 (Wed, 27 Apr 2011)
New Revision: 71
Modified:
core/clsFormElement.php
core/itembase/clsParser.php
domains/ci/bin/add_to_netgroup.php
domains/ci/bin/remove_from_netgroup.php
modules/core/event_script.php
modules/identity/identity.php
modules/mysql/resource.php
Log:
A problem cropped up when adding events to indivual resources. It turns out that php does not pass $this by reference, which is odd because it's the only objt passed by value that I know of.. This made it impossible for the event object to populate the dropdown that lets you select the event name. This has been fixed, so the event object can handle not having the context set.
Also made some tweaks to the netgroup scripts. Removed the - from the unused portions of the nidsNetgroupTriple attribute.
Modified: core/clsFormElement.php
===================================================================
--- core/clsFormElement.php 2011-04-26 21:19:39 UTC (rev 70)
+++ core/clsFormElement.php 2011-04-27 19:47:06 UTC (rev 71)
@@ -16,7 +16,10 @@
$this->name=$name;
$this->value=$value;
$this->value_list=$value_list;
- $this->val_obj = $obj;
+ if(is_object($obj))
+ {
+ $this->val_obj =& $obj;
+ }
$this->val_func = $func;
}
Modified: core/itembase/clsParser.php
===================================================================
--- core/itembase/clsParser.php 2011-04-26 21:19:39 UTC (rev 70)
+++ core/itembase/clsParser.php 2011-04-27 19:47:06 UTC (rev 71)
@@ -6,6 +6,7 @@
protected $tagNamespace;
protected $ContextName;
protected $ContextValue;
+ public $InstanceID;
function __construct()
{
@@ -20,6 +21,7 @@
{
$this->tagNamespace = "item";
}
+ $this->InstanceID = randomString(16);
parent::__construct();
}
Modified: domains/ci/bin/add_to_netgroup.php
===================================================================
--- domains/ci/bin/add_to_netgroup.php 2011-04-26 21:19:39 UTC (rev 70)
+++ domains/ci/bin/add_to_netgroup.php 2011-04-27 19:47:06 UTC (rev 71)
@@ -125,7 +125,7 @@
$data['objectClass']='nisNetgroup';
//$data['objectClass']='top';
//$data['cn']=$netgroup;
- $data['nisNetgroupTriple']="-,$account_username,-";
+ $data['nisNetgroupTriple']=",$account_username,";
$objLdap->AddDN("cn=$netgroup,ou=netgroups,$ldap_basedn",$data);
}
@@ -149,11 +149,11 @@
{
if(count($members)==0)
{
- $objLdap->AddAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>"-,$account_username,-"));
+ $objLdap->AddAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>",$account_username,"));
}
else
{
- $members[]="-,$account_username,-";
+ $members[]=",$account_username,";
$objLdap->ReplaceAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>$members));
}
Modified: domains/ci/bin/remove_from_netgroup.php
===================================================================
--- domains/ci/bin/remove_from_netgroup.php 2011-04-26 21:19:39 UTC (rev 70)
+++ domains/ci/bin/remove_from_netgroup.php 2011-04-27 19:47:06 UTC (rev 71)
@@ -122,7 +122,7 @@
function filter_members($var)
{
global $account_username;
- return ($var != "-,$account_username,-");
+ return ($var != ",$account_username,");
}
$result = $objLdap->GetDN("cn=$netgroup,ou=netgroups,".$ldap_basedn);
@@ -132,7 +132,7 @@
if(!is_array($members))
$members = array($members);
$bMatched = false;
- $val = "-,$account_username,-";
+ $val = ",$account_username,";
$m = array_values(array_filter($members,"filter_members"));
if(count($m)>0)
{
Modified: modules/core/event_script.php
===================================================================
--- modules/core/event_script.php 2011-04-26 21:19:39 UTC (rev 70)
+++ modules/core/event_script.php 2011-04-27 19:47:06 UTC (rev 71)
@@ -34,7 +34,7 @@
parent::__construct($id);
$this->SetFieldDefaultValue("state","inactive");
$this->SetFieldExtraDef("id","AUTO_INCREMENT");
- $this->fields["event_name"]->form_element = new clsFormElement("select",null,"","",null,$this,"GetObjectSelectValues");
+ $this->fields["event_name"]->form_element = new clsFormElement("select",null,"","",null,&$this,"GetObjectSelectValues");
$this->bClassFilePath = true; //include the class name & id in file paths
clsDDLManager::RegisterObject($this);
if($id)
@@ -96,6 +96,10 @@
{
$ret = array();
$class_name = $this->get("item_class");
+ if(strlen($this->GetContextName())==0 && strlen(GetArrayValue($_GET,"Context",""))>0)
+ {
+ $this->SetContext(GetArrayValue($_GET,"Context"),GetArrayValue($_GET,"ContextValue"));
+ }
if(!strlen($class_name) && strlen($this->GetContextName())>0)
{
$class_name = $this->GetContextName();
Modified: modules/identity/identity.php
===================================================================
--- modules/identity/identity.php 2011-04-26 21:19:39 UTC (rev 70)
+++ modules/identity/identity.php 2011-04-27 19:47:06 UTC (rev 71)
@@ -1513,41 +1513,9 @@
}
if($IdentityId>0)
{
- $objID = new Identity($IdentityId);
- $arrCredentials = array();
- if(count($arrIdentityCredentials)>0)
- {
- foreach($arrIdentityCredentials as $idc)
- {
- $objCredential = $idc->NamedRelationObject("Credential");
- if($objResource->IsCredentialAccepted($objCredential))
- {
- $ac = getDomainObject("AccountResourceCredential");
- $ac->SetIdentityCredential($idc->get("id"));
- if(is_object($objAccount))
- {
- $ac->SetAccount($objAccount);
- }
- $arrCredentials[] = $ac;
- }
- }
- }
- if($objID->get("id")>0 && is_object($objResource))
- {
- $objResource->AddToIdentity($objID->get("id"));
- if(is_object($objAccount))
- {
- $ret = $objResource->AddAccount($objAccount,'active');
- if(count($arrCredentials)>0)
- {
- $objResource->AddAccountIdentityCredential($arrCredentials);
- $count = count($arrCredentials);
- }
- }
- setUserFeedback("Added resource {$objResource->getDefaultText()} to {$objID->getDefaultText()}");
- }
- }
-
+ $api = getAPIObject("Resource");
+ $ret = $api->identity_assign($IdentityId,$objResource,$objAccount,$arrIdentityCredentials);
+ }
return $ret;
}
@@ -1570,22 +1538,13 @@
$t = $resources;
$resources[] = $t;
}
- $objID = new Identity($IdentityId);
- if($objID->get("id")>0)
+ if($IdentityId>0)
{
+ $api = getAPIObject("Resource");
+
foreach($resources as $res)
- {
- if(is_object($res)) //a resource object was passed in
- {
- $res->AddToIdentity($IdentityId);
- $count++;
- }
- else
- {
- $r = getDomainObject("Resource",$res);
- $r->RemoveFromIdentity($IdentityId);
- setUserFeedback("Removed resource \"{$r->getDefaultText()}\" from {$objID->GetDefaultText()}");
- }
+ {
+ $api->identity_remove($IdentityId,$res);
}
return true;
}
Modified: modules/mysql/resource.php
===================================================================
--- modules/mysql/resource.php 2011-04-26 21:19:39 UTC (rev 70)
+++ modules/mysql/resource.php 2011-04-27 19:47:06 UTC (rev 71)
@@ -293,6 +293,82 @@
return parent::edit($ResourceId,$data);
}
+ public function identity_assign($identity = null,$resource=null,$account=null,$arrIdentityCredentials=null )
+ {
+ global $obbjFactory;
+
+ $objResource = false;
+ if(is_null($identity))
+ {
+ if(is_null($IdentityId) && GetArrayValue($_GET,"Context","")=="Identity")
+ {
+ $IdentityId = GetArrayValue($_GET,"ContextValue",0);
+ $objIdentity = $objFactory->GetObject("Identity",$IdentityId);
+ }
+ }
+ elseif(is_numeric($identity))
+ {
+ $objIdentity = $objFactory->GetObject("Identity",$IdentityId);
+ }
+ elseif(is_object($identity))
+ $objIdentity = $identity;
+
+ if(is_numeric($account))
+ {
+ $objAccount = getDomainObject("Account",$account);
+ }
+ elseif(is_object($account))
+ {
+ $objAccount = $account;
+ }
+ if(is_numeric($resource))
+ {
+ $objResource = getDomainObject("Resource",$resource);
+ }
+ elseif(is_object($resource))
+ {
+ $objResource = $resource;
+ }
+
+ $ret = false;
+ if(is_object($objIdentity))
+ {
+ $arrCredentials = array();
+ if(count($arrIdentityCredentials)>0)
+ {
+ foreach($arrIdentityCredentials as $idc)
+ {
+ $objCredential = $idc->NamedRelationObject("Credential");
+ if($objResource->IsCredentialAccepted($objCredential))
+ {
+ $ac = getDomainObject("AccountResourceCredential");
+ $ac->SetIdentityCredential($idc->get("id"));
+ if(is_object($objAccount))
+ {
+ $ac->SetAccount($objAccount);
+ }
+ $arrCredentials[] = $ac;
+ }
+ }
+ }
+ if($objID->get("id")>0 && is_object($objResource))
+ {
+ $objResource->AddToIdentity($objID->get("id"));
+ if(is_object($objAccount))
+ {
+ $ret = $objResource->AddAccount($objAccount,'active');
+ if(count($arrCredentials)>0)
+ {
+ $objResource->AddAccountIdentityCredential($arrCredentials);
+ $count = count($arrCredentials);
+ }
+ }
+ setUserFeedback("Added resource {$objResource->getDefaultText()} to {$objID->getDefaultText()}");
+ }
+ }
+ return $ret;
+ }
+
public function identity_remove($IdentityId=null,$ResourceId=null)
{
if(is_null($IdentityId) && GetArrayValue($_GET,"Context","")=="Identity")
1
0
Author: cwalker
Date: 2011-04-26 16:19:39 -0500 (Tue, 26 Apr 2011)
New Revision: 70
Added:
domains/ci/bin/add_to_netgroup.php
domains/ci/bin/remove_from_netgroup.php
Modified:
bin/include/cli_loader.php
core/user/ldap.php
Log:
added scripts to add and remove accounts from netgroups, added some methdods to the ldap object to support this
Modified: bin/include/cli_loader.php
===================================================================
--- bin/include/cli_loader.php 2011-04-26 17:43:26 UTC (rev 69)
+++ bin/include/cli_loader.php 2011-04-26 21:19:39 UTC (rev 70)
@@ -53,6 +53,9 @@
// include_once("browser.php");
/* data object base classes and interfaces */
+include($pathtoroot."core/itembase/clsFactory.php");
+$objFactory = new clsFactory();
+
include($pathtoroot."core/itembase/iTagItem.php");
include($pathtoroot."core/itembase/clsField.php");
include($pathtoroot."core/itembase/clsItem.php");
@@ -207,4 +210,4 @@
$Config['fromaddress'] = $Config['sysaddress'];
}
$objMail->SystemFromAddress = $Config['fromaddress']; */
-?>
\ No newline at end of file
+?>
Modified: core/user/ldap.php
===================================================================
--- core/user/ldap.php 2011-04-26 17:43:26 UTC (rev 69)
+++ core/user/ldap.php 2011-04-26 21:19:39 UTC (rev 70)
@@ -150,7 +150,7 @@
if($r)
{
$res= true;
- $sr=ldap_search($this->ds, $this->dn, $query);
+ $sr=@ldap_search($this->ds, $this->dn, $query);
$this->LogError();
$this->data = ldap_get_entries($this->ds, $sr);
$this->LogError();
@@ -181,8 +181,11 @@
$auth_dn = $this->authdn;
if(!strlen($auth_dn))
$auth_dn = $this->dn;
-
- $result = @ldap_bind($this->ds,$this->uid_field."=".$username.",".$auth_dn,addslashes($password));
+ if(strlen($username)>0)
+ {
+ $auth_dn = $this->uid_field."=".$username.",".$auth_dn;
+ }
+ $result = @ldap_bind($this->ds,$auth_dn,addslashes($password));
$bdn = $this->uid_field."=".$username.",".$auth_dn;
if($result)
@@ -224,7 +227,7 @@
return $res;
}
- function GetDN($dn)
+ function GetDN($dn,$q="ObjectClass=*")
{
$r = false;
if($this->LdapEnabled())
@@ -233,7 +236,7 @@
if($this->ds)
{
$this->WriteToLog("Searching for DN $dn",KLogger::DEBUG);
- $sr=ldap_search($this->ds, $dn, "ObjectClass=*");
+ $sr=@ldap_search($this->ds, $dn, $q);
if($sr)
{
$r = ldap_first_entry($this->ds,$sr);
@@ -248,6 +251,21 @@
}
return $r;
}
+
+ function AddAttribute($dn,$attribs)
+ {
+ return ldap_mod_add($this->ds,$dn,$attribs);
+ }
+
+ function ReplaceAttribute($dn,$attribs)
+ {
+ return ldap_mod_replace($this->ds,$dn,$attribs);
+ }
+
+ function DeleteAttribute($dn,$attribs)
+ {
+ return ldap_mod_del($this->ds,$dn,$attribs);
+ }
function AddDN($ParentDN,$data)
{
Added: domains/ci/bin/add_to_netgroup.php
===================================================================
--- domains/ci/bin/add_to_netgroup.php (rev 0)
+++ domains/ci/bin/add_to_netgroup.php 2011-04-26 21:19:39 UTC (rev 70)
@@ -0,0 +1,161 @@
+#!/usr/bin/php -q
+<?php
+
+$f = "/etc/userbase2.conf";
+
+if(file_exists($f))
+{
+ $Config = parse_ini_file($f);
+}
+
+$pathtoroot = $Config['pathtoroot'];
+/* define STDIN in case we need it for user input */
+
+if(!defined("STDIN")) {
+define("STDIN", fopen('php://stdin','r'));
+}
+
+require_once($pathtoroot."bin/include/core_options.php");
+
+/* add script specific options */
+$objOptions->AddOption("ldap_host","H","ldaphost",true,false,"LDAP Hostname","LDAP");
+$objOptions->AddOption("ldap_authdn","a","ldapauth",true,false,"LDAP Auth DN","LDAP");
+$objOptions->AddOption("ldap_basedn","B","ldapbase",true,false,"LDAP Base DN","LDAP");
+$objOptions->AddOption("ldap_uidfield","U","ldapuid",true,false,"LDAP uid field name","LDAP");
+$objOptions->AddOption("ldap_bind_user","","ldapuser",true,false,"LDAP Bind User","LDAP");
+$objOptions->AddOption("ldap_bind_pass","","ldappass",true,true,"LDAP Bind Password","LDAP");
+
+$objOptions->AddOption("account","A","account",true,false,"Account username");
+$objOptions->AddOption("netgroup","N","netgroup",true,true,"Netgroup CN");
+
+/*read command line options */
+$objOptions->ParseOptions();
+
+/* bootstrap the platform */
+include_once($pathtoroot."bin/include/cli_loader.php");
+
+$username = $objOptions->GetValue("username");
+
+/* default to the shell user, if set */
+if(!strlen($username))
+{
+ $username = GetArrayValue($_SERVER,"user","");
+ if(strlen($username))
+ {
+ $objOptions->SetValue("username",$username);
+ }
+}
+
+$objOptions->GetInteractiveValues();
+
+$username = $objOptions->GetValue("username");
+$password = $objOptions->GetValue("password");
+$domain = $objOptions->GetValue("domain");
+$ldap_host = $objOptions->GetValue("ldap_host");
+$ldap_authdn = $objOptions->GetValue("ldap_authdn");
+$ldap_basedn = $objOptions->GetValue("ldap_basedn");
+$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
+$account_username = $objOptions->GetValue("account",0);
+$netgroup = $objOptions->GetValue("netgroup","");
+
+if(strlen($domain)==0)
+ die('No Domain Provided');
+
+if(strlen($netgroup)==0)
+ die("Netgroup not provided");
+
+$objDomain = new clsDomainBase();
+$objDomain->fetchByName($domain);
+
+$objUserAccount = null;
+$objCurrentUser = null;
+
+if($objDomain->get("id")>0)
+{
+ $objDomain->setAsCurrent();
+ echo $objDomain->get("name")." Set As Current Domain\n";
+ $objUserAccount = getDomainObject("Account");
+ $objUserAccount->fetchByUsername($username);
+ if($objDomain->AuthenticateUser($objUserAccount,$password))
+ {
+ $objCurrentUser = setCurrentAccountUser($objUserAccount);
+ }
+ else
+ $objCurrentUser = false;
+}
+
+if(!is_object($objCurrentUser))
+{
+ $u = new clsUser();
+ $u->fetchByValue(array("username"=>$username,"domain_id",0));
+ if($u->get("id")>0)
+ {
+ $objSession->SetUser($u->get("id"));
+ $objCurrentUser = $u;
+ }
+}
+
+if(strlen($ldap_host)==0)
+{
+ $ldap_host = $objDomain->GetLDAPServer();
+}
+
+$objIdentityList = new clsIdentityList();
+$objIdentityAPI = getApiObject("identity"); //new clsIdentityActions();
+
+$objLdap = new clsLdapServer($ldap_host,"",$ldap_authdn);
+$objLdap->uid_field = $uidfield;
+
+
+if(!$objLdap->Authenticate($objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
+{
+ die("Unable to bind {$ldap_authdn} to ldap server $ldap_host\n");
+}
+
+$objAccount = getDomainObject("Account");
+$objAccount->fetchByUsername($account_username);
+
+echo "Adding Account {$objAccount->GetDefaultText()} to netgroup $netgroup\n";
+
+echo "Searching for cn=$netgroup,ou=netgroups,$ldap_basedn\n";
+$result = $objLdap->GetDN("cn=$netgroup,ou=netgroups,".$ldap_basedn);
+if(!$result)
+{
+ $data=array();
+ $data['objectClass']='nisNetgroup';
+ //$data['objectClass']='top';
+ //$data['cn']=$netgroup;
+ $data['nisNetgroupTriple']="-,$account_username,-";
+
+ $objLdap->AddDN("cn=$netgroup,ou=netgroups,$ldap_basedn",$data);
+}
+else
+{
+ print_r($result);
+ $members = GetArrayValue($result,"nisNetgroupTriple",array());
+ if(!is_array($members))
+ $members = array($members);
+ $bMatched = false;
+ foreach($members as $m)
+ {
+ $ma = explode(",",$m);
+ $um = @$ma[1];
+ if($um==$account_username)
+ {
+ $bMatched=true;
+ }
+ }
+ if(!$bMatched)
+ {
+ if(count($members)==0)
+ {
+ $objLdap->AddAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>"-,$account_username,-"));
+ }
+ else
+ {
+ $members[]="-,$account_username,-";
+ $objLdap->ReplaceAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>$members));
+
+ }
+ }
+}
Property changes on: domains/ci/bin/add_to_netgroup.php
___________________________________________________________________
Added: svn:executable
+ *
Added: domains/ci/bin/remove_from_netgroup.php
===================================================================
--- domains/ci/bin/remove_from_netgroup.php (rev 0)
+++ domains/ci/bin/remove_from_netgroup.php 2011-04-26 21:19:39 UTC (rev 70)
@@ -0,0 +1,145 @@
+#!/usr/bin/php -q
+<?php
+
+$f = "/etc/userbase2.conf";
+
+if(file_exists($f))
+{
+ $Config = parse_ini_file($f);
+}
+
+$pathtoroot = $Config['pathtoroot'];
+/* define STDIN in case we need it for user input */
+
+if(!defined("STDIN")) {
+define("STDIN", fopen('php://stdin','r'));
+}
+
+require_once($pathtoroot."bin/include/core_options.php");
+
+/* add script specific options */
+$objOptions->AddOption("ldap_host","H","ldaphost",true,false,"LDAP Hostname","LDAP");
+$objOptions->AddOption("ldap_authdn","a","ldapauth",true,false,"LDAP Auth DN","LDAP");
+$objOptions->AddOption("ldap_basedn","B","ldapbase",true,false,"LDAP Base DN","LDAP");
+$objOptions->AddOption("ldap_uidfield","U","ldapuid",true,false,"LDAP uid field name","LDAP");
+$objOptions->AddOption("ldap_bind_user","","ldapuser",true,false,"LDAP Bind User","LDAP");
+$objOptions->AddOption("ldap_bind_pass","","ldappass",true,true,"LDAP Bind Password","LDAP");
+
+$objOptions->AddOption("account","A","account",true,false,"Account username");
+$objOptions->AddOption("netgroup","N","netgroup",true,true,"Netgroup CN");
+
+/*read command line options */
+$objOptions->ParseOptions();
+
+/* bootstrap the platform */
+include_once($pathtoroot."bin/include/cli_loader.php");
+
+$username = $objOptions->GetValue("username");
+
+/* default to the shell user, if set */
+if(!strlen($username))
+{
+ $username = GetArrayValue($_SERVER,"user","");
+ if(strlen($username))
+ {
+ $objOptions->SetValue("username",$username);
+ }
+}
+
+$objOptions->GetInteractiveValues();
+
+$username = $objOptions->GetValue("username");
+$password = $objOptions->GetValue("password");
+$domain = $objOptions->GetValue("domain");
+$ldap_host = $objOptions->GetValue("ldap_host");
+$ldap_authdn = $objOptions->GetValue("ldap_authdn");
+$ldap_basedn = $objOptions->GetValue("ldap_basedn");
+$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
+$account_username = $objOptions->GetValue("account",0);
+$netgroup = $objOptions->GetValue("netgroup","");
+
+if(strlen($domain)==0)
+ die('No Domain Provided');
+
+if(strlen($netgroup)==0)
+ die("Netgroup not provided");
+
+$objDomain = new clsDomainBase();
+$objDomain->fetchByName($domain);
+
+$objUserAccount = null;
+$objCurrentUser = null;
+
+if($objDomain->get("id")>0)
+{
+ $objDomain->setAsCurrent();
+ echo $objDomain->get("name")." Set As Current Domain\n";
+ $objUserAccount = getDomainObject("Account");
+ $objUserAccount->fetchByUsername($username);
+ if($objDomain->AuthenticateUser($objUserAccount,$password))
+ {
+ $objCurrentUser = setCurrentAccountUser($objUserAccount);
+ }
+ else
+ $objCurrentUser = false;
+}
+
+if(!is_object($objCurrentUser))
+{
+ $u = new clsUser();
+ $u->fetchByValue(array("username"=>$username,"domain_id",0));
+ if($u->get("id")>0)
+ {
+ $objSession->SetUser($u->get("id"));
+ $objCurrentUser = $u;
+ }
+}
+
+if(strlen($ldap_host)==0)
+{
+ $ldap_host = $objDomain->GetLDAPServer();
+}
+
+$objIdentityList = new clsIdentityList();
+$objIdentityAPI = getApiObject("identity"); //new clsIdentityActions();
+
+$objLdap = new clsLdapServer($ldap_host,"",$ldap_authdn);
+$objLdap->uid_field = $uidfield;
+
+
+if(!$objLdap->Authenticate($objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
+{
+ die("Unable to bind {$ldap_authdn} to ldap server $ldap_host\n");
+}
+
+$objAccount = getDomainObject("Account");
+$objAccount->fetchByUsername($account_username);
+
+echo "Removing Account {$objAccount->GetDefaultText()} from netgroup $netgroup\n";
+
+echo "Searching for cn=$netgroup,ou=netgroups,$ldap_basedn\n";
+
+function filter_members($var)
+{
+ global $account_username;
+ return ($var != "-,$account_username,-");
+}
+
+$result = $objLdap->GetDN("cn=$netgroup,ou=netgroups,".$ldap_basedn);
+if($result)
+{
+ $members = GetArrayValue($result,"nisNetgroupTriple",array());
+ if(!is_array($members))
+ $members = array($members);
+ $bMatched = false;
+ $val = "-,$account_username,-";
+ $m = array_values(array_filter($members,"filter_members"));
+ if(count($m)>0)
+ {
+ $objLdap->ReplaceAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>$m));
+ }
+ else
+ {
+ $objLdap->DeleteAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>array()));
+ }
+}
Property changes on: domains/ci/bin/remove_from_netgroup.php
___________________________________________________________________
Added: svn:executable
+ *
1
0
Hey all,
Here is a collection of links and tips I think would be useful for
using git with our project, along with a summary by me and some
reasons that I prefer git to SVN.
Git allows for more choice when working than subversion does. The
typical subversion workflow includes checking out the repo, making
changes, and then committing back directly to the same branch. If any
mistakes were made or if your connectivity is down, you're SOL. Git
allows for multiple different styles of workflows, though I foresee us
using one very similar to the generic centralized SVN workflow should
we chose to use git.
With git, there's a few extra steps in between editing code and having
it be in the repository. Git allows you to have something called an
index, where you can stage individual bits of changes that you'd like
to commit. This is extremely handy when you've made several edits to
multiple files simultaneously, but only want to commit code belonging
to a single feature. Once you're ready, you can commit to your local
repo. Every git clone is a self contained repository that has
everything needed to function. In essence, when you clone a repo from
somewhere else, you've got roughly all of the features SVN has but you
can use them all locally, without a network connection. Git adds
another step called pushing where you can take your changes and throw
them up on the server en mass. This means it's usually better to do
many smaller commits locally, and then push batches up to someone else
when you're ready.
This feature, along with the ability for other people to pluck changes
remotely from other repos, called pulling, allows for several
interesting workflows to emerge. Another killer feature is the
ability to quickly and extremely cheaply create topic branches.
Essentially you're able to fork your repository in a branch in one
command and then do exploratory edits in that branch. If you don't
like what comes out of it, it's fairly trivial to delete the branch
and then it's like nothing ever happened. Due to this, most git users
like to keep a master branch that contains the canonical code and then
do most of their edits in topic branches locally, merging the branches
only when they're ready to make a newer release. Using the ability to
pull/push and the ability to create cheap, easily mergible branches
allows for another feature I enjoy, where maybe I'm not ready to push
my changes to a central server and I'd like Chris to take a look at
them. I can ask him to pull from me temporarily and try out the
changes locally. He can then make modifications to that branch and
then send them back to me and if I like them I can then have them put
on the central server.
http://progit.org/book/ch5-1.html -- This link contains several
popular workflows. I foresee us somewhere between the centralized and
the integration manager workflow. We should have a centralized
repository into which we feed the code to a testing harness, most
likely Jenkins. Chris will handle the integration of code into a
blessed repository and the other developers will feed their code into
a staging repository, where if everything checks out, should be merged
by Chris into the 'official' repository.
Jenkins also has robust support for git:
https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin
Utilizing the cheap branching feature I discussed earlier, we can set
it up such that when you push your code to jenkins for testing, you
don't actually push it into the 'master' branch. You push it in its
topic branch and jenkins will reject it if it does not merge cleanly
with the master branch, as well as if it does not pass tests. That
way you can keep the master branch containing only with tested,
working code.
There are also several plugins for git to integrate into IDEs and
editors to ease the transition. However, I prefer to get down and
dirty on the command line and be rather meticulous about what I
checkin and how. I'm weird like that.
I'm quite positive I was completely ineloquent in explaining this and
my vision so feel free to berate me mercilessly and ask questions for
clarification. I've included a wealth of informational links and a
video at the bottom.
http://git-scm.com/ -- Official website.
http://progit.org/ -- Git book released for free online, very
comprehensive and full of tasty graphs.
http://www.youtube.com/watch?v=8dhZ9BXQgc4 -- Randal Schwartz talking
for an hour about git, explaining it in detail.
http://gitref.org/ -- GitRef, awesome quick git reference.
http://www.kernel.org/pub/software/scm/git/docs/everyday.html --
Everyday Git -- 20 git commands that will do 95% of what you need to
do everyday.
http://git-scm.com/course/svn.html -- Git tutorial for SVN users.
http://gitready.com/ -- collection of git tips of varying levels of diffifculty
1
0
r69 - core core/db core/itembase core/user domains/ci modules/core modules/identity modules/mysql modules/user tpl/common www/js/events www/tpl/common/items www/tpl/common/misc/list_controls www/tpl/nodes/identity www/tpl/nodes/resource_group
by cwalker@mcs.anl.gov 26 Apr '11
by cwalker@mcs.anl.gov 26 Apr '11
26 Apr '11
Author: cwalker
Date: 2011-04-26 12:43:26 -0500 (Tue, 26 Apr 2011)
New Revision: 69
Added:
core/itembase/clsFactory.php
Modified:
core/clsTemplate.php
core/db/CustomFields.php
core/db/clsDBItem.php
core/itembase/clsCollection.php
core/itembase/clsParser.php
core/loader.php
core/user/group_base.php
core/user/permission_base.php
core/user/user_base.php
domains/ci/account.php
domains/ci/resource.php
modules/core/clsDomainBase.php
modules/identity/identity.php
modules/mysql/account.php
modules/user/user.php
tpl/common/head_section.tpl
www/js/events/node_lists.js
www/tpl/common/items/identity_domain_items.tpl
www/tpl/common/misc/list_controls/resource_group_main.tpl
www/tpl/nodes/identity/address.tpl
www/tpl/nodes/identity/credential.tpl
www/tpl/nodes/identity/email.tpl
www/tpl/nodes/identity/resources.tpl
www/tpl/nodes/resource_group/resource_group.tpl
Log:
Implemented an object factory to reduce the excessive queries to the database on object creation. Also cleaned up some template stuff regarding node lists, including paging, sorting, etc
Modified: core/clsTemplate.php
===================================================================
--- core/clsTemplate.php 2011-04-25 22:04:30 UTC (rev 68)
+++ core/clsTemplate.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -264,6 +264,7 @@
{
global $objSession;
+ $ret = "";
$SupressError = ($SupressError || $tag->GetAttributeByName("_supresserror"));
switch($tag->name)
{
Modified: core/db/CustomFields.php
===================================================================
--- core/db/CustomFields.php 2011-04-25 22:04:30 UTC (rev 68)
+++ core/db/CustomFields.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -125,5 +125,12 @@
'value' => array(VARCHAR, 255));
parent::__construct();
}
+}
+class clsCustomFieldList extends clsDBParsedItem
+{
+ function __construct()
+ {
+ parent::__construct("clsCustomField");
+ }
}
\ No newline at end of file
Modified: core/db/clsDBItem.php
===================================================================
--- core/db/clsDBItem.php 2011-04-25 22:04:30 UTC (rev 68)
+++ core/db/clsDBItem.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -10,6 +10,7 @@
public $CustomData;
protected $ItemCache;
public $DB;
+ private $custom_fields_loaded;
function __construct()
{
@@ -52,6 +53,7 @@
{
$this->bEnableCustomFields = true;
}
+ $this->custom_fields_loaded = false;
$this->LoadCustomFields();
/* foreach($this->Relations as $r)
{
@@ -993,64 +995,69 @@
{
global $objCurrentCategory, $objDomains, $objDB;
- $this->CustomFields = array();
- if($this->bEnableCustomFields)
+ $current_key = $this->getPK()."_".$this->GetContextName()."_".$this->GetContextValue();
+ if(!strlen($this->custom_fields_loaded) || $this->custom_fields_loaded != $current_key)
{
- if(is_object($objDomains))
- {
- $d = $objDomains->getCurrentDomain(false);
- if(strlen($this->GetContextName())>0 && is_object($d) && strlen($this->GetContextValue())>0)
+ $this->CustomFields = array();
+ if($this->bEnableCustomFields)
+ {
+ if(is_object($objDomains))
+ {
+ $d = $objDomains->getCurrentDomain(false);
+ if(strlen($this->GetContextName())>0 && is_object($d) && strlen($this->GetContextValue())>0)
+ {
+ $ContextClassName = $d->getDomainClassName($this->GetContextName());
+ $sql = "select * FROM custom_fields WHERE ((classname='".$this->className."' AND item_id=0) ";
+ $sql .=" or (classname='$ContextClassName' AND child_classname='{$this->className}' AND item_id={$this->GetContextValue()})";
+
+ }
+ else
+ {
+ $sql = "select * FROM custom_fields WHERE ((classname='".$this->className."' AND item_id=0)";
+ }
+ }
+ else
+ {
+ $sql = "select * FROM custom_fields WHERE ((classname='".$this->className."' AND item_id=0)";
+ }
+ if($this->getPK())
{
- $ContextClassName = $d->getDomainClassName($this->GetContextName());
- $sql = "select * FROM custom_fields WHERE ((classname='".$this->className."' AND item_id=0) ";
- $sql .=" or (classname='$ContextClassName' AND child_classname='{$this->className}' AND item_id={$this->GetContextValue()})";
-
+ for($x=0;$x<count($this->Relations);$x++)
+ {
+ $r = $this->Relations[$x];
+ $obj = $this->NamedRelationObject($r->RelationName);
+ if(is_object($obj))
+ {
+ $sql .= " OR (classname='{$this->className}' AND child_classname='{$r->ClassName}' AND item_id='{$this->getPK()}')";
+ }
+ }
}
- else
+ if(is_object($objCurrentCategory))
{
- $sql = "select * FROM custom_fields WHERE ((classname='".$this->className."' AND item_id=0)";
+ $ids = $objCurrentCategory->ParentIdList();
+ if(count($ids)>0)
+ {
+ $ids[] = 0;
+ $sql .= ") AND category_id IN (".implode(",",$ids).")";
+ }
}
- }
- else
- {
- $sql = "select * FROM custom_fields WHERE ((classname='".$this->className."' AND item_id=0)";
- }
- if($this->getPK())
- {
- for($x=0;$x<count($this->Relations);$x++)
- {
- $r = $this->Relations[$x];
- $obj = $this->NamedRelationObject($r->RelationName);
- if(is_object($obj))
+ else
+ $sql .= ") AND category_id=0";
+ //echo $sql."<br>\n";
+ $rs = $objDB->doSelectSQL($sql);
+
+ foreach($rs as $r)
+ {
+ $c = new clsCustomField();
+ foreach($r as $field=>$value)
{
- $sql .= " OR (classname='{$this->className}' AND child_classname='{$r->ClassName}' AND item_id='{$this->getPK()}')";
+ $c->set($field,$value);
}
- }
- }
- if(is_object($objCurrentCategory))
- {
- $ids = $objCurrentCategory->ParentIdList();
- if(count($ids)>0)
- {
- $ids[] = 0;
- $sql .= ") AND category_id IN (".implode(",",$ids).")";
- }
- }
- else
- $sql .= ") AND category_id=0";
- //echo $sql."<br>\n";
- $rs = $objDB->doSelectSQL($sql);
-
- foreach($rs as $r)
- {
- $c = new clsCustomField();
- foreach($r as $field=>$value)
- {
- $c->set($field,$value);
+ $this->CustomFields[$c->get("name")] = $c;
+ unset($c);
}
- $this->CustomFields[$c->get("name")] = $c;
- unset($c);
- }
+ }
+ $this->custom_fields_loaded = $current_key;
}
}
Modified: core/itembase/clsCollection.php
===================================================================
--- core/itembase/clsCollection.php 2011-04-25 22:04:30 UTC (rev 68)
+++ core/itembase/clsCollection.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -26,7 +26,9 @@
public function NewObject($id=null)
{
- return new $this->className($id);
+ global $objFactory;
+
+ return $objFactory->CloneObject($this->className,$id);
}
public function NumItems()
Added: core/itembase/clsFactory.php
===================================================================
--- core/itembase/clsFactory.php (rev 0)
+++ core/itembase/clsFactory.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -0,0 +1,38 @@
+<?php
+
+class clsFactory
+{
+ private $storage;
+
+ function __construct()
+ {
+ $this->storage = array();
+ }
+
+ private function NewObject($className,$item_id)
+ {
+ $this->storage[$className][$item_id] = new $className($item_id);
+
+ return $this->storage[$className][$item_id];
+ }
+
+ public function GetObject($className,$item_id=0)
+ {
+ $c = @$this->storage[$className][$item_id];
+ if(is_object($c))
+ {
+ return $c;
+ }
+ else
+ {
+ return $this->NewObject($className,$item_id);
+ }
+ }
+
+ public function CloneObject($className,$item_id=0)
+ {
+ $c = $this->GetObject($className,$item_id);
+
+ return clone($c);
+ }
+}
\ No newline at end of file
Modified: core/itembase/clsParser.php
===================================================================
--- core/itembase/clsParser.php 2011-04-25 22:04:30 UTC (rev 68)
+++ core/itembase/clsParser.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -24,6 +24,15 @@
parent::__construct();
}
+ function __clone()
+ {
+ foreach($this as $key => $val) {
+ if(is_object($val)||(is_array($val))){
+ $this->{$key} = unserialize(serialize($val));
+ }
+ }
+ }
+
public function SetContext($Name,$Value)
{
$this->ContextName = $Name;
Modified: core/loader.php
===================================================================
--- core/loader.php 2011-04-25 22:04:30 UTC (rev 68)
+++ core/loader.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -55,7 +55,9 @@
$objParserLogger = new clsParserLogger();
/* data object base classes and interfaces */
-
+ include('itembase/clsFactory.php');
+ $objFactory = new clsFactory();
+
include('itembase/iTagItem.php');
include('itembase/clsField.php');
include('itembase/clsItem.php');
Modified: core/user/group_base.php
===================================================================
--- core/user/group_base.php 2011-04-25 22:04:30 UTC (rev 68)
+++ core/user/group_base.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -11,14 +11,14 @@
if(!is_array($this->fieldDefs))
{
$this->fieldDefs = array(
- 'id' => array(INTEGER, 4),
- 'name' => array(VARCHAR, 50),
- 'active' => array(INTEGER, 4),
- 'admin' => array(INTEGER, 4),
- 'reg_default' => array(INTEGER, 4),
- 'pam_default' => array(INTEGER, 4),
- 'default_template'=>array(VARCHAR,255),
- 'description'=>array(VARCHAR,255)
+ 'id' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'name' => array('datatype'=>VARCHAR, 'datasize'=>50),
+ 'active' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'admin' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'reg_default' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'pam_default' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'default_template'=>array('datatype'=>VARCHAR,'datasize'=>255),
+ 'description'=>array('datatype'=>VARCHAR,'datasize'=>255)
);
$this->Relations = array ();
Modified: core/user/permission_base.php
===================================================================
--- core/user/permission_base.php 2011-04-25 22:04:30 UTC (rev 68)
+++ core/user/permission_base.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -12,12 +12,12 @@
if(!is_array($this->fieldDefs))
{
$this->fieldDefs = array(
- 'id' => array(INTEGER, 4),
- 'name' => array(VARCHAR, 255),
- 'perm_type' => array(VARCHAR, 20),
- 'active' => array(INTEGER, 4),
- 'admin_only' => array(INTEGER, 4),
- 'description'=>array(VARCHAR,255)
+ 'id' => array('datatype'=>INTEGER,'datasize'=>4),
+ 'name' => array('datatype'=>VARCHAR, 'datasize'=>255),
+ 'perm_type' => array('datatype'=>VARCHAR, 'datasize'=>20),
+ 'active' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'admin_only' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'description'=>array('datatype'=>VARCHAR,'datasize'=>255)
);
$this->Relations = array ();
$this->FieldDisplayTags = array();
Modified: core/user/user_base.php
===================================================================
--- core/user/user_base.php 2011-04-25 22:04:30 UTC (rev 68)
+++ core/user/user_base.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -20,18 +20,18 @@
if(!is_array($this->fieldDefs))
{
$this->fieldDefs = array(
- 'id' => array(INTEGER, 4),
- 'username' => array(VARCHAR, 255),
- 'password' => array(VARCHAR, 255),
- 'email' => array(VARCHAR, 255),
- 'active' => array(INTEGER, 4),
- 'admin' => array(INTEGER, 4),
- 'primary_group' => array(INTEGER, 4),
- 'firstname'=>array(VARCHAR,255),
- 'lastname'=>array(VARCHAR,255),
- 'phone'=>array(VARCHAR,255),
- 'division'=>array(VARCHAR,255),
- 'last_login' => array(SQLDATETIME, 0)
+ 'id' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'username' => array('datatype'=>VARCHAR, 'datasize'=>255),
+ 'password' => array('datatype'=>VARCHAR, 'datasize'=>255),
+ 'email' => array('datatype'=>VARCHAR, 'datasize'=>255),
+ 'active' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'admin' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'primary_group' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'firstname'=>array('datatype'=>VARCHAR,'datasize'=>255),
+ 'lastname'=>array('datatype'=>VARCHAR,'datasize'=>255),
+ 'phone'=>array('datatype'=>VARCHAR,'datasize'=>255),
+ 'division'=>array('datatype'=>VARCHAR,'datasize'=>255),
+ 'last_login' => array('datatype'=>SQLDATETIME, 'datasize'=>0)
);
$this->Relations = array (new clsRelation("clsGroup","primary_group","id","PrimaryGroup")
Modified: domains/ci/account.php
===================================================================
--- domains/ci/account.php 2011-04-25 22:04:30 UTC (rev 68)
+++ domains/ci/account.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -34,6 +34,7 @@
new clsRelation("CI_ResourceGroup","id","id","ResourceGroup","clsResourceGroupList","account_resourcegroup","account_id","resourcegroup_id"),
new clsRelation("CI_AccountResourceCredential","id","account_id","AccountResourceCredential","CI_clsAccountResourceCredentialList")
);
+ $this->AddRelation("Identity","identity_id","id","Identity");
$this->FieldDisplayTags = array();
$this->ConfigPrefix = "CI";
@@ -316,7 +317,7 @@
public function Activate()
{
$this->set("state","active");
- $this->commit();
+ $this->commit();
}
public function Deny()
Modified: domains/ci/resource.php
===================================================================
--- domains/ci/resource.php 2011-04-25 22:04:30 UTC (rev 68)
+++ domains/ci/resource.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -42,6 +42,16 @@
$this->SetFieldExtraDef("id","AUTO_INCREMENT");
$this->bClassFilePath = true; //include the class name & id in file paths
$this->EnableRelationCustomFields("ResourceAccount");
+
+ $this->uiSortColumns = array(
+ "main"=>array("name","ldap_netgroup","state","description","full_name","brief_description","resource_info","public","requires_accounts",
+ "accepts_domain_pw","foreign_sensitive","needs_appoval","url"),
+ "group_main"=>array("name","ldap_netgroup","state","description","full_name","brief_description","resource_info","public","requires_accounts",
+ "accepts_domain_pw","foreign_sensitive","needs_appoval","url"),
+ "orphins"=>array("name","ldap_netgroup","state","description","full_name","brief_description","resource_info","public","requires_accounts",
+ "accepts_domain_pw","foreign_sensitive","needs_appoval","url")
+ );
+
if($id)
{
$this->fetch($id);
@@ -253,7 +263,7 @@
public function Credentials($ListType="all")
{
- global $objDomains;
+ global $objDomains,$objFactory;
$ids = array();
$d = $objDomains->getCurrentDomain();
@@ -266,7 +276,7 @@
$ids[] = $r['credential_id'];
}
}
- $lst = new clsCredentialList();
+ $lst = $objFactory->CloneObject("clsCredentialList");
if(count($ids)>0)
{
$lst->AddFilter("id",$ids,"=");
@@ -389,7 +399,7 @@
$sql .= " WHERE $where";
// $sql = $this->FinishListSQL($sql,$ListName);
- break;
+ break;
case "group_main":
$t = $this->table;
$sql = "select count(*) as c FROM $t INNER JOIN group_resources ON ($t.id=group_resources.resource_id)";
@@ -496,6 +506,7 @@
$sql = parent::BuildListSQL($ListName);
break;
}
+ //echo $ListName.":".$sql."<br />\n";
return $sql;
}
Modified: modules/core/clsDomainBase.php
===================================================================
--- modules/core/clsDomainBase.php 2011-04-25 22:04:30 UTC (rev 68)
+++ modules/core/clsDomainBase.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -151,15 +151,16 @@
public function getDomainObject($objName,$init_data=null)
{
+ global $objFactory;
$ret = null;
$className = $this->get("obj_prefix")."_".$objName;
if(class_exists($className))
{
- $ret = new $className($init_data);
+ $ret = $objFactory->CloneObject($className,$init_data); // new $className($init_data);
}
elseif(class_exists($objName))
{
- $ret = new $objName($init_data);
+ $ret = $objFactory->CloneObject($objName,$init_data); // new $objName($init_data);
}
return $ret;
}
@@ -189,7 +190,7 @@
public function getDomainObjectList($objName)
{
- global $objTagLib;
+ global $objTagLib, $objFactory;
$ret = null;
$className = $objTagLib->GetObjectClass($this->get("obj_prefix")."_".$objName);
@@ -197,7 +198,7 @@
{
if(class_exists($className))
{
- $ret = new $className();
+ $ret = $objFactory->CloneObject($className); // new $className();
}
}
if(!is_object($ret))
@@ -207,7 +208,7 @@
{
if(class_exists($className))
{
- $ret = new $className();
+ $ret = $objFactory->CloneObject($className); // new $className();
}
}
}
@@ -371,6 +372,33 @@
return $u;
}
+
+ function getAccountUser($objAccount)
+ {
+ $u = new clsUser();
+ $u->fetchByValue(array("username"=>$objAccount->get("username"),"domain_id"=>$this->get("id")));
+ if($u->get("id")>0)
+ {
+ return $u;
+ }
+
+ return false;
+ }
+
+ function setAccountUserGroup($objAccount, $group_name)
+ {
+ $u = $this->getAccountUser($objAccount);
+ if(is_object($u))
+ {
+ $g = new clsGroup();
+ $g->fetchByName($group_name);
+ if($g->get("id")>0)
+ {
+ $u->SetPrimaryGroup($g->get("id"));
+ }
+ }
+ }
+
}
class clsDomainList extends clsDBParsedCollection
Modified: modules/identity/identity.php
===================================================================
--- modules/identity/identity.php 2011-04-25 22:04:30 UTC (rev 68)
+++ modules/identity/identity.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -512,6 +512,7 @@
if(!is_object($this->Credentials))
{
$lst = new clsIdentityCredentialList();
+ $lst->SetPaging(false);
$lst->IdentityCredentials($list_type,$this->get("id"));
$lst->SetObjectContext("Identity",$this->get("id"));
$this->Credentials = $lst;
@@ -749,7 +750,7 @@
$ret = "";
$lst = $this->Resources(GetArrayValue($attribs,"_listtype","all"));
if(is_object($lst))
- $ret = (int)$lst->_pagenav($attribs);
+ $ret = $lst->_pagenav($attribs);
return $ret;
}
Modified: modules/mysql/account.php
===================================================================
--- modules/mysql/account.php 2011-04-25 22:04:30 UTC (rev 68)
+++ modules/mysql/account.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -18,11 +18,11 @@
public function __construct($id=null)
{
- $this->AddRelation("Identity","identity_id","id","Identity");
+/* $this->AddRelation("Identity","identity_id","id","Identity");*/
$this->AddRelation("IdentityCredential","id","id","Credential","clsIdentityCredentialList",
"account_credentials","account_id","identity_credential_id");
- $this->AddRelation("Identity","id","id","Sponsor","clsIdentityList",
- "account_sponsor","account_id","sponsor_identity_id");
+/* $this->AddRelation("Identity","id","id","Sponsor","clsIdentityList",
+ "account_sponsor","account_id","sponsor_identity_id");*/
if(!strlen($this->ItemName))
{
$this->ItemName = "Account";
@@ -45,7 +45,8 @@
{
$this->DeleteJoinRelation("Credential",$objIdentityCredential);
}
-
+
+/*
public function AddSponsor($objIdentity)
{
$this->AddRelatedObject("Sponsor",$objIdentity);
@@ -55,7 +56,7 @@
{
$this->DeleteJoinRelation("Sponsor",$objIdentity);
}
-
+*/
public function AddIdentityCredential($c)
{
if(is_array($c))
@@ -162,6 +163,7 @@
return $ret;
}
+
public function SetDomainPassword($new_password)
{
global $objDomains;
Modified: modules/user/user.php
===================================================================
--- modules/user/user.php 2011-04-25 22:04:30 UTC (rev 68)
+++ modules/user/user.php 2011-04-26 17:43:26 UTC (rev 69)
@@ -10,18 +10,18 @@
{
$this->primaryKey = 'id';
$this->fieldDefs = array(
- 'id' => array(INTEGER, 4),
- 'username' => array(VARCHAR, 255),
- 'password' => array(VARCHAR, 255),
- 'email' => array(VARCHAR, 255),
- 'active' => array(INTEGER, 4),
- 'admin' => array(INTEGER, 4),
- 'primary_group' => array(INTEGER, 4),
- 'firstname'=>array(VARCHAR,255),
- 'lastname'=>array(VARCHAR,255),
- 'phone'=>array(VARCHAR,255),
- 'division'=>array(VARCHAR,255),
- 'last_login' => array(SQLDATETIME, 0)
+ 'id' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'username' => array('datatype'=>VARCHAR, 'datasize'=>255),
+ 'password' => array('datatype'=>VARCHAR, 'datasize'=>255),
+ 'email' => array('datatype'=>VARCHAR, 'datasize'=>255),
+ 'active' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'admin' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'primary_group' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'firstname'=>array('datatype'=>VARCHAR,'datasize'=>255),
+ 'lastname'=>array('datatype'=>VARCHAR,'datasize'=>255),
+ 'phone'=>array('datatype'=>VARCHAR,'datasize'=>255),
+ 'division'=>array('datatype'=>VARCHAR,'datasize'=>255),
+ 'last_login' => array('datatype'=>SQLDATETIME, 'datasize'=>0)
);
$this->fieldDefs["identity_id"] = array('datatype'=>INTEGER,
'datasize'=>4);
Modified: tpl/common/head_section.tpl
===================================================================
--- tpl/common/head_section.tpl 2011-04-25 22:04:30 UTC (rev 68)
+++ tpl/common/head_section.tpl 2011-04-26 17:43:26 UTC (rev 69)
@@ -57,7 +57,7 @@
{
if($('#'+node_id).attr('ajaxTemplate'))
{
- $('#'+node_id).html('');
+ $('#'+node_id).html('Loading..');
$('#'+node_id).load($('#'+node_id).attr('ajaxTemplate'));
}
else
@@ -65,7 +65,7 @@
var n = $('#'+node_id).closest('[ajaxTemplate]');
if(n)
{
- $(n).html('');
+ $(n).html('Loading..');
$(n).load($(n).attr('ajaxTemplate'));
}
}
Modified: www/js/events/node_lists.js
===================================================================
--- www/js/events/node_lists.js 2011-04-25 22:04:30 UTC (rev 68)
+++ www/js/events/node_lists.js 2011-04-26 17:43:26 UTC (rev 69)
@@ -99,6 +99,25 @@
}
});
});
+
+ $('.list-node_paging_center a').live('click',function(event) {
+ event.preventDefault();
+ var url = $(this).attr('href');
+ var ListNode = $(this).closest('.list-node_controls');
+
+ $.ajax({
+ url: url,
+ success: function(data) {
+ var refresh_class=ListNode.attr('RefreshClass');
+ if(refresh_class)
+ {
+ $('.'+refresh_class).each(function() {
+ refreshNode($(this).attr('id'));
+ });
+ }
+ }
+ });
+ });
});
//item list event handlers go here
Modified: www/tpl/common/items/identity_domain_items.tpl
===================================================================
--- www/tpl/common/items/identity_domain_items.tpl 2011-04-25 22:04:30 UTC (rev 68)
+++ www/tpl/common/items/identity_domain_items.tpl 2011-04-26 17:43:26 UTC (rev 69)
@@ -1,5 +1,5 @@
- <div class="list-node" ajaxTemplate="<item:this _Field="link" _Parser="item.php" _Template="nodes/identity/affiliation.tpl" />"></div>
+ <div class="list-node affiliation_identity_<item:this _Field="id" />" ajaxTemplate="<item:this _Field="link" _Parser="item.php" _Template="nodes/identity/affiliation.tpl" />"></div>
- <div class="list-node" ajaxTemplate="<item:this _Field="link" _Parser="item.php" _Template="nodes/identity/resources.tpl" />"></div>
+ <div class="list-node resource_identity_<item:this _Field="id" />" ajaxTemplate="<item:this _Field="link" _Parser="item.php" _Template="nodes/identity/resources.tpl" />"></div>
- <div class="list-node" ajaxTemplate="<item:this _Field="link" _Parser="item.php" _Template="nodes/identity/account.tpl" />"></div>
+ <div class="list-node account_identity_<item:this _Field="id" />" ajaxTemplate="<item:this _Field="link" _Parser="item.php" _Template="nodes/identity/account.tpl" />"></div>
Modified: www/tpl/common/misc/list_controls/resource_group_main.tpl
===================================================================
--- www/tpl/common/misc/list_controls/resource_group_main.tpl 2011-04-25 22:04:30 UTC (rev 68)
+++ www/tpl/common/misc/list_controls/resource_group_main.tpl 2011-04-26 17:43:26 UTC (rev 69)
@@ -1,5 +1,5 @@
- <div class="list-node_controls">
+ <div class="list-node_controls" RefreshClass="resource_group_<item:this _Field="context_value" />">
<div class="list-node_search">
<form name="identity_searchlist" id="<item:this _Field="classname" />_searchlist" method="POST" style="display:inline" action="<item:this _Field="link" _Template="nodes/resource_group/ungrouped_main.tpl" />">
<input type=hidden name="List[List]" value="<item:this _Field="list_name" _ListType="group_main" />" />
@@ -25,6 +25,8 @@
<a href="<sys:thispage _Template="common/misc/ajax_feedback.tpl" _Params="List[List]=Identity_main&action=list:vars" />" CurrentOrder="<list:var _Var="SortOrder" _Item="Resource" _ListType="group_main" />" class="list-node_sort_order"><img src="images/list_sort_toggle.png" /></a>
</div>
<div class="list-node_paging">
- Page: <dlist:pagenav _Item="Resource" _ListType="group_main" _HideEmpty="true" />
- </div>
+ <div class="list-node_paging_left"> </div>
+ <div class="list-node_paging_center">Page: <dlist:pagenav _Item="Resource" _ListType="group_main" _HideEmpty="true" /></div>
+ <div class="list-node_paging_right"> </div>
+ </div>
</div>
Modified: www/tpl/nodes/identity/address.tpl
===================================================================
--- www/tpl/nodes/identity/address.tpl 2011-04-25 22:04:30 UTC (rev 68)
+++ www/tpl/nodes/identity/address.tpl 2011-04-26 17:43:26 UTC (rev 69)
@@ -31,7 +31,7 @@
<img src="images/list_sort_toggle.png" />
</a>
</div>
- <div class="list-node_paging">
+ <div class="list-node_paging" style="display: none;">
<div class="list-node_paging_left"> </div>
<div class="list-node_paging_center">Page: <item:this _Field="+rel:pagenav" _Relation="Address" _ListType="main" _HideEmpty="true" /></div>
<div class="list-node_paging_right"> </div>
Modified: www/tpl/nodes/identity/credential.tpl
===================================================================
--- www/tpl/nodes/identity/credential.tpl 2011-04-25 22:04:30 UTC (rev 68)
+++ www/tpl/nodes/identity/credential.tpl 2011-04-26 17:43:26 UTC (rev 69)
@@ -38,9 +38,7 @@
<img src="images/list_sort_toggle.png" />
</a>
</div>
- <div class="list-node_paging">
- Page: <item:this _Field="+rel:pagenav" _Relation="IdentityCredential" _ListType="main" _HideEmpty="true" />
- </div>
+
</div>
</div>
<div class="list-node_items" id="list_node_<sys:random_string />" ajaxTemplate="<item:this _Field="link" _Parser="item.php" _Template="nodes/identity/ajax/credential_list.tpl" />">
Modified: www/tpl/nodes/identity/email.tpl
===================================================================
--- www/tpl/nodes/identity/email.tpl 2011-04-25 22:04:30 UTC (rev 68)
+++ www/tpl/nodes/identity/email.tpl 2011-04-26 17:43:26 UTC (rev 69)
@@ -31,9 +31,6 @@
<img src="images/list_sort_toggle.png" />
</a>
</div>
- <div class="list-node_paging">
- Page: <item:this _Field="+rel:pagenav" _Relation="Email" _ListType="main" _HideEmpty="true" />
- </div>
</div>
</div>
<div class="list-node_items" id="list_node_<sys:random_string />" ajaxTemplate="<item:this _Field="link" _Parser="item.php" _Template="nodes/identity/ajax/email_list.tpl" />">
Modified: www/tpl/nodes/identity/resources.tpl
===================================================================
--- www/tpl/nodes/identity/resources.tpl 2011-04-25 22:04:30 UTC (rev 68)
+++ www/tpl/nodes/identity/resources.tpl 2011-04-26 17:43:26 UTC (rev 69)
@@ -1,7 +1,7 @@
<!-- Template: nodes/identity/resources.tpl -->
<div class="list-node_header" AddAction="assign_resource">
<h2>Resources</h2> (<item:this _Field="num_resources" _Relation="Resource" _ListType="main" _ListType="main" />)
- <div class="list-node_buttons">
+ <div class="list-node_buttons" >
<a id="edit_item_<sys:random_string />" FormAction="assign_resource" title="Assign Resource" href="<item:this _Parser="item.php" _Field="link" _Template="common/misc/wizard.tpl" />" WizardInit="<item:this _Parser="item.php" _Field="link" _Template="wizards/identity_resource/select_resource.tpl" />" class="list-init_wizard">
<img class="hoverable" src="images/list_add.png" />
</a>
@@ -9,7 +9,7 @@
<img class="hoverable" src="images/list_refresh.png" />
</a>
</div>
- <div class="list-node_controls">
+ <div class="list-node_controls" RefreshClass="resource_identity_<item:this _Field="id" />">
<div class="list-node_search">
<form name="affiliation_searchlist" id="<item:this _Object="Resource" _Field="classname" />_searchlist" method="POST" style="display:inline" action="<item:this _Field="link" _Template="nodes/identity/affiliation.tpl" />">
<input type=hidden name="List[List]" value="<item:this _Object="Resource" _Field="list_name" _ListType="main" />" />
@@ -38,11 +38,11 @@
<img src="images/list_sort_toggle.png" />
</a>
</div>
- <div class="list-node_paging">
- Page: <item:this _Field="resource_pagenav" _ListType="main" _HideEmpty="true" />
+ <div class="list-node_paging" style="display: none;">
+ Page: <item:this _Field="resources_pagenav" _ListType="main" _HideEmpty="true" />
</div>
</div>
</div>
- <div class="list-node_items" id="list_node_<sys:random_string />" ajaxTemplate="<item:this _Field="link" _Parser="item.php" _template="nodes/identity/ajax/resource_list.tpl" />">
+ <div class="list-node_items" id="list_node_<sys:random_string />" ajaxTemplate="<item:this _Field="link" _Parser="item.php" _template="nodes/identity/ajax/resource_list.tpl" />">
<item:this _Field="template" _template="nodes/identity/ajax/resource_list.tpl" />
</div>
\ No newline at end of file
Modified: www/tpl/nodes/resource_group/resource_group.tpl
===================================================================
--- www/tpl/nodes/resource_group/resource_group.tpl 2011-04-25 22:04:30 UTC (rev 68)
+++ www/tpl/nodes/resource_group/resource_group.tpl 2011-04-26 17:43:26 UTC (rev 69)
@@ -40,7 +40,7 @@
<div class="list-node_items" id="child_groups_<sys:random_string />" ajaxTemplate="<item:this _Field="link" _Template="nodes/resource_group/ajax/child_groups.tpl" />">
<item:this _Field="template" _Template="nodes/resource_group/ajax/child_groups.tpl" />
</div>
- <div class="list-node_header" AddAction="add_resource">
+ <div class="list-node_header resource_group_<item:this _Field="id" />" AddAction="add_resource" id="list-header-group_resources_<item:this _Field="id" />">
<h2>Resources</h2> (<item:this _Field="num_resources" _ListType="main" />)
<div class="list-node_buttons">
<a id="edit_item_<sys:random_string />" FormAction="resource_wizard" title="Add Resource"
@@ -55,6 +55,6 @@
</div>
<item:this _Field="rel_item_template" _Template="common/misc/list_controls/resource_group_main.tpl" _RelatedItem="Resource" />
</div>
- <div class="list-node_items" id="resource_group_<sys:random_string />" ajaxTemplate="<item:this _Field="link" _Template="nodes/resource_group/ajax/group_resources.tpl" />">
+ <div class="list-node_items resource_group_<item:this _Field="id" />" id="group_resources_<item:this _Field="id" />" ajaxTemplate="<item:this _Field="link" _Template="nodes/resource_group/ajax/group_resources.tpl" />">
<item:this _Field="template" _Template="nodes/resource_group/ajax/group_resources.tpl" />
</div>
1
0
r68 - core/db core/user domains/ci domains/ci/bin modules/identity
by cwalker@mcs.anl.gov 25 Apr '11
by cwalker@mcs.anl.gov 25 Apr '11
25 Apr '11
Author: cwalker
Date: 2011-04-25 17:04:30 -0500 (Mon, 25 Apr 2011)
New Revision: 68
Modified:
core/db/clsDBItem.php
core/user/ldap.php
domains/ci/bin/ci_import.php
domains/ci/resource_group.php
modules/identity/identity.php
Log:
debugged the import process for posix groups, cleaned up some context custom field issues that showed up.
Modified: core/db/clsDBItem.php
===================================================================
--- core/db/clsDBItem.php 2011-04-25 18:36:13 UTC (rev 67)
+++ core/db/clsDBItem.php 2011-04-25 22:04:30 UTC (rev 68)
@@ -6,8 +6,8 @@
public $Relations;
protected $uiRelations;
protected $bEnableCustomFields;
- protected $CustomFields;
- protected $CustomData;
+ public $CustomFields;
+ public $CustomData;
protected $ItemCache;
public $DB;
@@ -627,7 +627,11 @@
$arr = $this->doSelectSQL("SELECT * FROM {$this->table} {$where}");
$this->fillFromDBArray(@$arr[0]);
$this->clean();
- unset($arr);
+ //$this->LoadCustomFields();
+ if(@count($arr[0])>0)
+ {
+ // $this->LoadCustomData();
+ }
}
@@ -703,6 +707,12 @@
$this->fillFromDBArray((isset($arr[0])?$arr[0]:null));
}
$this->clean();
+ $this->LoadCustomFields();
+ if(@count($arr[0])>0)
+ {
+ $this->LoadCustomData();
+ }
+
return $this->get($this->primaryKey);
}
Modified: core/user/ldap.php
===================================================================
--- core/user/ldap.php 2011-04-25 18:36:13 UTC (rev 67)
+++ core/user/ldap.php 2011-04-25 22:04:30 UTC (rev 68)
@@ -6,16 +6,18 @@
{
public $server;
public $dn;
+ public $authdn;
public $uid_field;
private $data;
private $errors;
private $ds;
private $logger;
- function __construct($server="",$dn="")
+ function __construct($server="",$dn="",$authdn="")
{
$this->server = $server;
$this->dn = $dn;
+ $this->authdn = $authdn;
$this->data = false;
$this->ds = false;
$this->errors = array();
@@ -176,8 +178,12 @@
$this->connect();
if($this->ds)
{
- $result = @ldap_bind($this->ds,$this->uid_field."=".$username.",".$this->dn,addslashes($password));
- $bdn = $this->uid_field."=".$username.",".$this->dn;
+ $auth_dn = $this->authdn;
+ if(!strlen($auth_dn))
+ $auth_dn = $this->dn;
+
+ $result = @ldap_bind($this->ds,$this->uid_field."=".$username.",".$auth_dn,addslashes($password));
+ $bdn = $this->uid_field."=".$username.",".$auth_dn;
if($result)
{
Modified: domains/ci/bin/ci_import.php
===================================================================
--- domains/ci/bin/ci_import.php 2011-04-25 18:36:13 UTC (rev 67)
+++ domains/ci/bin/ci_import.php 2011-04-25 22:04:30 UTC (rev 68)
@@ -17,7 +17,7 @@
/* add script specific options */
$objOptions->AddOption("ldap_host","H","ldaphost",true,true,"LDAP Hostname","LDAP");
-$objOptions->AddOption("ldap_basedn","B","ldapbase",true,true,"LDAP Base DN","LDAP");
+$objOptions->AddOption("ldap_authdn","B","ldapdn",true,true,"LDAP Auth DN","LDAP");
$objOptions->AddOption("ldap_uidfield","U","ldapuid",true,true,"LDAP uid field name","LDAP");
$objOptions->AddOption("ldap_bind_user","","ldapuser",true,true,"LDAP Bind User");
$objOptions->AddOption("ldap_bind_pass","","ldappass",true,true,"LDAP Bind Password");
@@ -32,23 +32,24 @@
/* default to the shell user, if set */
if(!strlen($username))
{
- $username = GetArrayValue($_SERVER,"user","");
+ $username = @$_SERVER["user"];
if(strlen($username))
{
$objOptions->SetValue("username",$username);
}
}
+/* bootstrap the platform */
+include_once($pathtoroot."bin/include/cli_loader.php");
+
+
$objOptions->GetInteractiveValues();
$domain = $objOptions->GetValue("domain");
$ldap_host = $objOptions->GetValue("ldap_host");
-$ldap_base = $objOptions->GetValue("ldap_basedn");
+$ldap_base = $objOptions->GetValue("ldap_authdn");
$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
-/* bootstrap the platform */
-include_once($pathtoroot."bin/include/cli_loader.php");
-
/* The *userbase* username and password of the person running this script */
$username = $objOptions->GetValue("username");
$password = $objOptions->GetValue("password");
@@ -65,7 +66,7 @@
die('No LDAP Server provided');
if(strlen($ldap_base)==0)
- die('No LDAP Server provided');
+ die('No LDAP Base provided');
$objDomain = new clsDomainBase();
$objDomain->fetchByName($domain);
@@ -104,12 +105,13 @@
$a = getDomainObjectList("Account");
-$objLdap = new clsLdapServer($ldap_host,$ldap_base);
+$objLdap = new clsLdapServer($ldap_host,"",$ldap_base);
$objLdap->uid_field = $uidfield;
$objDB->doSQL("delete FROM {$objIdentityList->table}"); //delete all previous attempts
$objDB->doDeleteSQL("delete from IdentityAddress");
$objDB->doDeleteSQL("delete from IdentityEmail");
+$objDB->doDeleteSQL("delete from IdentityPhone");
$objDB->doDeleteSQL("delete from IdentityCredential");
$objDB->doDeleteSQL("delete from users WHERE domain_id=".getCurrentDomainId());
$objDB->doDeleteSQL("delete from users_groups WHERE group_id = 9");
@@ -122,6 +124,10 @@
$acr = getDomainObject("AccountResourceCredential");
$objCI_DB->doDeleteSQL("delete from {$acr->table}");
+$r = getDomainObject("Resource");
+$objCI_DB->doDeleteSQL("delete from {$r->table} WHERE owner_id=0");
+
+$objLdap->dn="ou=people,dc=ci,dc=uchicago,dc=edu";
if($objLdap->Query("(objectClass=inetOrgPerson)",$objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
{
$p = $objLdap->GetResult(0);
@@ -271,7 +277,7 @@
$sponsors = explode(",",$sponsor);
foreach($sponsors as $sp)
{
- $Sponsor = new Identity();
+ $objSponsor = new Identity();
if(strpos($sp,"@")>0)
{
$objSponsor->fetchByEmailAddress($sp);
@@ -280,7 +286,7 @@
{
$objSponsor->fetchByName($sp);
}
- if($Sponsor->get("id")>0)
+ if($objSponsor->get("id")>0)
{
$req->AddSponsor($objSponsor);
}
@@ -302,8 +308,9 @@
$objResourceAPI = getDomainObject("clsResourceActions");
-$objLdap->dn = "ou=netgroups,dc=ci, dc=uchicago, dc=edu";
-if($objLdap->Query("(objectClass=nisNetgroup)",$username,$password))
+$objLdap->dn = "ou=netgroups,dc=ci,dc=uchicago,dc=edu";
+
+if($objLdap->Query("(objectClass=nisNetgroup)",$objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
{
$p = $objLdap->GetResult(0);
$num_entries = $objLdap->NumRecords();
@@ -361,25 +368,39 @@
}
}
}
+else
+ echo "Error: Unable to query netgroups\n";
+$errors = $objLdap->GetErrors();
+if(count($errors)>0)
+{
+ echo "LDAP errors: \n";
+ print_r($objLdap->GetErrors());
-$objLdap->dn = "ou=group, dc=ci, dc=uchicago, dc=edu";
-if($objLdap->Query("(objectClass=posixGroup)",$username,$password))
+}
+
+
+$objLdap->dn = "ou=group,dc=ci,dc=uchicago,dc=edu";
+if($objLdap->Query("(objectClass=posixGroup)",$objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
{
- $objResouceGroup = getDomainObject("ResourceGroup");
+ echo "Importing posix groups..\n";
+ $objResourceGroup = getDomainObject("ResourceGroup");
$objResourceGroup->fetchByValue(array("name"=>"Unix Groups"));
+ echo "Fround Resourcegroup {$objResourceGroup->GetDefaultText()}\n";
if($objResourceGroup->get("id")>0)
{
$num_entries = $objLdap->NumRecords();
+ echo $num_entries." groups to import to {$objResourceGroup->GetDefaultText()}\n";
for($rec=0;$rec<$num_entries;$rec++)
{
$group_name = $objLdap->GetResultAttribute($rec,"cn");
$objResource = $objResourceGroup->fetchResource(array("name"=>$group_name));
+ $objResource->LoadCustomFields();
if(!$objResource->get("id"))
{
echo "Creating resource $group_name \n";
$objResource->set("name",$group_name);
$objResource->set("brief_description",$objLdap->GetResultAttribute($rec,"description"));
- $objResource->set("gidNumber",$objLdap->GetResultAttribute($rec,"gidNumber"));
+ $objResource->set("gidNumber",$objLdap->GetResultAttribute($rec,"gidnumber"));
$objResource->set("state","active");
$objResource->set("accepts_domain_pw",0);
$objResource->set("public",0);
@@ -390,6 +411,12 @@
$objResourceGroup->AddResource($objResource);
}
$members = $objLdap->GetResultAttribute($rec,"memberUid");
+ if(!is_array($members) && strlen($members)>0)
+ {
+ $members = array($members);
+ }
+ if(is_array($members))
+ {
foreach($members as $account_username)
{
$objAccount = getDomainObject("Account");
@@ -401,9 +428,22 @@
echo "Assigning User {$objID->get("id")} Account {$objAccount->GetDefaultText()} to Resource {$objResource->GetDefaultText()}\n";
}
}
+ }
}
}
}
+else
+{
+ echo "Error: Unable to query posix groups\n";
+}
+$errors = $objLdap->GetErrors();
+if(count($errors)>0)
+{
+ echo "LDAP errors: \n";
+ print_r($objLdap->GetErrors());
+}
+
+
$objLdap->disconnect();
?>
Modified: domains/ci/resource_group.php
===================================================================
--- domains/ci/resource_group.php 2011-04-25 18:36:13 UTC (rev 67)
+++ domains/ci/resource_group.php 2011-04-25 22:04:30 UTC (rev 68)
@@ -50,7 +50,9 @@
{
$search[] = array("group_id"=>$this->get("id"));
$objResource = getDomainObject("Resource");
- return $objResource->fetchByValue($search,$operator);
+ $objResource->SetContext($this->className,$this->get("id"));
+ $objResource->fetchByValue($search,$operator);
+ return $objResource;
}
/* methods required by iResourceGroup */
@@ -205,4 +207,4 @@
}
}
-?>
\ No newline at end of file
+?>
Modified: modules/identity/identity.php
===================================================================
--- modules/identity/identity.php 2011-04-25 18:36:13 UTC (rev 67)
+++ modules/identity/identity.php 2011-04-25 22:04:30 UTC (rev 68)
@@ -960,7 +960,7 @@
{
$data["identity_id"] = $this->get("id");
$api = getApiObject("identityphone");
- if(!$EmailId)
+ if(!$PhoneId)
{
$a = $api->add($data);
}
@@ -1483,13 +1483,14 @@
public function assign_resource($IdentityId=null,$objResource=null, $objAccount=null,$arrIdentityCredentials=null)
{
$ret = false;
+
+ $form = $this->getFormData("form");
if(is_null($IdentityId) || (int)$IdentityId==0)
{
$IdentityId = getItemId();
}
if(is_null($objResource))
{
- $form = $this->getFormData("form");
$objResource = getDomainObject("Resource",GetArrayValue($form,"resource"));
}
if(is_null($objAccount) && GetArrayValue($form,"account_id",0)>0)
@@ -1847,4 +1848,4 @@
}
}
-?>
\ No newline at end of file
+?>
1
0