Kohana "has many" issue - kohana-3

I have a model named permission.
Permission has many roles
permission has many users
permission has many denied users
Below is from the permissions model:
protected $_has_many = array(
'user' => array('through' => 'user_permission'),
'permissiondeny' => array('model' => 'user', 'through' => 'user_permissiondeny','foreign_key' => 'permissiondeny_id'),
'role' => array('through' => 'role_permission'),
);
The user and role relationships work as expected. I can select the deny permission, but when I try to add a new one I get the following php error:
PHP Fatal error: Uncaught Database_Exception [ 1110 ]: Column 'permissiondeny_id' specified twice [ INSERT INTO user_permissiondeny (permissiondeny_id, permissiondeny_id) VALUES ('1', 1) ] ~ MODPATH/database/classes/kohana/database/mysql.php [ 194 ]
Any suggestions as to what I'm missing?

Since you are not following the naming conventions in ORM, you need to change your has_many declaration:
protected $_has_many = array(
'user' => array('through' => 'user_permission'),
'permissiondeny' => array('model' => 'user', 'through' => 'user_permissiondeny','foreign_key' => 'permissiondeny_id', 'far_key' => 'permission_id'),
'role' => array('through' => 'role_permission'),
);
note the far_key part, you need to specify the name of the column that you'll be looking for. may it be user_id, role_id, permission_id, etc

Related

Is there a way to query entries and categories together in Craft 3?

'm working on a global site search ( autocomplete ), right now it have almost all entries ( that have uri defined ) for results, it uses js fetch and Craft element api in a json file that filter results based on a query string. Works great!
I was wondering if it's possible to add to the query categories too, i don't know if this is possible buy maybe it's a way to merge them, here is my json api code, thanks!
'search.json' => function() {
$qParam = Craft::$app->request->getParam('q');
return [
'elementType' => Entry::class,
'paginate' => false,
'criteria' => [
'uri'=> ':notempty:',
'search' => $qParam,
'orderBy' => 'score',
'limit' => 20,
],
'cache' => false,
'transformer' => function(Entry $item) {
return [
'title' => $item->title,
'url' => $item->url,
];
},
];
}

DOCUSIGN - Getting other tabs or fields to populate within the docusign signing process

Here is some of my PHP code I am using which works to grab the signature of the user no problem.However when I attempt to add another field for "datestart" I get nothing to show up on the PDF document within Docusign Demo. So basically I'm unable to get any other fields to populate within my Docusign signature besides the signature name and email when it comes to the signing part. Am I doing something wrong within my code? I used the code examples that docusign provided but with no luck.
More Insight: I am just trying to populate basic text fields that docusign provides. Nothing else at the moment.
# The signer object
$signer = new DocuSign\eSign\Model\Signer([
'email' => $signerEmail, 'name' => $signerName, 'recipient_id' => "1", 'routing_order' => "1",
'client_user_id' => $clientUserId # Setting the client_user_id marks the signer as embedded
]);
$signHere = new DocuSign\eSign\Model\SignHere([ # DocuSign SignHere field/tab
'document_id' => '1',
'page_number' => '2',
'recipient_id' => '1',
'tab_label' => 'Signaturebottom',
'x_position' => '71',
'y_position' => '629'
]);
//Here is the tab+text I am having troubles getting to show up below within my docusign pdf
//Just need extra fields to populate like dates and other peoples names and mailing address etc.
$tripdates = new DocuSign\eSign\Model\Text([
'anchor_string' => '/dateone/', 'anchor_units' => 'pixels',
'anchor_y_offset' => '409', 'anchor_x_offset' => '105',
'font' => "helvetica", 'font_size' => "size11",
'bold' => 'true', 'value' => "test",
'locked' => 'true', # mark the field as readonly
'tab_id' => 'datestart', 'tab_label' => 'datestart'
]);
# Add the tabs to the signer object
# The Tabs object wants arrays of the different field/tab types
$signer->setTabs(new DocuSign\eSign\Model\Tabs(
['sign_here_tabs' => [$signHere],
'text_tabs' => [$tripdates]
]));
# Next, create the top level envelope definition and populate it.
$envelopeDefinition = new DocuSign\eSign\Model\EnvelopeDefinition([
'email_subject' => "Please sign this document",
'documents' => [$document], # The order in the docs array determines the order in the envelope
'recipients' => new DocuSign\eSign\Model\Recipients(['signers' => [$signer]]), # The Recipients object wants arrays for each recipient type
'status' => "sent" # requests that the envelope be created and sent.
]);
Could it be because you're missing these:
'document_id' => '1',
'page_number' => '2',
'recipient_id' => '1',
Which you had for the signerTab but not for the textTab?

