本文整理汇总了PHP中DB_DataObject::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP DB_DataObject::factory方法的具体用法?PHP DB_DataObject::factory怎么用?PHP DB_DataObject::factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_DataObject
的用法示例。
在下文中一共展示了DB_DataObject::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
function post()
{
$si = DB_DataObject::factory('Signup');
if (empty($_REQUEST['id']) || !$si->get($_REQUEST['id'])) {
$this->jerr("invalid request");
}
if ($si->person_id != 0) {
$si->jerr("Account already processed");
}
// rejected..
if ($_REQUEST['person_id'] < 0) {
$si->setFrom($_REQUEST);
$si->update();
$this->jok("OK");
}
$p = DB_DataObject::factory("core_person");
$p->setFrom($_REQUEST);
$p->insert();
$si->setFrom($_REQUEST);
$si->person_id = $p->id;
$si->update();
// generate a password
// and send welcome message.
$this->jok($p->toArray());
}
示例2: listGroupMembership
/**
* Get a list of memberships for a person
* @param Pman_Core_DataObjects_Person $person who
* @param String column to fetch.. eg. group_id or 'name'
*
*/
function listGroupMembership($person, $arrayof = 'group_id')
{
$this->inAdmin = false;
$t = clone $this;
//DB_DataObject::debugLevel(1);
$grp = DB_DataObject::factory('core_group');
$t->joinAdd($grp, 'LEFT');
//$person->id = (int)$person->id;
$t->whereAdd("\n user_id = {$person->id}\n ");
$t->selectAdd();
$t->selectAdd("distinct(group_id), {$grp->tableName()}.name as name");
$t->whereAdd('group_id IS NOT NULL');
$t->find();
$ret = array();
// $ret = $arrayof == 'group_id' ? array(0) : array();
// default member of 'All groups'!!
while ($t->fetch()) {
$ret[] = $t->{$arrayof};
if ($t->name == 'Administrators') {
/// mmh... bit risky?
$this->inAdmin = true;
}
}
if ($arrayof == 'group_id' && !count($ret)) {
$ret = array(0);
/// default if they are not a member of any group.
}
//var_dump($ret);
return $ret;
}
示例3: makeEditForm
function makeEditForm($selfurl)
{
// nice names for each field
$formNames = array('cfg_incoming_path' => 'Kannel Incoming Path: ', 'cfg_username' => 'Username:', 'cfg_password' => 'Password:', 'cfg_global_sender' => 'Global Sender:', 'cfg_bearerbox_host' => 'Bearerbox IP:', 'cfg_sendsms_port' => 'Send SMS Port:', 'cfg_playsms_web' => 'PlaySMS web url:', 'cfg_restart_frequency' => 'Restart Kannel Regularly?');
// infer the fields we're going to show
// from the list of formNames
$renderFields = array();
foreach ($formNames as $field => $name) {
$renderFields[] = $field;
}
// find the first record in the config table
$do = DB_DataObject::factory('playsms_gwmodKannel_config');
$do->get(1);
// create the form with the user-showable names
$fb = DB_DataObject_FormBuilder::create($do, array("fieldLabels" => $formNames, "fieldsToRender" => $renderFields));
// set up enums
$fb->enumFields = array('cfg_restart_frequency');
$form = $fb->getForm("{$selfurl}");
if ($form->validate()) {
$err = "Gateway module configurations has been saved";
print "<p><font color=red>{$err}</font><p>";
$form->process(array(&$fb, 'processForm'), false);
}
$form->display();
echo "<p/><hr/><p/>";
echo "<a href=\"plugin/gateway/kannel/kannel-monitor/\">[ Monitor Status ]</a> \n";
echo "<a href=\"{$selfurl}&op=manage_smsc\">[ Bind SMSC ]</a>";
}
示例4: delete
public function delete()
{
$log = DB_DataObject::factory('log');
$log->id_users = $this->id;
$this->user_log(e('log_cleanup', array($log->delete())));
redirect('log');
}
示例5: init
function init($pg)
{
$group = DB_DataObject::factory('core_group');
// group should be auto created - by update-database...
if (!$group->get('name', 'core-person-signup-bcc')) {
$group = DB_DataObject::factory('core_group');
$group->name = 'core-person-signup-bcc';
$group->insert();
}
$p = DB_DataObject::factory('core_person');
if (!$p->count()) {
return;
// can not check people...
}
// got people...
$member = DB_DataObject::factory('core_group_member');
$member->group_id = $group->id;
if ($member->count()) {
return;
}
// not got members..
// if we only have one member - then add it .... (it's the admin, and they can modify this later.. - after they get annoyed with it..
$p->find(true);
$member = DB_DataObject::factory('core_group_member');
$member->group_id = $group->id;
$member->user_id = $p->id;
$member->insert();
// only display if we have members..
}
示例6: makeEditForm
function makeEditForm($selfurl)
{
// nice names for each field
$formNames = array('cfg_web_title' => 'Website title:', 'cfg_web_url' => 'Website URL:', 'cfg_email_service' => 'Website email', 'cfg_email_footer' => 'Forwarded email footer:', 'cfg_gateway_module' => 'Activated gateway module:', 'cfg_gateway_number' => 'Gateway number:', 'cfg_system_from' => 'System messages <br/> (e.g., balance updates) are sent from:', 'cfg_system_restart_frequency' => 'Restart the entire system regularly?');
// infer the fields we're going to show
// from the list of formNames
$renderFields = array();
foreach ($formNames as $field => $name) {
$renderFields[] = $field;
}
// List of gateway plugins.
// TODO: make this get listing of the gw plugin files
// rather than be hard-coded
$gw_mods = array("kannel" => "Kannel", "gnokii" => "Gnokii", "uplink" => "UpLink", "clickatell" => "ClickAtell");
// find the first record in the config table
$do = DB_DataObject::factory(playsms_tblConfig_main);
$do->find();
$do->fetch();
// create the form with the user-showable names
$fb = DB_DataObject_FormBuilder::create($do, array("fieldLabels" => $formNames, "fieldsToRender" => $renderFields));
$fb->submitText = "Save";
// set up gw_mod enum
$fb->enumFields = array('cfg_gateway_module', 'cfg_system_restart_frequency');
$fb->enumOptions = array('cfg_gateway_module' => $gw_mods);
$form = $fb->getForm("{$selfurl}");
if ($form->validate()) {
$err = "Main configuration has been saved";
print "<p><font color=red>{$err}</font><p>";
$form->process(array(&$fb, 'processForm'), false);
}
$form->display();
}
示例7: execute
function execute(&$controller, &$request, &$user)
{
$member = $user->getAttribute('member', GLU_NS);
// my feeds
$source = DB_DataObject::factory('source');
$source->whereAdd('member_id = ' . $source->escape($member->id));
if ($request->hasParameter('id')) {
$source->whereAdd('id = ' . $source->escape($request->getParameter('id')));
}
$source->find();
$feeds = array();
while ($source->fetch()) {
$rss = new FeedParser($source->uri);
$rss->parse();
foreach ($rss->getItems() as $item) {
$feed['id'] = $source->id;
$feed['title'] = $item['title'];
$feed['link'] = $item['link'];
$feed['description'] = isset($item['description']) ? $item['description'] : '';
$feed['date'] = isset($item['dc:date']) ? $item['dc:date'] : (isset($item['date']) ? $item['date'] : '');
$feeds[] = $feed;
}
}
$haj = new HTML_AJAX_JSON();
$output = $haj->encode($feeds);
header('Content-Type: application/x-javascript; charset=utf-8');
echo $output;
return VIEW_NONE;
}
示例8: populateCMS
protected function populateCMS($action)
{
try {
$content = Mreg::get('content');
} catch (Exception $e) {
$content = DB_DataObject::factory($this->_dbtable);
}
if (!$this->_forceaccessible && !empty($this->_dbaccessibleaspage)) {
$content->{$this->_dbaccessibleaspage} = 1;
}
if (key_exists('alias_id', $content->table())) {
$content->whereAdd('alias_id is null');
}
if (!$content->get($this->_dbstrip, $action)) {
$this->handleNotFound($action);
return;
}
if ($content->{$this->_dbisnode}) {
$target = strtolower(str_replace('Module_', '', get_class($this))) . '/' . $content->getPlugin('tree')->getFirstChild($content)->{$this->_dbstrip};
$this->redirect301($target);
}
$this->assignRef('content', $content);
$this->_content = $content;
try {
Mreg::set('content', $content);
} catch (Exception $e) {
}
$this->assign($this->_tpltitle, $content->{$this->_dbtitle});
}
示例9: del
function del($params)
{
$json = new Services_JSON();
$subcategory = DB_DataObject::factory("subcategory");
$subcategory->id = $params["id"];
print $subcategory->delete() ? $json->encode(array("error" => false)) : $json->encode(array("error" => true));
}
示例10: update
public function update()
{
$id = $this->request['id_arc'];
$this->check_permissons('arcanums', $id);
$old_arc = DB_DataObject::factory('arcanums');
$old_arc->get($id);
$portalid = $old_arc->id_portals;
//!!!
//olds to active = n
$old_arcs = DB_DataObject::factory('arcanums');
$old_arcs->id_portals = $portalid;
if ($old_arcs->find()) {
while ($old_arcs->fetch()) {
$n_enc = $this->arc_encrypt_input('n');
if ($old_arcs->active != $n_enc) {
$old_arcs->active = $n_enc;
$old_arcs->update();
}
}
}
$new_arcanum = DB_DataObject::factory('arcanums');
$new_arcanum->id_portals = $portalid;
$this->request['active'] = "y";
$this->request['created'] = TIME;
$new_arcanum = $this->arc_encrypt_input($new_arcanum, $this->request);
$new_arcanum->insert();
$this->content = 1;
$port = DB_DataObject::factory('portals');
$port->get($portalid);
$portal = $this->arc_decrypt_output($port->name);
$this->user_log(e('arcanums_changes') . ': [' . $portal . ']');
$this->useview = FALSE;
}
示例11: execute
function execute(&$controller, &$request, &$user)
{
$account = $request->getParameter('account');
$request->setAttribute('account', $account);
$count = $request->hasParameter('count') ? $request->getParameter('count') : 16;
$callback = $request->hasParameter('callback') ? $request->getParameter('callback') : false;
$request->setAttribute('callback', $callback);
$raw = $request->hasParameter('raw') ? true : false;
$request->setAttribute('raw', $raw);
$member = DB_DataObject::factory('member');
$member->get('account', $account);
$site = DB_DataObject::factory('site');
$site->get('member_id', $member->id);
$feed = array();
$feed['uri'] = SCRIPT_PATH . "{$member->account}/";
$feed['title'] = $site->title;
$feed['description'] = $site->description;
$feed['author'] = $member->account;
$entries = EntryUtils::get_entries_by_account($account, $count);
foreach ($entries as $key => $entry) {
$entry['tags'] = TagUtils::get_tags_by_entry_id($entry['id']);
$entries[$key] = $entry;
}
$feed = $feed + $entries;
$request->setAttribute('feed', $feed);
$request->setAttribute('entries', $entries);
return VIEW_SUCCESS;
}
示例12: pkeyGet
/**
* @fixme Should this return false on lookup fail to match staticGet?
*/
function pkeyGet($cls, $kv)
{
$i = Memcached_DataObject::multicache($cls, $kv);
if ($i !== false) {
// false == cache miss
return $i;
} else {
$i = DB_DataObject::factory($cls);
if (empty($i) || PEAR::isError($i)) {
return false;
}
foreach ($kv as $k => $v) {
$i->{$k} = $v;
}
if ($i->find(true)) {
$i->encache();
} else {
$i = null;
$c = self::memcache();
if (!empty($c)) {
$ck = self::multicacheKey($cls, $kv);
$c->set($ck, null);
}
}
return $i;
}
}
示例13: execute
function execute(&$controller, &$request, &$user)
{
$account = $request->getParameter('account');
$format = $request->hasParameter('format') ? $request->getParameter('format') : 'html';
$member = DB_DataObject::factory('member');
$member->get('account', $account);
$site = DB_DataObject::factory('site');
$site->get('member_id', $member->id);
$feed = DB_DataObject::factory('feed');
$feeds = $feed->getListsByAccount($account);
switch ($format) {
case 'opml11':
foreach ($feeds as $key => $feed) {
$f = array('title' => $feed->title, 'text' => $feed->description, 'link' => $feed->link, 'uri' => $feed->uri);
$feeds[$key] = $f;
}
$writer =& new OPMLWriter();
$writer->setHead(array('title' => $site->title, 'date' => time(), 'owner' => $account));
$writer->setOutlines($feeds);
$writer->display($format);
return VIEW_NONE;
case 'html':
default:
$request->setAttribute('sources', $feeds);
return VIEW_SUCCESS;
}
}
示例14: execute
function execute(&$controller, &$request, &$user)
{
$member = $user->getAttribute('member', GLU_NS);
$user->setAttribute('member', $member, GLU_NS);
$custom = $request->hasParameter('custom_design_submit') ? $request->getParameter('custom_design_submit') : null;
if ($custom) {
$ct = DB_DataObject::factory('custom_template');
$ct->member_id = $member->id;
if ($ct->count() > 0) {
$ct->get('member_id', $member->id);
$ct->template = $request->getParameter('css');
$ct->update();
} else {
$ct->member_id = $member->id;
$ct->template = $request->getParameter('css');
$ct->insert();
}
Controller::redirect(SCRIPT_PATH . 'setting/design/changed_custom');
} else {
$member->design_id = $request->getParameter('design_id');
$member->update();
Controller::redirect(SCRIPT_PATH . 'setting/design/changed');
}
return VIEW_NONE;
}
示例15: execute
function execute(&$filterChain, &$controller, &$request, &$user)
{
$loaded =& $request->getAttribute('AutoLoginFilter');
if ($loaded == null) {
$token = isset($_COOKIE['token']) ? $_COOKIE['token'] : null;
if ($token and !$user->isAuthenticated()) {
list($id, $password) = split('-', $token);
$member = DB_DataObject::factory('member');
$member->get($id);
if ($member->password == $password) {
$user->setAuthenticated(true);
$user->addPrivilege('member', GLU_NS);
$user->setAttribute('member', $member, GLU_NS);
// added cookie liftime for footprint
/*
setcookie(
'token', $token, time() + PLNET_LOGIN_LIFETIME
);
*/
}
}
$filterChain->execute($controller, $request, $user);
} else {
$filterChain->execute($controller, $request, $user);
}
}