Jump to content
Larry Ullman's Book Forums

Jonathon

Members
  • Posts

    1064
  • Joined

  • Last visited

  • Days Won

    55

Posts posted by Jonathon

  1. Hi Larry,

     

    Just wondered if you planned on using Zend Lucene for this like some older articles you wrote? Second question. If so, are your current articles on it still accurate with changes to Yii or Zend since you wrote them?

     

    Thanks

     

    Jonathon

  2. I may fixed this:

     

     

    protected function afterSave()
    {
    if ($this->user_role_fk == 1) { // standard
     
    if (!Yii::app()->authManager->isAssigned('standardPermissions',$this->id)) {
    Yii::app()->authManager->assign('standardPermissions', $this->id);
    }
     
    } elseif ($this->user_role_fk  == 2) { // moderator
     
    if (!Yii::app()->authManager->isAssigned('editorPermissions',$this->id)) {
    Yii::app()->authManager->assign('editorPermissions', $this->id);
    }
     
    } elseif ($this->user_role_fk  == 3) { // editor
     
    if (!Yii::app()->authManager->isAssigned('moderatorPermissions',$this->id)) {
    Yii::app()->authManager->assign('moderatorPermissions', $this->id);
    } 
    } 
     
    return parent::afterSave();
     
    }
     
    

     

    Does that seem about right?

  3. Ahh ok.

     

    Well I tried it

    protected function afterSave()
    {
     
    if (!Yii::app()->authManager->isAssigned($this->user_role_fk,$this->id)) {
      Yii::app()->authManager->assign($this->user_role_fk, $this->id);
       }
     
    return parent::afterSave();
     
    }
     
    

    And I am getting: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

     

    I have noticed that  CDbCommand->execute(array(":itemname" => "3", ":userid" => "13", ":bizrule" => null, ":data" => "N;"))

     

    :itemName I don't think should be 3.  Shouldn't itemName be the permission name i.e. standardPermissions etc?

     

    The isAssigned() takes the first parameter as the itemName. In my situation I only have the itemNames defined in the `authitem` table. So $this->user_role_fk would only relate the a numerical key in my user table that related to a type of user in my user_role table. 

     

    The user_role table doesn't have the itemName in either. It just has a few roles in it as shown above. 

  4. Hi Larry,

     

    Looking at your code to assign a user. You take

    if ($user->type === 'admin') {
    $auth->assign('admin',$user->id);
    } elseif ($user->type === 'author') {
    $auth->assign('author',$user->id);
    } elseif ($user->type === 'public') {
    $auth->assign('public',$user->id);
    }
     
    

    and condense it to:

    public function afterSave() {
    if(!Yii::app()->authManager->isAssigned(
    $this->type,$this->id)){
    Yii::app()->authManager->assign($this->type,
    $this->id);
    }
    returnparent::afterSave();
    }
     
    

    I was a little unsure as to how to adjust this in the following situation as my table structure is different.

     

    I have a User table and a user_role table, in my user table I have column user_role_fk that relates back the the user_role table.

     

    The user_role table has 2 columns (id, role)

     

    [id - role ]

    1 - standard

    2 - editor

    3 - moderator

     

    And the permissions I created were,

    - standardPermissions

    - editorPersimissions

    - moderatorPermissions.

     

    How would I update your code in my situation?

     

     

    Thanks

     

    Jonathon

  5. Hi Larry,

     

    I have a hopefully not too hard a question. I am updating a Cgridview via Ajax successfully. However before I display this widget I have a small title and use

     

     

    $model->itemCount 

     

    just to display the number of records. When I update I update via Ajax, how do I then update this title with the new number of records (If a user deletes one, or moves a record (I have a cart/wishlist kinda thingy))

     

    Thanks

     

    Jonathon

  6. I like iOS7 style, wasn't too enamoured with Bootstrap 3, just noticed they were different. Not sure my website, I suppose similar to you, maybe slightly sooner. Yeah, i've enjoyed Clistview and CGridview a lot. I need to improve my knoweldge of JS as a whole but around the matter of AJAX in Yii. It's passable at best currently.

  7. Hi Thomas,

     

    Not really, I will have links on several pages that will require a particular type of user to access them. Think of it like this. If eBay had separate logins depending on if you were a buyer or seller and sellers could only list items and buyers could only buy things. Then certain controller actions would only be relevant to certain user types.

     

    For instance item/create could be a controller/action for only the listers as they create the listings.

     

    So on ebay.com. If you click "sell item" at the top and you're not logged in it takes you to login page. 

     

    In my situation it takes me to the default login page. Which in my case was a buyers login.

     

    What I need to do is get yii to recognise that the controller/action item/create would be relevant to the "lister" users and instead when a non-logged in person clicks "sell item" it takes them to the lister login.

  8. Hi Larry / Antonio

     

    There are 2 user groups. 

     

    An example would be a "list item" link on a home page. It's visible to all users logged in or not. However if your not logged in and click the link it takes me to my default login page. Which is for "buyer" users. What I need is for it to take them to the "lister" login.

     

    Hope that makes sense.

     

    Jonathon

  9. Hi Larry,

     

    I have 2 different users as in they have there own login pages/authentication and DB tables. How do I specify a certain action relates to 1 particular user type and therefore when i'm not logged in and I try to access it, it redirects me to their login page rather than the default login page?

     

    For instance:

     

    item/create may be for "lister" user, except if directs me to my default login (which isn't for "listers").

     

    Thanks

     

    Jonathon 

  10. I was reading the docs for the select call http://www.yiiframework.com/doc/api/1.1/CDbCommand#select()-detail

     

    it says:

     

    Columns can be specified in either a string (e.g. "id, name") or an array (e.g. array('id', 'name'))

     

    I've actually done some hybrid version with

     

     

    $cmd->select(array('column1, column2, column3'));
    

     

    Will that be problematic at all?

     

    I can change it, it looked ok in my log. But I wanted to be sure.

     

    Jonathon

  11. Hi

     

    I have a really simple little basket and I put a constraint on the table that stopped a user adding the same item twice. In my create action I have the save method that works fine, but if I try to add an item that is already in the table it returns the CDbException. Which is good.

     

    I was thinking would the exist validator be able to solve this within the model. I wasn't sure how to set it as a "make sure it doesn't exist" kind of thing though.

     

    Jonathon

×
×
  • Create New...