コード例 #1
0
ファイル: feed.php プロジェクト: hemsinfotech/kodelearn
 /**
  * Method to save the streams to be associated to the feed
  * @param array $data
  */
 public function streams($data)
 {
     if (!empty($data['user_id']) && is_array($data['user_id'])) {
         // multiple user ids passed
         $users = $data['user_id'];
         foreach ($users as $user_id) {
             $this->_streams[] = Model_Feedstream::create_if_not_exists(array('user_id' => $user_id));
         }
     } elseif (!empty($data['role_id']) && is_array($data['role_id'])) {
         // if multiple role_ids passed
         $roles = $data['role_id'];
         foreach ($roles as $role_id) {
             $this->_streams[] = Model_Feedstream::create_if_not_exists(array_merge($data, array('role_id' => $role_id)));
         }
     } else {
         // create only one stream with whatever data passed including user_id and role_id
         $this->_streams[] = Model_Feedstream::create_if_not_exists($data);
     }
     return $this;
 }