miland
Posts: 31
|
Posted: 05/10/2006, 1:59 PM |
|
I'm modifying a CCS generated Login page to use LDAP instead of a MySQL user table for authenicating. Before the page even shows, I call a function to populate a listbox within the form that has the "context" for login (what location are you at). Anyway, I can't get the listbox to populate with the array of contexts. Does anyone have any suggestions?
The below is in my login_events.php:
function Page_BeforeShow(& $sender)
{
$Page_BeforeShow = true;
$Component = & $sender;
$Container = CCGetParentContainer($sender);
global $login; //Compatibility
//End Page_BeforeShow
//Custom Code @36-2A29BDB7
// -------------------------
// Write your own code here.
//Calls method from ldapMethods in common.php to connect annon. and get contexts.
$contexts = connectAnon();
$count = count($contexts);
//print_r($contexts);
for($i=0;$i<$count;$i++)
{
//echo "<option value = '$contexts[$i]'>$contexts[$i]</option>";
$login->ListBox1->Values[] = array($contexts[$i], $contexts[$i]);
}
// -------------------------
//End Custom Code
//Close Page_BeforeShow @1-4BC230CD
return $Page_BeforeShow;
}
//End Close Page_BeforeShow
|
|
|
Damian Hupfeld
|
Posted: 05/10/2006, 3:06 PM |
|
Can you get it to display the contexts in a label?
"miland" <miland@forum.codecharge> wrote in message
news:5446254346813b@news.codecharge.com...
> I'm modifying a CCS generated Login page to use LDAP instead of a MySQL
> user
> table for authenicating. Before the page even shows, I call a function to
> populate a listbox within the form that has the "context" for login (what
> location are you at). Anyway, I can't get the listbox to populate with
> the
> array of contexts. Does anyone have any suggestions?
>
> The below is in my login_events.php:
>
> function Page_BeforeShow(& $sender)
> {
> $Page_BeforeShow = true;
> $Component = & $sender;
> $Container = CCGetParentContainer($sender);
> global $login; //Compatibility
> //End Page_BeforeShow
>
> //Custom Code @36-2A29BDB7
> // -------------------------
> // Write your own code here.
> //Calls method from ldapMethods in common.php to connect annon. and get
> contexts.
> $contexts = connectAnon();
>
> $count = count($contexts);
> //print_r($contexts);
> for($i=0;$i<$count;$i++)
> {
> //echo "<option value = '$contexts[$i]'>$contexts[$i]</option>";
> $login->ListBox1->Values[] = array($contexts[$i], $contexts[$i]);
> }
>
> // -------------------------
> //End Custom Code
>
> //Close Page_BeforeShow @1-4BC230CD
> return $Page_BeforeShow;
> }
> //End Close Page_BeforeShow
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
miland
Posts: 31
|
Posted: 05/10/2006, 4:35 PM |
|
Would the correct syntax for getting them into a label be:
$login->Label1->SetValue(array($contexts[$i], $contexts[$i]));
|
|
|
feha
Posts: 712
|
Posted: 05/11/2006, 12:34 AM |
|
Try This
for($x= 0; $x< Count($contexts)-1; $x++)
$Array_Values[ ] = array($contexts [$j], $listboxval[++$j]);
$Container->ListBox1->Values = $Array_Values;
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
feha
Posts: 712
|
Posted: 05/11/2006, 12:36 AM |
|
correction:
for($x= 0; $x< Count($contexts)-1; $x++)
$Array_Values[ ] = array($contexts [$x], $contexts[++$x]);
$Container->ListBox1->Values = $Array_Values;
adapted for your case
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
feha
Posts: 712
|
Posted: 05/11/2006, 12:41 AM |
|
i don't know what separator is used in your $contexts array ?
// global $contexts;
$listbox_values = split(";",$contexts);
for($x= 0; $x< Count($listbox_values )-1; $x++)
$Array_Values[ ] = array($listbox_values[$x], $listbox_values [++$x]);
$Container->ListBox1->Values = $Array_Values;
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
feha
Posts: 712
|
Posted: 05/11/2006, 12:42 AM |
|
or you can use faster one explode
$listbox_values = explode(";",$contexts);
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
Damian Hupfeld
|
Posted: 05/11/2006, 4:04 AM |
|
That was some journey!
"feha" <feha@forum.codecharge> wrote in message
news:54462eaf93479c@news.codecharge.com...
> or you can use faster one explode
>
>
> $listbox_values = explode(";",$contexts);
>
> _________________
> Regards
> feha
> Vision.To Design
> www.vision.to
> wowdev.com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
feha
Posts: 712
|
Posted: 05/11/2006, 6:07 AM |
|
Quote :That was some journey!
Hope the Worth one ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
miland
Posts: 31
|
Posted: 05/11/2006, 8:21 AM |
|
I still am unable to get the above suggestions to work. This what I can get to work. My $contexts array has the following values:
Array ( [0] => ROANOKE [1] => MARIETTA [2] => BELAIR [3] => CHARLOTTE [4] => TAMPA [5] => MIAMI )
The before show code looks like this:
function Login_BeforeShow(& $sender)
{
$Login_BeforeShow = true;
$Component = & $sender;
$Container = CCGetParentContainer($sender);
global $Login; //Compatibility
//End Login_BeforeShow
//Custom Code @36-2A29BDB7
// -------------------------
// Write your own code here.
//Calls method from ldapMethods to
//connect annon. and get contexts.
$contexts = connectAnon();
$Login->ListBox1->Values = array_values($contexts);
// -------------------------
//End Custom Code
//Close Login_BeforeShow @29-95DE33DE
return $Login_BeforeShow;
}
//End Close Login_BeforeShow
Now, the listbox returns the following:
SELECT VALUE
O
A
E
H
A
I
If you look at the contents of $contexts (Array ( [0] => ROANOKE [1] => MARIETTA [2] => BELAIR [3] => CHARLOTTE [4] => TAMPA [5] => MIAMI ) ), the listbox is getting the 2nd letter of each word.
What am I doing wrong?
|
|
|
feha
Posts: 712
|
Posted: 05/11/2006, 8:32 AM |
|
try this:
for($x= 0; $x< Count($contexts)-1; $x++)
$Array_Values[ ] = array($contexts [++$x], $contexts[$x]);
$Container->ListBox1->Values = $Array_Values;
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
feha
Posts: 712
|
Posted: 05/11/2006, 8:35 AM |
|
you are not doing wrong if this is an automated array not created by you...
than her is the key second parameter not the first one ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
feha
Posts: 712
|
Posted: 05/11/2006, 8:40 AM |
|
many arrays are formed this way:
array(1=>"info_1", 2=>"info_2", 3=>"info_3", 4=>"info_4", 5=>"info_5");
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
miland
Posts: 31
|
Posted: 05/11/2006, 8:45 AM |
|
That helped, alot! I've got 3 of the 6 names in the listbox now. What should I change in the "for" to get all 6?
|
|
|
feha
Posts: 712
|
Posted: 05/11/2006, 9:02 AM |
|
the first array and last one is deffect ...
Array ( SOMETHING[0] => ROANOKE [1] => MARIETTA [2] => BELAIR [3] => CHARLOTTE [4] => TAMPA [5] => MIAMI[6]
and this is without minus (-1)
for($x= 0; $x< Count($contexts); $x++)
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
feha
Posts: 712
|
Posted: 05/11/2006, 9:52 AM |
|
some more info about LDAP http://www.php.net/manual/en/ref.ldap.php
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
miland
Posts: 31
|
Posted: 05/11/2006, 10:17 AM |
|
Finally, got all the values in the listbox. Thank you so much for your help! This is what I ended up with:
//Calls method from ldapMethods to
//connect annon. and get contexts.
$contexts = connectAnon();
for($x= 0; $x < Count($contexts); $x++)
{
$Array_Values[] = array($contexts[$x], $contexts[$x]);
}
$Container->ListBox1->Values = $Array_Values;
|
|
|
feha
Posts: 712
|
Posted: 05/11/2006, 11:06 AM |
|
Great , Ejoy
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|