Typo3: Where can i get list of TCA types?

I have bodytext and image so like this type of list where can I found? Can I get page list in select box?
$GLOBALS['TCA']['tt_content']['types']['text_image_left'] = [
'showitem' => '
--palette--;palette.general;general,
header, subheader, header_layout,menu,
bodytext;bodytext_formlabel,
--div--;tabs.images,
image,
--div--;tabs.appearance,
--palette--;palette.frames;frames,
--div--;tabs.access,
hidden;field.default.hidden,
--div--;tabs.extended
',
'columnsOverrides' => ['bodytext' => ['config' => ['enableRichtext' => true]]]
];
Hm, not sure if I get your question right. You asked
1. for a list of TCA types
2. how to get a list of pages in a select field (?)
You can find the complete TCA Documentation here:
https://docs.typo3.org/m/typo3/reference-tca/master/en-us/
Interesting part for you is the [column][*][config] part:
https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ColumnsConfig/Index.html
In order to create a select with a page list, you need following kind of configuration.
I would suggest to use "group" type for field.
'page' => [
'exclude' => true,
'label' => 'List of Pages',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'pages',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
]
]

How do I add an Excerpt box to custom post types in functions?

I just want the standard Excerpt box - not a metabox of my own creation, added to a Custom Post. The box shows up in Posts but not in Custom Posts. I've tried both of these older solutions but neither of them worked (maybe it's a WP 3.9 problem):
The custom post type name is "Scoop"
I added this to the register_post_type_scoop() $labels = array
'supports' => array('title','thumbnail','excerpt')
but it didn't work - neither did this:
add_post_type_support('Scoop', 'title');
add_post_type_support('Scoop', array('title', 'thumbnail', 'excerpt') );
Add a index value excerpt to the supports object. Below the example is:
add_action( 'init', 'create_testimonial_posttype' );
function create_testimonial_posttype(){
register_post_type( 'testimonials',
array(
'labels' => array(
'name' => __( 'Testimonials' ),
'singular_name' => __( 'Testimonial' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'clients'),
'supports' => array('title','thumbnail','editor','page-attributes','excerpt'),
)
);
}

Symfony security system, redirect loop (need to access the user in every page)?

I need to access the current user logged in (if any) in any part of the application. Special paths like /admin requires special permissions (roles).
This is the firewall configuration (just one firewall) protecting the entire application but not allowing anonymous users (because I need the current user even in homepage).
I got a redirect loop even requesting /. Any help?
'security.firewalls' => array(
'secured' => array(
'pattern' => '.*',
'anonymous' => false,
'form' => array(
'login_path' => '/login',
'check_path' => '/login_check',
'username_parameter' => 'login[username]',
'password_parameter' => 'login[password]',
),
'logout' => array('logout_path' => '/logout')
)
)
Access rules requires ROLE_ADMIN only for paths starting with /admin . The rest is anonymous:
'security.access_rules' => array(
array('^/admin', 'ROLE_ADMIN'),
array('^.*', 'IS_AUTHENTICATED_ANONYMOUSLY')
),
To allow acces via IS_AUTHENTICATED_ANONYMOUSLY have have to allow anonymous.
'security.firewalls' => array(
'secured' => array(
'pattern' => '/',
'anonymous' => true,
// other stuff
)
)
'security.access_rules' => array(
array('^/admin', 'ROLE_ADMIN'),
array('^/', 'IS_AUTHENTICATED_ANONYMOUSLY')
),
If the user is logged in you can access them in every page. IS_AUTHENTICATED_ANONYMOUSLY is only a role, which have unauthenticated users (anonymous).

Resources