All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
  Print view

call node (add functionality) from another node
Author Message
PostPosted: Fri Mar 08, 2013 3:13 pm 
Offline

Joined: Wed Jul 18, 2012 11:02 am
Posts: 7
I have a node called class.account.inc where I can add/edit/delete users. On top it'll create/delete a directory for each user and do a few other things.

What I would like to do is to call the account node from a different node with all the information to add a new user (username, password, etc.). I want it to behave the same way it does when I add a user via the webinterface.

I tried to do it with addDb but all it does is an INSERT. None of the other functionality like checking if the username is unique, hash the password, etc. is working.
Code:
$user = array ('username' => 'user01', 'password' => 'qwert');
$account_node = &atkGetNode("account.account");
$account_node->addDb($user);



Can anyone help please?

Thanks,
Björn


Top
 Profile  
 

Re: call node (add functionality) from another node
PostPosted: Wed Mar 13, 2013 6:34 am 
Regular
User avatar
Offline

Joined: Thu Aug 25, 2011 9:31 pm
Posts: 310
Location: Mumbai, India
if "... I want it to behave the same way it does when I add a user via the webinterface" means adding from outside atk the following code may help.

Code:
<?php

$config_atkroot = "./";
require_once("atk.inc");
atkimport("atk.ui.atkpage");
atksession();

$session = &atkSessionManager::getSession();
/* Fake the login process */
$session["login"]=1;
atksecure();

/* setup a new "page" and load ui, theme, css, and js */
$page = &atknew("atk.ui.atkpage");
$ui = &atkinstance("atk.ui.atkui");
$theme = &atkTheme::getInstance();
$pagecontent = atkOutput::getInstance();
$page->register_style($theme->stylePath("style.css"));
$page->register_script(atkconfig("atkroot")."atk/javascript/launcher.js");

/* get the node we want to work with */
$node = "request.request_quot"; // ur module/node
$nodeObj = &atkGetNode($node);


$record = $nodeObj->initial_values();


/* set the action we want to do */
$action = "add";
$handler = $nodeObj->getHandler($action);


/* if the action is changed the invoke page needs to be changed also. */
$display = $nodeObj->renderActionPage($action, $handler->invoke("addPage", array()));
$page->addContent($display);

/* display the whole thing, also set the page title */
$pagecontent->output($page->render(atktext('Add Page'), true));
$pagecontent->outputFlush(); // This shows AddLink and accepts data  but on Clicking Save&Close -> does not save


// Control never reaches to following

//echo  $_GET["doc_no"];
//echo  $_GET["company_name"];
$record = array();
$record['doc_no'] = $_GET["doc_no"];
$record['company_name'] = $_GET["company_name"];
atk_var_dump($record);
$result = $nodeObj->addDb($record);

?>


Top
 Profile  
 

Re: call node (add functionality) from another node
PostPosted: Wed Mar 13, 2013 6:38 am 
Regular
User avatar
Offline

Joined: Thu Aug 25, 2011 9:31 pm
Posts: 310
Location: Mumbai, India
search "glue" on forum


[url]
viewtopic.php?f=2&t=6161
[/url]


Top
 Profile  
 

Re: call node (add functionality) from another node
PostPosted: Wed Mar 13, 2013 12:03 pm 
Offline

Joined: Wed Jul 18, 2012 11:02 am
Posts: 7
Thanks for the input dgangal!

dgangal wrote:
If "... I want it to behave the same way it does when I add a user via the webinterface" means adding from outside atk the following code may help.


Yes outside atk. But I don't want to create a webpage I'm trying to set up the same functionality the webpage gives you as a webservice with nusoap. In this case add/modify/delete account.

To give a very specific example:
If I add an account via the webgui the following will happen:
1. accountname will be checked if it is unique
2. the password string will be checked against all the restrictions I configured in config.inc.php like config_password_minsize, etc.
2. the password gets hashed
3. the accountname and password hash will be written to the db

Do you know how I can achieve the same from php CLI? Adding a new account & password without checking manually if the accountname is unique and checking manually if all the password restrictions are fulfilled?

Thanks,
Björn


Top
 Profile  
 

Re: call node (add functionality) from another node
PostPosted: Fri Mar 15, 2013 5:38 am 
Regular
User avatar
Offline

Joined: Thu Aug 25, 2011 9:31 pm
Posts: 310
Location: Mumbai, India
i will have to disappoint u here .... i do not have much knowledge on this. Apologies.


Top
 Profile  
 

Re: call node (add functionality) from another node
PostPosted: Fri Aug 25, 2017 5:04 pm 
Regular
User avatar
Offline

Joined: Thu Aug 25, 2011 9:31 pm
Posts: 310
Location: Mumbai, India
For accessing atk node from outside without formal login form following $session["login"]=1; fakes atk and allows login and works fine.

$session = &atkSessionManager::getSession();
/* Fake the login process */
$session["login"]=1;


My query is - if additionally i wish to fake a specific userid as if that user has logged in .... which session vars have to be set --- something similarl

$session["userid"]='xxx'; //fake xxx has loggedin ..... it does NOT work


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group