HABTM with an extra field (saving)

2010-10-09 Thread jwerd
I have an issue where my HABTM save isn't quite working.  I mean it
is, but it's throwing a few notices to Cake, which I'm concerned
about:
Notice (8): Undefined index: id [CORE/cake/libs/model/model.php, line
1391]
Notice (8): Undefined index: id [CORE/cake/libs/model/model.php, line
1329]

I know if I turn off debug, these messages won't show but still, it's
a cause for concern for me.

So I have 3 tables in total...

reviews table:
id
title
(more fields, but irrelevant)

criterias table
id
title
(more fields but irrelevant)

and a joining table, which is HABTM

criteria_review table
criteria_id
review_id
value *

* that's the extra field I'm talking about.

now, in my view code, I copied the way the standard automagic multi-
select named stuff and came up with this:

?php echo $this-Form-input('Criteria.Criteria.'.
$i.'.criteria_id', array('label' = false, 'type'='hidden', 'value'=
$key)); ?
?php echo $this-Form-input('Criteria.Criteria.'.$i.'.value',
array('label' = false, 'type'='select', 'options'=array('1'='1 out
of 5','2'='2 out of 5','3'='3 out of 5','4'='4 out of 5','5'='5
out of 5'))); ?

It saves ok, but it throws those notices up there.  Any ideas on what
I'm doing wrong or what could be causing that?

Or if you have a better way to deal with EXACTLY what I'm going thru,
please, by all means, explain your way.

Thanks,
Jake

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Protect against XSS attacks but keep usual html

2010-10-09 Thread euromark
you might want to type XSS in the little textbox up here besides
Search this group
and hit enter


On 9 Okt., 04:47, huoxito huox...@gmail.com wrote:
 I was wondering if every time I'd display some data I have to Sanatize
 data against XSS attacks?

 And also It seems to me that cakephp Sanitize Component can't sanatize
 against XSS attacs and keep the sytles of a text

 How do you clean your data against XSS and still keep styles in text?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Header already sent error after saving data.

2010-10-09 Thread euromark
not in the view (if it contains HTML)
but that doesnt matter because at this point the spaces are ok!


On 9 Okt., 06:40, Ashwani Kumar ashwani.mail...@gmail.com wrote:
 Thanks a lot for your help.

 You're absolutely right This usually happens if you have ANY character
 printed out before the view actually renders. It can be a single space after
 the closing php tag of a php file (controller, model, ...).

 Actually, I had a lot of space in my model file after closing php tags ?.
 So i removed closing php tag from my model file and it worked just fine.

 So, I've just one think to ask to you that should i skip closing php tag in
 my every controller and model file. and can i also skip in view file 

 Thank you once again...

 On Fri, Oct 8, 2010 at 11:25 PM, euromark dereurom...@googlemail.comwrote:



  This usually happens if you have ANY character printed out before the
  view actually renders. It can be a single space after the closing php
  tag of a php file (controller, model, ...). Therefore you should not
  use ? at the end of php files (CakePHP took the same path in summer
  2010). It prevents this from happening.

  On 8 Okt., 19:23, Ashwani Kumar ashwani.mail...@gmail.com wrote:
   Hi all
      I'm trying to save some data using add() method in cakephp. This is
   add () method :

   function add() {
                           if (!empty($this-data)){
                                   if ($this-Book-save($this-data)) {
                                           $this-Session-setFlash('Data
  has been saved Successfully!',
   true);
                                           $this-redirect(array('action' =
  'index'));
                                   }
                           }
                   }
   Data is getting saved, but i'm getting following error
  onhttp://localhost/data-access/books/addpage.

   Warning (2): Cannot modify header information - headers already sent
   by (output started at C:\webs\test\data-access\models\book.php:8) [CORE
   \cake\libs\controller\controller.php, line 644]

   3 queries took 8 ms Nr  Query   Error   Affected        Num. rows
  Took (ms)
   1       DESCRIBE `books`                5       5       7
   2       INSERT INTO `books` (`isbn`, `title`, `description`,
  `author_name`)
   VALUES ('123', 'test book', 'hi! this is a test.', 'author xyz')
         1               1
   3       SELECT LAST_INSERT_ID() AS insertID             1       1       0

   I'm not a cakephp expert, rather i'm learning cakephp. Any reply will
   be appreciated. Thanks in advanced.

   Ashwani
   ashwani.mail...@gmail.com

  Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
  with their CakePHP related questions.

  You received this message because you are subscribed to the Google Groups
  CakePHP group.
  To post to this group, send email to cake-php@googlegroups.com
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.c 
  omFor more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Header already sent error after saving data.

2010-10-09 Thread Ashwani Kumar
all right thanks. I got a new thing to learn in cakephp,  from you.
Thanks a lot once again.

On 10/9/10, euromark dereurom...@googlemail.com wrote:
 not in the view (if it contains HTML)
 but that doesnt matter because at this point the spaces are ok!


 On 9 Okt., 06:40, Ashwani Kumar ashwani.mail...@gmail.com wrote:
 Thanks a lot for your help.

 You're absolutely right This usually happens if you have ANY character
 printed out before the view actually renders. It can be a single space
 after
 the closing php tag of a php file (controller, model, ...).

 Actually, I had a lot of space in my model file after closing php tags ?.
 So i removed closing php tag from my model file and it worked just fine.

 So, I've just one think to ask to you that should i skip closing php tag
 in
 my every controller and model file. and can i also skip in view file 

 Thank you once again...

 On Fri, Oct 8, 2010 at 11:25 PM, euromark
 dereurom...@googlemail.comwrote:



  This usually happens if you have ANY character printed out before the
  view actually renders. It can be a single space after the closing php
  tag of a php file (controller, model, ...). Therefore you should not
  use ? at the end of php files (CakePHP took the same path in summer
  2010). It prevents this from happening.

  On 8 Okt., 19:23, Ashwani Kumar ashwani.mail...@gmail.com wrote:
   Hi all
      I'm trying to save some data using add() method in cakephp. This is
   add () method :

   function add() {
                           if (!empty($this-data)){
                                   if ($this-Book-save($this-data)) {
                                           $this-Session-setFlash('Data
  has been saved Successfully!',
   true);
                                           $this-redirect(array('action'
   =
  'index'));
                                   }
                           }
                   }
   Data is getting saved, but i'm getting following error
  onhttp://localhost/data-access/books/addpage.

   Warning (2): Cannot modify header information - headers already sent
   by (output started at C:\webs\test\data-access\models\book.php:8)
   [CORE
   \cake\libs\controller\controller.php, line 644]

   3 queries took 8 ms Nr  Query   Error   Affected        Num. rows
  Took (ms)
   1       DESCRIBE `books`                5       5       7
   2       INSERT INTO `books` (`isbn`, `title`, `description`,
  `author_name`)
   VALUES ('123', 'test book', 'hi! this is a test.', 'author xyz')
         1               1
   3       SELECT LAST_INSERT_ID() AS insertID             1       1
     0

   I'm not a cakephp expert, rather i'm learning cakephp. Any reply will
   be appreciated. Thanks in advanced.

   Ashwani
   ashwani.mail...@gmail.com

  Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
  with their CakePHP related questions.

  You received this message because you are subscribed to the Google
  Groups
  CakePHP group.
  To post to this group, send email to cake-php@googlegroups.com
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.c
  omFor more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en

 Check out the new CakePHP Questions site http://cakeqs.org and help others
 with their CakePHP related questions.

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Even though $primaryKey is specified, I still get an error

2010-10-09 Thread Dan
Here is the code:

?php
class RalliesController extends AppController {

var $name = 'Rallies';
var $primaryKey = 'rally_id';

function manage($id=0) {
$this-Rally-id = $id;
$this-set('rally', $this-Rally-read());
}
}
?

Even though I've specified the primaryKey variable, I still get an
error due to the where clause looking for the field name id rather
than rally_id.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Duplicate Record Insert

2010-10-09 Thread Richard1328
I have a table with a unique index present in the table.  What is the
best method for preventing insertion of a duplicated record?
Currently I have code similar to:

if( !$this-Thing-save( $this-data ) )
{
  $this-Session-setFlash(__('The thing was not saved. Please, try
again.', true));
}

How would I say, if save() failed, but it failed because of a
duplicate, then there is not an error?

Also, is this the best way of handling duplicate record  inserts?  Is
there a better way, for instance using the model or some other method?

Thanks

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Duplicate Record Insert

2010-10-09 Thread euromark
use validation rules:
http://book.cakephp.org/view/472/isUnique


On 8 Okt., 23:43, Richard1328 reppe...@gmail.com wrote:
 I have a table with a unique index present in the table.  What is the
 best method for preventing insertion of a duplicated record?
 Currently I have code similar to:

 if( !$this-Thing-save( $this-data ) )
 {
   $this-Session-setFlash(__('The thing was not saved. Please, try
 again.', true));

 }

 How would I say, if save() failed, but it failed because of a
 duplicate, then there is not an error?

 Also, is this the best way of handling duplicate record  inserts?  Is
 there a better way, for instance using the model or some other method?

 Thanks

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Convert Text to Images to Protect your Email from Search

2010-10-09 Thread hoss7
i am create this test code:
?php
function CenterImageString($image, $image_width, $string, $font_size,
$y, $color)
 {
 $text_width = imagefontwidth($font_size)*strlen($string);
 $center = ceil($image_width / 2);
 $x = $center - (ceil($text_width/2));
 $bgColor = imagecolorallocate($image, 255, 255, 255);
$txtColor = imagecolorallocate($image, 0, 0, 0);
imagestring($image, $font_size, $x, $y,  $string, $txtColor);
 }
?
?php
header(Content-type: image/png);
$picture = imagecreate(200,80);
$black = ImageColorAllocate ($picture, 255, 255, 255);
CenterImageString($picture, 100, test, 2, 45, $black);
ImagePng ($picture);
?

but i cant convert to cakephp helper,please help me

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Convert Text to Images to Protect your Email from Search

2010-10-09 Thread euromark
did you even try?

On 9 Okt., 17:55, hoss7 hoss...@gmail.com wrote:
 i am create this test code:
 ?php
 function CenterImageString($image, $image_width, $string, $font_size,
 $y, $color)
  {
  $text_width = imagefontwidth($font_size)*strlen($string);
  $center = ceil($image_width / 2);
  $x = $center - (ceil($text_width/2));
  $bgColor = imagecolorallocate($image, 255, 255, 255);
 $txtColor = imagecolorallocate($image, 0, 0, 0);
 imagestring($image, $font_size, $x, $y,  $string, $txtColor);
  }
 ?
 ?php
 header(Content-type: image/png);
 $picture = imagecreate(200,80);
 $black = ImageColorAllocate ($picture, 255, 255, 255);
 CenterImageString($picture, 100, test, 2, 45, $black);
 ImagePng ($picture);
 ?

 but i cant convert to cakephp helper,please help me

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Problem with hasOne Relation

2010-10-09 Thread cricket
On Fri, Oct 8, 2010 at 1:41 PM, Raphi panicr...@t-online.de wrote:
 Ok let me try to explain.

 I have two tables involved: users, user_profiles

 Of course there is a model-file to any of the tables so: user.php,
 user_profile.php
 The models are linked via a hasOne(parent key user_id) relationship.
 (which is working perfectly).

 But now I want to implement a method that gives users the possibility
 to alter their own profiles. Therefore I created an editProfile
 method in the UsersController and a corresponding view-file
 edit_profile.ctp in views/users.

 Within this view-file I created a form using the formhelper:

    echo $form-create('UserProfile');
    echo $form-input('id');
    echo $form-input('name');
    echo $form-end('Save changes');

 That is great because creating the form using $form-
create('UserProfile'); makes it automatically fill in the values
 from the database. My problem occurs when it comes to submitting the
 form. Cake recognizes the UserProfile model and tries to use the
 UserProfileController which does not exist. I want to use the
 UsersController to do that job. I mean I know I could use $form-
create('User'); in order to get it working but that makes it
 impossible for cake to fill out the form automatically. I don't really
 get why using the User model doesn't work. For there is an existing
 relationship the User model should be able to pass on the
 user_profiles datas.


First, the reason why you ended up with form controller=users is
because you gave 'controller' as an aoption. You can do this, but not
the way that you did. The method takes a model name, plus an array of
options. The ones we're interested in are 'action' and 'url'. The
latter one takes as a value an array and it's in that array that you'd
supply 'controller'. So you had 'controller' one level up. Make sense?

Anyway, so you have a UserProfile model and table but you want to do
the action in UsersController. You can either get rid UserProfile
altogether and put all of its data in users table or you can do
something like:

echo $this-Form-create('UserProfile', array('url' =
array('controller' = 'users', 'action' = 'editProfile'));
echo $this-Form-hidden('UserProfile.user_id');

Or, you can leave out user_id and add it to $this-data in the action,
using $this-Session-user('id'); That way, there's no chance that
someone can fiddle with the form element values.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Strange behaviour with saveAll referring to hasOnes....

2010-10-09 Thread cricket
On Fri, Oct 8, 2010 at 2:07 PM, DerBjörn b.unkh...@googlemail.com wrote:
 @cricket:

 Nope, doesn't work. Thanks for your suggestion anyway.
 Generally if you use saveAll() you doesn't need a create(). This only
 is necessary for the normal save().

 So i am still looking for a solution! :) Thanks...


OK, just the first thing that came to mind. But I just looked at it
again and realised that your data array is missing some foreign keys.
The SkillPool and StrokePool arrays should include a player_id value,
I believe.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: FileUpload behavior and multiple models

2010-10-09 Thread cricket
On Thu, Oct 7, 2010 at 4:43 PM, Deek rdiek...@gmail.com wrote:
 In order to get around this issue of having multiple models using the
 FileUpload.FileUpload behavior I did the following:

 created two additional behavior files:

 private_file_upload.php and public_file_upload.php in /app/plugins/
 file_upload/models/behaviors

 containing the following code respectively:

 ?php

 App::Import('Behavior','FileUpload.file_upload');

 class PrivateFileUploadBehavior extends FileUploadBehavior {

 }
 ?

 ?php

 App::Import('Behavior','FileUpload.file_upload');

 class PublicFileUploadBehavior extends FileUploadBehavior {

 }
 ?

 then in the model configurations I changed

 var $actsAs = array(
       'FileUpload.FileUpload'

 to

 var $actsAs = array(
       'FileUpload.PrivateFileUpload'

 and

 var $actsAs = array(
       'FileUpload.PublicFileUpload'


 This has allowed me to use two separate configurations for each upload
 type, you can probably use this same method, just create separate
 behavior files to extend the base FileUpload for each different
 configuration you want to have.

I'm using my own modified version of the plugin, and for the same
reason. Some files need to be above webroot and some not.. And many
should be in separate directories based on User.id and so on, so I
need to change directories on the fly. But my approach was to edit the
component, as well as  plugins/file_upload/vendors/uploader.php

In the component:

 /**
* base path to append upload dir to
*
* @var string
* @access public
*/
var $base_path = WWW_ROOT;

Then, all instances of WWW_ROOT should be changed to $this-base_path.

New method:

/**
 * change upload directory path
 *
 * @param   string  $path   the new upload path
 * @return  void
 * @access  public
 */
public function changeDir($path)
{
$this-options['uploadDir'] = $path;
$this-Uploader-options['uploadDir'] = $this-base_path . $path;
}


In uploader.php, processFile() method:

//make sure the file doesn't already exist, if it does, add an itteration to it
$up_dir = $this-options['uploadDir'];

/* added by me
*/
if (!is_dir($up_dir))
{
if (!mkdir($up_dir, 0775, true))
{
$this-_error('Uploader::processFile() - Unable to create 
directory:
' . $up_dir);
return false;
}
}


I then set model to null in the config. My controllers have a
protected method _handleUpload() which is called when the component
detcts an upload:

GalleriesController::addImage

if (!empty($this-data))
{   
if ($this-FileUpload-hasFile)
{
if ($image_id = $this-_handleUpload())
{
$this-flash(
'Image uploaded successfully',
array('controller' = 'galleries', 'action' = 
'view', 'id' = $gallery_id)
);
}
}
else if (sizeof($this-FileUpload-errors))
{
$this-set('errors', $this-FileUpload-errors);
}

}


protected function _handleUpload()
{
/* clean file names up a bit
 */
$file_var = $this-FileUpload-options['fileVar'];

foreach($this-FileUpload-uploadedFiles as $key = $file)
{
$ext = strrchr($this-FileUpload-uploadedFiles[$key]['name'], 
'.');
$name = 
basename($this-FileUpload-uploadedFiles[$key]['name'], $ext);
$this-FileUpload-uploadedFiles[$key]['name'] =
Inflector::slug(strtolower($name)) . strtolower($ext);
}

/* first set $this-FileUpload-base_path to APP if required to be
above WWW_ROOT
 */
$this-FileUpload-changeDir('files/galleries/' .
$this-data['Gallery']['member_id']);

/* move the files to proper directory
 */
$this-FileUpload-processAllFiles();

if ($this-FileUpload-success)
{
foreach($this-FileUpload-finalFiles as $k = $v)
{
$path = $this-FileUpload-options['uploadDir'] . DS .
$this-FileUpload-finalFiles[$k];

// re-size image, create thumbnails, save info to db ...
}
}

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Convert Text to Images to Protect your Email from Search

2010-10-09 Thread cricket
On Fri, Oct 8, 2010 at 4:39 AM, hoss7 hoss...@gmail.com wrote:
 i need some helper for convert email to image,
 i am new in cakephp.

 Check out the new CakePHP Questions site http://cakeqs.org and help others 
 with their CakePHP related questions.

 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/cake-php?hl=en


I wouldn't bother with doing all that.

app/config/bootstrap.php:

/**
 * Wrap an email address in a formatted span tag in such a way
 * as to allow for easy javascript translation to a normal mailto: link.
 *
 * this:
 * f...@bar.net, 'email foo!', 'some title text'
 * becomes:
 * span class=Obfuscated title=some title textemail foo! [ foo
AT bar DOT net ]/span
 *
 * @param   string  address email address
 * @param   string  textlink text
 * @param   string  title   link title
 * @return  string  obfuscated address, wrapped in i span 
tag
 **/
function obfuscateEmail($address, $text= null, $title = null, $subject = null)
{
if (empty($address)) return null;

$regexp = 
'^[_a-z0-9-]+(\.[_a-z0-9-]+)*...@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$';
$search = Array('@', '.');
$replace = Array(' AT ', ' DOT ');
$class = 'Obfuscated';

if (is_string($address)  eregi($regexp, $address))
{
$obfuscated = str_replace($search, $replace, $address);

if (!is_null($subject))
{
$title .= |${subject};
}

return 'span class='.$class.' 
title='.$title.''.trim(${text}
[ ${obfuscated} ]).'/span';
}
return $address;
}

app/webroot/js/global.js (jquery):

$(function()
{
...

/* Obfuscated email addresses. See bootstrap.php
 */
$('.Obfuscated').each(deObfuscateEmail);

...
});

/**
 * De-obfuscate printed email addresses which are of the type:
 *
 * span class=Obfuscated title=some title
 * some link text [ someone AT gmail DOT com ]
 * span
 *
 * The braces around the address part are hard-wired here; probably shouldn't be
 **/
function deObfuscateEmail(i)
{   
var content = $(this).text();

/* grab the part inside the braces, swap out placeholders, and trim
 */
var obfuscated = content.match(/\[(.*)\]/);

var address = obfuscated[1]
.replace(' AT ', '@')
.replace(new RegExp(' DOT ', 'g'), '.')
.replace(/^\s+|\s+$/g, '');

/* get everything before the braces and trim
 */
var text = content.match(/.?[^[]+/);

text = (text[0] != content)
? text[0].replace(/^\s+|\s+$/g, '')
: address;  // if there's no text part, use the address

var title = $(this).attr('title') || '';

/* subject may be concatenated with title
 */
if (title.indexOf('|') = 0)
{
var parts = title.split('|');
title = parts[0];
address += '?subject=' + parts[1];
}

$(this).replaceWith($('a href=mailto:' + address + ' title=' +
title + '' + text + '/a'));
}

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Type of association?

2010-10-09 Thread jwerd
I have table that needs to store two foreign keys and an extra param
that will just be a value associated.

So I have a joining table:

fk_id
fk2_id
value

fk is just an example, it's to indicate it comes from another table
that will have other fields like name or title or whatever.

what kind of association am I creating to tables fk and fk2?

Thanks in advance.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Type of association?

2010-10-09 Thread jwerd
Cake thinks it's a HABTM association but I can't get it to save an
extra param when it runs the save operation.

On Oct 9, 4:45 pm, jwerd lamerh...@gmail.com wrote:
 I have table that needs to store two foreign keys and an extra param
 that will just be a value associated.

 So I have a joining table:

 fk_id
 fk2_id
 value

 fk is just an example, it's to indicate it comes from another table
 that will have other fields like name or title or whatever.

 what kind of association am I creating to tables fk and fk2?

 Thanks in advance.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: HABTM with an extra field (saving)

2010-10-09 Thread Jamie
Your HABTM join table needs a primary key, namely id. That's what
the model code is searching for and not finding.

-Jamie

On Oct 8, 11:31 pm, jwerd lamerh...@gmail.com wrote:
 I have an issue where my HABTM save isn't quite working.  I mean it
 is, but it's throwing a few notices to Cake, which I'm concerned
 about:
 Notice (8): Undefined index: id [CORE/cake/libs/model/model.php, line
 1391]
 Notice (8): Undefined index: id [CORE/cake/libs/model/model.php, line
 1329]

 I know if I turn off debug, these messages won't show but still, it's
 a cause for concern for me.

 So I have 3 tables in total...

 reviews table:
 id
 title
 (more fields, but irrelevant)

 criterias table
 id
 title
 (more fields but irrelevant)

 and a joining table, which is HABTM

 criteria_review table
 criteria_id
 review_id
 value *

 * that's the extra field I'm talking about.

 now, in my view code, I copied the way the standard automagic multi-
 select named stuff and came up with this:

                 ?php echo $this-Form-input('Criteria.Criteria.'.
 $i.'.criteria_id', array('label' = false, 'type'='hidden', 'value'=
 $key)); ?
                 ?php echo 
 $this-Form-input('Criteria.Criteria.'.$i.'.value',
 array('label' = false, 'type'='select', 'options'=array('1'='1 out
 of 5','2'='2 out of 5','3'='3 out of 5','4'='4 out of 5','5'='5
 out of 5'))); ?

 It saves ok, but it throws those notices up there.  Any ideas on what
 I'm doing wrong or what could be causing that?

 Or if you have a better way to deal with EXACTLY what I'm going thru,
 please, by all means, explain your way.

 Thanks,
 Jake

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en